bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / uiview / view1.cxx
blobc736e2614348b10762e0efd888ee1da28c13e208
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/svdpagv.hxx>
22 #include <svx/svdview.hxx>
23 #include <svx/ruler.hxx>
24 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
25 #include <idxmrk.hxx>
26 #include <view.hxx>
27 #include <wrtsh.hxx>
28 #include <swmodule.hxx>
29 #include <viewopt.hxx>
30 #include <docsh.hxx>
31 #include <globdoc.hxx>
32 #include <navipi.hxx>
33 #include <fldwrap.hxx>
34 #include <redlndlg.hxx>
35 #include <dpage.hxx>
36 #include <edtwin.hxx>
37 #include "formatclipboard.hxx"
38 #include <cmdid.h>
39 // header for class SfxRequest
40 #include <sfx2/request.hxx>
42 #include <sfx2/viewfrm.hxx>
44 extern int bDocSzUpdated;
46 void SwView::Activate(sal_Bool bMDIActivate)
48 // fdo#40438 Update the layout to make sure everything is correct before showing the content
49 m_pWrtShell->StartAction();
50 m_pWrtShell->EndAction( sal_True );
52 // aktuelle View anmelden an der DocShell
53 // die View bleibt solange an der DocShell
54 // aktiv bis Sie zerstoert wird oder durch Activate eine
55 // neue gesetzt wird
56 SwDocShell* pDocSh = GetDocShell();
57 if(pDocSh)
58 pDocSh->SetView(this);
59 SwModule* pSwMod = SW_MOD();
60 pSwMod->SetView(this);
62 // Dokumentgroesse hat sich geaendert
63 if(!bDocSzUpdated)
64 DocSzChgd(m_aDocSz);
66 // make selection visible
67 if(m_bMakeSelectionVisible)
69 m_pWrtShell->MakeSelVisible();
70 m_bMakeSelectionVisible = sal_False;
72 m_pHRuler->SetActive( sal_True );
73 m_pVRuler->SetActive( sal_True );
75 if ( bMDIActivate )
77 m_pWrtShell->ShGetFcs(sal_False); // Selektionen sichtbar
79 if( m_sSwViewData.Len() )
81 ReadUserData( m_sSwViewData, sal_False );
82 m_sSwViewData.Erase();
85 AttrChangedNotify(m_pWrtShell);
87 // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR)
88 sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId();
89 SfxViewFrame* pVFrame = GetViewFrame();
90 SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId);
91 if (pWrp)
92 pWrp->ReInitDlg(GetDocShell());
94 // RedlineDlg ggf neu initialisieren
95 nId = SwRedlineAcceptChild::GetChildWindowId();
96 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId);
97 if (pRed)
98 pRed->ReInitDlg(GetDocShell());
100 // reinit IdxMarkDlg
101 nId = SwInsertIdxMarkWrapper::GetChildWindowId();
102 SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId);
103 if (pIdxMrk)
104 pIdxMrk->ReInitDlg(*m_pWrtShell);
106 // reinit AuthMarkDlg
107 nId = SwInsertAuthMarkWrapper::GetChildWindowId();
108 SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame->
109 GetChildWindow(nId);
110 if (pAuthMrk)
111 pAuthMrk->ReInitDlg(*m_pWrtShell);
113 else
114 //Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter
115 AttrChangedNotify(m_pWrtShell);
117 SfxViewShell::Activate(bMDIActivate);
120 void SwView::Deactivate(sal_Bool bMDIActivate)
122 extern bool bFlushCharBuffer ;
123 // Befinden sich noch Zeichen im Input Buffer?
124 if( bFlushCharBuffer )
125 GetEditWin().FlushInBuffer();
127 if( bMDIActivate )
129 m_pWrtShell->ShLooseFcs(); // Selektionen unsichtbar
131 m_pHRuler->SetActive( sal_False );
132 m_pVRuler->SetActive( sal_False );
134 SfxViewShell::Deactivate(bMDIActivate);
137 void SwView::MarginChanged()
139 GetWrtShell().SetBrowseBorder( GetMargin() );
142 void SwView::ExecFormatPaintbrush(SfxRequest& rReq)
144 if(!m_pFormatClipboard)
145 return;
147 if( m_pFormatClipboard->HasContent() )
149 m_pFormatClipboard->Erase();
151 SwApplyTemplate aTemplate;
152 GetEditWin().SetApplyTemplate(aTemplate);
154 else
156 bool bPersistentCopy = false;
157 const SfxItemSet *pArgs = rReq.GetArgs();
158 if( pArgs && pArgs->Count() >= 1 )
160 bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
161 SID_FORMATPAINTBRUSH)).GetValue());
164 m_pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy );
166 SwApplyTemplate aTemplate;
167 aTemplate.m_pFormatClipboard = m_pFormatClipboard;
168 GetEditWin().SetApplyTemplate(aTemplate);
170 GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
173 void SwView::StateFormatPaintbrush(SfxItemSet &rSet)
175 if(!m_pFormatClipboard)
176 return;
178 bool bHasContent = m_pFormatClipboard && m_pFormatClipboard->HasContent();
179 rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent));
180 if(!bHasContent)
182 if( !m_pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) )
183 rSet.DisableItem( SID_FORMATPAINTBRUSH );
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */