xref: /AOO41X/main/sw/source/ui/uiview/view.cxx (revision 0deba7fbda3d9908785c25a443701a293b6f4e71)
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         // --> OD 2008-06-19 #i90516#
544         // only perform the code that is needed to determine, if at the
545         // actual cursor position is a post-it field
546 //        SwRect aFldRect;
547 //        SwContentAtPos aCntntAtPos( SwContentAtPos::SW_FIELD);
548 //        if( pWrtShell->GetContentAtPos( pWrtShell->GetCrsrDocPos(), aCntntAtPos, sal_False, &aFldRect ) )
549 //        {
550 //            const SwField* pFld = aCntntAtPos.aFnd.pFld;
551 //            if (pFld->Which()== RES_POSTITFLD)
552 //            {
553 //                mpPostItMgr->SetShadowState(reinterpret_cast<const SwPostItField*>(pFld));
554 //            }
555 //            else
556 //                mpPostItMgr->SetShadowState(0);
557 //        }
558 //        else
559 //            mpPostItMgr->SetShadowState(0);
560         mpPostItMgr->SetShadowState( pWrtShell->GetPostItFieldAtCursor() );
561 	}
562 
563 	return 0;
564 }
565 
566 
567 
568 IMPL_LINK( SwView, TimeoutHdl, Timer *, EMPTYARG )
569 {
570 	DBG_PROFSTART(viewhdl);
571 
572 	if( pWrtShell->BasicActionPend() || bNoInterrupt )
573 	{
574 		aTimer.Start();
575 		DBG_PROFSTOP(viewhdl);
576 		return 0;
577 	}
578 
579 	if ( bAttrChgNotifiedWithRegistrations )
580 	{
581 		GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
582 		bAttrChgNotifiedWithRegistrations = sal_False;
583 	}
584 
585 	_CheckReadonlyState();
586 	_CheckReadonlySelection();
587 
588     sal_Bool bOldUndo = pWrtShell->DoesUndo();
589     pWrtShell->DoUndo( sal_False );
590 	SelectShell();
591     pWrtShell->DoUndo( bOldUndo );
592 	bAttrChgNotified = sal_False;
593     GetViewImpl()->GetUNOObject_Impl()->NotifySelChanged();
594 
595 	DBG_PROFSTOP(viewhdl);
596 	return 0;
597 }
598 
599 void SwView::_CheckReadonlyState()
600 {
601 	SfxDispatcher &rDis = GetDispatcher();
602 	//Um erkennen zu koennen ob bereits disabled ist!
603 	SfxItemState eStateRO, eStateProtAll;
604 	const SfxPoolItem *pItem;
605 	// JP 29.04.97: von einem nur uns bekannten Slot den Status abfragen.
606 	//				Ansonsten kennen andere den Slot; wie z.B. die BasidIde
607 	eStateRO = rDis.QueryState( FN_INSERT_BOOKMARK, pItem );
608 	eStateProtAll = rDis.QueryState( FN_EDIT_REGION, pItem );
609 	sal_Bool bChgd = sal_False;
610 
611 	if ( !pWrtShell->IsCrsrReadonly() )
612 	{
613 		static sal_uInt16 aROIds[] =
614 		{
615 			SID_DELETE, 				FN_BACKSPACE,				FN_SHIFT_BACKSPACE,
616 			SID_UNDO,
617 			SID_REDO,					SID_REPEAT,					SID_PASTE,
618             SID_PASTE_UNFORMATTED,
619             SID_PASTE_SPECIAL,            SID_SBA_BRW_INSERT,
620 			SID_BACKGROUND_COLOR,       FN_INSERT_BOOKMARK,
621 			SID_CHARMAP,				FN_INSERT_SOFT_HYPHEN,
622 			FN_INSERT_HARDHYPHEN,		FN_INSERT_HARD_SPACE,		FN_INSERT_BREAK,
623 			FN_INSERT_LINEBREAK,		FN_INSERT_COLUMN_BREAK,		FN_INSERT_BREAK_DLG,
624 			FN_DELETE_SENT,				FN_DELETE_BACK_SENT,		FN_DELETE_WORD,
625 			FN_DELETE_BACK_WORD,		FN_DELETE_LINE,				FN_DELETE_BACK_LINE,
626 			FN_DELETE_PARA,				FN_DELETE_BACK_PARA,		FN_DELETE_WHOLE_LINE,
627 			FN_CALCULATE,				FN_FORMAT_RESET,
628 			FN_POSTIT,			   		FN_JAVAEDIT,				SID_ATTR_PARA_ADJUST_LEFT,
629 			SID_ATTR_PARA_ADJUST_RIGHT,	SID_ATTR_PARA_ADJUST_CENTER,SID_ATTR_PARA_ADJUST_BLOCK,
630 			SID_ATTR_PARA_LINESPACE_10,	SID_ATTR_PARA_LINESPACE_15,	SID_ATTR_PARA_LINESPACE_20,
631 			SID_ATTR_CHAR_FONT,			SID_ATTR_CHAR_FONTHEIGHT,	SID_ATTR_CHAR_COLOR_BACKGROUND,
632 			SID_ATTR_CHAR_COLOR_BACKGROUND_EXT,						SID_ATTR_CHAR_COLOR_EXT,
633 			SID_ATTR_CHAR_COLOR,		SID_ATTR_CHAR_WEIGHT,		SID_ATTR_CHAR_POSTURE,
634 			SID_ATTR_CHAR_OVERLINE,
635 			SID_ATTR_CHAR_UNDERLINE,	SID_ATTR_FLASH,				SID_ATTR_CHAR_STRIKEOUT,
636 			FN_UNDERLINE_DOUBLE,		SID_ATTR_CHAR_CONTOUR,		SID_ATTR_CHAR_SHADOWED,
637 			SID_ATTR_CHAR_AUTOKERN,		SID_ATTR_CHAR_ESCAPEMENT,	FN_SET_SUPER_SCRIPT,
638 			FN_SET_SUB_SCRIPT,			SID_ATTR_CHAR_CASEMAP,		SID_ATTR_CHAR_LANGUAGE,
639 			SID_ATTR_CHAR_KERNING,		SID_CHAR_DLG,				SID_ATTR_CHAR_WORDLINEMODE,
640 			FN_GROW_FONT_SIZE,			FN_SHRINK_FONT_SIZE,		FN_TXTATR_INET,
641 			FN_FORMAT_DROPCAPS,			SID_ATTR_PARA_ADJUST,		SID_ATTR_PARA_LINESPACE,
642 			SID_ATTR_PARA_SPLIT,		SID_ATTR_PARA_KEEP,			SID_ATTR_PARA_WIDOWS,
643 			SID_ATTR_PARA_ORPHANS,
644 			SID_ATTR_PARA_MODEL,		SID_PARA_DLG,
645 			FN_SELECT_PARA,				SID_DEC_INDENT,
646 			SID_INC_INDENT
647 		};
648 		static sal_Bool bFirst = sal_True;
649 		if ( bFirst )
650 		{
651 			qsort( (void*)aROIds, sizeof(aROIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
652 			bFirst = sal_False;
653 		}
654 		if ( SFX_ITEM_DISABLED == eStateRO )
655 		{
656 			rDis.SetSlotFilter( sal_Bool(2), sizeof(aROIds)/sizeof(sal_uInt16), aROIds );
657 			bChgd = sal_True;
658 		}
659 	}
660 	else if( pWrtShell->IsAllProtect() )
661 	{
662 		if ( SFX_ITEM_DISABLED == eStateProtAll )
663 		{
664 			static sal_uInt16 aAllProtIds[] = { SID_SAVEDOC, FN_EDIT_REGION };
665 			static sal_Bool bAllProtFirst = sal_True;
666 			if ( bAllProtFirst )
667 			{
668 				qsort( (void*)aAllProtIds, sizeof(aAllProtIds)/sizeof(sal_uInt16), sizeof(sal_uInt16), lcl_CmpIds );
669 				bAllProtFirst = sal_False;
670 			}
671 			rDis.SetSlotFilter( sal_Bool(2),
672 								sizeof(aAllProtIds)/sizeof(sal_uInt16),
673 								aAllProtIds );
674 			bChgd = sal_True;
675 		}
676 	}
677 	else if ( SFX_ITEM_DISABLED != eStateRO ||
678 				SFX_ITEM_DISABLED != eStateProtAll )
679 	{
680 		bChgd = sal_True;
681 		rDis.SetSlotFilter();
682 	}
683 	if ( bChgd )
684 		GetViewFrame()->GetBindings().InvalidateAll(sal_True);
685 }
686 
687 void SwView::_CheckReadonlySelection()
688 {
689 	sal_uInt32 nDisableFlags = 0;
690 	SfxDispatcher &rDis = GetDispatcher();
691 
692 	if( pWrtShell->HasReadonlySel() &&
693 		( !pWrtShell->GetDrawView() ||
694 			!pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount() ))
695 		nDisableFlags |= SW_DISABLE_ON_PROTECTED_CURSOR;
696 
697 	if( (SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags ) !=
698 		(SW_DISABLE_ON_PROTECTED_CURSOR & rDis.GetDisableFlags() ) )
699 	{
700 		// zusaetzlich am Window den InputContext umsetzen, damit in
701 		// japanischen / chinesischen Versionen die externe Eingabe
702 		// ab-/angeschaltet wird. Das aber nur wenn auch die richtige
703 		// Shell auf dem Stack steht.
704 		switch( pViewImpl->GetShellMode() )
705 		{
706 		case SHELL_MODE_TEXT:
707 		case SHELL_MODE_LIST_TEXT:
708 		case SHELL_MODE_TABLE_TEXT:
709 		case SHELL_MODE_TABLE_LIST_TEXT:
710 			{
711 //JP 22.01.99: temporaere Loesung!!! Sollte bei jeder Cursorbewegung
712 //			den Font von der akt. Einfuegeposition setzen, also ausserhalb
713 // 			dieses if's. Aber TH wertet den Font zur Zeit nicht aus und
714 //			das besorgen erscheint mir hier zu teuer zu sein.
715 //			Ausserdem haben wir keinen Font, sondern nur Attribute aus denen
716 //			die Textformatierung dann den richtigen Font zusammen baut.
717 
718 				InputContext aCntxt( GetEditWin().GetInputContext() );
719 				aCntxt.SetOptions( SW_DISABLE_ON_PROTECTED_CURSOR & nDisableFlags
720 									? (aCntxt.GetOptions() & ~
721 											( INPUTCONTEXT_TEXT |
722 												INPUTCONTEXT_EXTTEXTINPUT ))
723 									: (aCntxt.GetOptions() |
724 											( INPUTCONTEXT_TEXT |
725 												INPUTCONTEXT_EXTTEXTINPUT )) );
726 				GetEditWin().SetInputContext( aCntxt );
727 			}
728 			break;
729 		default:
730 			;
731 		}
732 
733 	}
734 
735 	if( nDisableFlags != rDis.GetDisableFlags() )
736 	{
737 		rDis.SetDisableFlags( nDisableFlags );
738 		GetViewFrame()->GetBindings().InvalidateAll( sal_True );
739 	}
740 }
741 
742 
743 SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
744 	: SfxViewShell( _pFrame, SWVIEWFLAGS ),
745 	aPageStr( SW_RES( STR_PAGE )),
746     nNewPage(USHRT_MAX),
747     pNumRuleNodeFromDoc(0), // #i23726#
748 	pEditWin( new SwEditWin( &_pFrame->GetWindow(), *this ) ),
749 	pWrtShell(0),
750 	pShell(0),
751 	pFormShell(0),
752 	pHScrollbar(0),
753 	pVScrollbar(0),
754     pScrollFill(new ScrollBarBox( &_pFrame->GetWindow(), _pFrame->GetFrame().GetParentFrame() ? 0 : WB_SIZEABLE )),
755     pHRuler( new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
756 					SVXRULER_SUPPORT_TABS |
757 					SVXRULER_SUPPORT_PARAGRAPH_MARGINS |
758 					SVXRULER_SUPPORT_BORDERS |
759                     SVXRULER_SUPPORT_NEGATIVE_MARGINS|
760                     SVXRULER_SUPPORT_REDUCED_METRIC,
761 					GetViewFrame()->GetBindings(),
762                     WB_STDRULER | WB_EXTRAFIELD | WB_BORDER)),
763     pVRuler(new SvxRuler(&GetViewFrame()->GetWindow(), pEditWin,
764                             SVXRULER_SUPPORT_TABS | SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL|
765                                 SVXRULER_SUPPORT_BORDERS | SVXRULER_SUPPORT_REDUCED_METRIC,
766 							GetViewFrame()->GetBindings(),
767                             WB_VSCROLL |  WB_EXTRAFIELD | WB_BORDER )),
768     pTogglePageBtn(0),
769 	pPageUpBtn(0),
770 	pPageDownBtn(0),
771 	pNaviBtn(0),
772 	pGlosHdl(0),
773 	pDrawActual(0),
774 	pLastTableFormat(0),
775     pFormatClipboard(new SwFormatClipboard()),
776 	mpPostItMgr(0),
777 	nSelectionType( INT_MAX ),
778 	nPageCnt(0),
779 	nDrawSfxId( USHRT_MAX ),
780 	nFormSfxId( USHRT_MAX ),
781     nLastPasteDestination( 0xFFFF ),
782     nLeftBorderDistance( 0 ),
783     //IAccessibility2 Implementation 2009-----
784 	nOldPageNum(0),
785     //-----IAccessibility2 Implementation 2009
786     nRightBorderDistance( 0 ),
787     bInMailMerge(sal_False),
788     bInDtor(sal_False),
789     bOldShellWasPagePreView(sal_False),
790     bIsPreviewDoubleClick(sal_False)
791 {
792     // OD 18.12.2002 #103492# - According to discussion with MBA and further
793     // investigations, no old SfxViewShell will be set as parameter <pOldSh>,
794     // if function "New Window" is performed to open an additional view beside
795     // an already existing one.
796     // If the view is switch from one to another, the 'old' view is given by
797     // parameter <pOldSh>.
798 
799     RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwView::SwView" );
800 
801     bCenterCrsr = bTopCrsr = bAllwaysShowSel = bTabColFromDoc = bTabRowFromDoc =
802     bSetTabColFromDoc = bSetTabRowFromDoc = bAttrChgNotified = bAttrChgNotifiedWithRegistrations =
803     bVerbsActive = bDrawRotate = bInOuterResizePixel = bInInnerResizePixel =
804     bPasteState = bPasteSpecialState = bMakeSelectionVisible = sal_False;
805 
806 	bShowAtResize = bDrawSelMode = bDocSzUpdated = sal_True;
807 
808     _CreateScrollbar( sal_True );
809     _CreateScrollbar( sal_False );
810 
811 	pViewImpl = new SwView_Impl(this);
812 	SetName(C2S("View"));
813 	SetWindow( pEditWin );
814 
815 	aTimer.SetTimeout( 120 );
816 
817 	SwDocShell* pDocSh = PTR_CAST( SwDocShell, _pFrame->GetObjectShell() );
818 	sal_Bool bOldModifyFlag = pDocSh->IsEnableSetModified();
819     if(bOldModifyFlag)
820         pDocSh->EnableSetModified( sal_False );
821 	ASSERT( pDocSh, "View ohne DocShell." );
822 	SwWebDocShell* pWebDShell = PTR_CAST( SwWebDocShell, pDocSh );
823 
824     const SwMasterUsrPref *pUsrPref = SW_MOD()->GetUsrPref(0 != pWebDShell);
825     SwViewOption aUsrPref( *pUsrPref);
826 
827     //! get lingu options without loading lingu DLL
828     SvtLinguOptions aLinguOpt;
829     SvtLinguConfig().GetOptions( aLinguOpt );
830     aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto );
831 
832 	sal_Bool bOldShellWasSrcView = sal_False;
833 
834     // OD 18.12.2002 #103492# - determine, if there is an existing view for
835     // document
836     SfxViewShell* pExistingSh = 0;
837     if ( pOldSh )
838     {
839         pExistingSh = pOldSh;
840         // determine type of existing view
841         if( pExistingSh->IsA( TYPE( SwPagePreView ) ) )
842         {
843             sSwViewData = ((SwPagePreView*)pExistingSh)->GetPrevSwViewData();
844             sNewCrsrPos = ((SwPagePreView*)pExistingSh)->GetNewCrsrPos();
845             nNewPage = ((SwPagePreView*)pExistingSh)->GetNewPage();
846             bOldShellWasPagePreView = sal_True;
847             bIsPreviewDoubleClick = sNewCrsrPos.Len() > 0 || nNewPage != USHRT_MAX;
848         }
849         else if( pExistingSh->IsA( TYPE( SwSrcView ) ) )
850             bOldShellWasSrcView = sal_True;
851     }
852 
853 	RTL_LOGFILE_CONTEXT_TRACE( aLog, "before create WrtShell" );
854     if(PTR_CAST( SwView, pExistingSh))
855 	{
856         pWrtShell = new SwWrtShell( *((SwView*)pExistingSh)->pWrtShell,
857 									pEditWin, *this);
858 	}
859 	else if( dynamic_cast<SwWrtShell*>( pDocSh->GetDoc()->GetCurrentViewShell() ) )
860 	{
861 		pWrtShell = new SwWrtShell( *(SwWrtShell*)pDocSh->GetDoc()->GetCurrentViewShell(),
862 									pEditWin, *this);
863 	}
864 	else
865 	{
866 		SwDoc& rDoc = *((SwDocShell*)pDocSh)->GetDoc();
867 
868         if( !bOldShellWasSrcView && pWebDShell && !bOldShellWasPagePreView )
869 			aUsrPref.setBrowseMode( sal_True );
870         else if( rDoc.IsLoaded() )
871             aUsrPref.setBrowseMode( rDoc.get(IDocumentSettingAccess::BROWSE_MODE) );
872 
873 		//Fuer den BrowseMode wollen wir keinen Factor uebernehmen.
874 		if( aUsrPref.getBrowseMode() && aUsrPref.GetZoomType() != SVX_ZOOM_PERCENT )
875 		{
876 			aUsrPref.SetZoomType( SVX_ZOOM_PERCENT );
877 			aUsrPref.SetZoom( 100 );
878 		}
879         if(pDocSh->IsPreview())
880         {
881             aUsrPref.SetZoomType( SVX_ZOOM_WHOLEPAGE );
882             aUsrPref.SetViewLayoutBookMode( false );
883             aUsrPref.SetViewLayoutColumns( 1 );
884         }
885 		pWrtShell = new SwWrtShell( rDoc, pEditWin, *this, &aUsrPref );
886         //#97610# creating an SwView from a SwPagePreView needs to
887         // add the ViewShell to the ring of the other ViewShell(s)
888         if(bOldShellWasPagePreView)
889 		{
890             ViewShell& rPreviewViewShell = *((SwPagePreView*)pExistingSh)->GetViewShell();
891             pWrtShell->MoveTo(&rPreviewViewShell);
892             //#95521# to update the field command et.al. if necessary
893             const SwViewOption* pPreViewOpt = rPreviewViewShell.GetViewOptions();
894             if( pPreViewOpt->IsFldName() != aUsrPref.IsFldName() ||
895                     pPreViewOpt->IsShowHiddenField() != aUsrPref.IsShowHiddenField() ||
896                     pPreViewOpt->IsShowHiddenPara() != aUsrPref.IsShowHiddenPara() ||
897                     pPreViewOpt->IsShowHiddenChar() != aUsrPref.IsShowHiddenChar() )
898                 rPreviewViewShell.ApplyViewOptions(aUsrPref);
899             // OD 09.01.2003 #106334# - reset design mode at draw view for form
900             // shell, if needed.
901             if ( ((SwPagePreView*)pExistingSh)->ResetFormDesignMode() &&
902                  pWrtShell->HasDrawView() )
903             {
904                 SdrView* pDrawView = pWrtShell->GetDrawView();
905                 pDrawView->SetDesignMode( ((SwPagePreView*)pExistingSh)->FormDesignModeToReset() );
906             }
907         }
908 	}
909 	RTL_LOGFILE_CONTEXT_TRACE( aLog, "after create WrtShell" );
910 
911     // --> OD 2005-02-11 #i38810# - assure that modified state of document
912     // isn't reset, if document is already modified.
913     const bool bIsDocModified = pWrtShell->GetDoc()->IsModified();
914     // <--
915 
916     // JP 05.02.99: Bug 61495 - damit unter anderem das HLineal im
917 	//				ReadonlyFall nicht angezeigt wird
918 	aUsrPref.SetReadonly( pWrtShell->GetViewOptions()->IsReadonly() );
919 
920 	//Kein Margin fuer OLE!
921 	Size aBrwsBorder;
922 	if( SFX_CREATE_MODE_EMBEDDED != pDocSh->GetCreateMode() )
923 		aBrwsBorder = GetMargin();
924 
925 	pWrtShell->SetBrowseBorder( aBrwsBorder );
926 
927 	// Im CTOR duerfen keine Shell wechsel erfolgen, die muessen ueber
928 	// den Timer "zwischen gespeichert" werden. Sonst raeumt der SFX
929 	// sie wieder vom Stack!
930 	sal_Bool bOld = bNoInterrupt;
931 	bNoInterrupt = sal_True;
932 
933     pHRuler->SetActive( sal_True );
934     pVRuler->SetActive( sal_True );
935 
936 	SfxViewFrame* pViewFrame = GetViewFrame();
937 	if( pViewFrame->GetFrame().GetParentFrame())
938 	{
939         aUsrPref.SetViewHRuler(sal_False);
940         aUsrPref.SetViewVRuler(sal_False);
941 	}
942 
943     StartListening( *pViewFrame, sal_True );
944     StartListening( *pDocSh, sal_True );
945 
946 	// Vom HLineal den ZOOM-Faktor einstellen
947     Fraction aZoomFract( aUsrPref.GetZoom(), 100 );
948     pHRuler->SetZoom( aZoomFract );
949     pVRuler->SetZoom( aZoomFract );
950     pHRuler->SetDoubleClickHdl(LINK( this, SwView, ExecRulerClick ));
951     FieldUnit eMetric = pUsrPref->GetHScrollMetric();
952     pHRuler->SetUnit( eMetric );
953     eMetric = pUsrPref->GetVScrollMetric();
954     pVRuler->SetUnit( eMetric );
955 
956 	// DocShell setzen
957 	pDocSh->SetView( this );
958 	SW_MOD()->SetView( this );
959 
960 	mpPostItMgr = new SwPostItMgr(this);
961 
962 	// Die DocSize erfragen und verarbeiten. Ueber die Handler konnte
963 	// die Shell nicht gefunden werden, weil die Shell innerhalb CTOR-Phase
964 	// nicht in der SFX-Verwaltung bekannt ist.
965 	DocSzChgd( pWrtShell->GetDocSize() );
966 
967 		// AttrChangedNotify Link setzen
968 	pWrtShell->SetChgLnk(LINK(this, SwView, AttrChangedNotify));
969 
970 	if( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED &&
971         //TODO/LATER: why a cast here?
972         //!((SvEmbeddedObject *)pDocSh)->GetVisArea().IsEmpty() )
973         //SetVisArea( ((SvEmbeddedObject *)pDocSh)->GetVisArea(),sal_False);
974         !pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() )
975         SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False);
976 
977     pWrtShell->DoUndo( 0 != SW_MOD()->GetUndoOptions().GetUndoCount() );
978 
979     const sal_Bool bBrowse = pWrtShell->GetViewOptions()->getBrowseMode();
980     // Disable "multiple window"
981 	SetNewWindowAllowed(!bBrowse);
982     // End of disabled multiple window
983 
984     ShowVScrollbar(aUsrPref.IsViewVScrollBar());
985     ShowHScrollbar(aUsrPref.IsViewHScrollBar());
986     pHScrollbar->SetAuto(bBrowse);
987     if( aUsrPref.IsViewHRuler() )
988         CreateTab();
989     if( aUsrPref.IsViewVRuler() )
990         CreateVLineal();
991 
992 	pWrtShell->SetUIOptions( aUsrPref );
993 	pWrtShell->SetReadOnlyAvailable( aUsrPref.IsCursorInProtectedArea() );
994     pWrtShell->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions());
995 
996 	if( pWrtShell->GetDoc()->IsUpdateExpFld() )
997 	{
998 		SET_CURR_SHELL( pWrtShell );
999 		pWrtShell->StartAction();
1000 		pWrtShell->CalcLayout();
1001 		pWrtShell->GetDoc()->UpdateFlds(NULL, false);
1002 		pWrtShell->EndAction();
1003 		pWrtShell->GetDoc()->SetUpdateExpFldStat( sal_False );
1004 	}
1005 
1006 	// ggfs. alle Verzeichnisse updaten:
1007 	if( pWrtShell->GetDoc()->IsUpdateTOX() )
1008 	{
1009 		SfxRequest aSfxRequest( FN_UPDATE_TOX, SFX_CALLMODE_SLOT, GetPool() );
1010 		Execute( aSfxRequest );
1011 		pWrtShell->GetDoc()->SetUpdateTOX( sal_False );		// wieder zurueck setzen
1012 		pWrtShell->SttEndDoc(sal_True);
1013 	}
1014 
1015 	// kein ResetModified, wenn es schone eine View auf dieses Doc gibt
1016 	SfxViewFrame* pVFrame = GetViewFrame();
1017 	SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
1018 	// zur Zeit(360) wird die View erst nach dem Ctor eingetragen
1019 	// der folgende Ausdruck funktioniert auch, wenn sich das aendert
1020 	//JP 27.07.98: wenn per Undo nicht mehr die Modifizierung aufhebar ist,
1021 	//				so setze das Modified NICHT zurueck.
1022     // --> OD 2005-02-11 #i38810# - no reset of modified state, if document
1023     // was already modified.
1024     if (!pWrtShell->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() &&
1025          ( !pFirst || pFirst == pVFrame ) &&
1026          !bIsDocModified )
1027     // <--
1028     {
1029 		pWrtShell->ResetModified();
1030     }
1031 
1032 	bNoInterrupt = bOld;
1033 
1034 	// wird ein GlobalDoc neu angelegt, soll auch der Navigator erzeugt werden
1035 	if( pDocSh->IsA(SwGlobalDocShell::StaticType()) &&
1036 		!pVFrame->GetChildWindow( SID_NAVIGATOR ))
1037 	{
1038 		SfxBoolItem aNavi(SID_NAVIGATOR, sal_True);
1039 		GetDispatcher().Execute(SID_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, &aNavi, 0L);
1040 	}
1041 
1042 
1043    uno::Reference< frame::XFrame >  xFrame = pVFrame->GetFrame().GetFrameInterface();
1044 
1045     uno::Reference< frame::XFrame >  xBeamerFrame = xFrame->findFrame(
1046             OUString::createFromAscii("_beamer"), frame::FrameSearchFlag::CHILDREN);
1047     if(xBeamerFrame.is())
1048     {
1049         SwDBData aData = pWrtShell->GetDBData();
1050         SW_MOD()->ShowDBObj( *this, aData );
1051     }
1052 
1053 	// has anybody calls the attrchanged handler in the constructor?
1054 	if( bAttrChgNotifiedWithRegistrations )
1055 	{
1056 		GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1057 	    if( aTimer.IsActive() )
1058 			aTimer.Stop();
1059 	}
1060 
1061 	aTimer.SetTimeoutHdl(LINK(this, SwView, TimeoutHdl));
1062 	bAttrChgNotified = bAttrChgNotifiedWithRegistrations = sal_False;
1063     if(bOldModifyFlag)
1064         pDocSh->EnableSetModified( sal_True );
1065     InvalidateBorder();
1066 }
1067 
1068 SwView::~SwView()
1069 {
1070     delete mpPostItMgr;
1071     // --> OD 2009-03-10 #i100035#
1072     mpPostItMgr = 0;
1073     // <--
1074 
1075     bInDtor = sal_True;
1076     pEditWin->Hide(); // damit kein Paint Aerger machen kann!
1077 	// An der SwDocShell den Pointer auf die View ruecksetzen
1078 	SwDocShell* pDocSh = GetDocShell();
1079 	if( pDocSh && pDocSh->GetView() == this )
1080 		pDocSh->SetView( 0 );
1081 	if ( SW_MOD()->GetView() == this )
1082 		SW_MOD()->SetView( 0 );
1083 
1084 	if( aTimer.IsActive() && bAttrChgNotifiedWithRegistrations )
1085 		GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1086 
1087 	//JP 27.11.00: Bug 80631 - the last view must end the text edit
1088 	SdrView *pSdrView = pWrtShell ? pWrtShell->GetDrawView() : 0;
1089 	if( pSdrView && pSdrView->IsTextEdit() )
1090 		pSdrView->SdrEndTextEdit( sal_True );
1091 
1092 	SetWindow( 0 );
1093 
1094     pViewImpl->Invalidate();
1095 	EndListening(*GetViewFrame());
1096 	EndListening(*GetDocShell());
1097 	delete pScrollFill;
1098 	delete pWrtShell;
1099 	pWrtShell = 0;		// Auf 0 setzen, damit folgende DToren nicht drauf zugreifen
1100 	pShell = 0;
1101 	delete pHScrollbar;
1102 	delete pVScrollbar;
1103     delete pHRuler;
1104     delete pVRuler;
1105 	delete pTogglePageBtn;
1106 	delete pPageUpBtn;
1107 	delete pNaviBtn;
1108 	delete pPageDownBtn;
1109 	delete pGlosHdl;
1110 	delete pViewImpl;
1111 	delete pEditWin;
1112     delete pFormatClipboard;
1113 }
1114 
1115 SwDocShell* SwView::GetDocShell()
1116 {
1117 	SfxObjectShell* pDocShell = GetViewFrame()->GetObjectShell();
1118 	return PTR_CAST(SwDocShell, pDocShell);
1119 }
1120 
1121 /*--------------------------------------------------------------------
1122 	Beschreibung:	CursorPos merken
1123  --------------------------------------------------------------------*/
1124 
1125 
1126 void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse )
1127 {
1128 	//Das Browse-Flag wird vom Sfx durchgereicht, wenn Dokumente gebrowsed
1129 	//werden (nicht zu verwechseln mit dem BrowseMode).
1130 	//Die dann gespeicherten Daten sind nicht persistent!!
1131 
1132 	const SwRect& rRect = pWrtShell->GetCharRect();
1133 	const Rectangle& rVis = GetVisArea();
1134 
1135 	rUserData = String::CreateFromInt32( rRect.Left() );
1136 	rUserData += ';';
1137 	rUserData += String::CreateFromInt32( rRect.Top() );
1138 	rUserData += ';';
1139 	rUserData += String::CreateFromInt32( pWrtShell->GetViewOptions()->GetZoom() );
1140 	rUserData += ';';
1141 	rUserData += String::CreateFromInt32( rVis.Left() );
1142 	rUserData += ';';
1143 	rUserData += String::CreateFromInt32( rVis.Top() );
1144 	rUserData += ';';
1145 	rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Right());
1146 	rUserData += ';';
1147 	rUserData += String::CreateFromInt32( bBrowse ? LONG_MIN : rVis.Bottom());
1148 	rUserData += ';';
1149 	rUserData += String::CreateFromInt32(
1150 			(sal_uInt16)pWrtShell->GetViewOptions()->GetZoomType());//eZoom;
1151 	rUserData += ';';
1152 	rUserData += FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? '0' : '1';
1153 }
1154 /*--------------------------------------------------------------------
1155 	Beschreibung: CursorPos setzen
1156  --------------------------------------------------------------------*/
1157 //#i43146# go to the last editing position when opening own files
1158 bool lcl_IsOwnDocument( SwView& rView )
1159 {
1160     uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1161         rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
1162     uno::Reference<document::XDocumentProperties> xDocProps
1163         = xDPS->getDocumentProperties();
1164     String Created = xDocProps->getAuthor();
1165     String Changed = xDocProps->getModifiedBy();
1166     String FullName = SW_MOD()->GetUserOptions().GetFullName();
1167     return (FullName.Len() &&
1168             (Changed.Len() && Changed == FullName )) ||
1169             (!Changed.Len() && Created.Len() && Created == FullName );
1170 }
1171 
1172 
1173 void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse )
1174 {
1175 	if ( rUserData.GetTokenCount() > 1 &&
1176 		//Fuer Dokumente ohne Layout nur im OnlineLayout oder beim
1177 		//Forward/Backward
1178 		 (!pWrtShell->IsNewLayout() || pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
1179 	{
1180         //#i43146# go to the last editing position when opening own files
1181         bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1182 
1183         SET_CURR_SHELL(pWrtShell);
1184 
1185 		sal_uInt16 nPos = 0;
1186 
1187 		// Nein, es ist *keine* gute Idee GetToken gleich im Point-Konstr.
1188 		// aufzurufen, denn welcher Parameter wird zuerst ausgewertet?
1189 		long nX = rUserData.GetToken( 0, ';', nPos ).ToInt32(),
1190 			 nY = rUserData.GetToken( 0, ';', nPos ).ToInt32();
1191 		Point aCrsrPos( nX, nY );
1192 
1193 		sal_uInt16 nZoomFactor =
1194 			static_cast< sal_uInt16 >( rUserData.GetToken(0, ';', nPos ).ToInt32() );
1195 
1196 		long nLeft	= rUserData.GetToken(0, ';', nPos ).ToInt32(),
1197 			 nTop	= rUserData.GetToken(0, ';', nPos ).ToInt32(),
1198 			 nRight = rUserData.GetToken(0, ';', nPos ).ToInt32(),
1199 			 nBottom= rUserData.GetToken(0, ';', nPos ).ToInt32();
1200 
1201 		const long nAdd = pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1202 		if ( nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
1203 		{
1204 			pWrtShell->EnableSmooth( sal_False );
1205 
1206 			const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1207 
1208 			sal_uInt16 nOff = 0;
1209 			SvxZoomType eZoom;
1210 			if( !pWrtShell->GetViewOptions()->getBrowseMode() )
1211 				eZoom = (SvxZoomType) (sal_uInt16)rUserData.GetToken(nOff, ';', nPos ).ToInt32();
1212 			else
1213 			{
1214 				eZoom = SVX_ZOOM_PERCENT;
1215 				++nOff;
1216 			}
1217 
1218 			sal_Bool bSelectObj = (0 != rUserData.GetToken( nOff, ';', nPos ).ToInt32())
1219 								&& pWrtShell->IsObjSelectable( aCrsrPos );
1220 
1221             //#i33307# restore editing position
1222             pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1223             // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
1224             bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
1225             pWrtShell->SetMacroExecAllowed( false );
1226 //!!! pb (11.08.2004): #i32536#
1227 // os: changed: The user data has to be read if the view is switched back from page preview
1228 //#i43146# go to the last editing position when opening own files
1229             if(bOldShellWasPagePreView || bIsOwnDocument)
1230             {
1231                 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1232             	if( bSelectObj )
1233             	{
1234             		pWrtShell->SelectObj( aCrsrPos );
1235             		pWrtShell->EnterSelFrmMode( &aCrsrPos );
1236             	}
1237             }
1238 
1239             // OD 11.02.2003 #100556# - reset flag value
1240             pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1241 
1242             // OD 08.04.2003 #108693# - set visible area before applying
1243             // information from print preview. Otherwise, the applied information
1244             // is lost.
1245 //!!! pb (11.08.2004): #i32536#
1246 // os: changed: The user data has to be read if the view is switched back from page preview
1247 //#i43146# go to the last editing position when opening own files
1248             if(bOldShellWasPagePreView || bIsOwnDocument )
1249             {
1250                 if ( bBrowse )
1251                     SetVisArea( aVis.TopLeft() );
1252                 else
1253                     SetVisArea( aVis );
1254             }
1255 
1256             //apply information from print preview - if available
1257 			if( sNewCrsrPos.Len() )
1258 			{
1259 				long nXTmp = sNewCrsrPos.GetToken( 0, ';' ).ToInt32(),
1260 				 	 nYTmp = sNewCrsrPos.GetToken( 1, ';' ).ToInt32();
1261                 Point aCrsrPos2( nXTmp, nYTmp );
1262                 bSelectObj = pWrtShell->IsObjSelectable( aCrsrPos2 );
1263 
1264                 pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos2, sal_False );
1265                 if( bSelectObj )
1266                 {
1267                     pWrtShell->SelectObj( aCrsrPos2 );
1268                     pWrtShell->EnterSelFrmMode( &aCrsrPos2 );
1269                 }
1270                 pWrtShell->MakeSelVisible();
1271                 sNewCrsrPos.Erase();
1272 			}
1273             else if(USHRT_MAX != nNewPage)
1274             {
1275                 pWrtShell->GotoPage(nNewPage, sal_True);
1276                 nNewPage = USHRT_MAX;
1277             }
1278 
1279 			SelectShell();
1280 
1281 			pWrtShell->StartAction();
1282 			const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
1283 			if( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom )
1284 				SetZoom( eZoom, nZoomFactor);
1285 
1286 			pWrtShell->LockView( sal_True );
1287 			pWrtShell->EndAction();
1288 			pWrtShell->LockView( sal_False );
1289 			pWrtShell->EnableSmooth( sal_True );
1290 		}
1291 	}
1292 }
1293 
1294 void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1295 {
1296     if(GetDocShell()->IsPreview()||bIsPreviewDoubleClick)
1297         return;
1298     //#i43146# go to the last editing position when opening own files
1299     bool bIsOwnDocument = lcl_IsOwnDocument( *this );
1300     sal_Int32 nLength = rSequence.getLength();
1301     if (nLength && (!pWrtShell->IsNewLayout() || pWrtShell->GetViewOptions()->getBrowseMode() || bBrowse) )
1302     {
1303 		SET_CURR_SHELL(pWrtShell);
1304         const beans::PropertyValue *pValue = rSequence.getConstArray();
1305 		const SwRect& rRect = pWrtShell->GetCharRect();
1306 		const Rectangle &rVis = GetVisArea();
1307         const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
1308 
1309         long nX = rRect.Left(), nY = rRect.Top(), nLeft = rVis.Left(), nTop = rVis.Top();
1310 		long nRight = bBrowse ? LONG_MIN : rVis.Right(), nBottom = bBrowse ? LONG_MIN : rVis.Bottom();
1311         sal_Int16 nZoomType = static_cast< sal_Int16 >(pVOpt->GetZoomType());
1312         sal_Int16 nZoomFactor = static_cast < sal_Int16 > (pVOpt->GetZoom());
1313         bool bViewLayoutBookMode = pVOpt->IsViewLayoutBookMode();
1314         sal_Int16 nViewLayoutColumns = pVOpt->GetViewLayoutColumns();
1315 
1316         sal_Bool bSelectedFrame = ( pWrtShell->GetSelFrmType() != FRMTYPE_NONE ),
1317 				 bGotViewLeft = sal_False, bGotViewTop = sal_False, bGotVisibleLeft = sal_False,
1318 				 bGotVisibleTop = sal_False, bGotVisibleRight = sal_False,
1319 				 bGotVisibleBottom = sal_False, bGotZoomType = sal_False,
1320 				 bGotZoomFactor = sal_False, bGotIsSelectedFrame = sal_False,
1321                  bGotViewLayoutColumns = sal_False, bGotViewLayoutBookMode = sal_False;
1322 
1323         for (sal_Int16 i = 0 ; i < nLength; i++)
1324         {
1325             if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLeft" ) ) )
1326             {
1327                pValue->Value >>= nX;
1328 			   nX = MM100_TO_TWIP( nX );
1329 			   bGotViewLeft = sal_True;
1330             }
1331             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewTop" ) ) )
1332             {
1333                pValue->Value >>= nY;
1334 			   nY = MM100_TO_TWIP( nY );
1335 			   bGotViewTop = sal_True;
1336             }
1337             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleLeft" ) ) )
1338             {
1339                pValue->Value >>= nLeft;
1340 			   nLeft = MM100_TO_TWIP( nLeft );
1341 			   bGotVisibleLeft = sal_True;
1342             }
1343             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleTop" ) ) )
1344             {
1345                pValue->Value >>= nTop;
1346 			   nTop = MM100_TO_TWIP( nTop );
1347 			   bGotVisibleTop = sal_True;
1348             }
1349             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleRight" ) ) )
1350             {
1351                pValue->Value >>= nRight;
1352 			   nRight = MM100_TO_TWIP( nRight );
1353 			   bGotVisibleRight = sal_True;
1354             }
1355             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VisibleBottom" ) ) )
1356             {
1357                pValue->Value >>= nBottom;
1358 			   nBottom = MM100_TO_TWIP( nBottom );
1359 			   bGotVisibleBottom = sal_True;
1360             }
1361             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomType" ) ) )
1362             {
1363                pValue->Value >>= nZoomType;
1364 			   bGotZoomType = sal_True;
1365             }
1366             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ZoomFactor" ) ) )
1367             {
1368                pValue->Value >>= nZoomFactor;
1369 			   bGotZoomFactor = sal_True;
1370             }
1371             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutColumns" ) ) )
1372             {
1373                pValue->Value >>= nViewLayoutColumns;
1374 			   bGotViewLayoutColumns = sal_True;
1375             }
1376             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ViewLayoutBookMode" ) ) )
1377             {
1378                bViewLayoutBookMode = * (sal_Bool *) pValue->Value.getValue();
1379 			   bGotViewLayoutBookMode = sal_True;
1380             }
1381             else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsSelectedFrame" ) ) )
1382             {
1383                pValue->Value >>= bSelectedFrame;
1384                bGotIsSelectedFrame = sal_True;
1385             }
1386             pValue++;
1387         }
1388 		if (bGotVisibleBottom)
1389 		{
1390 			Point aCrsrPos( nX, nY );
1391 			const long nAdd = pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2;
1392 			if (nBottom <= (pWrtShell->GetDocSize().Height()+nAdd) )
1393 			{
1394 				pWrtShell->EnableSmooth( sal_False );
1395 				const Rectangle aVis( nLeft, nTop, nRight, nBottom );
1396 
1397 				sal_uInt16 nOff = 0;
1398 				SvxZoomType eZoom;
1399                 if ( !pWrtShell->GetViewOptions()->getBrowseMode() )
1400 					eZoom = static_cast < SvxZoomType > ( nZoomType );
1401 				else
1402 				{
1403 					eZoom = SVX_ZOOM_PERCENT;
1404 					++nOff;
1405 				}
1406 				if (bGotIsSelectedFrame)
1407 				{
1408 					sal_Bool bSelectObj = (sal_False != bSelectedFrame )
1409 										&& pWrtShell->IsObjSelectable( aCrsrPos );
1410 
1411                     // OD 11.02.2003 #100556# - set flag value to avoid macro execution.
1412                     bool bSavedFlagValue = pWrtShell->IsMacroExecAllowed();
1413                     pWrtShell->SetMacroExecAllowed( false );
1414 //!!! pb (11.08.2004): #i32536#
1415 // os: changed: The user data has to be read if the view is switched back from page preview
1416 //#i43146# go to the last editing position when opening own files
1417                     //#i33307# restore editing position
1418                     pViewImpl->SetRestorePosition(aCrsrPos, bSelectObj);
1419                     if(bOldShellWasPagePreView|| bIsOwnDocument)
1420                     {
1421 					    pWrtShell->SwCrsrShell::SetCrsr( aCrsrPos, !bSelectObj );
1422 					    if( bSelectObj )
1423     					{
1424 						    pWrtShell->SelectObj( aCrsrPos );
1425 						    pWrtShell->EnterSelFrmMode( &aCrsrPos );
1426     					}
1427     				}
1428 
1429                     // OD 11.02.2003 #100556# - reset flag value
1430                     pWrtShell->SetMacroExecAllowed( bSavedFlagValue );
1431 				}
1432 				SelectShell();
1433 
1434                 // Set ViewLayoutSettings
1435                 const bool bSetViewLayoutSettings = bGotViewLayoutColumns && bGotViewLayoutBookMode &&
1436                                                     ( pVOpt->GetViewLayoutColumns() != nViewLayoutColumns || pVOpt->IsViewLayoutBookMode() != bViewLayoutBookMode );
1437 
1438                 const bool bSetViewSettings = bGotZoomType && bGotZoomFactor &&
1439                                               ( pVOpt->GetZoom() != nZoomFactor || pVOpt->GetZoomType() != eZoom );
1440 
1441                 // In case we have a 'fixed' view layout of 2 or more columns,
1442                 // we have to apply the view options *before* starting the action.
1443                 // Otherwsie the SetZoom function cannot work correctly, because
1444                 // the view layout hasn't been calculated.
1445                 const bool bZoomNeedsViewLayout = bSetViewLayoutSettings &&
1446                                                   1 < nViewLayoutColumns &&
1447                                                   bSetViewSettings &&
1448                                                   eZoom != SVX_ZOOM_PERCENT;
1449 
1450 
1451                 if ( !bZoomNeedsViewLayout )
1452                     pWrtShell->StartAction();
1453 
1454                 if ( bSetViewLayoutSettings )
1455                     SetViewLayout( nViewLayoutColumns, bViewLayoutBookMode, sal_True );
1456 
1457                 if ( bZoomNeedsViewLayout )
1458                     pWrtShell->StartAction();
1459 
1460 				if ( bSetViewSettings )
1461                     SetZoom( eZoom, nZoomFactor, sal_True );
1462 
1463 //!!! pb (11.08.2004): #i32536#
1464 // os: changed: The user data has to be read if the view is switched back from page preview
1465 //#i43146# go to the last editing position when opening own files
1466                 if(bOldShellWasPagePreView||bIsOwnDocument)
1467                 {
1468     				if ( bBrowse && bGotVisibleLeft && bGotVisibleTop )
1469                     {
1470                         Point aTopLeft(aVis.TopLeft());
1471                         //#i76699# make sure the document is still centered
1472                         const SwTwips lBorder = IsDocumentBorder() ? DOCUMENTBORDER : 2 * DOCUMENTBORDER;
1473                         SwTwips nEditWidth = GetEditWin().GetOutputSize().Width();
1474                         if(nEditWidth > (aDocSz.Width() + lBorder ))
1475                             aTopLeft.X() = ( aDocSz.Width() + lBorder - nEditWidth  ) / 2;
1476                         else
1477                         {
1478                             //check if the values are possible
1479                             long nXMax = pHScrollbar->GetRangeMax() - pHScrollbar->GetVisibleSize();
1480                             if( aTopLeft.X() > nXMax )
1481                                 aTopLeft.X() = nXMax < 0 ? 0 : nXMax;
1482                         }
1483                         SetVisArea( aTopLeft );
1484                     }
1485 				    else if (bGotVisibleLeft && bGotVisibleTop && bGotVisibleRight && bGotVisibleBottom )
1486     					SetVisArea( aVis );
1487 	    	    }
1488 
1489 				pWrtShell->LockView( sal_True );
1490 				pWrtShell->EndAction();
1491 				pWrtShell->LockView( sal_False );
1492 				pWrtShell->EnableSmooth( sal_True );
1493 			}
1494 		}
1495     }
1496 }
1497 #define NUM_VIEW_SETTINGS 12
1498 void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSequence, sal_Bool bBrowse )
1499 {
1500 	const SwRect& rRect = pWrtShell->GetCharRect();
1501 	const Rectangle& rVis = GetVisArea();
1502     Any aAny;
1503 
1504     rSequence.realloc ( NUM_VIEW_SETTINGS );
1505     sal_Int16 nIndex = 0;
1506     beans::PropertyValue *pValue = rSequence.getArray();
1507 
1508     sal_uInt16 nViewID( GetViewFrame()->GetCurViewId());
1509 	pValue->Name = rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM( "ViewId" ) );
1510 	OUStringBuffer sBuffer ( OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
1511 	SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
1512 	pValue->Value <<= sBuffer.makeStringAndClear();
1513     pValue++;nIndex++;
1514 
1515     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLeft" ) );
1516     pValue->Value <<= TWIP_TO_MM100 ( rRect.Left() );
1517     pValue++;nIndex++;
1518 
1519     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewTop" ) );
1520     pValue->Value <<= TWIP_TO_MM100 ( rRect.Top() );
1521     pValue++;nIndex++;
1522 
1523     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleLeft" ) );
1524     pValue->Value <<= TWIP_TO_MM100 ( rVis.Left() );
1525     pValue++;nIndex++;
1526 
1527     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleTop" ) );
1528     pValue->Value <<= TWIP_TO_MM100 ( rVis.Top() );
1529     pValue++;nIndex++;
1530 
1531     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleRight" ) );
1532     pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Right() );
1533     pValue++;nIndex++;
1534 
1535     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "VisibleBottom" ) );
1536     pValue->Value <<= TWIP_TO_MM100 ( bBrowse ? LONG_MIN : rVis.Bottom() );
1537     pValue++;nIndex++;
1538 
1539     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomType" ) );
1540     const sal_Int16 nZoomType = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetZoomType());
1541     pValue->Value <<= nZoomType;
1542     pValue++;nIndex++;
1543 
1544     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutColumns" ) );
1545     const sal_Int16 nViewLayoutColumns = static_cast< sal_Int16 >(pWrtShell->GetViewOptions()->GetViewLayoutColumns());
1546     pValue->Value <<= nViewLayoutColumns;
1547     pValue++;nIndex++;
1548 
1549     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ViewLayoutBookMode" ) );
1550     const sal_Bool bIsViewLayoutBookMode = pWrtShell->GetViewOptions()->IsViewLayoutBookMode();
1551     pValue->Value.setValue( &bIsViewLayoutBookMode, ::getBooleanCppuType() );
1552     pValue++;nIndex++;
1553 
1554     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ZoomFactor" ) );
1555     pValue->Value <<= static_cast < sal_Int16 > (pWrtShell->GetViewOptions()->GetZoom());
1556     pValue++;nIndex++;
1557 
1558     pValue->Name = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "IsSelectedFrame" ) );
1559 	const sal_Bool bIsSelected = FRMTYPE_NONE == pWrtShell->GetSelFrmType() ? sal_False : sal_True;
1560     pValue->Value.setValue ( &bIsSelected, ::getBooleanCppuType() );
1561 	nIndex++;
1562 
1563     if ( nIndex < NUM_VIEW_SETTINGS )
1564         rSequence.realloc ( nIndex );
1565 }
1566 #undef NUM_VIEW_SETTINGS
1567 
1568 
1569 
1570 void SwView::ShowCursor( FASTBOOL bOn )
1571 {
1572 	//JP 10.10.2001: Bug 90461 - don't scroll the cursor into the visible area
1573 	sal_Bool bUnlockView = !pWrtShell->IsViewLocked();
1574 	pWrtShell->LockView( sal_True );	//lock visible section
1575 
1576 	if( !bOn )
1577 		pWrtShell->HideCrsr();
1578 	else if( !pWrtShell->IsFrmSelected() && !pWrtShell->IsObjSelected() )
1579 		pWrtShell->ShowCrsr();
1580 
1581 	if( bUnlockView )
1582 		pWrtShell->LockView( sal_False );
1583 }
1584 
1585 
1586 
1587 ErrCode SwView::DoVerb( long nVerb )
1588 {
1589     if ( !GetViewFrame()->GetFrame().IsInPlace() )
1590 	{
1591 		SwWrtShell &rSh = GetWrtShell();
1592 		const int nSel = rSh.GetSelectionType();
1593 		if ( nSel & nsSelectionType::SEL_OLE )
1594 			rSh.LaunchOLEObj( nVerb );
1595 	}
1596 	return ERRCODE_NONE;
1597 }
1598 
1599 /*-----------------17.02.98 13:33-------------------
1600 	nur sal_True fuer eine Textselektion zurueck geben
1601 --------------------------------------------------*/
1602 sal_Bool SwView::HasSelection( sal_Bool  bText ) const
1603 {
1604 	return bText ? GetWrtShell().SwCrsrShell::HasSelection()
1605 				 : GetWrtShell().HasSelection();
1606 }
1607 
1608 /*-----------------09/16/97 09:50am-----------------
1609 
1610 --------------------------------------------------*/
1611 
1612 String SwView::GetSelectionText( sal_Bool bCompleteWrds )
1613 {
1614 	return GetSelectionTextParam( bCompleteWrds, sal_True );
1615 }
1616 
1617 /*-----------------09/16/97 09:50am-----------------
1618 
1619 --------------------------------------------------*/
1620 String	SwView::GetSelectionTextParam( sal_Bool bCompleteWrds,
1621 									   sal_Bool bEraseTrail )
1622 {
1623 	String sReturn;
1624 	if( bCompleteWrds && !GetWrtShell().HasSelection() )
1625 		GetWrtShell().SelWrd();
1626 
1627 	GetWrtShell().GetSelectedText( sReturn );
1628 	if( bEraseTrail )
1629 		sReturn.EraseTrailingChars();
1630 	return sReturn;
1631 }
1632 
1633 /*--------------------------------------------------------------------
1634 	Beschreibung:
1635  --------------------------------------------------------------------*/
1636 
1637 
1638 
1639 SwGlossaryHdl* SwView::GetGlosHdl()
1640 {
1641 	if(!pGlosHdl)
1642 		pGlosHdl = new SwGlossaryHdl(GetViewFrame(), pWrtShell);
1643 	return pGlosHdl;
1644 }
1645 
1646 /*-----------------05.09.96 15.50-------------------
1647 
1648 --------------------------------------------------*/
1649 
1650 
1651 
1652 void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1653 {
1654 	sal_Bool bCallBase = sal_True;
1655 	if ( rHint.ISA(SfxSimpleHint) )
1656 	{
1657 		sal_uInt32 nId = ((SfxSimpleHint&)rHint).GetId();
1658 		switch ( nId )
1659 		{
1660             // --> OD 2005-03-03 #i43775# - sub shells will be destroyed by the
1661             // dispatcher, if the view frame is dying. Thus, reset member <pShell>.
1662             case SFX_HINT_DYING:
1663                 {
1664                     if ( &rBC == GetViewFrame() )
1665                     {
1666                         ResetSubShell();
1667                     }
1668                 }
1669                 break;
1670             // <--
1671             case SFX_HINT_MODECHANGED:
1672 				{
1673 					// Modalmodus-Umschaltung?
1674 					sal_Bool bModal = GetDocShell()->IsInModalMode();
1675                     pHRuler->SetActive( !bModal );
1676                     pVRuler->SetActive( !bModal );
1677 				}
1678 
1679 				/* kein break hier */
1680 
1681 			case SFX_HINT_TITLECHANGED:
1682 				if ( GetDocShell()->IsReadOnly() != GetWrtShell().GetViewOptions()->IsReadonly() )
1683 				{
1684 					SwWrtShell &rSh = GetWrtShell();
1685 					rSh.SetReadonlyOption( GetDocShell()->IsReadOnly() );
1686 
1687                     if ( rSh.GetViewOptions()->IsViewVRuler() )
1688                         CreateVLineal();
1689 					else
1690                         KillVLineal();
1691                     if ( rSh.GetViewOptions()->IsViewHRuler() )
1692                         CreateTab();
1693 					else
1694                         KillTab();
1695 					bool bReadonly = GetDocShell()->IsReadOnly();
1696                     //#i76332# if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode
1697                     if( !bReadonly )
1698                     {
1699                         SwDrawDocument * pDrawDoc = 0;
1700                         if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) )
1701                         {
1702 				            if( !pDrawDoc->GetOpenInDesignMode() )
1703                                 break;// don't touch the design mode
1704                         }
1705                     }
1706                     SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly);
1707                     GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON,
1708 												&aItem, 0L );
1709 				}
1710 				break;
1711 
1712 			case SW_BROADCAST_DRAWVIEWS_CREATED:
1713 				{
1714 					bCallBase = sal_False;
1715 					if ( GetFormShell() )
1716 					{
1717 						GetFormShell()->SetView(
1718 							PTR_CAST(FmFormView, GetWrtShell().GetDrawView()) );
1719 						SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly());
1720                         GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON,
1721 												  &aItem, 0L );
1722 					}
1723 				}
1724 				break;
1725 		}
1726 	}
1727 	else if(rHint.ISA(FmDesignModeChangedHint))
1728 	{
1729 		sal_Bool bDesignMode = ((FmDesignModeChangedHint&)rHint).GetDesignMode();
1730 		if (!bDesignMode && GetDrawFuncPtr())
1731 		{
1732 			GetDrawFuncPtr()->Deactivate();
1733 			SetDrawFuncPtr(NULL);
1734 			LeaveDrawCreate();
1735 			AttrChangedNotify(pWrtShell);
1736 		}
1737 	}
1738 
1739 	if ( bCallBase )
1740 		SfxViewShell::Notify(rBC, rHint);
1741 }
1742 
1743 /*-----------------02.12.96 12:36-------------------
1744 
1745 --------------------------------------------------*/
1746 #if defined WNT || defined UNX
1747 
1748 void SwView::ScannerEventHdl( const EventObject& /*rEventObject*/ )
1749 {
1750 	uno::Reference< XScannerManager > xScanMgr = SW_MOD()->GetScannerManager();
1751 	if( xScanMgr.is() )
1752 	{
1753 		const ScannerContext	aContext( xScanMgr->getAvailableScanners().getConstArray()[ 0 ] );
1754 		const ScanError			eError = xScanMgr->getError( aContext );
1755 
1756 		if( ScanError_ScanErrorNone == eError )
1757 		{
1758 			const uno::Reference< awt::XBitmap > xBitmap( xScanMgr->getBitmap( aContext ) );
1759 
1760 			if( xBitmap.is() )
1761 			{
1762 				const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
1763 
1764 				if( !!aScanBmp )
1765 				{
1766 					Graphic aGrf(aScanBmp);
1767 					pWrtShell->Insert( aEmptyStr, aEmptyStr, aGrf );
1768 				}
1769 			}
1770 		}
1771 	}
1772 	SfxBindings& rBind = GetViewFrame()->GetBindings();
1773 	rBind.Invalidate( SID_TWAIN_SELECT );
1774 	rBind.Invalidate( SID_TWAIN_TRANSFER );
1775 }
1776 #endif
1777 
1778 /*-----------------04.03.97 15:07-------------------
1779 
1780 --------------------------------------------------*/
1781 
1782 
1783 void	SwView::StopShellTimer()
1784 {
1785 	if(aTimer.IsActive())
1786 	{
1787 		aTimer.Stop();
1788 		if ( bAttrChgNotifiedWithRegistrations )
1789 		{
1790 			GetViewFrame()->GetBindings().LEAVEREGISTRATIONS();
1791 			bAttrChgNotifiedWithRegistrations = sal_False;
1792 		}
1793 		SelectShell();
1794 		bAttrChgNotified = sal_False;
1795 	}
1796 }
1797 
1798 /*-----------------09/03/97 04:12pm-----------------
1799 
1800 --------------------------------------------------*/
1801 sal_uInt16  SwView::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
1802 {
1803 	SfxViewFrame* pVFrame = GetViewFrame();
1804 	pVFrame->SetChildWindow( SwInputChild::GetChildWindowId(), sal_False );
1805     if( pVFrame->GetDispatcher()->IsLocked() )
1806         pVFrame->GetDispatcher()->Lock(sal_False);
1807 
1808 	sal_uInt16 nRet;
1809 	if ( pFormShell &&
1810 		 sal_True != (nRet = pFormShell->PrepareClose( bUI, bForBrowsing )) )
1811 
1812 	{
1813 		return nRet;
1814 	}
1815 	return SfxViewShell::PrepareClose( bUI, bForBrowsing );
1816 }
1817 
1818 
1819 
1820 	// status methods for clipboard.
1821 	// Status changes now notified from the clipboard.
1822 sal_Bool SwView::IsPasteAllowed()
1823 {
1824 	sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
1825 	if( nLastPasteDestination != nPasteDestination )
1826 	{
1827 		TransferableDataHelper aDataHelper(
1828 						TransferableDataHelper::CreateFromSystemClipboard(
1829 														&GetEditWin()) );
1830 		if( aDataHelper.GetXTransferable().is() )
1831 		{
1832 			bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
1833 			bPasteSpecialState = SwTransferable::IsPasteSpecial(
1834 													*pWrtShell, aDataHelper );
1835 		}
1836 		else
1837 			bPasteState = bPasteSpecialState = sal_False;
1838 
1839 		if( 0xFFFF == nLastPasteDestination )  // the init value
1840 			pViewImpl->AddClipboardListener();
1841 		nLastPasteDestination = nPasteDestination;
1842 	}
1843 	return bPasteState;
1844 }
1845 
1846 sal_Bool SwView::IsPasteSpecialAllowed()
1847 {
1848     if ( pFormShell && pFormShell->IsActiveControl() )
1849         return sal_False;
1850 
1851 	sal_uInt16 nPasteDestination = SwTransferable::GetSotDestination( *pWrtShell );
1852 	if( nLastPasteDestination != nPasteDestination )
1853 	{
1854 		TransferableDataHelper aDataHelper(
1855 						TransferableDataHelper::CreateFromSystemClipboard(
1856 														&GetEditWin()) );
1857 		if( aDataHelper.GetXTransferable().is() )
1858 		{
1859 			bPasteState = SwTransferable::IsPaste( *pWrtShell, aDataHelper );
1860 			bPasteSpecialState = SwTransferable::IsPasteSpecial(
1861 													*pWrtShell, aDataHelper );
1862 		}
1863 		else
1864 			bPasteState = bPasteSpecialState = sal_False;
1865 
1866 		if( 0xFFFF == nLastPasteDestination )  // the init value
1867 			pViewImpl->AddClipboardListener();
1868 	}
1869 	return bPasteSpecialState;
1870 }
1871 /* -----------------------------12.07.01 13:25--------------------------------
1872 
1873  ---------------------------------------------------------------------------*/
1874 void SwView::NotifyDBChanged()
1875 {
1876     GetViewImpl()->GetUNOObject_Impl()->NotifyDBChanged();
1877 }
1878 
1879 /*--------------------------------------------------------------------
1880     Beschreibung:   Drucken
1881  --------------------------------------------------------------------*/
1882 
1883 /* -----------------------------28.10.02 13:25--------------------------------
1884 
1885  ---------------------------------------------------------------------------*/
1886 SfxObjectShellLock & SwView::GetTmpSelectionDoc()
1887 {
1888     return GetViewImpl()->GetTmpSelectionDoc();
1889 }
1890 /* -----------------------------31.10.02 13:25--------------------------------
1891 
1892  ---------------------------------------------------------------------------*/
1893 SfxObjectShellLock & SwView::GetOrCreateTmpSelectionDoc()
1894 {
1895     SfxObjectShellLock &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc();
1896     if (!rxTmpDoc.Is())
1897     {
1898         SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl();
1899         rxTmpDoc = pImpl->BuildTmpSelectionDoc();
1900     }
1901     return rxTmpDoc;
1902 }
1903 /* -----------------3/31/2003 12:39PM----------------
1904 
1905  --------------------------------------------------*/
1906 void SwView::AddTransferable(SwTransferable& rTransferable)
1907 {
1908     GetViewImpl()->AddTransferable(rTransferable);
1909 }
1910 
1911 /* --------------------------------------------------*/
1912 
1913 namespace sw {
1914 
1915 void InitPrintOptionsFromApplication(SwPrintData & o_rData, bool const bWeb)
1916 {
1917     o_rData = *SW_MOD()->GetPrtOptions(bWeb);
1918 }
1919 
1920 } // namespace sw
1921 
1922