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 <config_feature_desktop.h>
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>
34 #include <sfx2/objface.hxx>
35 #include <swmodule.hxx>
36 #include <unotxvw.hxx>
38 #include <globals.hrc>
45 #include <wlistsh.hxx>
46 #include <wformsh.hxx>
47 #include <wtextsh.hxx>
51 // TECHNICALLY not possible !!
52 #include <beziersh.hxx>
54 #include <drwtxtsh.hxx>
55 #include <annotsh.hxx>
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>
67 SFX_IMPL_NAMED_VIEWFACTORY(SwWebView
, "Default")
69 SFX_VIEW_REGISTRATION(SwWebDocShell
);
72 SFX_IMPL_INTERFACE(SwWebView
, SwView
)
74 void SwWebView::InitInterface_Impl()
76 GetStaticInterface()->RegisterChildWindow(SvxSearchDialogWrapper::GetChildWindowId());
77 GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
79 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS
, SfxVisibilityFlags::Standard
|SfxVisibilityFlags::Server
,
80 ToolbarId::Webtools_Toolbox
);
84 SwWebView::SwWebView(SfxViewFrame
& _rFrame
, SfxViewShell
* _pShell
) :
85 SwView(_rFrame
, _pShell
)
89 SwWebView::~SwWebView()
93 void SwWebView::SelectShell()
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())
101 bUpdateTable
= true; // can only be executed later
103 SetLastTableFrameFormat(pCurTableFormat
);
104 //SEL_TBL and SEL_TBL_CELLS can be ored!
105 SelectionType nNewSelectionType
= GetWrtShell().GetSelectionType()
106 & ~SelectionType::TableCell
;
108 SelectionType _nSelectionType
= GetSelectionType();
109 if ( nNewSelectionType
== _nSelectionType
)
111 GetViewFrame().GetBindings().InvalidateAll( false );
112 if ( _nSelectionType
& SelectionType::Ole
||
113 _nSelectionType
& SelectionType::Graphic
)
114 //The verb may of course change for graphics and OLE!
115 ImpSetVerb( nNewSelectionType
);
119 SfxDispatcher
&rDispatcher
= *GetViewFrame().GetDispatcher();
120 SwToolbarConfigItem
*pBarCfg
= SW_MOD()->GetWebToolbarConfig();
124 rDispatcher
.Flush(); // really delete all cached shells
126 //Additional to the old selection remember which toolbar was visible.
127 ToolbarId eId
= rDispatcher
.GetObjectBarId(SFX_OBJECTBAR_OBJECT
);
128 if (eId
!= ToolbarId::None
)
129 pBarCfg
->SetTopToolbar( _nSelectionType
, eId
);
133 for ( i
= 0; true; ++i
)
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 ) )
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
);
148 bool bInitFormShell
= false;
149 if( !GetFormShell() )
151 bInitFormShell
= true;
152 SetFormShell( new FmFormShell( this ) );
153 rDispatcher
.Push( *GetFormShell() );
156 bool bSetExtInpCntxt
= false;
157 _nSelectionType
= nNewSelectionType
;
158 SetSelectionType( _nSelectionType
);
159 ShellMode eShellMode
;
161 if ( _nSelectionType
& SelectionType::Ole
)
163 eShellMode
= ShellMode::Object
;
164 SetShell( new SwWebOleShell( *this ));
165 rDispatcher
.Push( *GetCurShell() );
167 else if ( _nSelectionType
& SelectionType::Frame
168 || _nSelectionType
& SelectionType::Graphic
)
170 eShellMode
= ShellMode::Frame
;
171 SetShell( new SwWebFrameShell( *this ));
172 rDispatcher
.Push( *GetCurShell() );
173 if(_nSelectionType
& SelectionType::Graphic
)
175 eShellMode
= ShellMode::Graphic
;
176 SetShell( new SwWebGrfShell( *this ));
177 rDispatcher
.Push( *GetCurShell() );
180 else if ( _nSelectionType
& SelectionType::Frame
)
182 eShellMode
= ShellMode::Frame
;
183 SetShell( new SwWebFrameShell( *this ));
184 rDispatcher
.Push( *GetCurShell() );
186 else if ( _nSelectionType
& SelectionType::DrawObject
)
188 eShellMode
= ShellMode::Draw
;
189 SetShell( new svx::ExtrusionBar( this ) );
190 rDispatcher
.Push( *GetCurShell() );
192 SetShell( new svx::FontworkBar( this ) );
193 rDispatcher
.Push( *GetCurShell() );
195 SetShell( new SwDrawShell( *this ));
196 rDispatcher
.Push( *GetCurShell() );
197 if ( _nSelectionType
& SelectionType::Ornament
)
199 eShellMode
= ShellMode::Bezier
;
200 SetShell( new SwBezierShell( *this ));
201 rDispatcher
.Push( *GetCurShell() );
205 else if ( _nSelectionType
& SelectionType::DbForm
)
207 eShellMode
= ShellMode::DrawForm
;
208 SetShell( new SwWebDrawFormShell( *this ));
210 rDispatcher
.Push( *GetCurShell() );
212 else if ( _nSelectionType
& SelectionType::DrawObjectEditMode
)
214 eShellMode
= ShellMode::DrawText
;
215 rDispatcher
.Push( *(new SwBaseShell( *this )) );
216 SetShell( new SwDrawTextShell( *this ));
217 rDispatcher
.Push( *GetCurShell() );
219 else if ( _nSelectionType
& SelectionType::PostIt
)
221 eShellMode
= ShellMode::PostIt
;
222 SetShell( new SwAnnotationShell( *this ) );
223 rDispatcher
.Push( *GetCurShell() );
227 bSetExtInpCntxt
= true;
228 eShellMode
= ShellMode::Text
;
229 if ( _nSelectionType
& SelectionType::NumberList
)
231 eShellMode
= ShellMode::ListText
;
232 SetShell( new SwWebListShell( *this ));
233 rDispatcher
.Push( *GetCurShell() );
235 SetShell( new SwWebTextShell(*this));
236 rDispatcher
.Push( *GetCurShell() );
237 if ( _nSelectionType
& SelectionType::Table
)
239 eShellMode
= eShellMode
== ShellMode::ListText
? ShellMode::TableListText
240 : ShellMode::TableText
;
241 SetShell( new SwWebTableShell( *this ));
242 rDispatcher
.Push( *GetCurShell() );
245 ImpSetVerb( _nSelectionType
);
246 GetViewImpl()->SetShellMode(eShellMode
);
248 if( !GetDocShell()->IsReadOnly() )
250 if( bSetExtInpCntxt
&& GetWrtShell().HasReadonlySel() )
251 bSetExtInpCntxt
= false;
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
);
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?!
271 Point aPnt
= GetEditWin().GetPointerPosPixel();
272 aPnt
= GetEditWin().PixelToLogic(aPnt
);
273 GetEditWin().UpdatePointer(aPnt
);
275 if ( bInitFormShell
&& GetWrtShell().GetDrawView() )
276 GetFormShell()->SetView( dynamic_cast< FmFormView
* >(
277 GetWrtShell().GetDrawView()));
280 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
282 //Opportune time for the communication with OLE objects?
283 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
284 GetDocShell()->GetDoc()->PrtOLENotify( false );
286 //now the table update
288 GetWrtShell().UpdateTable();
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */