xref: /AOO41X/main/sd/source/ui/func/fuoltext.cxx (revision 5b1900111deff329a5580f97b99b67a25168e53d)
1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5b190011SAndrew Rist  * distributed with this work for additional information
6*5b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist  * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*5b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*5b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist  * software distributed under the License is distributed on an
15*5b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5b190011SAndrew Rist  * specific language governing permissions and limitations
18*5b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*5b190011SAndrew Rist  *************************************************************/
21*5b190011SAndrew Rist 
22*5b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "fuoltext.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
31cdf0e10cSrcweir #include <editeng/outliner.hxx>
32cdf0e10cSrcweir #include <editeng/eeitem.hxx>
33cdf0e10cSrcweir #include <editeng/flditem.hxx>
34cdf0e10cSrcweir #include <sfx2/bindings.hxx>
35cdf0e10cSrcweir #include <sfx2/docfile.hxx>
36cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <svx/svxids.hrc>
39cdf0e10cSrcweir #include "app.hrc"
40cdf0e10cSrcweir #include "OutlineView.hxx"
41cdf0e10cSrcweir #ifndef SD_WINDOW_SHELL_HXX
42cdf0e10cSrcweir #include "Window.hxx"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #include "DrawDocShell.hxx"
45cdf0e10cSrcweir #include "ViewShell.hxx"
46cdf0e10cSrcweir #include "OutlineViewShell.hxx"
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include <stdio.h>          // Fuer SlotFilter-Listing
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace sd {
51cdf0e10cSrcweir 
52cdf0e10cSrcweir static sal_uInt16 SidArray[] = {
53cdf0e10cSrcweir 				SID_STYLE_FAMILY2,
54cdf0e10cSrcweir 				SID_STYLE_FAMILY3,
55cdf0e10cSrcweir 				SID_STYLE_FAMILY5,
56cdf0e10cSrcweir 				SID_STYLE_UPDATE_BY_EXAMPLE,
57cdf0e10cSrcweir 				SID_CUT,
58cdf0e10cSrcweir 				SID_COPY,
59cdf0e10cSrcweir 				SID_PASTE,
60cdf0e10cSrcweir 				SID_SELECTALL,
61cdf0e10cSrcweir 				SID_ATTR_CHAR_FONT,
62cdf0e10cSrcweir 				SID_ATTR_CHAR_POSTURE,
63cdf0e10cSrcweir 				SID_ATTR_CHAR_WEIGHT,
64cdf0e10cSrcweir 				SID_ATTR_CHAR_UNDERLINE,
65cdf0e10cSrcweir 				SID_ATTR_CHAR_FONTHEIGHT,
66cdf0e10cSrcweir 				SID_ATTR_CHAR_COLOR,
67cdf0e10cSrcweir 				SID_OUTLINE_UP,
68cdf0e10cSrcweir 				SID_OUTLINE_DOWN,
69cdf0e10cSrcweir 				SID_OUTLINE_LEFT,
70cdf0e10cSrcweir 				SID_OUTLINE_RIGHT,
71cdf0e10cSrcweir 				//SID_OUTLINE_FORMAT,
72cdf0e10cSrcweir 				SID_OUTLINE_COLLAPSE_ALL,
73cdf0e10cSrcweir 				//SID_OUTLINE_BULLET,
74cdf0e10cSrcweir 				SID_OUTLINE_COLLAPSE,
75cdf0e10cSrcweir 				SID_OUTLINE_EXPAND_ALL,
76cdf0e10cSrcweir 				SID_OUTLINE_EXPAND,
77cdf0e10cSrcweir 				SID_SET_SUPER_SCRIPT,
78cdf0e10cSrcweir 				SID_SET_SUB_SCRIPT,
79cdf0e10cSrcweir 				SID_HYPERLINK_GETLINK,
80cdf0e10cSrcweir 				SID_PRESENTATION_TEMPLATES,
81cdf0e10cSrcweir 				SID_STATUS_PAGE,
82cdf0e10cSrcweir 				SID_STATUS_LAYOUT,
83cdf0e10cSrcweir 				SID_EXPAND_PAGE,
84cdf0e10cSrcweir 				SID_SUMMARY_PAGE,
85cdf0e10cSrcweir 				SID_PARASPACE_INCREASE,
86cdf0e10cSrcweir 				SID_PARASPACE_DECREASE,
87cdf0e10cSrcweir 				0 };
88cdf0e10cSrcweir 
89cdf0e10cSrcweir TYPEINIT1( FuOutlineText, FuOutline );
90cdf0e10cSrcweir 
91cdf0e10cSrcweir /*************************************************************************
92cdf0e10cSrcweir |*
93cdf0e10cSrcweir |* Konstruktor
94cdf0e10cSrcweir |*
95cdf0e10cSrcweir \************************************************************************/
96cdf0e10cSrcweir 
97cdf0e10cSrcweir FuOutlineText::FuOutlineText(ViewShell* pViewShell, ::sd::Window* pWindow,
98cdf0e10cSrcweir 							 ::sd::View* pView, SdDrawDocument* pDoc,
99cdf0e10cSrcweir 							 SfxRequest& rReq)
100cdf0e10cSrcweir 	   : FuOutline(pViewShell, pWindow, pView, pDoc, rReq)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir FunctionReference FuOutlineText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	FunctionReference xFunc( new FuOutlineText( pViewSh, pWin, pView, pDoc, rReq ) );
107cdf0e10cSrcweir 	xFunc->DoExecute( rReq );
108cdf0e10cSrcweir 	return xFunc;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir /*************************************************************************
112cdf0e10cSrcweir |*
113cdf0e10cSrcweir |* MouseButtonDown-event
114cdf0e10cSrcweir |*
115cdf0e10cSrcweir \************************************************************************/
116cdf0e10cSrcweir 
117cdf0e10cSrcweir sal_Bool FuOutlineText::MouseButtonDown(const MouseEvent& rMEvt)
118cdf0e10cSrcweir {
119cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	mpWindow->GrabFocus();
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonDown(rMEvt);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	if (bReturn)
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir 		// Attributierung der akt. Textstelle kann jetzt anders sein
128cdf0e10cSrcweir 		mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
129cdf0e10cSrcweir 	}
130cdf0e10cSrcweir 	else
131cdf0e10cSrcweir 	{
132cdf0e10cSrcweir 		bReturn = FuOutline::MouseButtonDown(rMEvt);
133cdf0e10cSrcweir 	}
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	return (bReturn);
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir /*************************************************************************
139cdf0e10cSrcweir |*
140cdf0e10cSrcweir |* MouseMove-event
141cdf0e10cSrcweir |*
142cdf0e10cSrcweir \************************************************************************/
143cdf0e10cSrcweir 
144cdf0e10cSrcweir sal_Bool FuOutlineText::MouseMove(const MouseEvent& rMEvt)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseMove(rMEvt);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	if (!bReturn)
151cdf0e10cSrcweir 	{
152cdf0e10cSrcweir 		bReturn = FuOutline::MouseMove(rMEvt);
153cdf0e10cSrcweir 	}
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     // MT 07/2002: Done in OutlinerView::MouseMove
156cdf0e10cSrcweir     /*
157cdf0e10cSrcweir 	const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->
158cdf0e10cSrcweir 										GetFieldUnderMousePointer();
159cdf0e10cSrcweir 	const SvxFieldData* pField = NULL;
160cdf0e10cSrcweir 	if( pFieldItem )
161cdf0e10cSrcweir 		pField = pFieldItem->GetField();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	if( pField && pField->ISA( SvxURLField ) )
164cdf0e10cSrcweir 	{
165cdf0e10cSrcweir 	   mpWindow->SetPointer( Pointer( POINTER_REFHAND ) );
166cdf0e10cSrcweir 	}
167cdf0e10cSrcweir 	else
168cdf0e10cSrcweir 	   mpWindow->SetPointer( Pointer( POINTER_TEXT ) );
169cdf0e10cSrcweir     */
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	return (bReturn);
172cdf0e10cSrcweir }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir /*************************************************************************
175cdf0e10cSrcweir |*
176cdf0e10cSrcweir |* MouseButtonUp-event
177cdf0e10cSrcweir |*
178cdf0e10cSrcweir \************************************************************************/
179cdf0e10cSrcweir 
180cdf0e10cSrcweir sal_Bool FuOutlineText::MouseButtonUp(const MouseEvent& rMEvt)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 	bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonUp(rMEvt);
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 	if (bReturn)
187cdf0e10cSrcweir 	{
188cdf0e10cSrcweir 		// Attributierung der akt. Textstelle kann jetzt anders sein
189cdf0e10cSrcweir 		mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
190cdf0e10cSrcweir 	}
191cdf0e10cSrcweir 	else
192cdf0e10cSrcweir 	{
193cdf0e10cSrcweir 		const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->GetFieldUnderMousePointer();
194cdf0e10cSrcweir 		if( pFieldItem )
195cdf0e10cSrcweir 		{
196cdf0e10cSrcweir 			const SvxFieldData* pField = pFieldItem->GetField();
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 			if( pField && pField->ISA( SvxURLField ) )
199cdf0e10cSrcweir 			{
200cdf0e10cSrcweir 				bReturn = sal_True;
201cdf0e10cSrcweir 	            mpWindow->ReleaseMouse();
202cdf0e10cSrcweir                 SfxStringItem aStrItem( SID_FILE_NAME, ( (SvxURLField*) pField)->GetURL() );
203cdf0e10cSrcweir                 SfxStringItem aReferer( SID_REFERER, mpDocSh->GetMedium()->GetName() );
204cdf0e10cSrcweir                 SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
205cdf0e10cSrcweir                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 				if ( rMEvt.IsMod1() )
208cdf0e10cSrcweir 				{
209cdf0e10cSrcweir 					// Im neuen Frame oeffnen
210cdf0e10cSrcweir                 	pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
211cdf0e10cSrcweir                     		    &aStrItem, &aBrowseItem, &aReferer, 0L);
212cdf0e10cSrcweir 				}
213cdf0e10cSrcweir 				else
214cdf0e10cSrcweir 				{
215cdf0e10cSrcweir 					// Im aktuellen Frame oeffnen
216cdf0e10cSrcweir 					SfxFrameItem aFrameItem( SID_DOCFRAME, pFrame );
217cdf0e10cSrcweir                 	pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
218cdf0e10cSrcweir                     		    &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
219cdf0e10cSrcweir 				}
220cdf0e10cSrcweir 			}
221cdf0e10cSrcweir 		}
222cdf0e10cSrcweir 	}
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	if( !bReturn )
225cdf0e10cSrcweir 		bReturn = FuOutline::MouseButtonUp(rMEvt);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	return (bReturn);
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir /*************************************************************************
231cdf0e10cSrcweir |*
232cdf0e10cSrcweir |* Tastaturereignisse bearbeiten
233cdf0e10cSrcweir |*
234cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
235cdf0e10cSrcweir |* sal_False.
236cdf0e10cSrcweir |*
237cdf0e10cSrcweir \************************************************************************/
238cdf0e10cSrcweir 
239cdf0e10cSrcweir sal_Bool FuOutlineText::KeyInput(const KeyEvent& rKEvt)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 	sal_uInt16 nKeyGroup = rKEvt.GetKeyCode().GetGroup();
244cdf0e10cSrcweir 	if( !mpDocSh->IsReadOnly() || nKeyGroup == KEYGROUP_CURSOR )
245cdf0e10cSrcweir 	{
246cdf0e10cSrcweir 		mpWindow->GrabFocus();
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 		std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 		if( (nKeyGroup != KEYGROUP_CURSOR) && (nKeyGroup != KEYGROUP_FKEYS) )
251cdf0e10cSrcweir 			aGuard.reset( new OutlineViewModelChangeGuard( *pOutlineView ) );
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 		bReturn = pOutlineView->GetViewByWindow(mpWindow)->PostKeyEvent(rKEvt);
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 		if (bReturn)
256cdf0e10cSrcweir 		{
257cdf0e10cSrcweir             UpdateForKeyPress (rKEvt);
258cdf0e10cSrcweir 		}
259cdf0e10cSrcweir 		else
260cdf0e10cSrcweir 		{
261cdf0e10cSrcweir 			bReturn = FuOutline::KeyInput(rKEvt);
262cdf0e10cSrcweir 		}
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 	return (bReturn);
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir void FuOutlineText::UpdateForKeyPress (const KeyEvent& rEvent)
269cdf0e10cSrcweir {
270cdf0e10cSrcweir     // Attributes at the current text position may have changed.
271cdf0e10cSrcweir     mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     bool bUpdatePreview = true;
274cdf0e10cSrcweir     switch (rEvent.GetKeyCode().GetCode())
275cdf0e10cSrcweir     {
276cdf0e10cSrcweir         // When just the cursor has been moved the preview only changes when
277cdf0e10cSrcweir         // it moved to entries of another page.  To prevent unnecessary
278cdf0e10cSrcweir         // updates we check this here.  This is an early rejection test, so
279cdf0e10cSrcweir         // missing a key is not a problem.
280cdf0e10cSrcweir         case KEY_UP:
281cdf0e10cSrcweir         case KEY_DOWN:
282cdf0e10cSrcweir         case KEY_LEFT:
283cdf0e10cSrcweir         case KEY_RIGHT:
284cdf0e10cSrcweir         case KEY_HOME:
285cdf0e10cSrcweir         case KEY_END:
286cdf0e10cSrcweir         case KEY_PAGEUP:
287cdf0e10cSrcweir         case KEY_PAGEDOWN:
288cdf0e10cSrcweir         {
289cdf0e10cSrcweir             SdPage* pCurrentPage = pOutlineViewShell->GetActualPage();
290cdf0e10cSrcweir             bUpdatePreview = (pCurrentPage != pOutlineViewShell->GetActualPage());
291cdf0e10cSrcweir         }
292cdf0e10cSrcweir         break;
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir     if (bUpdatePreview)
295cdf0e10cSrcweir         pOutlineViewShell->UpdatePreview (pOutlineViewShell->GetActualPage());
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 
301cdf0e10cSrcweir /*************************************************************************
302cdf0e10cSrcweir |*
303cdf0e10cSrcweir |* Function aktivieren
304cdf0e10cSrcweir |*
305cdf0e10cSrcweir \************************************************************************/
306cdf0e10cSrcweir 
307cdf0e10cSrcweir void FuOutlineText::Activate()
308cdf0e10cSrcweir {
309cdf0e10cSrcweir 	FuOutline::Activate();
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir /*************************************************************************
313cdf0e10cSrcweir |*
314cdf0e10cSrcweir |* Function deaktivieren
315cdf0e10cSrcweir |*
316cdf0e10cSrcweir \************************************************************************/
317cdf0e10cSrcweir 
318cdf0e10cSrcweir void FuOutlineText::Deactivate()
319cdf0e10cSrcweir {
320cdf0e10cSrcweir 	FuOutline::Deactivate();
321cdf0e10cSrcweir }
322cdf0e10cSrcweir 
323cdf0e10cSrcweir /*************************************************************************
324cdf0e10cSrcweir |*
325cdf0e10cSrcweir |* Cut object to clipboard
326cdf0e10cSrcweir |*
327cdf0e10cSrcweir \************************************************************************/
328cdf0e10cSrcweir 
329cdf0e10cSrcweir void FuOutlineText::DoCut()
330cdf0e10cSrcweir {
331cdf0e10cSrcweir 	pOutlineView->GetViewByWindow(mpWindow)->Cut();
332cdf0e10cSrcweir }
333cdf0e10cSrcweir 
334cdf0e10cSrcweir /*************************************************************************
335cdf0e10cSrcweir |*
336cdf0e10cSrcweir |* Copy object to clipboard
337cdf0e10cSrcweir |*
338cdf0e10cSrcweir \************************************************************************/
339cdf0e10cSrcweir 
340cdf0e10cSrcweir void FuOutlineText::DoCopy()
341cdf0e10cSrcweir {
342cdf0e10cSrcweir 	pOutlineView->GetViewByWindow(mpWindow)->Copy();
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
345cdf0e10cSrcweir /*************************************************************************
346cdf0e10cSrcweir |*
347cdf0e10cSrcweir |* Paste object from clipboard
348cdf0e10cSrcweir |*
349cdf0e10cSrcweir \************************************************************************/
350cdf0e10cSrcweir 
351cdf0e10cSrcweir void FuOutlineText::DoPaste()
352cdf0e10cSrcweir {
353cdf0e10cSrcweir 	pOutlineView->GetViewByWindow(mpWindow)->PasteSpecial();
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 
357cdf0e10cSrcweir } // end of namespace sd
358