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_features.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 <sfx2/event.hxx>
38 #include <sfx2/infobar.hxx>
39 #include <svx/ruler.hxx>
40 #include <svx/srchdlg.hxx>
41 #include <svx/fmshell.hxx>
42 #include <svx/extrusionbar.hxx>
43 #include <svx/fontworkbar.hxx>
44 #include <svx/fmview.hxx>
45 #include <unotxvw.hxx>
47 #include <svl/hint.hxx>
48 #include <swmodule.hxx>
49 #include <inputwin.hxx>
50 #include <uivwimp.hxx>
56 #include <mediash.hxx>
61 #include <drawbase.hxx>
62 #include <drformsh.hxx>
63 #include <drwtxtsh.hxx>
64 #include <beziersh.hxx>
66 #include <globdoc.hxx>
68 #include <gloshdl.hxx>
69 #include <usrpref.hxx>
70 #include <srcview.hxx>
71 #include <strings.hrc>
73 #include <IDocumentUndoRedo.hxx>
74 #include <IDocumentSettingAccess.hxx>
75 #include <IDocumentDrawModelAccess.hxx>
76 #include <DocumentFieldsManager.hxx>
77 #include <IDocumentState.hxx>
78 #include <IDocumentLayoutAccess.hxx>
79 #include <drawdoc.hxx>
84 #include <swdtflvr.hxx>
86 #include <com/sun/star/frame/FrameSearchFlag.hpp>
87 #include <com/sun/star/frame/XLayoutManager.hpp>
88 #include <com/sun/star/scanner/ScannerContext.hpp>
89 #include <com/sun/star/scanner/XScannerManager2.hpp>
90 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
91 #include <com/sun/star/sdb/XDatabaseContext.hpp>
92 #include <com/sun/star/sdb/DatabaseContext.hpp>
93 #include <com/sun/star/sdbc/XDataSource.hpp>
94 #include <toolkit/helper/vclunohelper.hxx>
95 #include <sal/log.hxx>
97 #include <formatclipboard.hxx>
98 #include <PostItMgr.hxx>
99 #include <annotsh.hxx>
100 #include <swruler.hxx>
102 #include <com/sun/star/document/XDocumentProperties.hpp>
103 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
105 #include <comphelper/propertyvalue.hxx>
106 #include <sfx2/lokhelper.hxx>
107 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
108 #include <svtools/embedhlp.hxx>
109 #include <tools/UnitConversion.hxx>
110 #include <svx/svdoutl.hxx>
112 using namespace ::com::sun::star
;
113 using namespace ::com::sun::star::uno
;
114 using namespace ::com::sun::star::lang
;
115 using namespace ::com::sun::star::scanner
;
116 using namespace ::com::sun::star::sdb
;
117 using namespace ::com::sun::star::sdbc
;
119 #define SWVIEWFLAGS SfxViewShellFlags::HAS_PRINTOPTIONS
123 bool bDocSzUpdated
= true;
125 SvxSearchItem
* SwView::s_pSrchItem
= nullptr;
127 bool SwView::s_bExtra
= false;
128 bool SwView::s_bFound
= false;
129 bool SwView::s_bJustOpened
= false;
131 std::unique_ptr
<SearchAttrItemList
> SwView::s_xSearchList
;
132 std::unique_ptr
<SearchAttrItemList
> SwView::s_xReplaceList
;
134 SfxDispatcher
&SwView::GetDispatcher()
136 return *GetViewFrame()->GetDispatcher();
139 void SwView::ImpSetVerb( SelectionType nSelType
)
141 bool bResetVerbs
= m_bVerbsActive
;
142 if ( !GetViewFrame()->GetFrame().IsInPlace() &&
143 (SelectionType::Ole
|SelectionType::Graphic
) & nSelType
)
145 if ( m_pWrtShell
->IsSelObjProtected(FlyProtectFlags::Content
) == FlyProtectFlags::NONE
)
147 if ( nSelType
& SelectionType::Ole
)
149 SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
150 m_bVerbsActive
= true;
157 SetVerbs( Sequence
< embed::VerbDescriptor
>() );
158 m_bVerbsActive
= false;
162 // Called by the SwEditWin when it gets the focus.
164 void SwView::GotFocus() const
166 // if we got the focus, and the form shell *is* on the top of the dispatcher
167 // stack, then we need to rebuild the stack (the form shell doesn't belong to
169 const SfxDispatcher
& rDispatcher
= const_cast< SwView
* >( this )->GetDispatcher();
170 SfxShell
* pTopShell
= rDispatcher
.GetShell( 0 );
171 FmFormShell
* pAsFormShell
= dynamic_cast<FmFormShell
*>( pTopShell
);
174 pAsFormShell
->ForgetActiveControl();
175 const_cast< SwView
* >( this )->AttrChangedNotify(nullptr);
177 else if ( m_pPostItMgr
)
179 SwAnnotationShell
* pAsAnnotationShell
= dynamic_cast<SwAnnotationShell
*>( pTopShell
);
180 if ( pAsAnnotationShell
)
182 m_pPostItMgr
->SetActiveSidebarWin(nullptr);
183 const_cast< SwView
* >( this )->AttrChangedNotify(nullptr);
186 if( GetWrtShellPtr() )
188 SwWrtShell
& rWrtShell
= GetWrtShell();
189 rWrtShell
.GetDoc()->getIDocumentLayoutAccess().SetCurrentViewShell( GetWrtShellPtr() );
190 rWrtShell
.GetDoc()->getIDocumentSettingAccess().set( DocumentSettingId::BROWSE_MODE
,
191 rWrtShell
.GetViewOptions()->getBrowseMode() );
195 // called by the FormShell when a form control is focused. This is
196 // a request to put the form shell on the top of the dispatcher stack
198 IMPL_LINK_NOARG(SwView
, FormControlActivated
, LinkParamNone
*, void)
200 // if a form control has been activated, and the form shell is not on the top
201 // of the dispatcher stack, then we need to activate it
202 const SfxDispatcher
& rDispatcher
= GetDispatcher();
203 const SfxShell
* pTopShell
= rDispatcher
.GetShell( 0 );
204 const FmFormShell
* pAsFormShell
= dynamic_cast<const FmFormShell
*>( pTopShell
);
207 // if we're editing text currently, cancel this
208 SdrView
*pSdrView
= m_pWrtShell
? m_pWrtShell
->GetDrawView() : nullptr;
209 if ( pSdrView
&& pSdrView
->IsTextEdit() )
210 pSdrView
->SdrEndTextEdit( true );
212 AttrChangedNotify(nullptr);
218 uno::Reference
<frame::XLayoutManager
> getLayoutManager(const SfxViewFrame
& rViewFrame
)
220 uno::Reference
<frame::XLayoutManager
> xLayoutManager
;
221 uno::Reference
<beans::XPropertySet
> xPropSet(rViewFrame
.GetFrame().GetFrameInterface(),
227 xLayoutManager
.set(xPropSet
->getPropertyValue("LayoutManager"), uno::UNO_QUERY
);
229 catch (const Exception
& e
)
231 SAL_WARN("sw.ui", "Failure getting layout manager: " + e
.Message
);
234 return xLayoutManager
;
238 void SwView::ShowUIElement(const OUString
& sElementURL
) const
240 if (auto xLayoutManager
= getLayoutManager(*GetViewFrame()))
242 if (!xLayoutManager
->getElement(sElementURL
).is())
244 xLayoutManager
->createElement(sElementURL
);
245 xLayoutManager
->showElement(sElementURL
);
250 void SwView::SelectShell()
252 // Attention: Maintain the SelectShell for the WebView additionally
257 // Decision if the UpdateTable has to be called
258 bool bUpdateTable
= false;
259 const SwFrameFormat
* pCurTableFormat
= m_pWrtShell
->GetTableFormat();
260 if(pCurTableFormat
&& pCurTableFormat
!= m_pLastTableFormat
)
262 bUpdateTable
= true; // can only be executed later
264 m_pLastTableFormat
= pCurTableFormat
;
266 //SEL_TBL and SEL_TBL_CELLS can be ORed!
267 SelectionType nNewSelectionType
= m_pWrtShell
->GetSelectionType()
268 & ~SelectionType::TableCell
;
270 if ( m_pFormShell
&& m_pFormShell
->IsActiveControl() )
271 nNewSelectionType
|= SelectionType::FormControl
;
273 if ( nNewSelectionType
== m_nSelectionType
)
275 GetViewFrame()->GetBindings().InvalidateAll( false );
276 if ( m_nSelectionType
& SelectionType::Ole
||
277 m_nSelectionType
& SelectionType::Graphic
)
278 // For graphs and OLE the verb can be modified of course!
279 ImpSetVerb( nNewSelectionType
);
284 SfxDispatcher
&rDispatcher
= GetDispatcher();
285 SwToolbarConfigItem
*pBarCfg
= SW_MOD()->GetToolbarConfig();
289 rDispatcher
.Flush(); // Really erase all cached shells
290 //Remember to the old selection which toolbar was visible
291 ToolbarId eId
= rDispatcher
.GetObjectBarId(SFX_OBJECTBAR_OBJECT
);
292 if (eId
!= ToolbarId::None
)
293 pBarCfg
->SetTopToolbar(m_nSelectionType
, eId
);
295 for ( sal_uInt16 i
= 0; true; ++i
)
297 SfxShell
*pSfxShell
= rDispatcher
.GetShell( i
);
298 if ( dynamic_cast< const SwBaseShell
*>( pSfxShell
) != nullptr
299 || dynamic_cast< const SwDrawTextShell
*>( pSfxShell
) != nullptr
300 || dynamic_cast< const svx::ExtrusionBar
*>( pSfxShell
) != nullptr
301 || dynamic_cast< const svx::FontworkBar
*>( pSfxShell
) != nullptr
302 || dynamic_cast< const SwAnnotationShell
*>( pSfxShell
) != nullptr
305 rDispatcher
.Pop( *pSfxShell
, SfxDispatcherPopFlags::POP_DELETE
);
307 else if ( dynamic_cast< const FmFormShell
*>( pSfxShell
) != nullptr )
309 rDispatcher
.Pop( *pSfxShell
);
316 bool bInitFormShell
= false;
319 bInitFormShell
= true;
320 m_pFormShell
= new FmFormShell( this );
321 m_pFormShell
->SetControlActivationHandler( LINK( this, SwView
, FormControlActivated
) );
322 StartListening(*m_pFormShell
);
325 bool bSetExtInpCntxt
= false;
326 m_nSelectionType
= nNewSelectionType
;
327 ShellMode eShellMode
;
329 if ( !( m_nSelectionType
& SelectionType::FormControl
) )
330 rDispatcher
.Push( *m_pFormShell
);
332 m_pShell
= new SwNavigationShell( *this );
333 rDispatcher
.Push( *m_pShell
);
335 if ( m_nSelectionType
& SelectionType::Ole
)
337 eShellMode
= ShellMode::Object
;
338 m_pShell
= new SwOleShell( *this );
339 rDispatcher
.Push( *m_pShell
);
341 else if ( m_nSelectionType
& SelectionType::Frame
342 || m_nSelectionType
& SelectionType::Graphic
)
344 eShellMode
= ShellMode::Frame
;
345 m_pShell
= new SwFrameShell( *this );
346 rDispatcher
.Push( *m_pShell
);
347 if(m_nSelectionType
& SelectionType::Graphic
)
349 eShellMode
= ShellMode::Graphic
;
350 m_pShell
= new SwGrfShell( *this );
351 rDispatcher
.Push( *m_pShell
);
354 else if ( m_nSelectionType
& SelectionType::DrawObject
)
356 eShellMode
= ShellMode::Draw
;
357 m_pShell
= new SwDrawShell( *this );
358 rDispatcher
.Push( *m_pShell
);
360 if ( m_nSelectionType
& SelectionType::Ornament
)
362 eShellMode
= ShellMode::Bezier
;
363 m_pShell
= new SwBezierShell( *this );
364 rDispatcher
.Push( *m_pShell
);
366 #if HAVE_FEATURE_AVMEDIA
367 else if( m_nSelectionType
& SelectionType::Media
)
369 eShellMode
= ShellMode::Media
;
370 m_pShell
= new SwMediaShell( *this );
371 rDispatcher
.Push( *m_pShell
);
374 if (m_nSelectionType
& SelectionType::ExtrudedCustomShape
)
376 eShellMode
= ShellMode::ExtrudedCustomShape
;
377 m_pShell
= new svx::ExtrusionBar(this);
378 rDispatcher
.Push( *m_pShell
);
380 if (m_nSelectionType
& SelectionType::FontWork
)
382 eShellMode
= ShellMode::FontWork
;
383 m_pShell
= new svx::FontworkBar(this);
384 rDispatcher
.Push( *m_pShell
);
387 else if ( m_nSelectionType
& SelectionType::DbForm
)
389 eShellMode
= ShellMode::DrawForm
;
390 m_pShell
= new SwDrawFormShell( *this );
392 rDispatcher
.Push( *m_pShell
);
394 else if ( m_nSelectionType
& SelectionType::DrawObjectEditMode
)
396 bSetExtInpCntxt
= true;
397 eShellMode
= ShellMode::DrawText
;
398 rDispatcher
.Push( *(new SwBaseShell( *this )) );
399 m_pShell
= new SwDrawTextShell( *this );
400 rDispatcher
.Push( *m_pShell
);
402 else if ( m_nSelectionType
& SelectionType::PostIt
)
404 eShellMode
= ShellMode::PostIt
;
405 m_pShell
= new SwAnnotationShell( *this );
406 rDispatcher
.Push( *m_pShell
);
410 bSetExtInpCntxt
= true;
411 eShellMode
= ShellMode::Text
;
412 if ( m_nSelectionType
& SelectionType::NumberList
)
414 eShellMode
= ShellMode::ListText
;
415 m_pShell
= new SwListShell( *this );
416 rDispatcher
.Push( *m_pShell
);
418 m_pShell
= new SwTextShell(*this);
419 rDispatcher
.Push( *m_pShell
);
420 if ( m_nSelectionType
& SelectionType::Table
)
422 eShellMode
= eShellMode
== ShellMode::ListText
? ShellMode::TableListText
423 : ShellMode::TableText
;
424 m_pShell
= new SwTableShell( *this );
425 rDispatcher
.Push( *m_pShell
);
429 if ( m_nSelectionType
& SelectionType::FormControl
)
430 rDispatcher
.Push( *m_pFormShell
);
432 m_pViewImpl
->SetShellMode(eShellMode
);
433 ImpSetVerb( m_nSelectionType
);
435 if( !GetDocShell()->IsReadOnly() )
437 if( bSetExtInpCntxt
&& GetWrtShell().HasReadonlySel() )
438 bSetExtInpCntxt
= false;
440 InputContext
aCntxt( GetEditWin().GetInputContext() );
441 aCntxt
.SetOptions( bSetExtInpCntxt
442 ? (aCntxt
.GetOptions() |
443 ( InputContextFlags::Text
|
444 InputContextFlags::ExtText
))
445 : (aCntxt
.GetOptions() & ~
446 InputContextFlags( InputContextFlags::Text
|
447 InputContextFlags::ExtText
)) );
448 GetEditWin().SetInputContext( aCntxt
);
451 // Show Mail Merge toolbar initially for documents with Database fields
452 if (!m_bInitOnceCompleted
&& GetWrtShell().IsAnyDatabaseFieldInDoc())
453 ShowUIElement("private:resource/toolbar/mailmerge");
455 // Activate the toolbar to the new selection which also was active last time.
456 // Before a flush () must be, but does not affect the UI according to MBA and
457 // is not a performance problem.
458 // TODO/LATER: maybe now the Flush() command is superfluous?!
461 Point aPnt
= GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
462 aPnt
= GetEditWin().PixelToLogic(aPnt
);
463 GetEditWin().UpdatePointer(aPnt
);
465 SdrView
* pDView
= GetWrtShell().GetDrawView();
466 if ( bInitFormShell
&& pDView
)
467 m_pFormShell
->SetView(dynamic_cast<FmFormView
*>( pDView
) );
470 // Opportune time for the communication with OLE objects?
471 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
472 GetDocShell()->GetDoc()->PrtOLENotify( false );
474 // now the table-update
476 m_pWrtShell
->UpdateTable();
478 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
480 m_bInitOnceCompleted
= true;
483 // Interaction: AttrChangedNotify() and TimeoutHdl.
484 // No Update if actions are still open, since the cursor on the core side
485 // can be somewhere in no man's land.
486 // But since we can no longer supply status and we want instead lock
491 static int lcl_CmpIds( const void *pFirst
, const void *pSecond
)
493 return *static_cast<sal_uInt16
const *>(pFirst
) - *static_cast<sal_uInt16
const *>(pSecond
);
497 IMPL_LINK_NOARG(SwView
, AttrChangedNotify
, LinkParamNone
*, void)
499 if ( GetEditWin().IsChainMode() )
500 GetEditWin().SetChainMode( false );
502 //Opt: Not if PaintLocked. During unlock a notify will be once more triggered.
503 if( !m_pWrtShell
->IsPaintLocked() && !g_bNoInterrupt
&&
504 GetDocShell()->IsReadOnly() )
505 CheckReadonlyState();
507 if( !m_pWrtShell
->IsPaintLocked() && !g_bNoInterrupt
)
508 CheckReadonlySelection();
510 if( !m_bAttrChgNotified
)
512 if (m_pWrtShell
->ActionPend() || g_bNoInterrupt
||
513 GetDispatcher().IsLocked() || //do not confuse the SFX
514 GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
516 m_bAttrChgNotified
= true;
519 const SfxPoolItem
*pItem
;
520 if ( SfxItemState::SET
!= GetObjectShell()->GetMedium()->GetItemSet()->
521 GetItemState( SID_HIDDEN
, false, &pItem
) ||
522 !static_cast<const SfxBoolItem
*>(pItem
)->GetValue() )
524 GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
525 m_bAttrChgNotifiedWithRegistrations
= true;
534 // change ui if cursor is at a SwPostItField
537 // only perform the code that is needed to determine, if at the
538 // actual cursor position is a post-it field
539 m_pPostItMgr
->SetShadowState( m_pWrtShell
->GetPostItFieldAtCursor() );
543 IMPL_LINK_NOARG(SwView
, TimeoutHdl
, Timer
*, void)
545 if (m_pWrtShell
->ActionPend() || g_bNoInterrupt
)
551 if ( m_bAttrChgNotifiedWithRegistrations
)
553 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
554 m_bAttrChgNotifiedWithRegistrations
= false;
557 CheckReadonlyState();
558 CheckReadonlySelection();
560 bool bOldUndo
= m_pWrtShell
->DoesUndo();
561 m_pWrtShell
->DoUndo( false );
563 m_pWrtShell
->DoUndo( bOldUndo
);
564 m_bAttrChgNotified
= false;
565 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
568 void SwView::CheckReadonlyState()
570 SfxDispatcher
&rDis
= GetDispatcher();
571 // To be able to recognize if it is already disabled!
572 SfxItemState eStateRO
, eStateProtAll
;
573 const SfxPoolItem
*pItem
;
574 // Query the status from a slot which is only known to us.
575 // Otherwise the slot is known from other; like the BasicIde
576 eStateRO
= rDis
.QueryState( FN_INSERT_BOOKMARK
, pItem
);
577 eStateProtAll
= rDis
.QueryState( FN_EDIT_REGION
, pItem
);
580 if ( !m_pWrtShell
->IsCursorReadonly() )
582 static sal_uInt16 aROIds
[] =
584 SID_DELETE
, FN_BACKSPACE
, FN_SHIFT_BACKSPACE
,
586 SID_REDO
, SID_REPEAT
, SID_PASTE
,
587 SID_PASTE_UNFORMATTED
, FN_PASTE_NESTED_TABLE
, FN_TABLE_PASTE_ROW_BEFORE
,
588 FN_TABLE_PASTE_COL_BEFORE
, SID_PASTE_SPECIAL
, SID_SBA_BRW_INSERT
,
589 SID_BACKGROUND_COLOR
, FN_INSERT_BOOKMARK
, SID_CHARMAP_CONTROL
,
590 SID_CHARMAP
, SID_EMOJI_CONTROL
, FN_INSERT_SOFT_HYPHEN
,
591 FN_INSERT_HARDHYPHEN
, FN_INSERT_HARD_SPACE
, FN_INSERT_NNBSP
,
592 FN_INSERT_BREAK
, FN_INSERT_LINEBREAK
, FN_INSERT_COLUMN_BREAK
,
594 FN_DELETE_SENT
, FN_DELETE_BACK_SENT
, FN_DELETE_WORD
,
595 FN_DELETE_BACK_WORD
, FN_DELETE_LINE
, FN_DELETE_BACK_LINE
,
596 FN_DELETE_PARA
, FN_DELETE_BACK_PARA
, FN_DELETE_WHOLE_LINE
,
597 FN_CALCULATE
, FN_FORMAT_RESET
,
598 FN_POSTIT
, FN_JAVAEDIT
, SID_ATTR_PARA_ADJUST_LEFT
,
599 SID_ATTR_PARA_ADJUST_RIGHT
, SID_ATTR_PARA_ADJUST_CENTER
,SID_ATTR_PARA_ADJUST_BLOCK
,
600 SID_ATTR_PARA_LINESPACE_10
, SID_ATTR_PARA_LINESPACE_15
, SID_ATTR_PARA_LINESPACE_20
,
601 SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONTHEIGHT
, SID_ATTR_CHAR_COLOR_BACKGROUND
,
602 SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
, SID_ATTR_CHAR_COLOR_EXT
,
603 SID_ATTR_CHAR_COLOR
, SID_ATTR_CHAR_WEIGHT
, SID_ATTR_CHAR_POSTURE
,
604 SID_ATTR_CHAR_OVERLINE
,
605 SID_ATTR_CHAR_UNDERLINE
, SID_ATTR_FLASH
, SID_ATTR_CHAR_STRIKEOUT
,
606 SID_ULINE_VAL_SINGLE
, SID_ULINE_VAL_DOUBLE
, SID_ULINE_VAL_DOTTED
,
607 SID_ATTR_CHAR_CONTOUR
, SID_ATTR_CHAR_SHADOWED
,
608 SID_ATTR_CHAR_AUTOKERN
, SID_ATTR_CHAR_ESCAPEMENT
, FN_SET_SUPER_SCRIPT
,
609 FN_SET_SUB_SCRIPT
, SID_ATTR_CHAR_CASEMAP
, SID_ATTR_CHAR_LANGUAGE
,
610 SID_ATTR_CHAR_KERNING
, SID_CHAR_DLG
, SID_ATTR_CHAR_WORDLINEMODE
,
611 FN_GROW_FONT_SIZE
, FN_SHRINK_FONT_SIZE
, FN_TXTATR_INET
,
612 FN_FORMAT_DROPCAPS
, SID_ATTR_PARA_ADJUST
, SID_ATTR_PARA_LINESPACE
,
613 SID_ATTR_PARA_SPLIT
, SID_ATTR_PARA_KEEP
, SID_ATTR_PARA_WIDOWS
,
614 SID_ATTR_PARA_ORPHANS
,
615 SID_ATTR_PARA_MODEL
, SID_PARA_DLG
,
616 FN_SELECT_PARA
, SID_DEC_INDENT
,
619 static bool bFirst
= true;
622 qsort( static_cast<void*>(aROIds
), SAL_N_ELEMENTS(aROIds
), sizeof(sal_uInt16
), lcl_CmpIds
);
625 if ( SfxItemState::DISABLED
== eStateRO
)
627 rDis
.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY
, aROIds
);
631 else if( m_pWrtShell
->IsAllProtect() )
633 if ( SfxItemState::DISABLED
== eStateProtAll
)
635 static sal_uInt16 aAllProtIds
[] = { SID_SAVEDOC
, FN_EDIT_REGION
};
636 static bool bAllProtFirst
= true;
639 qsort( static_cast<void*>(aAllProtIds
), SAL_N_ELEMENTS(aAllProtIds
), sizeof(sal_uInt16
), lcl_CmpIds
);
640 bAllProtFirst
= false;
642 rDis
.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY
, aAllProtIds
);
646 else if ( SfxItemState::DISABLED
!= eStateRO
||
647 SfxItemState::DISABLED
!= eStateProtAll
)
650 rDis
.SetSlotFilter();
653 GetViewFrame()->GetBindings().InvalidateAll(true);
656 void SwView::CheckReadonlySelection()
658 SfxDisableFlags nDisableFlags
= SfxDisableFlags::NONE
;
659 SfxDispatcher
&rDis
= GetDispatcher();
661 if( m_pWrtShell
->HasReadonlySel() &&
662 ( !m_pWrtShell
->GetDrawView() ||
663 !m_pWrtShell
->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
664 nDisableFlags
|= SfxDisableFlags::SwOnProtectedCursor
;
666 if( (SfxDisableFlags::SwOnProtectedCursor
& nDisableFlags
) !=
667 (SfxDisableFlags::SwOnProtectedCursor
& rDis
.GetDisableFlags() ) )
669 // Additionally move at the Window the InputContext, so that
670 // in japanese / chinese versions the external input will be
671 // turned on or off. This but only if the correct shell is on
673 switch( m_pViewImpl
->GetShellMode() )
675 case ShellMode::Text
:
676 case ShellMode::ListText
:
677 case ShellMode::TableText
:
678 case ShellMode::TableListText
:
680 // Temporary solution!!! Should set the font of the current insertion point
681 // at each cursor movement, so outside of this "if". But TH does not
682 // evaluates the font at this time and the "purchase" appears to me
684 // Moreover, we don't have a font, but only attributes from which the
685 // text formatting and the correct font will be build together.
687 InputContext
aCntxt( GetEditWin().GetInputContext() );
688 aCntxt
.SetOptions( SfxDisableFlags::SwOnProtectedCursor
& nDisableFlags
689 ? (aCntxt
.GetOptions() & ~
690 InputContextFlags( InputContextFlags::Text
|
691 InputContextFlags::ExtText
))
692 : (aCntxt
.GetOptions() |
693 ( InputContextFlags::Text
|
694 InputContextFlags::ExtText
)) );
695 GetEditWin().SetInputContext( aCntxt
);
704 if( nDisableFlags
!= rDis
.GetDisableFlags() )
706 rDis
.SetDisableFlags( nDisableFlags
);
707 GetViewFrame()->GetBindings().InvalidateAll( true );
711 SwView::SwView( SfxViewFrame
*_pFrame
, SfxViewShell
* pOldSh
)
712 : SfxViewShell( _pFrame
, SWVIEWFLAGS
),
713 m_aTimer( "sw::SwView m_aTimer" ),
714 m_nNewPage(USHRT_MAX
),
716 m_pNumRuleNodeFromDoc(nullptr),
717 m_pEditWin( VclPtr
<SwEditWin
>::Create( &_pFrame
->GetWindow(), *this ) ),
719 m_pFormShell(nullptr),
720 m_pHScrollbar(nullptr),
721 m_pVScrollbar(nullptr),
722 m_pScrollFill(VclPtr
<ScrollBarBox
>::Create( &_pFrame
->GetWindow(), WB_SIZEABLE
)),
723 m_pVRuler(VclPtr
<SvxRuler
>::Create(&GetViewFrame()->GetWindow(), m_pEditWin
,
724 SvxRulerSupportFlags::TABS
| SvxRulerSupportFlags::PARAGRAPH_MARGINS_VERTICAL
|
725 SvxRulerSupportFlags::BORDERS
| SvxRulerSupportFlags::REDUCED_METRIC
,
726 GetViewFrame()->GetBindings(),
727 WB_VSCROLL
| WB_EXTRAFIELD
| WB_BORDER
)),
728 m_pLastTableFormat(nullptr),
729 m_pFormatClipboard(new SwFormatClipboard()),
730 m_nSelectionType( SelectionType::All
),
732 m_nDrawSfxId( USHRT_MAX
),
733 m_nFormSfxId( USHRT_MAX
),
734 m_eFormObjKind(OBJ_NONE
),
735 m_nLastPasteDestination( static_cast<SotExchangeDest
>(0xFFFF) ),
736 m_nLeftBorderDistance( 0 ),
737 m_nRightBorderDistance( 0 ),
738 m_eLastSearchCommand( static_cast<SvxSearchCmd
>(0xFFFF) ),
739 m_bWheelScrollInProgress(false),
740 m_bCenterCursor(false),
742 m_bTabColFromDoc(false),
743 m_bTabRowFromDoc(false),
744 m_bSetTabColFromDoc(false),
745 m_bSetTabRowFromDoc(false),
746 m_bAttrChgNotified(false),
747 m_bAttrChgNotifiedWithRegistrations(false),
748 m_bVerbsActive(false),
749 m_bDrawRotate(false),
750 m_bDrawSelMode(true),
751 m_bShowAtResize(true),
752 m_bInOuterResizePixel(false),
753 m_bInInnerResizePixel(false),
754 m_bPasteState(false),
755 m_bPasteSpecialState(false),
756 m_bInMailMerge(false),
758 m_bOldShellWasPagePreview(false),
759 m_bIsPreviewDoubleClick(false),
760 m_bMakeSelectionVisible(false),
761 m_bForceChangesToolbar(true),
762 m_nLOKPageUpDownOffset(0)
764 static bool bRequestDoubleBuffering
= getenv("VCL_DOUBLEBUFFERING_ENABLE");
765 if (bRequestDoubleBuffering
)
766 m_pEditWin
->RequestDoubleBuffering(true);
768 // According to discussion with MBA and further
769 // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
770 // if function "New Window" is performed to open an additional view beside
771 // an already existing one.
772 // If the view is switch from one to another, the 'old' view is given by
773 // parameter <pOldSh>.
775 bDocSzUpdated
= true;
777 CreateScrollbar( true );
778 CreateScrollbar( false );
780 m_pViewImpl
.reset(new SwView_Impl(this));
782 SetWindow( m_pEditWin
);
784 m_aTimer
.SetTimeout( 120 );
786 SwDocShell
& rDocSh
= dynamic_cast<SwDocShell
&>(*_pFrame
->GetObjectShell());
787 bool bOldModifyFlag
= rDocSh
.IsEnableSetModified();
789 rDocSh
.EnableSetModified( false );
790 // HACK: SwDocShell has some cached font info, VCL informs about font updates,
791 // but loading of docs with embedded fonts happens after SwDocShell is created
792 // but before SwEditWin (which handles the VCL event) is created. So update
794 if (rDocSh
.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS
))
795 rDocSh
.UpdateFontList();
796 bool bWebDShell
= dynamic_cast<const SwWebDocShell
*>(&rDocSh
) != nullptr;
798 const SwMasterUsrPref
*pUsrPref
= SW_MOD()->GetUsrPref(bWebDShell
);
799 SwViewOption
aUsrPref( *pUsrPref
);
801 //! get lingu options without loading lingu DLL
802 SvtLinguOptions aLinguOpt
;
803 SvtLinguConfig().GetOptions( aLinguOpt
);
804 aUsrPref
.SetOnlineSpell( aLinguOpt
.bIsSpellAuto
);
806 bool bOldShellWasSrcView
= false;
808 // determine if there is an existing view for
810 SfxViewShell
* pExistingSh
= nullptr;
813 pExistingSh
= pOldSh
;
814 // determine type of existing view
815 if (SwPagePreview
* pPagePreview
= dynamic_cast<SwPagePreview
*>(pExistingSh
))
817 m_sSwViewData
= pPagePreview
->GetPrevSwViewData();
818 m_sNewCursorPos
= pPagePreview
->GetNewCursorPos();
819 m_nNewPage
= pPagePreview
->GetNewPage();
820 m_bOldShellWasPagePreview
= true;
821 m_bIsPreviewDoubleClick
= !m_sNewCursorPos
.isEmpty() || m_nNewPage
!= USHRT_MAX
;
823 else if (dynamic_cast<const SwSrcView
*>(pExistingSh
) != nullptr)
824 bOldShellWasSrcView
= true;
827 SAL_INFO( "sw.ui", "before create WrtShell" );
828 if (SwView
*pView
= dynamic_cast<SwView
*>(pExistingSh
))
830 m_pWrtShell
.reset(new SwWrtShell(*pView
->m_pWrtShell
, m_pEditWin
, *this));
832 else if (SwWrtShell
*pWrtShell
= dynamic_cast<SwWrtShell
*>(rDocSh
.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()))
834 m_pWrtShell
.reset(new SwWrtShell(*pWrtShell
, m_pEditWin
, *this));
838 SwDoc
& rDoc
= *rDocSh
.GetDoc();
840 if( !bOldShellWasSrcView
&& bWebDShell
&& !m_bOldShellWasPagePreview
)
841 aUsrPref
.setBrowseMode( true );
843 aUsrPref
.setBrowseMode( rDoc
.getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE
) );
845 //For the BrowseMode we do not assume a factor.
846 if( aUsrPref
.getBrowseMode() && aUsrPref
.GetZoomType() != SvxZoomType::PERCENT
)
848 aUsrPref
.SetZoomType( SvxZoomType::PERCENT
);
849 aUsrPref
.SetZoom( 100 );
851 if (rDocSh
.IsPreview())
853 aUsrPref
.SetZoomType( SvxZoomType::WHOLEPAGE
);
854 aUsrPref
.SetViewLayoutBookMode( false );
855 aUsrPref
.SetViewLayoutColumns( 1 );
857 m_pWrtShell
.reset(new SwWrtShell(rDoc
, m_pEditWin
, *this, &aUsrPref
));
858 // creating an SwView from a SwPagePreview needs to
859 // add the SwViewShell to the ring of the other SwViewShell(s)
860 if(m_bOldShellWasPagePreview
)
862 SwViewShell
& rPreviewViewShell
= *static_cast<SwPagePreview
*>(pExistingSh
)->GetViewShell();
863 m_pWrtShell
->MoveTo(&rPreviewViewShell
);
864 // to update the field command et.al. if necessary
865 const SwViewOption
* pPreviewOpt
= rPreviewViewShell
.GetViewOptions();
866 if( pPreviewOpt
->IsFieldName() != aUsrPref
.IsFieldName() ||
867 pPreviewOpt
->IsShowHiddenField() != aUsrPref
.IsShowHiddenField() ||
868 pPreviewOpt
->IsShowHiddenPara() != aUsrPref
.IsShowHiddenPara() ||
869 pPreviewOpt
->IsShowHiddenChar() != aUsrPref
.IsShowHiddenChar() )
870 rPreviewViewShell
.ApplyViewOptions(aUsrPref
);
871 // reset design mode at draw view for form
873 if ( static_cast<SwPagePreview
*>(pExistingSh
)->ResetFormDesignMode() &&
874 m_pWrtShell
->HasDrawView() )
876 SdrView
* pDrawView
= m_pWrtShell
->GetDrawView();
877 pDrawView
->SetDesignMode( static_cast<SwPagePreview
*>(pExistingSh
)->FormDesignModeToReset() );
881 SAL_INFO( "sw.ui", "after create WrtShell" );
882 m_pHRuler
= VclPtr
<SwCommentRuler
>::Create(m_pWrtShell
.get(), &GetViewFrame()->GetWindow(), m_pEditWin
,
883 SvxRulerSupportFlags::TABS
|
884 SvxRulerSupportFlags::PARAGRAPH_MARGINS
|
885 SvxRulerSupportFlags::BORDERS
|
886 SvxRulerSupportFlags::NEGATIVE_MARGINS
|
887 SvxRulerSupportFlags::REDUCED_METRIC
,
888 GetViewFrame()->GetBindings(),
889 WB_STDRULER
| WB_EXTRAFIELD
| WB_BORDER
);
891 // assure that modified state of document
892 // isn't reset, if document is already modified.
893 const bool bIsDocModified
= m_pWrtShell
->GetDoc()->getIDocumentState().IsModified();
895 // Thus among other things, the HRuler is not displayed in the read-only case.
896 aUsrPref
.SetReadonly( m_pWrtShell
->GetViewOptions()->IsReadonly() );
898 // no margin for OLE!
900 if( SfxObjectCreateMode::EMBEDDED
!= rDocSh
.GetCreateMode() )
901 aBrwsBorder
= GetMargin();
903 m_pWrtShell
->SetBrowseBorder( aBrwsBorder
);
905 // In CTOR no shell changes may take place, which must be temporarily stored
906 // with the timer. Otherwise, the SFX removes them from the stack!
907 bool bOld
= g_bNoInterrupt
;
908 g_bNoInterrupt
= true;
910 m_pHRuler
->SetActive();
911 m_pVRuler
->SetActive();
913 SfxViewFrame
* pViewFrame
= GetViewFrame();
915 StartListening(*pViewFrame
, DuplicateHandling::Prevent
);
916 StartListening(rDocSh
, DuplicateHandling::Prevent
);
918 // Set Zoom-factor from HRuler
919 Fraction
aZoomFract( aUsrPref
.GetZoom(), 100 );
920 m_pHRuler
->SetZoom( aZoomFract
);
921 m_pVRuler
->SetZoom( aZoomFract
);
922 m_pHRuler
->SetDoubleClickHdl(LINK( this, SwView
, ExecRulerClick
));
923 FieldUnit eMetric
= pUsrPref
->GetHScrollMetric();
924 m_pHRuler
->SetUnit( eMetric
);
926 eMetric
= pUsrPref
->GetVScrollMetric();
927 m_pVRuler
->SetUnit( eMetric
);
929 m_pHRuler
->SetCharWidth( 371 ); // default character width
930 m_pVRuler
->SetLineHeight( 551 ); // default line height
933 m_xGlueDocShell
.reset(new SwViewGlueDocShell(*this, rDocSh
));
934 m_pPostItMgr
.reset(new SwPostItMgr(this));
936 // Check and process the DocSize. Via the handler, the shell could not
937 // be found, because the shell is not known in the SFX management
938 // within the CTOR phase.
939 DocSzChgd( m_pWrtShell
->GetDocSize() );
941 // Set AttrChangedNotify link
942 m_pWrtShell
->SetChgLnk(LINK(this, SwView
, AttrChangedNotify
));
944 if (rDocSh
.GetCreateMode() == SfxObjectCreateMode::EMBEDDED
&&
945 !rDocSh
.GetVisArea(ASPECT_CONTENT
).IsEmpty())
946 SetVisArea(rDocSh
.GetVisArea(ASPECT_CONTENT
),false);
949 officecfg::Office::Common::Undo::Steps::get() <= 0,
950 "sw.ui", "/org.openoffice.Office.Common/Undo/Steps <= 0");
951 if (!utl::ConfigManager::IsFuzzing() && 0 < officecfg::Office::Common::Undo::Steps::get())
953 m_pWrtShell
->DoUndo();
956 const bool bBrowse
= m_pWrtShell
->GetViewOptions()->getBrowseMode();
957 // Disable "multiple window"
958 SetNewWindowAllowed(!bBrowse
);
959 // End of disabled multiple window
961 m_bVScrollbarEnabled
= aUsrPref
.IsViewVScrollBar();
962 m_bHScrollbarEnabled
= aUsrPref
.IsViewHScrollBar();
963 m_pHScrollbar
->SetAuto(bBrowse
);
964 if( aUsrPref
.IsViewHRuler() )
966 if( aUsrPref
.IsViewVRuler() )
969 m_pWrtShell
->SetUIOptions( aUsrPref
);
970 m_pWrtShell
->SetReadOnlyAvailable( aUsrPref
.IsCursorInProtectedArea() );
971 m_pWrtShell
->ApplyAccessibilityOptions(SW_MOD()->GetAccessibilityOptions());
973 if( m_pWrtShell
->GetDoc()->getIDocumentState().IsUpdateExpField() )
975 if (m_pWrtShell
->GetDoc()->GetDocumentFieldsManager().containsUpdatableFields())
977 CurrShell
aCurr(m_pWrtShell
.get());
978 m_pWrtShell
->StartAction();
979 m_pWrtShell
->CalcLayout();
980 m_pWrtShell
->GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
981 m_pWrtShell
->EndAction();
983 m_pWrtShell
->GetDoc()->getIDocumentState().SetUpdateExpFieldStat( false );
986 // Update all tables if necessary:
987 if( m_pWrtShell
->GetDoc()->IsUpdateTOX() )
989 SfxRequest
aSfxRequest( FN_UPDATE_TOX
, SfxCallMode::SLOT
, GetPool() );
990 Execute( aSfxRequest
);
991 m_pWrtShell
->GetDoc()->SetUpdateTOX( false ); // reset again
992 m_pWrtShell
->SttEndDoc(true);
995 // No ResetModified, if there is already a view to this doc.
996 SfxViewFrame
* pVFrame
= GetViewFrame();
997 SfxViewFrame
* pFirst
= SfxViewFrame::GetFirst(&rDocSh
);
998 // Currently(360) the view is registered firstly after the CTOR,
999 // the following expression is also working if this changes.
1000 // If the modification cannot be canceled by undo, then do NOT set
1002 // no reset of modified state, if document
1003 // was already modified.
1004 if (!m_pWrtShell
->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
1005 ( !pFirst
|| pFirst
== pVFrame
) &&
1008 m_pWrtShell
->ResetModified();
1011 g_bNoInterrupt
= bOld
;
1013 // If a new GlobalDoc will be created, the navigator will also be generated.
1014 if( dynamic_cast<const SwGlobalDocShell
*>(&rDocSh
) != nullptr &&
1015 !pVFrame
->GetChildWindow( SID_NAVIGATOR
))
1017 SfxBoolItem
aNavi(SID_NAVIGATOR
, true);
1018 GetDispatcher().ExecuteList(SID_NAVIGATOR
, SfxCallMode::ASYNCHRON
, { &aNavi
});
1021 uno::Reference
< frame::XFrame
> xFrame
= pVFrame
->GetFrame().GetFrameInterface();
1023 uno::Reference
< frame::XFrame
> xBeamerFrame
= xFrame
->findFrame(
1024 "_beamer", frame::FrameSearchFlag::CHILDREN
);
1025 if(xBeamerFrame
.is())
1027 SwDBData aData
= m_pWrtShell
->GetDBData();
1028 SwModule::ShowDBObj( *this, aData
);
1031 // has anybody calls the attrchanged handler in the constructor?
1032 if( m_bAttrChgNotifiedWithRegistrations
)
1034 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1035 if( m_aTimer
.IsActive() )
1039 m_aTimer
.SetInvokeHandler(LINK(this, SwView
, TimeoutHdl
));
1040 m_bAttrChgNotified
= m_bAttrChgNotifiedWithRegistrations
= false;
1042 rDocSh
.EnableSetModified();
1045 if( !m_pHScrollbar
->IsVisible( true ) )
1046 ShowHScrollbar( false );
1047 if( !m_pVScrollbar
->IsVisible( true ) )
1048 ShowVScrollbar( false );
1050 if (m_pWrtShell
&& m_pWrtShell
->GetViewOptions()->IsShowOutlineContentVisibilityButton())
1051 m_pWrtShell
->InvalidateOutlineContentVisibility();
1053 GetViewFrame()->GetWindow().AddChildEventListener( LINK( this, SwView
, WindowChildEventListener
) );
1056 SwViewGlueDocShell::SwViewGlueDocShell(SwView
& rView
, SwDocShell
& rDocSh
)
1060 rDocSh
.SetView(&m_rView
);
1061 SW_MOD()->SetView(&m_rView
);
1064 SwViewGlueDocShell::~SwViewGlueDocShell()
1066 SwDocShell
* pDocSh
= m_rView
.GetDocShell();
1067 if (pDocSh
&& pDocSh
->GetView() == &m_rView
)
1068 pDocSh
->SetView(nullptr);
1069 if (SW_MOD()->GetView() == &m_rView
)
1070 SW_MOD()->SetView(nullptr);
1075 // Notify other LOK views that we are going away.
1076 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_CURSOR_VISIBLE
, "visible", "false");
1077 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_TEXT_VIEW_SELECTION
, "selection", "");
1078 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION
, "selection", "EMPTY");
1080 // Need to remove activated field's button before disposing EditWin.
1081 GetWrtShell().getIDocumentMarkAccess()->ClearFieldActivation();
1083 GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView
, WindowChildEventListener
) );
1084 m_pPostItMgr
.reset();
1087 m_pEditWin
->Hide(); // prevent problems with painting
1089 // Set pointer in SwDocShell to the view again
1090 m_xGlueDocShell
.reset();
1092 if( m_aTimer
.IsActive() && m_bAttrChgNotifiedWithRegistrations
)
1093 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1095 // the last view must end the text edit
1096 SdrView
*pSdrView
= m_pWrtShell
? m_pWrtShell
->GetDrawView() : nullptr;
1097 if( pSdrView
&& pSdrView
->IsTextEdit() )
1098 pSdrView
->SdrEndTextEdit( true );
1101 pSdrView
->DisposeUndoManager();
1104 SetWindow( nullptr );
1106 m_pViewImpl
->Invalidate();
1107 EndListening(*GetViewFrame());
1108 EndListening(*GetDocShell());
1109 m_pScrollFill
.disposeAndClear();
1110 m_pWrtShell
.reset(); // reset here so that it is not accessible by the following dtors.
1111 m_pHScrollbar
.disposeAndClear();
1112 m_pVScrollbar
.disposeAndClear();
1113 m_pHRuler
.disposeAndClear();
1114 m_pVRuler
.disposeAndClear();
1116 m_pViewImpl
.reset();
1118 // If this was enabled in the ctor for the frame, then disable it here.
1119 static bool bRequestDoubleBuffering
= getenv("VCL_DOUBLEBUFFERING_ENABLE");
1120 if (bRequestDoubleBuffering
)
1121 m_pEditWin
->RequestDoubleBuffering(false);
1122 m_pEditWin
.disposeAndClear();
1124 m_pFormatClipboard
.reset();
1127 SwDocShell
* SwView::GetDocShell()
1129 SfxObjectShell
* pDocShell
= GetViewFrame()->GetObjectShell();
1130 return dynamic_cast<SwDocShell
*>( pDocShell
);
1133 // Remember CursorPos
1135 void SwView::WriteUserData( OUString
&rUserData
, bool bBrowse
)
1137 // The browse flag will be passed from Sfx when documents are browsed
1138 // (not to be confused with the BrowseMode).
1139 // Then that stored data are not persistent!
1141 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1142 const tools::Rectangle
& rVis
= GetVisArea();
1144 rUserData
= OUString::number( rRect
.Left() );
1146 rUserData
+= OUString::number( rRect
.Top() );
1148 rUserData
+= OUString::number( m_pWrtShell
->GetViewOptions()->GetZoom() );
1150 rUserData
+= OUString::number( rVis
.Left() );
1152 rUserData
+= OUString::number( rVis
.Top() );
1154 rUserData
+= OUString::number( bBrowse
? SAL_MIN_INT32
: rVis
.Right());
1156 rUserData
+= OUString::number( bBrowse
? SAL_MIN_INT32
: rVis
.Bottom());
1158 rUserData
+= OUString::number(
1159 static_cast<sal_uInt16
>(m_pWrtShell
->GetViewOptions()->GetZoomType()));//eZoom;
1161 rUserData
+= FrameTypeFlags::NONE
== m_pWrtShell
->GetSelFrameType() ? OUStringLiteral(u
"0") : OUStringLiteral(u
"1");
1166 static bool lcl_IsOwnDocument( SwView
& rView
)
1168 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
1169 rView
.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW
);
1170 uno::Reference
<document::XDocumentProperties
> xDocProps
1171 = xDPS
->getDocumentProperties();
1172 OUString Created
= xDocProps
->getAuthor();
1173 OUString Changed
= xDocProps
->getModifiedBy();
1174 OUString FullName
= SW_MOD()->GetUserOptions().GetFullName();
1175 return !FullName
.isEmpty()
1176 && (Changed
== FullName
|| (Changed
.isEmpty() && Created
== FullName
));
1179 void SwView::ReadUserData( const OUString
&rUserData
, bool bBrowse
)
1181 if ( !(rUserData
.indexOf(';')>=0 && // more than one token
1182 // For document without layout only in the onlinelayout or
1183 // while forward/backward
1184 (!m_pWrtShell
->IsNewLayout() || m_pWrtShell
->GetViewOptions()->getBrowseMode() || bBrowse
)) )
1187 bool bIsOwnDocument
= lcl_IsOwnDocument( *this );
1189 CurrShell
aCurr(m_pWrtShell
.get());
1193 // No it is *not* a good idea to call GetToken within Point constr. immediately,
1194 // because which parameter is evaluated first?
1195 tools::Long nX
= rUserData
.getToken( 0, ';', nPos
).toInt32(),
1196 nY
= rUserData
.getToken( 0, ';', nPos
).toInt32();
1197 Point
aCursorPos( nX
, nY
);
1199 sal_uInt16 nZoomFactor
=
1200 static_cast< sal_uInt16
>( rUserData
.getToken(0, ';', nPos
).toInt32() );
1202 tools::Long nLeft
= rUserData
.getToken(0, ';', nPos
).toInt32(),
1203 nTop
= rUserData
.getToken(0, ';', nPos
).toInt32(),
1204 nRight
= rUserData
.getToken(0, ';', nPos
).toInt32(),
1205 nBottom
= rUserData
.getToken(0, ';', nPos
).toInt32();
1207 const tools::Long nAdd
= m_pWrtShell
->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER
: DOCUMENTBORDER
*2;
1208 if ( nBottom
> (m_pWrtShell
->GetDocSize().Height()+nAdd
) )
1211 m_pWrtShell
->EnableSmooth( false );
1213 const tools::Rectangle
aVis( nLeft
, nTop
, nRight
, nBottom
);
1217 if( !m_pWrtShell
->GetViewOptions()->getBrowseMode() )
1218 eZoom
= static_cast<SvxZoomType
>(o3tl::narrowing
<sal_uInt16
>(rUserData
.getToken(nOff
, ';', nPos
).toInt32()));
1221 eZoom
= SvxZoomType::PERCENT
;
1225 bool bSelectObj
= (0 != rUserData
.getToken( nOff
, ';', nPos
).toInt32())
1226 && m_pWrtShell
->IsObjSelectable( aCursorPos
);
1228 // restore editing position
1229 m_pViewImpl
->SetRestorePosition(aCursorPos
, bSelectObj
);
1230 // set flag value to avoid macro execution.
1231 bool bSavedFlagValue
= m_pWrtShell
->IsMacroExecAllowed();
1232 m_pWrtShell
->SetMacroExecAllowed( false );
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
)
1237 m_pWrtShell
->SwCursorShell::SetCursor( aCursorPos
, !bSelectObj
);
1240 m_pWrtShell
->SelectObj( aCursorPos
);
1241 m_pWrtShell
->EnterSelFrameMode( &aCursorPos
);
1246 m_pWrtShell
->SetMacroExecAllowed( bSavedFlagValue
);
1248 // set visible area before applying
1249 // information from print preview. Otherwise, the applied information
1251 // os: changed: The user data has to be read if the view is switched back from page preview
1252 // go to the last editing position when opening own files
1253 if(m_bOldShellWasPagePreview
|| bIsOwnDocument
)
1256 SetVisArea( aVis
.TopLeft() );
1261 //apply information from print preview - if available
1262 if( !m_sNewCursorPos
.isEmpty() )
1264 sal_Int32 nIdx
{ 0 };
1265 const tools::Long nXTmp
= m_sNewCursorPos
.getToken( 0, ';', nIdx
).toInt32();
1266 const tools::Long nYTmp
= m_sNewCursorPos
.getToken( 0, ';', nIdx
).toInt32();
1267 Point
aCursorPos2( nXTmp
, nYTmp
);
1268 bSelectObj
= m_pWrtShell
->IsObjSelectable( aCursorPos2
);
1270 m_pWrtShell
->SwCursorShell::SetCursor( aCursorPos2
);
1273 m_pWrtShell
->SelectObj( aCursorPos2
);
1274 m_pWrtShell
->EnterSelFrameMode( &aCursorPos2
);
1276 m_pWrtShell
->MakeSelVisible();
1277 m_sNewCursorPos
.clear();
1279 else if(USHRT_MAX
!= m_nNewPage
)
1281 m_pWrtShell
->GotoPage(m_nNewPage
, true);
1282 m_nNewPage
= USHRT_MAX
;
1287 m_pWrtShell
->StartAction();
1288 const SwViewOption
* pVOpt
= m_pWrtShell
->GetViewOptions();
1289 if( pVOpt
->GetZoom() != nZoomFactor
|| pVOpt
->GetZoomType() != eZoom
)
1290 SetZoom( eZoom
, nZoomFactor
);
1292 m_pWrtShell
->LockView( true );
1293 m_pWrtShell
->EndAction();
1294 m_pWrtShell
->LockView( false );
1295 m_pWrtShell
->EnableSmooth( true );
1298 void SwView::ReadUserDataSequence ( const uno::Sequence
< beans::PropertyValue
>& rSequence
)
1300 if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick
)
1302 bool bIsOwnDocument
= lcl_IsOwnDocument( *this );
1304 CurrShell
aCurr(m_pWrtShell
.get());
1305 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1306 const tools::Rectangle
&rVis
= GetVisArea();
1307 const SwViewOption
* pVOpt
= m_pWrtShell
->GetViewOptions();
1309 sal_Int64 nX
= rRect
.Left(), nY
= rRect
.Top(), nLeft
= rVis
.Left(), nTop
= rVis
.Top();
1310 sal_Int64 nRight
= nLeft
;
1311 sal_Int64 nBottom
= LONG_MIN
;
1312 sal_Int16 nZoomType
= static_cast< sal_Int16
>(pVOpt
->GetZoomType());
1313 sal_Int16 nZoomFactor
= static_cast < sal_Int16
> (pVOpt
->GetZoom());
1314 bool bViewLayoutBookMode
= pVOpt
->IsViewLayoutBookMode();
1315 sal_Int16 nViewLayoutColumns
= pVOpt
->GetViewLayoutColumns();
1317 bool bSelectedFrame
= ( m_pWrtShell
->GetSelFrameType() != FrameTypeFlags::NONE
),
1318 bGotVisibleLeft
= false,
1319 bGotVisibleTop
= false, bGotVisibleRight
= false,
1320 bGotVisibleBottom
= false, bGotZoomType
= false,
1321 bGotZoomFactor
= false, bGotIsSelectedFrame
= false,
1322 bGotViewLayoutColumns
= false, bGotViewLayoutBookMode
= false,
1323 bBrowseMode
= false, bGotBrowseMode
= false;
1324 bool bKeepRatio
= pVOpt
->IsKeepRatio();
1325 bool bGotKeepRatio
= false;
1327 for (const beans::PropertyValue
& rValue
: rSequence
)
1329 if ( rValue
.Name
== "ViewLeft" )
1331 rValue
.Value
>>= nX
;
1332 nX
= o3tl::toTwips(nX
, o3tl::Length::mm100
);
1334 else if ( rValue
.Name
== "ViewTop" )
1336 rValue
.Value
>>= nY
;
1337 nY
= o3tl::toTwips(nY
, o3tl::Length::mm100
);
1339 else if ( rValue
.Name
== "VisibleLeft" )
1341 rValue
.Value
>>= nLeft
;
1342 nLeft
= o3tl::toTwips(nLeft
, o3tl::Length::mm100
);
1343 bGotVisibleLeft
= true;
1345 else if ( rValue
.Name
== "VisibleTop" )
1347 rValue
.Value
>>= nTop
;
1348 nTop
= o3tl::toTwips(nTop
, o3tl::Length::mm100
);
1349 bGotVisibleTop
= true;
1351 else if ( rValue
.Name
== "VisibleRight" )
1353 rValue
.Value
>>= nRight
;
1354 nRight
= o3tl::toTwips(nRight
, o3tl::Length::mm100
);
1355 bGotVisibleRight
= true;
1357 else if ( rValue
.Name
== "VisibleBottom" )
1359 rValue
.Value
>>= nBottom
;
1360 nBottom
= o3tl::toTwips(nBottom
, o3tl::Length::mm100
);
1361 bGotVisibleBottom
= true;
1363 else if ( rValue
.Name
== "ZoomType" )
1365 rValue
.Value
>>= nZoomType
;
1366 bGotZoomType
= true;
1368 else if ( rValue
.Name
== "ZoomFactor" )
1370 rValue
.Value
>>= nZoomFactor
;
1371 bGotZoomFactor
= true;
1373 else if ( rValue
.Name
== "ViewLayoutColumns" )
1375 rValue
.Value
>>= nViewLayoutColumns
;
1376 bGotViewLayoutColumns
= true;
1378 else if ( rValue
.Name
== "ViewLayoutBookMode" )
1380 bViewLayoutBookMode
= *o3tl::doAccess
<bool>(rValue
.Value
);
1381 bGotViewLayoutBookMode
= true;
1383 else if ( rValue
.Name
== "IsSelectedFrame" )
1385 rValue
.Value
>>= bSelectedFrame
;
1386 bGotIsSelectedFrame
= true;
1388 else if (rValue
.Name
== "ShowOnlineLayout")
1390 rValue
.Value
>>= bBrowseMode
;
1391 bGotBrowseMode
= true;
1393 else if (rValue
.Name
== "KeepRatio")
1395 rValue
.Value
>>= bKeepRatio
;
1396 bGotKeepRatio
= true;
1398 // Fallback to common SdrModel processing
1400 GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(&rValue
);
1405 GetViewImpl()->GetUNOObject_Impl()->getViewSettings()->setPropertyValue("ShowOnlineLayout", uno::Any(bBrowseMode
));
1410 if (!bGotVisibleBottom
)
1413 Point
aCursorPos( nX
, nY
);
1414 const tools::Long nAdd
= m_pWrtShell
->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER
: DOCUMENTBORDER
*2;
1415 if (nBottom
> (m_pWrtShell
->GetDocSize().Height()+nAdd
) )
1418 m_pWrtShell
->EnableSmooth( false );
1419 const tools::Rectangle
aVis( nLeft
, nTop
, nRight
, nBottom
);
1422 if ( !m_pWrtShell
->GetViewOptions()->getBrowseMode() )
1423 eZoom
= static_cast < SvxZoomType
> ( nZoomType
);
1426 eZoom
= SvxZoomType::PERCENT
;
1428 if (bGotIsSelectedFrame
)
1430 bool bSelectObj
= bSelectedFrame
&& m_pWrtShell
->IsObjSelectable( aCursorPos
);
1432 // set flag value to avoid macro execution.
1433 bool bSavedFlagValue
= m_pWrtShell
->IsMacroExecAllowed();
1434 m_pWrtShell
->SetMacroExecAllowed( false );
1435 // os: changed: The user data has to be read if the view is switched back from page preview
1436 // go to the last editing position when opening own files
1437 m_pViewImpl
->SetRestorePosition(aCursorPos
, bSelectObj
);
1438 if(m_bOldShellWasPagePreview
|| bIsOwnDocument
)
1440 m_pWrtShell
->SwCursorShell::SetCursor( aCursorPos
, !bSelectObj
);
1442 // Update the shell to toggle Header/Footer edit if needed
1443 bool bInHeader
= true;
1444 if ( m_pWrtShell
->IsInHeaderFooter( &bInHeader
) )
1448 m_pWrtShell
->SetShowHeaderFooterSeparator( FrameControlType::Footer
, true );
1449 m_pWrtShell
->SetShowHeaderFooterSeparator( FrameControlType::Header
, false );
1453 m_pWrtShell
->SetShowHeaderFooterSeparator( FrameControlType::Header
, true );
1454 m_pWrtShell
->SetShowHeaderFooterSeparator( FrameControlType::Footer
, false );
1458 m_pWrtShell
->GetWin()->Invalidate();
1460 if ( m_pWrtShell
->IsInHeaderFooter() != m_pWrtShell
->IsHeaderFooterEdit() )
1461 m_pWrtShell
->ToggleHeaderFooterEdit();
1465 m_pWrtShell
->SelectObj( aCursorPos
);
1466 m_pWrtShell
->EnterSelFrameMode( &aCursorPos
);
1471 m_pWrtShell
->SetMacroExecAllowed( bSavedFlagValue
);
1474 if (bGotKeepRatio
&& bKeepRatio
!= pVOpt
->IsKeepRatio())
1476 // Got a custom value, then it makes sense to trigger notifications.
1477 SwViewOption
aUsrPref(*pVOpt
);
1478 aUsrPref
.SetKeepRatio(bKeepRatio
);
1479 SW_MOD()->ApplyUsrPref(aUsrPref
, this);
1482 // Set ViewLayoutSettings
1483 const bool bSetViewLayoutSettings
= bGotViewLayoutColumns
&& bGotViewLayoutBookMode
&&
1484 ( pVOpt
->GetViewLayoutColumns() != nViewLayoutColumns
|| pVOpt
->IsViewLayoutBookMode() != bViewLayoutBookMode
);
1486 const bool bSetViewSettings
= bGotZoomType
&& bGotZoomFactor
&&
1487 ( pVOpt
->GetZoom() != nZoomFactor
|| pVOpt
->GetZoomType() != eZoom
);
1489 // In case we have a 'fixed' view layout of 2 or more columns,
1490 // we have to apply the view options *before* starting the action.
1491 // Otherwise the SetZoom function cannot work correctly, because
1492 // the view layout hasn't been calculated.
1493 const bool bZoomNeedsViewLayout
= bSetViewLayoutSettings
&&
1494 1 < nViewLayoutColumns
&&
1496 eZoom
!= SvxZoomType::PERCENT
;
1498 if ( !bZoomNeedsViewLayout
)
1499 m_pWrtShell
->StartAction();
1501 if ( bSetViewLayoutSettings
)
1502 SetViewLayout( nViewLayoutColumns
, bViewLayoutBookMode
, true );
1504 if ( bZoomNeedsViewLayout
)
1505 m_pWrtShell
->StartAction();
1507 if ( bSetViewSettings
)
1508 SetZoom( eZoom
, nZoomFactor
, true );
1510 // os: changed: The user data has to be read if the view is switched back from page preview
1511 // go to the last editing position when opening own files
1512 if(m_bOldShellWasPagePreview
||bIsOwnDocument
)
1514 if ( bGotVisibleLeft
&& bGotVisibleTop
)
1516 Point
aTopLeft(aVis
.TopLeft());
1517 // make sure the document is still centered
1518 const SwTwips lBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: 2 * DOCUMENTBORDER
;
1519 SwTwips nEditWidth
= GetEditWin().GetOutDev()->GetOutputSize().Width();
1520 if(nEditWidth
> (m_aDocSz
.Width() + lBorder
))
1521 aTopLeft
.setX( ( m_aDocSz
.Width() + lBorder
- nEditWidth
) / 2 );
1524 //check if the values are possible
1525 tools::Long nXMax
= m_pHScrollbar
->GetRangeMax() - m_pHScrollbar
->GetVisibleSize();
1526 if( aTopLeft
.X() > nXMax
)
1527 aTopLeft
.setX( nXMax
< 0 ? 0 : nXMax
);
1529 SetVisArea( aTopLeft
);
1531 else if (bGotVisibleLeft
&& bGotVisibleTop
&& bGotVisibleRight
&& bGotVisibleBottom
)
1535 m_pWrtShell
->LockView( true );
1536 m_pWrtShell
->EndAction();
1537 m_pWrtShell
->LockView( false );
1538 m_pWrtShell
->EnableSmooth( true );
1542 void SwView::WriteUserDataSequence ( uno::Sequence
< beans::PropertyValue
>& rSequence
)
1544 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1545 const tools::Rectangle
& rVis
= GetVisArea();
1547 std::vector
<beans::PropertyValue
> aVector
;
1549 sal_uInt16
nViewID( GetViewFrame()->GetCurViewId());
1550 aVector
.push_back(comphelper::makePropertyValue("ViewId", "view" + OUString::number(nViewID
)));
1552 aVector
.push_back(comphelper::makePropertyValue("ViewLeft", convertTwipToMm100 ( rRect
.Left() )));
1554 aVector
.push_back(comphelper::makePropertyValue("ViewTop", convertTwipToMm100 ( rRect
.Top() )));
1556 auto visibleLeft
= convertTwipToMm100 ( rVis
.Left() );
1557 aVector
.push_back(comphelper::makePropertyValue("VisibleLeft", visibleLeft
));
1559 auto visibleTop
= convertTwipToMm100 ( rVis
.Top() );
1560 aVector
.push_back(comphelper::makePropertyValue("VisibleTop", visibleTop
));
1562 auto visibleRight
= rVis
.IsWidthEmpty() ? visibleLeft
: convertTwipToMm100 ( rVis
.Right() );
1563 aVector
.push_back(comphelper::makePropertyValue("VisibleRight", visibleRight
));
1565 auto visibleBottom
= rVis
.IsHeightEmpty() ? visibleTop
: convertTwipToMm100 ( rVis
.Bottom() );
1566 aVector
.push_back(comphelper::makePropertyValue("VisibleBottom", visibleBottom
));
1568 const sal_Int16 nZoomType
= static_cast< sal_Int16
>(m_pWrtShell
->GetViewOptions()->GetZoomType());
1569 aVector
.push_back(comphelper::makePropertyValue("ZoomType", nZoomType
));
1571 const sal_Int16 nViewLayoutColumns
= static_cast< sal_Int16
>(m_pWrtShell
->GetViewOptions()->GetViewLayoutColumns());
1572 aVector
.push_back(comphelper::makePropertyValue("ViewLayoutColumns", nViewLayoutColumns
));
1574 aVector
.push_back(comphelper::makePropertyValue("ViewLayoutBookMode", m_pWrtShell
->GetViewOptions()->IsViewLayoutBookMode()));
1576 aVector
.push_back(comphelper::makePropertyValue("ZoomFactor", static_cast < sal_Int16
> (m_pWrtShell
->GetViewOptions()->GetZoom())));
1578 aVector
.push_back(comphelper::makePropertyValue("IsSelectedFrame", FrameTypeFlags::NONE
!= m_pWrtShell
->GetSelFrameType()));
1581 comphelper::makePropertyValue("KeepRatio", m_pWrtShell
->GetViewOptions()->IsKeepRatio()));
1583 rSequence
= comphelper::containerToSequence(aVector
);
1585 // Common SdrModel processing
1586 GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->WriteUserDataSequence(rSequence
);
1589 void SwView::ShowCursor( bool bOn
)
1591 //don't scroll the cursor into the visible area
1592 bool bUnlockView
= !m_pWrtShell
->IsViewLocked();
1593 m_pWrtShell
->LockView( true ); //lock visible section
1596 m_pWrtShell
->HideCursor();
1597 else if( !m_pWrtShell
->IsFrameSelected() && !m_pWrtShell
->IsObjSelected() )
1598 m_pWrtShell
->ShowCursor();
1601 m_pWrtShell
->LockView( false );
1604 ErrCode
SwView::DoVerb(sal_Int32 nVerb
)
1606 if ( !GetViewFrame()->GetFrame().IsInPlace() )
1608 SwWrtShell
&rSh
= GetWrtShell();
1609 const SelectionType nSel
= rSh
.GetSelectionType();
1610 if ( nSel
& SelectionType::Ole
)
1611 rSh
.LaunchOLEObj( nVerb
);
1613 return ERRCODE_NONE
;
1616 // only return true for a text selection
1618 bool SwView::HasSelection( bool bText
) const
1620 return bText
? GetWrtShell().SwCursorShell::HasSelection()
1621 : GetWrtShell().HasSelection();
1624 OUString
SwView::GetSelectionText( bool bCompleteWrds
)
1626 return GetSelectionTextParam( bCompleteWrds
, true );
1629 OUString
SwView::GetSelectionTextParam( bool bCompleteWrds
, bool bEraseTrail
)
1632 if( bCompleteWrds
&& !GetWrtShell().HasSelection() )
1633 GetWrtShell().SelWrd();
1635 GetWrtShell().GetSelectedText( sReturn
);
1637 sReturn
= comphelper::string::stripEnd(sReturn
, ' ');
1641 SwGlossaryHdl
* SwView::GetGlosHdl()
1644 m_pGlosHdl
.reset(new SwGlossaryHdl(GetViewFrame(), m_pWrtShell
.get()));
1645 return m_pGlosHdl
.get();
1648 void SwView::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1650 bool bCallBase
= true;
1651 if(auto pChangedHint
= dynamic_cast<const FmDesignModeChangedHint
*>(&rHint
))
1653 bool bDesignMode
= pChangedHint
->GetDesignMode();
1654 if (!bDesignMode
&& GetDrawFuncPtr())
1656 GetDrawFuncPtr()->Deactivate();
1657 SetDrawFuncPtr(nullptr);
1659 AttrChangedNotify(nullptr);
1664 SfxHintId nId
= rHint
.GetId();
1668 // sub shells will be destroyed by the
1669 // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1670 case SfxHintId::Dying
:
1672 if ( &rBC
== GetViewFrame() )
1678 case SfxHintId::ModeChanged
:
1680 // Modal mode change-over?
1681 bool bModal
= GetDocShell()->IsInModalMode();
1682 m_pHRuler
->SetActive( !bModal
);
1683 m_pVRuler
->SetActive( !bModal
);
1688 case SfxHintId::TitleChanged
:
1689 if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1691 SwWrtShell
&rSh
= GetWrtShell();
1692 rSh
.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1694 if ( rSh
.GetViewOptions()->IsViewVRuler() )
1698 if ( rSh
.GetViewOptions()->IsViewHRuler() )
1702 bool bReadonly
= GetDocShell()->IsReadOnly();
1703 // if document is to be opened in alive-mode then this has to be
1704 // regarded while switching from readonly-mode to edit-mode
1707 SwDrawModel
* pDrawDoc
= GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
1710 if( !pDrawDoc
->GetOpenInDesignMode() )
1711 break;// don't touch the design mode
1714 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !bReadonly
);
1715 GetDispatcher().ExecuteList(SID_FM_DESIGN_MODE
,
1716 SfxCallMode::ASYNCHRON
, { &aItem
});
1720 case SfxHintId::SwDrawViewsCreated
:
1723 if ( GetFormShell() )
1725 GetFormShell()->SetView(dynamic_cast<FmFormView
*>(GetWrtShell().GetDrawView()));
1726 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !GetDocShell()->IsReadOnly());
1727 GetDispatcher().ExecuteList(SID_FM_DESIGN_MODE
,
1728 SfxCallMode::SYNCHRON
, { &aItem
});
1732 case SfxHintId::RedlineChanged
:
1734 static sal_uInt16
const aSlotRedLine
[] = {
1735 FN_REDLINE_ACCEPT_DIRECT
,
1736 FN_REDLINE_REJECT_DIRECT
,
1737 FN_REDLINE_NEXT_CHANGE
,
1738 FN_REDLINE_PREV_CHANGE
,
1739 FN_REDLINE_ACCEPT_ALL
,
1740 FN_REDLINE_REJECT_ALL
,
1743 GetViewFrame()->GetBindings().Invalidate(aSlotRedLine
);
1751 SfxViewShell::Notify(rBC
, rHint
);
1754 #if defined(_WIN32) || defined UNX
1756 void SwView::ScannerEventHdl()
1758 uno::Reference
< XScannerManager2
> xScanMgr
= SW_MOD()->GetScannerManager();
1761 const ScannerContext
aContext( xScanMgr
->getAvailableScanners().getConstArray()[ 0 ] );
1762 const ScanError eError
= xScanMgr
->getError( aContext
);
1764 if( ScanError_ScanErrorNone
== eError
)
1766 const uno::Reference
< awt::XBitmap
> xBitmap( xScanMgr
->getBitmap( aContext
) );
1770 const BitmapEx
aScanBmp( VCLUnoHelper::GetBitmap( xBitmap
) );
1772 if( !aScanBmp
.IsEmpty() )
1774 Graphic
aGrf(aScanBmp
);
1775 m_pWrtShell
->Insert( OUString(), OUString(), aGrf
);
1780 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
1781 rBind
.Invalidate( SID_TWAIN_SELECT
);
1782 rBind
.Invalidate( SID_TWAIN_TRANSFER
);
1786 void SwView::StopShellTimer()
1788 if(m_aTimer
.IsActive())
1791 if ( m_bAttrChgNotifiedWithRegistrations
)
1793 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1794 m_bAttrChgNotifiedWithRegistrations
= false;
1797 m_bAttrChgNotified
= false;
1801 bool SwView::PrepareClose( bool bUI
)
1803 SfxViewFrame
* pVFrame
= GetViewFrame();
1804 pVFrame
->SetChildWindow( SwInputChild::GetChildWindowId(), false );
1805 if( pVFrame
->GetDispatcher()->IsLocked() )
1806 pVFrame
->GetDispatcher()->Lock(false);
1808 if ( m_pFormShell
&& !m_pFormShell
->PrepareClose( bUI
) )
1812 return SfxViewShell::PrepareClose( bUI
);
1815 // status methods for clipboard.
1816 // Status changes now notified from the clipboard.
1817 bool SwView::IsPasteAllowed()
1819 SotExchangeDest nPasteDestination
= SwTransferable::GetSotDestination( *m_pWrtShell
);
1820 if( m_nLastPasteDestination
!= nPasteDestination
)
1822 TransferableDataHelper
aDataHelper(
1823 TransferableDataHelper::CreateFromSystemClipboard(
1825 if( aDataHelper
.GetXTransferable().is() )
1827 m_bPasteState
= SwTransferable::IsPaste( *m_pWrtShell
, aDataHelper
);
1828 m_bPasteSpecialState
= SwTransferable::IsPasteSpecial(
1829 *m_pWrtShell
, aDataHelper
);
1832 m_bPasteState
= m_bPasteSpecialState
= false;
1834 if( static_cast<SotExchangeDest
>(0xFFFF) == m_nLastPasteDestination
) // the init value
1835 m_pViewImpl
->AddClipboardListener();
1836 m_nLastPasteDestination
= nPasteDestination
;
1838 return m_bPasteState
;
1841 bool SwView::IsPasteSpecialAllowed()
1843 if ( m_pFormShell
&& m_pFormShell
->IsActiveControl() )
1846 SotExchangeDest nPasteDestination
= SwTransferable::GetSotDestination( *m_pWrtShell
);
1847 if( m_nLastPasteDestination
!= nPasteDestination
)
1849 TransferableDataHelper
aDataHelper(
1850 TransferableDataHelper::CreateFromSystemClipboard(
1852 if( aDataHelper
.GetXTransferable().is() )
1854 m_bPasteState
= SwTransferable::IsPaste( *m_pWrtShell
, aDataHelper
);
1855 m_bPasteSpecialState
= SwTransferable::IsPasteSpecial(
1856 *m_pWrtShell
, aDataHelper
);
1859 m_bPasteState
= m_bPasteSpecialState
= false;
1861 if( static_cast<SotExchangeDest
>(0xFFFF) == m_nLastPasteDestination
) // the init value
1862 m_pViewImpl
->AddClipboardListener();
1864 return m_bPasteSpecialState
;
1867 bool SwView::IsPasteSpreadsheet(bool bHasOwnTableCopied
)
1869 TransferableDataHelper
aDataHelper(
1870 TransferableDataHelper::CreateFromSystemClipboard(
1872 if( aDataHelper
.GetXTransferable().is() )
1874 if (bHasOwnTableCopied
&& SwTransferable::IsPasteOwnFormat( aDataHelper
))
1876 return aDataHelper
.HasFormat( SotClipboardFormatId::SYLK
) || aDataHelper
.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS
);
1881 void SwView::NotifyDBChanged()
1883 GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1888 SfxObjectShellLock
SwView::CreateTmpSelectionDoc()
1890 SwXTextView
*const pTempImpl
= GetViewImpl()->GetUNOObject_Impl();
1891 return pTempImpl
->BuildTmpSelectionDoc();
1894 void SwView::AddTransferable(SwTransferable
& rTransferable
)
1896 GetViewImpl()->AddTransferable(rTransferable
);
1899 tools::Rectangle
SwView::getLOKVisibleArea() const
1901 SwViewShell
* pVwSh
= GetWrtShellPtr();
1903 return pVwSh
->getLOKVisibleArea();
1905 return tools::Rectangle();
1908 void SwView::flushPendingLOKInvalidateTiles()
1910 SwWrtShell
* pSh
= GetWrtShellPtr();
1912 pSh
->FlushPendingLOKInvalidateTiles();
1915 OUString
SwView::GetDataSourceName() const
1917 uno::Reference
<lang::XMultiServiceFactory
> xFactory(GetDocShell()->GetModel(), uno::UNO_QUERY
);
1918 uno::Reference
<beans::XPropertySet
> xSettings(
1919 xFactory
->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY
);
1920 OUString sDataSourceName
= "";
1921 xSettings
->getPropertyValue("CurrentDatabaseDataSource") >>= sDataSourceName
;
1923 return sDataSourceName
;
1926 bool SwView::IsDataSourceAvailable(const OUString sDataSourceName
)
1928 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
1929 Reference
< XDatabaseContext
> xDatabaseContext
= DatabaseContext::create(xContext
);
1931 return xDatabaseContext
->hasByName(sDataSourceName
);
1936 void InitPrintOptionsFromApplication(SwPrintData
& o_rData
, bool const bWeb
)
1938 o_rData
= *SW_MOD()->GetPrtOptions(bWeb
);
1943 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */