update dev300-m58
[ooovba.git] / sw / source / ui / uiview / view.cxx
bloba4710b2061f3ed0d224e97b400f80d8efcf20505
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view.cxx,v $
10 * $Revision: 1.112.94.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
37 #include <stdlib.h>
38 #include <hintids.hxx>
39 #include <rtl/logfile.hxx>
40 #include <vcl/graph.hxx>
41 #include <vcl/inputctx.hxx>
42 #include <basic/sbxobj.hxx>
43 #include <svtools/eitem.hxx>
44 #include <svtools/undoopt.hxx>
45 #include <svtools/lingucfg.hxx>
46 #include <svtools/printdlg.hxx>
47 #include <svtools/useroptions.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/docfile.hxx>
51 #include <sfx2/printer.hxx>
52 #include <sfx2/app.hxx>
53 #include <svx/ruler.hxx>
54 #include <svx/protitem.hxx>
55 #include <svx/fmshell.hxx>
56 #include <svx/extrusionbar.hxx>
57 #include <svx/fontworkbar.hxx>
58 #include <unotxvw.hxx>
59 #include <cmdid.h>
60 #include <swhints.hxx>
61 #include <swmodule.hxx>
62 #include <inputwin.hxx>
63 #include <chartins.hxx>
64 #include <uivwimp.hxx>
65 #include <uitool.hxx>
66 #include <edtwin.hxx>
67 #include <textsh.hxx>
68 #include <listsh.hxx>
69 #include <tabsh.hxx>
70 #include <grfsh.hxx>
71 #include <mediash.hxx>
72 #include <docsh.hxx>
73 #include <frmsh.hxx>
74 #include <olesh.hxx>
75 #include <drawsh.hxx>
76 #include <drawbase.hxx>
77 #include <drformsh.hxx>
78 #include <drwtxtsh.hxx>
79 #include <beziersh.hxx>
80 #include <globdoc.hxx>
81 #include <scroll.hxx>
82 #include <globdoc.hxx>
83 #include <navipi.hxx>
84 #include <gloshdl.hxx>
85 #include <usrpref.hxx>
86 #include <srcview.hxx>
87 #include <doc.hxx>
88 #include <drawdoc.hxx>
89 #include <wdocsh.hxx>
90 #include <wview.hxx>
91 #include <workctrl.hxx>
92 #include <wrtsh.hxx>
93 #include <barcfg.hxx>
94 #include <pview.hxx>
95 #include <swdtflvr.hxx>
96 #include <view.hrc>
97 #include <globdoc.hrc>
98 #include <frmui.hrc>
99 #include <cfgitems.hxx>
100 #include <prtopt.hxx>
101 #include <swprtopt.hxx>
102 #include <linguistic/lngprops.hxx>
103 #include <svx/unolingu.hxx>
104 //#include <sfx2/app.hxx>
105 #include <com/sun/star/frame/FrameSearchFlag.hpp>
106 #include <com/sun/star/scanner/ScannerContext.hpp>
107 #include <com/sun/star/scanner/XScannerManager.hpp>
108 #include <toolkit/unohlp.hxx>
109 #include <rtl/ustrbuf.hxx>
110 #include <xmloff/xmluconv.hxx>
112 #include "formatclipboard.hxx"
113 #include <PostItMgr.hxx>
114 #include <annotsh.hxx>
116 #include <fldbas.hxx>
118 #include <unomid.h>
120 #include <com/sun/star/document/XDocumentProperties.hpp>
121 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
123 #ifndef _SVTOOLS_CJKOPTIONS_HXX
124 #include <svtools/cjkoptions.hxx>
125 #endif
128 using namespace ::com::sun::star;
129 using namespace ::com::sun::star::uno;
130 using namespace ::com::sun::star::lang;
131 using namespace ::com::sun::star::scanner;
132 using ::rtl::OUString;
133 using ::rtl::OUStringBuffer;
136 extern sal_Bool bNoInterrupt; // in mainwn.cxx
138 #define SWVIEWFLAGS ( SFX_VIEW_MAXIMIZE_FIRST| \
139 SFX_VIEW_OBJECTSIZE_EMBEDDED| \
140 SFX_VIEW_CAN_PRINT| \
141 SFX_VIEW_HAS_PRINTOPTIONS)
143 //MA 06. Nov. 95: Each raus in Absprache mit MI wg. Bug 21523
144 // SFX_VIEW_OPTIMIZE_EACH|
146 /*--------------------------------------------------------------------
147 Beschreibung: Statics
148 --------------------------------------------------------------------*/
150 int bDocSzUpdated = 1;
152 SvxSearchItem* SwView::pSrchItem = 0;
154 sal_uInt16 SwView::nInsertCtrlState = FN_INSERT_TABLE;
155 sal_uInt16 SwView::nWebInsertCtrlState = FN_INSERT_TABLE;
156 sal_uInt16 SwView::nInsertObjectCtrlState = SID_INSERT_DIAGRAM;
158 sal_Bool SwView::bExtra = sal_False;
159 sal_Bool SwView::bFound = sal_False;
160 sal_Bool SwView::bJustOpened = sal_False;
163 SvxSearchDialog* SwView::pSrchDlg = 0;
164 SearchAttrItemList* SwView::pSrchList = 0;
165 SearchAttrItemList* SwView::pReplList = 0;
167 DBG_NAME(viewhdl)
169 /*--------------------------------------------------------------------
170 Beschreibung:
171 --------------------------------------------------------------------*/
173 inline SfxDispatcher &SwView::GetDispatcher()
175 return *GetViewFrame()->GetDispatcher();
178 /*--------------------------------------------------------------------
179 Beschreibung:
180 --------------------------------------------------------------------*/
182 void SwView::ImpSetVerb( int nSelType )
184 sal_Bool bResetVerbs = bVerbsActive;
185 if ( !GetViewFrame()->GetFrame()->IsInPlace() &&
186 (nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF) & nSelType )
188 if ( !pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT) )
190 if ( nSelType & nsSelectionType::SEL_OLE )
192 SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
193 bVerbsActive = sal_True;
194 bResetVerbs = sal_False;
198 if ( bResetVerbs )
200 SetVerbs( 0 );
201 bVerbsActive = sal_False;
205 /*--------------------------------------------------------------------
206 Description:
207 called by the SwEditWin when it gets the focus
208 --------------------------------------------------------------------*/
210 void SwView::GotFocus() const
212 // if we got the focus, and the form shell *is* on the top of the dispatcher
213 // stack, then we need to rebuild the stack (the form shell doesn't belong to
214 // the top then)
215 const SfxDispatcher& rDispatcher = const_cast< SwView* >( this )->GetDispatcher();
216 SfxShell* pTopShell = rDispatcher.GetShell( 0 );
217 FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
218 if ( pAsFormShell )
220 pAsFormShell->ForgetActiveControl();
221 const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
223 else if ( mpPostItMgr )
225 SwAnnotationShell* pAsAnnotationShell = PTR_CAST( SwAnnotationShell, pTopShell );
226 if ( pAsAnnotationShell )
228 mpPostItMgr->SetActivePostIt(0);
229 const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
234 /*--------------------------------------------------------------------
235 Description:
236 called by the FormShell when a form control is focused. This is
237 a request to put the form shell on the top of the dispatcher
238 stack
239 --------------------------------------------------------------------*/
241 IMPL_LINK( SwView, FormControlActivated, FmFormShell*, EMPTYARG )
243 // if a form control has been activated, and the form shell is not on the top
244 // of the dispatcher stack, then we need to activate it
245 const SfxDispatcher& rDispatcher = GetDispatcher();
246 const SfxShell* pTopShell = rDispatcher.GetShell( 0 );
247 const FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
248 if ( !pAsFormShell )
250 // if we're editing text currently, cancel this
251 SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : NULL;
252 if ( pSdrView && pSdrView->IsTextEdit() )
253 pSdrView->SdrEndTextEdit( sal_True );
255 const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
258 return 0L;
261 void SwView::SelectShell()
263 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
265 // Achtung: SelectShell fuer die WebView mitpflegen
267 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
269 if(bInDtor)
270 return;
271 // Entscheidung, ob UpdateTable gerufen werden muss
272 sal_Bool bUpdateTable = sal_False;
273 const SwFrmFmt* pCurTableFmt = pWrtShell->GetTableFmt();
274 if(pCurTableFmt && pCurTableFmt != pLastTableFormat)
276 bUpdateTable = sal_True; // kann erst spaeter ausgefuehrt werden
278 pLastTableFormat = pCurTableFmt;
280 //SEL_TBL und SEL_TBL_CELLS koennen verodert sein!
281 int nNewSelectionType = (pWrtShell->GetSelectionType()
282 & ~nsSelectionType::SEL_TBL_CELLS);
284 if ( pFormShell && pFormShell->IsActiveControl() )
285 nNewSelectionType |= nsSelectionType::SEL_FOC_FRM_CTRL;
287 if ( nNewSelectionType == nSelectionType )
289 GetViewFrame()->GetBindings().InvalidateAll( sal_False );
290 if ( nSelectionType & nsSelectionType::SEL_OLE ||
291 nSelectionType & nsSelectionType::SEL_GRF )
292 //Fuer Grafiken und OLE kann sich natuerlich das Verb aendern!
293 ImpSetVerb( nNewSelectionType );
295 else
298 SfxDispatcher &rDispatcher = GetDispatcher();
299 SwToolbarConfigItem *pBarCfg = SW_MOD()->GetToolbarConfig();
301 // DELETEZ(pxSelectionObj); //Selektionsobjekt loeschen
302 if ( pShell )
304 rDispatcher.Flush(); // alle gecachten Shells wirklich loeschen
306 //Zur alten Selektion merken welche Toolbar sichtbar war
307 USHORT nId = static_cast< USHORT >( rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT ));
308 if ( nId )
309 pBarCfg->SetTopToolbar( nSelectionType, nId );
311 SfxShell *pSfxShell;
312 for ( sal_uInt16 i = 0; sal_True; ++i )
314 pSfxShell = rDispatcher.GetShell( i );
315 if ( pSfxShell->ISA( SwBaseShell )
316 || pSfxShell->ISA( SwDrawTextShell )
317 || pSfxShell->ISA( svx::ExtrusionBar )
318 || pSfxShell->ISA( svx::FontworkBar )
319 || pSfxShell->ISA( SwAnnotationShell )
322 rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_DELETE );
324 else if ( pSfxShell->ISA( FmFormShell ) )
326 rDispatcher.Pop( *pSfxShell );
328 else
329 break;
333 BOOL bInitFormShell = sal_False;
334 if (!pFormShell)
336 bInitFormShell = sal_True;
337 pFormShell = new FmFormShell( this );
338 pFormShell->SetControlActivationHandler( LINK( this, SwView, FormControlActivated ) );
339 StartListening(*pFormShell);
342 BOOL bSetExtInpCntxt = sal_False;
343 nSelectionType = nNewSelectionType;
344 ShellModes eShellMode;
346 if ( !( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) )
347 rDispatcher.Push( *pFormShell );
349 if ( nSelectionType & nsSelectionType::SEL_OLE )
351 eShellMode = SHELL_MODE_OBJECT;
352 pShell = new SwOleShell( *this );
353 rDispatcher.Push( *pShell );
355 else if ( nSelectionType & nsSelectionType::SEL_FRM
356 || nSelectionType & nsSelectionType::SEL_GRF)
358 eShellMode = SHELL_MODE_FRAME;
359 pShell = new SwFrameShell( *this );
360 rDispatcher.Push( *pShell );
361 if(nSelectionType & nsSelectionType::SEL_GRF )
363 eShellMode = SHELL_MODE_GRAPHIC;
364 pShell = new SwGrfShell( *this );
365 rDispatcher.Push( *pShell );
368 else if ( nSelectionType & nsSelectionType::SEL_DRW )
370 eShellMode = SHELL_MODE_DRAW;
371 pShell = new SwDrawShell( *this );
372 rDispatcher.Push( *pShell );
374 if ( nSelectionType & nsSelectionType::SEL_BEZ )
376 eShellMode = SHELL_MODE_BEZIER;
377 pShell = new SwBezierShell( *this );
378 rDispatcher.Push( *pShell );
380 else if( nSelectionType & nsSelectionType::SEL_MEDIA )
382 eShellMode = SHELL_MODE_MEDIA;
383 pShell = new SwMediaShell( *this );
384 rDispatcher.Push( *pShell );
387 if (nSelectionType & nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE)
389 eShellMode = SHELL_MODE_EXTRUDED_CUSTOMSHAPE;
390 pShell = new svx::ExtrusionBar(this);
391 rDispatcher.Push( *pShell );
393 if (nSelectionType & nsSelectionType::SEL_FONTWORK)
395 eShellMode = SHELL_MODE_FONTWORK;
396 pShell = new svx::FontworkBar(this);
397 rDispatcher.Push( *pShell );
400 else if ( nSelectionType & nsSelectionType::SEL_DRW_FORM )
402 eShellMode = SHELL_MODE_DRAW_FORM;
403 pShell = new SwDrawFormShell( *this );
405 rDispatcher.Push( *pShell );
407 else if ( nSelectionType & nsSelectionType::SEL_DRW_TXT )
409 bSetExtInpCntxt = sal_True;
410 eShellMode = SHELL_MODE_DRAWTEXT;
411 rDispatcher.Push( *(new SwBaseShell( *this )) );
412 pShell = new SwDrawTextShell( *this );
413 rDispatcher.Push( *pShell );
415 else if ( nSelectionType & nsSelectionType::SEL_POSTIT )
417 eShellMode = SHELL_MODE_POSTIT;
418 pShell = new SwAnnotationShell( *this );
419 rDispatcher.Push( *pShell );
421 else
423 bSetExtInpCntxt = sal_True;
424 eShellMode = SHELL_MODE_TEXT;
425 sal_uInt32 nHelpId = 0;
426 if ( nSelectionType & nsSelectionType::SEL_NUM )
428 eShellMode = SHELL_MODE_LIST_TEXT;
429 pShell = new SwListShell( *this );
430 nHelpId = pShell->GetHelpId();
431 rDispatcher.Push( *pShell );
433 pShell = new SwTextShell(*this);
434 if(nHelpId)
435 pShell->SetHelpId(nHelpId);
436 rDispatcher.Push( *pShell );
437 if ( nSelectionType & nsSelectionType::SEL_TBL )
439 eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
440 : SHELL_MODE_TABLE_TEXT;
441 pShell = new SwTableShell( *this );
442 rDispatcher.Push( *pShell );
446 if ( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL )
447 rDispatcher.Push( *pFormShell );
449 pViewImpl->SetShellMode(eShellMode);
450 ImpSetVerb( nSelectionType );
452 if( !GetDocShell()->IsReadOnly() )
454 if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
455 bSetExtInpCntxt = sal_False;
457 InputContext aCntxt( GetEditWin().GetInputContext() );
458 aCntxt.SetOptions( bSetExtInpCntxt
459 ? (aCntxt.GetOptions() |
460 ( INPUTCONTEXT_TEXT |
461 INPUTCONTEXT_EXTTEXTINPUT ))
462 : (aCntxt.GetOptions() & ~
463 ( INPUTCONTEXT_TEXT |
464 INPUTCONTEXT_EXTTEXTINPUT )) );
465 GetEditWin().SetInputContext( aCntxt );
468 //Zur neuen Selektion die Toolbar aktivieren, die auch beim letzten Mal
469 //aktiviert war
470 //Vorher muss ein Flush() sein, betrifft aber lt. MBA nicht das UI und ist
471 //kein Performance-Problem
472 // TODO/LATER: maybe now the Flush() command is superfluous?!
473 rDispatcher.Flush();
475 Point aPnt = GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
476 aPnt = GetEditWin().PixelToLogic(aPnt);
477 GetEditWin().UpdatePointer(aPnt);
479 SdrView* pDView = GetWrtShell().GetDrawView();
480 if ( bInitFormShell && pDView )
481 pFormShell->SetView(PTR_CAST(FmFormView, pDView));
484 //Guenstiger Zeitpunkt fuer die Kommunikation mit OLE-Objekten?
485 if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
486 GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
488 //jetzt das Tabellen-Update
489 if(bUpdateTable)
490 pWrtShell->UpdateTable();
492 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
495 //Zusammenspiel: AttrChangedNotify() und TimeoutHdl.
496 //Falls noch Actions offen sind keine Aktualisierung, da der
497 //Cursor auf der Core-Seite im Wald stehen kann.
498 //Da wir aber keine Stati mehr liefern koennen und wollen locken wir
499 //stattdessen den Dispatcher.
503 extern "C"
505 int lcl_CmpIds( const void *pFirst, const void *pSecond)
507 return (*(sal_uInt16*)pFirst) - (*(sal_uInt16*)pSecond);
513 IMPL_LINK( SwView, AttrChangedNotify, SwWrtShell *, EMPTYARG )
515 if ( GetEditWin().IsChainMode() )
516 GetEditWin().SetChainMode( sal_False );
518 //Opt: Nicht wenn PaintLocked. Beim Unlock wird dafuer nocheinmal ein
519 //Notify ausgeloest.
520 if( !pWrtShell->IsPaintLocked() && !bNoInterrupt &&
521 GetDocShell()->IsReadOnly() )
522 _CheckReadonlyState();
524 // JP 19.01.99: Cursor in Readonly Bereichen
525 if( !pWrtShell->IsPaintLocked() && !bNoInterrupt )
526 _CheckReadonlySelection();
528 if( !bAttrChgNotified )
530 if ( pWrtShell->BasicActionPend() || bNoInterrupt ||
531 GetDispatcher().IsLocked() || //do not confuse the SFX
532 GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
534 bAttrChgNotified = sal_True;
535 aTimer.Start();
537 const SfxPoolItem *pItem;
538 if ( SFX_ITEM_SET != GetObjectShell()->GetMedium()->GetItemSet()->
539 GetItemState( SID_HIDDEN, sal_False, &pItem ) ||
540 !((SfxBoolItem*)pItem)->GetValue() )
542 GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
543 bAttrChgNotifiedWithRegistrations = sal_True;
547 else
548 SelectShell();
552 //#i6193#, change ui if cursor is at a SwPostItField
553 if (mpPostItMgr)
555 // --> OD 2008-06-19 #i90516#
556 // only perform the code that is needed to determine, if at the
557 // actual cursor position is a post-it field
558 // SwRect aFldRect;
559 // SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
560 // if( pWrtShell->GetContentAtPos( pWrtShell->GetCrsrDocPos(), aCntntAtPos, FALSE, &aFldRect ) )
561 // {
562 // const SwField* pFld = aCntntAtPos.aFnd.pFld;
563 // if (pFld->Which()== RES_POSTITFLD)
564 // {
565 // mpPostItMgr->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld));
566 // }
567 // else
568 // mpPostItMgr->SetShadowState(0);
569 // }
570 // else
571 // mpPostItMgr->SetShadowState(0);
572 mpPostItMgr->SetShadowState( pWrtShell->GetPostItFieldAtCursor() );
575 return 0;
580 IMPL_LINK( SwView, TimeoutHdl, Timer *, EMPTYARG )
582 DBG_PROFSTART(viewhdl);
584 if( pWrtShell->BasicActionPend() || bNoInterrupt )
586 aTimer.Start();
587 DBG_PROFSTOP(viewhdl);
588 return 0;
591 if ( bAttrChgNotifiedWithRegistrations )
593 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
594 bAttrChgNotifiedWithRegistrations = sal_False;
597 _CheckReadonlyState();
598 _CheckReadonlySelection();
600 BOOL bOldUndo = pWrtShell->DoesUndo();
601 pWrtShell->DoUndo( FALSE );
602 SelectShell();
603 pWrtShell->DoUndo( bOldUndo );
604 bAttrChgNotified = sal_False;
605 GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
607 DBG_PROFSTOP(viewhdl);
608 return 0;
611 void SwView::_CheckReadonlyState()
613 SfxDispatcher &rDis = GetDispatcher();
614 //Um erkennen zu koennen ob bereits disabled ist!
615 SfxItemState eStateRO, eStateProtAll;
616 const SfxPoolItem *pItem;
617 // JP 29.04.97: von einem nur uns bekannten Slot den Status abfragen.
618 // Ansonsten kennen andere den Slot; wie z.B. die BasidIde
619 eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem );
620 eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem );
621 sal_Bool bChgd = sal_False;
623 if ( !pWrtShell->IsCrsrReadonly() )
625 static sal_uInt16 aROIds[] =
627 SID_DELETE, FN_BACKSPACE, FN_SHIFT_BACKSPACE,
628 SID_UNDO,
629 SID_REDO, SID_REPEAT, SID_PASTE,
630 SID_PASTE_UNFORMATTED,
631 FN_PASTESPECIAL, SID_SBA_BRW_INSERT,
632 SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK,
633 SID_CHARMAP, FN_INSERT_SOFT_HYPHEN,
634 FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_BREAK,
635 FN_INSERT_LINEBREAK, FN_INSERT_COLUMN_BREAK, FN_INSERT_BREAK_DLG,
636 FN_DELETE_SENT, FN_DELETE_BACK_SENT, FN_DELETE_WORD,
637 FN_DELETE_BACK_WORD, FN_DELETE_LINE, FN_DELETE_BACK_LINE,
638 FN_DELETE_PARA, FN_DELETE_BACK_PARA, FN_DELETE_WHOLE_LINE,
639 FN_CALCULATE, FN_FORMAT_RESET,
640 FN_POSTIT, FN_JAVAEDIT, SID_ATTR_PARA_ADJUST_LEFT,
641 SID_ATTR_PARA_ADJUST_RIGHT, SID_ATTR_PARA_ADJUST_CENTER,SID_ATTR_PARA_ADJUST_BLOCK,
642 SID_ATTR_PARA_LINESPACE_10, SID_ATTR_PARA_LINESPACE_15, SID_ATTR_PARA_LINESPACE_20,
643 SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_COLOR_BACKGROUND,
644 SID_ATTR_CHAR_COLOR_BACKGROUND_EXT, SID_ATTR_CHAR_COLOR_EXT,
645 SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_WEIGHT, SID_ATTR_CHAR_POSTURE,
646 SID_ATTR_CHAR_OVERLINE,
647 SID_ATTR_CHAR_UNDERLINE, SID_ATTR_FLASH, SID_ATTR_CHAR_STRIKEOUT,
648 FN_UNDERLINE_DOUBLE, SID_ATTR_CHAR_CONTOUR, SID_ATTR_CHAR_SHADOWED,
649 SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_ESCAPEMENT, FN_SET_SUPER_SCRIPT,
650 FN_SET_SUB_SCRIPT, SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_LANGUAGE,
651 SID_ATTR_CHAR_KERNING, SID_CHAR_DLG, SID_ATTR_CHAR_WORDLINEMODE,
652 FN_GROW_FONT_SIZE, FN_SHRINK_FONT_SIZE, FN_TXTATR_INET,
653 FN_FORMAT_DROPCAPS, SID_ATTR_PARA_ADJUST, SID_ATTR_PARA_LINESPACE,
654 SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_KEEP, SID_ATTR_PARA_WIDOWS,
655 SID_ATTR_PARA_ORPHANS,
656 SID_ATTR_PARA_MODEL, SID_PARA_DLG,
657 FN_SELECT_PARA, SID_DEC_INDENT,
658 SID_INC_INDENT
660 static sal_Bool bFirst = sal_True;
661 if ( bFirst )
663 qsort( (void*)aROIds, sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
664 bFirst = sal_False;
666 if ( SFX_ITEM_DISABLED == eStateRO )
668 rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
669 bChgd = sal_True;
672 else if( pWrtShell->IsAllProtect() )
674 if ( SFX_ITEM_DISABLED == eStateProtAll )
676 static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC, FN_EDIT_REGION };
677 static sal_Bool bAllProtFirst = sal_True;
678 if ( bAllProtFirst )
680 qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
681 bAllProtFirst = sal_False;
683 rDis.SetSlotFilter( sal_Bool(2),
684 sizeof(aAllProtIds)/sizeof(sal_uInt16),
685 aAllProtIds );
686 bChgd = sal_True;
689 else if ( SFX_ITEM_DISABLED != eStateRO ||
690 SFX_ITEM_DISABLED != eStateProtAll )
692 bChgd = sal_True;
693 rDis.SetSlotFilter();
695 if ( bChgd )
696 GetViewFrame()->GetBindings().InvalidateAll(sal_True);
699 void SwView::_CheckReadonlySelection()
701 sal_uInt32 nDisableFlags = 0;
702 SfxDispatcher &rDis = GetDispatcher();
704 if( pWrtShell->HasReadonlySel() &&
705 ( !pWrtShell->GetDrawView() ||
706 !pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
707 nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR;
709 if( (SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags ) !=
710 (SW_DISABLE_ON_PROTECTED_CURSOR & rDis.GetDisableFlags() ) )
712 // zusaetzlich am Window den InputContext umsetzen, damit in
713 // japanischen / chinesischen Versionen die externe Eingabe
714 // ab-/angeschaltet wird. Das aber nur wenn auch die richtige
715 // Shell auf dem Stack steht.
716 switch( pViewImpl->GetShellMode() )
718 case SHELL_MODE_TEXT:
719 case SHELL_MODE_LIST_TEXT:
720 case SHELL_MODE_TABLE_TEXT:
721 case SHELL_MODE_TABLE_LIST_TEXT:
723 //JP 22.01.99: temporaere Loesung!!! Sollte bei jeder Cursorbewegung
724 // den Font von der akt. Einfuegeposition setzen, also ausserhalb
725 // dieses if's. Aber TH wertet den Font zur Zeit nicht aus und
726 // das besorgen erscheint mir hier zu teuer zu sein.
727 // Ausserdem haben wir keinen Font, sondern nur Attribute aus denen
728 // die Textformatierung dann den richtigen Font zusammen baut.
730 InputContext aCntxt( GetEditWin().GetInputContext() );
731 aCntxt.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags
732 ? (aCntxt.GetOptions() & ~
733 ( INPUTCONTEXT_TEXT |
734 INPUTCONTEXT_EXTTEXTINPUT ))
735 : (aCntxt.GetOptions() |
736 ( INPUTCONTEXT_TEXT |
737 INPUTCONTEXT_EXTTEXTINPUT )) );
738 GetEditWin().SetInputContext( aCntxt );
740 break;
741 default:
747 if( nDisableFlags != rDis.GetDisableFlags() )
749 rDis.SetDisableFlags( nDisableFlags );
750 GetViewFrame()->GetBindings().InvalidateAll( sal_True );
755 SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
756 : SfxViewShell( _pFrame, SWVIEWFLAGS ),
758 aPageStr( SW_RES( STR_PAGE )),
759 nNewPage(USHRT_MAX),
760 pNumRuleNodeFromDoc(0), // #i23726#
761 pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ),
762 pWrtShell(0),
763 pShell(0),
764 pFormShell(0),
765 pHScrollbar(0),
766 pVScrollbar(0),
767 pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame()->GetParentFrame() ? 0 : WB_SIZEABLE )),
768 pHRuler( new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
769 SVXRULER_SUPPORT_TABS |
770 SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
771 SVXRULER_SUPPORT_BORDERS |
772 SVXRULER_SUPPORT_NEGATIVE_MARGINS|
773 SVXRULER_SUPPORT_REDUCED_METRIC,
774 GetViewFrame()->GetBindings(),
775 WB_STDRULER | WB_EXTRAFIELD | WB_BORDER)),
776 pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
777 SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL|
778 SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC,
779 GetViewFrame()->GetBindings(),
780 WB_VSCROLL | WB_EXTRAFIELD | WB_BORDER )),
781 pTogglePageBtn(0),
782 pPageUpBtn(0),
783 pPageDownBtn(0),
784 pNaviBtn(0),
785 pGlosHdl(0),
786 pDrawActual(0),
787 pLastTableFormat(0),
788 pFormatClipboard(new SwFormatClipboard()),
789 mpPostItMgr(0),
790 nSelectionType( INT_MAX ),
791 nPageCnt(0),
792 nDrawSfxId( USHRT_MAX ),
793 nFormSfxId( USHRT_MAX ),
794 nLastPasteDestination( 0xFFFF ),
795 nLeftBorderDistance( 0 ),
796 nRightBorderDistance( 0 ),
797 bInMailMerge(FALSE),
798 bInDtor(FALSE),
799 bOldShellWasPagePreView(FALSE)
801 // OD 18.12.2002 #103492# - According to discussion with MBA and further
802 // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
803 // if function "New Window" is performed to open an additional view beside
804 // an already existing one.
805 // If the view is switch from one to another, the 'old' view is given by
806 // parameter <pOldSh>.
808 RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwView::SwView" );
810 bCenterCrsr = bTopCrsr = bAllwaysShowSel = bTabColFromDoc = bTabRowFromDoc =
811 bSetTabColFromDoc = bSetTabRowFromDoc = bAttrChgNotified = bAttrChgNotifiedWithRegistrations =
812 bVerbsActive = bDrawRotate = bInOuterResizePixel = bInInnerResizePixel =
813 bPasteState = bPasteSpecialState = bMakeSelectionVisible = sal_False;
815 bShowAtResize = bDrawSelMode = bDocSzUpdated = sal_True;
817 _CreateScrollbar( TRUE );
818 _CreateScrollbar( FALSE );
820 pViewImpl = new SwView_Impl(this);
821 SetName(C2S("View"));
822 SetWindow( pEditWin );
824 aTimer.SetTimeout( 120 );
826 SwDocShell* pDocSh = PTR_CAST( SwDocShell, _pFrame->GetObjectShell() );
827 BOOL bOldModifyFlag = pDocSh->IsEnableSetModified();
828 if(bOldModifyFlag)
829 pDocSh->EnableSetModified( sal_False );
830 ASSERT( pDocSh, "View ohne DocShell." );
831 SwWebDocShell* pWebDShell = PTR_CAST( SwWebDocShell, pDocSh );
833 const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != pWebDShell);
834 SwViewOption aUsrPref( *pUsrPref);
836 //! get lingu options without loading lingu DLL
837 SvtLinguOptions aLinguOpt;
839 SvtLinguConfig().GetOptions( aLinguOpt );
841 aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );
843 sal_Bool bOldShellWasSrcView = FALSE;
845 // OD 18.12.2002 #103492# - determine, if there is an existing view for
846 // document
847 SfxViewShell* pExistingSh = 0;
848 if ( pOldSh )
849 pExistingSh = pOldSh;
850 else
852 SfxViewFrame *pF = SfxViewFrame::GetFirst( pDocSh );
853 if( pF == _pFrame )
854 pF = SfxViewFrame::GetNext( *pF, pDocSh );
855 if( pF )
856 pExistingSh = pF->GetViewShell();
859 // determine type of existing view
860 if( pExistingSh &&
861 pExistingSh->IsA( TYPE( SwPagePreView ) ) )
863 sSwViewData = ((SwPagePreView*)pExistingSh)->GetPrevSwViewData();
864 sNewCrsrPos = ((SwPagePreView*)pExistingSh)->GetNewCrsrPos();
865 nNewPage = ((SwPagePreView*)pExistingSh)->GetNewPage();
866 bOldShellWasPagePreView = TRUE;
868 else if( pExistingSh &&
869 pExistingSh->IsA( TYPE( SwSrcView ) ) )
870 bOldShellWasSrcView = TRUE;
872 RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create WrtShell" );
873 if(PTR_CAST( SwView, pExistingSh))
875 pWrtShell = new SwWrtShell( *((SwView*)pExistingSh)->pWrtShell,
876 pEditWin, *this);
877 //MA: Das kann doch nur zu einem GPF fuehren!
878 // nSelectionType = ((SwView*)pOldSh)->nSelectionType;
880 else
882 SwDoc& rDoc = *((SwDocShell*)pDocSh)->GetDoc();
884 if( !bOldShellWasSrcView && pWebDShell && !bOldShellWasPagePreView )
885 rDoc.set(IDocumentSettingAccess::BROWSE_MODE, true);
887 //Fuer den BrowseMode wollen wir keinen Factor uebernehmen.
888 if( rDoc.get(IDocumentSettingAccess::BROWSE_MODE) && aUsrPref.GetZoomType() != SVX_ZOOM_PERCENT )
890 aUsrPref.SetZoomType( SVX_ZOOM_PERCENT );
891 aUsrPref.SetZoom( 100 );
893 if(pDocSh->IsPreview())
895 aUsrPref.SetZoomType( SVX_ZOOM_WHOLEPAGE );
896 aUsrPref.SetViewLayoutBookMode( false );
897 aUsrPref.SetViewLayoutColumns( 1 );
899 pWrtShell = new SwWrtShell( rDoc, pEditWin, *this, &aUsrPref );
900 //#97610# creating an SwView from a SwPagePreView needs to
901 // add the ViewShell to the ring of the other ViewShell(s)
902 if(bOldShellWasPagePreView)
904 ViewShell& rPreviewViewShell = *((SwPagePreView*)pExistingSh)->GetViewShell();
905 pWrtShell->MoveTo(&rPreviewViewShell);
906 //#95521# to update the field command et.al. if necessary
907 const SwViewOption* pPreViewOpt = rPreviewViewShell.GetViewOptions();
908 if( pPreViewOpt->IsFldName() != aUsrPref.IsFldName() ||
909 pPreViewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() ||
910 pPreViewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() ||
911 pPreViewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() )
912 rPreviewViewShell.ApplyViewOptions(aUsrPref);
913 // OD 09.01.2003 #106334# - reset design mode at draw view for form
914 // shell, if needed.
915 if ( ((SwPagePreView*)pExistingSh)->ResetFormDesignMode() &&
916 pWrtShell->HasDrawView() )
918 SdrView* pDrawView = pWrtShell->GetDrawView();
919 pDrawView->SetDesignMode( ((SwPagePreView*)pExistingSh)->FormDesignModeToReset() );
923 RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create WrtShell" );
925 // --> OD 2005-02-11 #i38810# - assure that modified state of document
926 // isn't reset, if document is already modified.
927 const bool bIsDocModified = pWrtShell->GetDoc()->IsModified();
928 // <--
930 // JP 05.02.99: Bug 61495 - damit unter anderem das HLineal im
931 // ReadonlyFall nicht angezeigt wird
932 aUsrPref.SetReadonly( pWrtShell->GetViewOptions()->IsReadonly() );
934 //Kein Margin fuer OLE!
935 Size aBrwsBorder;
936 if( SFX_CREATE_MODE_EMBEDDED != pDocSh->GetCreateMode() )
937 aBrwsBorder = GetMargin();
939 if( _pFrame->GetFrameType() & SFXFRAME_INTERNAL )
940 pWrtShell->SetFrameView( aBrwsBorder );
941 else
942 pWrtShell->SetBrowseBorder( aBrwsBorder );
944 // Im CTOR duerfen keine Shell wechsel erfolgen, die muessen ueber
945 // den Timer "zwischen gespeichert" werden. Sonst raeumt der SFX
946 // sie wieder vom Stack!
947 sal_Bool bOld = bNoInterrupt;
948 bNoInterrupt = sal_True;
950 pHRuler->SetActive( sal_True );
951 pVRuler->SetActive( sal_True );
953 SfxViewFrame* pViewFrame = GetViewFrame();
954 if( pViewFrame->GetFrame()->GetParentFrame())
956 aUsrPref.SetViewHRuler(sal_False);
957 aUsrPref.SetViewVRuler(sal_False);
960 StartListening( *pViewFrame, TRUE );
961 StartListening( *pDocSh, TRUE );
963 // Vom HLineal den ZOOM-Faktor einstellen
964 Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
965 pHRuler->SetZoom( aZoomFract );
966 pVRuler->SetZoom( aZoomFract );
967 pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick ));
968 FieldUnit eMetric = pUsrPref->GetHScrollMetric();
970 BOOL bApplyCharUnit = pUsrPref->IsApplyCharUnit();
971 SvtCJKOptions aCJKOptions;
972 if ( aCJKOptions.IsAsianTypographyEnabled() )
974 if ( bApplyCharUnit )
975 eMetric = FUNIT_CHAR;
976 else
978 if ( eMetric == FUNIT_CHAR )
979 eMetric = FUNIT_CM;
982 else
984 if ( eMetric == FUNIT_CHAR )
985 eMetric = FUNIT_INCH;
987 pHRuler->SetUnit( eMetric );
989 eMetric = pUsrPref->GetVScrollMetric();
990 if ( aCJKOptions.IsAsianTypographyEnabled() )
992 if ( bApplyCharUnit )
993 eMetric = FUNIT_LINE;
994 else
996 if ( eMetric == FUNIT_LINE )
997 eMetric = FUNIT_CM;
1000 else
1002 if ( eMetric == FUNIT_LINE )
1003 eMetric = FUNIT_INCH;
1005 pVRuler->SetUnit( eMetric );
1007 pHRuler->SetCharWidth( 371 ); // default character width
1008 pVRuler->SetLineHeight( 551 ); // default line height
1010 // DocShell setzen
1011 pDocSh->SetView( this );
1012 SW_MOD()->SetView( this );
1014 mpPostItMgr = new SwPostItMgr(this);
1016 // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
1017 // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
1018 // nicht in der SFX-Verwaltung bekannt ist.
1019 DocSzChgd( pWrtShell->GetDocSize() );
1021 // AttrChangedNotify Link setzen
1022 pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify));
1024 if( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
1025 //TODO/LATER: why a cast here?
1026 //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() )
1027 //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False);
1028 !pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() )
1029 SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False);
1031 SwEditShell::SetUndoActionCount(
1032 static_cast< USHORT >( SW_MOD()->GetUndoOptions().GetUndoCount() ) );
1033 pWrtShell->DoUndo( 0 != SwEditShell::GetUndoActionCount() );
1035 const BOOL bBrowse = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
1036 SetNewWindowAllowed(!bBrowse);
1038 ShowVScrollbar(aUsrPref.IsViewVScrollBar());
1039 ShowHScrollbar(aUsrPref.IsViewHScrollBar());
1040 pHScrollbar->SetAuto(bBrowse);
1041 if( aUsrPref.IsViewHRuler() )
1042 CreateTab();
1043 if( aUsrPref.IsViewVRuler() )
1044 CreateVLineal();
1046 pWrtShell->SetUIOptions( aUsrPref );
1047 pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() );
1048 pWrtShell->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
1050 if( UseObjectSize() )
1052 //Damit der Sfx _rechtzeitig weiss_, wie gross die sheet::Border sind.
1053 SvBorder aTmp;
1054 CalcAndSetBorderPixel( aTmp, sal_True );
1057 if( pWrtShell->GetDoc()->IsUpdateExpFld() )
1059 SET_CURR_SHELL( pWrtShell );
1060 pWrtShell->StartAction();
1061 pWrtShell->CalcLayout();
1062 pWrtShell->GetDoc()->UpdateFlds(NULL, false);
1063 pWrtShell->EndAction();
1064 pWrtShell->GetDoc()->SetUpdateExpFldStat( sal_False );
1067 // ggfs. alle Verzeichnisse updaten:
1068 if( pWrtShell->GetDoc()->IsUpdateTOX() )
1070 SfxRequest aSfxRequest( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
1071 Execute( aSfxRequest );
1072 pWrtShell->GetDoc()->SetUpdateTOX( sal_False ); // wieder zurueck setzen
1073 pWrtShell->SttEndDoc(TRUE);
1076 // kein ResetModified, wenn es schone eine View auf dieses Doc gibt
1077 SfxViewFrame* pVFrame = GetViewFrame();
1078 SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
1079 // zur Zeit(360) wird die View erst nach dem Ctor eingetragen
1080 // der folgende Ausdruck funktioniert auch, wenn sich das aendert
1081 //JP 27.07.98: wenn per Undo nicht mehr die Modifizierung aufhebar ist,
1082 // so setze das Modified NICHT zurueck.
1083 // --> OD 2005-02-11 #i38810# - no reset of modified state, if document
1084 // was already modified.
1085 if ( !pWrtShell->GetDoc()->IsUndoNoResetModified() &&
1086 ( !pFirst || pFirst == pVFrame ) &&
1087 !bIsDocModified )
1088 // <--
1090 pWrtShell->ResetModified();
1093 bNoInterrupt = bOld;
1095 // wird ein GlobalDoc neu angelegt, soll auch der Navigator erzeugt werden
1096 if( pDocSh->IsA(SwGlobalDocShell::StaticType()) &&
1097 !pVFrame->GetChildWindow( SID_NAVIGATOR ))
1099 SfxBoolItem aNavi(SID_NAVIGATOR, sal_True);
1100 GetDispatcher().Execute(SID_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, &aNavi, 0L);
1104 /*uno::Reference< awt::XWindow > aTmpRef;
1105 _pFrame->GetFrame()->GetFrameInterface()->setComponent( aTmpRef,
1106 pViewImpl->GetUNOObject_Impl());*/
1108 uno::Reference< frame::XFrame > xFrame = pVFrame->GetFrame()->GetFrameInterface();
1110 uno::Reference< frame::XFrame > xBeamerFrame = xFrame->findFrame(
1111 OUString::createFromAscii("_beamer"), frame::FrameSearchFlag::CHILDREN);
1112 if(xBeamerFrame.is())
1114 SwDBData aData = pWrtShell->GetDBData();
1115 SW_MOD()->ShowDBObj( *this, aData );
1118 // has anybody calls the attrchanged handler in the constructor?
1119 if( bAttrChgNotifiedWithRegistrations )
1121 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1122 if( aTimer.IsActive() )
1123 aTimer.Stop();
1126 aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl));
1127 bAttrChgNotified = bAttrChgNotifiedWithRegistrations = sal_False;
1128 if(bOldModifyFlag)
1129 pDocSh->EnableSetModified( sal_True );
1130 InvalidateBorder();
1134 /*--------------------------------------------------------------------
1135 Beschreibung:
1136 --------------------------------------------------------------------*/
1139 SwView::~SwView()
1141 delete mpPostItMgr;
1142 // --> OD 2009-03-10 #i100035#
1143 mpPostItMgr = 0;
1144 // <--
1146 bInDtor = TRUE;
1147 pEditWin->Hide(); // damit kein Paint Aerger machen kann!
1148 // An der SwDocShell den Pointer auf die View ruecksetzen
1149 SwDocShell* pDocSh = GetDocShell();
1150 if( pDocSh && pDocSh->GetView() == this )
1151 pDocSh->SetView( 0 );
1152 if ( SW_MOD()->GetView() == this )
1153 SW_MOD()->SetView( 0 );
1155 if( aTimer.IsActive() && bAttrChgNotifiedWithRegistrations )
1156 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1158 //JP 27.11.00: Bug 80631 - the last view must end the text edit
1159 SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : 0;
1160 if( pSdrView && pSdrView->IsTextEdit() )
1161 pSdrView->SdrEndTextEdit( sal_True );
1163 SetWindow( 0 );
1165 pViewImpl->Invalidate();
1166 EndListening(*GetViewFrame());
1167 EndListening(*GetDocShell());
1168 delete pScrollFill;
1169 delete pWrtShell;
1170 pWrtShell = 0; // Auf 0 setzen, damit folgende DToren nicht drauf zugreifen
1171 pShell = 0;
1172 delete pHScrollbar;
1173 delete pVScrollbar;
1174 delete pHRuler;
1175 delete pVRuler;
1176 delete pTogglePageBtn;
1177 delete pPageUpBtn;
1178 delete pNaviBtn;
1179 delete pPageDownBtn;
1180 delete pGlosHdl;
1181 delete pViewImpl;
1182 delete pEditWin;
1183 delete pFormatClipboard;
1186 /*--------------------------------------------------------------------
1187 Beschreibung: DocShell rausgrabbeln ueber das FrameWindow
1188 --------------------------------------------------------------------*/
1191 SwDocShell* SwView::GetDocShell()
1193 SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell();
1194 return PTR_CAST(SwDocShell, pDocShell);
1197 /*--------------------------------------------------------------------
1198 Beschreibung: CursorPos merken
1199 --------------------------------------------------------------------*/
1202 void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse )
1204 //Das Browse-Flag wird vom Sfx durchgereicht, wenn Dokumente gebrowsed
1205 //werden (nicht zu verwechseln mit dem BrowseMode).
1206 //Die dann gespeicherten Daten sind nicht persistent!!
1208 const SwRect& rRect = pWrtShell->GetCharRect();
1209 const Rectangle& rVis = GetVisArea();
1211 rUserData = String::CreateFromInt32( rRect.Left() );
1212 rUserData += ';';
1213 rUserData += String::CreateFromInt32( rRect.Top() );
1214 rUserData += ';';
1215 rUserData += String::CreateFromInt32( pWrtShell->GetViewOptions()->GetZoom() );
1216 rUserData += ';';
1217 rUserData += String::CreateFromInt32( rVis.Left() );
1218 rUserData += ';';
1219 rUserData += String::CreateFromInt32( rVis.Top() );
1220 rUserData += ';';
1221 rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Right());
1222 rUserData += ';';
1223 rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Bottom());
1224 rUserData += ';';
1225 rUserData += String::CreateFromInt32(
1226 (sal_uInt16)pWrtShell->GetViewOptions()->GetZoomType());//eZoom;
1227 rUserData += ';';
1228 rUserData += FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? '0' : '1';
1230 /*--------------------------------------------------------------------
1231 Beschreibung: CursorPos setzen
1232 --------------------------------------------------------------------*/
1233 //#i43146# go to the last editing position when opening own files
1234 bool lcl_IsOwnDocument( SwView& rView )
1236 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1237 rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
1238 uno::Reference<document::XDocumentProperties> xDocProps
1239 = xDPS->getDocumentProperties();
1240 String Created = xDocProps->getAuthor();
1241 String Changed = xDocProps->getModifiedBy();
1242 String FullName = SW_MOD()->GetUserOptions().GetFullName();
1243 return FullName.Len() &&
1244 (Changed.Len() && Changed == FullName ) ||
1245 (!Changed.Len() && Created.Len() && Created == FullName );
1249 void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse )
1251 if ( rUserData.GetTokenCount() > 1 &&
1252 //Fuer Dokumente ohne Layout nur im OnlineLayout oder beim
1253 //Forward/Backward
1254 (!pWrtShell->IsNewLayout() || pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) || bBrowse) )
1256 //#i43146# go to the last editing position when opening own files
1257 bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1259 SET_CURR_SHELL(pWrtShell);
1261 sal_uInt16 nPos = 0;
1263 // Nein, es ist *keine* gute Idee GetToken gleich im Point-Konstr.
1264 // aufzurufen, denn welcher Parameter wird zuerst ausgewertet?
1265 long nX = rUserData.GetToken( 0, ';', nPos ).ToInt32(),
1266 nY = rUserData.GetToken( 0, ';', nPos ).ToInt32();
1267 Point aCrsrPos( nX, nY );
1269 sal_uInt16 nZoomFactor =
1270 static_cast< sal_uInt16 >( rUserData.GetToken(0, ';', nPos ).ToInt32() );
1272 long nLeft = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1273 nTop = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1274 nRight = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1275 nBottom= rUserData.GetToken(0, ';', nPos ).ToInt32();
1277 const long nAdd = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1278 if ( nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
1280 pWrtShell->EnableSmooth( sal_False );
1282 const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1284 sal_uInt16 nOff = 0;
1285 SvxZoomType eZoom;
1286 if( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
1287 eZoom = (SvxZoomType) (sal_uInt16)rUserData.GetToken(nOff, ';', nPos ).ToInt32();
1288 else
1290 eZoom = SVX_ZOOM_PERCENT;
1291 ++nOff;
1294 sal_Bool bSelectObj = (0 != rUserData.GetToken( nOff, ';', nPos ).ToInt32())
1295 && pWrtShell->IsObjSelectable( aCrsrPos );
1297 //#i33307# restore editing position
1298 pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1299 // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
1300 bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
1301 pWrtShell->SetMacroExecAllowed( false );
1302 //!!! pb (11.08.2004): #i32536#
1303 // os: changed: The user data has to be read if the view is switched back from page preview
1304 //#i43146# go to the last editing position when opening own files
1305 if(bOldShellWasPagePreView || bIsOwnDocument)
1307 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1308 if( bSelectObj )
1310 pWrtShell->SelectObj( aCrsrPos );
1311 pWrtShell->EnterSelFrmMode( &aCrsrPos );
1315 // OD 11.02.2003 #100556# - reset flag value
1316 pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1318 // OD 08.04.2003 #108693# - set visible area before applying
1319 // information from print preview. Otherwise, the applied information
1320 // is lost.
1321 //!!! pb (11.08.2004): #i32536#
1322 // os: changed: The user data has to be read if the view is switched back from page preview
1323 //#i43146# go to the last editing position when opening own files
1324 if(bOldShellWasPagePreView || bIsOwnDocument )
1326 if ( bBrowse )
1327 SetVisArea( aVis.TopLeft() );
1328 else
1329 SetVisArea( aVis );
1332 //apply information from print preview - if available
1333 if( sNewCrsrPos.Len() )
1335 long nXTmp = sNewCrsrPos.GetToken( 0, ';' ).ToInt32(),
1336 nYTmp = sNewCrsrPos.GetToken( 1, ';' ).ToInt32();
1337 Point aCrsrPos2( nXTmp, nYTmp );
1338 bSelectObj = pWrtShell->IsObjSelectable( aCrsrPos2 );
1340 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos2, FALSE );
1341 if( bSelectObj )
1343 pWrtShell->SelectObj( aCrsrPos2 );
1344 pWrtShell->EnterSelFrmMode( &aCrsrPos2 );
1346 pWrtShell->MakeSelVisible();
1347 sNewCrsrPos.Erase();
1349 else if(USHRT_MAX != nNewPage)
1351 pWrtShell->GotoPage(nNewPage, TRUE);
1352 nNewPage = USHRT_MAX;
1355 SelectShell();
1357 pWrtShell->StartAction();
1358 const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
1359 if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom )
1360 SetZoom( eZoom, nZoomFactor);
1362 pWrtShell->LockView( sal_True );
1363 pWrtShell->EndAction();
1364 pWrtShell->LockView( sal_False );
1365 pWrtShell->EnableSmooth( sal_True );
1370 void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1372 if(GetDocShell()->IsPreview())
1373 return;
1374 //#i43146# go to the last editing position when opening own files
1375 bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1376 sal_Int32 nLength = rSequence.getLength();
1377 if (nLength && (!pWrtShell->IsNewLayout() || pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) || bBrowse) )
1379 SET_CURR_SHELL(pWrtShell);
1380 const beans::PropertyValue *pValue = rSequence.getConstArray();
1381 const SwRect& rRect = pWrtShell->GetCharRect();
1382 const Rectangle &rVis = GetVisArea();
1383 const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
1385 long nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top();
1386 long nRight = bBrowse ? LONG_MIN : rVis.Right(), nBottom = bBrowse ? LONG_MIN : rVis.Bottom();
1387 sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
1388 sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
1389 bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
1390 sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
1392 sal_Bool bSelectedFrame = ( pWrtShell->GetSelFrmType() != FRMTYPE_NONE ),
1393 bGotViewLeft = sal_False, bGotViewTop = sal_False, bGotVisibleLeft = sal_False,
1394 bGotVisibleTop = sal_False, bGotVisibleRight = sal_False,
1395 bGotVisibleBottom = sal_False, bGotZoomType = sal_False,
1396 bGotZoomFactor = sal_False, bGotIsSelectedFrame = sal_False,
1397 bGotViewLayoutColumns = sal_False, bGotViewLayoutBookMode = sal_False;
1399 for (sal_Int16 i = 0 ; i < nLength; i++)
1401 if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLeft" ) ) )
1403 pValue->Value >>= nX;
1404 nX = MM100_TO_TWIP( nX );
1405 bGotViewLeft = sal_True;
1407 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewTop" ) ) )
1409 pValue->Value >>= nY;
1410 nY = MM100_TO_TWIP( nY );
1411 bGotViewTop = sal_True;
1413 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleLeft" ) ) )
1415 pValue->Value >>= nLeft;
1416 nLeft = MM100_TO_TWIP( nLeft );
1417 bGotVisibleLeft = sal_True;
1419 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleTop" ) ) )
1421 pValue->Value >>= nTop;
1422 nTop = MM100_TO_TWIP( nTop );
1423 bGotVisibleTop = sal_True;
1425 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleRight" ) ) )
1427 pValue->Value >>= nRight;
1428 nRight = MM100_TO_TWIP( nRight );
1429 bGotVisibleRight = sal_True;
1431 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleBottom" ) ) )
1433 pValue->Value >>= nBottom;
1434 nBottom = MM100_TO_TWIP( nBottom );
1435 bGotVisibleBottom = sal_True;
1437 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomType" ) ) )
1439 pValue->Value >>= nZoomType;
1440 bGotZoomType = sal_True;
1442 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomFactor" ) ) )
1444 pValue->Value >>= nZoomFactor;
1445 bGotZoomFactor = sal_True;
1447 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutColumns" ) ) )
1449 pValue->Value >>= nViewLayoutColumns;
1450 bGotViewLayoutColumns = sal_True;
1452 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutBookMode" ) ) )
1454 bViewLayoutBookMode = * (sal_Bool *) pValue->Value.getValue();
1455 bGotViewLayoutBookMode = sal_True;
1457 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsSelectedFrame" ) ) )
1459 pValue->Value >>= bSelectedFrame;
1460 bGotIsSelectedFrame = sal_True;
1462 else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsSelectedFrame" ) ) )
1464 pValue->Value >>= bSelectedFrame;
1465 bGotIsSelectedFrame = sal_True;
1467 pValue++;
1469 if (bGotVisibleBottom)
1471 Point aCrsrPos( nX, nY );
1472 const long nAdd = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1473 if (nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
1475 pWrtShell->EnableSmooth( sal_False );
1476 const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1478 sal_uInt16 nOff = 0;
1479 SvxZoomType eZoom;
1480 if ( !pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
1481 eZoom = static_cast < SvxZoomType > ( nZoomType );
1482 else
1484 eZoom = SVX_ZOOM_PERCENT;
1485 ++nOff;
1487 if (bGotIsSelectedFrame)
1489 sal_Bool bSelectObj = (sal_False != bSelectedFrame )
1490 && pWrtShell->IsObjSelectable( aCrsrPos );
1492 // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
1493 bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
1494 pWrtShell->SetMacroExecAllowed( false );
1495 //!!! pb (11.08.2004): #i32536#
1496 // os: changed: The user data has to be read if the view is switched back from page preview
1497 //#i43146# go to the last editing position when opening own files
1498 //#i33307# restore editing position
1499 pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1500 if(bOldShellWasPagePreView|| bIsOwnDocument)
1502 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1503 if( bSelectObj )
1505 pWrtShell->SelectObj( aCrsrPos );
1506 pWrtShell->EnterSelFrmMode( &aCrsrPos );
1510 // OD 11.02.2003 #100556# - reset flag value
1511 pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1513 SelectShell();
1515 // Set ViewLayoutSettings
1516 const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode &&
1517 ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode );
1519 const bool bSetViewSettings = bGotZoomType && bGotZoomFactor &&
1520 ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom );
1522 // In case we have a 'fixed' view layout of 2 or more columns,
1523 // we have to apply the view options *before* starting the action.
1524 // Otherwsie the SetZoom function cannot work correctly, because
1525 // the view layout hasn't been calculated.
1526 const bool bZoomNeedsViewLayout = bSetViewLayoutSettings &&
1527 1 < nViewLayoutColumns &&
1528 bSetViewSettings &&
1529 eZoom != SVX_ZOOM_PERCENT;
1532 if ( !bZoomNeedsViewLayout )
1533 pWrtShell->StartAction();
1535 if ( bSetViewLayoutSettings )
1536 SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, sal_True );
1538 if ( bZoomNeedsViewLayout )
1539 pWrtShell->StartAction();
1541 if ( bSetViewSettings )
1542 SetZoom( eZoom, nZoomFactor, sal_True );
1544 //!!! pb (11.08.2004): #i32536#
1545 // os: changed: The user data has to be read if the view is switched back from page preview
1546 //#i43146# go to the last editing position when opening own files
1547 if(bOldShellWasPagePreView||bIsOwnDocument)
1549 if ( bBrowse && bGotVisibleLeft && bGotVisibleTop )
1551 Point aTopLeft(aVis.TopLeft());
1552 //#i76699# make sure the document is still centered
1553 const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * DOCUMENTBORDER;
1554 SwTwips nEditWidth = GetEditWin().GetOutputSize().Width();
1555 if(nEditWidth > (aDocSz.Width() + lBorder ))
1556 aTopLeft.X() = ( aDocSz.Width() + lBorder - nEditWidth ) / 2;
1557 else
1559 //check if the values are possible
1560 long nXMax = pHScrollbar->GetRangeMax() - pHScrollbar->GetVisibleSize();
1561 if( aTopLeft.X() > nXMax )
1562 aTopLeft.X() = nXMax < 0 ? 0 : nXMax;
1564 SetVisArea( aTopLeft );
1566 else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom )
1567 SetVisArea( aVis );
1570 pWrtShell->LockView( sal_True );
1571 pWrtShell->EndAction();
1572 pWrtShell->LockView( sal_False );
1573 pWrtShell->EnableSmooth( sal_True );
1578 #define NUM_VIEW_SETTINGS 12
1579 void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1581 const SwRect& rRect = pWrtShell->GetCharRect();
1582 const Rectangle& rVis = GetVisArea();
1583 Any aAny;
1585 rSequence.realloc ( NUM_VIEW_SETTINGS );
1586 sal_Int16 nIndex = 0;
1587 beans::PropertyValue *pValue = rSequence.getArray();
1589 sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
1590 pValue->Name = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "ViewId" ) );
1591 OUStringBuffer sBuffer ( OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
1592 SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
1593 pValue->Value <<= sBuffer.makeStringAndClear();
1594 pValue++;nIndex++;
1596 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLeft" ) );
1597 pValue->Value <<= TWIP_TO_MM100 ( rRect.Left() );
1598 pValue++;nIndex++;
1600 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewTop" ) );
1601 pValue->Value <<= TWIP_TO_MM100 ( rRect.Top() );
1602 pValue++;nIndex++;
1604 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleLeft" ) );
1605 pValue->Value <<= TWIP_TO_MM100 ( rVis.Left() );
1606 pValue++;nIndex++;
1608 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleTop" ) );
1609 pValue->Value <<= TWIP_TO_MM100 ( rVis.Top() );
1610 pValue++;nIndex++;
1612 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleRight" ) );
1613 pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Right() );
1614 pValue++;nIndex++;
1616 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleBottom" ) );
1617 pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Bottom() );
1618 pValue++;nIndex++;
1620 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomType" ) );
1621 const sal_Int16 nZoomType = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetZoomType());
1622 pValue->Value <<= nZoomType;
1623 pValue++;nIndex++;
1625 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutColumns" ) );
1626 const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetViewLayoutColumns());
1627 pValue->Value <<= nViewLayoutColumns;
1628 pValue++;nIndex++;
1630 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutBookMode" ) );
1631 const sal_Bool bIsViewLayoutBookMode = pWrtShell->GetViewOptions()->IsViewLayoutBookMode();
1632 pValue->Value.setValue( &bIsViewLayoutBookMode, ::getBooleanCppuType() );
1633 pValue++;nIndex++;
1635 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomFactor" ) );
1636 pValue->Value <<= static_cast < sal_Int16 > (pWrtShell->GetViewOptions()->GetZoom());
1637 pValue++;nIndex++;
1639 pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "IsSelectedFrame" ) );
1640 const sal_Bool bIsSelected = FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? sal_False : sal_True;
1641 pValue->Value.setValue ( &bIsSelected, ::getBooleanCppuType() );
1642 nIndex++;
1644 if ( nIndex < NUM_VIEW_SETTINGS )
1645 rSequence.realloc ( nIndex );
1647 #undef NUM_VIEW_SETTINGS
1651 void SwView::ShowCursor( FASTBOOL bOn )
1653 //JP 10.10.2001: Bug 90461 - don't scroll the cursor into the visible area
1654 BOOL bUnlockView = !pWrtShell->IsViewLocked();
1655 pWrtShell->LockView( TRUE ); //lock visible section
1657 if( !bOn )
1658 pWrtShell->HideCrsr();
1659 else if( !pWrtShell->IsFrmSelected() && !pWrtShell->IsObjSelected() )
1660 pWrtShell->ShowCrsr();
1662 if( bUnlockView )
1663 pWrtShell->LockView( FALSE );
1668 ErrCode SwView::DoVerb( long nVerb )
1670 if ( !GetViewFrame()->GetFrame()->IsInPlace() )
1672 SwWrtShell &rSh = GetWrtShell();
1673 const int nSel = rSh.GetSelectionType();
1674 if ( nSel & nsSelectionType::SEL_OLE )
1675 rSh.LaunchOLEObj( nVerb );
1677 return ERRCODE_NONE;
1680 /*-----------------17.02.98 13:33-------------------
1681 nur sal_True fuer eine Textselektion zurueck geben
1682 --------------------------------------------------*/
1683 sal_Bool SwView::HasSelection( sal_Bool bText ) const
1685 return bText ? GetWrtShell().SwCrsrShell::HasSelection()
1686 : GetWrtShell().HasSelection();
1689 /*-----------------09/16/97 09:50am-----------------
1691 --------------------------------------------------*/
1693 String SwView::GetSelectionText( sal_Bool bCompleteWrds )
1695 return GetSelectionTextParam( bCompleteWrds, sal_True );
1698 /*-----------------09/16/97 09:50am-----------------
1700 --------------------------------------------------*/
1701 String SwView::GetSelectionTextParam( sal_Bool bCompleteWrds,
1702 sal_Bool bEraseTrail )
1704 String sReturn;
1705 if( bCompleteWrds && !GetWrtShell().HasSelection() )
1706 GetWrtShell().SelWrd();
1708 GetWrtShell().GetSelectedText( sReturn );
1709 if( bEraseTrail )
1710 sReturn.EraseTrailingChars();
1711 return sReturn;
1714 /*--------------------------------------------------------------------
1715 Beschreibung:
1716 --------------------------------------------------------------------*/
1720 SwGlossaryHdl* SwView::GetGlosHdl()
1722 if(!pGlosHdl)
1723 pGlosHdl = new SwGlossaryHdl(GetViewFrame(), pWrtShell);
1724 return pGlosHdl;
1727 /*-----------------05.09.96 15.50-------------------
1729 --------------------------------------------------*/
1733 void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1735 BOOL bCallBase = sal_True;
1736 if ( rHint.ISA(SfxSimpleHint) )
1738 sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
1739 switch ( nId )
1741 // --> OD 2005-03-03 #i43775# - sub shells will be destroyed by the
1742 // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1743 case SFX_HINT_DYING:
1745 if ( &rBC == GetViewFrame() )
1747 ResetSubShell();
1750 break;
1751 // <--
1752 case SFX_HINT_MODECHANGED:
1754 // Modalmodus-Umschaltung?
1755 sal_Bool bModal = GetDocShell()->IsInModalMode();
1756 pHRuler->SetActive( !bModal );
1757 pVRuler->SetActive( !bModal );
1760 /* kein break hier */
1762 case SFX_HINT_TITLECHANGED:
1763 if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1765 SwWrtShell &rSh = GetWrtShell();
1766 rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1768 if ( rSh.GetViewOptions()->IsViewVRuler() )
1769 CreateVLineal();
1770 else
1771 KillVLineal();
1772 if ( rSh.GetViewOptions()->IsViewHRuler() )
1773 CreateTab();
1774 else
1775 KillTab();
1776 bool bReadonly = GetDocShell()->IsReadOnly();
1777 //#i76332# if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode
1778 if( !bReadonly )
1780 SwDrawDocument * pDrawDoc = 0;
1781 if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) )
1783 if( !pDrawDoc->GetOpenInDesignMode() )
1784 break;// don't touch the design mode
1787 SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly);
1788 GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON,
1789 &aItem, 0L );
1791 break;
1793 case SW_BROADCAST_DRAWVIEWS_CREATED:
1795 bCallBase = sal_False;
1796 if ( GetFormShell() )
1798 GetFormShell()->SetView(
1799 PTR_CAST(FmFormView, GetWrtShell().GetDrawView()) );
1800 SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly());
1801 GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON,
1802 &aItem, 0L );
1805 break;
1808 else if(rHint.ISA(FmDesignModeChangedHint))
1810 sal_Bool bDesignMode = ((FmDesignModeChangedHint&)rHint).GetDesignMode();
1811 if (!bDesignMode && GetDrawFuncPtr())
1813 GetDrawFuncPtr()->Deactivate();
1814 SetDrawFuncPtr(NULL);
1815 LeaveDrawCreate();
1816 AttrChangedNotify(pWrtShell);
1820 if ( bCallBase )
1821 SfxViewShell::Notify(rBC, rHint);
1824 /*-----------------02.12.96 12:36-------------------
1826 --------------------------------------------------*/
1827 #if defined WIN || defined WNT || defined UNX
1829 void SwView::ScannerEventHdl( const EventObject& /*rEventObject*/ )
1831 uno::Reference< XScannerManager > xScanMgr = SW_MOD()->GetScannerManager();
1832 if( xScanMgr.is() )
1834 const ScannerContext aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] );
1835 const ScanError eError = xScanMgr->getError( aContext );
1837 if( ScanError_ScanErrorNone == eError )
1839 const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) );
1841 if( xBitmap.is() )
1843 const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
1845 if( !!aScanBmp )
1847 Graphic aGrf(aScanBmp);
1848 pWrtShell->Insert( aEmptyStr, aEmptyStr, aGrf );
1853 SfxBindings& rBind = GetViewFrame()->GetBindings();
1854 rBind.Invalidate( SID_TWAIN_SELECT );
1855 rBind.Invalidate( SID_TWAIN_TRANSFER );
1857 #endif
1859 /*-----------------04.03.97 15:07-------------------
1861 --------------------------------------------------*/
1864 void SwView::StopShellTimer()
1866 if(aTimer.IsActive())
1868 aTimer.Stop();
1869 if ( bAttrChgNotifiedWithRegistrations )
1871 GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1872 bAttrChgNotifiedWithRegistrations = sal_False;
1874 SelectShell();
1875 bAttrChgNotified = sal_False;
1879 /*-----------------09/03/97 04:12pm-----------------
1881 --------------------------------------------------*/
1882 sal_uInt16 SwView::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
1884 SfxViewFrame* pVFrame = GetViewFrame();
1885 pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False );
1886 if( pVFrame->GetDispatcher()->IsLocked() )
1887 pVFrame->GetDispatcher()->Lock(sal_False);
1889 sal_uInt16 nRet;
1890 if ( pFormShell &&
1891 sal_True != (nRet = pFormShell->PrepareClose( bUI, bForBrowsing )) )
1894 return nRet;
1896 return SfxViewShell::PrepareClose( bUI, bForBrowsing );
1901 // status methods for clipboard.
1902 // Status changes now notified from the clipboard.
1903 BOOL SwView::IsPasteAllowed()
1905 USHORT nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
1906 if( nLastPasteDestination != nPasteDestination )
1908 TransferableDataHelper aDataHelper(
1909 TransferableDataHelper::CreateFromSystemClipboard(
1910 &GetEditWin()) );
1911 if( aDataHelper.GetXTransferable().is() )
1913 bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
1914 bPasteSpecialState = SwTransferable::IsPasteSpecial(
1915 *pWrtShell, aDataHelper );
1917 else
1918 bPasteState = bPasteSpecialState = FALSE;
1920 if( 0xFFFF == nLastPasteDestination ) // the init value
1921 pViewImpl->AddClipboardListener();
1922 nLastPasteDestination = nPasteDestination;
1924 return bPasteState;
1927 BOOL SwView::IsPasteSpecialAllowed()
1929 if ( pFormShell && pFormShell->IsActiveControl() )
1930 return FALSE;
1932 USHORT nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
1933 if( nLastPasteDestination != nPasteDestination )
1935 TransferableDataHelper aDataHelper(
1936 TransferableDataHelper::CreateFromSystemClipboard(
1937 &GetEditWin()) );
1938 if( aDataHelper.GetXTransferable().is() )
1940 bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
1941 bPasteSpecialState = SwTransferable::IsPasteSpecial(
1942 *pWrtShell, aDataHelper );
1944 else
1945 bPasteState = bPasteSpecialState = FALSE;
1947 if( 0xFFFF == nLastPasteDestination ) // the init value
1948 pViewImpl->AddClipboardListener();
1950 return bPasteSpecialState;
1952 /* -----------------------------12.07.01 13:25--------------------------------
1954 ---------------------------------------------------------------------------*/
1955 void SwView::NotifyDBChanged()
1957 GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1960 /*--------------------------------------------------------------------
1961 Beschreibung: Drucken
1962 --------------------------------------------------------------------*/
1964 void SwView::MakeOptions( PrintDialog* pDlg, SwPrtOptions& rOpts,
1965 BOOL* pPrtProspect, BOOL* pPrtProspect_RTL, BOOL bWeb, SfxPrinter* pPrt, SwPrintData* pData )
1967 SwAddPrinterItem* pAddPrinterAttr;
1968 if( pPrt && SFX_ITEM_SET == pPrt->GetOptions().GetItemState(
1969 FN_PARAM_ADDPRINTER, FALSE, (const SfxPoolItem**)&pAddPrinterAttr ))
1971 pData = pAddPrinterAttr;
1973 else if(!pData)
1975 pData = SW_MOD()->GetPrtOptions(bWeb);
1977 rOpts = *pData;
1978 if( pPrtProspect )
1979 *pPrtProspect = pData->bPrintProspect;
1980 if( pPrtProspect_RTL )
1981 *pPrtProspect_RTL = pData->bPrintProspect_RTL;
1982 rOpts.aMulti.SetTotalRange( Range( 0, RANGE_MAX ) );
1983 rOpts.aMulti.SelectAll( FALSE );
1984 rOpts.nCopyCount = 1;
1985 rOpts.bCollate = FALSE;
1986 rOpts.bPrintSelection = FALSE;
1987 rOpts.bJobStartet = FALSE;
1989 if ( pDlg )
1991 rOpts.nCopyCount = pDlg->GetCopyCount();
1992 rOpts.bCollate = pDlg->IsCollateChecked();
1993 if ( pDlg->GetCheckedRange() == PRINTDIALOG_SELECTION )
1995 rOpts.aMulti.SelectAll();
1996 rOpts.bPrintSelection = TRUE;
1998 else if ( PRINTDIALOG_ALL == pDlg->GetCheckedRange() )
1999 rOpts.aMulti.SelectAll();
2000 else
2002 rOpts.aMulti = MultiSelection( pDlg->GetRangeText() );
2003 rOpts.aMulti.SetTotalRange( Range( 0, RANGE_MAX ) );
2006 else
2007 rOpts.aMulti.SelectAll();
2008 rOpts.aMulti.Select( 0, FALSE );
2011 /* -----------------------------28.10.02 13:25--------------------------------
2013 ---------------------------------------------------------------------------*/
2014 SfxObjectShellRef & SwView::GetTmpSelectionDoc()
2016 return GetViewImpl()->GetTmpSelectionDoc();
2018 /* -----------------------------31.10.02 13:25--------------------------------
2020 ---------------------------------------------------------------------------*/
2021 SfxObjectShellRef & SwView::GetOrCreateTmpSelectionDoc()
2023 SfxObjectShellRef &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc();
2024 if (!rxTmpDoc.Is())
2026 SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl();
2027 rxTmpDoc = pImpl->BuildTmpSelectionDoc(
2028 GetViewImpl()->GetEmbeddedObjRef() );
2030 return rxTmpDoc;
2032 /* -----------------3/31/2003 12:39PM----------------
2034 --------------------------------------------------*/
2035 void SwView::AddTransferable(SwTransferable& rTransferable)
2037 GetViewImpl()->AddTransferable(rTransferable);