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>
24 #include <hintids.hxx>
25 #include <comphelper/string.hxx>
26 #include <o3tl/any.hxx>
27 #include <officecfg/Office/Common.hxx>
28 #include <vcl/graph.hxx>
29 #include <vcl/inputctx.hxx>
30 #include <basic/sbxobj.hxx>
31 #include <svl/eitem.hxx>
32 #include <unotools/configmgr.hxx>
33 #include <unotools/lingucfg.hxx>
34 #include <unotools/useroptions.hxx>
35 #include <sfx2/app.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/docfile.hxx>
38 #include <sfx2/objface.hxx>
39 #include <sfx2/printer.hxx>
40 #include <sfx2/request.hxx>
41 #include <svx/ruler.hxx>
42 #include <svx/srchdlg.hxx>
43 #include <editeng/protitem.hxx>
44 #include <svx/fmshell.hxx>
45 #include <svx/extrusionbar.hxx>
46 #include <svx/fontworkbar.hxx>
47 #include <unotxvw.hxx>
49 #include <svl/hint.hxx>
50 #include <swmodule.hxx>
51 #include <inputwin.hxx>
52 #include <chartins.hxx>
53 #include <uivwimp.hxx>
60 #include <mediash.hxx>
65 #include <drawbase.hxx>
66 #include <drformsh.hxx>
67 #include <drwtxtsh.hxx>
68 #include <beziersh.hxx>
70 #include <globdoc.hxx>
73 #include <gloshdl.hxx>
74 #include <usrpref.hxx>
75 #include <srcview.hxx>
77 #include <IDocumentUndoRedo.hxx>
78 #include <IDocumentSettingAccess.hxx>
79 #include <IDocumentDrawModelAccess.hxx>
80 #include <DocumentFieldsManager.hxx>
81 #include <IDocumentState.hxx>
82 #include <IDocumentLayoutAccess.hxx>
83 #include <drawdoc.hxx>
86 #include <workctrl.hxx>
90 #include <swdtflvr.hxx>
91 #include <cfgitems.hxx>
93 #include <linguistic/lngprops.hxx>
94 #include <editeng/unolingu.hxx>
95 #include <com/sun/star/frame/FrameSearchFlag.hpp>
96 #include <com/sun/star/frame/XLayoutManager.hpp>
97 #include <com/sun/star/scanner/ScannerContext.hpp>
98 #include <com/sun/star/scanner/XScannerManager2.hpp>
99 #include <toolkit/helper/vclunohelper.hxx>
100 #include <rtl/ustrbuf.hxx>
101 #include <sal/log.hxx>
102 #include <sax/tools/converter.hxx>
104 #include <formatclipboard.hxx>
105 #include <PostItMgr.hxx>
106 #include <annotsh.hxx>
107 #include <swruler.hxx>
109 #include <fldbas.hxx>
113 #include <com/sun/star/document/XDocumentProperties.hpp>
114 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
116 #include <svl/cjkoptions.hxx>
117 #include <comphelper/propertyvalue.hxx>
118 #include <sfx2/lokhelper.hxx>
119 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
120 #include <svtools/embedhlp.hxx>
122 using namespace ::com::sun::star
;
123 using namespace ::com::sun::star::uno
;
124 using namespace ::com::sun::star::lang
;
125 using namespace ::com::sun::star::scanner
;
127 #define SWVIEWFLAGS SfxViewShellFlags::HAS_PRINTOPTIONS
131 bool bDocSzUpdated
= true;
133 SvxSearchItem
* SwView::m_pSrchItem
= nullptr;
135 bool SwView::m_bExtra
= false;
136 bool SwView::m_bFound
= false;
137 bool SwView::m_bJustOpened
= false;
139 SearchAttrItemList
* SwView::m_pSrchList
= nullptr;
140 SearchAttrItemList
* SwView::m_pReplList
= nullptr;
142 SfxDispatcher
&SwView::GetDispatcher()
144 return *GetViewFrame()->GetDispatcher();
147 void SwView::ImpSetVerb( SelectionType nSelType
)
149 bool bResetVerbs
= m_bVerbsActive
;
150 if ( !GetViewFrame()->GetFrame().IsInPlace() &&
151 (SelectionType::Ole
|SelectionType::Graphic
) & nSelType
)
153 if ( m_pWrtShell
->IsSelObjProtected(FlyProtectFlags::Content
) == FlyProtectFlags::NONE
)
155 if ( nSelType
& SelectionType::Ole
)
157 SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
158 m_bVerbsActive
= true;
165 SetVerbs( Sequence
< embed::VerbDescriptor
>() );
166 m_bVerbsActive
= false;
170 // Called by the SwEditWin when it gets the focus.
172 void SwView::GotFocus() const
174 // if we got the focus, and the form shell *is* on the top of the dispatcher
175 // stack, then we need to rebuild the stack (the form shell doesn't belong to
177 const SfxDispatcher
& rDispatcher
= const_cast< SwView
* >( this )->GetDispatcher();
178 SfxShell
* pTopShell
= rDispatcher
.GetShell( 0 );
179 FmFormShell
* pAsFormShell
= dynamic_cast<FmFormShell
*>( pTopShell
);
182 pAsFormShell
->ForgetActiveControl();
183 const_cast< SwView
* >( this )->AttrChangedNotify( m_pWrtShell
.get() );
185 else if ( m_pPostItMgr
)
187 SwAnnotationShell
* pAsAnnotationShell
= dynamic_cast<SwAnnotationShell
*>( pTopShell
);
188 if ( pAsAnnotationShell
)
190 m_pPostItMgr
->SetActiveSidebarWin(nullptr);
191 const_cast< SwView
* >( this )->AttrChangedNotify( m_pWrtShell
.get() );
194 if( GetWrtShellPtr() )
196 SwWrtShell
& rWrtShell
= GetWrtShell();
197 rWrtShell
.GetDoc()->getIDocumentLayoutAccess().SetCurrentViewShell( GetWrtShellPtr() );
198 rWrtShell
.GetDoc()->getIDocumentSettingAccess().set( DocumentSettingId::BROWSE_MODE
,
199 rWrtShell
.GetViewOptions()->getBrowseMode() );
203 // called by the FormShell when a form control is focused. This is
204 // a request to put the form shell on the top of the dispatcher stack
206 IMPL_LINK_NOARG(SwView
, FormControlActivated
, LinkParamNone
*, void)
208 // if a form control has been activated, and the form shell is not on the top
209 // of the dispatcher stack, then we need to activate it
210 const SfxDispatcher
& rDispatcher
= GetDispatcher();
211 const SfxShell
* pTopShell
= rDispatcher
.GetShell( 0 );
212 const FmFormShell
* pAsFormShell
= dynamic_cast<const FmFormShell
*>( pTopShell
);
215 // if we're editing text currently, cancel this
216 SdrView
*pSdrView
= m_pWrtShell
? m_pWrtShell
->GetDrawView() : nullptr;
217 if ( pSdrView
&& pSdrView
->IsTextEdit() )
218 pSdrView
->SdrEndTextEdit( true );
220 AttrChangedNotify( m_pWrtShell
.get() );
226 uno::Reference
<frame::XLayoutManager
> getLayoutManager(const SfxViewFrame
& rViewFrame
)
228 uno::Reference
<frame::XLayoutManager
> xLayoutManager
;
229 uno::Reference
<beans::XPropertySet
> xPropSet(rViewFrame
.GetFrame().GetFrameInterface(),
235 xLayoutManager
.set(xPropSet
->getPropertyValue("LayoutManager"), uno::UNO_QUERY
);
237 catch (const Exception
& e
)
239 SAL_WARN("sw.ui", "Failure getting layout manager: " + e
.Message
);
242 return xLayoutManager
;
246 void SwView::ShowUIElement(const OUString
& sElementURL
) const
248 if (auto xLayoutManager
= getLayoutManager(*GetViewFrame()))
250 if (!xLayoutManager
->getElement(sElementURL
).is())
252 xLayoutManager
->createElement(sElementURL
);
253 xLayoutManager
->showElement(sElementURL
);
258 void SwView::SelectShell()
260 // Attention: Maintain the SelectShell for the WebView additionally
265 // Decision if the UpdateTable has to be called
266 bool bUpdateTable
= false;
267 const SwFrameFormat
* pCurTableFormat
= m_pWrtShell
->GetTableFormat();
268 if(pCurTableFormat
&& pCurTableFormat
!= m_pLastTableFormat
)
270 bUpdateTable
= true; // can only be executed later
272 m_pLastTableFormat
= pCurTableFormat
;
274 //SEL_TBL and SEL_TBL_CELLS can be ORed!
275 SelectionType nNewSelectionType
= m_pWrtShell
->GetSelectionType()
276 & ~SelectionType::TableCell
;
278 if ( m_pFormShell
&& m_pFormShell
->IsActiveControl() )
279 nNewSelectionType
|= SelectionType::FormControl
;
281 if ( nNewSelectionType
== m_nSelectionType
)
283 GetViewFrame()->GetBindings().InvalidateAll( false );
284 if ( m_nSelectionType
& SelectionType::Ole
||
285 m_nSelectionType
& SelectionType::Graphic
)
286 // For graphs and OLE the verb can be modified of course!
287 ImpSetVerb( nNewSelectionType
);
292 SfxDispatcher
&rDispatcher
= GetDispatcher();
293 SwToolbarConfigItem
*pBarCfg
= SW_MOD()->GetToolbarConfig();
297 rDispatcher
.Flush(); // Really erase all cached shells
298 //Remember to the old selection which toolbar was visible
299 ToolbarId eId
= rDispatcher
.GetObjectBarId(SFX_OBJECTBAR_OBJECT
);
300 if (eId
!= ToolbarId::None
)
301 pBarCfg
->SetTopToolbar(m_nSelectionType
, eId
);
303 for ( sal_uInt16 i
= 0; true; ++i
)
305 SfxShell
*pSfxShell
= rDispatcher
.GetShell( i
);
306 if ( dynamic_cast< const SwBaseShell
*>( pSfxShell
) != nullptr
307 || dynamic_cast< const SwDrawTextShell
*>( pSfxShell
) != nullptr
308 || dynamic_cast< const svx::ExtrusionBar
*>( pSfxShell
) != nullptr
309 || dynamic_cast< const svx::FontworkBar
*>( pSfxShell
) != nullptr
310 || dynamic_cast< const SwAnnotationShell
*>( pSfxShell
) != nullptr
313 rDispatcher
.Pop( *pSfxShell
, SfxDispatcherPopFlags::POP_DELETE
);
315 else if ( dynamic_cast< const FmFormShell
*>( pSfxShell
) != nullptr )
317 rDispatcher
.Pop( *pSfxShell
);
324 bool bInitFormShell
= false;
327 bInitFormShell
= true;
328 m_pFormShell
= new FmFormShell( this );
329 m_pFormShell
->SetControlActivationHandler( LINK( this, SwView
, FormControlActivated
) );
330 StartListening(*m_pFormShell
);
333 bool bSetExtInpCntxt
= false;
334 m_nSelectionType
= nNewSelectionType
;
335 ShellMode eShellMode
;
337 if ( !( m_nSelectionType
& SelectionType::FormControl
) )
338 rDispatcher
.Push( *m_pFormShell
);
340 m_pShell
= new SwNavigationShell( *this );
341 rDispatcher
.Push( *m_pShell
);
343 if ( m_nSelectionType
& SelectionType::Ole
)
345 eShellMode
= ShellMode::Object
;
346 m_pShell
= new SwOleShell( *this );
347 rDispatcher
.Push( *m_pShell
);
349 else if ( m_nSelectionType
& SelectionType::Frame
350 || m_nSelectionType
& SelectionType::Graphic
)
352 eShellMode
= ShellMode::Frame
;
353 m_pShell
= new SwFrameShell( *this );
354 rDispatcher
.Push( *m_pShell
);
355 if(m_nSelectionType
& SelectionType::Graphic
)
357 eShellMode
= ShellMode::Graphic
;
358 m_pShell
= new SwGrfShell( *this );
359 rDispatcher
.Push( *m_pShell
);
362 else if ( m_nSelectionType
& SelectionType::DrawObject
)
364 eShellMode
= ShellMode::Draw
;
365 m_pShell
= new SwDrawShell( *this );
366 rDispatcher
.Push( *m_pShell
);
368 if ( m_nSelectionType
& SelectionType::Ornament
)
370 eShellMode
= ShellMode::Bezier
;
371 m_pShell
= new SwBezierShell( *this );
372 rDispatcher
.Push( *m_pShell
);
374 #if HAVE_FEATURE_AVMEDIA
375 else if( m_nSelectionType
& SelectionType::Media
)
377 eShellMode
= ShellMode::Media
;
378 m_pShell
= new SwMediaShell( *this );
379 rDispatcher
.Push( *m_pShell
);
382 if (m_nSelectionType
& SelectionType::ExtrudedCustomShape
)
384 eShellMode
= ShellMode::ExtrudedCustomShape
;
385 m_pShell
= new svx::ExtrusionBar(this);
386 rDispatcher
.Push( *m_pShell
);
388 if (m_nSelectionType
& SelectionType::FontWork
)
390 eShellMode
= ShellMode::FontWork
;
391 m_pShell
= new svx::FontworkBar(this);
392 rDispatcher
.Push( *m_pShell
);
395 else if ( m_nSelectionType
& SelectionType::DbForm
)
397 eShellMode
= ShellMode::DrawForm
;
398 m_pShell
= new SwDrawFormShell( *this );
400 rDispatcher
.Push( *m_pShell
);
402 else if ( m_nSelectionType
& SelectionType::DrawObjectEditMode
)
404 bSetExtInpCntxt
= true;
405 eShellMode
= ShellMode::DrawText
;
406 rDispatcher
.Push( *(new SwBaseShell( *this )) );
407 m_pShell
= new SwDrawTextShell( *this );
408 rDispatcher
.Push( *m_pShell
);
410 else if ( m_nSelectionType
& SelectionType::PostIt
)
412 eShellMode
= ShellMode::PostIt
;
413 m_pShell
= new SwAnnotationShell( *this );
414 rDispatcher
.Push( *m_pShell
);
418 bSetExtInpCntxt
= true;
419 eShellMode
= ShellMode::Text
;
420 if ( m_nSelectionType
& SelectionType::NumberList
)
422 eShellMode
= ShellMode::ListText
;
423 m_pShell
= new SwListShell( *this );
424 rDispatcher
.Push( *m_pShell
);
426 m_pShell
= new SwTextShell(*this);
427 rDispatcher
.Push( *m_pShell
);
428 if ( m_nSelectionType
& SelectionType::Table
)
430 eShellMode
= eShellMode
== ShellMode::ListText
? ShellMode::TableListText
431 : ShellMode::TableText
;
432 m_pShell
= new SwTableShell( *this );
433 rDispatcher
.Push( *m_pShell
);
437 if ( m_nSelectionType
& SelectionType::FormControl
)
438 rDispatcher
.Push( *m_pFormShell
);
440 m_pViewImpl
->SetShellMode(eShellMode
);
441 ImpSetVerb( m_nSelectionType
);
443 if( !GetDocShell()->IsReadOnly() )
445 if( bSetExtInpCntxt
&& GetWrtShell().HasReadonlySel() )
446 bSetExtInpCntxt
= false;
448 InputContext
aCntxt( GetEditWin().GetInputContext() );
449 aCntxt
.SetOptions( bSetExtInpCntxt
450 ? (aCntxt
.GetOptions() |
451 ( InputContextFlags::Text
|
452 InputContextFlags::ExtText
))
453 : (aCntxt
.GetOptions() & ~
454 InputContextFlags( InputContextFlags::Text
|
455 InputContextFlags::ExtText
)) );
456 GetEditWin().SetInputContext( aCntxt
);
459 // Show Mail Merge toolbar initially for documents with Database fields
460 if (!m_bInitOnceCompleted
&& GetWrtShell().IsAnyDatabaseFieldInDoc())
461 ShowUIElement("private:resource/toolbar/mailmerge");
463 // Activate the toolbar to the new selection which also was active last time.
464 // Before a flush () must be, but does not affect the UI according to MBA and
465 // is not a performance problem.
466 // TODO/LATER: maybe now the Flush() command is superfluous?!
469 Point aPnt
= GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
470 aPnt
= GetEditWin().PixelToLogic(aPnt
);
471 GetEditWin().UpdatePointer(aPnt
);
473 SdrView
* pDView
= GetWrtShell().GetDrawView();
474 if ( bInitFormShell
&& pDView
)
475 m_pFormShell
->SetView(dynamic_cast<FmFormView
*>( pDView
) );
478 // Opportune time for the communication with OLE objects?
479 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
480 GetDocShell()->GetDoc()->PrtOLENotify( false );
482 // now the table-update
484 m_pWrtShell
->UpdateTable();
486 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
488 m_bInitOnceCompleted
= true;
491 // Interaction: AttrChangedNotify() and TimeoutHdl.
492 // No Update if actions are still open, since the cursor on the core side
493 // can be somewhere in no man's land.
494 // But since we can no longer supply status and we want instead lock
499 static int lcl_CmpIds( const void *pFirst
, const void *pSecond
)
501 return *static_cast<sal_uInt16
const *>(pFirst
) - *static_cast<sal_uInt16
const *>(pSecond
);
505 IMPL_LINK_NOARG(SwView
, AttrChangedNotify
, SwCursorShell
*, void)
507 if ( GetEditWin().IsChainMode() )
508 GetEditWin().SetChainMode( false );
510 //Opt: Not if PaintLocked. During unlock a notify will be once more triggered.
511 if( !m_pWrtShell
->IsPaintLocked() && !g_bNoInterrupt
&&
512 GetDocShell()->IsReadOnly() )
513 CheckReadonlyState();
515 if( !m_pWrtShell
->IsPaintLocked() && !g_bNoInterrupt
)
516 CheckReadonlySelection();
518 if( !m_bAttrChgNotified
)
520 if (m_pWrtShell
->ActionPend() || g_bNoInterrupt
||
521 GetDispatcher().IsLocked() || //do not confuse the SFX
522 GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
524 m_bAttrChgNotified
= true;
527 const SfxPoolItem
*pItem
;
528 if ( SfxItemState::SET
!= GetObjectShell()->GetMedium()->GetItemSet()->
529 GetItemState( SID_HIDDEN
, false, &pItem
) ||
530 !static_cast<const SfxBoolItem
*>(pItem
)->GetValue() )
532 GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
533 m_bAttrChgNotifiedWithRegistrations
= true;
542 // change ui if cursor is at a SwPostItField
545 // only perform the code that is needed to determine, if at the
546 // actual cursor position is a post-it field
547 m_pPostItMgr
->SetShadowState( m_pWrtShell
->GetPostItFieldAtCursor() );
551 IMPL_LINK_NOARG(SwView
, TimeoutHdl
, Timer
*, void)
553 if (m_pWrtShell
->ActionPend() || g_bNoInterrupt
)
559 if ( m_bAttrChgNotifiedWithRegistrations
)
561 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
562 m_bAttrChgNotifiedWithRegistrations
= false;
565 CheckReadonlyState();
566 CheckReadonlySelection();
568 bool bOldUndo
= m_pWrtShell
->DoesUndo();
569 m_pWrtShell
->DoUndo( false );
571 m_pWrtShell
->DoUndo( bOldUndo
);
572 m_bAttrChgNotified
= false;
573 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
576 void SwView::CheckReadonlyState()
578 SfxDispatcher
&rDis
= GetDispatcher();
579 // To be able to recognize if it is already disabled!
580 SfxItemState eStateRO
, eStateProtAll
;
581 const SfxPoolItem
*pItem
;
582 // Query the status from a slot which is only known to us.
583 // Otherwise the slot is known from other; like the BasicIde
584 eStateRO
= rDis
.QueryState( FN_INSERT_BOOKMARK
, pItem
);
585 eStateProtAll
= rDis
.QueryState( FN_EDIT_REGION
, pItem
);
588 if ( !m_pWrtShell
->IsCursorReadonly() )
590 static sal_uInt16 aROIds
[] =
592 SID_DELETE
, FN_BACKSPACE
, FN_SHIFT_BACKSPACE
,
594 SID_REDO
, SID_REPEAT
, SID_PASTE
,
595 SID_PASTE_UNFORMATTED
,
596 SID_PASTE_SPECIAL
, SID_SBA_BRW_INSERT
,
597 SID_BACKGROUND_COLOR
, FN_INSERT_BOOKMARK
, SID_CHARMAP_CONTROL
,
598 SID_CHARMAP
, SID_EMOJI_CONTROL
, FN_INSERT_SOFT_HYPHEN
,
599 FN_INSERT_HARDHYPHEN
, FN_INSERT_HARD_SPACE
, FN_INSERT_NNBSP
,
600 FN_INSERT_BREAK
, FN_INSERT_LINEBREAK
, FN_INSERT_COLUMN_BREAK
,
602 FN_DELETE_SENT
, FN_DELETE_BACK_SENT
, FN_DELETE_WORD
,
603 FN_DELETE_BACK_WORD
, FN_DELETE_LINE
, FN_DELETE_BACK_LINE
,
604 FN_DELETE_PARA
, FN_DELETE_BACK_PARA
, FN_DELETE_WHOLE_LINE
,
605 FN_CALCULATE
, FN_FORMAT_RESET
,
606 FN_POSTIT
, FN_JAVAEDIT
, SID_ATTR_PARA_ADJUST_LEFT
,
607 SID_ATTR_PARA_ADJUST_RIGHT
, SID_ATTR_PARA_ADJUST_CENTER
,SID_ATTR_PARA_ADJUST_BLOCK
,
608 SID_ATTR_PARA_LINESPACE_10
, SID_ATTR_PARA_LINESPACE_15
, SID_ATTR_PARA_LINESPACE_20
,
609 SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONTHEIGHT
, SID_ATTR_CHAR_COLOR_BACKGROUND
,
610 SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
, SID_ATTR_CHAR_COLOR_EXT
,
611 SID_ATTR_CHAR_COLOR
, SID_ATTR_CHAR_WEIGHT
, SID_ATTR_CHAR_POSTURE
,
612 SID_ATTR_CHAR_OVERLINE
,
613 SID_ATTR_CHAR_UNDERLINE
, SID_ATTR_FLASH
, SID_ATTR_CHAR_STRIKEOUT
,
614 FN_UNDERLINE_DOUBLE
, SID_ATTR_CHAR_CONTOUR
, SID_ATTR_CHAR_SHADOWED
,
615 SID_ATTR_CHAR_AUTOKERN
, SID_ATTR_CHAR_ESCAPEMENT
, FN_SET_SUPER_SCRIPT
,
616 FN_SET_SUB_SCRIPT
, SID_ATTR_CHAR_CASEMAP
, SID_ATTR_CHAR_LANGUAGE
,
617 SID_ATTR_CHAR_KERNING
, SID_CHAR_DLG
, SID_ATTR_CHAR_WORDLINEMODE
,
618 FN_GROW_FONT_SIZE
, FN_SHRINK_FONT_SIZE
, FN_TXTATR_INET
,
619 FN_FORMAT_DROPCAPS
, SID_ATTR_PARA_ADJUST
, SID_ATTR_PARA_LINESPACE
,
620 SID_ATTR_PARA_SPLIT
, SID_ATTR_PARA_KEEP
, SID_ATTR_PARA_WIDOWS
,
621 SID_ATTR_PARA_ORPHANS
,
622 SID_ATTR_PARA_MODEL
, SID_PARA_DLG
,
623 FN_SELECT_PARA
, SID_DEC_INDENT
,
626 static bool bFirst
= true;
629 qsort( static_cast<void*>(aROIds
), SAL_N_ELEMENTS(aROIds
), sizeof(sal_uInt16
), lcl_CmpIds
);
632 if ( SfxItemState::DISABLED
== eStateRO
)
634 rDis
.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY
, aROIds
);
638 else if( m_pWrtShell
->IsAllProtect() )
640 if ( SfxItemState::DISABLED
== eStateProtAll
)
642 static sal_uInt16 aAllProtIds
[] = { SID_SAVEDOC
, FN_EDIT_REGION
};
643 static bool bAllProtFirst
= true;
646 qsort( static_cast<void*>(aAllProtIds
), SAL_N_ELEMENTS(aAllProtIds
), sizeof(sal_uInt16
), lcl_CmpIds
);
647 bAllProtFirst
= false;
649 rDis
.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY
, aAllProtIds
);
653 else if ( SfxItemState::DISABLED
!= eStateRO
||
654 SfxItemState::DISABLED
!= eStateProtAll
)
657 rDis
.SetSlotFilter();
660 GetViewFrame()->GetBindings().InvalidateAll(true);
663 void SwView::CheckReadonlySelection()
665 SfxDisableFlags nDisableFlags
= SfxDisableFlags::NONE
;
666 SfxDispatcher
&rDis
= GetDispatcher();
668 if( m_pWrtShell
->HasReadonlySel() &&
669 ( !m_pWrtShell
->GetDrawView() ||
670 !m_pWrtShell
->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
671 nDisableFlags
|= SfxDisableFlags::SwOnProtectedCursor
;
673 if( (SfxDisableFlags::SwOnProtectedCursor
& nDisableFlags
) !=
674 (SfxDisableFlags::SwOnProtectedCursor
& rDis
.GetDisableFlags() ) )
676 // Additionally move at the Window the InputContext, so that
677 // in japanese / chinese versions the external input will be
678 // turned on or off. This but only if the correct shell is on
680 switch( m_pViewImpl
->GetShellMode() )
682 case ShellMode::Text
:
683 case ShellMode::ListText
:
684 case ShellMode::TableText
:
685 case ShellMode::TableListText
:
687 // Temporary solution!!! Should set the font of the current insertion point
688 // at each cursor movement, so outside of this "if". But TH does not
689 // evaluates the font at this time and the "purchase" appears to me
691 // Moreover, we don't have a font, but only attributes from which the
692 // text formatting and the correct font will be build together.
694 InputContext
aCntxt( GetEditWin().GetInputContext() );
695 aCntxt
.SetOptions( SfxDisableFlags::SwOnProtectedCursor
& nDisableFlags
696 ? (aCntxt
.GetOptions() & ~
697 InputContextFlags( InputContextFlags::Text
|
698 InputContextFlags::ExtText
))
699 : (aCntxt
.GetOptions() |
700 ( InputContextFlags::Text
|
701 InputContextFlags::ExtText
)) );
702 GetEditWin().SetInputContext( aCntxt
);
711 if( nDisableFlags
!= rDis
.GetDisableFlags() )
713 rDis
.SetDisableFlags( nDisableFlags
);
714 GetViewFrame()->GetBindings().InvalidateAll( true );
718 SwView::SwView( SfxViewFrame
*_pFrame
, SfxViewShell
* pOldSh
)
719 : SfxViewShell( _pFrame
, SWVIEWFLAGS
),
720 m_nNewPage(USHRT_MAX
),
722 m_pNumRuleNodeFromDoc(nullptr),
723 m_pEditWin( VclPtr
<SwEditWin
>::Create( &_pFrame
->GetWindow(), *this ) ),
725 m_pFormShell(nullptr),
726 m_pHScrollbar(nullptr),
727 m_pVScrollbar(nullptr),
728 m_pScrollFill(VclPtr
<ScrollBarBox
>::Create( &_pFrame
->GetWindow(), WB_SIZEABLE
)),
729 m_pVRuler(VclPtr
<SvxRuler
>::Create(&GetViewFrame()->GetWindow(), m_pEditWin
,
730 SvxRulerSupportFlags::TABS
| SvxRulerSupportFlags::PARAGRAPH_MARGINS_VERTICAL
|
731 SvxRulerSupportFlags::BORDERS
| SvxRulerSupportFlags::REDUCED_METRIC
,
732 GetViewFrame()->GetBindings(),
733 WB_VSCROLL
| WB_EXTRAFIELD
| WB_BORDER
)),
734 m_pLastTableFormat(nullptr),
735 m_pFormatClipboard(new SwFormatClipboard()),
736 m_nSelectionType( SelectionType::All
),
738 m_nDrawSfxId( USHRT_MAX
),
739 m_nFormSfxId( USHRT_MAX
),
740 m_nLastPasteDestination( static_cast<SotExchangeDest
>(0xFFFF) ),
741 m_nLeftBorderDistance( 0 ),
742 m_nRightBorderDistance( 0 ),
743 m_eLastSearchCommand( static_cast<SvxSearchCmd
>(0xFFFF) ),
744 m_bWheelScrollInProgress(false),
745 m_bInMailMerge(false),
747 m_bOldShellWasPagePreview(false),
748 m_bIsPreviewDoubleClick(false),
749 m_nLOKPageUpDownOffset(0)
751 static bool bRequestDoubleBuffering
= getenv("VCL_DOUBLEBUFFERING_ENABLE");
752 if (bRequestDoubleBuffering
)
753 m_pEditWin
->RequestDoubleBuffering(true);
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>.
762 m_bCenterCursor
= m_bTopCursor
= m_bTabColFromDoc
= m_bTabRowFromDoc
=
763 m_bSetTabColFromDoc
= m_bSetTabRowFromDoc
= m_bAttrChgNotified
= m_bAttrChgNotifiedWithRegistrations
=
764 m_bVerbsActive
= m_bDrawRotate
= m_bInOuterResizePixel
= m_bInInnerResizePixel
=
765 m_bPasteState
= m_bPasteSpecialState
= m_bMakeSelectionVisible
= false;
767 m_bShowAtResize
= m_bDrawSelMode
= bDocSzUpdated
= true;
769 CreateScrollbar( true );
770 CreateScrollbar( false );
772 m_pViewImpl
.reset(new SwView_Impl(this));
774 SetWindow( m_pEditWin
);
776 m_aTimer
.SetTimeout( 120 );
778 SwDocShell
& rDocSh
= dynamic_cast<SwDocShell
&>(*_pFrame
->GetObjectShell());
779 bool bOldModifyFlag
= rDocSh
.IsEnableSetModified();
781 rDocSh
.EnableSetModified( false );
782 // HACK: SwDocShell has some cached font info, VCL informs about font updates,
783 // but loading of docs with embedded fonts happens after SwDocShell is created
784 // but before SwEditWin (which handles the VCL event) is created. So update
786 if (rDocSh
.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::EMBED_FONTS
))
787 rDocSh
.UpdateFontList();
788 bool bWebDShell
= dynamic_cast<const SwWebDocShell
*>(&rDocSh
) != nullptr;
790 const SwMasterUsrPref
*pUsrPref
= SW_MOD()->GetUsrPref(bWebDShell
);
791 SwViewOption
aUsrPref( *pUsrPref
);
793 //! get lingu options without loading lingu DLL
794 SvtLinguOptions aLinguOpt
;
795 SvtLinguConfig().GetOptions( aLinguOpt
);
796 aUsrPref
.SetOnlineSpell( aLinguOpt
.bIsSpellAuto
);
798 bool bOldShellWasSrcView
= false;
800 // determine if there is an existing view for
802 SfxViewShell
* pExistingSh
= nullptr;
805 pExistingSh
= pOldSh
;
806 // determine type of existing view
807 if (SwPagePreview
* pPagePreview
= dynamic_cast<SwPagePreview
*>(pExistingSh
))
809 m_sSwViewData
= pPagePreview
->GetPrevSwViewData();
810 m_sNewCursorPos
= pPagePreview
->GetNewCursorPos();
811 m_nNewPage
= pPagePreview
->GetNewPage();
812 m_bOldShellWasPagePreview
= true;
813 m_bIsPreviewDoubleClick
= !m_sNewCursorPos
.isEmpty() || m_nNewPage
!= USHRT_MAX
;
815 else if (dynamic_cast<const SwSrcView
*>(pExistingSh
) != nullptr)
816 bOldShellWasSrcView
= true;
819 SAL_INFO( "sw.ui", "before create WrtShell" );
820 if (SwView
*pView
= dynamic_cast<SwView
*>(pExistingSh
))
822 m_pWrtShell
.reset(new SwWrtShell(*pView
->m_pWrtShell
, m_pEditWin
, *this));
824 else if (SwWrtShell
*pWrtShell
= dynamic_cast<SwWrtShell
*>(rDocSh
.GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell()))
826 m_pWrtShell
.reset(new SwWrtShell(*pWrtShell
, m_pEditWin
, *this));
830 SwDoc
& rDoc
= *rDocSh
.GetDoc();
832 if( !bOldShellWasSrcView
&& bWebDShell
&& !m_bOldShellWasPagePreview
)
833 aUsrPref
.setBrowseMode( true );
835 aUsrPref
.setBrowseMode( rDoc
.getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE
) );
837 //For the BrowseMode we do not assume a factor.
838 if( aUsrPref
.getBrowseMode() && aUsrPref
.GetZoomType() != SvxZoomType::PERCENT
)
840 aUsrPref
.SetZoomType( SvxZoomType::PERCENT
);
841 aUsrPref
.SetZoom( 100 );
843 if (rDocSh
.IsPreview())
845 aUsrPref
.SetZoomType( SvxZoomType::WHOLEPAGE
);
846 aUsrPref
.SetViewLayoutBookMode( false );
847 aUsrPref
.SetViewLayoutColumns( 1 );
849 m_pWrtShell
.reset(new SwWrtShell(rDoc
, m_pEditWin
, *this, &aUsrPref
));
850 // creating an SwView from a SwPagePreview needs to
851 // add the SwViewShell to the ring of the other SwViewShell(s)
852 if(m_bOldShellWasPagePreview
)
854 SwViewShell
& rPreviewViewShell
= *static_cast<SwPagePreview
*>(pExistingSh
)->GetViewShell();
855 m_pWrtShell
->MoveTo(&rPreviewViewShell
);
856 // to update the field command et.al. if necessary
857 const SwViewOption
* pPreviewOpt
= rPreviewViewShell
.GetViewOptions();
858 if( pPreviewOpt
->IsFieldName() != aUsrPref
.IsFieldName() ||
859 pPreviewOpt
->IsShowHiddenField() != aUsrPref
.IsShowHiddenField() ||
860 pPreviewOpt
->IsShowHiddenPara() != aUsrPref
.IsShowHiddenPara() ||
861 pPreviewOpt
->IsShowHiddenChar() != aUsrPref
.IsShowHiddenChar() )
862 rPreviewViewShell
.ApplyViewOptions(aUsrPref
);
863 // reset design mode at draw view for form
865 if ( static_cast<SwPagePreview
*>(pExistingSh
)->ResetFormDesignMode() &&
866 m_pWrtShell
->HasDrawView() )
868 SdrView
* pDrawView
= m_pWrtShell
->GetDrawView();
869 pDrawView
->SetDesignMode( static_cast<SwPagePreview
*>(pExistingSh
)->FormDesignModeToReset() );
873 SAL_INFO( "sw.ui", "after create WrtShell" );
874 m_pHRuler
= VclPtr
<SwCommentRuler
>::Create(m_pWrtShell
.get(), &GetViewFrame()->GetWindow(), m_pEditWin
,
875 SvxRulerSupportFlags::TABS
|
876 SvxRulerSupportFlags::PARAGRAPH_MARGINS
|
877 SvxRulerSupportFlags::BORDERS
|
878 SvxRulerSupportFlags::NEGATIVE_MARGINS
|
879 SvxRulerSupportFlags::REDUCED_METRIC
,
880 GetViewFrame()->GetBindings(),
881 WB_STDRULER
| WB_EXTRAFIELD
| WB_BORDER
);
883 // assure that modified state of document
884 // isn't reset, if document is already modified.
885 const bool bIsDocModified
= m_pWrtShell
->GetDoc()->getIDocumentState().IsModified();
887 // Thus among other things, the HRuler is not displayed in the read-only case.
888 aUsrPref
.SetReadonly( m_pWrtShell
->GetViewOptions()->IsReadonly() );
890 // no margin for OLE!
892 if( SfxObjectCreateMode::EMBEDDED
!= rDocSh
.GetCreateMode() )
893 aBrwsBorder
= GetMargin();
895 m_pWrtShell
->SetBrowseBorder( aBrwsBorder
);
897 // In CTOR no shell changes may take place, which must be temporarily stored
898 // with the timer. Otherwise, the SFX removes them from the stack!
899 bool bOld
= g_bNoInterrupt
;
900 g_bNoInterrupt
= true;
902 m_pHRuler
->SetActive();
903 m_pVRuler
->SetActive();
905 SfxViewFrame
* pViewFrame
= GetViewFrame();
907 StartListening(*pViewFrame
, DuplicateHandling::Prevent
);
908 StartListening(rDocSh
, DuplicateHandling::Prevent
);
910 // Set Zoom-factor from HRuler
911 Fraction
aZoomFract( aUsrPref
.GetZoom(), 100 );
912 m_pHRuler
->SetZoom( aZoomFract
);
913 m_pVRuler
->SetZoom( aZoomFract
);
914 m_pHRuler
->SetDoubleClickHdl(LINK( this, SwView
, ExecRulerClick
));
915 FieldUnit eMetric
= pUsrPref
->GetHScrollMetric();
916 m_pHRuler
->SetUnit( eMetric
);
918 eMetric
= pUsrPref
->GetVScrollMetric();
919 m_pVRuler
->SetUnit( eMetric
);
921 m_pHRuler
->SetCharWidth( 371 ); // default character width
922 m_pVRuler
->SetLineHeight( 551 ); // default line height
925 m_xGlueDocShell
.reset(new SwViewGlueDocShell(*this, rDocSh
));
926 m_pPostItMgr
.reset(new SwPostItMgr(this));
928 // Check and process the DocSize. Via the handler, the shell could not
929 // be found, because the shell is not known in the SFX management
930 // within the CTOR phase.
931 DocSzChgd( m_pWrtShell
->GetDocSize() );
933 // Set AttrChangedNotify link
934 m_pWrtShell
->SetChgLnk(LINK(this, SwView
, AttrChangedNotify
));
936 if (rDocSh
.GetCreateMode() == SfxObjectCreateMode::EMBEDDED
&&
937 !rDocSh
.GetVisArea(ASPECT_CONTENT
).IsEmpty())
938 SetVisArea(rDocSh
.GetVisArea(ASPECT_CONTENT
),false);
941 officecfg::Office::Common::Undo::Steps::get() <= 0,
942 "sw.ui", "/org.openoffice.Office.Common/Undo/Steps <= 0");
943 if (!utl::ConfigManager::IsFuzzing() && 0 < officecfg::Office::Common::Undo::Steps::get())
945 m_pWrtShell
->DoUndo();
948 const bool bBrowse
= m_pWrtShell
->GetViewOptions()->getBrowseMode();
949 // Disable "multiple window"
950 SetNewWindowAllowed(!bBrowse
);
951 // End of disabled multiple window
953 m_bVScrollbarEnabled
= aUsrPref
.IsViewVScrollBar();
954 m_bHScrollbarEnabled
= aUsrPref
.IsViewHScrollBar();
955 m_pHScrollbar
->SetAuto(bBrowse
);
956 if( aUsrPref
.IsViewHRuler() )
958 if( aUsrPref
.IsViewVRuler() )
961 m_pWrtShell
->SetUIOptions( aUsrPref
);
962 m_pWrtShell
->SetReadOnlyAvailable( aUsrPref
.IsCursorInProtectedArea() );
963 m_pWrtShell
->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
965 if( m_pWrtShell
->GetDoc()->getIDocumentState().IsUpdateExpField() )
967 if (m_pWrtShell
->GetDoc()->GetDocumentFieldsManager().containsUpdatableFields())
969 SET_CURR_SHELL(m_pWrtShell
.get());
970 m_pWrtShell
->StartAction();
971 m_pWrtShell
->CalcLayout();
972 m_pWrtShell
->GetDoc()->getIDocumentFieldsAccess().UpdateFields(false);
973 m_pWrtShell
->EndAction();
975 m_pWrtShell
->GetDoc()->getIDocumentState().SetUpdateExpFieldStat( false );
978 // Update all tables if necessary:
979 if( m_pWrtShell
->GetDoc()->IsUpdateTOX() )
981 SfxRequest
aSfxRequest( FN_UPDATE_TOX
, SfxCallMode::SLOT
, GetPool() );
982 Execute( aSfxRequest
);
983 m_pWrtShell
->GetDoc()->SetUpdateTOX( false ); // reset again
984 m_pWrtShell
->SttEndDoc(true);
987 // No ResetModified, if there is already a view to this doc.
988 SfxViewFrame
* pVFrame
= GetViewFrame();
989 SfxViewFrame
* pFirst
= SfxViewFrame::GetFirst(&rDocSh
);
990 // Currently(360) the view is registered firstly after the CTOR,
991 // the following expression is also working if this changes.
992 // If the modification cannot be canceled by undo, then do NOT set
994 // no reset of modified state, if document
995 // was already modified.
996 if (!m_pWrtShell
->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
997 ( !pFirst
|| pFirst
== pVFrame
) &&
1000 m_pWrtShell
->ResetModified();
1003 g_bNoInterrupt
= bOld
;
1005 // If a new GlobalDoc will be created, the navigator will also be generated.
1006 if( dynamic_cast<const SwGlobalDocShell
*>(&rDocSh
) != nullptr &&
1007 !pVFrame
->GetChildWindow( SID_NAVIGATOR
))
1009 SfxBoolItem
aNavi(SID_NAVIGATOR
, true);
1010 GetDispatcher().ExecuteList(SID_NAVIGATOR
, SfxCallMode::ASYNCHRON
, { &aNavi
});
1013 uno::Reference
< frame::XFrame
> xFrame
= pVFrame
->GetFrame().GetFrameInterface();
1015 uno::Reference
< frame::XFrame
> xBeamerFrame
= xFrame
->findFrame(
1016 "_beamer", frame::FrameSearchFlag::CHILDREN
);
1017 if(xBeamerFrame
.is())
1019 SwDBData aData
= m_pWrtShell
->GetDBData();
1020 SwModule::ShowDBObj( *this, aData
);
1023 // has anybody calls the attrchanged handler in the constructor?
1024 if( m_bAttrChgNotifiedWithRegistrations
)
1026 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1027 if( m_aTimer
.IsActive() )
1031 m_aTimer
.SetInvokeHandler(LINK(this, SwView
, TimeoutHdl
));
1032 m_aTimer
.SetDebugName( "sw::SwView m_aTimer" );
1033 m_bAttrChgNotified
= m_bAttrChgNotifiedWithRegistrations
= false;
1035 rDocSh
.EnableSetModified();
1038 if( !m_pHScrollbar
->IsVisible( true ) )
1039 ShowHScrollbar( false );
1040 if( !m_pVScrollbar
->IsVisible( true ) )
1041 ShowVScrollbar( false );
1043 GetViewFrame()->GetWindow().AddChildEventListener( LINK( this, SwView
, WindowChildEventListener
) );
1046 SwViewGlueDocShell::SwViewGlueDocShell(SwView
& rView
, SwDocShell
& rDocSh
)
1050 rDocSh
.SetView(&m_rView
);
1051 SW_MOD()->SetView(&m_rView
);
1054 SwViewGlueDocShell::~SwViewGlueDocShell()
1056 SwDocShell
* pDocSh
= m_rView
.GetDocShell();
1057 if (pDocSh
&& pDocSh
->GetView() == &m_rView
)
1058 pDocSh
->SetView(nullptr);
1059 if (SW_MOD()->GetView() == &m_rView
)
1060 SW_MOD()->SetView(nullptr);
1065 // Notify other LOK views that we are going away.
1066 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_VIEW_CURSOR_VISIBLE
, "visible", "false");
1067 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_TEXT_VIEW_SELECTION
, "selection", "");
1068 SfxLokHelper::notifyOtherViews(this, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION
, "selection", "EMPTY");
1070 // Need to remove activated field's button before disposing EditWin.
1071 GetWrtShell().getIDocumentMarkAccess()->ClearFieldActivation();
1073 GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView
, WindowChildEventListener
) );
1074 m_pPostItMgr
.reset();
1077 m_pEditWin
->Hide(); // prevent problems with painting
1079 // Set pointer in SwDocShell to the view again
1080 m_xGlueDocShell
.reset();
1082 if( m_aTimer
.IsActive() && m_bAttrChgNotifiedWithRegistrations
)
1083 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1085 // the last view must end the text edit
1086 SdrView
*pSdrView
= m_pWrtShell
? m_pWrtShell
->GetDrawView() : nullptr;
1087 if( pSdrView
&& pSdrView
->IsTextEdit() )
1088 pSdrView
->SdrEndTextEdit( true );
1090 SetWindow( nullptr );
1092 m_pViewImpl
->Invalidate();
1093 EndListening(*GetViewFrame());
1094 EndListening(*GetDocShell());
1095 m_pScrollFill
.disposeAndClear();
1096 m_pWrtShell
.reset(); // reset here so that it is not accessible by the following dtors.
1097 m_pHScrollbar
.disposeAndClear();
1098 m_pVScrollbar
.disposeAndClear();
1099 m_pHRuler
.disposeAndClear();
1100 m_pVRuler
.disposeAndClear();
1102 m_pViewImpl
.reset();
1104 // If this was enabled in the ctor for the frame, then disable it here.
1105 static bool bRequestDoubleBuffering
= getenv("VCL_DOUBLEBUFFERING_ENABLE");
1106 if (bRequestDoubleBuffering
)
1107 m_pEditWin
->RequestDoubleBuffering(false);
1108 m_pEditWin
.disposeAndClear();
1110 m_pFormatClipboard
.reset();
1113 SwDocShell
* SwView::GetDocShell()
1115 SfxObjectShell
* pDocShell
= GetViewFrame()->GetObjectShell();
1116 return dynamic_cast<SwDocShell
*>( pDocShell
);
1119 // Remember CursorPos
1121 void SwView::WriteUserData( OUString
&rUserData
, bool bBrowse
)
1123 // The browse flag will be passed from Sfx when documents are browsed
1124 // (not to be confused with the BrowseMode).
1125 // Then that stored data are not persistent!
1127 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1128 const tools::Rectangle
& rVis
= GetVisArea();
1130 rUserData
= OUString::number( rRect
.Left() );
1132 rUserData
+= OUString::number( rRect
.Top() );
1134 rUserData
+= OUString::number( m_pWrtShell
->GetViewOptions()->GetZoom() );
1136 rUserData
+= OUString::number( rVis
.Left() );
1138 rUserData
+= OUString::number( rVis
.Top() );
1140 rUserData
+= OUString::number( bBrowse
? SAL_MIN_INT32
: rVis
.Right());
1142 rUserData
+= OUString::number( bBrowse
? SAL_MIN_INT32
: rVis
.Bottom());
1144 rUserData
+= OUString::number(
1145 static_cast<sal_uInt16
>(m_pWrtShell
->GetViewOptions()->GetZoomType()));//eZoom;
1147 rUserData
+= FrameTypeFlags::NONE
== m_pWrtShell
->GetSelFrameType() ? OUString("0") : OUString("1");
1152 static bool lcl_IsOwnDocument( SwView
& rView
)
1154 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
1155 rView
.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW
);
1156 uno::Reference
<document::XDocumentProperties
> xDocProps
1157 = xDPS
->getDocumentProperties();
1158 OUString Created
= xDocProps
->getAuthor();
1159 OUString Changed
= xDocProps
->getModifiedBy();
1160 OUString FullName
= SW_MOD()->GetUserOptions().GetFullName();
1161 return (!FullName
.isEmpty() &&
1162 (!Changed
.isEmpty() && Changed
== FullName
)) ||
1163 (Changed
.isEmpty() && !Created
.isEmpty() && Created
== FullName
);
1166 void SwView::ReadUserData( const OUString
&rUserData
, bool bBrowse
)
1168 if ( rUserData
.indexOf(';')>=0 && // more than one token
1169 // For document without layout only in the onlinelayout or
1170 // while forward/backward
1171 (!m_pWrtShell
->IsNewLayout() || m_pWrtShell
->GetViewOptions()->getBrowseMode() || bBrowse
) )
1173 bool bIsOwnDocument
= lcl_IsOwnDocument( *this );
1175 SET_CURR_SHELL(m_pWrtShell
.get());
1179 // No it is *not* a good idea to call GetToken within Point constr. immediately,
1180 // because which parameter is evaluated first?
1181 long nX
= rUserData
.getToken( 0, ';', nPos
).toInt32(),
1182 nY
= rUserData
.getToken( 0, ';', nPos
).toInt32();
1183 Point
aCursorPos( nX
, nY
);
1185 sal_uInt16 nZoomFactor
=
1186 static_cast< sal_uInt16
>( rUserData
.getToken(0, ';', nPos
).toInt32() );
1188 long nLeft
= rUserData
.getToken(0, ';', nPos
).toInt32(),
1189 nTop
= rUserData
.getToken(0, ';', nPos
).toInt32(),
1190 nRight
= rUserData
.getToken(0, ';', nPos
).toInt32(),
1191 nBottom
= rUserData
.getToken(0, ';', nPos
).toInt32();
1193 const long nAdd
= m_pWrtShell
->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER
: DOCUMENTBORDER
*2;
1194 if ( nBottom
<= (m_pWrtShell
->GetDocSize().Height()+nAdd
) )
1196 m_pWrtShell
->EnableSmooth( false );
1198 const tools::Rectangle
aVis( nLeft
, nTop
, nRight
, nBottom
);
1202 if( !m_pWrtShell
->GetViewOptions()->getBrowseMode() )
1203 eZoom
= static_cast<SvxZoomType
>(static_cast<sal_uInt16
>(rUserData
.getToken(nOff
, ';', nPos
).toInt32()));
1206 eZoom
= SvxZoomType::PERCENT
;
1210 bool bSelectObj
= (0 != rUserData
.getToken( nOff
, ';', nPos
).toInt32())
1211 && m_pWrtShell
->IsObjSelectable( aCursorPos
);
1213 // restore editing position
1214 m_pViewImpl
->SetRestorePosition(aCursorPos
, bSelectObj
);
1215 // set flag value to avoid macro execution.
1216 bool bSavedFlagValue
= m_pWrtShell
->IsMacroExecAllowed();
1217 m_pWrtShell
->SetMacroExecAllowed( false );
1218 // os: changed: The user data has to be read if the view is switched back from page preview
1219 // go to the last editing position when opening own files
1220 if(m_bOldShellWasPagePreview
|| bIsOwnDocument
)
1222 m_pWrtShell
->SwCursorShell::SetCursor( aCursorPos
, !bSelectObj
);
1225 m_pWrtShell
->SelectObj( aCursorPos
);
1226 m_pWrtShell
->EnterSelFrameMode( &aCursorPos
);
1231 m_pWrtShell
->SetMacroExecAllowed( bSavedFlagValue
);
1233 // set visible area before applying
1234 // information from print preview. Otherwise, the applied information
1236 // os: changed: The user data has to be read if the view is switched back from page preview
1237 // go to the last editing position when opening own files
1238 if(m_bOldShellWasPagePreview
|| bIsOwnDocument
)
1241 SetVisArea( aVis
.TopLeft() );
1246 //apply information from print preview - if available
1247 if( !m_sNewCursorPos
.isEmpty() )
1249 sal_Int32 nIdx
{ 0 };
1250 const long nXTmp
= m_sNewCursorPos
.getToken( 0, ';', nIdx
).toInt32();
1251 const long nYTmp
= m_sNewCursorPos
.getToken( 0, ';', nIdx
).toInt32();
1252 Point
aCursorPos2( nXTmp
, nYTmp
);
1253 bSelectObj
= m_pWrtShell
->IsObjSelectable( aCursorPos2
);
1255 m_pWrtShell
->SwCursorShell::SetCursor( aCursorPos2
);
1258 m_pWrtShell
->SelectObj( aCursorPos2
);
1259 m_pWrtShell
->EnterSelFrameMode( &aCursorPos2
);
1261 m_pWrtShell
->MakeSelVisible();
1262 m_sNewCursorPos
.clear();
1264 else if(USHRT_MAX
!= m_nNewPage
)
1266 m_pWrtShell
->GotoPage(m_nNewPage
, true);
1267 m_nNewPage
= USHRT_MAX
;
1272 m_pWrtShell
->StartAction();
1273 const SwViewOption
* pVOpt
= m_pWrtShell
->GetViewOptions();
1274 if( pVOpt
->GetZoom() != nZoomFactor
|| pVOpt
->GetZoomType() != eZoom
)
1275 SetZoom( eZoom
, nZoomFactor
);
1277 m_pWrtShell
->LockView( true );
1278 m_pWrtShell
->EndAction();
1279 m_pWrtShell
->LockView( false );
1280 m_pWrtShell
->EnableSmooth( true );
1285 void SwView::ReadUserDataSequence ( const uno::Sequence
< beans::PropertyValue
>& rSequence
)
1287 if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick
)
1289 bool bIsOwnDocument
= lcl_IsOwnDocument( *this );
1290 sal_Int32 nLength
= rSequence
.getLength();
1294 SET_CURR_SHELL(m_pWrtShell
.get());
1295 const beans::PropertyValue
*pValue
= rSequence
.getConstArray();
1296 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1297 const tools::Rectangle
&rVis
= GetVisArea();
1298 const SwViewOption
* pVOpt
= m_pWrtShell
->GetViewOptions();
1300 sal_Int64 nX
= rRect
.Left(), nY
= rRect
.Top(), nLeft
= rVis
.Left(), nTop
= rVis
.Top();
1301 sal_Int64 nRight
= LONG_MIN
;
1302 sal_Int64 nBottom
= LONG_MIN
;
1303 sal_Int16 nZoomType
= static_cast< sal_Int16
>(pVOpt
->GetZoomType());
1304 sal_Int16 nZoomFactor
= static_cast < sal_Int16
> (pVOpt
->GetZoom());
1305 bool bViewLayoutBookMode
= pVOpt
->IsViewLayoutBookMode();
1306 sal_Int16 nViewLayoutColumns
= pVOpt
->GetViewLayoutColumns();
1308 bool bSelectedFrame
= ( m_pWrtShell
->GetSelFrameType() != FrameTypeFlags::NONE
),
1309 bGotVisibleLeft
= false,
1310 bGotVisibleTop
= false, bGotVisibleRight
= false,
1311 bGotVisibleBottom
= false, bGotZoomType
= false,
1312 bGotZoomFactor
= false, bGotIsSelectedFrame
= false,
1313 bGotViewLayoutColumns
= false, bGotViewLayoutBookMode
= false,
1314 bBrowseMode
= false, bGotBrowseMode
= false;
1316 for (sal_Int32 i
= 0 ; i
< nLength
; i
++)
1318 if ( pValue
->Name
== "ViewLeft" )
1320 pValue
->Value
>>= nX
;
1321 nX
= convertMm100ToTwip( nX
);
1323 else if ( pValue
->Name
== "ViewTop" )
1325 pValue
->Value
>>= nY
;
1326 nY
= convertMm100ToTwip( nY
);
1328 else if ( pValue
->Name
== "VisibleLeft" )
1330 pValue
->Value
>>= nLeft
;
1331 nLeft
= convertMm100ToTwip( nLeft
);
1332 bGotVisibleLeft
= true;
1334 else if ( pValue
->Name
== "VisibleTop" )
1336 pValue
->Value
>>= nTop
;
1337 nTop
= convertMm100ToTwip( nTop
);
1338 bGotVisibleTop
= true;
1340 else if ( pValue
->Name
== "VisibleRight" )
1342 pValue
->Value
>>= nRight
;
1343 nRight
= convertMm100ToTwip( nRight
);
1344 bGotVisibleRight
= true;
1346 else if ( pValue
->Name
== "VisibleBottom" )
1348 pValue
->Value
>>= nBottom
;
1349 nBottom
= convertMm100ToTwip( nBottom
);
1350 bGotVisibleBottom
= true;
1352 else if ( pValue
->Name
== "ZoomType" )
1354 pValue
->Value
>>= nZoomType
;
1355 bGotZoomType
= true;
1357 else if ( pValue
->Name
== "ZoomFactor" )
1359 pValue
->Value
>>= nZoomFactor
;
1360 bGotZoomFactor
= true;
1362 else if ( pValue
->Name
== "ViewLayoutColumns" )
1364 pValue
->Value
>>= nViewLayoutColumns
;
1365 bGotViewLayoutColumns
= true;
1367 else if ( pValue
->Name
== "ViewLayoutBookMode" )
1369 bViewLayoutBookMode
= *o3tl::doAccess
<bool>(pValue
->Value
);
1370 bGotViewLayoutBookMode
= true;
1372 else if ( pValue
->Name
== "IsSelectedFrame" )
1374 pValue
->Value
>>= bSelectedFrame
;
1375 bGotIsSelectedFrame
= true;
1377 else if (pValue
->Name
== "ShowOnlineLayout")
1379 pValue
->Value
>>= bBrowseMode
;
1380 bGotBrowseMode
= true;
1382 // Fallback to common SdrModel processing
1383 else GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(pValue
);
1389 GetViewImpl()->GetUNOObject_Impl()->getViewSettings()->setPropertyValue("ShowOnlineLayout", uno::Any(bBrowseMode
));
1391 if (bGotVisibleBottom
)
1393 Point
aCursorPos( nX
, nY
);
1394 const long nAdd
= m_pWrtShell
->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER
: DOCUMENTBORDER
*2;
1395 if (nBottom
<= (m_pWrtShell
->GetDocSize().Height()+nAdd
) )
1397 m_pWrtShell
->EnableSmooth( false );
1398 const tools::Rectangle
aVis( nLeft
, nTop
, nRight
, nBottom
);
1401 if ( !m_pWrtShell
->GetViewOptions()->getBrowseMode() )
1402 eZoom
= static_cast < SvxZoomType
> ( nZoomType
);
1405 eZoom
= SvxZoomType::PERCENT
;
1407 if (bGotIsSelectedFrame
)
1409 bool bSelectObj
= bSelectedFrame
&& m_pWrtShell
->IsObjSelectable( aCursorPos
);
1411 // set flag value to avoid macro execution.
1412 bool bSavedFlagValue
= m_pWrtShell
->IsMacroExecAllowed();
1413 m_pWrtShell
->SetMacroExecAllowed( false );
1414 // os: changed: The user data has to be read if the view is switched back from page preview
1415 // go to the last editing position when opening own files
1416 m_pViewImpl
->SetRestorePosition(aCursorPos
, bSelectObj
);
1417 if(m_bOldShellWasPagePreview
|| bIsOwnDocument
)
1419 m_pWrtShell
->SwCursorShell::SetCursor( aCursorPos
, !bSelectObj
);
1421 // Update the shell to toggle Header/Footer edit if needed
1422 bool bInHeader
= true;
1423 if ( m_pWrtShell
->IsInHeaderFooter( &bInHeader
) )
1427 m_pWrtShell
->SetShowHeaderFooterSeparator( Footer
, true );
1428 m_pWrtShell
->SetShowHeaderFooterSeparator( Header
, false );
1432 m_pWrtShell
->SetShowHeaderFooterSeparator( Header
, true );
1433 m_pWrtShell
->SetShowHeaderFooterSeparator( Footer
, false );
1437 m_pWrtShell
->GetWin()->Invalidate();
1439 if ( m_pWrtShell
->IsInHeaderFooter() != m_pWrtShell
->IsHeaderFooterEdit() )
1440 m_pWrtShell
->ToggleHeaderFooterEdit();
1444 m_pWrtShell
->SelectObj( aCursorPos
);
1445 m_pWrtShell
->EnterSelFrameMode( &aCursorPos
);
1450 m_pWrtShell
->SetMacroExecAllowed( bSavedFlagValue
);
1454 // Set ViewLayoutSettings
1455 const bool bSetViewLayoutSettings
= bGotViewLayoutColumns
&& bGotViewLayoutBookMode
&&
1456 ( pVOpt
->GetViewLayoutColumns() != nViewLayoutColumns
|| pVOpt
->IsViewLayoutBookMode() != bViewLayoutBookMode
);
1458 const bool bSetViewSettings
= bGotZoomType
&& bGotZoomFactor
&&
1459 ( pVOpt
->GetZoom() != nZoomFactor
|| pVOpt
->GetZoomType() != eZoom
);
1461 // In case we have a 'fixed' view layout of 2 or more columns,
1462 // we have to apply the view options *before* starting the action.
1463 // Otherwise the SetZoom function cannot work correctly, because
1464 // the view layout hasn't been calculated.
1465 const bool bZoomNeedsViewLayout
= bSetViewLayoutSettings
&&
1466 1 < nViewLayoutColumns
&&
1468 eZoom
!= SvxZoomType::PERCENT
;
1470 if ( !bZoomNeedsViewLayout
)
1471 m_pWrtShell
->StartAction();
1473 if ( bSetViewLayoutSettings
)
1474 SetViewLayout( nViewLayoutColumns
, bViewLayoutBookMode
, true );
1476 if ( bZoomNeedsViewLayout
)
1477 m_pWrtShell
->StartAction();
1479 if ( bSetViewSettings
)
1480 SetZoom( eZoom
, nZoomFactor
, true );
1482 // os: changed: The user data has to be read if the view is switched back from page preview
1483 // go to the last editing position when opening own files
1484 if(m_bOldShellWasPagePreview
||bIsOwnDocument
)
1486 if ( bGotVisibleLeft
&& bGotVisibleTop
)
1488 Point
aTopLeft(aVis
.TopLeft());
1489 // make sure the document is still centered
1490 const SwTwips lBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: 2 * DOCUMENTBORDER
;
1491 SwTwips nEditWidth
= GetEditWin().GetOutputSize().Width();
1492 if(nEditWidth
> (m_aDocSz
.Width() + lBorder
))
1493 aTopLeft
.setX( ( m_aDocSz
.Width() + lBorder
- nEditWidth
) / 2 );
1496 //check if the values are possible
1497 long nXMax
= m_pHScrollbar
->GetRangeMax() - m_pHScrollbar
->GetVisibleSize();
1498 if( aTopLeft
.X() > nXMax
)
1499 aTopLeft
.setX( nXMax
< 0 ? 0 : nXMax
);
1501 SetVisArea( aTopLeft
);
1503 else if (bGotVisibleLeft
&& bGotVisibleTop
&& bGotVisibleRight
&& bGotVisibleBottom
)
1507 m_pWrtShell
->LockView( true );
1508 m_pWrtShell
->EndAction();
1509 m_pWrtShell
->LockView( false );
1510 m_pWrtShell
->EnableSmooth( true );
1516 void SwView::WriteUserDataSequence ( uno::Sequence
< beans::PropertyValue
>& rSequence
)
1518 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1519 const tools::Rectangle
& rVis
= GetVisArea();
1521 std::vector
<beans::PropertyValue
> aVector
;
1523 sal_uInt16
nViewID( GetViewFrame()->GetCurViewId());
1524 aVector
.push_back(comphelper::makePropertyValue("ViewId", "view" + OUString::number(nViewID
)));
1526 aVector
.push_back(comphelper::makePropertyValue("ViewLeft", convertTwipToMm100 ( rRect
.Left() )));
1528 aVector
.push_back(comphelper::makePropertyValue("ViewTop", convertTwipToMm100 ( rRect
.Top() )));
1530 aVector
.push_back(comphelper::makePropertyValue("VisibleLeft", convertTwipToMm100 ( rVis
.Left() )));
1532 aVector
.push_back(comphelper::makePropertyValue("VisibleTop", convertTwipToMm100 ( rVis
.Top() )));
1534 aVector
.push_back(comphelper::makePropertyValue("VisibleRight", convertTwipToMm100 ( rVis
.Right() )));
1536 aVector
.push_back(comphelper::makePropertyValue("VisibleBottom", convertTwipToMm100 ( rVis
.Bottom() )));
1538 const sal_Int16 nZoomType
= static_cast< sal_Int16
>(m_pWrtShell
->GetViewOptions()->GetZoomType());
1539 aVector
.push_back(comphelper::makePropertyValue("ZoomType", nZoomType
));
1541 const sal_Int16 nViewLayoutColumns
= static_cast< sal_Int16
>(m_pWrtShell
->GetViewOptions()->GetViewLayoutColumns());
1542 aVector
.push_back(comphelper::makePropertyValue("ViewLayoutColumns", nViewLayoutColumns
));
1544 aVector
.push_back(comphelper::makePropertyValue("ViewLayoutBookMode", m_pWrtShell
->GetViewOptions()->IsViewLayoutBookMode()));
1546 aVector
.push_back(comphelper::makePropertyValue("ZoomFactor", static_cast < sal_Int16
> (m_pWrtShell
->GetViewOptions()->GetZoom())));
1548 aVector
.push_back(comphelper::makePropertyValue("IsSelectedFrame", FrameTypeFlags::NONE
!= m_pWrtShell
->GetSelFrameType()));
1550 rSequence
= comphelper::containerToSequence(aVector
);
1552 // Common SdrModel processing
1553 GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->WriteUserDataSequence(rSequence
);
1556 void SwView::ShowCursor( bool bOn
)
1558 //don't scroll the cursor into the visible area
1559 bool bUnlockView
= !m_pWrtShell
->IsViewLocked();
1560 m_pWrtShell
->LockView( true ); //lock visible section
1563 m_pWrtShell
->HideCursor();
1564 else if( !m_pWrtShell
->IsFrameSelected() && !m_pWrtShell
->IsObjSelected() )
1565 m_pWrtShell
->ShowCursor();
1568 m_pWrtShell
->LockView( false );
1571 ErrCode
SwView::DoVerb( long nVerb
)
1573 if ( !GetViewFrame()->GetFrame().IsInPlace() )
1575 SwWrtShell
&rSh
= GetWrtShell();
1576 const SelectionType nSel
= rSh
.GetSelectionType();
1577 if ( nSel
& SelectionType::Ole
)
1578 rSh
.LaunchOLEObj( nVerb
);
1580 return ERRCODE_NONE
;
1583 // only return true for a text selection
1585 bool SwView::HasSelection( bool bText
) const
1587 return bText
? GetWrtShell().SwCursorShell::HasSelection()
1588 : GetWrtShell().HasSelection();
1591 OUString
SwView::GetSelectionText( bool bCompleteWrds
)
1593 return GetSelectionTextParam( bCompleteWrds
, true );
1596 OUString
SwView::GetSelectionTextParam( bool bCompleteWrds
, bool bEraseTrail
)
1599 if( bCompleteWrds
&& !GetWrtShell().HasSelection() )
1600 GetWrtShell().SelWrd();
1602 GetWrtShell().GetSelectedText( sReturn
);
1604 sReturn
= comphelper::string::stripEnd(sReturn
, ' ');
1608 SwGlossaryHdl
* SwView::GetGlosHdl()
1611 m_pGlosHdl
.reset(new SwGlossaryHdl(GetViewFrame(), m_pWrtShell
.get()));
1612 return m_pGlosHdl
.get();
1615 void SwView::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1617 bool bCallBase
= true;
1618 if(dynamic_cast<const FmDesignModeChangedHint
*>(&rHint
))
1620 bool bDesignMode
= static_cast<const FmDesignModeChangedHint
&>(rHint
).GetDesignMode();
1621 if (!bDesignMode
&& GetDrawFuncPtr())
1623 GetDrawFuncPtr()->Deactivate();
1624 SetDrawFuncPtr(nullptr);
1626 AttrChangedNotify(m_pWrtShell
.get());
1631 SfxHintId nId
= rHint
.GetId();
1634 // sub shells will be destroyed by the
1635 // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1636 case SfxHintId::Dying
:
1638 if ( &rBC
== GetViewFrame() )
1644 case SfxHintId::ModeChanged
:
1646 // Modal mode change-over?
1647 bool bModal
= GetDocShell()->IsInModalMode();
1648 m_pHRuler
->SetActive( !bModal
);
1649 m_pVRuler
->SetActive( !bModal
);
1654 case SfxHintId::TitleChanged
:
1655 if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1657 SwWrtShell
&rSh
= GetWrtShell();
1658 rSh
.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1660 if ( rSh
.GetViewOptions()->IsViewVRuler() )
1664 if ( rSh
.GetViewOptions()->IsViewHRuler() )
1668 bool bReadonly
= GetDocShell()->IsReadOnly();
1669 // if document is to be opened in alive-mode then this has to be
1670 // regarded while switching from readonly-mode to edit-mode
1673 SwDrawModel
* pDrawDoc
= GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel();
1676 if( !pDrawDoc
->GetOpenInDesignMode() )
1677 break;// don't touch the design mode
1680 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !bReadonly
);
1681 GetDispatcher().ExecuteList(SID_FM_DESIGN_MODE
,
1682 SfxCallMode::ASYNCHRON
, { &aItem
});
1686 case SfxHintId::SwDrawViewsCreated
:
1689 if ( GetFormShell() )
1691 GetFormShell()->SetView(dynamic_cast<FmFormView
*>(GetWrtShell().GetDrawView()));
1692 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !GetDocShell()->IsReadOnly());
1693 GetDispatcher().ExecuteList(SID_FM_DESIGN_MODE
,
1694 SfxCallMode::SYNCHRON
, { &aItem
});
1698 case SfxHintId::RedlineChanged
:
1700 static sal_uInt16
const aSlotRedLine
[] = {
1701 FN_REDLINE_ACCEPT_DIRECT
,
1702 FN_REDLINE_REJECT_DIRECT
,
1703 FN_REDLINE_NEXT_CHANGE
,
1704 FN_REDLINE_PREV_CHANGE
,
1705 FN_REDLINE_ACCEPT_ALL
,
1706 FN_REDLINE_REJECT_ALL
,
1709 GetViewFrame()->GetBindings().Invalidate(aSlotRedLine
);
1718 SfxViewShell::Notify(rBC
, rHint
);
1721 #if defined(_WIN32) || defined UNX
1723 void SwView::ScannerEventHdl()
1725 uno::Reference
< XScannerManager2
> xScanMgr
= SW_MOD()->GetScannerManager();
1728 const ScannerContext
aContext( xScanMgr
->getAvailableScanners().getConstArray()[ 0 ] );
1729 const ScanError eError
= xScanMgr
->getError( aContext
);
1731 if( ScanError_ScanErrorNone
== eError
)
1733 const uno::Reference
< awt::XBitmap
> xBitmap( xScanMgr
->getBitmap( aContext
) );
1737 const BitmapEx
aScanBmp( VCLUnoHelper::GetBitmap( xBitmap
) );
1741 Graphic
aGrf(aScanBmp
);
1742 m_pWrtShell
->Insert( OUString(), OUString(), aGrf
);
1747 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
1748 rBind
.Invalidate( SID_TWAIN_SELECT
);
1749 rBind
.Invalidate( SID_TWAIN_TRANSFER
);
1753 void SwView::StopShellTimer()
1755 if(m_aTimer
.IsActive())
1758 if ( m_bAttrChgNotifiedWithRegistrations
)
1760 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1761 m_bAttrChgNotifiedWithRegistrations
= false;
1764 m_bAttrChgNotified
= false;
1768 bool SwView::PrepareClose( bool bUI
)
1770 SfxViewFrame
* pVFrame
= GetViewFrame();
1771 pVFrame
->SetChildWindow( SwInputChild::GetChildWindowId(), false );
1772 if( pVFrame
->GetDispatcher()->IsLocked() )
1773 pVFrame
->GetDispatcher()->Lock(false);
1775 if ( m_pFormShell
&& !m_pFormShell
->PrepareClose( bUI
) )
1779 return SfxViewShell::PrepareClose( bUI
);
1782 // status methods for clipboard.
1783 // Status changes now notified from the clipboard.
1784 bool SwView::IsPasteAllowed()
1786 SotExchangeDest nPasteDestination
= SwTransferable::GetSotDestination( *m_pWrtShell
);
1787 if( m_nLastPasteDestination
!= nPasteDestination
)
1789 TransferableDataHelper
aDataHelper(
1790 TransferableDataHelper::CreateFromSystemClipboard(
1792 if( aDataHelper
.GetXTransferable().is() )
1794 m_bPasteState
= SwTransferable::IsPaste( *m_pWrtShell
, aDataHelper
);
1795 m_bPasteSpecialState
= SwTransferable::IsPasteSpecial(
1796 *m_pWrtShell
, aDataHelper
);
1799 m_bPasteState
= m_bPasteSpecialState
= false;
1801 if( static_cast<SotExchangeDest
>(0xFFFF) == m_nLastPasteDestination
) // the init value
1802 m_pViewImpl
->AddClipboardListener();
1803 m_nLastPasteDestination
= nPasteDestination
;
1805 return m_bPasteState
;
1808 bool SwView::IsPasteSpecialAllowed()
1810 if ( m_pFormShell
&& m_pFormShell
->IsActiveControl() )
1813 SotExchangeDest nPasteDestination
= SwTransferable::GetSotDestination( *m_pWrtShell
);
1814 if( m_nLastPasteDestination
!= nPasteDestination
)
1816 TransferableDataHelper
aDataHelper(
1817 TransferableDataHelper::CreateFromSystemClipboard(
1819 if( aDataHelper
.GetXTransferable().is() )
1821 m_bPasteState
= SwTransferable::IsPaste( *m_pWrtShell
, aDataHelper
);
1822 m_bPasteSpecialState
= SwTransferable::IsPasteSpecial(
1823 *m_pWrtShell
, aDataHelper
);
1826 m_bPasteState
= m_bPasteSpecialState
= false;
1828 if( static_cast<SotExchangeDest
>(0xFFFF) == m_nLastPasteDestination
) // the init value
1829 m_pViewImpl
->AddClipboardListener();
1831 return m_bPasteSpecialState
;
1834 void SwView::NotifyDBChanged()
1836 GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1841 SfxObjectShellLock
SwView::CreateTmpSelectionDoc()
1843 SwXTextView
*const pTempImpl
= GetViewImpl()->GetUNOObject_Impl();
1844 return pTempImpl
->BuildTmpSelectionDoc();
1847 void SwView::AddTransferable(SwTransferable
& rTransferable
)
1849 GetViewImpl()->AddTransferable(rTransferable
);
1854 void InitPrintOptionsFromApplication(SwPrintData
& o_rData
, bool const bWeb
)
1856 o_rData
= *SW_MOD()->GetPrtOptions(bWeb
);
1861 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */