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