xref: /AOO41X/main/sw/source/ui/uiview/view0.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #include "hintids.hxx"
34*cdf0e10cSrcweir #include <vcl/graph.hxx>
35*cdf0e10cSrcweir #include <svx/galbrws.hxx>
36*cdf0e10cSrcweir #include <svl/srchitem.hxx>
37*cdf0e10cSrcweir #include <SwSpellDialogChildWindow.hxx>
38*cdf0e10cSrcweir #include <svl/eitem.hxx>
39*cdf0e10cSrcweir #include <unotools/linguprops.hxx>
40*cdf0e10cSrcweir #include <unotools/lingucfg.hxx>
41*cdf0e10cSrcweir #include <viewopt.hxx>
42*cdf0e10cSrcweir #include <globals.h>
43*cdf0e10cSrcweir #include <sfx2/app.hxx>
44*cdf0e10cSrcweir #include <sfx2/request.hxx>
45*cdf0e10cSrcweir #include <svl/whiter.hxx>
46*cdf0e10cSrcweir #include <svx/srchdlg.hxx>
47*cdf0e10cSrcweir #include <sfx2/templdlg.hxx>
48*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
49*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
50*cdf0e10cSrcweir #include <uivwimp.hxx>
51*cdf0e10cSrcweir #include <avmedia/mediaplayer.hxx>
52*cdf0e10cSrcweir //#include <swlinguconfig.hxx>
53*cdf0e10cSrcweir #include <swmodule.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include <sfx2/objface.hxx>
56*cdf0e10cSrcweir #include <navipi.hxx>
57*cdf0e10cSrcweir #include <wrtsh.hxx>
58*cdf0e10cSrcweir #include <edtwin.hxx>
59*cdf0e10cSrcweir #include "view.hxx"
60*cdf0e10cSrcweir #include "basesh.hxx"
61*cdf0e10cSrcweir #include "docsh.hxx"
62*cdf0e10cSrcweir #include "doc.hxx"
63*cdf0e10cSrcweir #include "globals.hrc"
64*cdf0e10cSrcweir #include "cmdid.h"		 	// FN_		 ...
65*cdf0e10cSrcweir #include "globdoc.hxx"
66*cdf0e10cSrcweir #include "wview.hxx"
67*cdf0e10cSrcweir #include "shells.hrc"
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir #define OLEObjects
70*cdf0e10cSrcweir #define SwView
71*cdf0e10cSrcweir #define Frames
72*cdf0e10cSrcweir #define Graphics
73*cdf0e10cSrcweir #define Tables
74*cdf0e10cSrcweir #define Controls
75*cdf0e10cSrcweir #define GlobalContents
76*cdf0e10cSrcweir #define Text
77*cdf0e10cSrcweir #define Frame
78*cdf0e10cSrcweir #define Graphic
79*cdf0e10cSrcweir #define Object
80*cdf0e10cSrcweir #define Draw
81*cdf0e10cSrcweir #define TextDrawText
82*cdf0e10cSrcweir #define TextInTable
83*cdf0e10cSrcweir #define ListInText
84*cdf0e10cSrcweir #define ListInTable
85*cdf0e10cSrcweir #define WebTextInTable
86*cdf0e10cSrcweir #define WebListInText
87*cdf0e10cSrcweir #define WebListInTable
88*cdf0e10cSrcweir #define TextPage
89*cdf0e10cSrcweir #include <sfx2/msg.hxx>
90*cdf0e10cSrcweir #include "swslots.hxx"
91*cdf0e10cSrcweir #include <PostItMgr.hxx>
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir using namespace ::com::sun::star;
95*cdf0e10cSrcweir using ::rtl::OUString;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir #include <unomid.h>
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir SFX_IMPL_NAMED_VIEWFACTORY(SwView, "Default")
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir     if ( SvtModuleOptions().IsWriter() )
106*cdf0e10cSrcweir     {
107*cdf0e10cSrcweir         SFX_VIEW_REGISTRATION(SwDocShell);
108*cdf0e10cSrcweir         SFX_VIEW_REGISTRATION(SwGlobalDocShell);
109*cdf0e10cSrcweir     }
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir SFX_IMPL_INTERFACE( SwView, SfxViewShell, SW_RES(RID_TOOLS_TOOLBOX) )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR);
115*cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SID_TASKPANE);
116*cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
117*cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
118*cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION(SwSpellDialogChildWindow::GetChildWindowId());
119*cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION(FN_REDLINE_ACCEPT);
120*cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SID_HYPERLINK_DIALOG);
121*cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(GalleryChildWindow::GetChildWindowId());
122*cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(::avmedia::MediaPlayer::GetChildWindowId());
123*cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD_DATA_ONLY);
124*cdf0e10cSrcweir         SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_SYNC_LABELS,           CHILDWIN_LABEL    );
125*cdf0e10cSrcweir         SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_CHILDWINDOW, CHILDWIN_MAILMERGE);
126*cdf0e10cSrcweir //    SFX_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_SENDMAIL_CHILDWINDOW);
127*cdf0e10cSrcweir     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
128*cdf0e10cSrcweir 								SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
129*cdf0e10cSrcweir 								SW_RES(RID_TOOLS_TOOLBOX) );
130*cdf0e10cSrcweir }
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir TYPEINIT1(SwView,SfxViewShell)
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir /*-----------------13.12.97 11:06-------------------
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir --------------------------------------------------*/
137*cdf0e10cSrcweir ShellModes	SwView::GetShellMode()
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	return pViewImpl->GetShellMode();
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir /*-----------------13.12.97 11:28-------------------
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir --------------------------------------------------*/
145*cdf0e10cSrcweir view::XSelectionSupplier* SwView::GetUNOObject()
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	return pViewImpl->GetUNOObject();
148*cdf0e10cSrcweir }
149*cdf0e10cSrcweir /* -----------------------------06.05.2002 13:18------------------------------
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
152*cdf0e10cSrcweir void SwView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir     pWrtShell->ApplyAccessiblityOptions(rAccessibilityOptions);
155*cdf0e10cSrcweir     //to enable the right state of the selection cursor in readonly documents
156*cdf0e10cSrcweir     if(GetDocShell()->IsReadOnly())
157*cdf0e10cSrcweir         pWrtShell->ShowCrsr();
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir /*-- 26.05.2004 09:14:25---------------------------------------------------
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
163*cdf0e10cSrcweir void   SwView::SetMailMergeConfigItem(SwMailMergeConfigItem*  pConfigItem,
164*cdf0e10cSrcweir                 sal_uInt16 nRestart, sal_Bool bIsSource)
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir     pViewImpl->SetMailMergeConfigItem(pConfigItem, nRestart, bIsSource);
167*cdf0e10cSrcweir     UIFeatureChanged();
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir /*-- 26.05.2004 09:14:25---------------------------------------------------
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
172*cdf0e10cSrcweir SwMailMergeConfigItem*  SwView::GetMailMergeConfigItem()
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir     return pViewImpl->GetMailMergeConfigItem();
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir /*-- 26.05.2004 09:14:25---------------------------------------------------
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
179*cdf0e10cSrcweir sal_uInt16 SwView::GetMailMergeRestartPage() const
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir     return pViewImpl->GetMailMergeRestartPage();
182*cdf0e10cSrcweir }
183*cdf0e10cSrcweir /*-- 03.09.2004 11:56:33---------------------------------------------------
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
186*cdf0e10cSrcweir sal_Bool SwView::IsMailMergeSourceView() const
187*cdf0e10cSrcweir {
188*cdf0e10cSrcweir     return pViewImpl->IsMailMergeSourceView();
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir /*-- 12.04.2006 11:51:40---------------------------------------------------
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir   -----------------------------------------------------------------------*/
193*cdf0e10cSrcweir sal_Bool lcl_IsViewMarks( const SwViewOption& rVOpt )
194*cdf0e10cSrcweir {
195*cdf0e10cSrcweir     return  rVOpt.IsHardBlank() &&
196*cdf0e10cSrcweir             rVOpt.IsSoftHyph() &&
197*cdf0e10cSrcweir             SwViewOption::IsFieldShadings();
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir void lcl_SetViewMarks(SwViewOption& rVOpt, sal_Bool bOn )
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir     rVOpt.SetHardBlank(bOn);
202*cdf0e10cSrcweir     rVOpt.SetSoftHyph(bOn);
203*cdf0e10cSrcweir     SwViewOption::SetAppearanceFlag(
204*cdf0e10cSrcweir             VIEWOPT_FIELD_SHADINGS, bOn, sal_True);
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir void lcl_SetViewMetaChars( SwViewOption& rVOpt, sal_Bool bOn)
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir     rVOpt.SetViewMetaChars( bOn );
210*cdf0e10cSrcweir     if(bOn && !(rVOpt.IsParagraph()     ||
211*cdf0e10cSrcweir             rVOpt.IsTab()       ||
212*cdf0e10cSrcweir             rVOpt.IsLineBreak() ||
213*cdf0e10cSrcweir             rVOpt.IsShowHiddenChar() ||
214*cdf0e10cSrcweir             rVOpt.IsBlank()))
215*cdf0e10cSrcweir     {
216*cdf0e10cSrcweir         rVOpt.SetParagraph(bOn);
217*cdf0e10cSrcweir         rVOpt.SetTab(bOn);
218*cdf0e10cSrcweir         rVOpt.SetLineBreak(bOn);
219*cdf0e10cSrcweir         rVOpt.SetBlank(bOn);
220*cdf0e10cSrcweir         rVOpt.SetShowHiddenChar(bOn);
221*cdf0e10cSrcweir     }
222*cdf0e10cSrcweir }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir void SwView::RecheckBrowseMode()
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir     // OS: numerische Reihenfolge beachten!
227*cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aInva[] =
228*cdf0e10cSrcweir         {
229*cdf0e10cSrcweir             //SID_NEWWINDOW,/*5620*/
230*cdf0e10cSrcweir             SID_BROWSER_MODE, /*6313*/
231*cdf0e10cSrcweir             SID_RULER_BORDERS, SID_RULER_PAGE_POS,
232*cdf0e10cSrcweir             //SID_ATTR_LONG_LRSPACE,
233*cdf0e10cSrcweir             SID_HTML_MODE,
234*cdf0e10cSrcweir             SID_RULER_PROTECT,
235*cdf0e10cSrcweir             //SID_AUTOSPELL_CHECK,
236*cdf0e10cSrcweir             //SID_AUTOSPELL_MARKOFF,
237*cdf0e10cSrcweir             FN_RULER,      	/*20211*/
238*cdf0e10cSrcweir             FN_VIEW_GRAPHIC,    /*20213*/
239*cdf0e10cSrcweir             FN_VIEW_BOUNDS,   	/**/
240*cdf0e10cSrcweir             FN_VIEW_FIELDS,     /*20215*/
241*cdf0e10cSrcweir             FN_VLINEAL,             /*20216*/
242*cdf0e10cSrcweir             FN_VSCROLLBAR,      /*20217*/
243*cdf0e10cSrcweir             FN_HSCROLLBAR,      /*20218*/
244*cdf0e10cSrcweir             FN_VIEW_META_CHARS, /**/
245*cdf0e10cSrcweir             FN_VIEW_MARKS,     	/**/
246*cdf0e10cSrcweir             //FN_VIEW_FIELDNAME, 	/**/
247*cdf0e10cSrcweir             FN_VIEW_TABLEGRID,  /*20227*/
248*cdf0e10cSrcweir             FN_PRINT_LAYOUT, /*20237*/
249*cdf0e10cSrcweir             FN_QRY_MERGE,   /*20364*/
250*cdf0e10cSrcweir             FN_SHADOWCURSOR, /**/
251*cdf0e10cSrcweir             0
252*cdf0e10cSrcweir         };
253*cdf0e10cSrcweir     // the view must not exist!
254*cdf0e10cSrcweir     GetViewFrame()->GetBindings().Invalidate(aInva);
255*cdf0e10cSrcweir     CheckVisArea();
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir     SvxZoomType eType;
258*cdf0e10cSrcweir     if( GetWrtShell().GetViewOptions()->getBrowseMode() && SVX_ZOOM_PERCENT != (eType = (SvxZoomType)
259*cdf0e10cSrcweir         GetWrtShell().GetViewOptions()->GetZoomType()) )
260*cdf0e10cSrcweir         SetZoom( eType );
261*cdf0e10cSrcweir     InvalidateBorder();
262*cdf0e10cSrcweir }
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir /*--------------------------------------------------------------------
265*cdf0e10cSrcweir     State of view options
266*cdf0e10cSrcweir  --------------------------------------------------------------------*/
267*cdf0e10cSrcweir void SwView::StateViewOptions(SfxItemSet &rSet)
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir     SfxWhichIter aIter(rSet);
270*cdf0e10cSrcweir     sal_uInt16 nWhich = aIter.FirstWhich();
271*cdf0e10cSrcweir     SfxBoolItem aBool;
272*cdf0e10cSrcweir     const SwViewOption* pOpt = GetWrtShell().GetViewOptions();
273*cdf0e10cSrcweir     const IDocumentSettingAccess* pIDSA = GetDocShell()->getIDocumentSettingAccess();
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir     while(nWhich)
276*cdf0e10cSrcweir     {
277*cdf0e10cSrcweir         sal_Bool bReadonly = GetDocShell()->IsReadOnly();
278*cdf0e10cSrcweir         if ( bReadonly && nWhich != FN_VIEW_GRAPHIC )
279*cdf0e10cSrcweir         {
280*cdf0e10cSrcweir             rSet.DisableItem(nWhich);
281*cdf0e10cSrcweir             nWhich = 0;
282*cdf0e10cSrcweir         }
283*cdf0e10cSrcweir         switch(nWhich)
284*cdf0e10cSrcweir         {
285*cdf0e10cSrcweir             case FN_RULER:
286*cdf0e10cSrcweir             {
287*cdf0e10cSrcweir                 if(!pOpt->IsViewHRuler(sal_True) && !pOpt->IsViewVRuler(sal_True))
288*cdf0e10cSrcweir                 {
289*cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
290*cdf0e10cSrcweir                     nWhich = 0;
291*cdf0e10cSrcweir                 }
292*cdf0e10cSrcweir                 else
293*cdf0e10cSrcweir                     aBool.SetValue( pOpt->IsViewAnyRuler());
294*cdf0e10cSrcweir             }
295*cdf0e10cSrcweir             break;
296*cdf0e10cSrcweir             case SID_BROWSER_MODE:
297*cdf0e10cSrcweir             case FN_PRINT_LAYOUT:
298*cdf0e10cSrcweir 			{
299*cdf0e10cSrcweir                 sal_Bool bState = pOpt->getBrowseMode();
300*cdf0e10cSrcweir                 if(FN_PRINT_LAYOUT == nWhich)
301*cdf0e10cSrcweir                     bState = !bState;
302*cdf0e10cSrcweir                 aBool.SetValue( bState );
303*cdf0e10cSrcweir 			}
304*cdf0e10cSrcweir 			break;
305*cdf0e10cSrcweir             case FN_VIEW_BOUNDS:
306*cdf0e10cSrcweir                 aBool.SetValue( SwViewOption::IsDocBoundaries()); break;
307*cdf0e10cSrcweir             case FN_VIEW_GRAPHIC:
308*cdf0e10cSrcweir                 aBool.SetValue( !pOpt->IsGraphic() ); break;
309*cdf0e10cSrcweir             case FN_VIEW_FIELDS:
310*cdf0e10cSrcweir                 aBool.SetValue( SwViewOption::IsFieldShadings() ); break;
311*cdf0e10cSrcweir             case FN_VIEW_FIELDNAME:
312*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsFldName() ); break;
313*cdf0e10cSrcweir             case FN_VIEW_MARKS:
314*cdf0e10cSrcweir                 aBool.SetValue( lcl_IsViewMarks(*pOpt) ); break;
315*cdf0e10cSrcweir             case FN_VIEW_META_CHARS:
316*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsViewMetaChars() ); break;
317*cdf0e10cSrcweir             case FN_VIEW_TABLEGRID:
318*cdf0e10cSrcweir                 aBool.SetValue( SwViewOption::IsTableBoundaries() ); break;
319*cdf0e10cSrcweir 			case FN_VIEW_NOTES:
320*cdf0e10cSrcweir 			{
321*cdf0e10cSrcweir 				aBool.SetValue( pOpt->IsPostIts());
322*cdf0e10cSrcweir 				if (!GetPostItMgr()->HasNotes())
323*cdf0e10cSrcweir 				{
324*cdf0e10cSrcweir 					aBool.SetWhich( nWhich );
325*cdf0e10cSrcweir 					rSet.Put( aBool );
326*cdf0e10cSrcweir 					rSet.DisableItem(nWhich);
327*cdf0e10cSrcweir 					nWhich = 0;
328*cdf0e10cSrcweir 				}
329*cdf0e10cSrcweir 				break;
330*cdf0e10cSrcweir 			}
331*cdf0e10cSrcweir 			case FN_VIEW_HIDDEN_PARA:
332*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsShowHiddenPara()); break;
333*cdf0e10cSrcweir             case SID_GRID_VISIBLE:
334*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsGridVisible() ); break;
335*cdf0e10cSrcweir             case SID_GRID_USE:
336*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsSnap() ); break;
337*cdf0e10cSrcweir             case SID_HELPLINES_MOVE:
338*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsCrossHair() ); break;
339*cdf0e10cSrcweir             case FN_VIEW_SMOOTH_SCROLL:
340*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsSmoothScroll()); break;
341*cdf0e10cSrcweir             case FN_VLINEAL:
342*cdf0e10cSrcweir                 aBool.SetValue( 0 != StatVLineal() ); break;
343*cdf0e10cSrcweir             case FN_HSCROLLBAR:
344*cdf0e10cSrcweir                 if( pOpt->getBrowseMode() )
345*cdf0e10cSrcweir                 {
346*cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
347*cdf0e10cSrcweir                     nWhich = 0;
348*cdf0e10cSrcweir                 }
349*cdf0e10cSrcweir                 else
350*cdf0e10cSrcweir                     aBool.SetValue( IsHScrollbarVisible() ); break;
351*cdf0e10cSrcweir             case FN_VSCROLLBAR:
352*cdf0e10cSrcweir                 aBool.SetValue( IsVScrollbarVisible() ); break;
353*cdf0e10cSrcweir             case SID_AUTOSPELL_CHECK:
354*cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsOnlineSpell() );
355*cdf0e10cSrcweir             break;
356*cdf0e10cSrcweir             case FN_SHADOWCURSOR:
357*cdf0e10cSrcweir                 if (pIDSA == 0 || pOpt->getBrowseMode() )
358*cdf0e10cSrcweir                 {
359*cdf0e10cSrcweir                     rSet.DisableItem( nWhich );
360*cdf0e10cSrcweir                     nWhich = 0;
361*cdf0e10cSrcweir                 }
362*cdf0e10cSrcweir                 else
363*cdf0e10cSrcweir                     aBool.SetValue( pOpt->IsShadowCursor() );
364*cdf0e10cSrcweir             break;
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir         }
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir         if( nWhich )
369*cdf0e10cSrcweir         {
370*cdf0e10cSrcweir             aBool.SetWhich( nWhich );
371*cdf0e10cSrcweir             rSet.Put( aBool );
372*cdf0e10cSrcweir         }
373*cdf0e10cSrcweir         nWhich = aIter.NextWhich();
374*cdf0e10cSrcweir     }
375*cdf0e10cSrcweir }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir /*--------------------------------------------------------------------
378*cdf0e10cSrcweir     execute view options
379*cdf0e10cSrcweir  --------------------------------------------------------------------*/
380*cdf0e10cSrcweir void SwView::ExecViewOptions(SfxRequest &rReq)
381*cdf0e10cSrcweir {
382*cdf0e10cSrcweir     SwViewOption* pOpt = new SwViewOption( *GetWrtShell().GetViewOptions() );
383*cdf0e10cSrcweir     sal_Bool bModified = GetWrtShell().IsModified();
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir     int eState = STATE_TOGGLE;
386*cdf0e10cSrcweir     sal_Bool bSet = sal_False;
387*cdf0e10cSrcweir     bool bBrowseModeChanged = false;
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir     const SfxItemSet *pArgs = rReq.GetArgs();
390*cdf0e10cSrcweir     sal_uInt16 nSlot = rReq.GetSlot();
391*cdf0e10cSrcweir     const SfxPoolItem* pAttr=NULL;
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlot , sal_False, &pAttr ))
394*cdf0e10cSrcweir     {
395*cdf0e10cSrcweir         bSet = ((SfxBoolItem*)pAttr)->GetValue();
396*cdf0e10cSrcweir         eState = bSet ? STATE_ON : STATE_OFF;
397*cdf0e10cSrcweir     }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir     sal_Bool bFlag = STATE_ON == eState;
400*cdf0e10cSrcweir     uno::Reference< beans::XPropertySet >  xLngProp( ::GetLinguPropertySet() );
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir     switch ( nSlot )
403*cdf0e10cSrcweir     {
404*cdf0e10cSrcweir         case FN_VIEW_GRAPHIC:
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
407*cdf0e10cSrcweir                     bFlag = !pOpt->IsGraphic();
408*cdf0e10cSrcweir                 pOpt->SetGraphic( bFlag );
409*cdf0e10cSrcweir                 break;
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir         case FN_VIEW_FIELDS:
412*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
413*cdf0e10cSrcweir                     bFlag = !SwViewOption::IsFieldShadings() ;
414*cdf0e10cSrcweir                 SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bFlag, sal_True );
415*cdf0e10cSrcweir                 break;
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir         case FN_VIEW_BOUNDS:
418*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
419*cdf0e10cSrcweir                     bFlag = !SwViewOption::IsDocBoundaries();
420*cdf0e10cSrcweir                 SwViewOption::SetAppearanceFlag(VIEWOPT_DOC_BOUNDARIES, bFlag, sal_True );
421*cdf0e10cSrcweir                 break;
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir         case SID_GRID_VISIBLE:
424*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
425*cdf0e10cSrcweir                     bFlag = !pOpt->IsGridVisible();
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir                 pOpt->SetGridVisible( bFlag );
428*cdf0e10cSrcweir                 break;
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir         case SID_GRID_USE:
431*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
432*cdf0e10cSrcweir                     bFlag = !pOpt->IsSnap();
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir                 pOpt->SetSnap( bFlag );
435*cdf0e10cSrcweir                 break;
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir         case SID_HELPLINES_MOVE:
438*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
439*cdf0e10cSrcweir                     bFlag = !pOpt->IsCrossHair();
440*cdf0e10cSrcweir 
441*cdf0e10cSrcweir                 pOpt->SetCrossHair( bFlag );
442*cdf0e10cSrcweir                 break;
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir         case SID_BROWSER_MODE:
445*cdf0e10cSrcweir         case FN_PRINT_LAYOUT:
446*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
447*cdf0e10cSrcweir                     bFlag = !pOpt->getBrowseMode();
448*cdf0e10cSrcweir                 else if( nSlot == FN_PRINT_LAYOUT )
449*cdf0e10cSrcweir                     bFlag = !bFlag;
450*cdf0e10cSrcweir                 bBrowseModeChanged = bFlag != pOpt->getBrowseMode();
451*cdf0e10cSrcweir                 // Disable "multiple layout"
452*cdf0e10cSrcweir                 GetDocShell()->ToggleBrowserMode( bFlag, this );
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir                 pOpt->setBrowseMode( bFlag );
455*cdf0e10cSrcweir                 break;
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 	case FN_VIEW_NOTES:
458*cdf0e10cSrcweir                 if ( STATE_TOGGLE == eState )
459*cdf0e10cSrcweir                     bFlag = !pOpt->IsPostIts();
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir 				GetPostItMgr()->SetLayout();
462*cdf0e10cSrcweir                 pOpt->SetPostIts( bFlag );
463*cdf0e10cSrcweir                	if (pOpt->IsPostIts())
464*cdf0e10cSrcweir 			GetPostItMgr()->CheckMetaText();
465*cdf0e10cSrcweir 		 break;
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir         case FN_VIEW_HIDDEN_PARA:
468*cdf0e10cSrcweir                 if ( STATE_TOGGLE == eState )
469*cdf0e10cSrcweir                     bFlag = !pOpt->IsShowHiddenPara();
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir                 pOpt->SetShowHiddenPara( bFlag );
472*cdf0e10cSrcweir                 break;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir         case FN_VIEW_SMOOTH_SCROLL:
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir                 if ( STATE_TOGGLE == eState )
477*cdf0e10cSrcweir                     bFlag = !pOpt->IsSmoothScroll();
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir                 pOpt->SetSmoothScroll( bFlag );
480*cdf0e10cSrcweir                 break;
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir         case FN_VLINEAL:
484*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
485*cdf0e10cSrcweir                     bFlag = !pOpt->IsViewVRuler();
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir                 pOpt->SetViewVRuler( bFlag );
488*cdf0e10cSrcweir                 break;
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir         case FN_VSCROLLBAR:
491*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
492*cdf0e10cSrcweir                     bFlag = !pOpt->IsViewVScrollBar();
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir                 pOpt->SetViewVScrollBar( bFlag );
495*cdf0e10cSrcweir                 break;
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir         case FN_HSCROLLBAR:
498*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
499*cdf0e10cSrcweir                     bFlag = !pOpt->IsViewHScrollBar();
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir                 pOpt->SetViewHScrollBar( bFlag );
502*cdf0e10cSrcweir                 break;
503*cdf0e10cSrcweir         case FN_RULER:
504*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
505*cdf0e10cSrcweir                     bFlag = !pOpt->IsViewAnyRuler();
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir                 pOpt->SetViewAnyRuler( bFlag );
508*cdf0e10cSrcweir                 break;
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir         case FN_VIEW_TABLEGRID:
511*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
512*cdf0e10cSrcweir                     bFlag = !SwViewOption::IsTableBoundaries();
513*cdf0e10cSrcweir                 SwViewOption::SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bFlag, sal_True );
514*cdf0e10cSrcweir                 break;
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir         case FN_VIEW_FIELDNAME:
517*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
518*cdf0e10cSrcweir                     bFlag = !pOpt->IsFldName() ;
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir                 pOpt->SetFldName( bFlag );
521*cdf0e10cSrcweir                 break;
522*cdf0e10cSrcweir         case FN_VIEW_MARKS:
523*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
524*cdf0e10cSrcweir                     bFlag = !lcl_IsViewMarks(*pOpt) ;
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir                 lcl_SetViewMarks( *pOpt, bFlag );
527*cdf0e10cSrcweir                 break;
528*cdf0e10cSrcweir         case FN_VIEW_META_CHARS:
529*cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
530*cdf0e10cSrcweir                     bFlag = !pOpt->IsViewMetaChars();
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir                 lcl_SetViewMetaChars( *pOpt, bFlag );
533*cdf0e10cSrcweir         break;
534*cdf0e10cSrcweir         case SID_AUTOSPELL_CHECK:
535*cdf0e10cSrcweir             if( STATE_TOGGLE == eState )
536*cdf0e10cSrcweir                 bFlag = bSet = !pOpt->IsOnlineSpell();
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir             pOpt->SetOnlineSpell(bSet);
539*cdf0e10cSrcweir             {
540*cdf0e10cSrcweir                 uno::Any aVal( &bSet, ::getCppuBooleanType() );
541*cdf0e10cSrcweir                 String aPropName( C2S(UPN_IS_SPELL_AUTO) );
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir                 SvtLinguConfig  aCfg;
544*cdf0e10cSrcweir                 aCfg.SetProperty( aPropName, aVal );
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir                 if (xLngProp.is())
547*cdf0e10cSrcweir                     xLngProp->setPropertyValue( aPropName, aVal );
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir                 // for the time being we do not have a specific option for grammarchecking.
550*cdf0e10cSrcweir                 // thus we'll use the one for spell checking...
551*cdf0e10cSrcweir                 if (bSet)
552*cdf0e10cSrcweir                 {
553*cdf0e10cSrcweir                     SwDocShell *pDocSh = GetDocShell();
554*cdf0e10cSrcweir                     SwDoc *pDoc = pDocSh? pDocSh->GetDoc() : NULL;
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir                     // right now we don't have view options for automatic grammar checking. Thus...
557*cdf0e10cSrcweir                     sal_Bool bIsAutoGrammar = sal_False;
558*cdf0e10cSrcweir                     aCfg.GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar;
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir                     if (pDoc && bIsAutoGrammar)
561*cdf0e10cSrcweir                         StartGrammarChecking( *pDoc );
562*cdf0e10cSrcweir                 }
563*cdf0e10cSrcweir             }
564*cdf0e10cSrcweir         break;
565*cdf0e10cSrcweir         case FN_SHADOWCURSOR:
566*cdf0e10cSrcweir             if( STATE_TOGGLE == eState )
567*cdf0e10cSrcweir                 bFlag = bSet = !pOpt->IsShadowCursor();
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir             pOpt->SetShadowCursor(bSet);
570*cdf0e10cSrcweir         break;
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir         default:
573*cdf0e10cSrcweir             ASSERT(sal_False, Falsche Request-Methode);
574*cdf0e10cSrcweir             return;
575*cdf0e10cSrcweir     }
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir     // UserPrefs setzen Request als bearbeitet kennzeichnen
578*cdf0e10cSrcweir     sal_Bool bWebView =  0 != dynamic_cast<const SwWebView*>(this);
579*cdf0e10cSrcweir     SwWrtShell &rSh = GetWrtShell();
580*cdf0e10cSrcweir     rSh.StartAction();
581*cdf0e10cSrcweir     SwModule* pModule = SW_MOD();
582*cdf0e10cSrcweir     if( !(*rSh.GetViewOptions() == *pOpt ))
583*cdf0e10cSrcweir     {
584*cdf0e10cSrcweir         rSh.ApplyViewOptions( *pOpt );
585*cdf0e10cSrcweir         if( bBrowseModeChanged )
586*cdf0e10cSrcweir         {
587*cdf0e10cSrcweir             RecheckBrowseMode();
588*cdf0e10cSrcweir             CheckVisArea();
589*cdf0e10cSrcweir         }
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir         //Die UsrPref muessen als Modified gekennzeichnet werden.
592*cdf0e10cSrcweir         //call for initialization
593*cdf0e10cSrcweir         pModule->GetUsrPref(bWebView);
594*cdf0e10cSrcweir         pModule->CheckSpellChanges( pOpt->IsOnlineSpell(), sal_False, sal_False, sal_False );
595*cdf0e10cSrcweir     }
596*cdf0e10cSrcweir     //OS:   Modified wieder zuruecksetzen, weil Ansicht/Felder
597*cdf0e10cSrcweir     //      das Doc modified setzt.
598*cdf0e10cSrcweir     if( !bModified )
599*cdf0e10cSrcweir         rSh.ResetModified();
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir     pModule->ApplyUsrPref( *pOpt, this, bWebView ? VIEWOPT_DEST_WEB : VIEWOPT_DEST_TEXT );
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	//mod #i6193# let postits know about new spellcheck setting
604*cdf0e10cSrcweir     if ( nSlot == SID_AUTOSPELL_CHECK )
605*cdf0e10cSrcweir 		GetPostItMgr()->SetSpellChecking();
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir     const sal_Bool bLockedView = rSh.IsViewLocked();
608*cdf0e10cSrcweir     rSh.LockView( sal_True );    //lock visible section
609*cdf0e10cSrcweir     GetWrtShell().EndAction();
610*cdf0e10cSrcweir     if( bBrowseModeChanged && !bFlag )
611*cdf0e10cSrcweir         CalcVisArea( GetEditWin().GetOutputSizePixel() );
612*cdf0e10cSrcweir     rSh.LockView( bLockedView );
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir     delete pOpt;
615*cdf0e10cSrcweir     Invalidate(rReq.GetSlot());
616*cdf0e10cSrcweir     if(!pArgs)
617*cdf0e10cSrcweir         rReq.AppendItem(SfxBoolItem(nSlot, (sal_Bool)bFlag));
618*cdf0e10cSrcweir     rReq.Done();
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir IMPL_LINK( SwView, HtmlOptionsHdl, void*, EMPTYARG )
622*cdf0e10cSrcweir {
623*cdf0e10cSrcweir 	// Invalidierung, falls blinkender Text erlaubt/verboten wurde
624*cdf0e10cSrcweir     GetViewFrame()->GetBindings().Invalidate(SID_DRAW_TEXT_MARQUEE);
625*cdf0e10cSrcweir     return 0;
626*cdf0e10cSrcweir }
627