1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/svxids.hrc>
21 #include <sfx2/app.hxx>
22 #include <sfx2/bindings.hxx>
23 #include <sfx2/viewfrm.hxx>
24 #include <svx/svdmark.hxx>
25 #include <svx/svdview.hxx>
26 #include <svx/svdouno.hxx>
27 #include <svx/srchdlg.hxx>
28 #include <com/sun/star/form/FormButtonType.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <swmodule.hxx>
36 using namespace ::com::sun::star
;
38 bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId
, const ::sw::mark::IMark
* const pMark
)
41 (this->*m_fnKillSel
)( nullptr, false );
46 case BOOKMARK_INDEX
:bRet
= SwCursorShell::GotoMark( pMark
);break;
47 case BOOKMARK_NEXT
: bRet
= SwCursorShell::GoNextBookmark();break;
48 case BOOKMARK_PREV
: bRet
= SwCursorShell::GoPrevBookmark();break;
49 default:;//prevent warning
52 if( bRet
&& IsSelFrameMode() )
59 m_fnKillSel
= &SwWrtShell::ResetSelect
;
60 m_fnSetCursor
= &SwWrtShell::SetCursorKillSel
;
65 bool SwWrtShell::GotoField( const SwFormatField
& rField
)
67 (this->*m_fnKillSel
)( nullptr, false );
69 bool bRet
= SwCursorShell::GotoFormatField( rField
);
70 if( bRet
&& IsSelFrameMode() )
78 m_fnKillSel
= &SwWrtShell::ResetSelect
;
79 m_fnSetCursor
= &SwWrtShell::SetCursorKillSel
;
85 bool SwWrtShell::GotoFieldmark(::sw::mark::IFieldmark
const * const pMark
)
87 (this->*m_fnKillSel
)( nullptr, false );
88 bool bRet
= SwCursorShell::GotoFieldmark(pMark
);
89 if( bRet
&& IsSelFrameMode() )
96 m_fnKillSel
= &SwWrtShell::ResetSelect
;
97 m_fnSetCursor
= &SwWrtShell::SetCursorKillSel
;
102 // Invalidate FontWork-Slots
104 void SwWrtShell::DrawSelChanged( )
106 static sal_uInt16
const aInval
[] =
108 SID_ATTR_FILL_STYLE
, SID_ATTR_FILL_COLOR
, SID_ATTR_LINE_STYLE
,
109 SID_ATTR_LINE_WIDTH
, SID_ATTR_LINE_COLOR
,
110 /*AF: these may be needed for the sidebar.
111 SID_SVX_AREA_TRANSPARENCY, SID_SVX_AREA_TRANSP_GRADIENT,
112 SID_SVX_AREA_TRANS_TYPE,
117 GetView().GetViewFrame()->GetBindings().Invalidate(aInval
);
119 bool bOldVal
= g_bNoInterrupt
;
120 g_bNoInterrupt
= true; // Trick to run AttrChangedNotify by timer.
121 GetView().AttrChangedNotify(nullptr);
122 g_bNoInterrupt
= bOldVal
;
125 void SwWrtShell::GotoMark( const OUString
& rName
)
127 IDocumentMarkAccess::const_iterator_t ppMark
= getIDocumentMarkAccess()->findMark( rName
);
128 if (ppMark
== getIDocumentMarkAccess()->getAllMarksEnd())
130 MoveBookMark( BOOKMARK_INDEX
, *ppMark
);
133 void SwWrtShell::GotoMark( const ::sw::mark::IMark
* const pMark
)
135 MoveBookMark( BOOKMARK_INDEX
, pMark
);
138 bool SwWrtShell::GoNextBookmark()
140 if ( !getIDocumentMarkAccess()->getBookmarksCount() )
142 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound
);
146 bool bRet
= MoveBookMark( BOOKMARK_NEXT
);
149 MoveBookMark( BOOKMARK_INDEX
, *getIDocumentMarkAccess()->getBookmarksBegin() );
150 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped
);
153 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty
);
159 bool SwWrtShell::GoPrevBookmark()
161 if ( !getIDocumentMarkAccess()->getBookmarksCount() )
163 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound
);
167 bool bRet
= MoveBookMark( BOOKMARK_PREV
);
170 MoveBookMark( BOOKMARK_INDEX
, *( getIDocumentMarkAccess()->getBookmarksEnd() - 1 ) );
171 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped
);
174 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty
);
180 void SwWrtShell::ExecMacro( const SvxMacro
& rMacro
, OUString
* pRet
, SbxArray
* pArgs
)
182 // execute macro, if it is allowed.
183 if ( IsMacroExecAllowed() )
185 GetDoc()->ExecMacro( rMacro
, pRet
, pArgs
);
189 sal_uInt16
SwWrtShell::CallEvent( SvMacroItemId nEvent
, const SwCallMouseEvent
& rCallEvent
,
192 return GetDoc()->CallEvent( nEvent
, rCallEvent
, bChkPtr
);
195 // If a util::URL-Button is selected, return its util::URL
196 // otherwise an empty string.
197 bool SwWrtShell::GetURLFromButton( OUString
& rURL
, OUString
& rDescr
) const
200 const SdrView
*pDView
= GetDrawView();
203 // A fly is precisely achievable if it is selected.
204 const SdrMarkList
&rMarkList
= pDView
->GetMarkedObjectList();
206 if (rMarkList
.GetMark(0))
208 SdrUnoObj
* pUnoCtrl
= dynamic_cast<SdrUnoObj
*>( rMarkList
.GetMark(0)->GetMarkedSdrObj() );
209 if (pUnoCtrl
&& SdrInventor::FmForm
== pUnoCtrl
->GetObjInventor())
211 const uno::Reference
< awt::XControlModel
>& xControlModel
= pUnoCtrl
->GetUnoControlModel();
213 OSL_ENSURE( xControlModel
.is(), "UNO-Control without Model" );
214 if( !xControlModel
.is() )
217 uno::Reference
< beans::XPropertySet
> xPropSet(xControlModel
, uno::UNO_QUERY
);
221 uno::Reference
< beans::XPropertySetInfo
> xInfo
= xPropSet
->getPropertySetInfo();
222 if(xInfo
->hasPropertyByName( "ButtonType" ))
224 aTmp
= xPropSet
->getPropertyValue( "ButtonType" );
225 form::FormButtonType eTmpButtonType
;
226 aTmp
>>= eTmpButtonType
;
227 if( form::FormButtonType_URL
== eTmpButtonType
)
230 aTmp
= xPropSet
->getPropertyValue( "Label" );
232 if( (aTmp
>>= uTmp
) && !uTmp
.isEmpty())
238 aTmp
= xPropSet
->getPropertyValue( "TargetURL" );
239 if( (aTmp
>>= uTmp
) && !uTmp
.isEmpty())
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */