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