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