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