Bug Summary

File:home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx
Warning:line 849, column 47
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name view.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SW_DLLIMPLEMENTATION -D SWUI_DLL_NAME="libswuilo.so" -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/sw/source/core/inc -I /home/maarten/src/libreoffice/core/sw/source/filter/inc -I /home/maarten/src/libreoffice/core/sw/source/uibase/inc -I /home/maarten/src/libreoffice/core/sw/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sw/sdi -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/sw/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/oovbaapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx
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_features.h>
21
22#include <stdlib.h>
23#include <hintids.hxx>
24#include <comphelper/string.hxx>
25#include <o3tl/any.hxx>
26#include <officecfg/Office/Common.hxx>
27#include <vcl/graph.hxx>
28#include <vcl/inputctx.hxx>
29#include <svl/eitem.hxx>
30#include <unotools/configmgr.hxx>
31#include <unotools/lingucfg.hxx>
32#include <unotools/useroptions.hxx>
33#include <sfx2/dispatch.hxx>
34#include <sfx2/docfile.hxx>
35#include <sfx2/objface.hxx>
36#include <sfx2/request.hxx>
37#include <svx/ruler.hxx>
38#include <svx/srchdlg.hxx>
39#include <svx/fmshell.hxx>
40#include <svx/extrusionbar.hxx>
41#include <svx/fontworkbar.hxx>
42#include <svx/fmview.hxx>
43#include <unotxvw.hxx>
44#include <cmdid.h>
45#include <svl/hint.hxx>
46#include <swmodule.hxx>
47#include <inputwin.hxx>
48#include <uivwimp.hxx>
49#include <edtwin.hxx>
50#include <textsh.hxx>
51#include <listsh.hxx>
52#include <tabsh.hxx>
53#include <grfsh.hxx>
54#include <mediash.hxx>
55#include <docsh.hxx>
56#include <frmsh.hxx>
57#include <olesh.hxx>
58#include <drawsh.hxx>
59#include <drawbase.hxx>
60#include <drformsh.hxx>
61#include <drwtxtsh.hxx>
62#include <beziersh.hxx>
63#include <navsh.hxx>
64#include <globdoc.hxx>
65#include <scroll.hxx>
66#include <gloshdl.hxx>
67#include <usrpref.hxx>
68#include <srcview.hxx>
69#include <doc.hxx>
70#include <IDocumentUndoRedo.hxx>
71#include <IDocumentSettingAccess.hxx>
72#include <IDocumentDrawModelAccess.hxx>
73#include <DocumentFieldsManager.hxx>
74#include <IDocumentState.hxx>
75#include <IDocumentLayoutAccess.hxx>
76#include <drawdoc.hxx>
77#include <wdocsh.hxx>
78#include <wrtsh.hxx>
79#include <barcfg.hxx>
80#include <pview.hxx>
81#include <swdtflvr.hxx>
82#include <prtopt.hxx>
83#include <com/sun/star/frame/FrameSearchFlag.hpp>
84#include <com/sun/star/frame/XLayoutManager.hpp>
85#include <com/sun/star/scanner/ScannerContext.hpp>
86#include <com/sun/star/scanner/XScannerManager2.hpp>
87#include <toolkit/helper/vclunohelper.hxx>
88#include <sal/log.hxx>
89
90#include <formatclipboard.hxx>
91#include <PostItMgr.hxx>
92#include <annotsh.hxx>
93#include <swruler.hxx>
94
95#include <com/sun/star/document/XDocumentProperties.hpp>
96#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
97
98#include <comphelper/propertyvalue.hxx>
99#include <sfx2/lokhelper.hxx>
100#include <LibreOfficeKit/LibreOfficeKitEnums.h>
101#include <svtools/embedhlp.hxx>
102#include <tools/UnitConversion.hxx>
103
104using namespace ::com::sun::star;
105using namespace ::com::sun::star::uno;
106using namespace ::com::sun::star::lang;
107using namespace ::com::sun::star::scanner;
108
109#define SWVIEWFLAGSSfxViewShellFlags::HAS_PRINTOPTIONS SfxViewShellFlags::HAS_PRINTOPTIONS
110
111// Statics. OMG.
112
113bool bDocSzUpdated = true;
114
115SvxSearchItem* SwView::s_pSrchItem = nullptr;
116
117bool SwView::s_bExtra = false;
118bool SwView::s_bFound = false;
119bool SwView::s_bJustOpened = false;
120
121std::unique_ptr<SearchAttrItemList> SwView::s_xSearchList;
122std::unique_ptr<SearchAttrItemList> SwView::s_xReplaceList;
123
124SfxDispatcher &SwView::GetDispatcher()
125{
126 return *GetViewFrame()->GetDispatcher();
127}
128
129void SwView::ImpSetVerb( SelectionType nSelType )
130{
131 bool bResetVerbs = m_bVerbsActive;
132 if ( !GetViewFrame()->GetFrame().IsInPlace() &&
133 (SelectionType::Ole|SelectionType::Graphic) & nSelType )
134 {
135 if ( m_pWrtShell->IsSelObjProtected(FlyProtectFlags::Content) == FlyProtectFlags::NONE )
136 {
137 if ( nSelType & SelectionType::Ole )
138 {
139 SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
140 m_bVerbsActive = true;
141 bResetVerbs = false;
142 }
143 }
144 }
145 if ( bResetVerbs )
146 {
147 SetVerbs( Sequence< embed::VerbDescriptor >() );
148 m_bVerbsActive = false;
149 }
150}
151
152// Called by the SwEditWin when it gets the focus.
153
154void SwView::GotFocus() const
155{
156 // if we got the focus, and the form shell *is* on the top of the dispatcher
157 // stack, then we need to rebuild the stack (the form shell doesn't belong to
158 // the top then)
159 const SfxDispatcher& rDispatcher = const_cast< SwView* >( this )->GetDispatcher();
160 SfxShell* pTopShell = rDispatcher.GetShell( 0 );
161 FmFormShell* pAsFormShell = dynamic_cast<FmFormShell*>( pTopShell );
162 if ( pAsFormShell )
163 {
164 pAsFormShell->ForgetActiveControl();
165 const_cast< SwView* >( this )->AttrChangedNotify(nullptr);
166 }
167 else if ( m_pPostItMgr )
168 {
169 SwAnnotationShell* pAsAnnotationShell = dynamic_cast<SwAnnotationShell*>( pTopShell );
170 if ( pAsAnnotationShell )
171 {
172 m_pPostItMgr->SetActiveSidebarWin(nullptr);
173 const_cast< SwView* >( this )->AttrChangedNotify(nullptr);
174 }
175 }
176 if( GetWrtShellPtr() )
177 {
178 SwWrtShell& rWrtShell = GetWrtShell();
179 rWrtShell.GetDoc()->getIDocumentLayoutAccess().SetCurrentViewShell( GetWrtShellPtr() );
180 rWrtShell.GetDoc()->getIDocumentSettingAccess().set( DocumentSettingId::BROWSE_MODE,
181 rWrtShell.GetViewOptions()->getBrowseMode() );
182 }
183}
184
185// called by the FormShell when a form control is focused. This is
186// a request to put the form shell on the top of the dispatcher stack
187
188IMPL_LINK_NOARG(SwView, FormControlActivated, LinkParamNone*, void)void SwView::LinkStubFormControlActivated(void * instance, LinkParamNone
* data) { return static_cast<SwView *>(instance)->FormControlActivated
(data); } void SwView::FormControlActivated(__attribute__ ((unused
)) LinkParamNone*)
189{
190 // if a form control has been activated, and the form shell is not on the top
191 // of the dispatcher stack, then we need to activate it
192 const SfxDispatcher& rDispatcher = GetDispatcher();
193 const SfxShell* pTopShell = rDispatcher.GetShell( 0 );
194 const FmFormShell* pAsFormShell = dynamic_cast<const FmFormShell*>( pTopShell );
195 if ( !pAsFormShell )
196 {
197 // if we're editing text currently, cancel this
198 SdrView *pSdrView = m_pWrtShell ? m_pWrtShell->GetDrawView() : nullptr;
199 if ( pSdrView && pSdrView->IsTextEdit() )
200 pSdrView->SdrEndTextEdit( true );
201
202 AttrChangedNotify(nullptr);
203 }
204}
205
206namespace
207{
208uno::Reference<frame::XLayoutManager> getLayoutManager(const SfxViewFrame& rViewFrame)
209{
210 uno::Reference<frame::XLayoutManager> xLayoutManager;
211 uno::Reference<beans::XPropertySet> xPropSet(rViewFrame.GetFrame().GetFrameInterface(),
212 uno::UNO_QUERY);
213 if (xPropSet.is())
214 {
215 try
216 {
217 xLayoutManager.set(xPropSet->getPropertyValue("LayoutManager"), uno::UNO_QUERY);
218 }
219 catch (const Exception& e)
220 {
221 SAL_WARN("sw.ui", "Failure getting layout manager: " + e.Message)do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Failure getting layout manager: " + e.Message) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "221" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Failure getting layout manager: " + e
.Message), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "Failure getting layout manager: "
+ e.Message; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "221" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Failure getting layout manager: " + e.Message) ==
1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "221" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Failure getting layout manager: " + e
.Message), 0); } else { ::std::ostringstream sal_detail_stream
; sal_detail_stream << "Failure getting layout manager: "
+ e.Message; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "221" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
222 }
223 }
224 return xLayoutManager;
225}
226}
227
228void SwView::ShowUIElement(const OUString& sElementURL) const
229{
230 if (auto xLayoutManager = getLayoutManager(*GetViewFrame()))
231 {
232 if (!xLayoutManager->getElement(sElementURL).is())
233 {
234 xLayoutManager->createElement(sElementURL);
235 xLayoutManager->showElement(sElementURL);
236 }
237 }
238}
239
240void SwView::SelectShell()
241{
242 // Attention: Maintain the SelectShell for the WebView additionally
243
244 if(m_bInDtor)
245 return;
246
247 // Decision if the UpdateTable has to be called
248 bool bUpdateTable = false;
249 const SwFrameFormat* pCurTableFormat = m_pWrtShell->GetTableFormat();
250 if(pCurTableFormat && pCurTableFormat != m_pLastTableFormat)
251 {
252 bUpdateTable = true; // can only be executed later
253 }
254 m_pLastTableFormat = pCurTableFormat;
255
256 //SEL_TBL and SEL_TBL_CELLS can be ORed!
257 SelectionType nNewSelectionType = m_pWrtShell->GetSelectionType()
258 & ~SelectionType::TableCell;
259
260 if ( m_pFormShell && m_pFormShell->IsActiveControl() )
261 nNewSelectionType |= SelectionType::FormControl;
262
263 if ( nNewSelectionType == m_nSelectionType )
264 {
265 GetViewFrame()->GetBindings().InvalidateAll( false );
266 if ( m_nSelectionType & SelectionType::Ole ||
267 m_nSelectionType & SelectionType::Graphic )
268 // For graphs and OLE the verb can be modified of course!
269 ImpSetVerb( nNewSelectionType );
270 }
271 else
272 {
273
274 SfxDispatcher &rDispatcher = GetDispatcher();
275 SwToolbarConfigItem *pBarCfg = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetToolbarConfig();
276
277 if ( m_pShell )
278 {
279 rDispatcher.Flush(); // Really erase all cached shells
280 //Remember to the old selection which toolbar was visible
281 ToolbarId eId = rDispatcher.GetObjectBarId(SFX_OBJECTBAR_OBJECT1);
282 if (eId != ToolbarId::None)
283 pBarCfg->SetTopToolbar(m_nSelectionType, eId);
284
285 for ( sal_uInt16 i = 0; true; ++i )
286 {
287 SfxShell *pSfxShell = rDispatcher.GetShell( i );
288 if ( dynamic_cast< const SwBaseShell *>( pSfxShell ) != nullptr
289 || dynamic_cast< const SwDrawTextShell *>( pSfxShell ) != nullptr
290 || dynamic_cast< const svx::ExtrusionBar*>( pSfxShell ) != nullptr
291 || dynamic_cast< const svx::FontworkBar*>( pSfxShell ) != nullptr
292 || dynamic_cast< const SwAnnotationShell *>( pSfxShell ) != nullptr
293 )
294 {
295 rDispatcher.Pop( *pSfxShell, SfxDispatcherPopFlags::POP_DELETE );
296 }
297 else if ( dynamic_cast< const FmFormShell *>( pSfxShell ) != nullptr )
298 {
299 rDispatcher.Pop( *pSfxShell );
300 }
301 else
302 break;
303 }
304 }
305
306 bool bInitFormShell = false;
307 if (!m_pFormShell)
308 {
309 bInitFormShell = true;
310 m_pFormShell = new FmFormShell( this );
311 m_pFormShell->SetControlActivationHandler( LINK( this, SwView, FormControlActivated )::tools::detail::makeLink( ::tools::detail::castTo<SwView *
>(this), &SwView::LinkStubFormControlActivated)
);
312 StartListening(*m_pFormShell);
313 }
314
315 bool bSetExtInpCntxt = false;
316 m_nSelectionType = nNewSelectionType;
317 ShellMode eShellMode;
318
319 if ( !( m_nSelectionType & SelectionType::FormControl ) )
320 rDispatcher.Push( *m_pFormShell );
321
322 m_pShell = new SwNavigationShell( *this );
323 rDispatcher.Push( *m_pShell );
324
325 if ( m_nSelectionType & SelectionType::Ole )
326 {
327 eShellMode = ShellMode::Object;
328 m_pShell = new SwOleShell( *this );
329 rDispatcher.Push( *m_pShell );
330 }
331 else if ( m_nSelectionType & SelectionType::Frame
332 || m_nSelectionType & SelectionType::Graphic)
333 {
334 eShellMode = ShellMode::Frame;
335 m_pShell = new SwFrameShell( *this );
336 rDispatcher.Push( *m_pShell );
337 if(m_nSelectionType & SelectionType::Graphic )
338 {
339 eShellMode = ShellMode::Graphic;
340 m_pShell = new SwGrfShell( *this );
341 rDispatcher.Push( *m_pShell );
342 }
343 }
344 else if ( m_nSelectionType & SelectionType::DrawObject )
345 {
346 eShellMode = ShellMode::Draw;
347 m_pShell = new SwDrawShell( *this );
348 rDispatcher.Push( *m_pShell );
349
350 if ( m_nSelectionType & SelectionType::Ornament )
351 {
352 eShellMode = ShellMode::Bezier;
353 m_pShell = new SwBezierShell( *this );
354 rDispatcher.Push( *m_pShell );
355 }
356#if HAVE_FEATURE_AVMEDIA1
357 else if( m_nSelectionType & SelectionType::Media )
358 {
359 eShellMode = ShellMode::Media;
360 m_pShell = new SwMediaShell( *this );
361 rDispatcher.Push( *m_pShell );
362 }
363#endif
364 if (m_nSelectionType & SelectionType::ExtrudedCustomShape)
365 {
366 eShellMode = ShellMode::ExtrudedCustomShape;
367 m_pShell = new svx::ExtrusionBar(this);
368 rDispatcher.Push( *m_pShell );
369 }
370 if (m_nSelectionType & SelectionType::FontWork)
371 {
372 eShellMode = ShellMode::FontWork;
373 m_pShell = new svx::FontworkBar(this);
374 rDispatcher.Push( *m_pShell );
375 }
376 }
377 else if ( m_nSelectionType & SelectionType::DbForm )
378 {
379 eShellMode = ShellMode::DrawForm;
380 m_pShell = new SwDrawFormShell( *this );
381
382 rDispatcher.Push( *m_pShell );
383 }
384 else if ( m_nSelectionType & SelectionType::DrawObjectEditMode )
385 {
386 bSetExtInpCntxt = true;
387 eShellMode = ShellMode::DrawText;
388 rDispatcher.Push( *(new SwBaseShell( *this )) );
389 m_pShell = new SwDrawTextShell( *this );
390 rDispatcher.Push( *m_pShell );
391 }
392 else if ( m_nSelectionType & SelectionType::PostIt )
393 {
394 eShellMode = ShellMode::PostIt;
395 m_pShell = new SwAnnotationShell( *this );
396 rDispatcher.Push( *m_pShell );
397 }
398 else
399 {
400 bSetExtInpCntxt = true;
401 eShellMode = ShellMode::Text;
402 if ( m_nSelectionType & SelectionType::NumberList )
403 {
404 eShellMode = ShellMode::ListText;
405 m_pShell = new SwListShell( *this );
406 rDispatcher.Push( *m_pShell );
407 }
408 m_pShell = new SwTextShell(*this);
409 rDispatcher.Push( *m_pShell );
410 if ( m_nSelectionType & SelectionType::Table )
411 {
412 eShellMode = eShellMode == ShellMode::ListText ? ShellMode::TableListText
413 : ShellMode::TableText;
414 m_pShell = new SwTableShell( *this );
415 rDispatcher.Push( *m_pShell );
416 }
417 }
418
419 if ( m_nSelectionType & SelectionType::FormControl )
420 rDispatcher.Push( *m_pFormShell );
421
422 m_pViewImpl->SetShellMode(eShellMode);
423 ImpSetVerb( m_nSelectionType );
424
425 if( !GetDocShell()->IsReadOnly() )
426 {
427 if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
428 bSetExtInpCntxt = false;
429
430 InputContext aCntxt( GetEditWin().GetInputContext() );
431 aCntxt.SetOptions( bSetExtInpCntxt
432 ? (aCntxt.GetOptions() |
433 ( InputContextFlags::Text |
434 InputContextFlags::ExtText ))
435 : (aCntxt.GetOptions() & ~
436 InputContextFlags( InputContextFlags::Text |
437 InputContextFlags::ExtText )) );
438 GetEditWin().SetInputContext( aCntxt );
439 }
440
441 // Show Mail Merge toolbar initially for documents with Database fields
442 if (!m_bInitOnceCompleted && GetWrtShell().IsAnyDatabaseFieldInDoc())
443 ShowUIElement("private:resource/toolbar/mailmerge");
444
445 // Activate the toolbar to the new selection which also was active last time.
446 // Before a flush () must be, but does not affect the UI according to MBA and
447 // is not a performance problem.
448 // TODO/LATER: maybe now the Flush() command is superfluous?!
449 rDispatcher.Flush();
450
451 Point aPnt = GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
452 aPnt = GetEditWin().PixelToLogic(aPnt);
453 GetEditWin().UpdatePointer(aPnt);
454
455 SdrView* pDView = GetWrtShell().GetDrawView();
456 if ( bInitFormShell && pDView )
457 m_pFormShell->SetView(dynamic_cast<FmFormView*>( pDView) );
458
459 }
460 // Opportune time for the communication with OLE objects?
461 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
462 GetDocShell()->GetDoc()->PrtOLENotify( false );
463
464 // now the table-update
465 if(bUpdateTable)
466 m_pWrtShell->UpdateTable();
467
468 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
469
470 m_bInitOnceCompleted = true;
471}
472
473// Interaction: AttrChangedNotify() and TimeoutHdl.
474// No Update if actions are still open, since the cursor on the core side
475// can be somewhere in no man's land.
476// But since we can no longer supply status and we want instead lock
477// the dispatcher.
478
479extern "C"
480{
481 static int lcl_CmpIds( const void *pFirst, const void *pSecond)
482 {
483 return *static_cast<sal_uInt16 const *>(pFirst) - *static_cast<sal_uInt16 const *>(pSecond);
484 }
485}
486
487IMPL_LINK_NOARG(SwView, AttrChangedNotify, LinkParamNone*, void)void SwView::LinkStubAttrChangedNotify(void * instance, LinkParamNone
* data) { return static_cast<SwView *>(instance)->AttrChangedNotify
(data); } void SwView::AttrChangedNotify(__attribute__ ((unused
)) LinkParamNone*)
488{
489 if ( GetEditWin().IsChainMode() )
490 GetEditWin().SetChainMode( false );
491
492 //Opt: Not if PaintLocked. During unlock a notify will be once more triggered.
493 if( !m_pWrtShell->IsPaintLocked() && !g_bNoInterrupt &&
494 GetDocShell()->IsReadOnly() )
495 CheckReadonlyState();
496
497 if( !m_pWrtShell->IsPaintLocked() && !g_bNoInterrupt )
498 CheckReadonlySelection();
499
500 if( !m_bAttrChgNotified )
501 {
502 if (m_pWrtShell->ActionPend() || g_bNoInterrupt ||
503 GetDispatcher().IsLocked() || //do not confuse the SFX
504 GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
505 {
506 m_bAttrChgNotified = true;
507 m_aTimer.Start();
508
509 const SfxPoolItem *pItem;
510 if ( SfxItemState::SET != GetObjectShell()->GetMedium()->GetItemSet()->
511 GetItemState( SID_HIDDEN(5000 + 534), false, &pItem ) ||
512 !static_cast<const SfxBoolItem*>(pItem)->GetValue() )
513 {
514 GetViewFrame()->GetBindings().ENTERREGISTRATIONS()EnterRegistrations();
515 m_bAttrChgNotifiedWithRegistrations = true;
516 }
517
518 }
519 else
520 SelectShell();
521
522 }
523
524 // change ui if cursor is at a SwPostItField
525 if (m_pPostItMgr)
526 {
527 // only perform the code that is needed to determine, if at the
528 // actual cursor position is a post-it field
529 m_pPostItMgr->SetShadowState( m_pWrtShell->GetPostItFieldAtCursor() );
530 }
531}
532
533IMPL_LINK_NOARG(SwView, TimeoutHdl, Timer *, void)void SwView::LinkStubTimeoutHdl(void * instance, Timer * data
) { return static_cast<SwView *>(instance)->TimeoutHdl
(data); } void SwView::TimeoutHdl(__attribute__ ((unused)) Timer
*)
534{
535 if (m_pWrtShell->ActionPend() || g_bNoInterrupt)
536 {
537 m_aTimer.Start();
538 return;
539 }
540
541 if ( m_bAttrChgNotifiedWithRegistrations )
542 {
543 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS()LeaveRegistrations();
544 m_bAttrChgNotifiedWithRegistrations = false;
545 }
546
547 CheckReadonlyState();
548 CheckReadonlySelection();
549
550 bool bOldUndo = m_pWrtShell->DoesUndo();
551 m_pWrtShell->DoUndo( false );
552 SelectShell();
553 m_pWrtShell->DoUndo( bOldUndo );
554 m_bAttrChgNotified = false;
555 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
556}
557
558void SwView::CheckReadonlyState()
559{
560 SfxDispatcher &rDis = GetDispatcher();
561 // To be able to recognize if it is already disabled!
562 SfxItemState eStateRO, eStateProtAll;
563 const SfxPoolItem *pItem;
564 // Query the status from a slot which is only known to us.
565 // Otherwise the slot is known from other; like the BasicIde
566 eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK((20000 + 300) + 2 ), pItem );
567 eStateProtAll = rDis.QueryState( FN_EDIT_REGION((20000 + 100) + 65), pItem );
568 bool bChgd = false;
569
570 if ( !m_pWrtShell->IsCursorReadonly() )
571 {
572 static sal_uInt16 aROIds[] =
573 {
574 SID_DELETE(5000 + 713), FN_BACKSPACE((20000 + 900) + 26), FN_SHIFT_BACKSPACE((20000 + 900) + 42),
575 SID_UNDO(5000 + 701),
576 SID_REDO(5000 + 700), SID_REPEAT(5000 + 702), SID_PASTE(5000 + 712),
577 SID_PASTE_UNFORMATTED(5000 + 314), FN_PASTE_NESTED_TABLE((20000 + 1400) + 30), FN_TABLE_PASTE_ROW_BEFORE((20000 + 1400) + 31),
578 FN_TABLE_PASTE_COL_BEFORE((20000 + 1400) + 32), SID_PASTE_SPECIAL(5000 + 311), SID_SBA_BRW_INSERT(((((((10000 + 1499) + 1) + 499) + 1) + 100) + 1)+101),
579 SID_BACKGROUND_COLORTypedWhichId<SvxColorItem>( 10000 + 186 ), FN_INSERT_BOOKMARK((20000 + 300) + 2 ), SID_CHARMAP_CONTROL(5000 + 406),
580 SID_CHARMAP((10000 + 500) + 3), SID_EMOJI_CONTROL(5000 + 405), FN_INSERT_SOFT_HYPHEN((20000 + 300) + 43),
581 FN_INSERT_HARDHYPHEN((20000 + 300) + 85), FN_INSERT_HARD_SPACE((20000 + 300) + 44), FN_INSERT_NNBSP((20000 + 300) + 45),
582 FN_INSERT_BREAK((20000 + 300) + 3), FN_INSERT_LINEBREAK((20000 + 300) + 18), FN_INSERT_COLUMN_BREAK((20000 + 300) + 5 ),
583 FN_INSERT_BREAK_DLG((20000 + 300) + 4 ),
584 FN_DELETE_SENT((20000 + 900) + 27), FN_DELETE_BACK_SENT((20000 + 900) + 28), FN_DELETE_WORD((20000 + 900) + 29),
585 FN_DELETE_BACK_WORD((20000 + 900) + 30), FN_DELETE_LINE((20000 + 900) + 31), FN_DELETE_BACK_LINE((20000 + 900) + 32),
586 FN_DELETE_PARA((20000 + 900) + 33), FN_DELETE_BACK_PARA((20000 + 900) + 34), FN_DELETE_WHOLE_LINE((20000 + 900) + 35),
587 FN_CALCULATE((20000 + 600) + 15), FN_FORMAT_RESET((20000 + 400) + 69),
588 FN_POSTIT((20000 + 300) + 29), FN_JAVAEDIT((20000 + 1400) + 10), SID_ATTR_PARA_ADJUST_LEFT( 10000 + 28 ),
589 SID_ATTR_PARA_ADJUST_RIGHT( 10000 + 29 ), SID_ATTR_PARA_ADJUST_CENTER( 10000 + 30 ),SID_ATTR_PARA_ADJUST_BLOCK( 10000 + 31 ),
590 SID_ATTR_PARA_LINESPACE_10( 10000 + 34 ), SID_ATTR_PARA_LINESPACE_15( 10000 + 35 ), SID_ATTR_PARA_LINESPACE_20( 10000 + 36 ),
591 SID_ATTR_CHAR_FONT( 10000 + 7 ), SID_ATTR_CHAR_FONTHEIGHT( 10000 + 15 ), SID_ATTR_CHAR_COLOR_BACKGROUND(10000 + 489),
592 SID_ATTR_CHAR_COLOR_BACKGROUND_EXT(10000 + 490), SID_ATTR_CHAR_COLOR_EXT(10000 + 488),
593 SID_ATTR_CHAR_COLOR( 10000 + 17 ), SID_ATTR_CHAR_WEIGHT( 10000 + 9 ), SID_ATTR_CHAR_POSTURE( 10000 + 8 ),
594 SID_ATTR_CHAR_OVERLINE( ((10000 + 1499) + 1) + 68 ),
595 SID_ATTR_CHAR_UNDERLINE( 10000 + 14 ), SID_ATTR_FLASH( 10000 + 406 ), SID_ATTR_CHAR_STRIKEOUT( 10000 + 13 ),
596 SID_ULINE_VAL_SINGLE(10000 + 1196), SID_ULINE_VAL_DOUBLE(10000 + 1197), SID_ULINE_VAL_DOTTED(10000 + 1198),
597 SID_ATTR_CHAR_CONTOUR( 10000 + 12 ), SID_ATTR_CHAR_SHADOWED( 10000 + 10 ),
598 SID_ATTR_CHAR_AUTOKERN( 10000 + 67 ), SID_ATTR_CHAR_ESCAPEMENT( 10000 + 21 ), FN_SET_SUPER_SCRIPT((20000 + 400) + 11),
599 FN_SET_SUB_SCRIPT((20000 + 400) + 12), SID_ATTR_CHAR_CASEMAP( 10000 + 19 ), SID_ATTR_CHAR_LANGUAGE( 10000 + 20 ),
600 SID_ATTR_CHAR_KERNING( 10000 + 18 ), SID_CHAR_DLG( 10000 + 296 ), SID_ATTR_CHAR_WORDLINEMODE( 10000 + 11 ),
601 FN_GROW_FONT_SIZE((20000 + 400) + 3 ), FN_SHRINK_FONT_SIZE((20000 + 400) + 4 ), FN_TXTATR_INET((20000 + 1000) +29),
602 FN_FORMAT_DROPCAPS((20000 + 400) + 54), SID_ATTR_PARA_ADJUST( 10000 + 27 ), SID_ATTR_PARA_LINESPACE( 10000 + 33 ),
603 SID_ATTR_PARA_SPLIT( 10000 + 39 ), SID_ATTR_PARA_KEEP( 10000 + 66 ), SID_ATTR_PARA_WIDOWS( 10000 + 41 ),
604 SID_ATTR_PARA_ORPHANS( 10000 + 40 ),
605 SID_ATTR_PARA_MODEL( 10000 + 65 ), SID_PARA_DLG( 10000 + 297 ),
606 FN_SELECT_PARA((20000 + 100) + 97), SID_DEC_INDENT( 10000 + 461 ),
607 SID_INC_INDENT( 10000 + 462 )
608 };
609 static bool bFirst = true;
610 if ( bFirst )
611 {
612 qsort( static_cast<void*>(aROIds), SAL_N_ELEMENTS(aROIds)(sizeof(sal_n_array_size(aROIds))), sizeof(sal_uInt16), lcl_CmpIds );
613 bFirst = false;
614 }
615 if ( SfxItemState::DISABLED == eStateRO )
616 {
617 rDis.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY, aROIds );
618 bChgd = true;
619 }
620 }
621 else if( m_pWrtShell->IsAllProtect() )
622 {
623 if ( SfxItemState::DISABLED == eStateProtAll )
624 {
625 static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC(5000 + 505), FN_EDIT_REGION((20000 + 100) + 65) };
626 static bool bAllProtFirst = true;
627 if ( bAllProtFirst )
628 {
629 qsort( static_cast<void*>(aAllProtIds), SAL_N_ELEMENTS(aAllProtIds)(sizeof(sal_n_array_size(aAllProtIds))), sizeof(sal_uInt16), lcl_CmpIds );
630 bAllProtFirst = false;
631 }
632 rDis.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY, aAllProtIds );
633 bChgd = true;
634 }
635 }
636 else if ( SfxItemState::DISABLED != eStateRO ||
637 SfxItemState::DISABLED != eStateProtAll )
638 {
639 bChgd = true;
640 rDis.SetSlotFilter();
641 }
642 if ( bChgd )
643 GetViewFrame()->GetBindings().InvalidateAll(true);
644}
645
646void SwView::CheckReadonlySelection()
647{
648 SfxDisableFlags nDisableFlags = SfxDisableFlags::NONE;
649 SfxDispatcher &rDis = GetDispatcher();
650
651 if( m_pWrtShell->HasReadonlySel() &&
652 ( !m_pWrtShell->GetDrawView() ||
653 !m_pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
654 nDisableFlags |= SfxDisableFlags::SwOnProtectedCursor;
655
656 if( (SfxDisableFlags::SwOnProtectedCursor & nDisableFlags ) !=
657 (SfxDisableFlags::SwOnProtectedCursor & rDis.GetDisableFlags() ) )
658 {
659 // Additionally move at the Window the InputContext, so that
660 // in japanese / chinese versions the external input will be
661 // turned on or off. This but only if the correct shell is on
662 // the stack.
663 switch( m_pViewImpl->GetShellMode() )
664 {
665 case ShellMode::Text:
666 case ShellMode::ListText:
667 case ShellMode::TableText:
668 case ShellMode::TableListText:
669 {
670// Temporary solution!!! Should set the font of the current insertion point
671// at each cursor movement, so outside of this "if". But TH does not
672// evaluates the font at this time and the "purchase" appears to me
673// as too expensive.
674// Moreover, we don't have a font, but only attributes from which the
675// text formatting and the correct font will be build together.
676
677 InputContext aCntxt( GetEditWin().GetInputContext() );
678 aCntxt.SetOptions( SfxDisableFlags::SwOnProtectedCursor & nDisableFlags
679 ? (aCntxt.GetOptions() & ~
680 InputContextFlags( InputContextFlags::Text |
681 InputContextFlags::ExtText ))
682 : (aCntxt.GetOptions() |
683 ( InputContextFlags::Text |
684 InputContextFlags::ExtText )) );
685 GetEditWin().SetInputContext( aCntxt );
686 }
687 break;
688 default:
689 ;
690 }
691
692 }
693
694 if( nDisableFlags != rDis.GetDisableFlags() )
695 {
696 rDis.SetDisableFlags( nDisableFlags );
697 GetViewFrame()->GetBindings().InvalidateAll( true );
698 }
699}
700
701SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
702 : SfxViewShell( _pFrame, SWVIEWFLAGSSfxViewShellFlags::HAS_PRINTOPTIONS ),
703 m_nNewPage(USHRT_MAX(32767 *2 +1)),
704 m_nOldPageNum(0),
705 m_pNumRuleNodeFromDoc(nullptr),
706 m_pEditWin( VclPtr<SwEditWin>::Create( &_pFrame->GetWindow(), *this ) ),
707 m_pShell(nullptr),
708 m_pFormShell(nullptr),
709 m_pHScrollbar(nullptr),
710 m_pVScrollbar(nullptr),
711 m_pScrollFill(VclPtr<ScrollBarBox>::Create( &_pFrame->GetWindow(), WB_SIZEABLE )),
712 m_pVRuler(VclPtr<SvxRuler>::Create(&GetViewFrame()->GetWindow(), m_pEditWin,
713 SvxRulerSupportFlags::TABS | SvxRulerSupportFlags::PARAGRAPH_MARGINS_VERTICAL|
714 SvxRulerSupportFlags::BORDERS | SvxRulerSupportFlags::REDUCED_METRIC,
715 GetViewFrame()->GetBindings(),
716 WB_VSCROLL | WB_EXTRAFIELD | WB_BORDER )),
717 m_pLastTableFormat(nullptr),
718 m_pFormatClipboard(new SwFormatClipboard()),
719 m_nSelectionType( SelectionType::All ),
720 m_nPageCnt(0),
721 m_nDrawSfxId( USHRT_MAX(32767 *2 +1) ),
722 m_nFormSfxId( USHRT_MAX(32767 *2 +1) ),
723 m_nLastPasteDestination( static_cast<SotExchangeDest>(0xFFFF) ),
724 m_nLeftBorderDistance( 0 ),
725 m_nRightBorderDistance( 0 ),
726 m_eLastSearchCommand( static_cast<SvxSearchCmd>(0xFFFF) ),
727 m_bWheelScrollInProgress(false),
728 m_bCenterCursor(false),
729 m_bTopCursor(false),
730 m_bTabColFromDoc(false),
731 m_bTabRowFromDoc(false),
732 m_bSetTabColFromDoc(false),
733 m_bSetTabRowFromDoc(false),
734 m_bAttrChgNotified(false),
735 m_bAttrChgNotifiedWithRegistrations(false),
736 m_bVerbsActive(false),
737 m_bDrawRotate(false),
738 m_bDrawSelMode(true),
739 m_bShowAtResize(true),
740 m_bInOuterResizePixel(false),
741 m_bInInnerResizePixel(false),
742 m_bPasteState(false),
743 m_bPasteSpecialState(false),
744 m_bInMailMerge(false),
745 m_bInDtor(false),
746 m_bOldShellWasPagePreview(false),
747 m_bIsPreviewDoubleClick(false),
748 m_bMakeSelectionVisible(false),
749 m_nLOKPageUpDownOffset(0)
750{
751 static bool bRequestDoubleBuffering = getenv("VCL_DOUBLEBUFFERING_ENABLE");
752 if (bRequestDoubleBuffering)
1
Assuming 'bRequestDoubleBuffering' is false
2
Taking false branch
753 m_pEditWin->RequestDoubleBuffering(true);
754
755 // According to discussion with MBA and further
756 // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
757 // if function "New Window" is performed to open an additional view beside
758 // an already existing one.
759 // If the view is switch from one to another, the 'old' view is given by
760 // parameter <pOldSh>.
761
762 bDocSzUpdated = true;
763
764 CreateScrollbar( true );
765 CreateScrollbar( false );
766
767 m_pViewImpl.reset(new SwView_Impl(this));
768 SetName("View");
769 SetWindow( m_pEditWin );
770
771 m_aTimer.SetTimeout( 120 );
772
773 SwDocShell& rDocSh = dynamic_cast<SwDocShell&>(*_pFrame->GetObjectShell());
774 bool bOldModifyFlag = rDocSh.IsEnableSetModified();
775 if (bOldModifyFlag)
3
Assuming 'bOldModifyFlag' is false
4
Taking false branch
776 rDocSh.EnableSetModified( false );
777 // HACK: SwDocShell has some cached font info, VCL informs about font updates,
778 // but loading of docs with embedded fonts happens after SwDocShell is created
779 // but before SwEditWin (which handles the VCL event) is created. So update
780 // manually.
781 if (rDocSh.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS ))
5
Assuming the condition is false
6
Taking false branch
782 rDocSh.UpdateFontList();
783 bool bWebDShell = dynamic_cast<const SwWebDocShell*>(&rDocSh) != nullptr;
784
785 const SwMasterUsrPref *pUsrPref = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetUsrPref(bWebDShell);
786 SwViewOption aUsrPref( *pUsrPref);
787
788 //! get lingu options without loading lingu DLL
789 SvtLinguOptions aLinguOpt;
790 SvtLinguConfig().GetOptions( aLinguOpt );
791 aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );
792
793 bool bOldShellWasSrcView = false;
794
795 // determine if there is an existing view for
796 // document
797 SfxViewShell* pExistingSh = nullptr;
7
'pExistingSh' initialized to a null pointer value
798 if ( pOldSh )
8
Assuming 'pOldSh' is null
9
Taking false branch
799 {
800 pExistingSh = pOldSh;
801 // determine type of existing view
802 if (SwPagePreview* pPagePreview = dynamic_cast<SwPagePreview *>(pExistingSh))
803 {
804 m_sSwViewData = pPagePreview->GetPrevSwViewData();
805 m_sNewCursorPos = pPagePreview->GetNewCursorPos();
806 m_nNewPage = pPagePreview->GetNewPage();
807 m_bOldShellWasPagePreview = true;
808 m_bIsPreviewDoubleClick = !m_sNewCursorPos.isEmpty() || m_nNewPage != USHRT_MAX(32767 *2 +1);
809 }
810 else if (dynamic_cast<const SwSrcView *>(pExistingSh) != nullptr)
811 bOldShellWasSrcView = true;
812 }
813
814 SAL_INFO( "sw.ui", "before create WrtShell" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "before create WrtShell") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "814" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "before create WrtShell"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"before create WrtShell"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "814" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "before create WrtShell") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "814" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "before create WrtShell"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"before create WrtShell"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "814" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
10
Taking true branch
11
'Default' branch taken. Execution continues on line 814
12
Loop condition is false. Exiting loop
815 if (SwView *pView
12.1
'pView' is null
= dynamic_cast<SwView*>(pExistingSh))
13
Taking false branch
816 {
817 m_pWrtShell.reset(new SwWrtShell(*pView->m_pWrtShell, m_pEditWin, *this));
818 }
819 else if (SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(rDocSh.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()))
14
Assuming 'pWrtShell' is null
15
Taking false branch
820 {
821 m_pWrtShell.reset(new SwWrtShell(*pWrtShell, m_pEditWin, *this));
822 }
823 else
824 {
825 SwDoc& rDoc = *rDocSh.GetDoc();
826
827 if( !bOldShellWasSrcView
15.1
'bOldShellWasSrcView' is false
&& bWebDShell
15.2
'bWebDShell' is false
&& !m_bOldShellWasPagePreview )
828 aUsrPref.setBrowseMode( true );
829 else
830 aUsrPref.setBrowseMode( rDoc.getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE) );
831
832 //For the BrowseMode we do not assume a factor.
833 if( aUsrPref.getBrowseMode() && aUsrPref.GetZoomType() != SvxZoomType::PERCENT )
16
Assuming the condition is false
834 {
835 aUsrPref.SetZoomType( SvxZoomType::PERCENT );
836 aUsrPref.SetZoom( 100 );
837 }
838 if (rDocSh.IsPreview())
17
Assuming the condition is false
18
Taking false branch
839 {
840 aUsrPref.SetZoomType( SvxZoomType::WHOLEPAGE );
841 aUsrPref.SetViewLayoutBookMode( false );
842 aUsrPref.SetViewLayoutColumns( 1 );
843 }
844 m_pWrtShell.reset(new SwWrtShell(rDoc, m_pEditWin, *this, &aUsrPref));
845 // creating an SwView from a SwPagePreview needs to
846 // add the SwViewShell to the ring of the other SwViewShell(s)
847 if(m_bOldShellWasPagePreview)
19
Assuming field 'm_bOldShellWasPagePreview' is true
20
Taking true branch
848 {
849 SwViewShell& rPreviewViewShell = *static_cast<SwPagePreview*>(pExistingSh)->GetViewShell();
21
Called C++ object pointer is null
850 m_pWrtShell->MoveTo(&rPreviewViewShell);
851 // to update the field command et.al. if necessary
852 const SwViewOption* pPreviewOpt = rPreviewViewShell.GetViewOptions();
853 if( pPreviewOpt->IsFieldName() != aUsrPref.IsFieldName() ||
854 pPreviewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() ||
855 pPreviewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() ||
856 pPreviewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() )
857 rPreviewViewShell.ApplyViewOptions(aUsrPref);
858 // reset design mode at draw view for form
859 // shell, if needed.
860 if ( static_cast<SwPagePreview*>(pExistingSh)->ResetFormDesignMode() &&
861 m_pWrtShell->HasDrawView() )
862 {
863 SdrView* pDrawView = m_pWrtShell->GetDrawView();
864 pDrawView->SetDesignMode( static_cast<SwPagePreview*>(pExistingSh)->FormDesignModeToReset() );
865 }
866 }
867 }
868 SAL_INFO( "sw.ui", "after create WrtShell" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_INFO
, "sw.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "after create WrtShell") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "868" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "after create WrtShell"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"after create WrtShell"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "868" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "after create WrtShell") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_INFO), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "868" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "after create WrtShell"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"after create WrtShell"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_INFO
), ("sw.ui"), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "868" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
869 m_pHRuler = VclPtr<SwCommentRuler>::Create(m_pWrtShell.get(), &GetViewFrame()->GetWindow(), m_pEditWin,
870 SvxRulerSupportFlags::TABS |
871 SvxRulerSupportFlags::PARAGRAPH_MARGINS |
872 SvxRulerSupportFlags::BORDERS |
873 SvxRulerSupportFlags::NEGATIVE_MARGINS|
874 SvxRulerSupportFlags::REDUCED_METRIC,
875 GetViewFrame()->GetBindings(),
876 WB_STDRULER | WB_EXTRAFIELD | WB_BORDER);
877
878 // assure that modified state of document
879 // isn't reset, if document is already modified.
880 const bool bIsDocModified = m_pWrtShell->GetDoc()->getIDocumentState().IsModified();
881
882 // Thus among other things, the HRuler is not displayed in the read-only case.
883 aUsrPref.SetReadonly( m_pWrtShell->GetViewOptions()->IsReadonly() );
884
885 // no margin for OLE!
886 Size aBrwsBorder;
887 if( SfxObjectCreateMode::EMBEDDED != rDocSh.GetCreateMode() )
888 aBrwsBorder = GetMargin();
889
890 m_pWrtShell->SetBrowseBorder( aBrwsBorder );
891
892 // In CTOR no shell changes may take place, which must be temporarily stored
893 // with the timer. Otherwise, the SFX removes them from the stack!
894 bool bOld = g_bNoInterrupt;
895 g_bNoInterrupt = true;
896
897 m_pHRuler->SetActive();
898 m_pVRuler->SetActive();
899
900 SfxViewFrame* pViewFrame = GetViewFrame();
901
902 StartListening(*pViewFrame, DuplicateHandling::Prevent);
903 StartListening(rDocSh, DuplicateHandling::Prevent);
904
905 // Set Zoom-factor from HRuler
906 Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
907 m_pHRuler->SetZoom( aZoomFract );
908 m_pVRuler->SetZoom( aZoomFract );
909 m_pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick )::tools::detail::makeLink( ::tools::detail::castTo<SwView *
>(this), &SwView::LinkStubExecRulerClick)
);
910 FieldUnit eMetric = pUsrPref->GetHScrollMetric();
911 m_pHRuler->SetUnit( eMetric );
912
913 eMetric = pUsrPref->GetVScrollMetric();
914 m_pVRuler->SetUnit( eMetric );
915
916 m_pHRuler->SetCharWidth( 371 ); // default character width
917 m_pVRuler->SetLineHeight( 551 ); // default line height
918
919 // Set DocShell
920 m_xGlueDocShell.reset(new SwViewGlueDocShell(*this, rDocSh));
921 m_pPostItMgr.reset(new SwPostItMgr(this));
922
923 // Check and process the DocSize. Via the handler, the shell could not
924 // be found, because the shell is not known in the SFX management
925 // within the CTOR phase.
926 DocSzChgd( m_pWrtShell->GetDocSize() );
927
928 // Set AttrChangedNotify link
929 m_pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify)::tools::detail::makeLink( ::tools::detail::castTo<SwView *
>(this), &SwView::LinkStubAttrChangedNotify)
);
930
931 if (rDocSh.GetCreateMode() == SfxObjectCreateMode::EMBEDDED &&
932 !rDocSh.GetVisArea(ASPECT_CONTENT1).IsEmpty())
933 SetVisArea(rDocSh.GetVisArea(ASPECT_CONTENT1),false);
934
935 SAL_WARN_IF(do { if (true && (officecfg::Office::Common::Undo::Steps
::get() <= 0)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "/org.openoffice.Office.Common/Undo/Steps <= 0";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui")
, ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "/org.openoffice.Office.Common/Undo/Steps <= 0";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui")
, ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
936 officecfg::Office::Common::Undo::Steps::get() <= 0,do { if (true && (officecfg::Office::Common::Undo::Steps
::get() <= 0)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "/org.openoffice.Office.Common/Undo/Steps <= 0";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui")
, ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "/org.openoffice.Office.Common/Undo/Steps <= 0";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui")
, ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
937 "sw.ui", "/org.openoffice.Office.Common/Undo/Steps <= 0")do { if (true && (officecfg::Office::Common::Undo::Steps
::get() <= 0)) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.ui")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case SAL_DETAIL_LOG_ACTION_LOG
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "/org.openoffice.Office.Common/Undo/Steps <= 0";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui")
, ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui"
), ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "/org.openoffice.Office.Common/Undo/Steps <= 0"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "/org.openoffice.Office.Common/Undo/Steps <= 0";
::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.ui")
, ("/home/maarten/src/libreoffice/core/sw/source/uibase/uiview/view.cxx"
":" "937" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
938 if (!utl::ConfigManager::IsFuzzing() && 0 < officecfg::Office::Common::Undo::Steps::get())
939 {
940 m_pWrtShell->DoUndo();
941 }
942
943 const bool bBrowse = m_pWrtShell->GetViewOptions()->getBrowseMode();
944 // Disable "multiple window"
945 SetNewWindowAllowed(!bBrowse);
946 // End of disabled multiple window
947
948 m_bVScrollbarEnabled = aUsrPref.IsViewVScrollBar();
949 m_bHScrollbarEnabled = aUsrPref.IsViewHScrollBar();
950 m_pHScrollbar->SetAuto(bBrowse);
951 if( aUsrPref.IsViewHRuler() )
952 CreateTab();
953 if( aUsrPref.IsViewVRuler() )
954 CreateVRuler();
955
956 m_pWrtShell->SetUIOptions( aUsrPref );
957 m_pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() );
958 m_pWrtShell->ApplyAccessibilityOptions(SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetAccessibilityOptions());
959
960 if( m_pWrtShell->GetDoc()->getIDocumentState().IsUpdateExpField() )
961 {
962 if (m_pWrtShell->GetDoc()->GetDocumentFieldsManager().containsUpdatableFields())
963 {
964 CurrShell aCurr(m_pWrtShell.get());
965 m_pWrtShell->StartAction();
966 m_pWrtShell->CalcLayout();
967 m_pWrtShell->GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
968 m_pWrtShell->EndAction();
969 }
970 m_pWrtShell->GetDoc()->getIDocumentState().SetUpdateExpFieldStat( false );
971 }
972
973 // Update all tables if necessary:
974 if( m_pWrtShell->GetDoc()->IsUpdateTOX() )
975 {
976 SfxRequest aSfxRequest( FN_UPDATE_TOX((20000 + 600) + 53), SfxCallMode::SLOT, GetPool() );
977 Execute( aSfxRequest );
978 m_pWrtShell->GetDoc()->SetUpdateTOX( false ); // reset again
979 m_pWrtShell->SttEndDoc(true);
980 }
981
982 // No ResetModified, if there is already a view to this doc.
983 SfxViewFrame* pVFrame = GetViewFrame();
984 SfxViewFrame* pFirst = SfxViewFrame::GetFirst(&rDocSh);
985 // Currently(360) the view is registered firstly after the CTOR,
986 // the following expression is also working if this changes.
987 // If the modification cannot be canceled by undo, then do NOT set
988 // the modify back.
989 // no reset of modified state, if document
990 // was already modified.
991 if (!m_pWrtShell->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
992 ( !pFirst || pFirst == pVFrame ) &&
993 !bIsDocModified )
994 {
995 m_pWrtShell->ResetModified();
996 }
997
998 g_bNoInterrupt = bOld;
999
1000 // If a new GlobalDoc will be created, the navigator will also be generated.
1001 if( dynamic_cast<const SwGlobalDocShell*>(&rDocSh) != nullptr &&
1002 !pVFrame->GetChildWindow( SID_NAVIGATOR(10000 + 366) ))
1003 {
1004 SfxBoolItem aNavi(SID_NAVIGATOR(10000 + 366), true);
1005 GetDispatcher().ExecuteList(SID_NAVIGATOR(10000 + 366), SfxCallMode::ASYNCHRON, { &aNavi });
1006 }
1007
1008 uno::Reference< frame::XFrame > xFrame = pVFrame->GetFrame().GetFrameInterface();
1009
1010 uno::Reference< frame::XFrame > xBeamerFrame = xFrame->findFrame(
1011 "_beamer", frame::FrameSearchFlag::CHILDREN);
1012 if(xBeamerFrame.is())
1013 {
1014 SwDBData aData = m_pWrtShell->GetDBData();
1015 SwModule::ShowDBObj( *this, aData );
1016 }
1017
1018 // has anybody calls the attrchanged handler in the constructor?
1019 if( m_bAttrChgNotifiedWithRegistrations )
1020 {
1021 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS()LeaveRegistrations();
1022 if( m_aTimer.IsActive() )
1023 m_aTimer.Stop();
1024 }
1025
1026 m_aTimer.SetInvokeHandler(LINK(this, SwView, TimeoutHdl)::tools::detail::makeLink( ::tools::detail::castTo<SwView *
>(this), &SwView::LinkStubTimeoutHdl)
);
1027 m_aTimer.SetDebugName( "sw::SwView m_aTimer" );
1028 m_bAttrChgNotified = m_bAttrChgNotifiedWithRegistrations = false;
1029 if (bOldModifyFlag)
1030 rDocSh.EnableSetModified();
1031 InvalidateBorder();
1032
1033 if( !m_pHScrollbar->IsVisible( true ) )
1034 ShowHScrollbar( false );
1035 if( !m_pVScrollbar->IsVisible( true ) )
1036 ShowVScrollbar( false );
1037
1038 GetViewFrame()->GetWindow().AddChildEventListener( LINK( this, SwView, WindowChildEventListener )::tools::detail::makeLink( ::tools::detail::castTo<SwView *
>(this), &SwView::LinkStubWindowChildEventListener)
);
1039}
1040
1041SwViewGlueDocShell::SwViewGlueDocShell(SwView& rView, SwDocShell& rDocSh)
1042 : m_rView(rView)
1043{
1044 // Set DocShell
1045 rDocSh.SetView(&m_rView);
1046 SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->SetView(&m_rView);
1047}
1048
1049SwViewGlueDocShell::~SwViewGlueDocShell()
1050{
1051 SwDocShell* pDocSh = m_rView.GetDocShell();
1052 if (pDocSh && pDocSh->GetView() == &m_rView)
1053 pDocSh->SetView(nullptr);
1054 if (SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetView() == &m_rView)
1055 SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->SetView(nullptr);
1056}
1057
1058SwView::~SwView()
1059{
1060 // Notify other LOK views that we are going away.
1061 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_CURSOR_VISIBLE, "visible", "false");
1062 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", "");
1063 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
1064
1065 // Need to remove activated field's button before disposing EditWin.
1066 GetWrtShell().getIDocumentMarkAccess()->ClearFieldActivation();
1067
1068 GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView, WindowChildEventListener )::tools::detail::makeLink( ::tools::detail::castTo<SwView *
>(this), &SwView::LinkStubWindowChildEventListener)
);
1069 m_pPostItMgr.reset();
1070
1071 m_bInDtor = true;
1072 m_pEditWin->Hide(); // prevent problems with painting
1073
1074 // Set pointer in SwDocShell to the view again
1075 m_xGlueDocShell.reset();
1076
1077 if( m_aTimer.IsActive() && m_bAttrChgNotifiedWithRegistrations )
1078 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS()LeaveRegistrations();
1079
1080 // the last view must end the text edit
1081 SdrView *pSdrView = m_pWrtShell ? m_pWrtShell->GetDrawView() : nullptr;
1082 if( pSdrView && pSdrView->IsTextEdit() )
1083 pSdrView->SdrEndTextEdit( true );
1084
1085 SetWindow( nullptr );
1086
1087 m_pViewImpl->Invalidate();
1088 EndListening(*GetViewFrame());
1089 EndListening(*GetDocShell());
1090 m_pScrollFill.disposeAndClear();
1091 m_pWrtShell.reset(); // reset here so that it is not accessible by the following dtors.
1092 m_pHScrollbar.disposeAndClear();
1093 m_pVScrollbar.disposeAndClear();
1094 m_pHRuler.disposeAndClear();
1095 m_pVRuler.disposeAndClear();
1096 m_pGlosHdl.reset();
1097 m_pViewImpl.reset();
1098
1099 // If this was enabled in the ctor for the frame, then disable it here.
1100 static bool bRequestDoubleBuffering = getenv("VCL_DOUBLEBUFFERING_ENABLE");
1101 if (bRequestDoubleBuffering)
1102 m_pEditWin->RequestDoubleBuffering(false);
1103 m_pEditWin.disposeAndClear();
1104
1105 m_pFormatClipboard.reset();
1106}
1107
1108SwDocShell* SwView::GetDocShell()
1109{
1110 SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell();
1111 return dynamic_cast<SwDocShell*>( pDocShell );
1112}
1113
1114// Remember CursorPos
1115
1116void SwView::WriteUserData( OUString &rUserData, bool bBrowse )
1117{
1118 // The browse flag will be passed from Sfx when documents are browsed
1119 // (not to be confused with the BrowseMode).
1120 // Then that stored data are not persistent!
1121
1122 const SwRect& rRect = m_pWrtShell->GetCharRect();
1123 const tools::Rectangle& rVis = GetVisArea();
1124
1125 rUserData = OUString::number( rRect.Left() );
1126 rUserData += ";";
1127 rUserData += OUString::number( rRect.Top() );
1128 rUserData += ";";
1129 rUserData += OUString::number( m_pWrtShell->GetViewOptions()->GetZoom() );
1130 rUserData += ";";
1131 rUserData += OUString::number( rVis.Left() );
1132 rUserData += ";";
1133 rUserData += OUString::number( rVis.Top() );
1134 rUserData += ";";
1135 rUserData += OUString::number( bBrowse ? SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1)) : rVis.Right());
1136 rUserData += ";";
1137 rUserData += OUString::number( bBrowse ? SAL_MIN_INT32((sal_Int32) (-0x7FFFFFFF - 1)) : rVis.Bottom());
1138 rUserData += ";";
1139 rUserData += OUString::number(
1140 static_cast<sal_uInt16>(m_pWrtShell->GetViewOptions()->GetZoomType()));//eZoom;
1141 rUserData += ";";
1142 rUserData += FrameTypeFlags::NONE == m_pWrtShell->GetSelFrameType() ? OUStringLiteral(u"0") : OUStringLiteral(u"1");
1143}
1144
1145// Set CursorPos
1146
1147static bool lcl_IsOwnDocument( SwView& rView )
1148{
1149 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1150 rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
1151 uno::Reference<document::XDocumentProperties> xDocProps
1152 = xDPS->getDocumentProperties();
1153 OUString Created = xDocProps->getAuthor();
1154 OUString Changed = xDocProps->getModifiedBy();
1155 OUString FullName = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetUserOptions().GetFullName();
1156 return (!FullName.isEmpty() &&
1157 (!Changed.isEmpty() && Changed == FullName )) ||
1158 (Changed.isEmpty() && !Created.isEmpty() && Created == FullName );
1159}
1160
1161void SwView::ReadUserData( const OUString &rUserData, bool bBrowse )
1162{
1163 if ( !(rUserData.indexOf(';')>=0 && // more than one token
1164 // For document without layout only in the onlinelayout or
1165 // while forward/backward
1166 (!m_pWrtShell->IsNewLayout() || m_pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse)) )
1167 return;
1168
1169 bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1170
1171 CurrShell aCurr(m_pWrtShell.get());
1172
1173 sal_Int32 nPos = 0;
1174
1175 // No it is *not* a good idea to call GetToken within Point constr. immediately,
1176 // because which parameter is evaluated first?
1177 long nX = rUserData.getToken( 0, ';', nPos ).toInt32(),
1178 nY = rUserData.getToken( 0, ';', nPos ).toInt32();
1179 Point aCursorPos( nX, nY );
1180
1181 sal_uInt16 nZoomFactor =
1182 static_cast< sal_uInt16 >( rUserData.getToken(0, ';', nPos ).toInt32() );
1183
1184 long nLeft = rUserData.getToken(0, ';', nPos ).toInt32(),
1185 nTop = rUserData.getToken(0, ';', nPos ).toInt32(),
1186 nRight = rUserData.getToken(0, ';', nPos ).toInt32(),
1187 nBottom= rUserData.getToken(0, ';', nPos ).toInt32();
1188
1189 const long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER284 : DOCUMENTBORDER284*2;
1190 if ( nBottom > (m_pWrtShell->GetDocSize().Height()+nAdd) )
1191 return;
1192
1193 m_pWrtShell->EnableSmooth( false );
1194
1195 const tools::Rectangle aVis( nLeft, nTop, nRight, nBottom );
1196
1197 sal_Int32 nOff = 0;
1198 SvxZoomType eZoom;
1199 if( !m_pWrtShell->GetViewOptions()->getBrowseMode() )
1200 eZoom = static_cast<SvxZoomType>(static_cast<sal_uInt16>(rUserData.getToken(nOff, ';', nPos ).toInt32()));
1201 else
1202 {
1203 eZoom = SvxZoomType::PERCENT;
1204 ++nOff;
1205 }
1206
1207 bool bSelectObj = (0 != rUserData.getToken( nOff, ';', nPos ).toInt32())
1208 && m_pWrtShell->IsObjSelectable( aCursorPos );
1209
1210 // restore editing position
1211 m_pViewImpl->SetRestorePosition(aCursorPos, bSelectObj);
1212 // set flag value to avoid macro execution.
1213 bool bSavedFlagValue = m_pWrtShell->IsMacroExecAllowed();
1214 m_pWrtShell->SetMacroExecAllowed( false );
1215// os: changed: The user data has to be read if the view is switched back from page preview
1216// go to the last editing position when opening own files
1217 if(m_bOldShellWasPagePreview || bIsOwnDocument)
1218 {
1219 m_pWrtShell->SwCursorShell::SetCursor( aCursorPos, !bSelectObj );
1220 if( bSelectObj )
1221 {
1222 m_pWrtShell->SelectObj( aCursorPos );
1223 m_pWrtShell->EnterSelFrameMode( &aCursorPos );
1224 }
1225 }
1226
1227 // reset flag value
1228 m_pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1229
1230 // set visible area before applying
1231 // information from print preview. Otherwise, the applied information
1232 // is lost.
1233// os: changed: The user data has to be read if the view is switched back from page preview
1234// go to the last editing position when opening own files
1235 if(m_bOldShellWasPagePreview || bIsOwnDocument )
1236 {
1237 if ( bBrowse )
1238 SetVisArea( aVis.TopLeft() );
1239 else
1240 SetVisArea( aVis );
1241 }
1242
1243 //apply information from print preview - if available
1244 if( !m_sNewCursorPos.isEmpty() )
1245 {
1246 sal_Int32 nIdx{ 0 };
1247 const long nXTmp = m_sNewCursorPos.getToken( 0, ';', nIdx ).toInt32();
1248 const long nYTmp = m_sNewCursorPos.getToken( 0, ';', nIdx ).toInt32();
1249 Point aCursorPos2( nXTmp, nYTmp );
1250 bSelectObj = m_pWrtShell->IsObjSelectable( aCursorPos2 );
1251
1252 m_pWrtShell->SwCursorShell::SetCursor( aCursorPos2 );
1253 if( bSelectObj )
1254 {
1255 m_pWrtShell->SelectObj( aCursorPos2 );
1256 m_pWrtShell->EnterSelFrameMode( &aCursorPos2 );
1257 }
1258 m_pWrtShell->MakeSelVisible();
1259 m_sNewCursorPos.clear();
1260 }
1261 else if(USHRT_MAX(32767 *2 +1) != m_nNewPage)
1262 {
1263 m_pWrtShell->GotoPage(m_nNewPage, true);
1264 m_nNewPage = USHRT_MAX(32767 *2 +1);
1265 }
1266
1267 SelectShell();
1268
1269 m_pWrtShell->StartAction();
1270 const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
1271 if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom )
1272 SetZoom( eZoom, nZoomFactor);
1273
1274 m_pWrtShell->LockView( true );
1275 m_pWrtShell->EndAction();
1276 m_pWrtShell->LockView( false );
1277 m_pWrtShell->EnableSmooth( true );
1278}
1279
1280void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence )
1281{
1282 if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick)
1283 return;
1284 bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1285 if (!rSequence.hasElements())
1286 return;
1287
1288 CurrShell aCurr(m_pWrtShell.get());
1289 const SwRect& rRect = m_pWrtShell->GetCharRect();
1290 const tools::Rectangle &rVis = GetVisArea();
1291 const SwViewOption* pVOpt = m_pWrtShell->GetViewOptions();
1292
1293 sal_Int64 nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top();
1294 sal_Int64 nRight = nLeft;
1295 sal_Int64 nBottom = LONG_MIN(-9223372036854775807L -1L);
1296 sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
1297 sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
1298 bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
1299 sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
1300
1301 bool bSelectedFrame = ( m_pWrtShell->GetSelFrameType() != FrameTypeFlags::NONE ),
1302 bGotVisibleLeft = false,
1303 bGotVisibleTop = false, bGotVisibleRight = false,
1304 bGotVisibleBottom = false, bGotZoomType = false,
1305 bGotZoomFactor = false, bGotIsSelectedFrame = false,
1306 bGotViewLayoutColumns = false, bGotViewLayoutBookMode = false,
1307 bBrowseMode = false, bGotBrowseMode = false;
1308
1309 for (const beans::PropertyValue& rValue : rSequence)
1310 {
1311 if ( rValue.Name == "ViewLeft" )
1312 {
1313 rValue.Value >>= nX;
1314 nX = convertMm100ToTwip( nX );
1315 }
1316 else if ( rValue.Name == "ViewTop" )
1317 {
1318 rValue.Value >>= nY;
1319 nY = convertMm100ToTwip( nY );
1320 }
1321 else if ( rValue.Name == "VisibleLeft" )
1322 {
1323 rValue.Value >>= nLeft;
1324 nLeft = convertMm100ToTwip( nLeft );
1325 bGotVisibleLeft = true;
1326 }
1327 else if ( rValue.Name == "VisibleTop" )
1328 {
1329 rValue.Value >>= nTop;
1330 nTop = convertMm100ToTwip( nTop );
1331 bGotVisibleTop = true;
1332 }
1333 else if ( rValue.Name == "VisibleRight" )
1334 {
1335 rValue.Value >>= nRight;
1336 nRight = convertMm100ToTwip( nRight );
1337 bGotVisibleRight = true;
1338 }
1339 else if ( rValue.Name == "VisibleBottom" )
1340 {
1341 rValue.Value >>= nBottom;
1342 nBottom = convertMm100ToTwip( nBottom );
1343 bGotVisibleBottom = true;
1344 }
1345 else if ( rValue.Name == "ZoomType" )
1346 {
1347 rValue.Value >>= nZoomType;
1348 bGotZoomType = true;
1349 }
1350 else if ( rValue.Name == "ZoomFactor" )
1351 {
1352 rValue.Value >>= nZoomFactor;
1353 bGotZoomFactor = true;
1354 }
1355 else if ( rValue.Name == "ViewLayoutColumns" )
1356 {
1357 rValue.Value >>= nViewLayoutColumns;
1358 bGotViewLayoutColumns = true;
1359 }
1360 else if ( rValue.Name == "ViewLayoutBookMode" )
1361 {
1362 bViewLayoutBookMode = *o3tl::doAccess<bool>(rValue.Value);
1363 bGotViewLayoutBookMode = true;
1364 }
1365 else if ( rValue.Name == "IsSelectedFrame" )
1366 {
1367 rValue.Value >>= bSelectedFrame;
1368 bGotIsSelectedFrame = true;
1369 }
1370 else if (rValue.Name == "ShowOnlineLayout")
1371 {
1372 rValue.Value >>= bBrowseMode;
1373 bGotBrowseMode = true;
1374 }
1375 // Fallback to common SdrModel processing
1376 else
1377 GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(&rValue);
1378 }
1379 if (bGotBrowseMode)
1380 {
1381 // delegate further
1382 GetViewImpl()->GetUNOObject_Impl()->getViewSettings()->setPropertyValue("ShowOnlineLayout", uno::Any(bBrowseMode));
1383 }
1384
1385 SelectShell();
1386
1387 if (!bGotVisibleBottom)
1388 return;
1389
1390 Point aCursorPos( nX, nY );
1391 const long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER284 : DOCUMENTBORDER284*2;
1392 if (nBottom > (m_pWrtShell->GetDocSize().Height()+nAdd) )
1393 return;
1394
1395 m_pWrtShell->EnableSmooth( false );
1396 const tools::Rectangle aVis( nLeft, nTop, nRight, nBottom );
1397
1398 SvxZoomType eZoom;
1399 if ( !m_pWrtShell->GetViewOptions()->getBrowseMode() )
1400 eZoom = static_cast < SvxZoomType > ( nZoomType );
1401 else
1402 {
1403 eZoom = SvxZoomType::PERCENT;
1404 }
1405 if (bGotIsSelectedFrame)
1406 {
1407 bool bSelectObj = bSelectedFrame && m_pWrtShell->IsObjSelectable( aCursorPos );
1408
1409 // set flag value to avoid macro execution.
1410 bool bSavedFlagValue = m_pWrtShell->IsMacroExecAllowed();
1411 m_pWrtShell->SetMacroExecAllowed( false );
1412// os: changed: The user data has to be read if the view is switched back from page preview
1413// go to the last editing position when opening own files
1414 m_pViewImpl->SetRestorePosition(aCursorPos, bSelectObj);
1415 if(m_bOldShellWasPagePreview|| bIsOwnDocument)
1416 {
1417 m_pWrtShell->SwCursorShell::SetCursor( aCursorPos, !bSelectObj );
1418
1419 // Update the shell to toggle Header/Footer edit if needed
1420 bool bInHeader = true;
1421 if ( m_pWrtShell->IsInHeaderFooter( &bInHeader ) )
1422 {
1423 if ( !bInHeader )
1424 {
1425 m_pWrtShell->SetShowHeaderFooterSeparator( FrameControlType::Footer, true );
1426 m_pWrtShell->SetShowHeaderFooterSeparator( FrameControlType::Header, false );
1427 }
1428 else
1429 {
1430 m_pWrtShell->SetShowHeaderFooterSeparator( FrameControlType::Header, true );
1431 m_pWrtShell->SetShowHeaderFooterSeparator( FrameControlType::Footer, false );
1432 }
1433
1434 // Force repaint
1435 m_pWrtShell->GetWin()->Invalidate();
1436 }
1437 if ( m_pWrtShell->IsInHeaderFooter() != m_pWrtShell->IsHeaderFooterEdit() )
1438 m_pWrtShell->ToggleHeaderFooterEdit();
1439
1440 if( bSelectObj )
1441 {
1442 m_pWrtShell->SelectObj( aCursorPos );
1443 m_pWrtShell->EnterSelFrameMode( &aCursorPos );
1444 }
1445 }
1446
1447 // reset flag value
1448 m_pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1449 }
1450
1451 // Set ViewLayoutSettings
1452 const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode &&
1453 ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode );
1454
1455 const bool bSetViewSettings = bGotZoomType && bGotZoomFactor &&
1456 ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom );
1457
1458 // In case we have a 'fixed' view layout of 2 or more columns,
1459 // we have to apply the view options *before* starting the action.
1460 // Otherwise the SetZoom function cannot work correctly, because
1461 // the view layout hasn't been calculated.
1462 const bool bZoomNeedsViewLayout = bSetViewLayoutSettings &&
1463 1 < nViewLayoutColumns &&
1464 bSetViewSettings &&
1465 eZoom != SvxZoomType::PERCENT;
1466
1467 if ( !bZoomNeedsViewLayout )
1468 m_pWrtShell->StartAction();
1469
1470 if ( bSetViewLayoutSettings )
1471 SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, true );
1472
1473 if ( bZoomNeedsViewLayout )
1474 m_pWrtShell->StartAction();
1475
1476 if ( bSetViewSettings )
1477 SetZoom( eZoom, nZoomFactor, true );
1478
1479// os: changed: The user data has to be read if the view is switched back from page preview
1480// go to the last editing position when opening own files
1481 if(m_bOldShellWasPagePreview||bIsOwnDocument)
1482 {
1483 if ( bGotVisibleLeft && bGotVisibleTop )
1484 {
1485 Point aTopLeft(aVis.TopLeft());
1486 // make sure the document is still centered
1487 const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER284 : 2 * DOCUMENTBORDER284;
1488 SwTwips nEditWidth = GetEditWin().GetOutputSize().Width();
1489 if(nEditWidth > (m_aDocSz.Width() + lBorder ))
1490 aTopLeft.setX( ( m_aDocSz.Width() + lBorder - nEditWidth ) / 2 );
1491 else
1492 {
1493 //check if the values are possible
1494 long nXMax = m_pHScrollbar->GetRangeMax() - m_pHScrollbar->GetVisibleSize();
1495 if( aTopLeft.X() > nXMax )
1496 aTopLeft.setX( nXMax < 0 ? 0 : nXMax );
1497 }
1498 SetVisArea( aTopLeft );
1499 }
1500 else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom )
1501 SetVisArea( aVis );
1502 }
1503
1504 m_pWrtShell->LockView( true );
1505 m_pWrtShell->EndAction();
1506 m_pWrtShell->LockView( false );
1507 m_pWrtShell->EnableSmooth( true );
1508
1509}
1510
1511void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence )
1512{
1513 const SwRect& rRect = m_pWrtShell->GetCharRect();
1514 const tools::Rectangle& rVis = GetVisArea();
1515
1516 std::vector<beans::PropertyValue> aVector;
1517
1518 sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
1519 aVector.push_back(comphelper::makePropertyValue("ViewId", "view" + OUString::number(nViewID)));
1520
1521 aVector.push_back(comphelper::makePropertyValue("ViewLeft", convertTwipToMm100 ( rRect.Left() )));
1522
1523 aVector.push_back(comphelper::makePropertyValue("ViewTop", convertTwipToMm100 ( rRect.Top() )));
1524
1525 auto visibleLeft = convertTwipToMm100 ( rVis.Left() );
1526 aVector.push_back(comphelper::makePropertyValue("VisibleLeft", visibleLeft));
1527
1528 auto visibleTop = convertTwipToMm100 ( rVis.Top() );
1529 aVector.push_back(comphelper::makePropertyValue("VisibleTop", visibleTop));
1530
1531 auto visibleRight = rVis.IsWidthEmpty() ? visibleLeft : convertTwipToMm100 ( rVis.Right() );
1532 aVector.push_back(comphelper::makePropertyValue("VisibleRight", visibleRight));
1533
1534 auto visibleBottom = rVis.IsHeightEmpty() ? visibleTop : convertTwipToMm100 ( rVis.Bottom() );
1535 aVector.push_back(comphelper::makePropertyValue("VisibleBottom", visibleBottom));
1536
1537 const sal_Int16 nZoomType = static_cast< sal_Int16 >(m_pWrtShell->GetViewOptions()->GetZoomType());
1538 aVector.push_back(comphelper::makePropertyValue("ZoomType", nZoomType));
1539
1540 const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(m_pWrtShell->GetViewOptions()->GetViewLayoutColumns());
1541 aVector.push_back(comphelper::makePropertyValue("ViewLayoutColumns", nViewLayoutColumns));
1542
1543 aVector.push_back(comphelper::makePropertyValue("ViewLayoutBookMode", m_pWrtShell->GetViewOptions()->IsViewLayoutBookMode()));
1544
1545 aVector.push_back(comphelper::makePropertyValue("ZoomFactor", static_cast < sal_Int16 > (m_pWrtShell->GetViewOptions()->GetZoom())));
1546
1547 aVector.push_back(comphelper::makePropertyValue("IsSelectedFrame", FrameTypeFlags::NONE != m_pWrtShell->GetSelFrameType()));
1548
1549 rSequence = comphelper::containerToSequence(aVector);
1550
1551 // Common SdrModel processing
1552 GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->WriteUserDataSequence(rSequence);
1553}
1554
1555void SwView::ShowCursor( bool bOn )
1556{
1557 //don't scroll the cursor into the visible area
1558 bool bUnlockView = !m_pWrtShell->IsViewLocked();
1559 m_pWrtShell->LockView( true ); //lock visible section
1560
1561 if( !bOn )
1562 m_pWrtShell->HideCursor();
1563 else if( !m_pWrtShell->IsFrameSelected() && !m_pWrtShell->IsObjSelected() )
1564 m_pWrtShell->ShowCursor();
1565
1566 if( bUnlockView )
1567 m_pWrtShell->LockView( false );
1568}
1569
1570ErrCode SwView::DoVerb( long nVerb )
1571{
1572 if ( !GetViewFrame()->GetFrame().IsInPlace() )
1573 {
1574 SwWrtShell &rSh = GetWrtShell();
1575 const SelectionType nSel = rSh.GetSelectionType();
1576 if ( nSel & SelectionType::Ole )
1577 rSh.LaunchOLEObj( nVerb );
1578 }
1579 return ERRCODE_NONEErrCode(0);
1580}
1581
1582// only return true for a text selection
1583
1584bool SwView::HasSelection( bool bText ) const
1585{
1586 return bText ? GetWrtShell().SwCursorShell::HasSelection()
1587 : GetWrtShell().HasSelection();
1588}
1589
1590OUString SwView::GetSelectionText( bool bCompleteWrds )
1591{
1592 return GetSelectionTextParam( bCompleteWrds, true );
1593}
1594
1595OUString SwView::GetSelectionTextParam( bool bCompleteWrds, bool bEraseTrail )
1596{
1597 OUString sReturn;
1598 if( bCompleteWrds && !GetWrtShell().HasSelection() )
1599 GetWrtShell().SelWrd();
1600
1601 GetWrtShell().GetSelectedText( sReturn );
1602 if( bEraseTrail )
1603 sReturn = comphelper::string::stripEnd(sReturn, ' ');
1604 return sReturn;
1605}
1606
1607SwGlossaryHdl* SwView::GetGlosHdl()
1608{
1609 if(!m_pGlosHdl)
1610 m_pGlosHdl.reset(new SwGlossaryHdl(GetViewFrame(), m_pWrtShell.get()));
1611 return m_pGlosHdl.get();
1612}
1613
1614void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1615{
1616 bool bCallBase = true;
1617 if(dynamic_cast<const FmDesignModeChangedHint*>(&rHint))
1618 {
1619 bool bDesignMode = static_cast<const FmDesignModeChangedHint&>(rHint).GetDesignMode();
1620 if (!bDesignMode && GetDrawFuncPtr())
1621 {
1622 GetDrawFuncPtr()->Deactivate();
1623 SetDrawFuncPtr(nullptr);
1624 LeaveDrawCreate();
1625 AttrChangedNotify(nullptr);
1626 }
1627 }
1628 else
1629 {
1630 SfxHintId nId = rHint.GetId();
1631 switch ( nId )
1632 {
1633 // sub shells will be destroyed by the
1634 // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1635 case SfxHintId::Dying:
1636 {
1637 if ( &rBC == GetViewFrame() )
1638 {
1639 ResetSubShell();
1640 }
1641 }
1642 break;
1643 case SfxHintId::ModeChanged:
1644 {
1645 // Modal mode change-over?
1646 bool bModal = GetDocShell()->IsInModalMode();
1647 m_pHRuler->SetActive( !bModal );
1648 m_pVRuler->SetActive( !bModal );
1649 }
1650
1651 [[fallthrough]];
1652
1653 case SfxHintId::TitleChanged:
1654 if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1655 {
1656 SwWrtShell &rSh = GetWrtShell();
1657 rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1658
1659 if ( rSh.GetViewOptions()->IsViewVRuler() )
1660 CreateVRuler();
1661 else
1662 KillVRuler();
1663 if ( rSh.GetViewOptions()->IsViewHRuler() )
1664 CreateTab();
1665 else
1666 KillTab();
1667 bool bReadonly = GetDocShell()->IsReadOnly();
1668 // if document is to be opened in alive-mode then this has to be
1669 // regarded while switching from readonly-mode to edit-mode
1670 if( !bReadonly )
1671 {
1672 SwDrawModel * pDrawDoc = GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
1673 if (pDrawDoc)
1674 {
1675 if( !pDrawDoc->GetOpenInDesignMode() )
1676 break;// don't touch the design mode
1677 }
1678 }
1679 SfxBoolItem aItem( SID_FM_DESIGN_MODE( 10000 + 629 ), !bReadonly);
1680 GetDispatcher().ExecuteList(SID_FM_DESIGN_MODE( 10000 + 629 ),
1681 SfxCallMode::ASYNCHRON, { &aItem });
1682 }
1683 break;
1684
1685 case SfxHintId::SwDrawViewsCreated:
1686 {
1687 bCallBase = false;
1688 if ( GetFormShell() )
1689 {
1690 GetFormShell()->SetView(dynamic_cast<FmFormView*>(GetWrtShell().GetDrawView()));
1691 SfxBoolItem aItem( SID_FM_DESIGN_MODE( 10000 + 629 ), !GetDocShell()->IsReadOnly());
1692 GetDispatcher().ExecuteList(SID_FM_DESIGN_MODE( 10000 + 629 ),
1693 SfxCallMode::SYNCHRON, { &aItem });
1694 }
1695 }
1696 break;
1697 case SfxHintId::RedlineChanged:
1698 {
1699 static sal_uInt16 const aSlotRedLine[] = {
1700 FN_REDLINE_ACCEPT_DIRECT((20000 + 1800) + 37),
1701 FN_REDLINE_REJECT_DIRECT((20000 + 1800) + 38),
1702 FN_REDLINE_NEXT_CHANGE((20000 + 1800) + 41),
1703 FN_REDLINE_PREV_CHANGE((20000 + 1800) + 42),
1704 FN_REDLINE_ACCEPT_ALL((20000 + 1800) + 43),
1705 FN_REDLINE_REJECT_ALL((20000 + 1800) + 44),
1706 0
1707 };
1708 GetViewFrame()->GetBindings().Invalidate(aSlotRedLine);
1709 }
1710 break;
1711
1712 default: break;
1713 }
1714 }
1715
1716 if ( bCallBase )
1717 SfxViewShell::Notify(rBC, rHint);
1718}
1719
1720#if defined(_WIN32) || defined UNX1
1721
1722void SwView::ScannerEventHdl()
1723{
1724 uno::Reference< XScannerManager2 > xScanMgr = SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetScannerManager();
1725 if( xScanMgr.is() )
1726 {
1727 const ScannerContext aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] );
1728 const ScanError eError = xScanMgr->getError( aContext );
1729
1730 if( ScanError_ScanErrorNone == eError )
1731 {
1732 const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) );
1733
1734 if( xBitmap.is() )
1735 {
1736 const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
1737
1738 if( !!aScanBmp )
1739 {
1740 Graphic aGrf(aScanBmp);
1741 m_pWrtShell->Insert( OUString(), OUString(), aGrf );
1742 }
1743 }
1744 }
1745 }
1746 SfxBindings& rBind = GetViewFrame()->GetBindings();
1747 rBind.Invalidate( SID_TWAIN_SELECT( 10000 + 331 ) );
1748 rBind.Invalidate( SID_TWAIN_TRANSFER( 10000 + 332 ) );
1749}
1750#endif
1751
1752void SwView::StopShellTimer()
1753{
1754 if(m_aTimer.IsActive())
1755 {
1756 m_aTimer.Stop();
1757 if ( m_bAttrChgNotifiedWithRegistrations )
1758 {
1759 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS()LeaveRegistrations();
1760 m_bAttrChgNotifiedWithRegistrations = false;
1761 }
1762 SelectShell();
1763 m_bAttrChgNotified = false;
1764 }
1765}
1766
1767bool SwView::PrepareClose( bool bUI )
1768{
1769 SfxViewFrame* pVFrame = GetViewFrame();
1770 pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), false );
1771 if( pVFrame->GetDispatcher()->IsLocked() )
1772 pVFrame->GetDispatcher()->Lock(false);
1773
1774 if ( m_pFormShell && !m_pFormShell->PrepareClose( bUI ) )
1775 {
1776 return false;
1777 }
1778 return SfxViewShell::PrepareClose( bUI );
1779}
1780
1781// status methods for clipboard.
1782// Status changes now notified from the clipboard.
1783bool SwView::IsPasteAllowed()
1784{
1785 SotExchangeDest nPasteDestination = SwTransferable::GetSotDestination( *m_pWrtShell );
1786 if( m_nLastPasteDestination != nPasteDestination )
1787 {
1788 TransferableDataHelper aDataHelper(
1789 TransferableDataHelper::CreateFromSystemClipboard(
1790 &GetEditWin()) );
1791 if( aDataHelper.GetXTransferable().is() )
1792 {
1793 m_bPasteState = SwTransferable::IsPaste( *m_pWrtShell, aDataHelper );
1794 m_bPasteSpecialState = SwTransferable::IsPasteSpecial(
1795 *m_pWrtShell, aDataHelper );
1796 }
1797 else
1798 m_bPasteState = m_bPasteSpecialState = false;
1799
1800 if( static_cast<SotExchangeDest>(0xFFFF) == m_nLastPasteDestination ) // the init value
1801 m_pViewImpl->AddClipboardListener();
1802 m_nLastPasteDestination = nPasteDestination;
1803 }
1804 return m_bPasteState;
1805}
1806
1807bool SwView::IsPasteSpecialAllowed()
1808{
1809 if ( m_pFormShell && m_pFormShell->IsActiveControl() )
1810 return false;
1811
1812 SotExchangeDest nPasteDestination = SwTransferable::GetSotDestination( *m_pWrtShell );
1813 if( m_nLastPasteDestination != nPasteDestination )
1814 {
1815 TransferableDataHelper aDataHelper(
1816 TransferableDataHelper::CreateFromSystemClipboard(
1817 &GetEditWin()) );
1818 if( aDataHelper.GetXTransferable().is() )
1819 {
1820 m_bPasteState = SwTransferable::IsPaste( *m_pWrtShell, aDataHelper );
1821 m_bPasteSpecialState = SwTransferable::IsPasteSpecial(
1822 *m_pWrtShell, aDataHelper );
1823 }
1824 else
1825 m_bPasteState = m_bPasteSpecialState = false;
1826
1827 if( static_cast<SotExchangeDest>(0xFFFF) == m_nLastPasteDestination ) // the init value
1828 m_pViewImpl->AddClipboardListener();
1829 }
1830 return m_bPasteSpecialState;
1831}
1832
1833bool SwView::IsPasteSpreadsheet(bool bHasOwnTableCopied)
1834{
1835 TransferableDataHelper aDataHelper(
1836 TransferableDataHelper::CreateFromSystemClipboard(
1837 &GetEditWin()) );
1838 if( aDataHelper.GetXTransferable().is() )
1839 {
1840 if (bHasOwnTableCopied && SwTransferable::IsPasteOwnFormat( aDataHelper ))
1841 return true;
1842 return aDataHelper.HasFormat( SotClipboardFormatId::SYLK ) || aDataHelper.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS );
1843 }
1844 return false;
1845}
1846
1847void SwView::NotifyDBChanged()
1848{
1849 GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1850}
1851
1852// Printing
1853
1854SfxObjectShellLock SwView::CreateTmpSelectionDoc()
1855{
1856 SwXTextView *const pTempImpl = GetViewImpl()->GetUNOObject_Impl();
1857 return pTempImpl->BuildTmpSelectionDoc();
1858}
1859
1860void SwView::AddTransferable(SwTransferable& rTransferable)
1861{
1862 GetViewImpl()->AddTransferable(rTransferable);
1863}
1864
1865namespace sw {
1866
1867void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb)
1868{
1869 o_rData = *SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetPrtOptions(bWeb);
1870}
1871
1872} // namespace sw
1873
1874/* vim:set shiftwidth=4 softtabstop=4 expandtab: */