LibreOffice Module sw (master)  1
wrtsh3.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <svx/svxids.hrc>
21 #include <sfx2/app.hxx>
22 #include <sfx2/childwin.hxx>
23 #include <sfx2/bindings.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <svx/svdmark.hxx>
26 #include <svx/svdview.hxx>
27 #include <svx/fmglob.hxx>
28 #include <svx/svdouno.hxx>
29 #include <svx/srchdlg.hxx>
30 #include <com/sun/star/form/FormButtonType.hpp>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <sfx2/htmlmode.hxx>
33 #include <swmodule.hxx>
34 #include <wrtsh.hxx>
35 #include <view.hxx>
36 #include <IMark.hxx>
37 #include <doc.hxx>
38 
39 #include <unomid.h>
40 
41 using namespace ::com::sun::star;
42 
43 bool SwWrtShell::MoveBookMark( BookMarkMove eFuncId, const ::sw::mark::IMark* const pMark)
44 {
46  (this->*m_fnKillSel)( nullptr, false );
47 
48  bool bRet = true;
49  switch(eFuncId)
50  {
51  case BOOKMARK_INDEX:bRet = SwCursorShell::GotoMark( pMark );break;
52  case BOOKMARK_NEXT: bRet = SwCursorShell::GoNextBookmark();break;
53  case BOOKMARK_PREV: bRet = SwCursorShell::GoPrevBookmark();break;
54  default:;//prevent warning
55  }
56 
57  if( bRet && IsSelFrameMode() )
58  {
59  UnSelectFrame();
61  }
62  if( IsSelection() )
63  {
66  }
67  return bRet;
68 }
69 
70 bool SwWrtShell::GotoField( const SwFormatField& rField )
71 {
72  (this->*m_fnKillSel)( nullptr, false );
73 
74  bool bRet = SwCursorShell::GotoFormatField( rField );
75  if( bRet && IsSelFrameMode() )
76  {
77  UnSelectFrame();
79  }
80 
81  if( IsSelection() )
82  {
85  }
86 
87  return bRet;
88 }
89 
91 {
92  (this->*m_fnKillSel)( nullptr, false );
93  bool bRet = SwCursorShell::GotoFieldmark(pMark);
94  if( bRet && IsSelFrameMode() )
95  {
96  UnSelectFrame();
98  }
99  if( IsSelection() )
100  {
103  }
104  return bRet;
105 }
106 
107 // Invalidate FontWork-Slots
108 
110 {
111  static sal_uInt16 const aInval[] =
112  {
113  SID_ATTR_FILL_STYLE, SID_ATTR_FILL_COLOR, SID_ATTR_LINE_STYLE,
114  SID_ATTR_LINE_WIDTH, SID_ATTR_LINE_COLOR,
115  /*AF: these may be needed for the sidebar.
116  SID_SVX_AREA_TRANSPARENCY, SID_SVX_AREA_TRANSP_GRADIENT,
117  SID_SVX_AREA_TRANS_TYPE,
118  */
119  0
120  };
121 
123 
124  bool bOldVal = g_bNoInterrupt;
125  g_bNoInterrupt = true; // Trick to run AttrChangedNotify by timer.
126  GetView().AttrChangedNotify(this);
127  g_bNoInterrupt = bOldVal;
128 }
129 
130 void SwWrtShell::GotoMark( const OUString& rName )
131 {
133  if (ppMark == getIDocumentMarkAccess()->getAllMarksEnd())
134  return;
135  MoveBookMark( BOOKMARK_INDEX, ppMark->get() );
136 }
137 
138 void SwWrtShell::GotoMark( const ::sw::mark::IMark* const pMark )
139 {
140  MoveBookMark( BOOKMARK_INDEX, pMark );
141 }
142 
144 {
145  if ( !getIDocumentMarkAccess()->getBookmarksCount() )
146  {
147  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
148  return false;
149  }
150  LockView( true );
151  bool bRet = MoveBookMark( BOOKMARK_NEXT );
152  if ( !bRet )
153  {
154  MoveBookMark( BOOKMARK_INDEX, getIDocumentMarkAccess()->getBookmarksBegin()->get() );
155  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::EndWrapped );
156  }
157  else
158  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
159  LockView( false );
160  ShowCursor();
161  return true;
162 }
163 
165 {
166  if ( !getIDocumentMarkAccess()->getBookmarksCount() )
167  {
168  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::NavElementNotFound );
169  return false;
170  }
171  LockView( true );
172  bool bRet = MoveBookMark( BOOKMARK_PREV );
173  if ( !bRet )
174  {
175  MoveBookMark( BOOKMARK_INDEX, ( getIDocumentMarkAccess()->getBookmarksEnd() - 1 )->get() );
176  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::StartWrapped );
177  }
178  else
179  SvxSearchDialogWrapper::SetSearchLabel( SearchLabel::Empty );
180  LockView( false );
181  ShowCursor();
182  return true;
183 }
184 
185 void SwWrtShell::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs )
186 {
187  // execute macro, if it is allowed.
188  if ( IsMacroExecAllowed() )
189  {
190  GetDoc()->ExecMacro( rMacro, pRet, pArgs );
191  }
192 }
193 
194 sal_uInt16 SwWrtShell::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCallEvent,
195  bool bChkPtr)
196 {
197  return GetDoc()->CallEvent( nEvent, rCallEvent, bChkPtr );
198 }
199 
200  // If a util::URL-Button is selected, return its util::URL
201  // otherwise an empty string.
202 bool SwWrtShell::GetURLFromButton( OUString& rURL, OUString& rDescr ) const
203 {
204  bool bRet = false;
205  const SdrView *pDView = GetDrawView();
206  if( pDView )
207  {
208  // A fly is precisely achievable if it is selected.
209  const SdrMarkList &rMarkList = pDView->GetMarkedObjectList();
210 
211  if (rMarkList.GetMark(0))
212  {
213  SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( rMarkList.GetMark(0)->GetMarkedSdrObj() );
214  if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
215  {
216  const uno::Reference< awt::XControlModel >& xControlModel = pUnoCtrl->GetUnoControlModel();
217 
218  OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
219  if( !xControlModel.is() )
220  return bRet;
221 
222  uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY);
223 
224  uno::Any aTmp;
225 
226  uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
227  if(xInfo->hasPropertyByName( "ButtonType" ))
228  {
229  aTmp = xPropSet->getPropertyValue( "ButtonType" );
230  form::FormButtonType eTmpButtonType;
231  aTmp >>= eTmpButtonType;
232  if( form::FormButtonType_URL == eTmpButtonType)
233  {
234  // Label
235  aTmp = xPropSet->getPropertyValue( "Label" );
236  OUString uTmp;
237  if( (aTmp >>= uTmp) && !uTmp.isEmpty())
238  {
239  rDescr = uTmp;
240  }
241 
242  // util::URL
243  aTmp = xPropSet->getPropertyValue( "TargetURL" );
244  if( (aTmp >>= uTmp) && !uTmp.isEmpty())
245  {
246  rURL = uTmp;
247  }
248  bRet = true;
249  }
250  }
251  }
252  }
253  }
254 
255  return bRet;
256 }
257 
258 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
virtual void DrawSelChanged() override
Definition: wrtsh3.cxx:109
SdrView * GetDrawView()
Definition: vnew.cxx:376
bool GetURLFromButton(OUString &rURL, OUString &rDescr) const
Definition: wrtsh3.cxx:202
SAL_DLLPRIVATE bool MoveBookMark(BookMarkMove eFuncId, const ::sw::mark::IMark *const pMark=nullptr)
Definition: wrtsh3.cxx:43
SvMacroItemId
SdrMark * GetMark(size_t nNum) const
void Invalidate(sal_uInt16 nId)
bool GotoMark(const ::sw::mark::IMark *const pMark)
Definition: crbm.cxx:186
sal_uInt16 CallEvent(SvMacroItemId nEvent, const SwCallMouseEvent &rCallEvent, bool bChkPtr=false)
Definition: docbasic.cxx:130
const SwView & GetView() const
Definition: wrtsh.hxx:424
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
SELECTFUNC m_fnSetCursor
Definition: wrtsh.hxx:105
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2592
void ExecMacro(const SvxMacro &rMacro, OUString *pRet=nullptr, SbxArray *pArgs=nullptr)
Definition: wrtsh3.cxx:185
container_t::const_iterator const_iterator_t
SdrObject * GetMarkedSdrObj() const
bool IsSelection() const
Definition: crsrsh.hxx:875
bool GoNextBookmark()
Definition: wrtsh3.cxx:143
SfxBindings & GetBindings()
const SdrMarkList & GetMarkedObjectList() const
bool GotoFieldmark(const ::sw::mark::IFieldmark *const pMark)
Definition: crbm.cxx:312
long ResetSelect(const Point *, bool)
Definition: select.cxx:337
bool GoNextBookmark()
Definition: crbm.cxx:202
static void SetSearchLabel(const SearchLabel &rSL)
bool GoPrevBookmark()
Definition: wrtsh3.cxx:164
virtual SdrInventor GetObjInventor() const
bool IsMacroExecAllowed()
Definition: crsrsh.hxx:833
void GotoMark(const ::sw::mark::IMark *const pMark)
Definition: wrtsh3.cxx:138
void addCurrentPosition()
Definition: wrtsh1.cxx:1512
bool GotoField(const SwFormatField &rField)
Definition: wrtsh3.cxx:70
void LockView(bool b)
Definition: viewsh.hxx:465
void ExecMacro(const SvxMacro &rMacro, OUString *pRet, SbxArray *pArgs)
Definition: docbasic.cxx:76
void ShowCursor()
Definition: crsrsh.cxx:2293
void UnSelectFrame()
Definition: select.cxx:327
SAL_DLLPRIVATE long SetCursorKillSel(const Point *, bool bProp)
Definition: select.cxx:320
bool GoPrevBookmark()
Definition: crbm.cxx:239
sal_uInt16 CallEvent(SvMacroItemId nEvent, const SwCallMouseEvent &rCallEvent, bool bCheckPtr=false)
Definition: wrtsh3.cxx:194
void LeaveSelFrameMode()
Definition: select.cxx:721
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
bool g_bNoInterrupt
Definition: swmodule.cxx:138
bool GotoFieldmark(::sw::mark::IFieldmark const *const pMark)
Definition: wrtsh3.cxx:90
bool GotoFormatField(const SwFormatField &rField)
Definition: crstrvl.cxx:853
SELECTFUNC m_fnKillSel
Definition: wrtsh.hxx:107
bool IsSelFrameMode() const
Definition: wrtsh.hxx:166