update dev300-m58
[ooovba.git] / sw / source / ui / uiview / view1.cxx
bloba26e519f724be1f5912034663ca25776334c7a52
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view1.cxx,v $
10 * $Revision: 1.15 $
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"
35 #include <svx/svdpagv.hxx>
36 #include <svx/svdview.hxx>
37 #include <svx/ruler.hxx>
38 #include <idxmrk.hxx>
39 #ifndef _VIEW_HXX
40 #include <view.hxx>
41 #endif
42 #include <wrtsh.hxx>
43 #include <swmodule.hxx>
44 #include <viewopt.hxx>
45 #ifndef _DOCSH_HXX
46 #include <docsh.hxx>
47 #endif
48 #ifndef _GLOBDOC_HXX
49 #include <globdoc.hxx>
50 #endif
51 #include <navipi.hxx>
52 #include <fldwrap.hxx>
53 #ifndef _REDLNDLG_HXX
54 #include <redlndlg.hxx>
55 #endif
56 #include <dpage.hxx>
57 #include <edtwin.hxx>
58 #include "formatclipboard.hxx"
59 #ifndef _CMDID_H
60 #include <cmdid.h>
61 #endif
62 // header for class SfxRequest
63 #include <sfx2/request.hxx>
65 #include <sfx2/viewfrm.hxx>
67 extern int bDocSzUpdated;
70 /*--------------------------------------------------------------------
71 Beschreibung:
72 --------------------------------------------------------------------*/
75 void SwView::Activate(BOOL bMDIActivate)
77 // aktuelle View anmelden an der DocShell
78 // die View bleibt solange an der DocShell
79 // aktiv bis Sie zerstoert wird oder durch Activate eine
80 // neue gesetzt wird
81 SwDocShell* pDocSh = GetDocShell();
82 if(pDocSh)
83 pDocSh->SetView(this);
84 SwModule* pSwMod = SW_MOD();
85 pSwMod->SetView(this);
87 // Dokumentgroesse hat sich geaendert
88 if(!bDocSzUpdated)
89 DocSzChgd(aDocSz);
91 // #b6330459# make selection visible
92 if(bMakeSelectionVisible)
94 pWrtShell->MakeSelVisible();
95 bMakeSelectionVisible = sal_False;
97 pHRuler->SetActive( TRUE );
98 pVRuler->SetActive( TRUE );
100 if ( bMDIActivate )
102 pWrtShell->ShGetFcs(FALSE); // Selektionen sichtbar
104 if( sSwViewData.Len() )
106 ReadUserData( sSwViewData, FALSE );
107 sSwViewData.Erase();
110 AttrChangedNotify(pWrtShell);
112 // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
113 USHORT nId = SwFldDlgWrapper::GetChildWindowId();
114 SfxViewFrame* pVFrame = GetViewFrame();
115 SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
116 if (pWrp)
117 pWrp->ReInitDlg(GetDocShell());
119 // RedlineDlg ggf neu initialisieren
120 nId = SwRedlineAcceptChild::GetChildWindowId();
121 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
122 if (pRed)
123 pRed->ReInitDlg(GetDocShell());
125 // reinit IdxMarkDlg
126 nId = SwInsertIdxMarkWrapper::GetChildWindowId();
127 SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
128 if (pIdxMrk)
129 pIdxMrk->ReInitDlg(*pWrtShell);
131 // reinit AuthMarkDlg
132 nId = SwInsertAuthMarkWrapper::GetChildWindowId();
133 SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
134 GetChildWindow(nId);
135 if (pAuthMrk)
136 pAuthMrk->ReInitDlg(*pWrtShell);
138 else
139 //Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
140 AttrChangedNotify(pWrtShell);
142 SfxViewShell::Activate(bMDIActivate);
145 /*--------------------------------------------------------------------
146 Beschreibung:
147 --------------------------------------------------------------------*/
150 void SwView::Deactivate(BOOL bMDIActivate)
152 extern BOOL bFlushCharBuffer ;
153 // Befinden sich noch Zeichen im Input Buffer?
154 if( bFlushCharBuffer )
155 GetEditWin().FlushInBuffer();
157 if( bMDIActivate )
159 pWrtShell->ShLooseFcs(); // Selektionen unsichtbar
161 pHRuler->SetActive( FALSE );
162 pVRuler->SetActive( FALSE );
164 SfxViewShell::Deactivate(bMDIActivate);
167 /*--------------------------------------------------------------------
168 Beschreibung:
169 --------------------------------------------------------------------*/
171 void SwView::MarginChanged()
173 GetWrtShell().SetBrowseBorder( GetMargin() );
176 /*--------------------------------------------------------------------
177 --------------------------------------------------------------------*/
179 void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
181 if(!pFormatClipboard)
182 return;
184 if( pFormatClipboard->HasContent() )
186 pFormatClipboard->Erase();
188 SwApplyTemplate aTemplate;
189 GetEditWin().SetApplyTemplate(aTemplate);
191 else
193 bool bPersistentCopy = false;
194 const SfxItemSet *pArgs = rReq.GetArgs();
195 if( pArgs && pArgs->Count() >= 1 )
197 bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
198 SID_FORMATPAINTBRUSH)).GetValue());
201 pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
203 SwApplyTemplate aTemplate;
204 aTemplate.pFormatClipboard = pFormatClipboard;
205 GetEditWin().SetApplyTemplate(aTemplate);
207 GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
210 void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
212 if(!pFormatClipboard)
213 return;
215 bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent();
216 rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
217 if(!bHasContent)
219 if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
220 rSet.DisableItem( SID_FORMATPAINTBRUSH );