1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view0.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include "hintids.hxx"
37 #include <vcl/graph.hxx>
38 #include <svx/galbrws.hxx>
39 #include <svx/srchitem.hxx>
40 #include <SwSpellDialogChildWindow.hxx>
41 #include <svtools/eitem.hxx>
42 #include <svtools/linguprops.hxx>
43 #include <svtools/lingucfg.hxx>
44 #include <viewopt.hxx>
46 #include <sfx2/app.hxx>
47 #include <sfx2/request.hxx>
48 #include <svtools/whiter.hxx>
49 #include <svx/srchdlg.hxx>
50 #include <sfx2/templdlg.hxx>
51 #include <uivwimp.hxx>
52 #include <avmedia/mediaplayer.hxx>
53 #include <swmodule.hxx>
55 #include <sfx2/objface.hxx>
62 #include "globals.hrc"
63 #include "cmdid.h" // FN_ ...
64 #include "globdoc.hxx"
70 #define SearchAttributes
71 #define ReplaceAttributes
72 #define SearchSettings
73 #define _ExecSearch ExecSearch
74 #define _StateSearch StateSearch
79 #define GlobalContents
89 #define WebTextInTable
91 #define WebListInTable
93 #include <sfx2/msg.hxx>
94 #include <svx/svxslots.hxx>
95 #include "swslots.hxx"
96 #include <PostItMgr.hxx>
99 using namespace ::com::sun::star
;
100 using ::rtl::OUString
;
102 #include <svtools/moduleoptions.hxx>
104 #include <IDocumentSettingAccess.hxx>
109 SFX_IMPL_VIEWFACTORY(SwView
, SW_RES(STR_NONAME
))
111 if ( SvtModuleOptions().IsWriter() )
113 SFX_VIEW_REGISTRATION(SwDocShell
);
114 SFX_VIEW_REGISTRATION(SwGlobalDocShell
);
118 SFX_IMPL_INTERFACE( SwView
, SfxViewShell
, SW_RES(RID_TOOLS_TOOLBOX
) )
120 SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR
);
121 SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
122 SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId());
123 SFX_CHILDWINDOW_REGISTRATION(SwSpellDialogChildWindow::GetChildWindowId());
124 SFX_CHILDWINDOW_REGISTRATION(FN_REDLINE_ACCEPT
);
125 SFX_CHILDWINDOW_REGISTRATION(SID_HYPERLINK_DIALOG
);
126 SFX_CHILDWINDOW_REGISTRATION(GalleryChildWindow::GetChildWindowId());
127 SFX_CHILDWINDOW_REGISTRATION(::avmedia::MediaPlayer::GetChildWindowId());
128 SFX_CHILDWINDOW_REGISTRATION(FN_INSERT_FIELD_DATA_ONLY
);
129 SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_SYNC_LABELS
, CHILDWIN_LABEL
);
130 SFX_FEATURED_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_CHILDWINDOW
, CHILDWIN_MAILMERGE
);
131 // SFX_CHILDWINDOW_REGISTRATION(FN_MAILMERGE_SENDMAIL_CHILDWINDOW);
132 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS
|
133 SFX_VISIBILITY_STANDARD
|SFX_VISIBILITY_SERVER
,
134 SW_RES(RID_TOOLS_TOOLBOX
) );
137 TYPEINIT1(SwView
,SfxViewShell
)
139 /*-----------------13.12.97 11:06-------------------
141 --------------------------------------------------*/
142 ShellModes
SwView::GetShellMode()
144 return pViewImpl
->GetShellMode();
147 /*-----------------13.12.97 11:28-------------------
149 --------------------------------------------------*/
150 view::XSelectionSupplier
* SwView::GetUNOObject()
152 return pViewImpl
->GetUNOObject();
154 /* -----------------------------06.05.2002 13:18------------------------------
156 ---------------------------------------------------------------------------*/
157 void SwView::ApplyAccessiblityOptions(SvtAccessibilityOptions
& rAccessibilityOptions
)
159 pWrtShell
->ApplyAccessiblityOptions(rAccessibilityOptions
);
160 //to enable the right state of the selection cursor in readonly documents
161 if(GetDocShell()->IsReadOnly())
162 pWrtShell
->ShowCrsr();
165 /*-- 26.05.2004 09:14:25---------------------------------------------------
167 -----------------------------------------------------------------------*/
168 void SwView::SetMailMergeConfigItem(SwMailMergeConfigItem
* pConfigItem
,
169 sal_uInt16 nRestart
, sal_Bool bIsSource
)
171 pViewImpl
->SetMailMergeConfigItem(pConfigItem
, nRestart
, bIsSource
);
174 /*-- 26.05.2004 09:14:25---------------------------------------------------
176 -----------------------------------------------------------------------*/
177 SwMailMergeConfigItem
* SwView::GetMailMergeConfigItem()
179 return pViewImpl
->GetMailMergeConfigItem();
181 /*-- 26.05.2004 09:14:25---------------------------------------------------
183 -----------------------------------------------------------------------*/
184 sal_uInt16
SwView::GetMailMergeRestartPage() const
186 return pViewImpl
->GetMailMergeRestartPage();
188 /*-- 03.09.2004 11:56:33---------------------------------------------------
190 -----------------------------------------------------------------------*/
191 sal_Bool
SwView::IsMailMergeSourceView() const
193 return pViewImpl
->IsMailMergeSourceView();
195 /*-- 12.04.2006 11:51:40---------------------------------------------------
197 -----------------------------------------------------------------------*/
198 sal_Bool
lcl_IsViewMarks( const SwViewOption
& rVOpt
)
200 return rVOpt
.IsHardBlank() &&
201 rVOpt
.IsSoftHyph() &&
202 SwViewOption::IsFieldShadings();
204 void lcl_SetViewMarks(SwViewOption
& rVOpt
, sal_Bool bOn
)
206 rVOpt
.SetHardBlank(bOn
);
207 rVOpt
.SetSoftHyph(bOn
);
208 SwViewOption::SetAppearanceFlag(
209 VIEWOPT_FIELD_SHADINGS
, bOn
, TRUE
);
212 void lcl_SetViewMetaChars( SwViewOption
& rVOpt
, sal_Bool bOn
)
214 rVOpt
.SetViewMetaChars( bOn
);
215 if(bOn
&& !(rVOpt
.IsParagraph() ||
217 rVOpt
.IsLineBreak() ||
218 rVOpt
.IsShowHiddenChar() ||
221 rVOpt
.SetParagraph(bOn
);
223 rVOpt
.SetLineBreak(bOn
);
225 rVOpt
.SetShowHiddenChar(bOn
);
229 /*--------------------------------------------------------------------
230 State of view options
231 --------------------------------------------------------------------*/
232 void SwView::StateViewOptions(SfxItemSet
&rSet
)
234 SfxWhichIter
aIter(rSet
);
235 sal_uInt16 nWhich
= aIter
.FirstWhich();
237 const SwViewOption
* pOpt
= GetWrtShell().GetViewOptions();
238 const IDocumentSettingAccess
* pIDSA
= GetDocShell()->getIDocumentSettingAccess();
242 sal_Bool bReadonly
= GetDocShell()->IsReadOnly();
243 sal_Bool bBrowse
= pIDSA
? pIDSA
->get( IDocumentSettingAccess::BROWSE_MODE
) : sal_False
;
244 if ( bReadonly
&& nWhich
!= FN_VIEW_GRAPHIC
)
246 rSet
.DisableItem(nWhich
);
253 if(!pOpt
->IsViewHRuler(TRUE
) && !pOpt
->IsViewVRuler(TRUE
))
255 rSet
.DisableItem(nWhich
);
259 aBool
.SetValue( pOpt
->IsViewAnyRuler());
263 aBool
.SetValue( SwViewOption::IsDocBoundaries()); break;
264 case FN_VIEW_GRAPHIC
:
265 aBool
.SetValue( !pOpt
->IsGraphic() ); break;
267 aBool
.SetValue( SwViewOption::IsFieldShadings() ); break;
268 case FN_VIEW_FIELDNAME
:
269 aBool
.SetValue( pOpt
->IsFldName() ); break;
271 aBool
.SetValue( lcl_IsViewMarks(*pOpt
) ); break;
272 case FN_VIEW_META_CHARS
:
273 aBool
.SetValue( pOpt
->IsViewMetaChars() ); break;
274 case FN_VIEW_TABLEGRID
:
275 aBool
.SetValue( SwViewOption::IsTableBoundaries() ); break;
278 aBool
.SetValue( pOpt
->IsPostIts());
279 if (!GetPostItMgr()->HasNotes())
281 aBool
.SetWhich( nWhich
);
283 rSet
.DisableItem(nWhich
);
288 case FN_VIEW_HIDDEN_PARA
:
289 aBool
.SetValue( pOpt
->IsShowHiddenPara()); break;
290 case SID_GRID_VISIBLE
:
291 aBool
.SetValue( pOpt
->IsGridVisible() ); break;
293 aBool
.SetValue( pOpt
->IsSnap() ); break;
294 case SID_HELPLINES_MOVE
:
295 aBool
.SetValue( pOpt
->IsCrossHair() ); break;
296 case FN_VIEW_SMOOTH_SCROLL
:
297 aBool
.SetValue( pOpt
->IsSmoothScroll()); break;
299 aBool
.SetValue( 0 != StatVLineal() ); break;
303 rSet
.DisableItem(nWhich
);
307 aBool
.SetValue( IsHScrollbarVisible() ); break;
309 aBool
.SetValue( IsVScrollbarVisible() ); break;
310 case SID_AUTOSPELL_CHECK
:
311 aBool
.SetValue( pOpt
->IsOnlineSpell() );
313 case FN_SHADOWCURSOR
:
314 if (pIDSA
== 0 || pIDSA
->get( IDocumentSettingAccess::BROWSE_MODE
))
316 rSet
.DisableItem( nWhich
);
320 aBool
.SetValue( pOpt
->IsShadowCursor() );
327 aBool
.SetWhich( nWhich
);
330 nWhich
= aIter
.NextWhich();
334 /*--------------------------------------------------------------------
336 --------------------------------------------------------------------*/
337 void SwView::ExecViewOptions(SfxRequest
&rReq
)
339 SwViewOption
* pOpt
= new SwViewOption( *GetWrtShell().GetViewOptions() );
340 sal_Bool bModified
= GetWrtShell().IsModified();
342 int eState
= STATE_TOGGLE
;
343 sal_Bool bSet
= sal_False
;
345 const SfxItemSet
*pArgs
= rReq
.GetArgs();
346 sal_uInt16 nSlot
= rReq
.GetSlot();
347 const SfxPoolItem
* pAttr
=NULL
;
349 if( pArgs
&& SFX_ITEM_SET
== pArgs
->GetItemState( nSlot
, sal_False
, &pAttr
))
351 bSet
= ((SfxBoolItem
*)pAttr
)->GetValue();
352 eState
= bSet
? STATE_ON
: STATE_OFF
;
355 BOOL bFlag
= STATE_ON
== eState
;
356 uno::Reference
< beans::XPropertySet
> xLngProp( ::GetLinguPropertySet() );
360 case FN_VIEW_GRAPHIC
:
362 if( STATE_TOGGLE
== eState
)
363 bFlag
= !pOpt
->IsGraphic();
364 pOpt
->SetGraphic( bFlag
);
368 if( STATE_TOGGLE
== eState
)
369 bFlag
= !SwViewOption::IsFieldShadings() ;
370 SwViewOption::SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS
, bFlag
, TRUE
);
374 if( STATE_TOGGLE
== eState
)
375 bFlag
= !SwViewOption::IsDocBoundaries();
376 SwViewOption::SetAppearanceFlag(VIEWOPT_DOC_BOUNDARIES
, bFlag
, TRUE
);
379 case SID_GRID_VISIBLE
:
380 if( STATE_TOGGLE
== eState
)
381 bFlag
= !pOpt
->IsGridVisible();
383 pOpt
->SetGridVisible( bFlag
);
387 if( STATE_TOGGLE
== eState
)
388 bFlag
= !pOpt
->IsSnap();
390 pOpt
->SetSnap( bFlag
);
393 case SID_HELPLINES_MOVE
:
394 if( STATE_TOGGLE
== eState
)
395 bFlag
= !pOpt
->IsCrossHair();
397 pOpt
->SetCrossHair( bFlag
);
401 if ( STATE_TOGGLE
== eState
)
402 bFlag
= !pOpt
->IsPostIts();
404 GetPostItMgr()->SetLayout();
405 pOpt
->SetPostIts( bFlag
);
406 if (pOpt
->IsPostIts())
407 GetPostItMgr()->CheckMetaText();
410 case FN_VIEW_HIDDEN_PARA
:
411 if ( STATE_TOGGLE
== eState
)
412 bFlag
= !pOpt
->IsShowHiddenPara();
414 pOpt
->SetShowHiddenPara( bFlag
);
417 case FN_VIEW_SMOOTH_SCROLL
:
419 if ( STATE_TOGGLE
== eState
)
420 bFlag
= !pOpt
->IsSmoothScroll();
422 pOpt
->SetSmoothScroll( bFlag
);
427 if( STATE_TOGGLE
== eState
)
428 bFlag
= !pOpt
->IsViewVRuler();
430 pOpt
->SetViewVRuler( bFlag
);
434 if( STATE_TOGGLE
== eState
)
435 bFlag
= !pOpt
->IsViewVScrollBar();
437 pOpt
->SetViewVScrollBar( bFlag
);
441 if( STATE_TOGGLE
== eState
)
442 bFlag
= !pOpt
->IsViewHScrollBar();
444 pOpt
->SetViewHScrollBar( bFlag
);
447 if( STATE_TOGGLE
== eState
)
448 bFlag
= !pOpt
->IsViewAnyRuler();
450 pOpt
->SetViewAnyRuler( bFlag
);
453 case FN_VIEW_TABLEGRID
:
454 if( STATE_TOGGLE
== eState
)
455 bFlag
= !SwViewOption::IsTableBoundaries();
456 SwViewOption::SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES
, bFlag
, TRUE
);
459 case FN_VIEW_FIELDNAME
:
460 if( STATE_TOGGLE
== eState
)
461 bFlag
= !pOpt
->IsFldName() ;
463 pOpt
->SetFldName( bFlag
);
466 if( STATE_TOGGLE
== eState
)
467 bFlag
= !lcl_IsViewMarks(*pOpt
) ;
469 lcl_SetViewMarks( *pOpt
, bFlag
);
471 case FN_VIEW_META_CHARS
:
472 if( STATE_TOGGLE
== eState
)
473 bFlag
= !pOpt
->IsViewMetaChars();
475 lcl_SetViewMetaChars( *pOpt
, bFlag
);
477 case SID_AUTOSPELL_CHECK
:
478 if( STATE_TOGGLE
== eState
)
479 bFlag
= bSet
= !pOpt
->IsOnlineSpell();
481 pOpt
->SetOnlineSpell(bSet
);
483 uno::Any
aVal( &bSet
, ::getCppuBooleanType() );
484 String
aPropName( C2S(UPN_IS_SPELL_AUTO
) );
487 aCfg
.SetProperty( aPropName
, aVal
);
490 xLngProp
->setPropertyValue( aPropName
, aVal
);
492 // for the time being we do not have a specific option for grammarchecking.
493 // thus we'll use the one for spell checking...
496 SwDocShell
*pDocSh
= GetDocShell();
497 SwDoc
*pDoc
= pDocSh
? pDocSh
->GetDoc() : NULL
;
499 // right now we don't have view options for automatic grammar checking. Thus...
500 sal_Bool bIsAutoGrammar
= sal_False
;
501 aCfg
.GetProperty( C2U( UPN_IS_GRAMMAR_AUTO
) ) >>= bIsAutoGrammar
;
503 if (pDoc
&& bIsAutoGrammar
)
504 StartGrammarChecking( *pDoc
);
508 case FN_SHADOWCURSOR
:
509 if( STATE_TOGGLE
== eState
)
510 bFlag
= bSet
= !pOpt
->IsShadowCursor();
512 pOpt
->SetShadowCursor(bSet
);
516 ASSERT(sal_False
, Falsche Request
-Methode
);
520 // UserPrefs setzen Request als bearbeitet kennzeichnen
521 sal_Bool bWebView
= 0 != dynamic_cast<const SwWebView
*>(this);
522 SwWrtShell
&rSh
= GetWrtShell();
524 SwModule
* pModule
= SW_MOD();
525 if( !(*rSh
.GetViewOptions() == *pOpt
))
527 rSh
.ApplyViewOptions( *pOpt
);
529 //Die UsrPref muessen als Modified gekennzeichnet werden.
530 //call for initialization
531 pModule
->GetUsrPref(bWebView
);
532 pModule
->CheckSpellChanges( pOpt
->IsOnlineSpell(), sal_False
, sal_False
, sal_False
);
534 //OS: Modified wieder zuruecksetzen, weil Ansicht/Felder
535 // das Doc modified setzt.
539 pModule
->ApplyUsrPref( *pOpt
, this, bWebView
? VIEWOPT_DEST_WEB
: VIEWOPT_DEST_TEXT
);
541 //mod #i6193# let postits know about new spellcheck setting
542 if ( nSlot
== SID_AUTOSPELL_CHECK
)
543 GetPostItMgr()->SetSpellChecking();
545 const BOOL bLockedView
= rSh
.IsViewLocked();
546 rSh
.LockView( TRUE
); //lock visible section
547 GetWrtShell().EndAction();
548 rSh
.LockView( bLockedView
);
551 Invalidate(rReq
.GetSlot());
553 rReq
.AppendItem(SfxBoolItem(nSlot
, (BOOL
)bFlag
));