Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <svx/svdpagv.hxx>
22 : #include <svx/svdview.hxx>
23 : #include <svx/ruler.hxx>
24 : #include <idxmrk.hxx>
25 : #include <view.hxx>
26 : #include <wrtsh.hxx>
27 : #include <swmodule.hxx>
28 : #include <viewopt.hxx>
29 : #include <docsh.hxx>
30 : #include <globdoc.hxx>
31 : #include <navipi.hxx>
32 : #include <fldwrap.hxx>
33 : #include <redlndlg.hxx>
34 : #include <dpage.hxx>
35 : #include <edtwin.hxx>
36 : #include "formatclipboard.hxx"
37 : #include <cmdid.h>
38 : // header for class SfxRequest
39 : #include <sfx2/request.hxx>
40 :
41 : #include <sfx2/viewfrm.hxx>
42 :
43 : extern int bDocSzUpdated;
44 :
45 478 : void SwView::Activate(sal_Bool bMDIActivate)
46 : {
47 : // fdo#40438 Update the layout to make sure everything is correct before showing the content
48 478 : pWrtShell->StartAction();
49 478 : pWrtShell->EndAction( sal_True );
50 :
51 : // aktuelle View anmelden an der DocShell
52 : // die View bleibt solange an der DocShell
53 : // aktiv bis Sie zerstoert wird oder durch Activate eine
54 : // neue gesetzt wird
55 478 : SwDocShell* pDocSh = GetDocShell();
56 478 : if(pDocSh)
57 478 : pDocSh->SetView(this);
58 478 : SwModule* pSwMod = SW_MOD();
59 478 : pSwMod->SetView(this);
60 :
61 : // Dokumentgroesse hat sich geaendert
62 478 : if(!bDocSzUpdated)
63 478 : DocSzChgd(aDocSz);
64 :
65 : // make selection visible
66 478 : if(bMakeSelectionVisible)
67 : {
68 0 : pWrtShell->MakeSelVisible();
69 0 : bMakeSelectionVisible = sal_False;
70 : }
71 478 : pHRuler->SetActive( sal_True );
72 478 : pVRuler->SetActive( sal_True );
73 :
74 478 : if ( bMDIActivate )
75 : {
76 478 : pWrtShell->ShGetFcs(sal_False); // Selektionen sichtbar
77 :
78 478 : if( sSwViewData.Len() )
79 : {
80 0 : ReadUserData( sSwViewData, sal_False );
81 0 : sSwViewData.Erase();
82 : }
83 :
84 478 : AttrChangedNotify(pWrtShell);
85 :
86 : // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
87 478 : sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
88 478 : SfxViewFrame* pVFrame = GetViewFrame();
89 478 : SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
90 478 : if (pWrp)
91 0 : pWrp->ReInitDlg(GetDocShell());
92 :
93 : // RedlineDlg ggf neu initialisieren
94 478 : nId = SwRedlineAcceptChild::GetChildWindowId();
95 478 : SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
96 478 : if (pRed)
97 0 : pRed->ReInitDlg(GetDocShell());
98 :
99 : // reinit IdxMarkDlg
100 478 : nId = SwInsertIdxMarkWrapper::GetChildWindowId();
101 478 : SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
102 478 : if (pIdxMrk)
103 0 : pIdxMrk->ReInitDlg(*pWrtShell);
104 :
105 : // reinit AuthMarkDlg
106 478 : nId = SwInsertAuthMarkWrapper::GetChildWindowId();
107 : SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
108 478 : GetChildWindow(nId);
109 478 : if (pAuthMrk)
110 0 : pAuthMrk->ReInitDlg(*pWrtShell);
111 : }
112 : else
113 : //Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
114 0 : AttrChangedNotify(pWrtShell);
115 :
116 478 : SfxViewShell::Activate(bMDIActivate);
117 478 : }
118 :
119 478 : void SwView::Deactivate(sal_Bool bMDIActivate)
120 : {
121 : extern sal_Bool bFlushCharBuffer ;
122 : // Befinden sich noch Zeichen im Input Buffer?
123 478 : if( bFlushCharBuffer )
124 0 : GetEditWin().FlushInBuffer();
125 :
126 478 : if( bMDIActivate )
127 : {
128 478 : pWrtShell->ShLooseFcs(); // Selektionen unsichtbar
129 :
130 478 : pHRuler->SetActive( sal_False );
131 478 : pVRuler->SetActive( sal_False );
132 : }
133 478 : SfxViewShell::Deactivate(bMDIActivate);
134 478 : }
135 :
136 0 : void SwView::MarginChanged()
137 : {
138 0 : GetWrtShell().SetBrowseBorder( GetMargin() );
139 0 : }
140 :
141 0 : void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
142 : {
143 0 : if(!pFormatClipboard)
144 0 : return;
145 :
146 0 : if( pFormatClipboard->HasContent() )
147 : {
148 0 : pFormatClipboard->Erase();
149 :
150 0 : SwApplyTemplate aTemplate;
151 0 : GetEditWin().SetApplyTemplate(aTemplate);
152 : }
153 : else
154 : {
155 0 : bool bPersistentCopy = false;
156 0 : const SfxItemSet *pArgs = rReq.GetArgs();
157 0 : if( pArgs && pArgs->Count() >= 1 )
158 : {
159 : bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
160 0 : SID_FORMATPAINTBRUSH)).GetValue());
161 : }
162 :
163 0 : pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
164 :
165 0 : SwApplyTemplate aTemplate;
166 0 : aTemplate.pFormatClipboard = pFormatClipboard;
167 0 : GetEditWin().SetApplyTemplate(aTemplate);
168 : }
169 0 : GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
170 : }
171 :
172 5 : void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
173 : {
174 5 : if(!pFormatClipboard)
175 5 : return;
176 :
177 5 : bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent();
178 5 : rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
179 5 : if(!bHasContent)
180 : {
181 5 : if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
182 0 : rSet.DisableItem( SID_FORMATPAINTBRUSH );
183 : }
184 72 : }
185 :
186 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|