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