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 : #include <svx/svdpagv.hxx>
21 : #include <svx/svdview.hxx>
22 : #include <svx/ruler.hxx>
23 : #include <svx/sidebar/ContextChangeEventMultiplexer.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 : #include <sfx2/request.hxx>
39 : #include <sfx2/viewfrm.hxx>
40 : #include <wordcountdialog.hxx>
41 :
42 : extern bool bDocSzUpdated;
43 :
44 2673 : void SwView::Activate(bool bMDIActivate)
45 : {
46 : // fdo#40438 Update the layout to make sure everything is correct before showing the content
47 2673 : m_pWrtShell->StartAction();
48 2673 : m_pWrtShell->EndAction( true );
49 :
50 : // Register the current View at the DocShell.
51 : // The view remains active at the DocShell until it will
52 : // be destroyed or by Activate a new one will be set.
53 2673 : SwDocShell* pDocSh = GetDocShell();
54 2673 : if(pDocSh)
55 2673 : pDocSh->SetView(this);
56 2673 : SwModule* pSwMod = SW_MOD();
57 2673 : pSwMod->SetView(this);
58 :
59 : // Document size has changed.
60 2673 : if(!bDocSzUpdated)
61 2673 : DocSzChgd(m_aDocSz);
62 :
63 : // make selection visible
64 2673 : if(m_bMakeSelectionVisible)
65 : {
66 0 : m_pWrtShell->MakeSelVisible();
67 0 : m_bMakeSelectionVisible = false;
68 : }
69 2673 : m_pHRuler->SetActive( true );
70 2673 : m_pVRuler->SetActive( true );
71 :
72 2673 : if ( bMDIActivate )
73 : {
74 2673 : m_pWrtShell->ShGetFcs(false); // Selections visible
75 :
76 2673 : if( !m_sSwViewData.isEmpty() )
77 : {
78 0 : ReadUserData(m_sSwViewData, false);
79 0 : m_sSwViewData.clear();
80 : }
81 :
82 2673 : AttrChangedNotify(m_pWrtShell);
83 :
84 : // Initialize Fielddlg newly if necessary (e.g. for TYP_SETVAR)
85 2673 : sal_uInt16 nId = SwFieldDlgWrapper::GetChildWindowId();
86 2673 : SfxViewFrame* pVFrame = GetViewFrame();
87 2673 : SwFieldDlgWrapper *pWrp = static_cast<SwFieldDlgWrapper*>(pVFrame->GetChildWindow(nId));
88 2673 : if (pWrp)
89 0 : pWrp->ReInitDlg(GetDocShell());
90 :
91 : // Initialize RedlineDlg newly if necessary
92 2673 : nId = SwRedlineAcceptChild::GetChildWindowId();
93 2673 : SwRedlineAcceptChild *pRed = static_cast<SwRedlineAcceptChild*>(pVFrame->GetChildWindow(nId));
94 2673 : if (pRed)
95 0 : pRed->ReInitDlg(GetDocShell());
96 :
97 : // reinit IdxMarkDlg
98 2673 : nId = SwInsertIdxMarkWrapper::GetChildWindowId();
99 2673 : SwInsertIdxMarkWrapper *pIdxMrk = static_cast<SwInsertIdxMarkWrapper*>(pVFrame->GetChildWindow(nId));
100 2673 : if (pIdxMrk)
101 0 : pIdxMrk->ReInitDlg(*m_pWrtShell);
102 :
103 : // reinit AuthMarkDlg
104 2673 : nId = SwInsertAuthMarkWrapper::GetChildWindowId();
105 : SwInsertAuthMarkWrapper *pAuthMrk = static_cast<SwInsertAuthMarkWrapper*>(pVFrame->
106 2673 : GetChildWindow(nId));
107 2673 : if (pAuthMrk)
108 0 : pAuthMrk->ReInitDlg(*m_pWrtShell);
109 : }
110 : else
111 : // At least call the Notify (as a precaution because of the SlotFilter).
112 0 : AttrChangedNotify(m_pWrtShell);
113 :
114 2673 : SfxViewShell::Activate(bMDIActivate);
115 2673 : }
116 :
117 2672 : void SwView::Deactivate(bool bMDIActivate)
118 : {
119 : extern bool g_bFlushCharBuffer ;
120 : // Are Characters still in the input buffer?
121 2672 : if( g_bFlushCharBuffer )
122 0 : GetEditWin().FlushInBuffer();
123 :
124 2672 : if( bMDIActivate )
125 : {
126 2672 : m_pWrtShell->ShLooseFcs(); // Selections invisible
127 :
128 2672 : m_pHRuler->SetActive( false );
129 2672 : m_pVRuler->SetActive( false );
130 : }
131 2672 : SfxViewShell::Deactivate(bMDIActivate);
132 2672 : }
133 :
134 0 : void SwView::MarginChanged()
135 : {
136 0 : GetWrtShell().SetBrowseBorder( GetMargin() );
137 0 : }
138 :
139 0 : void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
140 : {
141 0 : if(!m_pFormatClipboard)
142 0 : return;
143 :
144 0 : if( m_pFormatClipboard->HasContent() )
145 : {
146 0 : m_pFormatClipboard->Erase();
147 :
148 0 : SwApplyTemplate aTemplate;
149 0 : GetEditWin().SetApplyTemplate(aTemplate);
150 : }
151 : else
152 : {
153 0 : bool bPersistentCopy = false;
154 0 : const SfxItemSet *pArgs = rReq.GetArgs();
155 0 : if( pArgs && pArgs->Count() >= 1 )
156 : {
157 : bPersistentCopy = static_cast<bool>(static_cast<const SfxBoolItem &>(pArgs->Get(
158 0 : SID_FORMATPAINTBRUSH)).GetValue());
159 : }
160 :
161 0 : m_pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
162 :
163 0 : SwApplyTemplate aTemplate;
164 0 : aTemplate.m_pFormatClipboard = m_pFormatClipboard;
165 0 : GetEditWin().SetApplyTemplate(aTemplate);
166 : }
167 0 : GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
168 : }
169 :
170 849 : void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
171 : {
172 849 : if(!m_pFormatClipboard)
173 849 : return;
174 :
175 849 : bool bHasContent = m_pFormatClipboard && m_pFormatClipboard->HasContent();
176 849 : rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
177 849 : if(!bHasContent)
178 : {
179 849 : if( !SwFormatClipboard::CanCopyThisType( GetWrtShell().GetSelectionType() ) )
180 0 : rSet.DisableItem( SID_FORMATPAINTBRUSH );
181 : }
182 : }
183 :
184 0 : void SwView::UpdateWordCount(SfxShell* pShell, sal_uInt16 nSlot)
185 : {
186 0 : SfxViewFrame* pVFrame = GetViewFrame();
187 0 : if (pVFrame != NULL)
188 : {
189 0 : pVFrame->ToggleChildWindow(FN_WORDCOUNT_DIALOG);
190 0 : pShell->Invalidate(nSlot);
191 :
192 0 : SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(pVFrame->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
193 0 : if (pWrdCnt)
194 0 : pWrdCnt->UpdateCounts();
195 : }
196 177 : }
197 :
198 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|