nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / uibase / wrtsh / wrtsh3.cxx
blob1fd1ce2cddeb40a01425b4dcde3644453708b6ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
31 #include <wrtsh.hxx>
32 #include <view.hxx>
33 #include <IMark.hxx>
34 #include <doc.hxx>
36 using namespace ::com::sun::star;
38 bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark)
40 addCurrentPosition();
41 (this->*m_fnKillSel)( nullptr, false );
43 bool bRet = true;
44 switch(eFuncId)
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() )
54 UnSelectFrame();
55 LeaveSelFrameMode();
57 if( IsSelection() )
59 m_fnKillSel = &SwWrtShell::ResetSelect;
60 m_fnSetCursor = &SwWrtShell::SetCursorKillSel;
62 return bRet;
65 bool SwWrtShell::GotoField( const SwFormatField& rField )
67 (this->*m_fnKillSel)( nullptr, false );
69 bool bRet = SwCursorShell::GotoFormatField( rField );
70 if( bRet && IsSelFrameMode() )
72 UnSelectFrame();
73 LeaveSelFrameMode();
76 if( IsSelection() )
78 m_fnKillSel = &SwWrtShell::ResetSelect;
79 m_fnSetCursor = &SwWrtShell::SetCursorKillSel;
82 return bRet;
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() )
91 UnSelectFrame();
92 LeaveSelFrameMode();
94 if( IsSelection() )
96 m_fnKillSel = &SwWrtShell::ResetSelect;
97 m_fnSetCursor = &SwWrtShell::SetCursorKillSel;
99 return bRet;
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())
129 return;
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 );
143 return false;
145 LockView( true );
146 bool bRet = MoveBookMark( BOOKMARK_NEXT );
147 if ( !bRet )
149 MoveBookMark( BOOKMARK_INDEX, *getIDocumentMarkAccess()->getBookmarksBegin() );
150 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
152 else
153 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
154 LockView( false );
155 ShowCursor();
156 return true;
159 bool SwWrtShell::GoPrevBookmark()
161 if ( !getIDocumentMarkAccess()->getBookmarksCount() )
163 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
164 return false;
166 LockView( true );
167 bool bRet = MoveBookMark( BOOKMARK_PREV );
168 if ( !bRet )
170 MoveBookMark( BOOKMARK_INDEX, *( getIDocumentMarkAccess()->getBookmarksEnd() - 1 ) );
171 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
173 else
174 SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
175 LockView( false );
176 ShowCursor();
177 return true;
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,
190 bool bChkPtr)
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
199 bool bRet = false;
200 const SdrView *pDView = GetDrawView();
201 if( pDView )
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() )
215 return bRet;
217 uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY);
219 uno::Any aTmp;
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)
229 // Label
230 aTmp = xPropSet->getPropertyValue( "Label" );
231 OUString uTmp;
232 if( (aTmp >>= uTmp) && !uTmp.isEmpty())
234 rDescr = uTmp;
237 // util::URL
238 aTmp = xPropSet->getPropertyValue( "TargetURL" );
239 if( (aTmp >>= uTmp) && !uTmp.isEmpty())
241 rURL = uTmp;
243 bRet = true;
250 return bRet;
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */