1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view1.cxx,v $
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>
43 #include <swmodule.hxx>
44 #include <viewopt.hxx>
49 #include <globdoc.hxx>
52 #include <fldwrap.hxx>
54 #include <redlndlg.hxx>
58 #include "formatclipboard.hxx"
62 // header for class SfxRequest
63 #include <sfx2/request.hxx>
65 #include <sfx2/viewfrm.hxx>
67 extern int bDocSzUpdated
;
70 /*--------------------------------------------------------------------
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
81 SwDocShell
* pDocSh
= GetDocShell();
83 pDocSh
->SetView(this);
84 SwModule
* pSwMod
= SW_MOD();
85 pSwMod
->SetView(this);
87 // Dokumentgroesse hat sich geaendert
91 // #b6330459# make selection visible
92 if(bMakeSelectionVisible
)
94 pWrtShell
->MakeSelVisible();
95 bMakeSelectionVisible
= sal_False
;
97 pHRuler
->SetActive( TRUE
);
98 pVRuler
->SetActive( TRUE
);
102 pWrtShell
->ShGetFcs(FALSE
); // Selektionen sichtbar
104 if( sSwViewData
.Len() )
106 ReadUserData( sSwViewData
, FALSE
);
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
);
117 pWrp
->ReInitDlg(GetDocShell());
119 // RedlineDlg ggf neu initialisieren
120 nId
= SwRedlineAcceptChild::GetChildWindowId();
121 SwRedlineAcceptChild
*pRed
= (SwRedlineAcceptChild
*)pVFrame
->GetChildWindow(nId
);
123 pRed
->ReInitDlg(GetDocShell());
126 nId
= SwInsertIdxMarkWrapper::GetChildWindowId();
127 SwInsertIdxMarkWrapper
*pIdxMrk
= (SwInsertIdxMarkWrapper
*)pVFrame
->GetChildWindow(nId
);
129 pIdxMrk
->ReInitDlg(*pWrtShell
);
131 // reinit AuthMarkDlg
132 nId
= SwInsertAuthMarkWrapper::GetChildWindowId();
133 SwInsertAuthMarkWrapper
*pAuthMrk
= (SwInsertAuthMarkWrapper
*)pVFrame
->
136 pAuthMrk
->ReInitDlg(*pWrtShell
);
139 //Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
140 AttrChangedNotify(pWrtShell
);
142 SfxViewShell::Activate(bMDIActivate
);
145 /*--------------------------------------------------------------------
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();
159 pWrtShell
->ShLooseFcs(); // Selektionen unsichtbar
161 pHRuler
->SetActive( FALSE
);
162 pVRuler
->SetActive( FALSE
);
164 SfxViewShell::Deactivate(bMDIActivate
);
167 /*--------------------------------------------------------------------
169 --------------------------------------------------------------------*/
171 void SwView::MarginChanged()
173 GetWrtShell().SetBrowseBorder( GetMargin() );
176 /*--------------------------------------------------------------------
177 --------------------------------------------------------------------*/
179 void SwView::ExecFormatPaintbrush(SfxRequest
& rReq
)
181 if(!pFormatClipboard
)
184 if( pFormatClipboard
->HasContent() )
186 pFormatClipboard
->Erase();
188 SwApplyTemplate aTemplate
;
189 GetEditWin().SetApplyTemplate(aTemplate
);
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
)
215 bool bHasContent
= pFormatClipboard
&& pFormatClipboard
->HasContent();
216 rSet
.Put(SfxBoolItem(SID_FORMATPAINTBRUSH
, bHasContent
));
219 if( !pFormatClipboard
->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
220 rSet
.DisableItem( SID_FORMATPAINTBRUSH
);