xref: /aoo41x/main/sw/source/ui/uiview/view1.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 
32 #include <svx/svdpagv.hxx>
33 #include <svx/svdview.hxx>
34 #include <svx/ruler.hxx>
35 #include <idxmrk.hxx>
36 #ifndef _VIEW_HXX
37 #include <view.hxx>
38 #endif
39 #include <wrtsh.hxx>
40 #include <swmodule.hxx>
41 #include <viewopt.hxx>
42 #ifndef _DOCSH_HXX
43 #include <docsh.hxx>
44 #endif
45 #ifndef _GLOBDOC_HXX
46 #include <globdoc.hxx>
47 #endif
48 #include <navipi.hxx>
49 #include <fldwrap.hxx>
50 #ifndef _REDLNDLG_HXX
51 #include <redlndlg.hxx>
52 #endif
53 #include <dpage.hxx>
54 #include <edtwin.hxx>
55 #include "formatclipboard.hxx"
56 #ifndef _CMDID_H
57 #include <cmdid.h>
58 #endif
59 // header for class SfxRequest
60 #include <sfx2/request.hxx>
61 
62 #include <sfx2/viewfrm.hxx>
63 
64 extern int bDocSzUpdated;
65 
66 
67 /*--------------------------------------------------------------------
68 	Beschreibung:
69  --------------------------------------------------------------------*/
70 
71 
72 void SwView::Activate(sal_Bool bMDIActivate)
73 {
74 	// aktuelle View anmelden an der DocShell
75 	// die View bleibt solange an der DocShell
76 	// aktiv bis Sie zerstoert wird oder durch Activate eine
77 	// neue gesetzt wird
78 	SwDocShell* pDocSh = GetDocShell();
79 	if(pDocSh)
80 		pDocSh->SetView(this);
81 	SwModule* pSwMod = SW_MOD();
82 	pSwMod->SetView(this);
83 
84 	// Dokumentgroesse hat sich geaendert
85 	if(!bDocSzUpdated)
86 		DocSzChgd(aDocSz);
87 
88     // #b6330459# make selection visible
89     if(bMakeSelectionVisible)
90     {
91         pWrtShell->MakeSelVisible();
92         bMakeSelectionVisible = sal_False;
93     }
94     pHRuler->SetActive( sal_True );
95     pVRuler->SetActive( sal_True );
96 
97 	if ( bMDIActivate )
98 	{
99 		pWrtShell->ShGetFcs(sal_False);		// Selektionen sichtbar
100 
101 		if( sSwViewData.Len() )
102 		{
103             ReadUserData( sSwViewData, sal_False );
104 			sSwViewData.Erase();
105         }
106 
107         AttrChangedNotify(pWrtShell);
108 
109 		// Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
110 		sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
111 		SfxViewFrame* pVFrame = GetViewFrame();
112 		SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
113 		if (pWrp)
114 			pWrp->ReInitDlg(GetDocShell());
115 
116 		// RedlineDlg ggf neu initialisieren
117 		nId = SwRedlineAcceptChild::GetChildWindowId();
118 		SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
119 		if (pRed)
120 			pRed->ReInitDlg(GetDocShell());
121 
122 		// reinit IdxMarkDlg
123 		nId = SwInsertIdxMarkWrapper::GetChildWindowId();
124 		SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
125 		if (pIdxMrk)
126 			pIdxMrk->ReInitDlg(*pWrtShell);
127 
128 		// reinit AuthMarkDlg
129 		nId = SwInsertAuthMarkWrapper::GetChildWindowId();
130 		SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
131 																GetChildWindow(nId);
132 		if (pAuthMrk)
133 			pAuthMrk->ReInitDlg(*pWrtShell);
134 	}
135 	else
136 		//Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
137 		AttrChangedNotify(pWrtShell);
138 
139 	SfxViewShell::Activate(bMDIActivate);
140 }
141 
142 /*--------------------------------------------------------------------
143 	Beschreibung:
144  --------------------------------------------------------------------*/
145 
146 
147 void SwView::Deactivate(sal_Bool bMDIActivate)
148 {
149 	extern sal_Bool bFlushCharBuffer ;
150 		// Befinden sich noch Zeichen im Input Buffer?
151 	if( bFlushCharBuffer )
152         GetEditWin().FlushInBuffer();
153 
154 	if( bMDIActivate )
155 	{
156 		pWrtShell->ShLooseFcs();	// Selektionen unsichtbar
157 
158         pHRuler->SetActive( sal_False );
159         pVRuler->SetActive( sal_False );
160 	}
161 	SfxViewShell::Deactivate(bMDIActivate);
162 }
163 
164 /*--------------------------------------------------------------------
165 	Beschreibung:
166  --------------------------------------------------------------------*/
167 
168 void SwView::MarginChanged()
169 {
170 	GetWrtShell().SetBrowseBorder( GetMargin() );
171 }
172 
173 /*--------------------------------------------------------------------
174  --------------------------------------------------------------------*/
175 
176 void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
177 {
178     if(!pFormatClipboard)
179         return;
180 
181     if( pFormatClipboard->HasContent() )
182     {
183         pFormatClipboard->Erase();
184 
185         SwApplyTemplate aTemplate;
186         GetEditWin().SetApplyTemplate(aTemplate);
187     }
188     else
189     {
190         bool bPersistentCopy = false;
191         const SfxItemSet *pArgs = rReq.GetArgs();
192         if( pArgs && pArgs->Count() >= 1 )
193         {
194             bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
195                                     SID_FORMATPAINTBRUSH)).GetValue());
196         }
197 
198         pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
199 
200         SwApplyTemplate aTemplate;
201         aTemplate.pFormatClipboard = pFormatClipboard;
202         GetEditWin().SetApplyTemplate(aTemplate);
203     }
204     GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
205 }
206 
207 void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
208 {
209     if(!pFormatClipboard)
210         return;
211 
212     bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent();
213     rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
214     if(!bHasContent)
215     {
216         if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
217             rSet.DisableItem( SID_FORMATPAINTBRUSH );
218     }
219 }
220