xref: /trunk/main/sw/source/ui/uiview/view1.cxx (revision f120fe41)
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
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
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.
19efeef26fSAndrew Rist  *
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 #include <svx/svdpagv.hxx>
29cdf0e10cSrcweir #include <svx/svdview.hxx>
30cdf0e10cSrcweir #include <svx/ruler.hxx>
31*95a18594SAndre Fischer #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
32cdf0e10cSrcweir #include <idxmrk.hxx>
33cdf0e10cSrcweir #ifndef _VIEW_HXX
34cdf0e10cSrcweir #include <view.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include <wrtsh.hxx>
37cdf0e10cSrcweir #include <swmodule.hxx>
38cdf0e10cSrcweir #include <viewopt.hxx>
39cdf0e10cSrcweir #ifndef _DOCSH_HXX
40cdf0e10cSrcweir #include <docsh.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _GLOBDOC_HXX
43cdf0e10cSrcweir #include <globdoc.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #include <navipi.hxx>
46cdf0e10cSrcweir #include <fldwrap.hxx>
47cdf0e10cSrcweir #ifndef _REDLNDLG_HXX
48cdf0e10cSrcweir #include <redlndlg.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #include <dpage.hxx>
51cdf0e10cSrcweir #include <edtwin.hxx>
52cdf0e10cSrcweir #include "formatclipboard.hxx"
53cdf0e10cSrcweir #ifndef _CMDID_H
54cdf0e10cSrcweir #include <cmdid.h>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir // header for class SfxRequest
57cdf0e10cSrcweir #include <sfx2/request.hxx>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir extern int bDocSzUpdated;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /*--------------------------------------------------------------------
65cdf0e10cSrcweir 	Beschreibung:
66cdf0e10cSrcweir  --------------------------------------------------------------------*/
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
Activate(sal_Bool bMDIActivate)69cdf0e10cSrcweir void SwView::Activate(sal_Bool bMDIActivate)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	// aktuelle View anmelden an der DocShell
72cdf0e10cSrcweir 	// die View bleibt solange an der DocShell
73cdf0e10cSrcweir 	// aktiv bis Sie zerstoert wird oder durch Activate eine
74cdf0e10cSrcweir 	// neue gesetzt wird
75cdf0e10cSrcweir 	SwDocShell* pDocSh = GetDocShell();
76cdf0e10cSrcweir 	if(pDocSh)
77cdf0e10cSrcweir 		pDocSh->SetView(this);
78cdf0e10cSrcweir 	SwModule* pSwMod = SW_MOD();
79cdf0e10cSrcweir 	pSwMod->SetView(this);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	// Dokumentgroesse hat sich geaendert
82cdf0e10cSrcweir 	if(!bDocSzUpdated)
83cdf0e10cSrcweir 		DocSzChgd(aDocSz);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     // #b6330459# make selection visible
86cdf0e10cSrcweir     if(bMakeSelectionVisible)
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         pWrtShell->MakeSelVisible();
89cdf0e10cSrcweir         bMakeSelectionVisible = sal_False;
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir     pHRuler->SetActive( sal_True );
92cdf0e10cSrcweir     pVRuler->SetActive( sal_True );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	if ( bMDIActivate )
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		pWrtShell->ShGetFcs(sal_False);		// Selektionen sichtbar
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 		if( sSwViewData.Len() )
99cdf0e10cSrcweir 		{
100cdf0e10cSrcweir             ReadUserData( sSwViewData, sal_False );
101cdf0e10cSrcweir 			sSwViewData.Erase();
102cdf0e10cSrcweir         }
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         AttrChangedNotify(pWrtShell);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 		// Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
107cdf0e10cSrcweir 		sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
108cdf0e10cSrcweir 		SfxViewFrame* pVFrame = GetViewFrame();
109cdf0e10cSrcweir 		SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
110cdf0e10cSrcweir 		if (pWrp)
111cdf0e10cSrcweir 			pWrp->ReInitDlg(GetDocShell());
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		// RedlineDlg ggf neu initialisieren
114cdf0e10cSrcweir 		nId = SwRedlineAcceptChild::GetChildWindowId();
115cdf0e10cSrcweir 		SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
116cdf0e10cSrcweir 		if (pRed)
117cdf0e10cSrcweir 			pRed->ReInitDlg(GetDocShell());
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 		// reinit IdxMarkDlg
120cdf0e10cSrcweir 		nId = SwInsertIdxMarkWrapper::GetChildWindowId();
121cdf0e10cSrcweir 		SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
122cdf0e10cSrcweir 		if (pIdxMrk)
123cdf0e10cSrcweir 			pIdxMrk->ReInitDlg(*pWrtShell);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 		// reinit AuthMarkDlg
126cdf0e10cSrcweir 		nId = SwInsertAuthMarkWrapper::GetChildWindowId();
127cdf0e10cSrcweir 		SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
128cdf0e10cSrcweir 																GetChildWindow(nId);
129cdf0e10cSrcweir 		if (pAuthMrk)
130cdf0e10cSrcweir 			pAuthMrk->ReInitDlg(*pWrtShell);
131cdf0e10cSrcweir 	}
132cdf0e10cSrcweir 	else
133cdf0e10cSrcweir 		//Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
134cdf0e10cSrcweir 		AttrChangedNotify(pWrtShell);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	SfxViewShell::Activate(bMDIActivate);
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir /*--------------------------------------------------------------------
140cdf0e10cSrcweir 	Beschreibung:
141cdf0e10cSrcweir  --------------------------------------------------------------------*/
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 
Deactivate(sal_Bool bMDIActivate)144cdf0e10cSrcweir void SwView::Deactivate(sal_Bool bMDIActivate)
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	extern sal_Bool bFlushCharBuffer ;
147cdf0e10cSrcweir 		// Befinden sich noch Zeichen im Input Buffer?
148cdf0e10cSrcweir 	if( bFlushCharBuffer )
149cdf0e10cSrcweir         GetEditWin().FlushInBuffer();
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	if( bMDIActivate )
152cdf0e10cSrcweir 	{
153cdf0e10cSrcweir 		pWrtShell->ShLooseFcs();	// Selektionen unsichtbar
154cdf0e10cSrcweir 
155cdf0e10cSrcweir         pHRuler->SetActive( sal_False );
156cdf0e10cSrcweir         pVRuler->SetActive( sal_False );
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir 	SfxViewShell::Deactivate(bMDIActivate);
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir /*--------------------------------------------------------------------
162cdf0e10cSrcweir 	Beschreibung:
163cdf0e10cSrcweir  --------------------------------------------------------------------*/
164cdf0e10cSrcweir 
MarginChanged()165cdf0e10cSrcweir void SwView::MarginChanged()
166cdf0e10cSrcweir {
167cdf0e10cSrcweir 	GetWrtShell().SetBrowseBorder( GetMargin() );
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir /*--------------------------------------------------------------------
171cdf0e10cSrcweir  --------------------------------------------------------------------*/
172cdf0e10cSrcweir 
ExecFormatPaintbrush(SfxRequest & rReq)173cdf0e10cSrcweir void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
174cdf0e10cSrcweir {
175cdf0e10cSrcweir     if(!pFormatClipboard)
176cdf0e10cSrcweir         return;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     if( pFormatClipboard->HasContent() )
179cdf0e10cSrcweir     {
180cdf0e10cSrcweir         pFormatClipboard->Erase();
181cdf0e10cSrcweir 
182cdf0e10cSrcweir         SwApplyTemplate aTemplate;
183cdf0e10cSrcweir         GetEditWin().SetApplyTemplate(aTemplate);
184cdf0e10cSrcweir     }
185cdf0e10cSrcweir     else
186cdf0e10cSrcweir     {
187cdf0e10cSrcweir         bool bPersistentCopy = false;
188cdf0e10cSrcweir         const SfxItemSet *pArgs = rReq.GetArgs();
189cdf0e10cSrcweir         if( pArgs && pArgs->Count() >= 1 )
190cdf0e10cSrcweir         {
191cdf0e10cSrcweir             bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
192cdf0e10cSrcweir                                     SID_FORMATPAINTBRUSH)).GetValue());
193cdf0e10cSrcweir         }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir         pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
196cdf0e10cSrcweir 
197cdf0e10cSrcweir         SwApplyTemplate aTemplate;
198cdf0e10cSrcweir         aTemplate.pFormatClipboard = pFormatClipboard;
199cdf0e10cSrcweir         GetEditWin().SetApplyTemplate(aTemplate);
200cdf0e10cSrcweir     }
201cdf0e10cSrcweir     GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
StateFormatPaintbrush(SfxItemSet & rSet)204cdf0e10cSrcweir void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     if(!pFormatClipboard)
207cdf0e10cSrcweir         return;
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent();
210cdf0e10cSrcweir     rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
211cdf0e10cSrcweir     if(!bHasContent)
212cdf0e10cSrcweir     {
213cdf0e10cSrcweir         if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
214cdf0e10cSrcweir             rSet.DisableItem( SID_FORMATPAINTBRUSH );
215cdf0e10cSrcweir     }
216cdf0e10cSrcweir }
217