LibreOffice Module sw (master) 1
wview.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 <config_feature_desktop.h>
21
22#include <sfx2/msg.hxx>
23#include <sfx2/dispatch.hxx>
24#include <sfx2/infobar.hxx>
25#include <sfx2/viewfrm.hxx>
26#include <svx/srchdlg.hxx>
27#include <uivwimp.hxx>
28#include <svx/fmshell.hxx>
29#include <svx/fmview.hxx>
30#include <svx/extrusionbar.hxx>
31#include <svx/fontworkbar.hxx>
32#include <vcl/inputctx.hxx>
33
34#include <sfx2/objface.hxx>
35#include <swmodule.hxx>
36#include <unotxvw.hxx>
37#include <cmdid.h>
38#include <globals.hrc>
39#include <wrtsh.hxx>
40#include <edtwin.hxx>
41#include <wgrfsh.hxx>
42#include <wfrmsh.hxx>
43#include <wolesh.hxx>
44#include <wtabsh.hxx>
45#include <wlistsh.hxx>
46#include <wformsh.hxx>
47#include <wtextsh.hxx>
48#include <barcfg.hxx>
49#include <doc.hxx>
50
51// TECHNICALLY not possible !!
52#include <beziersh.hxx>
53#include <drawsh.hxx>
54#include <drwtxtsh.hxx>
55#include <annotsh.hxx>
56
57#include <wview.hxx>
58#include <wdocsh.hxx>
59
60 // needed for -fsanitize=function visibility of typeinfo for functions of
61 // type void(SfxShell*,SfxRequest&) defined in swslots.hxx
62#include <sfx2/viewfac.hxx>
63#define ShellClass_SwWebView
64#define ShellClass_Text
65#include <swslots.hxx>
66
68{
70}
71
73
74void SwWebView::InitInterface_Impl()
75{
76 GetStaticInterface()->RegisterChildWindow(SvxSearchDialogWrapper::GetChildWindowId());
77 GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
78
79 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS, SfxVisibilityFlags::Standard|SfxVisibilityFlags::Server,
80 ToolbarId::Webtools_Toolbox);
81}
82
83
85 SwView(_rFrame, _pShell)
86{
87}
88
90{
91}
92
94{
95#if HAVE_FEATURE_DESKTOP
96 // Decision whether UpdateTable must be called
97 bool bUpdateTable = false;
98 const SwFrameFormat* pCurTableFormat = GetWrtShell().GetTableFormat();
99 if(pCurTableFormat && pCurTableFormat != GetLastTableFrameFormat())
100 {
101 bUpdateTable = true; // can only be executed later
102 }
103 SetLastTableFrameFormat(pCurTableFormat);
104 //SEL_TBL and SEL_TBL_CELLS can be ored!
105 SelectionType nNewSelectionType = GetWrtShell().GetSelectionType()
106 & ~SelectionType::TableCell;
107
108 SelectionType _nSelectionType = GetSelectionType();
109 if ( nNewSelectionType == _nSelectionType )
110 {
112 if ( _nSelectionType & SelectionType::Ole ||
113 _nSelectionType & SelectionType::Graphic )
114 //The verb may of course change for graphics and OLE!
115 ImpSetVerb( nNewSelectionType );
116 }
117 else
118 {
119 SfxDispatcher &rDispatcher = *GetViewFrame().GetDispatcher();
120 SwToolbarConfigItem *pBarCfg = SW_MOD()->GetWebToolbarConfig();
121
122 if( GetCurShell() )
123 {
124 rDispatcher.Flush(); // really delete all cached shells
125
126 //Additional to the old selection remember which toolbar was visible.
128 if (eId != ToolbarId::None)
129 pBarCfg->SetTopToolbar( _nSelectionType, eId );
130
131 SfxShell *pSfxShell;
132 sal_uInt16 i;
133 for ( i = 0; true; ++i )
134 {
135 pSfxShell = rDispatcher.GetShell( i );
136 if ( !( dynamic_cast< const SwBaseShell *>( pSfxShell ) != nullptr ||
137 dynamic_cast< const SwDrawTextShell *>( pSfxShell ) || dynamic_cast< const SwAnnotationShell *>( pSfxShell ) != nullptr ) )
138 break;
139 }
140 if (i)
141 {
142 pSfxShell = rDispatcher.GetShell( --i );
143 OSL_ENSURE( pSfxShell, "My Shell is lost in space" );
144 rDispatcher.Pop( *pSfxShell, SfxDispatcherPopFlags::POP_UNTIL | SfxDispatcherPopFlags::POP_DELETE);
145 }
146 }
147
148 bool bInitFormShell = false;
149 if( !GetFormShell() )
150 {
151 bInitFormShell = true;
152 SetFormShell( new FmFormShell( this ) );
153 rDispatcher.Push( *GetFormShell() );
154 }
155
156 bool bSetExtInpCntxt = false;
157 _nSelectionType = nNewSelectionType;
158 SetSelectionType( _nSelectionType );
159 ShellMode eShellMode;
160
161 if ( _nSelectionType & SelectionType::Ole )
162 {
163 eShellMode = ShellMode::Object;
164 SetShell( new SwWebOleShell( *this ));
165 rDispatcher.Push( *GetCurShell() );
166 }
167 else if ( _nSelectionType & SelectionType::Frame
168 || _nSelectionType & SelectionType::Graphic)
169 {
170 eShellMode = ShellMode::Frame;
171 SetShell( new SwWebFrameShell( *this ));
172 rDispatcher.Push( *GetCurShell() );
173 if(_nSelectionType & SelectionType::Graphic )
174 {
175 eShellMode = ShellMode::Graphic;
176 SetShell( new SwWebGrfShell( *this ));
177 rDispatcher.Push( *GetCurShell() );
178 }
179 }
180 else if ( _nSelectionType & SelectionType::Frame )
181 {
182 eShellMode = ShellMode::Frame;
183 SetShell( new SwWebFrameShell( *this ));
184 rDispatcher.Push( *GetCurShell() );
185 }
186 else if ( _nSelectionType & SelectionType::DrawObject )
187 {
188 eShellMode = ShellMode::Draw;
189 SetShell( new svx::ExtrusionBar( this ) );
190 rDispatcher.Push( *GetCurShell() );
191
192 SetShell( new svx::FontworkBar( this ) );
193 rDispatcher.Push( *GetCurShell() );
194
195 SetShell( new SwDrawShell( *this ));
196 rDispatcher.Push( *GetCurShell() );
197 if ( _nSelectionType & SelectionType::Ornament )
198 {
199 eShellMode = ShellMode::Bezier;
200 SetShell( new SwBezierShell( *this ));
201 rDispatcher.Push( *GetCurShell() );
202 }
203
204 }
205 else if ( _nSelectionType & SelectionType::DbForm )
206 {
207 eShellMode = ShellMode::DrawForm;
208 SetShell( new SwWebDrawFormShell( *this ));
209
210 rDispatcher.Push( *GetCurShell() );
211 }
212 else if ( _nSelectionType & SelectionType::DrawObjectEditMode )
213 {
214 eShellMode = ShellMode::DrawText;
215 rDispatcher.Push( *(new SwBaseShell( *this )) );
216 SetShell( new SwDrawTextShell( *this ));
217 rDispatcher.Push( *GetCurShell() );
218 }
219 else if ( _nSelectionType & SelectionType::PostIt )
220 {
221 eShellMode = ShellMode::PostIt;
222 SetShell( new SwAnnotationShell( *this ) );
223 rDispatcher.Push( *GetCurShell() );
224 }
225 else
226 {
227 bSetExtInpCntxt = true;
228 eShellMode = ShellMode::Text;
229 if ( _nSelectionType & SelectionType::NumberList )
230 {
231 eShellMode = ShellMode::ListText;
232 SetShell( new SwWebListShell( *this ));
233 rDispatcher.Push( *GetCurShell() );
234 }
235 SetShell( new SwWebTextShell(*this));
236 rDispatcher.Push( *GetCurShell() );
237 if ( _nSelectionType & SelectionType::Table )
238 {
239 eShellMode = eShellMode == ShellMode::ListText ? ShellMode::TableListText
241 SetShell( new SwWebTableShell( *this ));
242 rDispatcher.Push( *GetCurShell() );
243 }
244 }
245 ImpSetVerb( _nSelectionType );
246 GetViewImpl()->SetShellMode(eShellMode);
247
248 if( !GetDocShell()->IsReadOnly() )
249 {
250 if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
251 bSetExtInpCntxt = false;
252
253 InputContext aCntxt( GetEditWin().GetInputContext() );
254 aCntxt.SetOptions( bSetExtInpCntxt
255 ? (aCntxt.GetOptions() |
256 ( InputContextFlags::Text |
257 InputContextFlags::ExtText ))
258 : (aCntxt.GetOptions() & ~
259 InputContextFlags( InputContextFlags::Text |
260 InputContextFlags::ExtText )) );
261 GetEditWin().SetInputContext( aCntxt );
262 }
263
264 //Additional to the selection enable the toolbar, which was
265 //activated last time
266 //Before must be a Flush(), but concerns according to MBA not the
267 //user interface and is not a performance issue.
268 // TODO/LATER: maybe now the Flush() command is superfluous?!
269 rDispatcher.Flush();
270
272 aPnt = GetEditWin().PixelToLogic(aPnt);
274
275 if ( bInitFormShell && GetWrtShell().GetDrawView() )
276 GetFormShell()->SetView( dynamic_cast< FmFormView* >(
278
279 }
281
282 //Opportune time for the communication with OLE objects?
283 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
284 GetDocShell()->GetDoc()->PrtOLENotify( false );
285
286 //now the table update
287 if(bUpdateTable)
289#endif
290}
291
292/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetView(FmFormView *pView)
InputContextFlags GetOptions() const
void SetOptions(InputContextFlags nOptions)
void InvalidateAll(bool bWithMsg)
ToolbarId GetObjectBarId(sal_uInt16 nPos) const
void Pop(SfxShell &rShell, SfxDispatcherPopFlags nMode=SfxDispatcherPopFlags::NONE)
void Push(SfxShell &rShell)
SfxShell * GetShell(sal_uInt16 nIdx) const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxViewFrame & GetViewFrame() const
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:204
void PrtOLENotify(bool bAll)
Definition: docdesc.cxx:812
SfxShell subclass that is used while interacting with the editeng-based text of a shape.
Definition: drwtxtsh.hxx:32
void UpdateTable()
update fields of a listing
Definition: edtab.cxx:255
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
void UpdatePointer(const Point &, sal_uInt16 nButtons=0)
Definition: edtwin.cxx:344
Style of a layout element.
Definition: frmfmt.hxx:72
void SetTopToolbar(SelectionType nSelType, ToolbarId eBarId)
Definition: barcfg.cxx:82
void SetShellMode(ShellMode eSet)
Definition: uivwimp.cxx:82
SwXTextView * GetUNOObject_Impl()
Definition: uivwimp.cxx:92
Definition: view.hxx:146
SfxShell * GetCurShell()
Definition: view.hxx:586
SwWrtShell & GetWrtShell() const
Definition: view.hxx:423
virtual SdrView * GetDrawView() const override
Definition: viewdraw.cxx:621
SelectionType GetSelectionType() const
Definition: view.hxx:362
virtual FmFormShell * GetFormShell() override
Definition: view.hxx:589
void SetFormShell(FmFormShell *pSh)
Definition: view.hxx:367
const SwFrameFormat * GetLastTableFrameFormat() const
Definition: view.hxx:376
void SetSelectionType(SelectionType nSet)
Definition: view.hxx:363
void ImpSetVerb(SelectionType nSelType)
Definition: view.cxx:141
void SetLastTableFrameFormat(const SwFrameFormat *pSet)
Definition: view.hxx:377
void SetShell(SfxShell *pS)
Definition: view.hxx:366
SwEditWin & GetEditWin()
Definition: view.hxx:426
SwDocShell * GetDocShell()
Definition: view.cxx:1193
SwView_Impl * GetViewImpl()
Definition: view.hxx:358
virtual void SelectShell() override
Definition: wview.cxx:93
SwWebView(SfxViewFrame &rFrame, SfxViewShell *)
Definition: wview.cxx:84
virtual ~SwWebView() override
Definition: wview.cxx:89
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1723
void NotifySelChanged()
Definition: unotxvw.cxx:640
void SetInputContext(const InputContext &rInputContext)
Point PixelToLogic(const Point &rDevicePt) const
Point GetPointerPosPixel()
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
SelectionType
InputContextFlags
int i
#define SFX_OBJECTBAR_OBJECT
#define SFX_OBJECTBAR_TOOLS
#define SFX_IMPL_INTERFACE(Class, SuperClass)
#define SW_MOD()
Definition: swmodule.hxx:254
ToolbarId
ShellMode
Definition: view.hxx:87
#define SFX_VIEW_REGISTRATION(DocClass)
SFX_IMPL_NAMED_VIEWFACTORY(SwWebView, "Default")
Definition: wview.cxx:67