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