merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / fuoltext.cxx
blob35a2f96a6576393ffcc417d38743f896a76ccf8b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuoltext.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include "fuoltext.hxx"
37 #include <sfx2/viewfrm.hxx>
38 #include <svx/outliner.hxx>
39 #include <svx/eeitem.hxx>
40 #include <svx/flditem.hxx>
41 #include <sfx2/bindings.hxx>
42 #include <sfx2/docfile.hxx>
43 #include <sfx2/dispatch.hxx>
45 #include <svx/svxids.hrc>
46 #include "app.hrc"
47 #include "OutlineView.hxx"
48 #ifndef SD_WINDOW_SHELL_HXX
49 #include "Window.hxx"
50 #endif
51 #include "DrawDocShell.hxx"
52 #include "ViewShell.hxx"
53 #include "OutlineViewShell.hxx"
55 #include <stdio.h> // Fuer SlotFilter-Listing
57 namespace sd {
59 static USHORT SidArray[] = {
60 SID_STYLE_FAMILY2,
61 SID_STYLE_FAMILY3,
62 SID_STYLE_FAMILY5,
63 SID_STYLE_UPDATE_BY_EXAMPLE,
64 SID_CUT,
65 SID_COPY,
66 SID_PASTE,
67 SID_SELECTALL,
68 SID_ATTR_CHAR_FONT,
69 SID_ATTR_CHAR_POSTURE,
70 SID_ATTR_CHAR_WEIGHT,
71 SID_ATTR_CHAR_UNDERLINE,
72 SID_ATTR_CHAR_FONTHEIGHT,
73 SID_ATTR_CHAR_COLOR,
74 SID_OUTLINE_UP,
75 SID_OUTLINE_DOWN,
76 SID_OUTLINE_LEFT,
77 SID_OUTLINE_RIGHT,
78 //SID_OUTLINE_FORMAT,
79 SID_OUTLINE_COLLAPSE_ALL,
80 //SID_OUTLINE_BULLET,
81 SID_OUTLINE_COLLAPSE,
82 SID_OUTLINE_EXPAND_ALL,
83 SID_OUTLINE_EXPAND,
84 SID_SET_SUPER_SCRIPT,
85 SID_SET_SUB_SCRIPT,
86 SID_HYPERLINK_GETLINK,
87 SID_PRESENTATION_TEMPLATES,
88 SID_STATUS_PAGE,
89 SID_STATUS_LAYOUT,
90 SID_EXPAND_PAGE,
91 SID_SUMMARY_PAGE,
92 SID_PARASPACE_INCREASE,
93 SID_PARASPACE_DECREASE,
94 0 };
96 TYPEINIT1( FuOutlineText, FuOutline );
98 /*************************************************************************
100 |* Konstruktor
102 \************************************************************************/
104 FuOutlineText::FuOutlineText(ViewShell* pViewShell, ::sd::Window* pWindow,
105 ::sd::View* pView, SdDrawDocument* pDoc,
106 SfxRequest& rReq)
107 : FuOutline(pViewShell, pWindow, pView, pDoc, rReq)
111 FunctionReference FuOutlineText::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
113 FunctionReference xFunc( new FuOutlineText( pViewSh, pWin, pView, pDoc, rReq ) );
114 xFunc->DoExecute( rReq );
115 return xFunc;
118 /*************************************************************************
120 |* MouseButtonDown-event
122 \************************************************************************/
124 BOOL FuOutlineText::MouseButtonDown(const MouseEvent& rMEvt)
126 BOOL bReturn = FALSE;
128 mpWindow->GrabFocus();
130 bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonDown(rMEvt);
132 if (bReturn)
134 // Attributierung der akt. Textstelle kann jetzt anders sein
135 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
137 else
139 bReturn = FuOutline::MouseButtonDown(rMEvt);
142 return (bReturn);
145 /*************************************************************************
147 |* MouseMove-event
149 \************************************************************************/
151 BOOL FuOutlineText::MouseMove(const MouseEvent& rMEvt)
153 BOOL bReturn = FALSE;
155 bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseMove(rMEvt);
157 if (!bReturn)
159 bReturn = FuOutline::MouseMove(rMEvt);
162 // MT 07/2002: Done in OutlinerView::MouseMove
164 const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->
165 GetFieldUnderMousePointer();
166 const SvxFieldData* pField = NULL;
167 if( pFieldItem )
168 pField = pFieldItem->GetField();
170 if( pField && pField->ISA( SvxURLField ) )
172 mpWindow->SetPointer( Pointer( POINTER_REFHAND ) );
174 else
175 mpWindow->SetPointer( Pointer( POINTER_TEXT ) );
178 return (bReturn);
181 /*************************************************************************
183 |* MouseButtonUp-event
185 \************************************************************************/
187 BOOL FuOutlineText::MouseButtonUp(const MouseEvent& rMEvt)
189 BOOL bReturn = FALSE;
191 bReturn = pOutlineView->GetViewByWindow(mpWindow)->MouseButtonUp(rMEvt);
193 if (bReturn)
195 // Attributierung der akt. Textstelle kann jetzt anders sein
196 mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
198 else
200 const SvxFieldItem* pFieldItem = pOutlineView->GetViewByWindow( mpWindow )->GetFieldUnderMousePointer();
201 if( pFieldItem )
203 const SvxFieldData* pField = pFieldItem->GetField();
205 if( pField && pField->ISA( SvxURLField ) )
207 bReturn = TRUE;
208 mpWindow->ReleaseMouse();
209 SfxStringItem aStrItem( SID_FILE_NAME, ( (SvxURLField*) pField)->GetURL() );
210 SfxStringItem aReferer( SID_REFERER, mpDocSh->GetMedium()->GetName() );
211 SfxBoolItem aBrowseItem( SID_BROWSE, TRUE );
212 SfxViewFrame* pFrame = mpViewShell->GetViewFrame();
214 if ( rMEvt.IsMod1() )
216 // Im neuen Frame oeffnen
217 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
218 &aStrItem, &aBrowseItem, &aReferer, 0L);
220 else
222 // Im aktuellen Frame oeffnen
223 SfxFrameItem aFrameItem( SID_DOCFRAME, pFrame );
224 pFrame->GetDispatcher()->Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
225 &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
231 if( !bReturn )
232 bReturn = FuOutline::MouseButtonUp(rMEvt);
234 return (bReturn);
237 /*************************************************************************
239 |* Tastaturereignisse bearbeiten
241 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
242 |* FALSE.
244 \************************************************************************/
246 BOOL FuOutlineText::KeyInput(const KeyEvent& rKEvt)
248 BOOL bReturn = FALSE;
250 USHORT nKeyGroup = rKEvt.GetKeyCode().GetGroup();
251 if( !mpDocSh->IsReadOnly() || nKeyGroup == KEYGROUP_CURSOR )
253 mpWindow->GrabFocus();
255 std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
257 if( (nKeyGroup != KEYGROUP_CURSOR) && (nKeyGroup != KEYGROUP_FKEYS) )
258 aGuard.reset( new OutlineViewModelChangeGuard( *pOutlineView ) );
260 bReturn = pOutlineView->GetViewByWindow(mpWindow)->PostKeyEvent(rKEvt);
262 if (bReturn)
264 UpdateForKeyPress (rKEvt);
266 else
268 bReturn = FuOutline::KeyInput(rKEvt);
272 return (bReturn);
275 void FuOutlineText::UpdateForKeyPress (const KeyEvent& rEvent)
277 // Attributes at the current text position may have changed.
278 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SidArray);
280 bool bUpdatePreview = true;
281 switch (rEvent.GetKeyCode().GetCode())
283 // When just the cursor has been moved the preview only changes when
284 // it moved to entries of another page. To prevent unnecessary
285 // updates we check this here. This is an early rejection test, so
286 // missing a key is not a problem.
287 case KEY_UP:
288 case KEY_DOWN:
289 case KEY_LEFT:
290 case KEY_RIGHT:
291 case KEY_HOME:
292 case KEY_END:
293 case KEY_PAGEUP:
294 case KEY_PAGEDOWN:
296 SdPage* pCurrentPage = pOutlineViewShell->GetActualPage();
297 bUpdatePreview = (pCurrentPage != pOutlineViewShell->GetActualPage());
299 break;
301 if (bUpdatePreview)
302 pOutlineViewShell->UpdatePreview (pOutlineViewShell->GetActualPage());
308 /*************************************************************************
310 |* Function aktivieren
312 \************************************************************************/
314 void FuOutlineText::Activate()
316 FuOutline::Activate();
319 /*************************************************************************
321 |* Function deaktivieren
323 \************************************************************************/
325 void FuOutlineText::Deactivate()
327 FuOutline::Deactivate();
330 /*************************************************************************
332 |* Cut object to clipboard
334 \************************************************************************/
336 void FuOutlineText::DoCut()
338 pOutlineView->GetViewByWindow(mpWindow)->Cut();
341 /*************************************************************************
343 |* Copy object to clipboard
345 \************************************************************************/
347 void FuOutlineText::DoCopy()
349 pOutlineView->GetViewByWindow(mpWindow)->Copy();
352 /*************************************************************************
354 |* Paste object from clipboard
356 \************************************************************************/
358 void FuOutlineText::DoPaste()
360 pOutlineView->GetViewByWindow(mpWindow)->PasteSpecial();
364 } // end of namespace sd