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 <officecfg/Office/Common.hxx>
27 #include <rtl/logfile.hxx>
28 #include <vcl/graph.hxx>
29 #include <vcl/inputctx.hxx>
30 #include <basic/sbxobj.hxx>
31 #include <svl/eitem.hxx>
32 #include <unotools/lingucfg.hxx>
33 #include <unotools/useroptions.hxx>
34 #include <sfx2/dispatch.hxx>
35 #include <sfx2/request.hxx>
36 #include <sfx2/docfile.hxx>
37 #include <sfx2/printer.hxx>
38 #include <sfx2/app.hxx>
39 #include <svx/ruler.hxx>
40 #include <editeng/protitem.hxx>
41 #include <svx/fmshell.hxx>
42 #include <svx/extrusionbar.hxx>
43 #include <svx/fontworkbar.hxx>
44 #include <unotxvw.hxx>
46 #include <swhints.hxx>
47 #include <swmodule.hxx>
48 #include <inputwin.hxx>
49 #include <chartins.hxx>
50 #include <uivwimp.hxx>
57 #include <mediash.hxx>
62 #include <drawbase.hxx>
63 #include <drformsh.hxx>
64 #include <drwtxtsh.hxx>
65 #include <beziersh.hxx>
67 #include <globdoc.hxx>
70 #include <gloshdl.hxx>
71 #include <usrpref.hxx>
72 #include <srcview.hxx>
74 #include <IDocumentUndoRedo.hxx>
75 #include <drawdoc.hxx>
78 #include <workctrl.hxx>
82 #include <swdtflvr.hxx>
84 #include <globdoc.hrc>
86 #include <cfgitems.hxx>
88 #include <linguistic/lngprops.hxx>
89 #include <editeng/unolingu.hxx>
90 #include <com/sun/star/frame/FrameSearchFlag.hpp>
91 #include <com/sun/star/scanner/ScannerContext.hpp>
92 #include <com/sun/star/scanner/XScannerManager2.hpp>
93 #include <toolkit/unohlp.hxx>
94 #include <rtl/ustrbuf.hxx>
95 #include <sax/tools/converter.hxx>
97 #include "formatclipboard.hxx"
98 #include <PostItMgr.hxx>
99 #include <annotsh.hxx>
100 #include <swruler.hxx>
102 #include <fldbas.hxx>
106 #include <com/sun/star/document/XDocumentProperties.hpp>
107 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
109 #include <svl/cjkoptions.hxx>
111 using namespace ::com::sun::star
;
112 using namespace ::com::sun::star::uno
;
113 using namespace ::com::sun::star::lang
;
114 using namespace ::com::sun::star::scanner
;
116 extern bool bNoInterrupt
; // in mainwn.cxx
118 #define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT| \
119 SFX_VIEW_HAS_PRINTOPTIONS)
121 /*--------------------------------------------------------------------
122 Beschreibung: Statics
123 --------------------------------------------------------------------*/
125 int bDocSzUpdated
= 1;
127 SvxSearchItem
* SwView::m_pSrchItem
= 0;
129 sal_uInt16
SwView::m_nInsertCtrlState
= FN_INSERT_TABLE
;
130 sal_uInt16
SwView::m_nWebInsertCtrlState
= FN_INSERT_TABLE
;
131 sal_uInt16
SwView::m_nInsertObjectCtrlState
= SID_INSERT_DIAGRAM
;
133 bool SwView::m_bExtra
= false;
134 sal_Bool
SwView::m_bFound
= sal_False
;
135 bool SwView::m_bJustOpened
= false;
137 SvxSearchDialog
* SwView::m_pSrchDlg
= 0;
138 SearchAttrItemList
* SwView::m_pSrchList
= 0;
139 SearchAttrItemList
* SwView::m_pReplList
= 0;
143 inline SfxDispatcher
&SwView::GetDispatcher()
145 return *GetViewFrame()->GetDispatcher();
148 void SwView::ImpSetVerb( int nSelType
)
150 sal_Bool bResetVerbs
= m_bVerbsActive
;
151 if ( !GetViewFrame()->GetFrame().IsInPlace() &&
152 (nsSelectionType::SEL_OLE
|nsSelectionType::SEL_GRF
) & nSelType
)
154 if ( !m_pWrtShell
->IsSelObjProtected(FLYPROTECT_CONTENT
) )
156 if ( nSelType
& nsSelectionType::SEL_OLE
)
158 SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
159 m_bVerbsActive
= sal_True
;
160 bResetVerbs
= sal_False
;
166 SetVerbs( Sequence
< embed::VerbDescriptor
>() );
167 m_bVerbsActive
= sal_False
;
171 /*--------------------------------------------------------------------
173 called by the SwEditWin when it gets the focus
174 --------------------------------------------------------------------*/
175 void SwView::GotFocus() const
177 // if we got the focus, and the form shell *is* on the top of the dispatcher
178 // stack, then we need to rebuild the stack (the form shell doesn't belong to
180 const SfxDispatcher
& rDispatcher
= const_cast< SwView
* >( this )->GetDispatcher();
181 SfxShell
* pTopShell
= rDispatcher
.GetShell( 0 );
182 FmFormShell
* pAsFormShell
= PTR_CAST( FmFormShell
, pTopShell
);
185 pAsFormShell
->ForgetActiveControl();
186 const_cast< SwView
* >( this )->AttrChangedNotify( m_pWrtShell
);
188 else if ( m_pPostItMgr
)
190 SwAnnotationShell
* pAsAnnotationShell
= PTR_CAST( SwAnnotationShell
, pTopShell
);
191 if ( pAsAnnotationShell
)
193 m_pPostItMgr
->SetActiveSidebarWin(0);
194 const_cast< SwView
* >( this )->AttrChangedNotify( m_pWrtShell
);
197 if( GetWrtShellPtr() )
199 SwWrtShell
& rWrtShell
= GetWrtShell();
200 rWrtShell
.GetDoc()->SetCurrentViewShell( GetWrtShellPtr() );
201 rWrtShell
.GetDoc()->set( IDocumentSettingAccess::BROWSE_MODE
,
202 rWrtShell
.GetViewOptions()->getBrowseMode() );
206 /*--------------------------------------------------------------------
208 called by the FormShell when a form control is focused. This is
209 a request to put the form shell on the top of the dispatcher
211 --------------------------------------------------------------------*/
212 IMPL_LINK_NOARG(SwView
, FormControlActivated
)
214 // if a form control has been activated, and the form shell is not on the top
215 // of the dispatcher stack, then we need to activate it
216 const SfxDispatcher
& rDispatcher
= GetDispatcher();
217 const SfxShell
* pTopShell
= rDispatcher
.GetShell( 0 );
218 const FmFormShell
* pAsFormShell
= PTR_CAST( FmFormShell
, pTopShell
);
221 // if we're editing text currently, cancel this
222 SdrView
*pSdrView
= m_pWrtShell
? m_pWrtShell
->GetDrawView() : NULL
;
223 if ( pSdrView
&& pSdrView
->IsTextEdit() )
224 pSdrView
->SdrEndTextEdit( sal_True
);
226 const_cast< SwView
* >( this )->AttrChangedNotify( m_pWrtShell
);
232 void SwView::SelectShell()
234 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
236 // Achtung: SelectShell fuer die WebView mitpflegen
238 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
242 // Entscheidung, ob UpdateTable gerufen werden muss
243 sal_Bool bUpdateTable
= sal_False
;
244 const SwFrmFmt
* pCurTableFmt
= m_pWrtShell
->GetTableFmt();
245 if(pCurTableFmt
&& pCurTableFmt
!= m_pLastTableFormat
)
247 bUpdateTable
= sal_True
; // kann erst spaeter ausgefuehrt werden
249 m_pLastTableFormat
= pCurTableFmt
;
251 //SEL_TBL and SEL_TBL_CELLS can be changed!
252 int nNewSelectionType
= (m_pWrtShell
->GetSelectionType()
253 & ~nsSelectionType::SEL_TBL_CELLS
);
255 if ( m_pFormShell
&& m_pFormShell
->IsActiveControl() )
256 nNewSelectionType
|= nsSelectionType::SEL_FOC_FRM_CTRL
;
258 if ( nNewSelectionType
== m_nSelectionType
)
260 GetViewFrame()->GetBindings().InvalidateAll( sal_False
);
261 if ( m_nSelectionType
& nsSelectionType::SEL_OLE
||
262 m_nSelectionType
& nsSelectionType::SEL_GRF
)
263 //Fuer Grafiken und OLE kann sich natuerlich das Verb aendern!
264 ImpSetVerb( nNewSelectionType
);
269 SfxDispatcher
&rDispatcher
= GetDispatcher();
270 SwToolbarConfigItem
*pBarCfg
= SW_MOD()->GetToolbarConfig();
274 rDispatcher
.Flush(); // alle gecachten Shells wirklich loeschen
276 //Zur alten Selektion merken welche Toolbar sichtbar war
277 sal_uInt16 nId
= static_cast< sal_uInt16
>( rDispatcher
.GetObjectBarId( SFX_OBJECTBAR_OBJECT
));
279 pBarCfg
->SetTopToolbar( m_nSelectionType
, nId
);
282 for ( sal_uInt16 i
= 0; sal_True
; ++i
)
284 pSfxShell
= rDispatcher
.GetShell( i
);
285 if ( pSfxShell
->ISA( SwBaseShell
)
286 || pSfxShell
->ISA( SwDrawTextShell
)
287 || pSfxShell
->ISA( svx::ExtrusionBar
)
288 || pSfxShell
->ISA( svx::FontworkBar
)
289 || pSfxShell
->ISA( SwAnnotationShell
)
292 rDispatcher
.Pop( *pSfxShell
, SFX_SHELL_POP_DELETE
);
294 else if ( pSfxShell
->ISA( FmFormShell
) )
296 rDispatcher
.Pop( *pSfxShell
);
303 sal_Bool bInitFormShell
= sal_False
;
306 bInitFormShell
= sal_True
;
307 m_pFormShell
= new FmFormShell( this );
308 m_pFormShell
->SetControlActivationHandler( LINK( this, SwView
, FormControlActivated
) );
309 StartListening(*m_pFormShell
);
312 sal_Bool bSetExtInpCntxt
= sal_False
;
313 m_nSelectionType
= nNewSelectionType
;
314 ShellModes eShellMode
;
316 if ( !( m_nSelectionType
& nsSelectionType::SEL_FOC_FRM_CTRL
) )
317 rDispatcher
.Push( *m_pFormShell
);
319 eShellMode
= SHELL_MODE_NAVIGATION
;
320 m_pShell
= new SwNavigationShell( *this );
321 rDispatcher
.Push( *m_pShell
);
323 if ( m_nSelectionType
& nsSelectionType::SEL_OLE
)
325 eShellMode
= SHELL_MODE_OBJECT
;
326 m_pShell
= new SwOleShell( *this );
327 rDispatcher
.Push( *m_pShell
);
329 else if ( m_nSelectionType
& nsSelectionType::SEL_FRM
330 || m_nSelectionType
& nsSelectionType::SEL_GRF
)
332 eShellMode
= SHELL_MODE_FRAME
;
333 m_pShell
= new SwFrameShell( *this );
334 rDispatcher
.Push( *m_pShell
);
335 if(m_nSelectionType
& nsSelectionType::SEL_GRF
)
337 eShellMode
= SHELL_MODE_GRAPHIC
;
338 m_pShell
= new SwGrfShell( *this );
339 rDispatcher
.Push( *m_pShell
);
342 else if ( m_nSelectionType
& nsSelectionType::SEL_DRW
)
344 eShellMode
= SHELL_MODE_DRAW
;
345 m_pShell
= new SwDrawShell( *this );
346 rDispatcher
.Push( *m_pShell
);
348 if ( m_nSelectionType
& nsSelectionType::SEL_BEZ
)
350 eShellMode
= SHELL_MODE_BEZIER
;
351 m_pShell
= new SwBezierShell( *this );
352 rDispatcher
.Push( *m_pShell
);
354 else if( m_nSelectionType
& nsSelectionType::SEL_MEDIA
)
356 eShellMode
= SHELL_MODE_MEDIA
;
357 m_pShell
= new SwMediaShell( *this );
358 rDispatcher
.Push( *m_pShell
);
361 if (m_nSelectionType
& nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE
)
363 eShellMode
= SHELL_MODE_EXTRUDED_CUSTOMSHAPE
;
364 m_pShell
= new svx::ExtrusionBar(this);
365 rDispatcher
.Push( *m_pShell
);
367 if (m_nSelectionType
& nsSelectionType::SEL_FONTWORK
)
369 eShellMode
= SHELL_MODE_FONTWORK
;
370 m_pShell
= new svx::FontworkBar(this);
371 rDispatcher
.Push( *m_pShell
);
374 else if ( m_nSelectionType
& nsSelectionType::SEL_DRW_FORM
)
376 eShellMode
= SHELL_MODE_DRAW_FORM
;
377 m_pShell
= new SwDrawFormShell( *this );
379 rDispatcher
.Push( *m_pShell
);
381 else if ( m_nSelectionType
& nsSelectionType::SEL_DRW_TXT
)
383 bSetExtInpCntxt
= sal_True
;
384 eShellMode
= SHELL_MODE_DRAWTEXT
;
385 rDispatcher
.Push( *(new SwBaseShell( *this )) );
386 m_pShell
= new SwDrawTextShell( *this );
387 rDispatcher
.Push( *m_pShell
);
389 else if ( m_nSelectionType
& nsSelectionType::SEL_POSTIT
)
391 eShellMode
= SHELL_MODE_POSTIT
;
392 m_pShell
= new SwAnnotationShell( *this );
393 rDispatcher
.Push( *m_pShell
);
397 bSetExtInpCntxt
= sal_True
;
398 eShellMode
= SHELL_MODE_TEXT
;
399 sal_uInt32 nHelpId
= 0;
400 if ( m_nSelectionType
& nsSelectionType::SEL_NUM
)
402 eShellMode
= SHELL_MODE_LIST_TEXT
;
403 m_pShell
= new SwListShell( *this );
404 nHelpId
= m_pShell
->GetHelpId();
405 rDispatcher
.Push( *m_pShell
);
407 m_pShell
= new SwTextShell(*this);
409 m_pShell
->SetHelpId(nHelpId
);
410 rDispatcher
.Push( *m_pShell
);
411 if ( m_nSelectionType
& nsSelectionType::SEL_TBL
)
413 eShellMode
= eShellMode
== SHELL_MODE_LIST_TEXT
? SHELL_MODE_TABLE_LIST_TEXT
414 : SHELL_MODE_TABLE_TEXT
;
415 m_pShell
= new SwTableShell( *this );
416 rDispatcher
.Push( *m_pShell
);
420 if ( m_nSelectionType
& nsSelectionType::SEL_FOC_FRM_CTRL
)
421 rDispatcher
.Push( *m_pFormShell
);
423 m_pViewImpl
->SetShellMode(eShellMode
);
424 ImpSetVerb( m_nSelectionType
);
426 if( !GetDocShell()->IsReadOnly() )
428 if( bSetExtInpCntxt
&& GetWrtShell().HasReadonlySel() )
429 bSetExtInpCntxt
= sal_False
;
431 InputContext
aCntxt( GetEditWin().GetInputContext() );
432 aCntxt
.SetOptions( bSetExtInpCntxt
433 ? (aCntxt
.GetOptions() |
434 ( INPUTCONTEXT_TEXT
|
435 INPUTCONTEXT_EXTTEXTINPUT
))
436 : (aCntxt
.GetOptions() & ~
437 ( INPUTCONTEXT_TEXT
|
438 INPUTCONTEXT_EXTTEXTINPUT
)) );
439 GetEditWin().SetInputContext( aCntxt
);
442 //Zur neuen Selektion die Toolbar aktivieren, die auch beim letzten Mal
444 //Vorher muss ein Flush() sein, betrifft aber lt. MBA nicht das UI und ist
445 //kein Performance-Problem
446 // TODO/LATER: maybe now the Flush() command is superfluous?!
449 Point aPnt
= GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
450 aPnt
= GetEditWin().PixelToLogic(aPnt
);
451 GetEditWin().UpdatePointer(aPnt
);
453 SdrView
* pDView
= GetWrtShell().GetDrawView();
454 if ( bInitFormShell
&& pDView
)
455 m_pFormShell
->SetView(PTR_CAST(FmFormView
, pDView
));
458 //Guenstiger Zeitpunkt fuer die Kommunikation mit OLE-Objekten?
459 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
460 GetDocShell()->GetDoc()->PrtOLENotify( sal_False
);
462 // now the table-update
464 m_pWrtShell
->UpdateTable();
466 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
469 //Zusammenspiel: AttrChangedNotify() und TimeoutHdl.
470 //Falls noch Actions offen sind keine Aktualisierung, da der
471 //Cursor auf der Core-Seite im Wald stehen kann.
472 //Da wir aber keine Stati mehr liefern koennen und wollen locken wir
473 //stattdessen den Dispatcher.
477 static int lcl_CmpIds( const void *pFirst
, const void *pSecond
)
479 return (*(sal_uInt16
*)pFirst
) - (*(sal_uInt16
*)pSecond
);
483 IMPL_LINK_NOARG(SwView
, AttrChangedNotify
)
485 if ( GetEditWin().IsChainMode() )
486 GetEditWin().SetChainMode( sal_False
);
488 //Opt: Nicht wenn PaintLocked. Beim Unlock wird dafuer nocheinmal ein
490 if( !m_pWrtShell
->IsPaintLocked() && !bNoInterrupt
&&
491 GetDocShell()->IsReadOnly() )
492 _CheckReadonlyState();
494 if( !m_pWrtShell
->IsPaintLocked() && !bNoInterrupt
)
495 _CheckReadonlySelection();
497 if( !m_bAttrChgNotified
)
499 if ( m_pWrtShell
->BasicActionPend() || bNoInterrupt
||
500 GetDispatcher().IsLocked() || //do not confuse the SFX
501 GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
503 m_bAttrChgNotified
= sal_True
;
506 const SfxPoolItem
*pItem
;
507 if ( SFX_ITEM_SET
!= GetObjectShell()->GetMedium()->GetItemSet()->
508 GetItemState( SID_HIDDEN
, sal_False
, &pItem
) ||
509 !((SfxBoolItem
*)pItem
)->GetValue() )
511 GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
512 m_bAttrChgNotifiedWithRegistrations
= sal_True
;
521 // change ui if cursor is at a SwPostItField
524 // only perform the code that is needed to determine, if at the
525 // actual cursor position is a post-it field
526 m_pPostItMgr
->SetShadowState( m_pWrtShell
->GetPostItFieldAtCursor() );
532 IMPL_LINK_NOARG(SwView
, TimeoutHdl
)
534 DBG_PROFSTART(viewhdl
);
536 if( m_pWrtShell
->BasicActionPend() || bNoInterrupt
)
539 DBG_PROFSTOP(viewhdl
);
543 if ( m_bAttrChgNotifiedWithRegistrations
)
545 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
546 m_bAttrChgNotifiedWithRegistrations
= sal_False
;
549 _CheckReadonlyState();
550 _CheckReadonlySelection();
552 sal_Bool bOldUndo
= m_pWrtShell
->DoesUndo();
553 m_pWrtShell
->DoUndo( sal_False
);
555 m_pWrtShell
->DoUndo( bOldUndo
);
556 m_bAttrChgNotified
= sal_False
;
557 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
559 DBG_PROFSTOP(viewhdl
);
563 void SwView::_CheckReadonlyState()
565 SfxDispatcher
&rDis
= GetDispatcher();
566 //Um erkennen zu koennen ob bereits disabled ist!
567 SfxItemState eStateRO
, eStateProtAll
;
568 const SfxPoolItem
*pItem
;
569 // von einem nur uns bekannten Slot den Status abfragen.
570 // Ansonsten kennen andere den Slot; wie z.B. die BasidIde
571 eStateRO
= rDis
.QueryState( FN_INSERT_BOOKMARK
, pItem
);
572 eStateProtAll
= rDis
.QueryState( FN_EDIT_REGION
, pItem
);
573 sal_Bool bChgd
= sal_False
;
575 if ( !m_pWrtShell
->IsCrsrReadonly() )
577 static sal_uInt16 aROIds
[] =
579 SID_DELETE
, FN_BACKSPACE
, FN_SHIFT_BACKSPACE
,
581 SID_REDO
, SID_REPEAT
, SID_PASTE
,
582 SID_PASTE_UNFORMATTED
,
583 SID_PASTE_SPECIAL
, SID_SBA_BRW_INSERT
,
584 SID_BACKGROUND_COLOR
, FN_INSERT_BOOKMARK
,
585 SID_CHARMAP
, FN_INSERT_SOFT_HYPHEN
,
586 FN_INSERT_HARDHYPHEN
, FN_INSERT_HARD_SPACE
, FN_INSERT_BREAK
,
587 FN_INSERT_LINEBREAK
, FN_INSERT_COLUMN_BREAK
, FN_INSERT_BREAK_DLG
,
588 FN_DELETE_SENT
, FN_DELETE_BACK_SENT
, FN_DELETE_WORD
,
589 FN_DELETE_BACK_WORD
, FN_DELETE_LINE
, FN_DELETE_BACK_LINE
,
590 FN_DELETE_PARA
, FN_DELETE_BACK_PARA
, FN_DELETE_WHOLE_LINE
,
591 FN_CALCULATE
, FN_FORMAT_RESET
,
592 FN_POSTIT
, FN_JAVAEDIT
, SID_ATTR_PARA_ADJUST_LEFT
,
593 SID_ATTR_PARA_ADJUST_RIGHT
, SID_ATTR_PARA_ADJUST_CENTER
,SID_ATTR_PARA_ADJUST_BLOCK
,
594 SID_ATTR_PARA_LINESPACE_10
, SID_ATTR_PARA_LINESPACE_15
, SID_ATTR_PARA_LINESPACE_20
,
595 SID_ATTR_CHAR_FONT
, SID_ATTR_CHAR_FONTHEIGHT
, SID_ATTR_CHAR_COLOR_BACKGROUND
,
596 SID_ATTR_CHAR_COLOR_BACKGROUND_EXT
, SID_ATTR_CHAR_COLOR_EXT
,
597 SID_ATTR_CHAR_COLOR
, SID_ATTR_CHAR_WEIGHT
, SID_ATTR_CHAR_POSTURE
,
598 SID_ATTR_CHAR_OVERLINE
,
599 SID_ATTR_CHAR_UNDERLINE
, SID_ATTR_FLASH
, SID_ATTR_CHAR_STRIKEOUT
,
600 FN_UNDERLINE_DOUBLE
, SID_ATTR_CHAR_CONTOUR
, SID_ATTR_CHAR_SHADOWED
,
601 SID_ATTR_CHAR_AUTOKERN
, SID_ATTR_CHAR_ESCAPEMENT
, FN_SET_SUPER_SCRIPT
,
602 FN_SET_SUB_SCRIPT
, SID_ATTR_CHAR_CASEMAP
, SID_ATTR_CHAR_LANGUAGE
,
603 SID_ATTR_CHAR_KERNING
, SID_CHAR_DLG
, SID_ATTR_CHAR_WORDLINEMODE
,
604 FN_GROW_FONT_SIZE
, FN_SHRINK_FONT_SIZE
, FN_TXTATR_INET
,
605 FN_FORMAT_DROPCAPS
, SID_ATTR_PARA_ADJUST
, SID_ATTR_PARA_LINESPACE
,
606 SID_ATTR_PARA_SPLIT
, SID_ATTR_PARA_KEEP
, SID_ATTR_PARA_WIDOWS
,
607 SID_ATTR_PARA_ORPHANS
,
608 SID_ATTR_PARA_MODEL
, SID_PARA_DLG
,
609 FN_SELECT_PARA
, SID_DEC_INDENT
,
612 static sal_Bool bFirst
= sal_True
;
615 qsort( (void*)aROIds
, sizeof(aROIds
)/sizeof(sal_uInt16
), sizeof(sal_uInt16
), lcl_CmpIds
);
618 if ( SFX_ITEM_DISABLED
== eStateRO
)
620 rDis
.SetSlotFilter( sal_Bool(2), sizeof(aROIds
)/sizeof(sal_uInt16
), aROIds
);
624 else if( m_pWrtShell
->IsAllProtect() )
626 if ( SFX_ITEM_DISABLED
== eStateProtAll
)
628 static sal_uInt16 aAllProtIds
[] = { SID_SAVEDOC
, FN_EDIT_REGION
};
629 static sal_Bool bAllProtFirst
= sal_True
;
632 qsort( (void*)aAllProtIds
, sizeof(aAllProtIds
)/sizeof(sal_uInt16
), sizeof(sal_uInt16
), lcl_CmpIds
);
633 bAllProtFirst
= sal_False
;
635 rDis
.SetSlotFilter( sal_Bool(2),
636 sizeof(aAllProtIds
)/sizeof(sal_uInt16
),
641 else if ( SFX_ITEM_DISABLED
!= eStateRO
||
642 SFX_ITEM_DISABLED
!= eStateProtAll
)
645 rDis
.SetSlotFilter();
648 GetViewFrame()->GetBindings().InvalidateAll(sal_True
);
651 void SwView::_CheckReadonlySelection()
653 sal_uInt32 nDisableFlags
= 0;
654 SfxDispatcher
&rDis
= GetDispatcher();
656 if( m_pWrtShell
->HasReadonlySel(m_bAnnotationMode
) &&
657 ( !m_pWrtShell
->GetDrawView() ||
658 !m_pWrtShell
->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
659 nDisableFlags
|= SW_DISABLE_ON_PROTECTED_CURSOR
;
661 if( (SW_DISABLE_ON_PROTECTED_CURSOR
& nDisableFlags
) !=
662 (SW_DISABLE_ON_PROTECTED_CURSOR
& rDis
.GetDisableFlags() ) )
664 // zusaetzlich am Window den InputContext umsetzen, damit in
665 // japanischen / chinesischen Versionen die externe Eingabe
666 // ab-/angeschaltet wird. Das aber nur wenn auch die richtige
667 // Shell auf dem Stack steht.
668 switch( m_pViewImpl
->GetShellMode() )
670 case SHELL_MODE_TEXT
:
671 case SHELL_MODE_LIST_TEXT
:
672 case SHELL_MODE_TABLE_TEXT
:
673 case SHELL_MODE_TABLE_LIST_TEXT
:
675 // temporaere Loesung!!! Sollte bei jeder Cursorbewegung
676 // den Font von der akt. Einfuegeposition setzen, also ausserhalb
677 // dieses if's. Aber TH wertet den Font zur Zeit nicht aus und
678 // das besorgen erscheint mir hier zu teuer zu sein.
679 // Ausserdem haben wir keinen Font, sondern nur Attribute aus denen
680 // die Textformatierung dann den richtigen Font zusammen baut.
682 InputContext
aCntxt( GetEditWin().GetInputContext() );
683 aCntxt
.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR
& nDisableFlags
684 ? (aCntxt
.GetOptions() & ~
685 ( INPUTCONTEXT_TEXT
|
686 INPUTCONTEXT_EXTTEXTINPUT
))
687 : (aCntxt
.GetOptions() |
688 ( INPUTCONTEXT_TEXT
|
689 INPUTCONTEXT_EXTTEXTINPUT
)) );
690 GetEditWin().SetInputContext( aCntxt
);
699 if( nDisableFlags
!= rDis
.GetDisableFlags() )
701 rDis
.SetDisableFlags( nDisableFlags
);
702 GetViewFrame()->GetBindings().InvalidateAll( sal_True
);
706 SwView::SwView( SfxViewFrame
*_pFrame
, SfxViewShell
* pOldSh
)
707 : SfxViewShell( _pFrame
, SWVIEWFLAGS
),
708 m_aPageStr( SW_RES( STR_PAGE
)),
709 m_nNewPage(USHRT_MAX
),
710 m_pNumRuleNodeFromDoc(0),
711 m_pEditWin( new SwEditWin( &_pFrame
->GetWindow(), *this ) ),
717 m_pScrollFill(new ScrollBarBox( &_pFrame
->GetWindow(), _pFrame
->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE
)),
718 m_pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), m_pEditWin
,
719 SVXRULER_SUPPORT_TABS
| SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL
|
720 SVXRULER_SUPPORT_BORDERS
| SVXRULER_SUPPORT_REDUCED_METRIC
,
721 GetViewFrame()->GetBindings(),
722 WB_VSCROLL
| WB_EXTRAFIELD
| WB_BORDER
)),
729 m_pLastTableFormat(0),
730 m_pFormatClipboard(new SwFormatClipboard()),
732 m_nSelectionType( INT_MAX
),
734 m_nDrawSfxId( USHRT_MAX
),
735 m_nFormSfxId( USHRT_MAX
),
736 m_nLastPasteDestination( 0xFFFF ),
737 m_nLeftBorderDistance( 0 ),
738 m_nRightBorderDistance( 0 ),
739 m_bWheelScrollInProgress(false),
740 m_bInMailMerge(sal_False
),
741 m_bInDtor(sal_False
),
742 m_bOldShellWasPagePreView(sal_False
),
743 m_bIsPreviewDoubleClick(sal_False
),
744 m_bAnnotationMode(false)
746 // According to discussion with MBA and further
747 // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
748 // if function "New Window" is performed to open an additional view beside
749 // an already existing one.
750 // If the view is switch from one to another, the 'old' view is given by
751 // parameter <pOldSh>.
753 RTL_LOGFILE_CONTEXT_AUTHOR( aLog
, "SW", "JP93722", "SwView::SwView" );
755 m_bCenterCrsr
= m_bTopCrsr
= m_bAlwaysShowSel
= m_bTabColFromDoc
= m_bTabRowFromDoc
=
756 m_bSetTabColFromDoc
= m_bSetTabRowFromDoc
= m_bAttrChgNotified
= m_bAttrChgNotifiedWithRegistrations
=
757 m_bVerbsActive
= m_bDrawRotate
= m_bInOuterResizePixel
= m_bInInnerResizePixel
=
758 m_bPasteState
= m_bPasteSpecialState
= m_bMakeSelectionVisible
= sal_False
;
760 m_bShowAtResize
= m_bDrawSelMode
= bDocSzUpdated
= sal_True
;
762 _CreateScrollbar( sal_True
);
763 _CreateScrollbar( sal_False
);
765 m_pViewImpl
= new SwView_Impl(this);
766 SetName(OUString("View"));
767 SetWindow( m_pEditWin
);
769 m_aTimer
.SetTimeout( 120 );
771 SwDocShell
* pDocSh
= PTR_CAST( SwDocShell
, _pFrame
->GetObjectShell() );
772 sal_Bool bOldModifyFlag
= pDocSh
->IsEnableSetModified();
774 pDocSh
->EnableSetModified( sal_False
);
775 // HACK: SwDocShell has some cached font info, VCL informs about font updates,
776 // but loading of docs with embedded fonts happens after SwDocShell is created
777 // but before SwEditWin (which handles the VCL event) is created. So update
779 if( pDocSh
->GetDoc()->get( IDocumentSettingAccess::EMBED_FONTS
))
780 pDocSh
->UpdateFontList();
781 OSL_ENSURE( pDocSh
, "view without DocShell." );
782 SwWebDocShell
* pWebDShell
= PTR_CAST( SwWebDocShell
, pDocSh
);
784 const SwMasterUsrPref
*pUsrPref
= SW_MOD()->GetUsrPref(0 != pWebDShell
);
785 SwViewOption
aUsrPref( *pUsrPref
);
787 //! get lingu options without loading lingu DLL
788 SvtLinguOptions aLinguOpt
;
789 SvtLinguConfig().GetOptions( aLinguOpt
);
790 aUsrPref
.SetOnlineSpell( aLinguOpt
.bIsSpellAuto
);
792 sal_Bool bOldShellWasSrcView
= sal_False
;
794 // determine if there is an existing view for
796 SfxViewShell
* pExistingSh
= 0;
799 pExistingSh
= pOldSh
;
800 // determine type of existing view
801 if( pExistingSh
->IsA( TYPE( SwPagePreView
) ) )
803 m_sSwViewData
= ((SwPagePreView
*)pExistingSh
)->GetPrevSwViewData();
804 m_sNewCrsrPos
= ((SwPagePreView
*)pExistingSh
)->GetNewCrsrPos();
805 m_nNewPage
= ((SwPagePreView
*)pExistingSh
)->GetNewPage();
806 m_bOldShellWasPagePreView
= sal_True
;
807 m_bIsPreviewDoubleClick
= m_sNewCrsrPos
.Len() > 0 || m_nNewPage
!= USHRT_MAX
;
809 else if( pExistingSh
->IsA( TYPE( SwSrcView
) ) )
810 bOldShellWasSrcView
= sal_True
;
813 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "before create WrtShell" );
814 if(PTR_CAST( SwView
, pExistingSh
))
816 m_pWrtShell
= new SwWrtShell( *((SwView
*)pExistingSh
)->m_pWrtShell
,
819 else if( dynamic_cast<SwWrtShell
*>( pDocSh
->GetDoc()->GetCurrentViewShell() ) )
821 m_pWrtShell
= new SwWrtShell( *(SwWrtShell
*)pDocSh
->GetDoc()->GetCurrentViewShell(),
826 SwDoc
& rDoc
= *((SwDocShell
*)pDocSh
)->GetDoc();
828 if( !bOldShellWasSrcView
&& pWebDShell
&& !m_bOldShellWasPagePreView
)
829 aUsrPref
.setBrowseMode( sal_True
);
831 aUsrPref
.setBrowseMode( rDoc
.get(IDocumentSettingAccess::BROWSE_MODE
) );
833 //Fuer den BrowseMode wollen wir keinen Factor uebernehmen.
834 if( aUsrPref
.getBrowseMode() && aUsrPref
.GetZoomType() != SVX_ZOOM_PERCENT
)
836 aUsrPref
.SetZoomType( SVX_ZOOM_PERCENT
);
837 aUsrPref
.SetZoom( 100 );
839 if(pDocSh
->IsPreview())
841 aUsrPref
.SetZoomType( SVX_ZOOM_WHOLEPAGE
);
842 aUsrPref
.SetViewLayoutBookMode( false );
843 aUsrPref
.SetViewLayoutColumns( 1 );
845 m_pWrtShell
= new SwWrtShell( rDoc
, m_pEditWin
, *this, &aUsrPref
);
846 // creating an SwView from a SwPagePreView needs to
847 // add the ViewShell to the ring of the other ViewShell(s)
848 if(m_bOldShellWasPagePreView
)
850 ViewShell
& rPreviewViewShell
= *((SwPagePreView
*)pExistingSh
)->GetViewShell();
851 m_pWrtShell
->MoveTo(&rPreviewViewShell
);
852 // to update the field command et.al. if necessary
853 const SwViewOption
* pPreViewOpt
= rPreviewViewShell
.GetViewOptions();
854 if( pPreViewOpt
->IsFldName() != aUsrPref
.IsFldName() ||
855 pPreViewOpt
->IsShowHiddenField() != aUsrPref
.IsShowHiddenField() ||
856 pPreViewOpt
->IsShowHiddenPara() != aUsrPref
.IsShowHiddenPara() ||
857 pPreViewOpt
->IsShowHiddenChar() != aUsrPref
.IsShowHiddenChar() )
858 rPreviewViewShell
.ApplyViewOptions(aUsrPref
);
859 // reset design mode at draw view for form
861 if ( ((SwPagePreView
*)pExistingSh
)->ResetFormDesignMode() &&
862 m_pWrtShell
->HasDrawView() )
864 SdrView
* pDrawView
= m_pWrtShell
->GetDrawView();
865 pDrawView
->SetDesignMode( ((SwPagePreView
*)pExistingSh
)->FormDesignModeToReset() );
869 RTL_LOGFILE_CONTEXT_TRACE( aLog
, "after create WrtShell" );
871 m_pHRuler
= new SwCommentRuler(m_pWrtShell
, &GetViewFrame()->GetWindow(), m_pEditWin
,
872 SVXRULER_SUPPORT_TABS
|
873 SVXRULER_SUPPORT_PARAGRAPH_MARGINS
|
874 SVXRULER_SUPPORT_BORDERS
|
875 SVXRULER_SUPPORT_NEGATIVE_MARGINS
|
876 SVXRULER_SUPPORT_REDUCED_METRIC
,
877 GetViewFrame()->GetBindings(),
878 WB_STDRULER
| WB_EXTRAFIELD
| WB_BORDER
);
880 // assure that modified state of document
881 // isn't reset, if document is already modified.
882 const bool bIsDocModified
= m_pWrtShell
->GetDoc()->IsModified();
884 // damit unter anderem das HRuler im
885 // ReadonlyFall nicht angezeigt wird
886 aUsrPref
.SetReadonly( m_pWrtShell
->GetViewOptions()->IsReadonly() );
888 // no margin for OLE!
890 if( SFX_CREATE_MODE_EMBEDDED
!= pDocSh
->GetCreateMode() )
891 aBrwsBorder
= GetMargin();
893 m_pWrtShell
->SetBrowseBorder( aBrwsBorder
);
895 // Im CTOR duerfen keine Shell wechsel erfolgen, die muessen ueber
896 // den Timer "zwischen gespeichert" werden. Sonst raeumt der SFX
897 // sie wieder vom Stack!
898 bool bOld
= bNoInterrupt
;
901 m_pHRuler
->SetActive( sal_True
);
902 m_pVRuler
->SetActive( sal_True
);
904 SfxViewFrame
* pViewFrame
= GetViewFrame();
905 if( pViewFrame
->GetFrame().GetParentFrame())
907 aUsrPref
.SetViewHRuler(sal_False
);
908 aUsrPref
.SetViewVRuler(sal_False
);
911 StartListening( *pViewFrame
, sal_True
);
912 StartListening( *pDocSh
, sal_True
);
914 // Set Zoom-factor from HRuler
915 Fraction
aZoomFract( aUsrPref
.GetZoom(), 100 );
916 m_pHRuler
->SetZoom( aZoomFract
);
917 m_pVRuler
->SetZoom( aZoomFract
);
918 m_pHRuler
->SetDoubleClickHdl(LINK( this, SwView
, ExecRulerClick
));
919 FieldUnit eMetric
= pUsrPref
->GetHScrollMetric();
920 m_pHRuler
->SetUnit( eMetric
);
922 eMetric
= pUsrPref
->GetVScrollMetric();
923 m_pVRuler
->SetUnit( eMetric
);
925 m_pHRuler
->SetCharWidth( 371 ); // default character width
926 m_pVRuler
->SetLineHeight( 551 ); // default line height
929 pDocSh
->SetView( this );
930 SW_MOD()->SetView( this );
932 m_pPostItMgr
= new SwPostItMgr(this);
934 // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
935 // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
936 // nicht in der SFX-Verwaltung bekannt ist.
937 DocSzChgd( m_pWrtShell
->GetDocSize() );
939 // AttrChangedNotify Link setzen
940 m_pWrtShell
->SetChgLnk(LINK(this, SwView
, AttrChangedNotify
));
942 if( pDocSh
->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
&&
943 //TODO/LATER: why a cast here?
944 //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() )
945 //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False);
946 !pDocSh
->GetVisArea(ASPECT_CONTENT
).IsEmpty() )
947 SetVisArea( pDocSh
->GetVisArea(ASPECT_CONTENT
),sal_False
);
950 officecfg::Office::Common::Undo::Steps::get() <= 0,
951 "sw", "/org.openoffice.Office.Common/Undo/Steps <= 0");
952 m_pWrtShell
->DoUndo( true );
954 const sal_Bool bBrowse
= m_pWrtShell
->GetViewOptions()->getBrowseMode();
955 // Disable "multiple window"
956 SetNewWindowAllowed(!bBrowse
);
957 // End of disabled multiple window
959 m_bVScrollbarEnabled
= aUsrPref
.IsViewVScrollBar();
960 m_bHScrollbarEnabled
= aUsrPref
.IsViewHScrollBar();
961 m_pHScrollbar
->SetAuto(bBrowse
);
962 if( aUsrPref
.IsViewHRuler() )
964 if( aUsrPref
.IsViewVRuler() )
967 m_pWrtShell
->SetUIOptions( aUsrPref
);
968 m_pWrtShell
->SetReadOnlyAvailable( aUsrPref
.IsCursorInProtectedArea() );
969 m_pWrtShell
->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
971 if( m_pWrtShell
->GetDoc()->IsUpdateExpFld() )
973 if (m_pWrtShell
->GetDoc()->containsUpdatableFields())
975 SET_CURR_SHELL( m_pWrtShell
);
976 m_pWrtShell
->StartAction();
977 m_pWrtShell
->CalcLayout();
978 m_pWrtShell
->GetDoc()->UpdateFlds(NULL
, false);
979 m_pWrtShell
->EndAction();
981 m_pWrtShell
->GetDoc()->SetUpdateExpFldStat( sal_False
);
984 // ggfs. alle Verzeichnisse updaten:
985 if( m_pWrtShell
->GetDoc()->IsUpdateTOX() )
987 SfxRequest
aSfxRequest( FN_UPDATE_TOX
, SFX_CALLMODE_SLOT
, GetPool() );
988 Execute( aSfxRequest
);
989 m_pWrtShell
->GetDoc()->SetUpdateTOX( sal_False
); // wieder zurueck setzen
990 m_pWrtShell
->SttEndDoc(sal_True
);
993 // kein ResetModified, wenn es schone eine View auf dieses Doc gibt
994 SfxViewFrame
* pVFrame
= GetViewFrame();
995 SfxViewFrame
* pFirst
= SfxViewFrame::GetFirst(pDocSh
);
996 // zur Zeit(360) wird die View erst nach dem Ctor eingetragen
997 // der folgende Ausdruck funktioniert auch, wenn sich das aendert
998 // wenn per Undo nicht mehr die Modifizierung aufhebar ist,
999 // so setze das Modified NICHT zurueck.
1000 // no reset of modified state, if document
1001 // was already modified.
1002 if (!m_pWrtShell
->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
1003 ( !pFirst
|| pFirst
== pVFrame
) &&
1006 m_pWrtShell
->ResetModified();
1009 bNoInterrupt
= bOld
;
1011 // wird ein GlobalDoc neu angelegt, soll auch der Navigator erzeugt werden
1012 if( pDocSh
->IsA(SwGlobalDocShell::StaticType()) &&
1013 !pVFrame
->GetChildWindow( SID_NAVIGATOR
))
1015 SfxBoolItem
aNavi(SID_NAVIGATOR
, sal_True
);
1016 GetDispatcher().Execute(SID_NAVIGATOR
, SFX_CALLMODE_ASYNCHRON
, &aNavi
, 0L);
1019 uno::Reference
< frame::XFrame
> xFrame
= pVFrame
->GetFrame().GetFrameInterface();
1021 uno::Reference
< frame::XFrame
> xBeamerFrame
= xFrame
->findFrame(
1022 OUString("_beamer"), frame::FrameSearchFlag::CHILDREN
);
1023 if(xBeamerFrame
.is())
1025 SwDBData aData
= m_pWrtShell
->GetDBData();
1026 SW_MOD()->ShowDBObj( *this, aData
);
1029 // has anybody calls the attrchanged handler in the constructor?
1030 if( m_bAttrChgNotifiedWithRegistrations
)
1032 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1033 if( m_aTimer
.IsActive() )
1037 m_aTimer
.SetTimeoutHdl(LINK(this, SwView
, TimeoutHdl
));
1038 m_bAttrChgNotified
= m_bAttrChgNotifiedWithRegistrations
= sal_False
;
1040 pDocSh
->EnableSetModified( sal_True
);
1043 if( !m_pHScrollbar
->IsVisible( sal_True
) )
1044 ShowHScrollbar( sal_False
);
1045 if( !m_pVScrollbar
->IsVisible( sal_True
) )
1046 ShowVScrollbar( sal_False
);
1048 GetViewFrame()->GetWindow().AddChildEventListener( LINK( this, SwView
, WindowChildEventListener
) );
1053 GetViewFrame()->GetWindow().RemoveChildEventListener( LINK( this, SwView
, WindowChildEventListener
) );
1054 delete m_pPostItMgr
;
1057 m_bInDtor
= sal_True
;
1058 m_pEditWin
->Hide(); // damit kein Paint Aerger machen kann!
1059 // An der SwDocShell den Pointer auf die View ruecksetzen
1061 SwDocShell
* pDocSh
= GetDocShell();
1062 if( pDocSh
&& pDocSh
->GetView() == this )
1063 pDocSh
->SetView( 0 );
1064 if ( SW_MOD()->GetView() == this )
1065 SW_MOD()->SetView( 0 );
1067 if( m_aTimer
.IsActive() && m_bAttrChgNotifiedWithRegistrations
)
1068 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1070 // the last view must end the text edit
1071 SdrView
*pSdrView
= m_pWrtShell
? m_pWrtShell
->GetDrawView() : 0;
1072 if( pSdrView
&& pSdrView
->IsTextEdit() )
1073 pSdrView
->SdrEndTextEdit( sal_True
);
1077 m_pViewImpl
->Invalidate();
1078 EndListening(*GetViewFrame());
1079 EndListening(*GetDocShell());
1080 delete m_pScrollFill
;
1082 m_pWrtShell
= 0; // Auf 0 setzen, damit folgende DToren nicht drauf zugreifen
1084 delete m_pHScrollbar
;
1085 delete m_pVScrollbar
;
1088 delete m_pTogglePageBtn
;
1089 delete m_pPageUpBtn
;
1091 delete m_pPageDownBtn
;
1095 delete m_pFormatClipboard
;
1098 SwDocShell
* SwView::GetDocShell()
1100 SfxObjectShell
* pDocShell
= GetViewFrame()->GetObjectShell();
1101 return PTR_CAST(SwDocShell
, pDocShell
);
1104 /*--------------------------------------------------------------------
1105 Beschreibung: CursorPos merken
1106 --------------------------------------------------------------------*/
1107 void SwView::WriteUserData( String
&rUserData
, sal_Bool bBrowse
)
1109 //Das Browse-Flag wird vom Sfx durchgereicht, wenn Dokumente gebrowsed
1110 //werden (nicht zu verwechseln mit dem BrowseMode).
1111 //Die dann gespeicherten Daten sind nicht persistent!!
1113 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1114 const Rectangle
& rVis
= GetVisArea();
1116 rUserData
= OUString::number( rRect
.Left() );
1118 rUserData
+= OUString::number( rRect
.Top() );
1120 rUserData
+= OUString::number( m_pWrtShell
->GetViewOptions()->GetZoom() );
1122 rUserData
+= OUString::number( rVis
.Left() );
1124 rUserData
+= OUString::number( rVis
.Top() );
1126 rUserData
+= OUString::number( bBrowse
? SAL_MIN_INT32
: rVis
.Right());
1128 rUserData
+= OUString::number( bBrowse
? SAL_MIN_INT32
: rVis
.Bottom());
1130 rUserData
+= OUString::number(
1131 (sal_uInt16
)m_pWrtShell
->GetViewOptions()->GetZoomType());//eZoom;
1133 rUserData
+= FRMTYPE_NONE
== m_pWrtShell
->GetSelFrmType() ? '0' : '1';
1136 /*--------------------------------------------------------------------
1137 Beschreibung: CursorPos setzen
1138 --------------------------------------------------------------------*/
1139 static bool lcl_IsOwnDocument( SwView
& rView
)
1141 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
1142 rView
.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW
);
1143 uno::Reference
<document::XDocumentProperties
> xDocProps
1144 = xDPS
->getDocumentProperties();
1145 String Created
= xDocProps
->getAuthor();
1146 String Changed
= xDocProps
->getModifiedBy();
1147 String FullName
= SW_MOD()->GetUserOptions().GetFullName();
1148 return (FullName
.Len() &&
1149 (Changed
.Len() && Changed
== FullName
)) ||
1150 (!Changed
.Len() && Created
.Len() && Created
== FullName
);
1153 void SwView::ReadUserData( const String
&rUserData
, sal_Bool bBrowse
)
1155 if ( comphelper::string::getTokenCount(rUserData
, ';') > 1 &&
1156 //Fuer Dokumente ohne Layout nur im OnlineLayout oder beim
1158 (!m_pWrtShell
->IsNewLayout() || m_pWrtShell
->GetViewOptions()->getBrowseMode() || bBrowse
) )
1160 bool bIsOwnDocument
= lcl_IsOwnDocument( *this );
1162 SET_CURR_SHELL(m_pWrtShell
);
1166 // Nein, es ist *keine* gute Idee GetToken gleich im Point-Konstr.
1167 // aufzurufen, denn welcher Parameter wird zuerst ausgewertet?
1168 long nX
= rUserData
.GetToken( 0, ';', nPos
).ToInt32(),
1169 nY
= rUserData
.GetToken( 0, ';', nPos
).ToInt32();
1170 Point
aCrsrPos( nX
, nY
);
1172 sal_uInt16 nZoomFactor
=
1173 static_cast< sal_uInt16
>( rUserData
.GetToken(0, ';', nPos
).ToInt32() );
1175 long nLeft
= rUserData
.GetToken(0, ';', nPos
).ToInt32(),
1176 nTop
= rUserData
.GetToken(0, ';', nPos
).ToInt32(),
1177 nRight
= rUserData
.GetToken(0, ';', nPos
).ToInt32(),
1178 nBottom
= rUserData
.GetToken(0, ';', nPos
).ToInt32();
1180 const long nAdd
= m_pWrtShell
->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER
: DOCUMENTBORDER
*2;
1181 if ( nBottom
<= (m_pWrtShell
->GetDocSize().Height()+nAdd
) )
1183 m_pWrtShell
->EnableSmooth( sal_False
);
1185 const Rectangle
aVis( nLeft
, nTop
, nRight
, nBottom
);
1187 sal_uInt16 nOff
= 0;
1189 if( !m_pWrtShell
->GetViewOptions()->getBrowseMode() )
1190 eZoom
= (SvxZoomType
) (sal_uInt16
)rUserData
.GetToken(nOff
, ';', nPos
).ToInt32();
1193 eZoom
= SVX_ZOOM_PERCENT
;
1197 sal_Bool bSelectObj
= (0 != rUserData
.GetToken( nOff
, ';', nPos
).ToInt32())
1198 && m_pWrtShell
->IsObjSelectable( aCrsrPos
);
1200 // restore editing position
1201 m_pViewImpl
->SetRestorePosition(aCrsrPos
, bSelectObj
);
1202 // set flag value to avoid macro execution.
1203 bool bSavedFlagValue
= m_pWrtShell
->IsMacroExecAllowed();
1204 m_pWrtShell
->SetMacroExecAllowed( false );
1205 // os: changed: The user data has to be read if the view is switched back from page preview
1206 // go to the last editing position when opening own files
1207 if(m_bOldShellWasPagePreView
|| bIsOwnDocument
)
1209 m_pWrtShell
->SwCrsrShell::SetCrsr( aCrsrPos
, !bSelectObj
);
1212 m_pWrtShell
->SelectObj( aCrsrPos
);
1213 m_pWrtShell
->EnterSelFrmMode( &aCrsrPos
);
1218 m_pWrtShell
->SetMacroExecAllowed( bSavedFlagValue
);
1220 // set visible area before applying
1221 // information from print preview. Otherwise, the applied information
1223 // os: changed: The user data has to be read if the view is switched back from page preview
1224 // go to the last editing position when opening own files
1225 if(m_bOldShellWasPagePreView
|| bIsOwnDocument
)
1228 SetVisArea( aVis
.TopLeft() );
1233 //apply information from print preview - if available
1234 if( m_sNewCrsrPos
.Len() )
1236 long nXTmp
= m_sNewCrsrPos
.GetToken( 0, ';' ).ToInt32(),
1237 nYTmp
= m_sNewCrsrPos
.GetToken( 1, ';' ).ToInt32();
1238 Point
aCrsrPos2( nXTmp
, nYTmp
);
1239 bSelectObj
= m_pWrtShell
->IsObjSelectable( aCrsrPos2
);
1241 m_pWrtShell
->SwCrsrShell::SetCrsr( aCrsrPos2
, sal_False
);
1244 m_pWrtShell
->SelectObj( aCrsrPos2
);
1245 m_pWrtShell
->EnterSelFrmMode( &aCrsrPos2
);
1247 m_pWrtShell
->MakeSelVisible();
1248 m_sNewCrsrPos
.Erase();
1250 else if(USHRT_MAX
!= m_nNewPage
)
1252 m_pWrtShell
->GotoPage(m_nNewPage
, sal_True
);
1253 m_nNewPage
= USHRT_MAX
;
1258 m_pWrtShell
->StartAction();
1259 const SwViewOption
* pVOpt
= m_pWrtShell
->GetViewOptions();
1260 if( pVOpt
->GetZoom() != nZoomFactor
|| pVOpt
->GetZoomType() != eZoom
)
1261 SetZoom( eZoom
, nZoomFactor
);
1263 m_pWrtShell
->LockView( sal_True
);
1264 m_pWrtShell
->EndAction();
1265 m_pWrtShell
->LockView( sal_False
);
1266 m_pWrtShell
->EnableSmooth( sal_True
);
1271 void SwView::ReadUserDataSequence ( const uno::Sequence
< beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
1273 if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick
)
1275 bool bIsOwnDocument
= lcl_IsOwnDocument( *this );
1276 sal_Int32 nLength
= rSequence
.getLength();
1277 if (nLength
&& (!m_pWrtShell
->IsNewLayout() || m_pWrtShell
->GetViewOptions()->getBrowseMode() || bBrowse
) )
1279 SET_CURR_SHELL(m_pWrtShell
);
1280 const beans::PropertyValue
*pValue
= rSequence
.getConstArray();
1281 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1282 const Rectangle
&rVis
= GetVisArea();
1283 const SwViewOption
* pVOpt
= m_pWrtShell
->GetViewOptions();
1285 long nX
= rRect
.Left(), nY
= rRect
.Top(), nLeft
= rVis
.Left(), nTop
= rVis
.Top();
1286 long nRight
= bBrowse
? LONG_MIN
: rVis
.Right(), nBottom
= bBrowse
? LONG_MIN
: rVis
.Bottom();
1287 sal_Int16 nZoomType
= static_cast< sal_Int16
>(pVOpt
->GetZoomType());
1288 sal_Int16 nZoomFactor
= static_cast < sal_Int16
> (pVOpt
->GetZoom());
1289 bool bViewLayoutBookMode
= pVOpt
->IsViewLayoutBookMode();
1290 sal_Int16 nViewLayoutColumns
= pVOpt
->GetViewLayoutColumns();
1292 sal_Bool bSelectedFrame
= ( m_pWrtShell
->GetSelFrmType() != FRMTYPE_NONE
),
1293 bGotVisibleLeft
= sal_False
,
1294 bGotVisibleTop
= sal_False
, bGotVisibleRight
= sal_False
,
1295 bGotVisibleBottom
= sal_False
, bGotZoomType
= sal_False
,
1296 bGotZoomFactor
= sal_False
, bGotIsSelectedFrame
= sal_False
,
1297 bGotViewLayoutColumns
= sal_False
, bGotViewLayoutBookMode
= sal_False
;
1299 for (sal_Int16 i
= 0 ; i
< nLength
; i
++)
1301 if ( pValue
->Name
== "ViewLeft" )
1303 pValue
->Value
>>= nX
;
1304 nX
= MM100_TO_TWIP( nX
);
1306 else if ( pValue
->Name
== "ViewTop" )
1308 pValue
->Value
>>= nY
;
1309 nY
= MM100_TO_TWIP( nY
);
1311 else if ( pValue
->Name
== "VisibleLeft" )
1313 pValue
->Value
>>= nLeft
;
1314 nLeft
= MM100_TO_TWIP( nLeft
);
1315 bGotVisibleLeft
= sal_True
;
1317 else if ( pValue
->Name
== "VisibleTop" )
1319 pValue
->Value
>>= nTop
;
1320 nTop
= MM100_TO_TWIP( nTop
);
1321 bGotVisibleTop
= sal_True
;
1323 else if ( pValue
->Name
== "VisibleRight" )
1325 pValue
->Value
>>= nRight
;
1326 nRight
= MM100_TO_TWIP( nRight
);
1327 bGotVisibleRight
= sal_True
;
1329 else if ( pValue
->Name
== "VisibleBottom" )
1331 pValue
->Value
>>= nBottom
;
1332 nBottom
= MM100_TO_TWIP( nBottom
);
1333 bGotVisibleBottom
= sal_True
;
1335 else if ( pValue
->Name
== "ZoomType" )
1337 pValue
->Value
>>= nZoomType
;
1338 bGotZoomType
= sal_True
;
1340 else if ( pValue
->Name
== "ZoomFactor" )
1342 pValue
->Value
>>= nZoomFactor
;
1343 bGotZoomFactor
= sal_True
;
1345 else if ( pValue
->Name
== "ViewLayoutColumns" )
1347 pValue
->Value
>>= nViewLayoutColumns
;
1348 bGotViewLayoutColumns
= sal_True
;
1350 else if ( pValue
->Name
== "ViewLayoutBookMode" )
1352 bViewLayoutBookMode
= * (sal_Bool
*) pValue
->Value
.getValue();
1353 bGotViewLayoutBookMode
= sal_True
;
1355 else if ( pValue
->Name
== "IsSelectedFrame" )
1357 pValue
->Value
>>= bSelectedFrame
;
1358 bGotIsSelectedFrame
= sal_True
;
1362 if (bGotVisibleBottom
)
1364 Point
aCrsrPos( nX
, nY
);
1365 const long nAdd
= m_pWrtShell
->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER
: DOCUMENTBORDER
*2;
1366 if (nBottom
<= (m_pWrtShell
->GetDocSize().Height()+nAdd
) )
1368 m_pWrtShell
->EnableSmooth( sal_False
);
1369 const Rectangle
aVis( nLeft
, nTop
, nRight
, nBottom
);
1372 if ( !m_pWrtShell
->GetViewOptions()->getBrowseMode() )
1373 eZoom
= static_cast < SvxZoomType
> ( nZoomType
);
1376 eZoom
= SVX_ZOOM_PERCENT
;
1378 if (bGotIsSelectedFrame
)
1380 sal_Bool bSelectObj
= (sal_False
!= bSelectedFrame
)
1381 && m_pWrtShell
->IsObjSelectable( aCrsrPos
);
1383 // set flag value to avoid macro execution.
1384 bool bSavedFlagValue
= m_pWrtShell
->IsMacroExecAllowed();
1385 m_pWrtShell
->SetMacroExecAllowed( false );
1386 // os: changed: The user data has to be read if the view is switched back from page preview
1387 // go to the last editing position when opening own files
1388 m_pViewImpl
->SetRestorePosition(aCrsrPos
, bSelectObj
);
1389 if(m_bOldShellWasPagePreView
|| bIsOwnDocument
)
1391 m_pWrtShell
->SwCrsrShell::SetCrsr( aCrsrPos
, !bSelectObj
);
1393 // Update the shell to toggle Header/Footer edit if needed
1394 sal_Bool bInHeader
= sal_True
;
1395 if ( m_pWrtShell
->IsInHeaderFooter( &bInHeader
) )
1399 m_pWrtShell
->SetShowHeaderFooterSeparator( Footer
, true );
1400 m_pWrtShell
->SetShowHeaderFooterSeparator( Header
, false );
1404 m_pWrtShell
->SetShowHeaderFooterSeparator( Header
, true );
1405 m_pWrtShell
->SetShowHeaderFooterSeparator( Footer
, false );
1409 m_pWrtShell
->GetWin()->Invalidate();
1411 if ( m_pWrtShell
->IsInHeaderFooter() != m_pWrtShell
->IsHeaderFooterEdit() )
1412 m_pWrtShell
->ToggleHeaderFooterEdit();
1416 m_pWrtShell
->SelectObj( aCrsrPos
);
1417 m_pWrtShell
->EnterSelFrmMode( &aCrsrPos
);
1422 m_pWrtShell
->SetMacroExecAllowed( bSavedFlagValue
);
1426 // Set ViewLayoutSettings
1427 const bool bSetViewLayoutSettings
= bGotViewLayoutColumns
&& bGotViewLayoutBookMode
&&
1428 ( pVOpt
->GetViewLayoutColumns() != nViewLayoutColumns
|| pVOpt
->IsViewLayoutBookMode() != bViewLayoutBookMode
);
1430 const bool bSetViewSettings
= bGotZoomType
&& bGotZoomFactor
&&
1431 ( pVOpt
->GetZoom() != nZoomFactor
|| pVOpt
->GetZoomType() != eZoom
);
1433 // In case we have a 'fixed' view layout of 2 or more columns,
1434 // we have to apply the view options *before* starting the action.
1435 // Otherwsie the SetZoom function cannot work correctly, because
1436 // the view layout hasn't been calculated.
1437 const bool bZoomNeedsViewLayout
= bSetViewLayoutSettings
&&
1438 1 < nViewLayoutColumns
&&
1440 eZoom
!= SVX_ZOOM_PERCENT
;
1442 if ( !bZoomNeedsViewLayout
)
1443 m_pWrtShell
->StartAction();
1445 if ( bSetViewLayoutSettings
)
1446 SetViewLayout( nViewLayoutColumns
, bViewLayoutBookMode
, sal_True
);
1448 if ( bZoomNeedsViewLayout
)
1449 m_pWrtShell
->StartAction();
1451 if ( bSetViewSettings
)
1452 SetZoom( eZoom
, nZoomFactor
, sal_True
);
1454 // os: changed: The user data has to be read if the view is switched back from page preview
1455 // go to the last editing position when opening own files
1456 if(m_bOldShellWasPagePreView
||bIsOwnDocument
)
1458 if ( bBrowse
&& bGotVisibleLeft
&& bGotVisibleTop
)
1460 Point
aTopLeft(aVis
.TopLeft());
1461 // make sure the document is still centered
1462 const SwTwips lBorder
= IsDocumentBorder() ? DOCUMENTBORDER
: 2 * DOCUMENTBORDER
;
1463 SwTwips nEditWidth
= GetEditWin().GetOutputSize().Width();
1464 if(nEditWidth
> (m_aDocSz
.Width() + lBorder
))
1465 aTopLeft
.X() = ( m_aDocSz
.Width() + lBorder
- nEditWidth
) / 2;
1468 //check if the values are possible
1469 long nXMax
= m_pHScrollbar
->GetRangeMax() - m_pHScrollbar
->GetVisibleSize();
1470 if( aTopLeft
.X() > nXMax
)
1471 aTopLeft
.X() = nXMax
< 0 ? 0 : nXMax
;
1473 SetVisArea( aTopLeft
);
1475 else if (bGotVisibleLeft
&& bGotVisibleTop
&& bGotVisibleRight
&& bGotVisibleBottom
)
1479 m_pWrtShell
->LockView( sal_True
);
1480 m_pWrtShell
->EndAction();
1481 m_pWrtShell
->LockView( sal_False
);
1482 m_pWrtShell
->EnableSmooth( sal_True
);
1488 #define NUM_VIEW_SETTINGS 12
1489 void SwView::WriteUserDataSequence ( uno::Sequence
< beans::PropertyValue
>& rSequence
, sal_Bool bBrowse
)
1491 const SwRect
& rRect
= m_pWrtShell
->GetCharRect();
1492 const Rectangle
& rVis
= GetVisArea();
1495 rSequence
.realloc ( NUM_VIEW_SETTINGS
);
1496 sal_Int16 nIndex
= 0;
1497 beans::PropertyValue
*pValue
= rSequence
.getArray();
1499 sal_uInt16
nViewID( GetViewFrame()->GetCurViewId());
1500 pValue
->Name
= OUString( "ViewId" );
1501 OUStringBuffer
sBuffer ( OUString( "view" ) );
1502 ::sax::Converter::convertNumber(sBuffer
, static_cast<sal_Int32
>(nViewID
));
1503 pValue
->Value
<<= sBuffer
.makeStringAndClear();
1506 pValue
->Name
= OUString( "ViewLeft" );
1507 pValue
->Value
<<= TWIP_TO_MM100 ( rRect
.Left() );
1510 pValue
->Name
= OUString( "ViewTop" );
1511 pValue
->Value
<<= TWIP_TO_MM100 ( rRect
.Top() );
1514 pValue
->Name
= OUString( "VisibleLeft" );
1515 pValue
->Value
<<= TWIP_TO_MM100 ( rVis
.Left() );
1518 pValue
->Name
= OUString( "VisibleTop" );
1519 pValue
->Value
<<= TWIP_TO_MM100 ( rVis
.Top() );
1522 pValue
->Name
= OUString( "VisibleRight" );
1523 pValue
->Value
<<= TWIP_TO_MM100 ( bBrowse
? LONG_MIN
: rVis
.Right() );
1526 pValue
->Name
= OUString( "VisibleBottom" );
1527 pValue
->Value
<<= TWIP_TO_MM100 ( bBrowse
? LONG_MIN
: rVis
.Bottom() );
1530 pValue
->Name
= OUString( "ZoomType" );
1531 const sal_Int16 nZoomType
= static_cast< sal_Int16
>(m_pWrtShell
->GetViewOptions()->GetZoomType());
1532 pValue
->Value
<<= nZoomType
;
1535 pValue
->Name
= OUString( "ViewLayoutColumns" );
1536 const sal_Int16 nViewLayoutColumns
= static_cast< sal_Int16
>(m_pWrtShell
->GetViewOptions()->GetViewLayoutColumns());
1537 pValue
->Value
<<= nViewLayoutColumns
;
1540 pValue
->Name
= OUString( "ViewLayoutBookMode" );
1541 const sal_Bool bIsViewLayoutBookMode
= m_pWrtShell
->GetViewOptions()->IsViewLayoutBookMode();
1542 pValue
->Value
.setValue( &bIsViewLayoutBookMode
, ::getBooleanCppuType() );
1545 pValue
->Name
= OUString( "ZoomFactor" );
1546 pValue
->Value
<<= static_cast < sal_Int16
> (m_pWrtShell
->GetViewOptions()->GetZoom());
1549 pValue
->Name
= OUString( "IsSelectedFrame" );
1550 const sal_Bool bIsSelected
= FRMTYPE_NONE
== m_pWrtShell
->GetSelFrmType() ? sal_False
: sal_True
;
1551 pValue
->Value
.setValue ( &bIsSelected
, ::getBooleanCppuType() );
1554 if ( nIndex
< NUM_VIEW_SETTINGS
)
1555 rSequence
.realloc ( nIndex
);
1557 #undef NUM_VIEW_SETTINGS
1559 void SwView::ShowCursor( bool bOn
)
1561 //don't scroll the cursor into the visible area
1562 sal_Bool bUnlockView
= !m_pWrtShell
->IsViewLocked();
1563 m_pWrtShell
->LockView( sal_True
); //lock visible section
1566 m_pWrtShell
->HideCrsr();
1567 else if( !m_pWrtShell
->IsFrmSelected() && !m_pWrtShell
->IsObjSelected() )
1568 m_pWrtShell
->ShowCrsr();
1571 m_pWrtShell
->LockView( sal_False
);
1574 ErrCode
SwView::DoVerb( long nVerb
)
1576 if ( !GetViewFrame()->GetFrame().IsInPlace() )
1578 SwWrtShell
&rSh
= GetWrtShell();
1579 const int nSel
= rSh
.GetSelectionType();
1580 if ( nSel
& nsSelectionType::SEL_OLE
)
1581 rSh
.LaunchOLEObj( nVerb
);
1583 return ERRCODE_NONE
;
1586 /* only return sal_True for a text selection
1588 sal_Bool
SwView::HasSelection( sal_Bool bText
) const
1590 return bText
? GetWrtShell().SwCrsrShell::HasSelection()
1591 : GetWrtShell().HasSelection();
1594 String
SwView::GetSelectionText( sal_Bool bCompleteWrds
)
1596 return GetSelectionTextParam( bCompleteWrds
, sal_True
);
1599 String
SwView::GetSelectionTextParam( sal_Bool bCompleteWrds
,
1600 sal_Bool bEraseTrail
)
1603 if( bCompleteWrds
&& !GetWrtShell().HasSelection() )
1604 GetWrtShell().SelWrd();
1606 GetWrtShell().GetSelectedText( sReturn
);
1608 sReturn
= comphelper::string::stripEnd(sReturn
, ' ');
1612 SwGlossaryHdl
* SwView::GetGlosHdl()
1615 m_pGlosHdl
= new SwGlossaryHdl(GetViewFrame(), m_pWrtShell
);
1619 void SwView::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
1621 sal_Bool bCallBase
= sal_True
;
1622 if ( rHint
.ISA(SfxSimpleHint
) )
1624 sal_uInt32 nId
= ((SfxSimpleHint
&)rHint
).GetId();
1627 // sub shells will be destroyed by the
1628 // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1629 case SFX_HINT_DYING
:
1631 if ( &rBC
== GetViewFrame() )
1637 case SFX_HINT_MODECHANGED
:
1639 // Modalmodus-Umschaltung?
1640 sal_Bool bModal
= GetDocShell()->IsInModalMode();
1641 m_pHRuler
->SetActive( !bModal
);
1642 m_pVRuler
->SetActive( !bModal
);
1647 case SFX_HINT_TITLECHANGED
:
1648 if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1650 SwWrtShell
&rSh
= GetWrtShell();
1651 rSh
.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1653 if ( rSh
.GetViewOptions()->IsViewVRuler() )
1657 if ( rSh
.GetViewOptions()->IsViewHRuler() )
1661 bool bReadonly
= GetDocShell()->IsReadOnly();
1662 // if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode
1665 SwDrawDocument
* pDrawDoc
= 0;
1666 if ( 0 != ( pDrawDoc
= dynamic_cast< SwDrawDocument
* > (GetDocShell()->GetDoc()->GetDrawModel() ) ) )
1668 if( !pDrawDoc
->GetOpenInDesignMode() )
1669 break;// don't touch the design mode
1672 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !bReadonly
);
1673 GetDispatcher().Execute( SID_FM_DESIGN_MODE
, SFX_CALLMODE_ASYNCHRON
,
1678 case SW_BROADCAST_DRAWVIEWS_CREATED
:
1680 bCallBase
= sal_False
;
1681 if ( GetFormShell() )
1683 GetFormShell()->SetView(
1684 PTR_CAST(FmFormView
, GetWrtShell().GetDrawView()) );
1685 SfxBoolItem
aItem( SID_FM_DESIGN_MODE
, !GetDocShell()->IsReadOnly());
1686 GetDispatcher().Execute( SID_FM_DESIGN_MODE
, SFX_CALLMODE_SYNCHRON
,
1693 else if(rHint
.ISA(FmDesignModeChangedHint
))
1695 sal_Bool bDesignMode
= ((FmDesignModeChangedHint
&)rHint
).GetDesignMode();
1696 if (!bDesignMode
&& GetDrawFuncPtr())
1698 GetDrawFuncPtr()->Deactivate();
1699 SetDrawFuncPtr(NULL
);
1701 AttrChangedNotify(m_pWrtShell
);
1706 SfxViewShell::Notify(rBC
, rHint
);
1709 #if defined WNT || defined UNX
1711 void SwView::ScannerEventHdl( const EventObject
& /*rEventObject*/ )
1713 uno::Reference
< XScannerManager2
> xScanMgr
= SW_MOD()->GetScannerManager();
1716 const ScannerContext
aContext( xScanMgr
->getAvailableScanners().getConstArray()[ 0 ] );
1717 const ScanError eError
= xScanMgr
->getError( aContext
);
1719 if( ScanError_ScanErrorNone
== eError
)
1721 const uno::Reference
< awt::XBitmap
> xBitmap( xScanMgr
->getBitmap( aContext
) );
1725 const BitmapEx
aScanBmp( VCLUnoHelper::GetBitmap( xBitmap
) );
1729 Graphic
aGrf(aScanBmp
);
1730 m_pWrtShell
->Insert( aEmptyStr
, aEmptyStr
, aGrf
);
1735 SfxBindings
& rBind
= GetViewFrame()->GetBindings();
1736 rBind
.Invalidate( SID_TWAIN_SELECT
);
1737 rBind
.Invalidate( SID_TWAIN_TRANSFER
);
1741 void SwView::StopShellTimer()
1743 if(m_aTimer
.IsActive())
1746 if ( m_bAttrChgNotifiedWithRegistrations
)
1748 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1749 m_bAttrChgNotifiedWithRegistrations
= sal_False
;
1752 m_bAttrChgNotified
= sal_False
;
1756 sal_uInt16
SwView::PrepareClose( sal_Bool bUI
, sal_Bool bForBrowsing
)
1758 SfxViewFrame
* pVFrame
= GetViewFrame();
1759 pVFrame
->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False
);
1760 if( pVFrame
->GetDispatcher()->IsLocked() )
1761 pVFrame
->GetDispatcher()->Lock(sal_False
);
1764 if ( m_pFormShell
&&
1765 sal_True
!= (nRet
= m_pFormShell
->PrepareClose( bUI
, bForBrowsing
)) )
1770 return SfxViewShell::PrepareClose( bUI
, bForBrowsing
);
1773 // status methods for clipboard.
1774 // Status changes now notified from the clipboard.
1775 sal_Bool
SwView::IsPasteAllowed()
1777 sal_uInt16 nPasteDestination
= SwTransferable::GetSotDestination( *m_pWrtShell
);
1778 if( m_nLastPasteDestination
!= nPasteDestination
)
1780 TransferableDataHelper
aDataHelper(
1781 TransferableDataHelper::CreateFromSystemClipboard(
1783 if( aDataHelper
.GetXTransferable().is() )
1785 m_bPasteState
= SwTransferable::IsPaste( *m_pWrtShell
, aDataHelper
);
1786 m_bPasteSpecialState
= SwTransferable::IsPasteSpecial(
1787 *m_pWrtShell
, aDataHelper
);
1790 m_bPasteState
= m_bPasteSpecialState
= sal_False
;
1792 if( 0xFFFF == m_nLastPasteDestination
) // the init value
1793 m_pViewImpl
->AddClipboardListener();
1794 m_nLastPasteDestination
= nPasteDestination
;
1796 return m_bPasteState
;
1799 sal_Bool
SwView::IsPasteSpecialAllowed()
1801 if ( m_pFormShell
&& m_pFormShell
->IsActiveControl() )
1804 sal_uInt16 nPasteDestination
= SwTransferable::GetSotDestination( *m_pWrtShell
);
1805 if( m_nLastPasteDestination
!= nPasteDestination
)
1807 TransferableDataHelper
aDataHelper(
1808 TransferableDataHelper::CreateFromSystemClipboard(
1810 if( aDataHelper
.GetXTransferable().is() )
1812 m_bPasteState
= SwTransferable::IsPaste( *m_pWrtShell
, aDataHelper
);
1813 m_bPasteSpecialState
= SwTransferable::IsPasteSpecial(
1814 *m_pWrtShell
, aDataHelper
);
1817 m_bPasteState
= m_bPasteSpecialState
= sal_False
;
1819 if( 0xFFFF == m_nLastPasteDestination
) // the init value
1820 m_pViewImpl
->AddClipboardListener();
1822 return m_bPasteSpecialState
;
1825 void SwView::NotifyDBChanged()
1827 GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1830 /*--------------------------------------------------------------------
1832 --------------------------------------------------------------------*/
1833 SfxObjectShellLock
SwView::CreateTmpSelectionDoc()
1835 SwXTextView
*const pImpl
= GetViewImpl()->GetUNOObject_Impl();
1836 return pImpl
->BuildTmpSelectionDoc();
1839 void SwView::AddTransferable(SwTransferable
& rTransferable
)
1841 GetViewImpl()->AddTransferable(rTransferable
);
1846 void InitPrintOptionsFromApplication(SwPrintData
& o_rData
, bool const bWeb
)
1848 o_rData
= *SW_MOD()->GetPrtOptions(bWeb
);
1853 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */