xref: /AOO41X/main/sd/source/ui/func/fuoltext.cxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
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_SHADOWED,
65                 SID_ATTR_CHAR_STRIKEOUT,
66                 SID_ATTR_CHAR_UNDERLINE,
67                 SID_ATTR_CHAR_FONTHEIGHT,
68                 SID_ATTR_CHAR_COLOR,
69                 SID_ATTR_CHAR_KERNING,
70                 SID_OUTLINE_UP,
71                 SID_OUTLINE_DOWN,
72                 SID_OUTLINE_LEFT,
73                 SID_OUTLINE_RIGHT,
74                 //SID_OUTLINE_FORMAT,
75                 SID_OUTLINE_COLLAPSE_ALL,
76                 //SID_OUTLINE_BULLET,
77                 SID_OUTLINE_COLLAPSE,
78                 SID_OUTLINE_EXPAND_ALL,
79                 SID_OUTLINE_EXPAND,
80                 SID_SET_SUPER_SCRIPT,
81                 SID_SET_SUB_SCRIPT,
82                 SID_HYPERLINK_GETLINK,
83                 SID_PRESENTATION_TEMPLATES,
84                 SID_STATUS_PAGE,
85                 SID_STATUS_LAYOUT,
86                 SID_EXPAND_PAGE,
87                 SID_SUMMARY_PAGE,
88                 SID_PARASPACE_INCREASE,
89                 SID_PARASPACE_DECREASE,
90                 0 };
91 
92 TYPEINIT1( FuOutlineText, FuOutline );
93 
94 /*************************************************************************
95 |*
96 |* Konstruktor
97 |*
98 \************************************************************************/
99 
FuOutlineText(ViewShell * pViewShell,::sd::Window * pWindow,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)100 FuOutlineText::FuOutlineText(ViewShell* pViewShell, ::sd::Window* pWindow,
101                              ::sd::View* pView, SdDrawDocument* pDoc,
102                              SfxRequest& rReq)
103        : FuOutline(pViewShell, pWindow, pView, pDoc, rReq)
104 {
105 }
106 
Create(ViewShell * pViewSh,::sd::Window * pWin,::sd::View * pView,SdDrawDocument * pDoc,SfxRequest & rReq)107 FunctionReference FuOutlineText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
108 {
109     FunctionReference xFunc( new FuOutlineText( pViewSh, pWin, pView, pDoc, rReq ) );
110     xFunc->DoExecute( rReq );
111     return xFunc;
112 }
113 
114 /*************************************************************************
115 |*
116 |* MouseButtonDown-event
117 |*
118 \************************************************************************/
119 
MouseButtonDown(const MouseEvent & rMEvt)120 sal_Bool FuOutlineText::MouseButtonDown(const MouseEvent& rMEvt)
121 {
122     sal_Bool bReturn = sal_False;
123 
124     mpWindow->GrabFocus();
125 
126     bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonDown(rMEvt);
127 
128     if (bReturn)
129     {
130         // Attributierung der akt. Textstelle kann jetzt anders sein
131         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
132     }
133     else
134     {
135         bReturn = FuOutline::MouseButtonDown(rMEvt);
136     }
137 
138     return (bReturn);
139 }
140 
141 /*************************************************************************
142 |*
143 |* MouseMove-event
144 |*
145 \************************************************************************/
146 
MouseMove(const MouseEvent & rMEvt)147 sal_Bool FuOutlineText::MouseMove(const MouseEvent& rMEvt)
148 {
149     sal_Bool bReturn = sal_False;
150 
151     bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseMove(rMEvt);
152 
153     if (!bReturn)
154     {
155         bReturn = FuOutline::MouseMove(rMEvt);
156     }
157 
158     // MT 07/2002: Done in OutlinerView::MouseMove
159     /*
160     const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->
161                                         GetFieldUnderMousePointer();
162     const SvxFieldData* pField = NULL;
163     if( pFieldItem )
164         pField = pFieldItem->GetField();
165 
166     if( pField && pField->ISA( SvxURLField ) )
167     {
168        mpWindow->SetPointer( Pointer( POINTER_REFHAND ) );
169     }
170     else
171        mpWindow->SetPointer( Pointer( POINTER_TEXT ) );
172     */
173 
174     return (bReturn);
175 }
176 
177 /*************************************************************************
178 |*
179 |* MouseButtonUp-event
180 |*
181 \************************************************************************/
182 
MouseButtonUp(const MouseEvent & rMEvt)183 sal_Bool FuOutlineText::MouseButtonUp(const MouseEvent& rMEvt)
184 {
185     sal_Bool bReturn = sal_False;
186 
187     bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonUp(rMEvt);
188 
189     if (bReturn)
190     {
191         // Attributierung der akt. Textstelle kann jetzt anders sein
192         mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
193     }
194     else
195     {
196         const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->GetFieldUnderMousePointer();
197         if( pFieldItem )
198         {
199             const SvxFieldData* pField = pFieldItem->GetField();
200 
201             if( pField && pField->ISA( SvxURLField ) )
202             {
203                 bReturn = sal_True;
204                 mpWindow->ReleaseMouse();
205                 SfxStringItem aStrItem( SID_FILE_NAME, ( (SvxURLField*) pField)->GetURL() );
206                 SfxStringItem aReferer( SID_REFERER, mpDocSh->GetMedium()->GetName() );
207                 SfxBoolItem aBrowseItem( SID_BROWSE, sal_True );
208                 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
209 
210                 if ( rMEvt.IsMod1() )
211                 {
212                     // Im neuen Frame oeffnen
213                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
214                                 &aStrItem, &aBrowseItem, &aReferer, 0L);
215                 }
216                 else
217                 {
218                     // Im aktuellen Frame oeffnen
219                     SfxFrameItem aFrameItem( SID_DOCFRAME, pFrame );
220                     pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
221                                 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
222                 }
223             }
224         }
225     }
226 
227     if( !bReturn )
228         bReturn = FuOutline::MouseButtonUp(rMEvt);
229 
230     return (bReturn);
231 }
232 
233 /*************************************************************************
234 |*
235 |* Tastaturereignisse bearbeiten
236 |*
237 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
238 |* sal_False.
239 |*
240 \************************************************************************/
241 
KeyInput(const KeyEvent & rKEvt)242 sal_Bool FuOutlineText::KeyInput(const KeyEvent& rKEvt)
243 {
244     sal_Bool bReturn = sal_False;
245 
246     sal_uInt16 nKeyGroup = rKEvt.GetKeyCode().GetGroup();
247     if( !mpDocSh->IsReadOnly() || nKeyGroup == KEYGROUP_CURSOR )
248     {
249         mpWindow->GrabFocus();
250 
251         std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
252 
253         if( (nKeyGroup != KEYGROUP_CURSOR) && (nKeyGroup != KEYGROUP_FKEYS) )
254             aGuard.reset( new OutlineViewModelChangeGuard( *pOutlineView ) );
255 
256         bReturn = pOutlineView->GetViewByWindow(mpWindow)->PostKeyEvent(rKEvt);
257 
258         if (bReturn)
259         {
260             UpdateForKeyPress (rKEvt);
261         }
262         else
263         {
264             bReturn = FuOutline::KeyInput(rKEvt);
265         }
266     }
267 
268     return (bReturn);
269 }
270 
UpdateForKeyPress(const KeyEvent & rEvent)271 void FuOutlineText::UpdateForKeyPress (const KeyEvent& rEvent)
272 {
273     // Attributes at the current text position may have changed.
274     mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
275 
276     bool bUpdatePreview = true;
277     switch (rEvent.GetKeyCode().GetCode())
278     {
279         // When just the cursor has been moved the preview only changes when
280         // it moved to entries of another page.  To prevent unnecessary
281         // updates we check this here.  This is an early rejection test, so
282         // missing a key is not a problem.
283         case KEY_UP:
284         case KEY_DOWN:
285         case KEY_LEFT:
286         case KEY_RIGHT:
287         case KEY_HOME:
288         case KEY_END:
289         case KEY_PAGEUP:
290         case KEY_PAGEDOWN:
291         {
292             SdPage* pCurrentPage = pOutlineViewShell->GetActualPage();
293             bUpdatePreview = (pCurrentPage != pOutlineViewShell->GetActualPage());
294         }
295         break;
296     }
297     if (bUpdatePreview)
298         pOutlineViewShell->UpdatePreview (pOutlineViewShell->GetActualPage());
299 }
300 
301 
302 
303 
304 /*************************************************************************
305 |*
306 |* Function aktivieren
307 |*
308 \************************************************************************/
309 
Activate()310 void FuOutlineText::Activate()
311 {
312     FuOutline::Activate();
313 }
314 
315 /*************************************************************************
316 |*
317 |* Function deaktivieren
318 |*
319 \************************************************************************/
320 
Deactivate()321 void FuOutlineText::Deactivate()
322 {
323     FuOutline::Deactivate();
324 }
325 
326 /*************************************************************************
327 |*
328 |* Cut object to clipboard
329 |*
330 \************************************************************************/
331 
DoCut()332 void FuOutlineText::DoCut()
333 {
334     pOutlineView->GetViewByWindow(mpWindow)->Cut();
335 }
336 
337 /*************************************************************************
338 |*
339 |* Copy object to clipboard
340 |*
341 \************************************************************************/
342 
DoCopy()343 void FuOutlineText::DoCopy()
344 {
345     pOutlineView->GetViewByWindow(mpWindow)->Copy();
346 }
347 
348 /*************************************************************************
349 |*
350 |* Paste object from clipboard
351 |*
352 \************************************************************************/
353 
DoPaste()354 void FuOutlineText::DoPaste()
355 {
356     pOutlineView->GetViewByWindow(mpWindow)->PasteSpecial();
357 }
358 
359 
360 } // end of namespace sd
361