xref: /AOO41X/main/sw/source/ui/uiview/view0.cxx (revision d3e0dd8eb215533c15e891ee35bd141abe9397ee)
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 
SFX_IMPL_INTERFACE(SwView,SfxViewShell,SW_RES (RID_TOOLS_TOOLBOX))109cdf0e10cSrcweir SFX_IMPL_INTERFACE( SwView, SfxViewShell, SW_RES(RID_TOOLS_TOOLBOX) )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR);
112*7a32b0c8SAndre Fischer 	SFX_CHILDWINDOW_REGISTRATION(::sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
113cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
114cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
115cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION(SwSpellDialogChildWindow::GetChildWindowId());
116cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION(FN_REDLINE_ACCEPT);
117cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(SID_HYPERLINK_DIALOG);
118cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(GalleryChildWindow::GetChildWindowId());
119cdf0e10cSrcweir 	SFX_CHILDWINDOW_REGISTRATION(::avmedia::MediaPlayer::GetChildWindowId());
120cdf0e10cSrcweir     SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD_DATA_ONLY);
121cdf0e10cSrcweir         SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_SYNC_LABELS,           CHILDWIN_LABEL    );
122cdf0e10cSrcweir         SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_CHILDWINDOW, CHILDWIN_MAILMERGE);
123cdf0e10cSrcweir //    SFX_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_SENDMAIL_CHILDWINDOW);
124cdf0e10cSrcweir     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS|
125cdf0e10cSrcweir 								SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
126cdf0e10cSrcweir 								SW_RES(RID_TOOLS_TOOLBOX) );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
TYPEINIT1(SwView,SfxViewShell)129cdf0e10cSrcweir TYPEINIT1(SwView,SfxViewShell)
130cdf0e10cSrcweir 
131cdf0e10cSrcweir /*-----------------13.12.97 11:06-------------------
132cdf0e10cSrcweir 
133cdf0e10cSrcweir --------------------------------------------------*/
134cdf0e10cSrcweir ShellModes	SwView::GetShellMode()
135cdf0e10cSrcweir {
136cdf0e10cSrcweir 	return pViewImpl->GetShellMode();
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir /*-----------------13.12.97 11:28-------------------
140cdf0e10cSrcweir 
141cdf0e10cSrcweir --------------------------------------------------*/
GetUNOObject()142cdf0e10cSrcweir view::XSelectionSupplier* SwView::GetUNOObject()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	return pViewImpl->GetUNOObject();
145cdf0e10cSrcweir }
146cdf0e10cSrcweir /* -----------------------------06.05.2002 13:18------------------------------
147cdf0e10cSrcweir 
148cdf0e10cSrcweir  ---------------------------------------------------------------------------*/
ApplyAccessiblityOptions(SvtAccessibilityOptions & rAccessibilityOptions)149cdf0e10cSrcweir void SwView::ApplyAccessiblityOptions(SvtAccessibilityOptions& rAccessibilityOptions)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     pWrtShell->ApplyAccessiblityOptions(rAccessibilityOptions);
152cdf0e10cSrcweir     //to enable the right state of the selection cursor in readonly documents
153cdf0e10cSrcweir     if(GetDocShell()->IsReadOnly())
154cdf0e10cSrcweir         pWrtShell->ShowCrsr();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir }
157cdf0e10cSrcweir /*-- 26.05.2004 09:14:25---------------------------------------------------
158cdf0e10cSrcweir 
159cdf0e10cSrcweir   -----------------------------------------------------------------------*/
SetMailMergeConfigItem(SwMailMergeConfigItem * pConfigItem,sal_uInt16 nRestart,sal_Bool bIsSource)160cdf0e10cSrcweir void   SwView::SetMailMergeConfigItem(SwMailMergeConfigItem*  pConfigItem,
161cdf0e10cSrcweir                 sal_uInt16 nRestart, sal_Bool bIsSource)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir     pViewImpl->SetMailMergeConfigItem(pConfigItem, nRestart, bIsSource);
164cdf0e10cSrcweir     UIFeatureChanged();
165cdf0e10cSrcweir }
166cdf0e10cSrcweir /*-- 26.05.2004 09:14:25---------------------------------------------------
167cdf0e10cSrcweir 
168cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailMergeConfigItem()169cdf0e10cSrcweir SwMailMergeConfigItem*  SwView::GetMailMergeConfigItem()
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     return pViewImpl->GetMailMergeConfigItem();
172cdf0e10cSrcweir }
173cdf0e10cSrcweir /*-- 26.05.2004 09:14:25---------------------------------------------------
174cdf0e10cSrcweir 
175cdf0e10cSrcweir   -----------------------------------------------------------------------*/
GetMailMergeRestartPage() const176cdf0e10cSrcweir sal_uInt16 SwView::GetMailMergeRestartPage() const
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     return pViewImpl->GetMailMergeRestartPage();
179cdf0e10cSrcweir }
180cdf0e10cSrcweir /*-- 03.09.2004 11:56:33---------------------------------------------------
181cdf0e10cSrcweir 
182cdf0e10cSrcweir   -----------------------------------------------------------------------*/
IsMailMergeSourceView() const183cdf0e10cSrcweir sal_Bool SwView::IsMailMergeSourceView() const
184cdf0e10cSrcweir {
185cdf0e10cSrcweir     return pViewImpl->IsMailMergeSourceView();
186cdf0e10cSrcweir }
187cdf0e10cSrcweir /*-- 12.04.2006 11:51:40---------------------------------------------------
188cdf0e10cSrcweir 
189cdf0e10cSrcweir   -----------------------------------------------------------------------*/
lcl_IsViewMarks(const SwViewOption & rVOpt)190cdf0e10cSrcweir sal_Bool lcl_IsViewMarks( const SwViewOption& rVOpt )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir     return  rVOpt.IsHardBlank() &&
193cdf0e10cSrcweir             rVOpt.IsSoftHyph() &&
194cdf0e10cSrcweir             SwViewOption::IsFieldShadings();
195cdf0e10cSrcweir }
lcl_SetViewMarks(SwViewOption & rVOpt,sal_Bool bOn)196cdf0e10cSrcweir void lcl_SetViewMarks(SwViewOption& rVOpt, sal_Bool bOn )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir     rVOpt.SetHardBlank(bOn);
199cdf0e10cSrcweir     rVOpt.SetSoftHyph(bOn);
200cdf0e10cSrcweir     SwViewOption::SetAppearanceFlag(
201cdf0e10cSrcweir             VIEWOPT_FIELD_SHADINGS, bOn, sal_True);
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
lcl_SetViewMetaChars(SwViewOption & rVOpt,sal_Bool bOn)204cdf0e10cSrcweir void lcl_SetViewMetaChars( SwViewOption& rVOpt, sal_Bool bOn)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     rVOpt.SetViewMetaChars( bOn );
207cdf0e10cSrcweir     if(bOn && !(rVOpt.IsParagraph()     ||
208cdf0e10cSrcweir             rVOpt.IsTab()       ||
209cdf0e10cSrcweir             rVOpt.IsLineBreak() ||
210cdf0e10cSrcweir             rVOpt.IsShowHiddenChar() ||
211cdf0e10cSrcweir             rVOpt.IsBlank()))
212cdf0e10cSrcweir     {
213cdf0e10cSrcweir         rVOpt.SetParagraph(bOn);
214cdf0e10cSrcweir         rVOpt.SetTab(bOn);
215cdf0e10cSrcweir         rVOpt.SetLineBreak(bOn);
216cdf0e10cSrcweir         rVOpt.SetBlank(bOn);
217cdf0e10cSrcweir         rVOpt.SetShowHiddenChar(bOn);
218cdf0e10cSrcweir     }
219cdf0e10cSrcweir }
220cdf0e10cSrcweir 
RecheckBrowseMode()221cdf0e10cSrcweir void SwView::RecheckBrowseMode()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     // OS: numerische Reihenfolge beachten!
224cdf0e10cSrcweir     static sal_uInt16 __READONLY_DATA aInva[] =
225cdf0e10cSrcweir         {
226cdf0e10cSrcweir             //SID_NEWWINDOW,/*5620*/
227cdf0e10cSrcweir             SID_BROWSER_MODE, /*6313*/
228cdf0e10cSrcweir             SID_RULER_BORDERS, SID_RULER_PAGE_POS,
229cdf0e10cSrcweir             //SID_ATTR_LONG_LRSPACE,
230cdf0e10cSrcweir             SID_HTML_MODE,
231cdf0e10cSrcweir             SID_RULER_PROTECT,
232cdf0e10cSrcweir             //SID_AUTOSPELL_CHECK,
233cdf0e10cSrcweir             //SID_AUTOSPELL_MARKOFF,
234cdf0e10cSrcweir             FN_RULER,      	/*20211*/
235cdf0e10cSrcweir             FN_VIEW_GRAPHIC,    /*20213*/
236cdf0e10cSrcweir             FN_VIEW_BOUNDS,   	/**/
237cdf0e10cSrcweir             FN_VIEW_FIELDS,     /*20215*/
238cdf0e10cSrcweir             FN_VLINEAL,             /*20216*/
239cdf0e10cSrcweir             FN_VSCROLLBAR,      /*20217*/
240cdf0e10cSrcweir             FN_HSCROLLBAR,      /*20218*/
241cdf0e10cSrcweir             FN_VIEW_META_CHARS, /**/
242cdf0e10cSrcweir             FN_VIEW_MARKS,     	/**/
243cdf0e10cSrcweir             //FN_VIEW_FIELDNAME, 	/**/
244cdf0e10cSrcweir             FN_VIEW_TABLEGRID,  /*20227*/
245cdf0e10cSrcweir             FN_PRINT_LAYOUT, /*20237*/
246cdf0e10cSrcweir             FN_QRY_MERGE,   /*20364*/
247cdf0e10cSrcweir             FN_SHADOWCURSOR, /**/
248cdf0e10cSrcweir             0
249cdf0e10cSrcweir         };
250cdf0e10cSrcweir     // the view must not exist!
251cdf0e10cSrcweir     GetViewFrame()->GetBindings().Invalidate(aInva);
252cdf0e10cSrcweir     CheckVisArea();
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     SvxZoomType eType;
255cdf0e10cSrcweir     if( GetWrtShell().GetViewOptions()->getBrowseMode() && SVX_ZOOM_PERCENT != (eType = (SvxZoomType)
256cdf0e10cSrcweir         GetWrtShell().GetViewOptions()->GetZoomType()) )
257cdf0e10cSrcweir         SetZoom( eType );
258cdf0e10cSrcweir     InvalidateBorder();
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir /*--------------------------------------------------------------------
262cdf0e10cSrcweir     State of view options
263cdf0e10cSrcweir  --------------------------------------------------------------------*/
StateViewOptions(SfxItemSet & rSet)264cdf0e10cSrcweir void SwView::StateViewOptions(SfxItemSet &rSet)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir     SfxWhichIter aIter(rSet);
267cdf0e10cSrcweir     sal_uInt16 nWhich = aIter.FirstWhich();
268cdf0e10cSrcweir     SfxBoolItem aBool;
269cdf0e10cSrcweir     const SwViewOption* pOpt = GetWrtShell().GetViewOptions();
270cdf0e10cSrcweir     const IDocumentSettingAccess* pIDSA = GetDocShell()->getIDocumentSettingAccess();
271cdf0e10cSrcweir 
272cdf0e10cSrcweir     while(nWhich)
273cdf0e10cSrcweir     {
274cdf0e10cSrcweir         sal_Bool bReadonly = GetDocShell()->IsReadOnly();
275cdf0e10cSrcweir         if ( bReadonly && nWhich != FN_VIEW_GRAPHIC )
276cdf0e10cSrcweir         {
277cdf0e10cSrcweir             rSet.DisableItem(nWhich);
278cdf0e10cSrcweir             nWhich = 0;
279cdf0e10cSrcweir         }
280cdf0e10cSrcweir         switch(nWhich)
281cdf0e10cSrcweir         {
282cdf0e10cSrcweir             case FN_RULER:
283cdf0e10cSrcweir             {
284cdf0e10cSrcweir                 if(!pOpt->IsViewHRuler(sal_True) && !pOpt->IsViewVRuler(sal_True))
285cdf0e10cSrcweir                 {
286cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
287cdf0e10cSrcweir                     nWhich = 0;
288cdf0e10cSrcweir                 }
289cdf0e10cSrcweir                 else
290cdf0e10cSrcweir                     aBool.SetValue( pOpt->IsViewAnyRuler());
291cdf0e10cSrcweir             }
292cdf0e10cSrcweir             break;
293cdf0e10cSrcweir             case SID_BROWSER_MODE:
294cdf0e10cSrcweir             case FN_PRINT_LAYOUT:
295cdf0e10cSrcweir 			{
296cdf0e10cSrcweir                 sal_Bool bState = pOpt->getBrowseMode();
297cdf0e10cSrcweir                 if(FN_PRINT_LAYOUT == nWhich)
298cdf0e10cSrcweir                     bState = !bState;
299cdf0e10cSrcweir                 aBool.SetValue( bState );
300cdf0e10cSrcweir 			}
301cdf0e10cSrcweir 			break;
302cdf0e10cSrcweir             case FN_VIEW_BOUNDS:
303cdf0e10cSrcweir                 aBool.SetValue( SwViewOption::IsDocBoundaries()); break;
304cdf0e10cSrcweir             case FN_VIEW_GRAPHIC:
305cdf0e10cSrcweir                 aBool.SetValue( !pOpt->IsGraphic() ); break;
306cdf0e10cSrcweir             case FN_VIEW_FIELDS:
307cdf0e10cSrcweir                 aBool.SetValue( SwViewOption::IsFieldShadings() ); break;
308cdf0e10cSrcweir             case FN_VIEW_FIELDNAME:
309cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsFldName() ); break;
310cdf0e10cSrcweir             case FN_VIEW_MARKS:
311cdf0e10cSrcweir                 aBool.SetValue( lcl_IsViewMarks(*pOpt) ); break;
312cdf0e10cSrcweir             case FN_VIEW_META_CHARS:
313cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsViewMetaChars() ); break;
314cdf0e10cSrcweir             case FN_VIEW_TABLEGRID:
315cdf0e10cSrcweir                 aBool.SetValue( SwViewOption::IsTableBoundaries() ); break;
316cdf0e10cSrcweir 			case FN_VIEW_NOTES:
317cdf0e10cSrcweir 			{
318cdf0e10cSrcweir 				aBool.SetValue( pOpt->IsPostIts());
319cdf0e10cSrcweir 				if (!GetPostItMgr()->HasNotes())
320cdf0e10cSrcweir 				{
321cdf0e10cSrcweir 					aBool.SetWhich( nWhich );
322cdf0e10cSrcweir 					rSet.Put( aBool );
323cdf0e10cSrcweir 					rSet.DisableItem(nWhich);
324cdf0e10cSrcweir 					nWhich = 0;
325cdf0e10cSrcweir 				}
326cdf0e10cSrcweir 				break;
327cdf0e10cSrcweir 			}
328cdf0e10cSrcweir 			case FN_VIEW_HIDDEN_PARA:
329cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsShowHiddenPara()); break;
330cdf0e10cSrcweir             case SID_GRID_VISIBLE:
331cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsGridVisible() ); break;
332cdf0e10cSrcweir             case SID_GRID_USE:
333cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsSnap() ); break;
334cdf0e10cSrcweir             case SID_HELPLINES_MOVE:
335cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsCrossHair() ); break;
336cdf0e10cSrcweir             case FN_VIEW_SMOOTH_SCROLL:
337cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsSmoothScroll()); break;
338cdf0e10cSrcweir             case FN_VLINEAL:
339cdf0e10cSrcweir                 aBool.SetValue( 0 != StatVLineal() ); break;
340cdf0e10cSrcweir             case FN_HSCROLLBAR:
341cdf0e10cSrcweir                 if( pOpt->getBrowseMode() )
342cdf0e10cSrcweir                 {
343cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
344cdf0e10cSrcweir                     nWhich = 0;
345cdf0e10cSrcweir                 }
346cdf0e10cSrcweir                 else
347cdf0e10cSrcweir                     aBool.SetValue( IsHScrollbarVisible() ); break;
348cdf0e10cSrcweir             case FN_VSCROLLBAR:
349cdf0e10cSrcweir                 aBool.SetValue( IsVScrollbarVisible() ); break;
350cdf0e10cSrcweir             case SID_AUTOSPELL_CHECK:
351cdf0e10cSrcweir                 aBool.SetValue( pOpt->IsOnlineSpell() );
352cdf0e10cSrcweir             break;
353cdf0e10cSrcweir             case FN_SHADOWCURSOR:
354cdf0e10cSrcweir                 if (pIDSA == 0 || pOpt->getBrowseMode() )
355cdf0e10cSrcweir                 {
356cdf0e10cSrcweir                     rSet.DisableItem( nWhich );
357cdf0e10cSrcweir                     nWhich = 0;
358cdf0e10cSrcweir                 }
359cdf0e10cSrcweir                 else
360cdf0e10cSrcweir                     aBool.SetValue( pOpt->IsShadowCursor() );
361cdf0e10cSrcweir             break;
362cdf0e10cSrcweir 
363cdf0e10cSrcweir         }
364cdf0e10cSrcweir 
365cdf0e10cSrcweir         if( nWhich )
366cdf0e10cSrcweir         {
367cdf0e10cSrcweir             aBool.SetWhich( nWhich );
368cdf0e10cSrcweir             rSet.Put( aBool );
369cdf0e10cSrcweir         }
370cdf0e10cSrcweir         nWhich = aIter.NextWhich();
371cdf0e10cSrcweir     }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir 
374cdf0e10cSrcweir /*--------------------------------------------------------------------
375cdf0e10cSrcweir     execute view options
376cdf0e10cSrcweir  --------------------------------------------------------------------*/
ExecViewOptions(SfxRequest & rReq)377cdf0e10cSrcweir void SwView::ExecViewOptions(SfxRequest &rReq)
378cdf0e10cSrcweir {
379cdf0e10cSrcweir     SwViewOption* pOpt = new SwViewOption( *GetWrtShell().GetViewOptions() );
380cdf0e10cSrcweir     sal_Bool bModified = GetWrtShell().IsModified();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     int eState = STATE_TOGGLE;
383cdf0e10cSrcweir     sal_Bool bSet = sal_False;
384cdf0e10cSrcweir     bool bBrowseModeChanged = false;
385cdf0e10cSrcweir 
386cdf0e10cSrcweir     const SfxItemSet *pArgs = rReq.GetArgs();
387cdf0e10cSrcweir     sal_uInt16 nSlot = rReq.GetSlot();
388cdf0e10cSrcweir     const SfxPoolItem* pAttr=NULL;
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlot , sal_False, &pAttr ))
391cdf0e10cSrcweir     {
392cdf0e10cSrcweir         bSet = ((SfxBoolItem*)pAttr)->GetValue();
393cdf0e10cSrcweir         eState = bSet ? STATE_ON : STATE_OFF;
394cdf0e10cSrcweir     }
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     sal_Bool bFlag = STATE_ON == eState;
397cdf0e10cSrcweir     uno::Reference< beans::XPropertySet >  xLngProp( ::GetLinguPropertySet() );
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     switch ( nSlot )
400cdf0e10cSrcweir     {
401cdf0e10cSrcweir         case FN_VIEW_GRAPHIC:
402cdf0e10cSrcweir 
403cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
404cdf0e10cSrcweir                     bFlag = !pOpt->IsGraphic();
405cdf0e10cSrcweir                 pOpt->SetGraphic( bFlag );
406cdf0e10cSrcweir                 break;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir         case FN_VIEW_FIELDS:
409cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
410cdf0e10cSrcweir                     bFlag = !SwViewOption::IsFieldShadings() ;
411cdf0e10cSrcweir                 SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bFlag, sal_True );
412cdf0e10cSrcweir                 break;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir         case FN_VIEW_BOUNDS:
415cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
416cdf0e10cSrcweir                     bFlag = !SwViewOption::IsDocBoundaries();
417cdf0e10cSrcweir                 SwViewOption::SetAppearanceFlag(VIEWOPT_DOC_BOUNDARIES, bFlag, sal_True );
418cdf0e10cSrcweir                 break;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir         case SID_GRID_VISIBLE:
421cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
422cdf0e10cSrcweir                     bFlag = !pOpt->IsGridVisible();
423cdf0e10cSrcweir 
424cdf0e10cSrcweir                 pOpt->SetGridVisible( bFlag );
425cdf0e10cSrcweir                 break;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir         case SID_GRID_USE:
428cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
429cdf0e10cSrcweir                     bFlag = !pOpt->IsSnap();
430cdf0e10cSrcweir 
431cdf0e10cSrcweir                 pOpt->SetSnap( bFlag );
432cdf0e10cSrcweir                 break;
433cdf0e10cSrcweir 
434cdf0e10cSrcweir         case SID_HELPLINES_MOVE:
435cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
436cdf0e10cSrcweir                     bFlag = !pOpt->IsCrossHair();
437cdf0e10cSrcweir 
438cdf0e10cSrcweir                 pOpt->SetCrossHair( bFlag );
439cdf0e10cSrcweir                 break;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir         case SID_BROWSER_MODE:
442cdf0e10cSrcweir         case FN_PRINT_LAYOUT:
443cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
444cdf0e10cSrcweir                     bFlag = !pOpt->getBrowseMode();
445cdf0e10cSrcweir                 else if( nSlot == FN_PRINT_LAYOUT )
446cdf0e10cSrcweir                     bFlag = !bFlag;
447cdf0e10cSrcweir                 bBrowseModeChanged = bFlag != pOpt->getBrowseMode();
448cdf0e10cSrcweir                 // Disable "multiple layout"
449cdf0e10cSrcweir                 GetDocShell()->ToggleBrowserMode( bFlag, this );
450cdf0e10cSrcweir 
451cdf0e10cSrcweir                 pOpt->setBrowseMode( bFlag );
452cdf0e10cSrcweir                 break;
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	case FN_VIEW_NOTES:
455cdf0e10cSrcweir                 if ( STATE_TOGGLE == eState )
456cdf0e10cSrcweir                     bFlag = !pOpt->IsPostIts();
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 				GetPostItMgr()->SetLayout();
459cdf0e10cSrcweir                 pOpt->SetPostIts( bFlag );
460cdf0e10cSrcweir                	if (pOpt->IsPostIts())
461cdf0e10cSrcweir 			GetPostItMgr()->CheckMetaText();
462cdf0e10cSrcweir 		 break;
463cdf0e10cSrcweir 
464cdf0e10cSrcweir         case FN_VIEW_HIDDEN_PARA:
465cdf0e10cSrcweir                 if ( STATE_TOGGLE == eState )
466cdf0e10cSrcweir                     bFlag = !pOpt->IsShowHiddenPara();
467cdf0e10cSrcweir 
468cdf0e10cSrcweir                 pOpt->SetShowHiddenPara( bFlag );
469cdf0e10cSrcweir                 break;
470cdf0e10cSrcweir 
471cdf0e10cSrcweir         case FN_VIEW_SMOOTH_SCROLL:
472cdf0e10cSrcweir 
473cdf0e10cSrcweir                 if ( STATE_TOGGLE == eState )
474cdf0e10cSrcweir                     bFlag = !pOpt->IsSmoothScroll();
475cdf0e10cSrcweir 
476cdf0e10cSrcweir                 pOpt->SetSmoothScroll( bFlag );
477cdf0e10cSrcweir                 break;
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 
480cdf0e10cSrcweir         case FN_VLINEAL:
481cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
482cdf0e10cSrcweir                     bFlag = !pOpt->IsViewVRuler();
483cdf0e10cSrcweir 
484cdf0e10cSrcweir                 pOpt->SetViewVRuler( bFlag );
485cdf0e10cSrcweir                 break;
486cdf0e10cSrcweir 
487cdf0e10cSrcweir         case FN_VSCROLLBAR:
488cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
489cdf0e10cSrcweir                     bFlag = !pOpt->IsViewVScrollBar();
490cdf0e10cSrcweir 
491cdf0e10cSrcweir                 pOpt->SetViewVScrollBar( bFlag );
492cdf0e10cSrcweir                 break;
493cdf0e10cSrcweir 
494cdf0e10cSrcweir         case FN_HSCROLLBAR:
495cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
496cdf0e10cSrcweir                     bFlag = !pOpt->IsViewHScrollBar();
497cdf0e10cSrcweir 
498cdf0e10cSrcweir                 pOpt->SetViewHScrollBar( bFlag );
499cdf0e10cSrcweir                 break;
500cdf0e10cSrcweir         case FN_RULER:
501cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
502cdf0e10cSrcweir                     bFlag = !pOpt->IsViewAnyRuler();
503cdf0e10cSrcweir 
504cdf0e10cSrcweir                 pOpt->SetViewAnyRuler( bFlag );
505cdf0e10cSrcweir                 break;
506cdf0e10cSrcweir 
507cdf0e10cSrcweir         case FN_VIEW_TABLEGRID:
508cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
509cdf0e10cSrcweir                     bFlag = !SwViewOption::IsTableBoundaries();
510cdf0e10cSrcweir                 SwViewOption::SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bFlag, sal_True );
511cdf0e10cSrcweir                 break;
512cdf0e10cSrcweir 
513cdf0e10cSrcweir         case FN_VIEW_FIELDNAME:
514cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
515cdf0e10cSrcweir                     bFlag = !pOpt->IsFldName() ;
516cdf0e10cSrcweir 
517cdf0e10cSrcweir                 pOpt->SetFldName( bFlag );
518cdf0e10cSrcweir                 break;
519cdf0e10cSrcweir         case FN_VIEW_MARKS:
520cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
521cdf0e10cSrcweir                     bFlag = !lcl_IsViewMarks(*pOpt) ;
522cdf0e10cSrcweir 
523cdf0e10cSrcweir                 lcl_SetViewMarks( *pOpt, bFlag );
524cdf0e10cSrcweir                 break;
525cdf0e10cSrcweir         case FN_VIEW_META_CHARS:
526cdf0e10cSrcweir                 if( STATE_TOGGLE == eState )
527cdf0e10cSrcweir                     bFlag = !pOpt->IsViewMetaChars();
528cdf0e10cSrcweir 
529cdf0e10cSrcweir                 lcl_SetViewMetaChars( *pOpt, bFlag );
530cdf0e10cSrcweir         break;
531cdf0e10cSrcweir         case SID_AUTOSPELL_CHECK:
532cdf0e10cSrcweir             if( STATE_TOGGLE == eState )
533cdf0e10cSrcweir                 bFlag = bSet = !pOpt->IsOnlineSpell();
534cdf0e10cSrcweir 
535cdf0e10cSrcweir             pOpt->SetOnlineSpell(bSet);
536cdf0e10cSrcweir             {
537cdf0e10cSrcweir                 uno::Any aVal( &bSet, ::getCppuBooleanType() );
538cdf0e10cSrcweir                 String aPropName( C2S(UPN_IS_SPELL_AUTO) );
539cdf0e10cSrcweir 
540cdf0e10cSrcweir                 SvtLinguConfig  aCfg;
541cdf0e10cSrcweir                 aCfg.SetProperty( aPropName, aVal );
542cdf0e10cSrcweir 
543cdf0e10cSrcweir                 if (xLngProp.is())
544cdf0e10cSrcweir                     xLngProp->setPropertyValue( aPropName, aVal );
545cdf0e10cSrcweir 
546cdf0e10cSrcweir                 // for the time being we do not have a specific option for grammarchecking.
547cdf0e10cSrcweir                 // thus we'll use the one for spell checking...
548cdf0e10cSrcweir                 if (bSet)
549cdf0e10cSrcweir                 {
550cdf0e10cSrcweir                     SwDocShell *pDocSh = GetDocShell();
551cdf0e10cSrcweir                     SwDoc *pDoc = pDocSh? pDocSh->GetDoc() : NULL;
552cdf0e10cSrcweir 
553cdf0e10cSrcweir                     // right now we don't have view options for automatic grammar checking. Thus...
554cdf0e10cSrcweir                     sal_Bool bIsAutoGrammar = sal_False;
555cdf0e10cSrcweir                     aCfg.GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar;
556cdf0e10cSrcweir 
557cdf0e10cSrcweir                     if (pDoc && bIsAutoGrammar)
558cdf0e10cSrcweir                         StartGrammarChecking( *pDoc );
559cdf0e10cSrcweir                 }
560cdf0e10cSrcweir             }
561cdf0e10cSrcweir         break;
562cdf0e10cSrcweir         case FN_SHADOWCURSOR:
563cdf0e10cSrcweir             if( STATE_TOGGLE == eState )
564cdf0e10cSrcweir                 bFlag = bSet = !pOpt->IsShadowCursor();
565cdf0e10cSrcweir 
566cdf0e10cSrcweir             pOpt->SetShadowCursor(bSet);
567cdf0e10cSrcweir         break;
568cdf0e10cSrcweir 
569cdf0e10cSrcweir         default:
570cdf0e10cSrcweir             ASSERT(sal_False, Falsche Request-Methode);
571cdf0e10cSrcweir             return;
572cdf0e10cSrcweir     }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir     // UserPrefs setzen Request als bearbeitet kennzeichnen
575cdf0e10cSrcweir     sal_Bool bWebView =  0 != dynamic_cast<const SwWebView*>(this);
576cdf0e10cSrcweir     SwWrtShell &rSh = GetWrtShell();
577cdf0e10cSrcweir     rSh.StartAction();
578cdf0e10cSrcweir     SwModule* pModule = SW_MOD();
579cdf0e10cSrcweir     if( !(*rSh.GetViewOptions() == *pOpt ))
580cdf0e10cSrcweir     {
581cdf0e10cSrcweir         rSh.ApplyViewOptions( *pOpt );
582cdf0e10cSrcweir         if( bBrowseModeChanged )
583cdf0e10cSrcweir         {
584cdf0e10cSrcweir             RecheckBrowseMode();
585cdf0e10cSrcweir             CheckVisArea();
586cdf0e10cSrcweir         }
587cdf0e10cSrcweir 
588cdf0e10cSrcweir         //Die UsrPref muessen als Modified gekennzeichnet werden.
589cdf0e10cSrcweir         //call for initialization
590cdf0e10cSrcweir         pModule->GetUsrPref(bWebView);
591cdf0e10cSrcweir         pModule->CheckSpellChanges( pOpt->IsOnlineSpell(), sal_False, sal_False, sal_False );
592cdf0e10cSrcweir     }
593cdf0e10cSrcweir     //OS:   Modified wieder zuruecksetzen, weil Ansicht/Felder
594cdf0e10cSrcweir     //      das Doc modified setzt.
595cdf0e10cSrcweir     if( !bModified )
596cdf0e10cSrcweir         rSh.ResetModified();
597cdf0e10cSrcweir 
598cdf0e10cSrcweir     pModule->ApplyUsrPref( *pOpt, this, bWebView ? VIEWOPT_DEST_WEB : VIEWOPT_DEST_TEXT );
599cdf0e10cSrcweir 
600cdf0e10cSrcweir 	//mod #i6193# let postits know about new spellcheck setting
601cdf0e10cSrcweir     if ( nSlot == SID_AUTOSPELL_CHECK )
602cdf0e10cSrcweir 		GetPostItMgr()->SetSpellChecking();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     const sal_Bool bLockedView = rSh.IsViewLocked();
605cdf0e10cSrcweir     rSh.LockView( sal_True );    //lock visible section
606cdf0e10cSrcweir     GetWrtShell().EndAction();
607cdf0e10cSrcweir     if( bBrowseModeChanged && !bFlag )
608cdf0e10cSrcweir         CalcVisArea( GetEditWin().GetOutputSizePixel() );
609cdf0e10cSrcweir     rSh.LockView( bLockedView );
610cdf0e10cSrcweir 
611cdf0e10cSrcweir     delete pOpt;
612cdf0e10cSrcweir     Invalidate(rReq.GetSlot());
613cdf0e10cSrcweir     if(!pArgs)
614cdf0e10cSrcweir         rReq.AppendItem(SfxBoolItem(nSlot, (sal_Bool)bFlag));
615cdf0e10cSrcweir     rReq.Done();
616cdf0e10cSrcweir }
617cdf0e10cSrcweir 
IMPL_LINK(SwView,HtmlOptionsHdl,void *,EMPTYARG)618cdf0e10cSrcweir IMPL_LINK( SwView, HtmlOptionsHdl, void*, EMPTYARG )
619cdf0e10cSrcweir {
620cdf0e10cSrcweir 	// Invalidierung, falls blinkender Text erlaubt/verboten wurde
621cdf0e10cSrcweir     GetViewFrame()->GetBindings().Invalidate(SID_DRAW_TEXT_MARQUEE);
622cdf0e10cSrcweir     return 0;
623cdf0e10cSrcweir }
624