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: wrtsh3.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_sw.hxx"
35 #ifndef _SVX_SVXIDS_HRC //autogen
36 #include <svx/svxids.hrc>
38 #include <sfx2/app.hxx>
39 #include <sfx2/childwin.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <svx/svdmark.hxx>
42 #include <svx/svdview.hxx>
43 #include <svx/fmglob.hxx>
44 #include <svx/svdouno.hxx>
45 #include <com/sun/star/form/FormButtonType.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <svx/htmlmode.hxx>
48 #include <tools/urlobj.hxx>
58 using namespace ::com::sun::star
;
59 using ::rtl::OUString
;
61 extern sal_Bool bNoInterrupt
; // in mainwn.cxx
63 BOOL
SwWrtShell::MoveBookMark( BookMarkMove eFuncId
, const ::sw::mark::IMark
* const pMark
)
65 //JP 08.03.96: die Wizards brauchen die Selektion !!
67 (this->*fnKillSel
)( 0, sal_False
);
72 case BOOKMARK_INDEX
:bRet
= SwCrsrShell::GotoMark( pMark
);break;
73 case BOOKMARK_NEXT
: bRet
= SwCrsrShell::GoNextBookmark();break;
74 case BOOKMARK_PREV
: bRet
= SwCrsrShell::GoPrevBookmark();break;
75 default:;//prevent warning
78 if( bRet
&& IsSelFrmMode() )
85 fnKillSel
= &SwWrtShell::ResetSelect
;
86 fnSetCrsr
= &SwWrtShell::SetCrsrKillSel
;
91 BOOL
SwWrtShell::GotoField( const SwFmtFld
& rFld
)
93 (this->*fnKillSel
)( 0, sal_False
);
95 BOOL bRet
= SwCrsrShell::GotoFld( rFld
);
96 if( bRet
&& IsSelFrmMode() )
104 fnKillSel
= &SwWrtShell::ResetSelect
;
105 fnSetCrsr
= &SwWrtShell::SetCrsrKillSel
;
111 bool SwWrtShell::GotoFieldmark(::sw::mark::IFieldmark
const * const pMark
)
113 (this->*fnKillSel
)( 0, sal_False
);
114 bool bRet
= SwCrsrShell::GotoFieldmark(pMark
);
115 if( bRet
&& IsSelFrmMode() )
122 fnKillSel
= &SwWrtShell::ResetSelect
;
123 fnSetCrsr
= &SwWrtShell::SetCrsrKillSel
;
128 /*--------------------------------------------------------------------
129 Beschreibung: FontWork-Slots invalidieren
130 --------------------------------------------------------------------*/
133 void SwWrtShell::DrawSelChanged( )
135 static sal_uInt16 __READONLY_DATA aInval
[] =
137 SID_ATTR_FILL_STYLE
, SID_ATTR_FILL_COLOR
, SID_ATTR_LINE_STYLE
,
138 SID_ATTR_LINE_WIDTH
, SID_ATTR_LINE_COLOR
, 0
141 GetView().GetViewFrame()->GetBindings().Invalidate(aInval
);
143 sal_Bool bOldVal
= bNoInterrupt
;
144 bNoInterrupt
= sal_True
; // Trick, um AttrChangedNotify ueber Timer auszufuehren
145 GetView().AttrChangedNotify(this);
146 bNoInterrupt
= bOldVal
;
149 BOOL
SwWrtShell::GotoMark( const ::rtl::OUString
& rName
)
151 IDocumentMarkAccess::const_iterator_t ppMark
= getIDocumentMarkAccess()->findMark( rName
);
152 if(ppMark
== getIDocumentMarkAccess()->getMarksEnd()) return false;
153 return MoveBookMark( BOOKMARK_INDEX
, ppMark
->get() );
157 BOOL
SwWrtShell::GotoMark( const ::sw::mark::IMark
* const pMark
)
159 return MoveBookMark( BOOKMARK_INDEX
, pMark
);
163 BOOL
SwWrtShell::GoNextBookmark()
165 return MoveBookMark( BOOKMARK_NEXT
);
169 BOOL
SwWrtShell::GoPrevBookmark()
171 return MoveBookMark( BOOKMARK_PREV
);
175 void SwWrtShell::ExecMacro( const SvxMacro
& rMacro
, String
* pRet
, SbxArray
* pArgs
)
177 // OD 11.02.2003 #100556# - execute macro, if it is allowed.
178 if ( IsMacroExecAllowed() )
180 GetDoc()->ExecMacro( rMacro
, pRet
, pArgs
);
185 sal_uInt16
SwWrtShell::CallEvent( sal_uInt16 nEvent
, const SwCallMouseEvent
& rCallEvent
,
186 sal_Bool bChkPtr
, SbxArray
* pArgs
,
187 const Link
* pCallBack
)
189 return GetDoc()->CallEvent( nEvent
, rCallEvent
, bChkPtr
, pArgs
, pCallBack
);
193 // fall ein util::URL-Button selektiert ist, dessen util::URL returnen, ansonsten
195 sal_Bool
SwWrtShell::GetURLFromButton( String
& rURL
, String
& rDescr
) const
197 sal_Bool bRet
= sal_False
;
198 const SdrView
*pDView
= GetDrawView();
201 // Ein Fly ist genau dann erreichbar, wenn er selektiert ist.
202 const SdrMarkList
&rMarkList
= pDView
->GetMarkedObjectList();
204 if (rMarkList
.GetMark(0))
206 SdrUnoObj
* pUnoCtrl
= PTR_CAST(SdrUnoObj
, rMarkList
.GetMark(0)->GetMarkedSdrObj());
207 if (pUnoCtrl
&& FmFormInventor
== pUnoCtrl
->GetObjInventor())
209 uno::Reference
< awt::XControlModel
> xControlModel
= pUnoCtrl
->GetUnoControlModel();
211 ASSERT( xControlModel
.is(), "UNO-Control ohne Model" );
212 if( !xControlModel
.is() )
215 uno::Reference
< beans::XPropertySet
> xPropSet(xControlModel
, uno::UNO_QUERY
);
219 form::FormButtonType eButtonType
= form::FormButtonType_URL
;
220 uno::Reference
< beans::XPropertySetInfo
> xInfo
= xPropSet
->getPropertySetInfo();
221 if(xInfo
->hasPropertyByName( C2U("ButtonType") ))
223 aTmp
= xPropSet
->getPropertyValue( C2U("ButtonType") );
224 form::FormButtonType eTmpButtonType
;
225 aTmp
>>= eTmpButtonType
;
226 if( eButtonType
== eTmpButtonType
)
229 aTmp
= xPropSet
->getPropertyValue( C2U("Label") );
231 if( (aTmp
>>= uTmp
) && uTmp
.getLength())
233 rDescr
= String(uTmp
);
237 aTmp
= xPropSet
->getPropertyValue( C2U("TargetURL") );
238 if( (aTmp
>>= uTmp
) && uTmp
.getLength())