xref: /aoo4110/main/sw/source/ui/uiview/view1.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <svx/svdpagv.hxx>
29 #include <svx/svdview.hxx>
30 #include <svx/ruler.hxx>
31 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
32 #include <idxmrk.hxx>
33 #ifndef _VIEW_HXX
34 #include <view.hxx>
35 #endif
36 #include <wrtsh.hxx>
37 #include <swmodule.hxx>
38 #include <viewopt.hxx>
39 #ifndef _DOCSH_HXX
40 #include <docsh.hxx>
41 #endif
42 #ifndef _GLOBDOC_HXX
43 #include <globdoc.hxx>
44 #endif
45 #include <navipi.hxx>
46 #include <fldwrap.hxx>
47 #ifndef _REDLNDLG_HXX
48 #include <redlndlg.hxx>
49 #endif
50 #include <dpage.hxx>
51 #include <edtwin.hxx>
52 #include "formatclipboard.hxx"
53 #ifndef _CMDID_H
54 #include <cmdid.h>
55 #endif
56 // header for class SfxRequest
57 #include <sfx2/request.hxx>
58 
59 #include <sfx2/viewfrm.hxx>
60 
61 extern int bDocSzUpdated;
62 
63 
64 /*--------------------------------------------------------------------
65 	Beschreibung:
66  --------------------------------------------------------------------*/
67 
68 
Activate(sal_Bool bMDIActivate)69 void SwView::Activate(sal_Bool bMDIActivate)
70 {
71 	// aktuelle View anmelden an der DocShell
72 	// die View bleibt solange an der DocShell
73 	// aktiv bis Sie zerstoert wird oder durch Activate eine
74 	// neue gesetzt wird
75 	SwDocShell* pDocSh = GetDocShell();
76 	if(pDocSh)
77 		pDocSh->SetView(this);
78 	SwModule* pSwMod = SW_MOD();
79 	pSwMod->SetView(this);
80 
81 	// Dokumentgroesse hat sich geaendert
82 	if(!bDocSzUpdated)
83 		DocSzChgd(aDocSz);
84 
85     // #b6330459# make selection visible
86     if(bMakeSelectionVisible)
87     {
88         pWrtShell->MakeSelVisible();
89         bMakeSelectionVisible = sal_False;
90     }
91     pHRuler->SetActive( sal_True );
92     pVRuler->SetActive( sal_True );
93 
94 	if ( bMDIActivate )
95 	{
96 		pWrtShell->ShGetFcs(sal_False);		// Selektionen sichtbar
97 
98 		if( sSwViewData.Len() )
99 		{
100             ReadUserData( sSwViewData, sal_False );
101 			sSwViewData.Erase();
102         }
103 
104         AttrChangedNotify(pWrtShell);
105 
106 		// Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
107 		sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
108 		SfxViewFrame* pVFrame = GetViewFrame();
109 		SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
110 		if (pWrp)
111 			pWrp->ReInitDlg(GetDocShell());
112 
113 		// RedlineDlg ggf neu initialisieren
114 		nId = SwRedlineAcceptChild::GetChildWindowId();
115 		SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
116 		if (pRed)
117 			pRed->ReInitDlg(GetDocShell());
118 
119 		// reinit IdxMarkDlg
120 		nId = SwInsertIdxMarkWrapper::GetChildWindowId();
121 		SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
122 		if (pIdxMrk)
123 			pIdxMrk->ReInitDlg(*pWrtShell);
124 
125 		// reinit AuthMarkDlg
126 		nId = SwInsertAuthMarkWrapper::GetChildWindowId();
127 		SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
128 																GetChildWindow(nId);
129 		if (pAuthMrk)
130 			pAuthMrk->ReInitDlg(*pWrtShell);
131 	}
132 	else
133 		//Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
134 		AttrChangedNotify(pWrtShell);
135 
136 	SfxViewShell::Activate(bMDIActivate);
137 }
138 
139 /*--------------------------------------------------------------------
140 	Beschreibung:
141  --------------------------------------------------------------------*/
142 
143 
Deactivate(sal_Bool bMDIActivate)144 void SwView::Deactivate(sal_Bool bMDIActivate)
145 {
146 	extern sal_Bool bFlushCharBuffer ;
147 		// Befinden sich noch Zeichen im Input Buffer?
148 	if( bFlushCharBuffer )
149         GetEditWin().FlushInBuffer();
150 
151 	if( bMDIActivate )
152 	{
153 		pWrtShell->ShLooseFcs();	// Selektionen unsichtbar
154 
155         pHRuler->SetActive( sal_False );
156         pVRuler->SetActive( sal_False );
157 	}
158 	SfxViewShell::Deactivate(bMDIActivate);
159 }
160 
161 /*--------------------------------------------------------------------
162 	Beschreibung:
163  --------------------------------------------------------------------*/
164 
MarginChanged()165 void SwView::MarginChanged()
166 {
167 	GetWrtShell().SetBrowseBorder( GetMargin() );
168 }
169 
170 /*--------------------------------------------------------------------
171  --------------------------------------------------------------------*/
172 
ExecFormatPaintbrush(SfxRequest & rReq)173 void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
174 {
175     if(!pFormatClipboard)
176         return;
177 
178     if( pFormatClipboard->HasContent() )
179     {
180         pFormatClipboard->Erase();
181 
182         SwApplyTemplate aTemplate;
183         GetEditWin().SetApplyTemplate(aTemplate);
184     }
185     else
186     {
187         bool bPersistentCopy = false;
188         const SfxItemSet *pArgs = rReq.GetArgs();
189         if( pArgs && pArgs->Count() >= 1 )
190         {
191             bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
192                                     SID_FORMATPAINTBRUSH)).GetValue());
193         }
194 
195         pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
196 
197         SwApplyTemplate aTemplate;
198         aTemplate.pFormatClipboard = pFormatClipboard;
199         GetEditWin().SetApplyTemplate(aTemplate);
200     }
201     GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
202 }
203 
StateFormatPaintbrush(SfxItemSet & rSet)204 void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
205 {
206     if(!pFormatClipboard)
207         return;
208 
209     bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent();
210     rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
211     if(!bHasContent)
212     {
213         if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
214             rSet.DisableItem( SID_FORMATPAINTBRUSH );
215     }
216 }
217