1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuoltext.cxx,v $
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>
47 #include "OutlineView.hxx"
48 #ifndef SD_WINDOW_SHELL_HXX
51 #include "DrawDocShell.hxx"
52 #include "ViewShell.hxx"
53 #include "OutlineViewShell.hxx"
55 #include <stdio.h> // Fuer SlotFilter-Listing
59 static USHORT SidArray
[] = {
63 SID_STYLE_UPDATE_BY_EXAMPLE
,
69 SID_ATTR_CHAR_POSTURE
,
71 SID_ATTR_CHAR_UNDERLINE
,
72 SID_ATTR_CHAR_FONTHEIGHT
,
79 SID_OUTLINE_COLLAPSE_ALL
,
82 SID_OUTLINE_EXPAND_ALL
,
86 SID_HYPERLINK_GETLINK
,
87 SID_PRESENTATION_TEMPLATES
,
92 SID_PARASPACE_INCREASE
,
93 SID_PARASPACE_DECREASE
,
96 TYPEINIT1( FuOutlineText
, FuOutline
);
98 /*************************************************************************
102 \************************************************************************/
104 FuOutlineText::FuOutlineText(ViewShell
* pViewShell
, ::sd::Window
* pWindow
,
105 ::sd::View
* pView
, SdDrawDocument
* pDoc
,
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
);
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
);
134 // Attributierung der akt. Textstelle kann jetzt anders sein
135 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArray
);
139 bReturn
= FuOutline::MouseButtonDown(rMEvt
);
145 /*************************************************************************
149 \************************************************************************/
151 BOOL
FuOutlineText::MouseMove(const MouseEvent
& rMEvt
)
153 BOOL bReturn
= FALSE
;
155 bReturn
= pOutlineView
->GetViewByWindow(mpWindow
)->MouseMove(rMEvt
);
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;
168 pField = pFieldItem->GetField();
170 if( pField && pField->ISA( SvxURLField ) )
172 mpWindow->SetPointer( Pointer( POINTER_REFHAND ) );
175 mpWindow->SetPointer( Pointer( POINTER_TEXT ) );
181 /*************************************************************************
183 |* MouseButtonUp-event
185 \************************************************************************/
187 BOOL
FuOutlineText::MouseButtonUp(const MouseEvent
& rMEvt
)
189 BOOL bReturn
= FALSE
;
191 bReturn
= pOutlineView
->GetViewByWindow(mpWindow
)->MouseButtonUp(rMEvt
);
195 // Attributierung der akt. Textstelle kann jetzt anders sein
196 mpViewShell
->GetViewFrame()->GetBindings().Invalidate( SidArray
);
200 const SvxFieldItem
* pFieldItem
= pOutlineView
->GetViewByWindow( mpWindow
)->GetFieldUnderMousePointer();
203 const SvxFieldData
* pField
= pFieldItem
->GetField();
205 if( pField
&& pField
->ISA( SvxURLField
) )
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);
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);
232 bReturn
= FuOutline::MouseButtonUp(rMEvt
);
237 /*************************************************************************
239 |* Tastaturereignisse bearbeiten
241 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
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
);
264 UpdateForKeyPress (rKEvt
);
268 bReturn
= FuOutline::KeyInput(rKEvt
);
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.
296 SdPage
* pCurrentPage
= pOutlineViewShell
->GetActualPage();
297 bUpdatePreview
= (pCurrentPage
!= pOutlineViewShell
->GetActualPage());
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