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