xref: /trunk/main/sw/source/ui/uiview/view.cxx (revision a0d53b35b9c5a6bd9856ab272d521493ba628169)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers
29 #include <stdlib.h>
30 #include <hintids.hxx>
31 #include <rtl/logfile.hxx>
32 #include <vcl/graph.hxx>
33 #include <vcl/inputctx.hxx>
34 #include <basic/sbxobj.hxx>
35 #include <svl/eitem.hxx>
36 #include <unotools/undoopt.hxx>
37 #include <unotools/lingucfg.hxx>
38 #include <unotools/useroptions.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <sfx2/request.hxx>
41 #include <sfx2/docfile.hxx>
42 #include <sfx2/printer.hxx>
43 #include <sfx2/app.hxx>
44 #include <svx/ruler.hxx>
45 #include <editeng/protitem.hxx>
46 #include <svx/fmshell.hxx>
47 #include <svx/extrusionbar.hxx>
48 #include <svx/fontworkbar.hxx>
49 #include <unotxvw.hxx>
50 #include <cmdid.h>
51 #include <swhints.hxx>
52 #include <swmodule.hxx>
53 #include <inputwin.hxx>
54 #include <chartins.hxx>
55 #include <uivwimp.hxx>
56 #include <uitool.hxx>
57 #include <edtwin.hxx>
58 #include <textsh.hxx>
59 #include <listsh.hxx>
60 #include <tabsh.hxx>
61 #include <grfsh.hxx>
62 #include <mediash.hxx>
63 #include <docsh.hxx>
64 #include <frmsh.hxx>
65 #include <olesh.hxx>
66 #include <drawsh.hxx>
67 #include <drawbase.hxx>
68 #include <drformsh.hxx>
69 #include <drwtxtsh.hxx>
70 #include <beziersh.hxx>
71 #include <globdoc.hxx>
72 #include <scroll.hxx>
73 #include <navipi.hxx>
74 #include <gloshdl.hxx>
75 #include <usrpref.hxx>
76 #include <srcview.hxx>
77 #include <doc.hxx>
78 #include <IDocumentUndoRedo.hxx>
79 #include <drawdoc.hxx>
80 #include <wdocsh.hxx>
81 #include <wview.hxx>
82 #include <workctrl.hxx>
83 #include <wrtsh.hxx>
84 #include <barcfg.hxx>
85 #include <pview.hxx>
86 #include <swdtflvr.hxx>
87 #include <view.hrc>
88 #include <globdoc.hrc>
89 #include <frmui.hrc>
90 #include <cfgitems.hxx>
91 #include <prtopt.hxx>
92 #include <linguistic/lngprops.hxx>
93 #include <editeng/unolingu.hxx>
94 //#include <sfx2/app.hxx>
95 #include <com/sun/star/frame/FrameSearchFlag.hpp>
96 #include <com/sun/star/scanner/ScannerContext.hpp>
97 #include <com/sun/star/scanner/XScannerManager.hpp>
98 #include <toolkit/unohlp.hxx>
99 #include <rtl/ustrbuf.hxx>
100 #include <xmloff/xmluconv.hxx>
101 
102 #include "formatclipboard.hxx"
103 #include <PostItMgr.hxx>
104 #include <annotsh.hxx>
105 
106 #include <fldbas.hxx>
107 
108 #include <unomid.h>
109 
110 #include <com/sun/star/document/XDocumentProperties.hpp>
111 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
112 
113 
114 using namespace ::com::sun::star;
115 using namespace ::com::sun::star::uno;
116 using namespace ::com::sun::star::lang;
117 using namespace ::com::sun::star::scanner;
118 using ::rtl::OUString;
119 using ::rtl::OUStringBuffer;
120 
121 
122 extern sal_Bool bNoInterrupt;       // in mainwn.cxx
123 
124 #define SWVIEWFLAGS ( SFX_VIEW_CAN_PRINT|               \
125                       SFX_VIEW_HAS_PRINTOPTIONS)
126 
127 /*--------------------------------------------------------------------
128     Beschreibung:   Statics
129  --------------------------------------------------------------------*/
130 
131 int bDocSzUpdated = 1;
132 
133 SvxSearchItem*  SwView::pSrchItem   = 0;
134 
135 sal_uInt16          SwView::nInsertCtrlState        = FN_INSERT_TABLE;
136 sal_uInt16          SwView::nWebInsertCtrlState     = FN_INSERT_TABLE;
137 sal_uInt16          SwView::nInsertObjectCtrlState  = SID_INSERT_DIAGRAM;
138 
139 sal_Bool            SwView::bExtra      = sal_False;
140 sal_Bool            SwView::bFound      = sal_False;
141 sal_Bool            SwView::bJustOpened = sal_False;
142 
143 
144 SvxSearchDialog*    SwView::pSrchDlg    = 0;
145 SearchAttrItemList* SwView::pSrchList   = 0;
146 SearchAttrItemList* SwView::pReplList   = 0;
147 
148 DBG_NAME(viewhdl)
149 
150 /*--------------------------------------------------------------------
151     Beschreibung:
152  --------------------------------------------------------------------*/
153 
154 inline SfxDispatcher &SwView::GetDispatcher()
155 {
156     return *GetViewFrame()->GetDispatcher();
157 }
158 
159 /*--------------------------------------------------------------------
160     Beschreibung:
161  --------------------------------------------------------------------*/
162 
163 void SwView::ImpSetVerb( int nSelType )
164 {
165     sal_Bool bResetVerbs = bVerbsActive;
166     if ( !GetViewFrame()->GetFrame().IsInPlace() &&
167          (nsSelectionType::SEL_OLE|nsSelectionType::SEL_GRF) & nSelType )
168     {
169         if ( !pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT) )
170         {
171             if ( nSelType & nsSelectionType::SEL_OLE )
172             {
173                 SetVerbs( GetWrtShell().GetOLEObject()->getSupportedVerbs() );
174                 bVerbsActive = sal_True;
175                 bResetVerbs = sal_False;
176             }
177         }
178     }
179     if ( bResetVerbs )
180     {
181         SetVerbs( Sequence< embed::VerbDescriptor >() );
182         bVerbsActive = sal_False;
183     }
184 }
185 
186 /*--------------------------------------------------------------------
187     Description:
188     called by the SwEditWin when it gets the focus
189  --------------------------------------------------------------------*/
190 
191 void SwView::GotFocus() const
192 {
193     // if we got the focus, and the form shell *is* on the top of the dispatcher
194     // stack, then we need to rebuild the stack (the form shell doesn't belong to
195     // the top then)
196     const SfxDispatcher& rDispatcher = const_cast< SwView* >( this )->GetDispatcher();
197     SfxShell* pTopShell = rDispatcher.GetShell( 0 );
198     FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
199     if ( pAsFormShell )
200     {
201         pAsFormShell->ForgetActiveControl();
202         const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
203     }
204     else if ( mpPostItMgr )
205     {
206         SwAnnotationShell* pAsAnnotationShell = PTR_CAST( SwAnnotationShell, pTopShell );
207         if ( pAsAnnotationShell )
208         {
209             mpPostItMgr->SetActiveSidebarWin(0);
210             const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
211         }
212     }
213     if( GetWrtShellPtr() )
214     {
215         SwWrtShell& rWrtShell = GetWrtShell();
216         rWrtShell.GetDoc()->SetCurrentViewShell( GetWrtShellPtr() );
217         rWrtShell.GetDoc()->set( IDocumentSettingAccess::BROWSE_MODE,
218                                  rWrtShell.GetViewOptions()->getBrowseMode() );
219     }
220 }
221 
222 /*--------------------------------------------------------------------
223     Description:
224     called by the FormShell when a form control is focused. This is
225     a request to put the form shell on the top of the dispatcher
226     stack
227  --------------------------------------------------------------------*/
228 
229 IMPL_LINK( SwView, FormControlActivated, FmFormShell*, EMPTYARG )
230 {
231     // if a form control has been activated, and the form shell is not on the top
232     // of the dispatcher stack, then we need to activate it
233     const SfxDispatcher& rDispatcher = GetDispatcher();
234     const SfxShell* pTopShell = rDispatcher.GetShell( 0 );
235     const FmFormShell* pAsFormShell = PTR_CAST( FmFormShell, pTopShell );
236     if ( !pAsFormShell )
237     {
238         // if we're editing text currently, cancel this
239         SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : NULL;
240         if ( pSdrView && pSdrView->IsTextEdit() )
241             pSdrView->SdrEndTextEdit( sal_True );
242 
243         const_cast< SwView* >( this )->AttrChangedNotify( pWrtShell );
244     }
245 
246     return 0L;
247 }
248 
249 void SwView::SelectShell()
250 {
251 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
252 //
253 //      Achtung: SelectShell fuer die WebView mitpflegen
254 //
255 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
256 
257           if(bInDtor)
258         return;
259     // Entscheidung, ob UpdateTable gerufen werden muss
260     sal_Bool bUpdateTable = sal_False;
261     const SwFrmFmt* pCurTableFmt = pWrtShell->GetTableFmt();
262     if(pCurTableFmt && pCurTableFmt != pLastTableFormat)
263     {
264         bUpdateTable = sal_True; // kann erst spaeter ausgefuehrt werden
265     }
266     pLastTableFormat = pCurTableFmt;
267 
268     //SEL_TBL und SEL_TBL_CELLS koennen verodert sein!
269     int nNewSelectionType = (pWrtShell->GetSelectionType()
270                                 & ~nsSelectionType::SEL_TBL_CELLS);
271 
272     if ( pFormShell && pFormShell->IsActiveControl() )
273         nNewSelectionType |= nsSelectionType::SEL_FOC_FRM_CTRL;
274 
275     if ( nNewSelectionType == nSelectionType )
276     {
277         GetViewFrame()->GetBindings().InvalidateAll( sal_False );
278         if ( nSelectionType & nsSelectionType::SEL_OLE ||
279              nSelectionType & nsSelectionType::SEL_GRF )
280             //Fuer Grafiken und OLE kann sich natuerlich das Verb aendern!
281             ImpSetVerb( nNewSelectionType );
282     }
283     else
284     {
285 
286         SfxDispatcher &rDispatcher = GetDispatcher();
287         SwToolbarConfigItem *pBarCfg = SW_MOD()->GetToolbarConfig();
288 
289     //  DELETEZ(pxSelectionObj); //Selektionsobjekt loeschen
290         if ( pShell )
291         {
292             rDispatcher.Flush();        // alle gecachten Shells wirklich loeschen
293 
294             //Zur alten Selektion merken welche Toolbar sichtbar war
295             sal_uInt16 nId = static_cast< sal_uInt16 >( rDispatcher.GetObjectBarId( SFX_OBJECTBAR_OBJECT ));
296             if ( nId )
297                 pBarCfg->SetTopToolbar( nSelectionType, nId );
298 
299             SfxShell *pSfxShell;
300             for ( sal_uInt16 i = 0; sal_True; ++i )
301             {
302                 pSfxShell = rDispatcher.GetShell( i );
303                 if  (  pSfxShell->ISA( SwBaseShell )
304                     || pSfxShell->ISA( SwDrawTextShell )
305                     || pSfxShell->ISA( svx::ExtrusionBar )
306                     || pSfxShell->ISA( svx::FontworkBar )
307                     || pSfxShell->ISA( SwAnnotationShell )
308                     )
309                 {
310                     rDispatcher.Pop( *pSfxShell, SFX_SHELL_POP_DELETE );
311                 }
312                 else if ( pSfxShell->ISA( FmFormShell ) )
313                 {
314                     rDispatcher.Pop( *pSfxShell );
315                 }
316                 else
317                     break;
318             }
319         }
320 
321         sal_Bool bInitFormShell = sal_False;
322         if (!pFormShell)
323         {
324             bInitFormShell = sal_True;
325             pFormShell = new FmFormShell( this );
326             pFormShell->SetControlActivationHandler( LINK( this, SwView, FormControlActivated ) );
327             StartListening(*pFormShell);
328         }
329 
330         sal_Bool bSetExtInpCntxt = sal_False;
331         nSelectionType = nNewSelectionType;
332         ShellModes eShellMode;
333 
334         if ( !( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL ) )
335             rDispatcher.Push( *pFormShell );
336 
337         if ( nSelectionType & nsSelectionType::SEL_OLE )
338         {
339             eShellMode = SHELL_MODE_OBJECT;
340             pShell = new SwOleShell( *this );
341             rDispatcher.Push( *pShell );
342         }
343         else if ( nSelectionType & nsSelectionType::SEL_FRM
344             || nSelectionType & nsSelectionType::SEL_GRF)
345         {
346             eShellMode = SHELL_MODE_FRAME;
347             pShell = new SwFrameShell( *this );
348             rDispatcher.Push( *pShell );
349             if(nSelectionType & nsSelectionType::SEL_GRF )
350             {
351                 eShellMode = SHELL_MODE_GRAPHIC;
352                 pShell = new SwGrfShell( *this );
353                 rDispatcher.Push( *pShell );
354             }
355         }
356         else if ( nSelectionType & nsSelectionType::SEL_DRW )
357         {
358             eShellMode = SHELL_MODE_DRAW;
359             pShell = new SwDrawShell( *this );
360             rDispatcher.Push( *pShell );
361 
362             if ( nSelectionType & nsSelectionType::SEL_BEZ )
363             {
364                 eShellMode = SHELL_MODE_BEZIER;
365                 pShell = new SwBezierShell( *this );
366                 rDispatcher.Push( *pShell );
367             }
368             else if( nSelectionType & nsSelectionType::SEL_MEDIA )
369             {
370                 eShellMode = SHELL_MODE_MEDIA;
371                 pShell = new SwMediaShell( *this );
372                 rDispatcher.Push( *pShell );
373             }
374 
375             if (nSelectionType & nsSelectionType::SEL_EXTRUDED_CUSTOMSHAPE)
376             {
377                 eShellMode = SHELL_MODE_EXTRUDED_CUSTOMSHAPE;
378                 pShell = new svx::ExtrusionBar(this);
379                 rDispatcher.Push( *pShell );
380             }
381             if (nSelectionType & nsSelectionType::SEL_FONTWORK)
382             {
383                 eShellMode = SHELL_MODE_FONTWORK;
384                 pShell = new svx::FontworkBar(this);
385                 rDispatcher.Push( *pShell );
386             }
387         }
388         else if ( nSelectionType & nsSelectionType::SEL_DRW_FORM )
389         {
390             eShellMode = SHELL_MODE_DRAW_FORM;
391             pShell = new SwDrawFormShell( *this );
392 
393             rDispatcher.Push( *pShell );
394         }
395         else if ( nSelectionType & nsSelectionType::SEL_DRW_TXT )
396         {
397             bSetExtInpCntxt = sal_True;
398             eShellMode = SHELL_MODE_DRAWTEXT;
399             rDispatcher.Push( *(new SwBaseShell( *this )) );
400             pShell = new SwDrawTextShell( *this );
401             rDispatcher.Push( *pShell );
402         }
403         else if ( nSelectionType & nsSelectionType::SEL_POSTIT )
404         {
405             eShellMode = SHELL_MODE_POSTIT;
406             pShell = new SwAnnotationShell( *this );
407             rDispatcher.Push( *pShell );
408         }
409         else
410         {
411             bSetExtInpCntxt = sal_True;
412             eShellMode = SHELL_MODE_TEXT;
413             sal_uInt32 nHelpId = 0;
414             if ( nSelectionType & nsSelectionType::SEL_NUM )
415             {
416                 eShellMode = SHELL_MODE_LIST_TEXT;
417                 pShell = new SwListShell( *this );
418                 nHelpId = pShell->GetHelpId();
419                 rDispatcher.Push( *pShell );
420             }
421             pShell = new SwTextShell(*this);
422             if(nHelpId)
423                 pShell->SetHelpId(nHelpId);
424             rDispatcher.Push( *pShell );
425             if ( nSelectionType & nsSelectionType::SEL_TBL )
426             {
427                 eShellMode = eShellMode == SHELL_MODE_LIST_TEXT ? SHELL_MODE_TABLE_LIST_TEXT
428                                                         : SHELL_MODE_TABLE_TEXT;
429                 pShell = new SwTableShell( *this );
430                 rDispatcher.Push( *pShell );
431             }
432         }
433 
434         if ( nSelectionType & nsSelectionType::SEL_FOC_FRM_CTRL )
435             rDispatcher.Push( *pFormShell );
436 
437         pViewImpl->SetShellMode(eShellMode);
438         ImpSetVerb( nSelectionType );
439 
440         if( !GetDocShell()->IsReadOnly() )
441         {
442             if( bSetExtInpCntxt && GetWrtShell().HasReadonlySel() )
443                 bSetExtInpCntxt = sal_False;
444 
445             InputContext aCntxt( GetEditWin().GetInputContext() );
446             aCntxt.SetOptions( bSetExtInpCntxt
447                                 ? (aCntxt.GetOptions() |
448                                         ( INPUTCONTEXT_TEXT |
449                                             INPUTCONTEXT_EXTTEXTINPUT ))
450                                 : (aCntxt.GetOptions() & ~
451                                         ( INPUTCONTEXT_TEXT |
452                                             INPUTCONTEXT_EXTTEXTINPUT )) );
453             GetEditWin().SetInputContext( aCntxt );
454         }
455 
456         //Zur neuen Selektion die Toolbar aktivieren, die auch beim letzten Mal
457         //aktiviert war
458         //Vorher muss ein Flush() sein, betrifft aber lt. MBA nicht das UI und ist
459         //kein Performance-Problem
460         // TODO/LATER: maybe now the Flush() command is superfluous?!
461         rDispatcher.Flush();
462 
463         Point aPnt = GetEditWin().OutputToScreenPixel(GetEditWin().GetPointerPosPixel());
464         aPnt = GetEditWin().PixelToLogic(aPnt);
465         GetEditWin().UpdatePointer(aPnt);
466 
467         SdrView* pDView = GetWrtShell().GetDrawView();
468         if ( bInitFormShell && pDView )
469             pFormShell->SetView(PTR_CAST(FmFormView, pDView));
470 
471     }
472     //Guenstiger Zeitpunkt fuer die Kommunikation mit OLE-Objekten?
473     if ( GetDocShell()->GetDoc()->IsOLEPrtNotifyPending() )
474         GetDocShell()->GetDoc()->PrtOLENotify( sal_False );
475 
476     //jetzt das Tabellen-Update
477     if(bUpdateTable)
478         pWrtShell->UpdateTable();
479 
480     GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
481 }
482 
483 //Zusammenspiel: AttrChangedNotify() und TimeoutHdl.
484 //Falls noch Actions offen sind keine Aktualisierung, da der
485 //Cursor auf der Core-Seite im Wald stehen kann.
486 //Da wir aber keine Stati mehr liefern koennen und wollen locken wir
487 //stattdessen den Dispatcher.
488 
489 
490 
491 extern "C"
492 {
493     int lcl_CmpIds( const void *pFirst, const void *pSecond)
494     {
495         return (*(sal_uInt16*)pFirst) - (*(sal_uInt16*)pSecond);
496     }
497 }
498 
499 
500 
501 IMPL_LINK( SwView, AttrChangedNotify, SwWrtShell *, EMPTYARG )
502 {
503     if ( GetEditWin().IsChainMode() )
504         GetEditWin().SetChainMode( sal_False );
505 
506     //Opt: Nicht wenn PaintLocked. Beim Unlock wird dafuer nocheinmal ein
507     //Notify ausgeloest.
508     if( !pWrtShell->IsPaintLocked() && !bNoInterrupt &&
509         GetDocShell()->IsReadOnly() )
510         _CheckReadonlyState();
511 
512     // JP 19.01.99: Cursor in Readonly Bereichen
513     if( !pWrtShell->IsPaintLocked() && !bNoInterrupt )
514         _CheckReadonlySelection();
515 
516     if( !bAttrChgNotified )
517     {
518         if ( pWrtShell->BasicActionPend() || bNoInterrupt ||
519              GetDispatcher().IsLocked() ||               //do not confuse the SFX
520              GetViewFrame()->GetBindings().IsInUpdate() )//do not confuse the SFX
521         {
522             bAttrChgNotified = sal_True;
523             aTimer.Start();
524 
525             const SfxPoolItem *pItem;
526             if ( SFX_ITEM_SET != GetObjectShell()->GetMedium()->GetItemSet()->
527                                     GetItemState( SID_HIDDEN, sal_False, &pItem ) ||
528                  !((SfxBoolItem*)pItem)->GetValue() )
529             {
530                 GetViewFrame()->GetBindings().ENTERREGISTRATIONS();
531                 bAttrChgNotifiedWithRegistrations = sal_True;
532             }
533 
534         }
535         else
536             SelectShell();
537 
538     }
539 
540     //#i6193#, change ui if cursor is at a SwPostItField
541     if (mpPostItMgr)
542     {
543         mpPostItMgr->SetShadowState( pWrtShell->GetPostItFieldAtCursor() );
544     }
545 
546     return 0;
547 }
548 
549 
550 
551 IMPL_LINK( SwView, TimeoutHdl, Timer *, EMPTYARG )
552 {
553     DBG_PROFSTART(viewhdl);
554 
555     if( pWrtShell->BasicActionPend() || bNoInterrupt )
556     {
557         aTimer.Start();
558         DBG_PROFSTOP(viewhdl);
559         return 0;
560     }
561 
562     if ( bAttrChgNotifiedWithRegistrations )
563     {
564         GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
565         bAttrChgNotifiedWithRegistrations = sal_False;
566     }
567 
568     _CheckReadonlyState();
569     _CheckReadonlySelection();
570 
571     sal_Bool bOldUndo = pWrtShell->DoesUndo();
572     pWrtShell->DoUndo( sal_False );
573     SelectShell();
574     pWrtShell->DoUndo( bOldUndo );
575     bAttrChgNotified = sal_False;
576     GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
577 
578     DBG_PROFSTOP(viewhdl);
579     return 0;
580 }
581 
582 void SwView::_CheckReadonlyState()
583 {
584     SfxDispatcher &rDis = GetDispatcher();
585     //Um erkennen zu koennen ob bereits disabled ist!
586     SfxItemState eStateRO, eStateProtAll;
587     const SfxPoolItem *pItem;
588     // JP 29.04.97: von einem nur uns bekannten Slot den Status abfragen.
589     //              Ansonsten kennen andere den Slot; wie z.B. die BasidIde
590     eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem );
591     eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem );
592     sal_Bool bChgd = sal_False;
593 
594     if ( !pWrtShell->IsCrsrReadonly() )
595     {
596         static sal_uInt16 aROIds[] =
597         {
598             SID_DELETE,                 FN_BACKSPACE,               FN_SHIFT_BACKSPACE,
599             SID_UNDO,
600             SID_REDO,                   SID_REPEAT,                 SID_PASTE,
601             SID_PASTE_UNFORMATTED,
602             SID_PASTE_SPECIAL,            SID_SBA_BRW_INSERT,
603             SID_BACKGROUND_COLOR,       FN_INSERT_BOOKMARK,
604             SID_CHARMAP,                FN_INSERT_SOFT_HYPHEN,
605             FN_INSERT_HARDHYPHEN,       FN_INSERT_HARD_SPACE,       FN_INSERT_BREAK,
606             FN_INSERT_LINEBREAK,        FN_INSERT_COLUMN_BREAK,     FN_INSERT_BREAK_DLG,
607             FN_DELETE_SENT,             FN_DELETE_BACK_SENT,        FN_DELETE_WORD,
608             FN_DELETE_BACK_WORD,        FN_DELETE_LINE,             FN_DELETE_BACK_LINE,
609             FN_DELETE_PARA,             FN_DELETE_BACK_PARA,        FN_DELETE_WHOLE_LINE,
610             FN_CALCULATE,               FN_FORMAT_RESET,
611             FN_POSTIT,                  FN_JAVAEDIT,                SID_ATTR_PARA_ADJUST_LEFT,
612             SID_ATTR_PARA_ADJUST_RIGHT, SID_ATTR_PARA_ADJUST_CENTER,SID_ATTR_PARA_ADJUST_BLOCK,
613             SID_ATTR_PARA_LINESPACE_10, SID_ATTR_PARA_LINESPACE_15, SID_ATTR_PARA_LINESPACE_20,
614             SID_ATTR_CHAR_FONT,         SID_ATTR_CHAR_FONTHEIGHT,   SID_ATTR_CHAR_COLOR_BACKGROUND,
615             SID_ATTR_CHAR_COLOR_BACKGROUND_EXT,                     SID_ATTR_CHAR_COLOR_EXT,
616             SID_ATTR_CHAR_COLOR,        SID_ATTR_CHAR_WEIGHT,       SID_ATTR_CHAR_POSTURE,
617             SID_ATTR_CHAR_OVERLINE,
618             SID_ATTR_CHAR_UNDERLINE,    SID_ATTR_FLASH,             SID_ATTR_CHAR_STRIKEOUT,
619             FN_UNDERLINE_DOUBLE,        SID_ATTR_CHAR_CONTOUR,      SID_ATTR_CHAR_SHADOWED,
620             SID_ATTR_CHAR_AUTOKERN,     SID_ATTR_CHAR_ESCAPEMENT,   FN_SET_SUPER_SCRIPT,
621             FN_SET_SUB_SCRIPT,          SID_ATTR_CHAR_CASEMAP,      SID_ATTR_CHAR_LANGUAGE,
622             SID_ATTR_CHAR_KERNING,      SID_CHAR_DLG,               SID_ATTR_CHAR_WORDLINEMODE,
623             FN_GROW_FONT_SIZE,          FN_SHRINK_FONT_SIZE,        FN_TXTATR_INET,
624             FN_FORMAT_DROPCAPS,         SID_ATTR_PARA_ADJUST,       SID_ATTR_PARA_LINESPACE,
625             SID_ATTR_PARA_SPLIT,        SID_ATTR_PARA_KEEP,         SID_ATTR_PARA_WIDOWS,
626             SID_ATTR_PARA_ORPHANS,
627             SID_ATTR_PARA_MODEL,        SID_PARA_DLG,
628             FN_SELECT_PARA,             SID_DEC_INDENT,
629             SID_INC_INDENT
630         };
631         static sal_Bool bFirst = sal_True;
632         if ( bFirst )
633         {
634             qsort( (void*)aROIds, sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
635             bFirst = sal_False;
636         }
637         if ( SFX_ITEM_DISABLED == eStateRO )
638         {
639             rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
640             bChgd = sal_True;
641         }
642     }
643     else if( pWrtShell->IsAllProtect() )
644     {
645         if ( SFX_ITEM_DISABLED == eStateProtAll )
646         {
647             static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC, FN_EDIT_REGION };
648             static sal_Bool bAllProtFirst = sal_True;
649             if ( bAllProtFirst )
650             {
651                 qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
652                 bAllProtFirst = sal_False;
653             }
654             rDis.SetSlotFilter( sal_Bool(2),
655                                 sizeof(aAllProtIds)/sizeof(sal_uInt16),
656                                 aAllProtIds );
657             bChgd = sal_True;
658         }
659     }
660     else if ( SFX_ITEM_DISABLED != eStateRO ||
661                 SFX_ITEM_DISABLED != eStateProtAll )
662     {
663         bChgd = sal_True;
664         rDis.SetSlotFilter();
665     }
666     if ( bChgd )
667         GetViewFrame()->GetBindings().InvalidateAll(sal_True);
668 }
669 
670 void SwView::_CheckReadonlySelection()
671 {
672     sal_uInt32 nDisableFlags = 0;
673     SfxDispatcher &rDis = GetDispatcher();
674 
675     if( pWrtShell->HasReadonlySel() &&
676         ( !pWrtShell->GetDrawView() ||
677             !pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
678         nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR;
679 
680     if( (SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags ) !=
681         (SW_DISABLE_ON_PROTECTED_CURSOR & rDis.GetDisableFlags() ) )
682     {
683         // zusaetzlich am Window den InputContext umsetzen, damit in
684         // japanischen / chinesischen Versionen die externe Eingabe
685         // ab-/angeschaltet wird. Das aber nur wenn auch die richtige
686         // Shell auf dem Stack steht.
687         switch( pViewImpl->GetShellMode() )
688         {
689         case SHELL_MODE_TEXT:
690         case SHELL_MODE_LIST_TEXT:
691         case SHELL_MODE_TABLE_TEXT:
692         case SHELL_MODE_TABLE_LIST_TEXT:
693             {
694 //JP 22.01.99: temporaere Loesung!!! Sollte bei jeder Cursorbewegung
695 //          den Font von der akt. Einfuegeposition setzen, also ausserhalb
696 //          dieses if's. Aber TH wertet den Font zur Zeit nicht aus und
697 //          das besorgen erscheint mir hier zu teuer zu sein.
698 //          Ausserdem haben wir keinen Font, sondern nur Attribute aus denen
699 //          die Textformatierung dann den richtigen Font zusammen baut.
700 
701                 InputContext aCntxt( GetEditWin().GetInputContext() );
702                 aCntxt.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags
703                                     ? (aCntxt.GetOptions() & ~
704                                             ( INPUTCONTEXT_TEXT |
705                                                 INPUTCONTEXT_EXTTEXTINPUT ))
706                                     : (aCntxt.GetOptions() |
707                                             ( INPUTCONTEXT_TEXT |
708                                                 INPUTCONTEXT_EXTTEXTINPUT )) );
709                 GetEditWin().SetInputContext( aCntxt );
710             }
711             break;
712         default:
713             ;
714         }
715 
716     }
717 
718     if( nDisableFlags != rDis.GetDisableFlags() )
719     {
720         rDis.SetDisableFlags( nDisableFlags );
721         GetViewFrame()->GetBindings().InvalidateAll( sal_True );
722     }
723 }
724 
725 
726 SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
727     : SfxViewShell( _pFrame, SWVIEWFLAGS ),
728     aPageStr( SW_RES( STR_PAGE )),
729     nNewPage(USHRT_MAX),
730     pNumRuleNodeFromDoc(0), // #i23726#
731     pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ),
732     pWrtShell(0),
733     pShell(0),
734     pFormShell(0),
735     pHScrollbar(0),
736     pVScrollbar(0),
737     pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
738     pHRuler( new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
739                     SVXRULER_SUPPORT_TABS |
740                     SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
741                     SVXRULER_SUPPORT_BORDERS |
742                     SVXRULER_SUPPORT_NEGATIVE_MARGINS|
743                     SVXRULER_SUPPORT_REDUCED_METRIC,
744                     GetViewFrame()->GetBindings(),
745                     WB_STDRULER | WB_EXTRAFIELD | WB_BORDER)),
746     pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
747                             SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL|
748                                 SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC,
749                             GetViewFrame()->GetBindings(),
750                             WB_VSCROLL |  WB_EXTRAFIELD | WB_BORDER )),
751     pTogglePageBtn(0),
752     pPageUpBtn(0),
753     pPageDownBtn(0),
754     pNaviBtn(0),
755     pGlosHdl(0),
756     pDrawActual(0),
757     pLastTableFormat(0),
758     pFormatClipboard(new SwFormatClipboard()),
759     mpPostItMgr(0),
760     nSelectionType( INT_MAX ),
761     nPageCnt(0),
762     nDrawSfxId( USHRT_MAX ),
763     nFormSfxId( USHRT_MAX ),
764     nLastPasteDestination( 0xFFFF ),
765     nLeftBorderDistance( 0 ),
766     //IAccessibility2 Implementation 2009-----
767     nOldPageNum(0),
768     //-----IAccessibility2 Implementation 2009
769     nRightBorderDistance( 0 ),
770     bInMailMerge(sal_False),
771     bInDtor(sal_False),
772     bOldShellWasPagePreView(sal_False),
773     bIsPreviewDoubleClick(sal_False)
774 {
775     // OD 18.12.2002 #103492# - According to discussion with MBA and further
776     // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
777     // if function "New Window" is performed to open an additional view beside
778     // an already existing one.
779     // If the view is switch from one to another, the 'old' view is given by
780     // parameter <pOldSh>.
781 
782     RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwView::SwView" );
783 
784     bCenterCrsr = bTopCrsr = bAllwaysShowSel = bTabColFromDoc = bTabRowFromDoc =
785     bSetTabColFromDoc = bSetTabRowFromDoc = bAttrChgNotified = bAttrChgNotifiedWithRegistrations =
786     bVerbsActive = bDrawRotate = bInOuterResizePixel = bInInnerResizePixel =
787     bPasteState = bPasteSpecialState = bMakeSelectionVisible = sal_False;
788 
789     bShowAtResize = bDrawSelMode = bDocSzUpdated = sal_True;
790 
791     _CreateScrollbar( sal_True );
792     _CreateScrollbar( sal_False );
793 
794     pViewImpl = new SwView_Impl(this);
795     SetName(C2S("View"));
796     SetWindow( pEditWin );
797 
798     aTimer.SetTimeout( 120 );
799 
800     SwDocShell* pDocSh = PTR_CAST( SwDocShell, _pFrame->GetObjectShell() );
801     sal_Bool bOldModifyFlag = pDocSh->IsEnableSetModified();
802     if(bOldModifyFlag)
803         pDocSh->EnableSetModified( sal_False );
804     ASSERT( pDocSh, "View ohne DocShell." );
805     SwWebDocShell* pWebDShell = PTR_CAST( SwWebDocShell, pDocSh );
806 
807     const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != pWebDShell);
808     SwViewOption aUsrPref( *pUsrPref);
809 
810     //! get lingu options without loading lingu DLL
811     SvtLinguOptions aLinguOpt;
812     SvtLinguConfig().GetOptions( aLinguOpt );
813     aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );
814 
815     sal_Bool bOldShellWasSrcView = sal_False;
816 
817     // OD 18.12.2002 #103492# - determine, if there is an existing view for
818     // document
819     SfxViewShell* pExistingSh = 0;
820     if ( pOldSh )
821     {
822         pExistingSh = pOldSh;
823         // determine type of existing view
824         if( pExistingSh->IsA( TYPE( SwPagePreView ) ) )
825         {
826             sSwViewData = ((SwPagePreView*)pExistingSh)->GetPrevSwViewData();
827             sNewCrsrPos = ((SwPagePreView*)pExistingSh)->GetNewCrsrPos();
828             nNewPage = ((SwPagePreView*)pExistingSh)->GetNewPage();
829             bOldShellWasPagePreView = sal_True;
830             bIsPreviewDoubleClick = sNewCrsrPos.Len() > 0 || nNewPage != USHRT_MAX;
831         }
832         else if( pExistingSh->IsA( TYPE( SwSrcView ) ) )
833             bOldShellWasSrcView = sal_True;
834     }
835 
836     RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create WrtShell" );
837     if(PTR_CAST( SwView, pExistingSh))
838     {
839         pWrtShell = new SwWrtShell( *((SwView*)pExistingSh)->pWrtShell,
840                                     pEditWin, *this);
841     }
842     else if( dynamic_cast<SwWrtShell*>( pDocSh->GetDoc()->GetCurrentViewShell() ) )
843     {
844         pWrtShell = new SwWrtShell( *(SwWrtShell*)pDocSh->GetDoc()->GetCurrentViewShell(),
845                                     pEditWin, *this);
846     }
847     else
848     {
849         SwDoc& rDoc = *((SwDocShell*)pDocSh)->GetDoc();
850 
851         if( !bOldShellWasSrcView && pWebDShell && !bOldShellWasPagePreView )
852             aUsrPref.setBrowseMode( sal_True );
853         else if( rDoc.IsLoaded() )
854             aUsrPref.setBrowseMode( rDoc.get(IDocumentSettingAccess::BROWSE_MODE) );
855 
856         //Fuer den BrowseMode wollen wir keinen Factor uebernehmen.
857         if( aUsrPref.getBrowseMode() && aUsrPref.GetZoomType() != SVX_ZOOM_PERCENT )
858         {
859             aUsrPref.SetZoomType( SVX_ZOOM_PERCENT );
860             aUsrPref.SetZoom( 100 );
861         }
862         if(pDocSh->IsPreview())
863         {
864             aUsrPref.SetZoomType( SVX_ZOOM_WHOLEPAGE );
865             aUsrPref.SetViewLayoutBookMode( false );
866             aUsrPref.SetViewLayoutColumns( 1 );
867         }
868         pWrtShell = new SwWrtShell( rDoc, pEditWin, *this, &aUsrPref );
869         //#97610# creating an SwView from a SwPagePreView needs to
870         // add the ViewShell to the ring of the other ViewShell(s)
871         if(bOldShellWasPagePreView)
872         {
873             ViewShell& rPreviewViewShell = *((SwPagePreView*)pExistingSh)->GetViewShell();
874             pWrtShell->MoveTo(&rPreviewViewShell);
875             //#95521# to update the field command et.al. if necessary
876             const SwViewOption* pPreViewOpt = rPreviewViewShell.GetViewOptions();
877             if( pPreViewOpt->IsFldName() != aUsrPref.IsFldName() ||
878                     pPreViewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() ||
879                     pPreViewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() ||
880                     pPreViewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() )
881                 rPreviewViewShell.ApplyViewOptions(aUsrPref);
882             // OD 09.01.2003 #106334# - reset design mode at draw view for form
883             // shell, if needed.
884             if ( ((SwPagePreView*)pExistingSh)->ResetFormDesignMode() &&
885                  pWrtShell->HasDrawView() )
886             {
887                 SdrView* pDrawView = pWrtShell->GetDrawView();
888                 pDrawView->SetDesignMode( ((SwPagePreView*)pExistingSh)->FormDesignModeToReset() );
889             }
890         }
891     }
892     RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create WrtShell" );
893 
894     // --> OD 2005-02-11 #i38810# - assure that modified state of document
895     // isn't reset, if document is already modified.
896     const bool bIsDocModified = pWrtShell->GetDoc()->IsModified();
897     // <--
898 
899     // JP 05.02.99: Bug 61495 - damit unter anderem das HLineal im
900     //              ReadonlyFall nicht angezeigt wird
901     aUsrPref.SetReadonly( pWrtShell->GetViewOptions()->IsReadonly() );
902 
903     //Kein Margin fuer OLE!
904     Size aBrwsBorder;
905     if( SFX_CREATE_MODE_EMBEDDED != pDocSh->GetCreateMode() )
906         aBrwsBorder = GetMargin();
907 
908     pWrtShell->SetBrowseBorder( aBrwsBorder );
909 
910     // Im CTOR duerfen keine Shell wechsel erfolgen, die muessen ueber
911     // den Timer "zwischen gespeichert" werden. Sonst raeumt der SFX
912     // sie wieder vom Stack!
913     sal_Bool bOld = bNoInterrupt;
914     bNoInterrupt = sal_True;
915 
916     pHRuler->SetActive( sal_True );
917     pVRuler->SetActive( sal_True );
918 
919     SfxViewFrame* pViewFrame = GetViewFrame();
920     if( pViewFrame->GetFrame().GetParentFrame())
921     {
922         aUsrPref.SetViewHRuler(sal_False);
923         aUsrPref.SetViewVRuler(sal_False);
924     }
925 
926     StartListening( *pViewFrame, sal_True );
927     StartListening( *pDocSh, sal_True );
928 
929     // Vom HLineal den ZOOM-Faktor einstellen
930     Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
931     pHRuler->SetZoom( aZoomFract );
932     pVRuler->SetZoom( aZoomFract );
933     pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick ));
934     FieldUnit eMetric = pUsrPref->GetHScrollMetric();
935     pHRuler->SetUnit( eMetric );
936     eMetric = pUsrPref->GetVScrollMetric();
937     pVRuler->SetUnit( eMetric );
938 
939     // DocShell setzen
940     pDocSh->SetView( this );
941     SW_MOD()->SetView( this );
942 
943     mpPostItMgr = new SwPostItMgr(this);
944 
945     // Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
946     // die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
947     // nicht in der SFX-Verwaltung bekannt ist.
948     DocSzChgd( pWrtShell->GetDocSize() );
949 
950         // AttrChangedNotify Link setzen
951     pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify));
952 
953     if( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
954         //TODO/LATER: why a cast here?
955         //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() )
956         //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False);
957         !pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() )
958         SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False);
959 
960     pWrtShell->DoUndo( 0 != SW_MOD()->GetUndoOptions().GetUndoCount() );
961 
962     const sal_Bool bBrowse = pWrtShell->GetViewOptions()->getBrowseMode();
963     // Disable "multiple window"
964     SetNewWindowAllowed(!bBrowse);
965     // End of disabled multiple window
966 
967     ShowVScrollbar(aUsrPref.IsViewVScrollBar());
968     ShowHScrollbar(aUsrPref.IsViewHScrollBar());
969     pHScrollbar->SetAuto(bBrowse);
970     if( aUsrPref.IsViewHRuler() )
971         CreateTab();
972     if( aUsrPref.IsViewVRuler() )
973         CreateVLineal();
974 
975     pWrtShell->SetUIOptions( aUsrPref );
976     pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() );
977     pWrtShell->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
978 
979     if( pWrtShell->GetDoc()->IsUpdateExpFld() )
980     {
981         SET_CURR_SHELL( pWrtShell );
982         pWrtShell->StartAction();
983         pWrtShell->CalcLayout();
984         pWrtShell->GetDoc()->UpdateFlds(NULL, false);
985         pWrtShell->EndAction();
986         pWrtShell->GetDoc()->SetUpdateExpFldStat( sal_False );
987     }
988 
989     // ggfs. alle Verzeichnisse updaten:
990     if( pWrtShell->GetDoc()->IsUpdateTOX() )
991     {
992         SfxRequest aSfxRequest( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
993         Execute( aSfxRequest );
994         pWrtShell->GetDoc()->SetUpdateTOX( sal_False );     // wieder zurueck setzen
995         pWrtShell->SttEndDoc(sal_True);
996     }
997 
998     // kein ResetModified, wenn es schone eine View auf dieses Doc gibt
999     SfxViewFrame* pVFrame = GetViewFrame();
1000     SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
1001     // zur Zeit(360) wird die View erst nach dem Ctor eingetragen
1002     // der folgende Ausdruck funktioniert auch, wenn sich das aendert
1003     //JP 27.07.98: wenn per Undo nicht mehr die Modifizierung aufhebar ist,
1004     //              so setze das Modified NICHT zurueck.
1005     // --> OD 2005-02-11 #i38810# - no reset of modified state, if document
1006     // was already modified.
1007     if (!pWrtShell->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
1008          ( !pFirst || pFirst == pVFrame ) &&
1009          !bIsDocModified )
1010     // <--
1011     {
1012         pWrtShell->ResetModified();
1013     }
1014 
1015     bNoInterrupt = bOld;
1016 
1017     // wird ein GlobalDoc neu angelegt, soll auch der Navigator erzeugt werden
1018     if( pDocSh->IsA(SwGlobalDocShell::StaticType()) &&
1019         !pVFrame->GetChildWindow( SID_NAVIGATOR ))
1020     {
1021         SfxBoolItem aNavi(SID_NAVIGATOR, sal_True);
1022         GetDispatcher().Execute(SID_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, &aNavi, 0L);
1023     }
1024 
1025 
1026    uno::Reference< frame::XFrame >  xFrame = pVFrame->GetFrame().GetFrameInterface();
1027 
1028     uno::Reference< frame::XFrame >  xBeamerFrame = xFrame->findFrame(
1029             OUString::createFromAscii("_beamer"), frame::FrameSearchFlag::CHILDREN);
1030     if(xBeamerFrame.is())
1031     {
1032         SwDBData aData = pWrtShell->GetDBData();
1033         SW_MOD()->ShowDBObj( *this, aData );
1034     }
1035 
1036     // has anybody calls the attrchanged handler in the constructor?
1037     if( bAttrChgNotifiedWithRegistrations )
1038     {
1039         GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1040         if( aTimer.IsActive() )
1041             aTimer.Stop();
1042     }
1043 
1044     aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl));
1045     bAttrChgNotified = bAttrChgNotifiedWithRegistrations = sal_False;
1046     if(bOldModifyFlag)
1047         pDocSh->EnableSetModified( sal_True );
1048     InvalidateBorder();
1049 }
1050 
1051 SwView::~SwView()
1052 {
1053     delete mpPostItMgr;
1054     // --> OD 2009-03-10 #i100035#
1055     mpPostItMgr = 0;
1056     // <--
1057 
1058     bInDtor = sal_True;
1059     pEditWin->Hide(); // damit kein Paint Aerger machen kann!
1060     // 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 );
1066 
1067     if( aTimer.IsActive() && bAttrChgNotifiedWithRegistrations )
1068         GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1069 
1070     //JP 27.11.00: Bug 80631 - the last view must end the text edit
1071     SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : 0;
1072     if( pSdrView && pSdrView->IsTextEdit() )
1073         pSdrView->SdrEndTextEdit( sal_True );
1074 
1075     SetWindow( 0 );
1076 
1077     pViewImpl->Invalidate();
1078     EndListening(*GetViewFrame());
1079     EndListening(*GetDocShell());
1080     delete pScrollFill;
1081     delete pWrtShell;
1082     pWrtShell = 0;      // Auf 0 setzen, damit folgende DToren nicht drauf zugreifen
1083     pShell = 0;
1084     delete pHScrollbar;
1085     delete pVScrollbar;
1086     delete pHRuler;
1087     delete pVRuler;
1088     delete pTogglePageBtn;
1089     delete pPageUpBtn;
1090     delete pNaviBtn;
1091     delete pPageDownBtn;
1092     delete pGlosHdl;
1093     delete pViewImpl;
1094     delete pEditWin;
1095     delete pFormatClipboard;
1096 }
1097 
1098 SwDocShell* SwView::GetDocShell()
1099 {
1100     SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell();
1101     return PTR_CAST(SwDocShell, pDocShell);
1102 }
1103 
1104 /*--------------------------------------------------------------------
1105     Beschreibung:   CursorPos merken
1106  --------------------------------------------------------------------*/
1107 
1108 
1109 void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse )
1110 {
1111     //Das Browse-Flag wird vom Sfx durchgereicht, wenn Dokumente gebrowsed
1112     //werden (nicht zu verwechseln mit dem BrowseMode).
1113     //Die dann gespeicherten Daten sind nicht persistent!!
1114 
1115     const SwRect& rRect = pWrtShell->GetCharRect();
1116     const Rectangle& rVis = GetVisArea();
1117 
1118     rUserData = String::CreateFromInt32( rRect.Left() );
1119     rUserData += ';';
1120     rUserData += String::CreateFromInt32( rRect.Top() );
1121     rUserData += ';';
1122     rUserData += String::CreateFromInt32( pWrtShell->GetViewOptions()->GetZoom() );
1123     rUserData += ';';
1124     rUserData += String::CreateFromInt32( rVis.Left() );
1125     rUserData += ';';
1126     rUserData += String::CreateFromInt32( rVis.Top() );
1127     rUserData += ';';
1128     rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Right());
1129     rUserData += ';';
1130     rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Bottom());
1131     rUserData += ';';
1132     rUserData += String::CreateFromInt32(
1133             (sal_uInt16)pWrtShell->GetViewOptions()->GetZoomType());//eZoom;
1134     rUserData += ';';
1135     rUserData += FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? '0' : '1';
1136 }
1137 /*--------------------------------------------------------------------
1138     Beschreibung: CursorPos setzen
1139  --------------------------------------------------------------------*/
1140 //#i43146# go to the last editing position when opening own files
1141 bool lcl_IsOwnDocument( SwView& rView )
1142 {
1143     uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1144         rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
1145     uno::Reference<document::XDocumentProperties> xDocProps
1146         = xDPS->getDocumentProperties();
1147     String Created = xDocProps->getAuthor();
1148     String Changed = xDocProps->getModifiedBy();
1149     String FullName = SW_MOD()->GetUserOptions().GetFullName();
1150     return (FullName.Len() &&
1151             (Changed.Len() && Changed == FullName )) ||
1152             (!Changed.Len() && Created.Len() && Created == FullName );
1153 }
1154 
1155 
1156 void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse )
1157 {
1158     if ( rUserData.GetTokenCount() > 1 &&
1159         //Fuer Dokumente ohne Layout nur im OnlineLayout oder beim
1160         //Forward/Backward
1161          (!pWrtShell->IsNewLayout() || pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
1162     {
1163         //#i43146# go to the last editing position when opening own files
1164         bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1165 
1166         SET_CURR_SHELL(pWrtShell);
1167 
1168         sal_uInt16 nPos = 0;
1169 
1170         // Nein, es ist *keine* gute Idee GetToken gleich im Point-Konstr.
1171         // aufzurufen, denn welcher Parameter wird zuerst ausgewertet?
1172         long nX = rUserData.GetToken( 0, ';', nPos ).ToInt32(),
1173              nY = rUserData.GetToken( 0, ';', nPos ).ToInt32();
1174         Point aCrsrPos( nX, nY );
1175 
1176         sal_uInt16 nZoomFactor =
1177             static_cast< sal_uInt16 >( rUserData.GetToken(0, ';', nPos ).ToInt32() );
1178 
1179         long nLeft  = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1180              nTop   = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1181              nRight = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1182              nBottom= rUserData.GetToken(0, ';', nPos ).ToInt32();
1183 
1184         const long nAdd = pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1185         if ( nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
1186         {
1187             pWrtShell->EnableSmooth( sal_False );
1188 
1189             const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1190 
1191             sal_uInt16 nOff = 0;
1192             SvxZoomType eZoom;
1193             if( !pWrtShell->GetViewOptions()->getBrowseMode() )
1194                 eZoom = (SvxZoomType) (sal_uInt16)rUserData.GetToken(nOff, ';', nPos ).ToInt32();
1195             else
1196             {
1197                 eZoom = SVX_ZOOM_PERCENT;
1198                 ++nOff;
1199             }
1200 
1201             sal_Bool bSelectObj = (0 != rUserData.GetToken( nOff, ';', nPos ).ToInt32())
1202                                 && pWrtShell->IsObjSelectable( aCrsrPos );
1203 
1204             //#i33307# restore editing position
1205             pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1206             // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
1207             bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
1208             pWrtShell->SetMacroExecAllowed( false );
1209 //!!! pb (11.08.2004): #i32536#
1210 // os: changed: The user data has to be read if the view is switched back from page preview
1211 //#i43146# go to the last editing position when opening own files
1212             if(bOldShellWasPagePreView || bIsOwnDocument)
1213             {
1214                 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1215                 if( bSelectObj )
1216                 {
1217                     pWrtShell->SelectObj( aCrsrPos );
1218                     pWrtShell->EnterSelFrmMode( &aCrsrPos );
1219                 }
1220             }
1221 
1222             // OD 11.02.2003 #100556# - reset flag value
1223             pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1224 
1225             // OD 08.04.2003 #108693# - set visible area before applying
1226             // information from print preview. Otherwise, the applied information
1227             // is lost.
1228 //!!! pb (11.08.2004): #i32536#
1229 // os: changed: The user data has to be read if the view is switched back from page preview
1230 //#i43146# go to the last editing position when opening own files
1231             if(bOldShellWasPagePreView || bIsOwnDocument )
1232             {
1233                 if ( bBrowse )
1234                     SetVisArea( aVis.TopLeft() );
1235                 else
1236                     SetVisArea( aVis );
1237             }
1238 
1239             //apply information from print preview - if available
1240             if( sNewCrsrPos.Len() )
1241             {
1242                 long nXTmp = sNewCrsrPos.GetToken( 0, ';' ).ToInt32(),
1243                      nYTmp = sNewCrsrPos.GetToken( 1, ';' ).ToInt32();
1244                 Point aCrsrPos2( nXTmp, nYTmp );
1245                 bSelectObj = pWrtShell->IsObjSelectable( aCrsrPos2 );
1246 
1247                 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos2, sal_False );
1248                 if( bSelectObj )
1249                 {
1250                     pWrtShell->SelectObj( aCrsrPos2 );
1251                     pWrtShell->EnterSelFrmMode( &aCrsrPos2 );
1252                 }
1253                 pWrtShell->MakeSelVisible();
1254                 sNewCrsrPos.Erase();
1255             }
1256             else if(USHRT_MAX != nNewPage)
1257             {
1258                 pWrtShell->GotoPage(nNewPage, sal_True);
1259                 nNewPage = USHRT_MAX;
1260             }
1261 
1262             SelectShell();
1263 
1264             pWrtShell->StartAction();
1265             const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
1266             if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom )
1267                 SetZoom( eZoom, nZoomFactor);
1268 
1269             pWrtShell->LockView( sal_True );
1270             pWrtShell->EndAction();
1271             pWrtShell->LockView( sal_False );
1272             pWrtShell->EnableSmooth( sal_True );
1273         }
1274     }
1275 }
1276 
1277 void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1278 {
1279     if(GetDocShell()->IsPreview()||bIsPreviewDoubleClick)
1280         return;
1281     //#i43146# go to the last editing position when opening own files
1282     bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1283     sal_Int32 nLength = rSequence.getLength();
1284     if (nLength && (!pWrtShell->IsNewLayout() || pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
1285     {
1286         SET_CURR_SHELL(pWrtShell);
1287         const beans::PropertyValue *pValue = rSequence.getConstArray();
1288         const SwRect& rRect = pWrtShell->GetCharRect();
1289         const Rectangle &rVis = GetVisArea();
1290         const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
1291 
1292         long nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top();
1293         long nRight = bBrowse ? LONG_MIN : rVis.Right(), nBottom = bBrowse ? LONG_MIN : rVis.Bottom();
1294         sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
1295         sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
1296         bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
1297         sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
1298 
1299         sal_Bool bSelectedFrame = ( pWrtShell->GetSelFrmType() != FRMTYPE_NONE ),
1300                  bGotViewLeft = sal_False, bGotViewTop = sal_False, bGotVisibleLeft = sal_False,
1301                  bGotVisibleTop = sal_False, bGotVisibleRight = sal_False,
1302                  bGotVisibleBottom = sal_False, bGotZoomType = sal_False,
1303                  bGotZoomFactor = sal_False, bGotIsSelectedFrame = sal_False,
1304                  bGotViewLayoutColumns = sal_False, bGotViewLayoutBookMode = sal_False;
1305 
1306         for (sal_Int16 i = 0 ; i < nLength; i++)
1307         {
1308             if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLeft" ) ) )
1309             {
1310                pValue->Value >>= nX;
1311                nX = MM100_TO_TWIP( nX );
1312                bGotViewLeft = sal_True;
1313             }
1314             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewTop" ) ) )
1315             {
1316                pValue->Value >>= nY;
1317                nY = MM100_TO_TWIP( nY );
1318                bGotViewTop = sal_True;
1319             }
1320             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleLeft" ) ) )
1321             {
1322                pValue->Value >>= nLeft;
1323                nLeft = MM100_TO_TWIP( nLeft );
1324                bGotVisibleLeft = sal_True;
1325             }
1326             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleTop" ) ) )
1327             {
1328                pValue->Value >>= nTop;
1329                nTop = MM100_TO_TWIP( nTop );
1330                bGotVisibleTop = sal_True;
1331             }
1332             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleRight" ) ) )
1333             {
1334                pValue->Value >>= nRight;
1335                nRight = MM100_TO_TWIP( nRight );
1336                bGotVisibleRight = sal_True;
1337             }
1338             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleBottom" ) ) )
1339             {
1340                pValue->Value >>= nBottom;
1341                nBottom = MM100_TO_TWIP( nBottom );
1342                bGotVisibleBottom = sal_True;
1343             }
1344             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomType" ) ) )
1345             {
1346                pValue->Value >>= nZoomType;
1347                bGotZoomType = sal_True;
1348             }
1349             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomFactor" ) ) )
1350             {
1351                pValue->Value >>= nZoomFactor;
1352                bGotZoomFactor = sal_True;
1353             }
1354             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutColumns" ) ) )
1355             {
1356                pValue->Value >>= nViewLayoutColumns;
1357                bGotViewLayoutColumns = sal_True;
1358             }
1359             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutBookMode" ) ) )
1360             {
1361                bViewLayoutBookMode = * (sal_Bool *) pValue->Value.getValue();
1362                bGotViewLayoutBookMode = sal_True;
1363             }
1364             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsSelectedFrame" ) ) )
1365             {
1366                pValue->Value >>= bSelectedFrame;
1367                bGotIsSelectedFrame = sal_True;
1368             }
1369             pValue++;
1370         }
1371         if (bGotVisibleBottom)
1372         {
1373             Point aCrsrPos( nX, nY );
1374             const long nAdd = pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1375             if (nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
1376             {
1377                 pWrtShell->EnableSmooth( sal_False );
1378                 const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1379 
1380                 sal_uInt16 nOff = 0;
1381                 SvxZoomType eZoom;
1382                 if ( !pWrtShell->GetViewOptions()->getBrowseMode() )
1383                     eZoom = static_cast < SvxZoomType > ( nZoomType );
1384                 else
1385                 {
1386                     eZoom = SVX_ZOOM_PERCENT;
1387                     ++nOff;
1388                 }
1389                 if (bGotIsSelectedFrame)
1390                 {
1391                     sal_Bool bSelectObj = (sal_False != bSelectedFrame )
1392                                         && pWrtShell->IsObjSelectable( aCrsrPos );
1393 
1394                     // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
1395                     bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
1396                     pWrtShell->SetMacroExecAllowed( false );
1397 //!!! pb (11.08.2004): #i32536#
1398 // os: changed: The user data has to be read if the view is switched back from page preview
1399 //#i43146# go to the last editing position when opening own files
1400                     //#i33307# restore editing position
1401                     pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1402                     if(bOldShellWasPagePreView|| bIsOwnDocument)
1403                     {
1404                         pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1405                         if( bSelectObj )
1406                         {
1407                             pWrtShell->SelectObj( aCrsrPos );
1408                             pWrtShell->EnterSelFrmMode( &aCrsrPos );
1409                         }
1410                     }
1411 
1412                     // OD 11.02.2003 #100556# - reset flag value
1413                     pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1414                 }
1415                 SelectShell();
1416 
1417                 // Set ViewLayoutSettings
1418                 const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode &&
1419                                                     ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode );
1420 
1421                 const bool bSetViewSettings = bGotZoomType && bGotZoomFactor &&
1422                                               ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom );
1423 
1424                 // In case we have a 'fixed' view layout of 2 or more columns,
1425                 // we have to apply the view options *before* starting the action.
1426                 // Otherwsie the SetZoom function cannot work correctly, because
1427                 // the view layout hasn't been calculated.
1428                 const bool bZoomNeedsViewLayout = bSetViewLayoutSettings &&
1429                                                   1 < nViewLayoutColumns &&
1430                                                   bSetViewSettings &&
1431                                                   eZoom != SVX_ZOOM_PERCENT;
1432 
1433 
1434                 if ( !bZoomNeedsViewLayout )
1435                     pWrtShell->StartAction();
1436 
1437                 if ( bSetViewLayoutSettings )
1438                     SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, sal_True );
1439 
1440                 if ( bZoomNeedsViewLayout )
1441                     pWrtShell->StartAction();
1442 
1443                 if ( bSetViewSettings )
1444                     SetZoom( eZoom, nZoomFactor, sal_True );
1445 
1446 //!!! pb (11.08.2004): #i32536#
1447 // os: changed: The user data has to be read if the view is switched back from page preview
1448 //#i43146# go to the last editing position when opening own files
1449                 if(bOldShellWasPagePreView||bIsOwnDocument)
1450                 {
1451                     if ( bBrowse && bGotVisibleLeft && bGotVisibleTop )
1452                     {
1453                         Point aTopLeft(aVis.TopLeft());
1454                         //#i76699# make sure the document is still centered
1455                         const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * DOCUMENTBORDER;
1456                         SwTwips nEditWidth = GetEditWin().GetOutputSize().Width();
1457                         if(nEditWidth > (aDocSz.Width() + lBorder ))
1458                             aTopLeft.X() = ( aDocSz.Width() + lBorder - nEditWidth  ) / 2;
1459                         else
1460                         {
1461                             //check if the values are possible
1462                             long nXMax = pHScrollbar->GetRangeMax() - pHScrollbar->GetVisibleSize();
1463                             if( aTopLeft.X() > nXMax )
1464                                 aTopLeft.X() = nXMax < 0 ? 0 : nXMax;
1465                         }
1466                         SetVisArea( aTopLeft );
1467                     }
1468                     else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom )
1469                         SetVisArea( aVis );
1470                 }
1471 
1472                 pWrtShell->LockView( sal_True );
1473                 pWrtShell->EndAction();
1474                 pWrtShell->LockView( sal_False );
1475                 pWrtShell->EnableSmooth( sal_True );
1476             }
1477         }
1478     }
1479 }
1480 #define NUM_VIEW_SETTINGS 12
1481 void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1482 {
1483     const SwRect& rRect = pWrtShell->GetCharRect();
1484     const Rectangle& rVis = GetVisArea();
1485     Any aAny;
1486 
1487     rSequence.realloc ( NUM_VIEW_SETTINGS );
1488     sal_Int16 nIndex = 0;
1489     beans::PropertyValue *pValue = rSequence.getArray();
1490 
1491     sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
1492     pValue->Name = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "ViewId" ) );
1493     OUStringBuffer sBuffer ( OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
1494     SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
1495     pValue->Value <<= sBuffer.makeStringAndClear();
1496     pValue++;nIndex++;
1497 
1498     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLeft" ) );
1499     pValue->Value <<= TWIP_TO_MM100 ( rRect.Left() );
1500     pValue++;nIndex++;
1501 
1502     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewTop" ) );
1503     pValue->Value <<= TWIP_TO_MM100 ( rRect.Top() );
1504     pValue++;nIndex++;
1505 
1506     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleLeft" ) );
1507     pValue->Value <<= TWIP_TO_MM100 ( rVis.Left() );
1508     pValue++;nIndex++;
1509 
1510     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleTop" ) );
1511     pValue->Value <<= TWIP_TO_MM100 ( rVis.Top() );
1512     pValue++;nIndex++;
1513 
1514     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleRight" ) );
1515     pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Right() );
1516     pValue++;nIndex++;
1517 
1518     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleBottom" ) );
1519     pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Bottom() );
1520     pValue++;nIndex++;
1521 
1522     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomType" ) );
1523     const sal_Int16 nZoomType = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetZoomType());
1524     pValue->Value <<= nZoomType;
1525     pValue++;nIndex++;
1526 
1527     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutColumns" ) );
1528     const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetViewLayoutColumns());
1529     pValue->Value <<= nViewLayoutColumns;
1530     pValue++;nIndex++;
1531 
1532     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutBookMode" ) );
1533     const sal_Bool bIsViewLayoutBookMode = pWrtShell->GetViewOptions()->IsViewLayoutBookMode();
1534     pValue->Value.setValue( &bIsViewLayoutBookMode, ::getBooleanCppuType() );
1535     pValue++;nIndex++;
1536 
1537     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomFactor" ) );
1538     pValue->Value <<= static_cast < sal_Int16 > (pWrtShell->GetViewOptions()->GetZoom());
1539     pValue++;nIndex++;
1540 
1541     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "IsSelectedFrame" ) );
1542     const sal_Bool bIsSelected = FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? sal_False : sal_True;
1543     pValue->Value.setValue ( &bIsSelected, ::getBooleanCppuType() );
1544     nIndex++;
1545 
1546     if ( nIndex < NUM_VIEW_SETTINGS )
1547         rSequence.realloc ( nIndex );
1548 }
1549 #undef NUM_VIEW_SETTINGS
1550 
1551 
1552 
1553 void SwView::ShowCursor( FASTBOOL bOn )
1554 {
1555     //JP 10.10.2001: Bug 90461 - don't scroll the cursor into the visible area
1556     sal_Bool bUnlockView = !pWrtShell->IsViewLocked();
1557     pWrtShell->LockView( sal_True );    //lock visible section
1558 
1559     if( !bOn )
1560         pWrtShell->HideCrsr();
1561     else if( !pWrtShell->IsFrmSelected() && !pWrtShell->IsObjSelected() )
1562         pWrtShell->ShowCrsr();
1563 
1564     if( bUnlockView )
1565         pWrtShell->LockView( sal_False );
1566 }
1567 
1568 
1569 
1570 ErrCode SwView::DoVerb( long nVerb )
1571 {
1572     if ( !GetViewFrame()->GetFrame().IsInPlace() )
1573     {
1574         SwWrtShell &rSh = GetWrtShell();
1575         const int nSel = rSh.GetSelectionType();
1576         if ( nSel & nsSelectionType::SEL_OLE )
1577             rSh.LaunchOLEObj( nVerb );
1578     }
1579     return ERRCODE_NONE;
1580 }
1581 
1582 /*-----------------17.02.98 13:33-------------------
1583     nur sal_True fuer eine Textselektion zurueck geben
1584 --------------------------------------------------*/
1585 sal_Bool SwView::HasSelection( sal_Bool  bText ) const
1586 {
1587     return bText ? GetWrtShell().SwCrsrShell::HasSelection()
1588                  : GetWrtShell().HasSelection();
1589 }
1590 
1591 /*-----------------09/16/97 09:50am-----------------
1592 
1593 --------------------------------------------------*/
1594 
1595 String SwView::GetSelectionText( sal_Bool bCompleteWrds )
1596 {
1597     return GetSelectionTextParam( bCompleteWrds, sal_True );
1598 }
1599 
1600 /*-----------------09/16/97 09:50am-----------------
1601 
1602 --------------------------------------------------*/
1603 String  SwView::GetSelectionTextParam( sal_Bool bCompleteWrds,
1604                                        sal_Bool bEraseTrail )
1605 {
1606     String sReturn;
1607     if( bCompleteWrds && !GetWrtShell().HasSelection() )
1608         GetWrtShell().SelWrd();
1609 
1610     GetWrtShell().GetSelectedText( sReturn );
1611     if( bEraseTrail )
1612         sReturn.EraseTrailingChars();
1613     return sReturn;
1614 }
1615 
1616 /*--------------------------------------------------------------------
1617     Beschreibung:
1618  --------------------------------------------------------------------*/
1619 
1620 
1621 
1622 SwGlossaryHdl* SwView::GetGlosHdl()
1623 {
1624     if(!pGlosHdl)
1625         pGlosHdl = new SwGlossaryHdl(GetViewFrame(), pWrtShell);
1626     return pGlosHdl;
1627 }
1628 
1629 /*-----------------05.09.96 15.50-------------------
1630 
1631 --------------------------------------------------*/
1632 
1633 
1634 
1635 void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1636 {
1637     sal_Bool bCallBase = sal_True;
1638     if ( rHint.ISA(SfxSimpleHint) )
1639     {
1640         sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
1641         switch ( nId )
1642         {
1643             // --> OD 2005-03-03 #i43775# - sub shells will be destroyed by the
1644             // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1645             case SFX_HINT_DYING:
1646                 {
1647                     if ( &rBC == GetViewFrame() )
1648                     {
1649                         ResetSubShell();
1650                     }
1651                 }
1652                 break;
1653             // <--
1654             case SFX_HINT_MODECHANGED:
1655                 {
1656                     // Modalmodus-Umschaltung?
1657                     sal_Bool bModal = GetDocShell()->IsInModalMode();
1658                     pHRuler->SetActive( !bModal );
1659                     pVRuler->SetActive( !bModal );
1660                 }
1661 
1662                 /* kein break hier */
1663 
1664             case SFX_HINT_TITLECHANGED:
1665                 if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1666                 {
1667                     SwWrtShell &rSh = GetWrtShell();
1668                     rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1669 
1670                     if ( rSh.GetViewOptions()->IsViewVRuler() )
1671                         CreateVLineal();
1672                     else
1673                         KillVLineal();
1674                     if ( rSh.GetViewOptions()->IsViewHRuler() )
1675                         CreateTab();
1676                     else
1677                         KillTab();
1678                     bool bReadonly = GetDocShell()->IsReadOnly();
1679                     //#i76332# if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode
1680                     if( !bReadonly )
1681                     {
1682                         SwDrawDocument * pDrawDoc = 0;
1683                         if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) )
1684                         {
1685                             if( !pDrawDoc->GetOpenInDesignMode() )
1686                                 break;// don't touch the design mode
1687                         }
1688                     }
1689                     SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly);
1690                     GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON,
1691                                                 &aItem, 0L );
1692                 }
1693                 break;
1694 
1695             case SW_BROADCAST_DRAWVIEWS_CREATED:
1696                 {
1697                     bCallBase = sal_False;
1698                     if ( GetFormShell() )
1699                     {
1700                         GetFormShell()->SetView(
1701                             PTR_CAST(FmFormView, GetWrtShell().GetDrawView()) );
1702                         SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly());
1703                         GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON,
1704                                                   &aItem, 0L );
1705                     }
1706                 }
1707                 break;
1708         }
1709     }
1710     else if(rHint.ISA(FmDesignModeChangedHint))
1711     {
1712         sal_Bool bDesignMode = ((FmDesignModeChangedHint&)rHint).GetDesignMode();
1713         if (!bDesignMode && GetDrawFuncPtr())
1714         {
1715             GetDrawFuncPtr()->Deactivate();
1716             SetDrawFuncPtr(NULL);
1717             LeaveDrawCreate();
1718             AttrChangedNotify(pWrtShell);
1719         }
1720     }
1721 
1722     if ( bCallBase )
1723         SfxViewShell::Notify(rBC, rHint);
1724 }
1725 
1726 /*-----------------02.12.96 12:36-------------------
1727 
1728 --------------------------------------------------*/
1729 #if defined WNT || defined UNX
1730 
1731 void SwView::ScannerEventHdl( const EventObject& /*rEventObject*/ )
1732 {
1733     uno::Reference< XScannerManager > xScanMgr = SW_MOD()->GetScannerManager();
1734     if( xScanMgr.is() )
1735     {
1736         const ScannerContext    aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] );
1737         const ScanError         eError = xScanMgr->getError( aContext );
1738 
1739         if( ScanError_ScanErrorNone == eError )
1740         {
1741             const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) );
1742 
1743             if( xBitmap.is() )
1744             {
1745                 const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
1746 
1747                 if( !!aScanBmp )
1748                 {
1749                     Graphic aGrf(aScanBmp);
1750                     pWrtShell->Insert( aEmptyStr, aEmptyStr, aGrf );
1751                 }
1752             }
1753         }
1754     }
1755     SfxBindings& rBind = GetViewFrame()->GetBindings();
1756     rBind.Invalidate( SID_TWAIN_SELECT );
1757     rBind.Invalidate( SID_TWAIN_TRANSFER );
1758 }
1759 #endif
1760 
1761 /*-----------------04.03.97 15:07-------------------
1762 
1763 --------------------------------------------------*/
1764 
1765 
1766 void    SwView::StopShellTimer()
1767 {
1768     if(aTimer.IsActive())
1769     {
1770         aTimer.Stop();
1771         if ( bAttrChgNotifiedWithRegistrations )
1772         {
1773             GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1774             bAttrChgNotifiedWithRegistrations = sal_False;
1775         }
1776         SelectShell();
1777         bAttrChgNotified = sal_False;
1778     }
1779 }
1780 
1781 /*-----------------09/03/97 04:12pm-----------------
1782 
1783 --------------------------------------------------*/
1784 sal_uInt16  SwView::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
1785 {
1786     SfxViewFrame* pVFrame = GetViewFrame();
1787     pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False );
1788     if( pVFrame->GetDispatcher()->IsLocked() )
1789         pVFrame->GetDispatcher()->Lock(sal_False);
1790 
1791     sal_uInt16 nRet;
1792     if ( pFormShell &&
1793          sal_True != (nRet = pFormShell->PrepareClose( bUI, bForBrowsing )) )
1794 
1795     {
1796         return nRet;
1797     }
1798     return SfxViewShell::PrepareClose( bUI, bForBrowsing );
1799 }
1800 
1801 
1802 
1803     // status methods for clipboard.
1804     // Status changes now notified from the clipboard.
1805 sal_Bool SwView::IsPasteAllowed()
1806 {
1807     sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
1808     if( nLastPasteDestination != nPasteDestination )
1809     {
1810         TransferableDataHelper aDataHelper(
1811                         TransferableDataHelper::CreateFromSystemClipboard(
1812                                                         &GetEditWin()) );
1813         if( aDataHelper.GetXTransferable().is() )
1814         {
1815             bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
1816             bPasteSpecialState = SwTransferable::IsPasteSpecial(
1817                                                     *pWrtShell, aDataHelper );
1818         }
1819         else
1820             bPasteState = bPasteSpecialState = sal_False;
1821 
1822         if( 0xFFFF == nLastPasteDestination )  // the init value
1823             pViewImpl->AddClipboardListener();
1824         nLastPasteDestination = nPasteDestination;
1825     }
1826     return bPasteState;
1827 }
1828 
1829 sal_Bool SwView::IsPasteSpecialAllowed()
1830 {
1831     if ( pFormShell && pFormShell->IsActiveControl() )
1832         return sal_False;
1833 
1834     sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
1835     if( nLastPasteDestination != nPasteDestination )
1836     {
1837         TransferableDataHelper aDataHelper(
1838                         TransferableDataHelper::CreateFromSystemClipboard(
1839                                                         &GetEditWin()) );
1840         if( aDataHelper.GetXTransferable().is() )
1841         {
1842             bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
1843             bPasteSpecialState = SwTransferable::IsPasteSpecial(
1844                                                     *pWrtShell, aDataHelper );
1845         }
1846         else
1847             bPasteState = bPasteSpecialState = sal_False;
1848 
1849         if( 0xFFFF == nLastPasteDestination )  // the init value
1850             pViewImpl->AddClipboardListener();
1851     }
1852     return bPasteSpecialState;
1853 }
1854 /* -----------------------------12.07.01 13:25--------------------------------
1855 
1856  ---------------------------------------------------------------------------*/
1857 void SwView::NotifyDBChanged()
1858 {
1859     GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1860 }
1861 
1862 /*--------------------------------------------------------------------
1863     Beschreibung:   Drucken
1864  --------------------------------------------------------------------*/
1865 
1866 /* -----------------------------28.10.02 13:25--------------------------------
1867 
1868  ---------------------------------------------------------------------------*/
1869 SfxObjectShellLock & SwView::GetTmpSelectionDoc()
1870 {
1871     return GetViewImpl()->GetTmpSelectionDoc();
1872 }
1873 /* -----------------------------31.10.02 13:25--------------------------------
1874 
1875  ---------------------------------------------------------------------------*/
1876 SfxObjectShellLock & SwView::GetOrCreateTmpSelectionDoc()
1877 {
1878     SfxObjectShellLock &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc();
1879     if (!rxTmpDoc.Is())
1880     {
1881         SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl();
1882         rxTmpDoc = pImpl->BuildTmpSelectionDoc();
1883     }
1884     return rxTmpDoc;
1885 }
1886 /* -----------------3/31/2003 12:39PM----------------
1887 
1888  --------------------------------------------------*/
1889 void SwView::AddTransferable(SwTransferable& rTransferable)
1890 {
1891     GetViewImpl()->AddTransferable(rTransferable);
1892 }
1893 
1894 /* --------------------------------------------------*/
1895 
1896 namespace sw {
1897 
1898 void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb)
1899 {
1900     o_rData = *SW_MOD()->GetPrtOptions(bWeb);
1901 }
1902 
1903 } // namespace sw
1904 
1905