1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 28 #include <svx/svdpagv.hxx> 29 #include <svx/svdview.hxx> 30 #include <svx/ruler.hxx> 31 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx> 32 #include <idxmrk.hxx> 33 #ifndef _VIEW_HXX 34 #include <view.hxx> 35 #endif 36 #include <wrtsh.hxx> 37 #include <swmodule.hxx> 38 #include <viewopt.hxx> 39 #ifndef _DOCSH_HXX 40 #include <docsh.hxx> 41 #endif 42 #ifndef _GLOBDOC_HXX 43 #include <globdoc.hxx> 44 #endif 45 #include <navipi.hxx> 46 #include <fldwrap.hxx> 47 #ifndef _REDLNDLG_HXX 48 #include <redlndlg.hxx> 49 #endif 50 #include <dpage.hxx> 51 #include <edtwin.hxx> 52 #include "formatclipboard.hxx" 53 #ifndef _CMDID_H 54 #include <cmdid.h> 55 #endif 56 // header for class SfxRequest 57 #include <sfx2/request.hxx> 58 59 #include <sfx2/viewfrm.hxx> 60 61 extern int bDocSzUpdated; 62 63 64 /*-------------------------------------------------------------------- 65 Beschreibung: 66 --------------------------------------------------------------------*/ 67 68 69 void SwView::Activate(sal_Bool bMDIActivate) 70 { 71 // aktuelle View anmelden an der DocShell 72 // die View bleibt solange an der DocShell 73 // aktiv bis Sie zerstoert wird oder durch Activate eine 74 // neue gesetzt wird 75 SwDocShell* pDocSh = GetDocShell(); 76 if(pDocSh) 77 pDocSh->SetView(this); 78 SwModule* pSwMod = SW_MOD(); 79 pSwMod->SetView(this); 80 81 // Dokumentgroesse hat sich geaendert 82 if(!bDocSzUpdated) 83 DocSzChgd(aDocSz); 84 85 // #b6330459# make selection visible 86 if(bMakeSelectionVisible) 87 { 88 pWrtShell->MakeSelVisible(); 89 bMakeSelectionVisible = sal_False; 90 } 91 pHRuler->SetActive( sal_True ); 92 pVRuler->SetActive( sal_True ); 93 94 if ( bMDIActivate ) 95 { 96 pWrtShell->ShGetFcs(sal_False); // Selektionen sichtbar 97 98 if( sSwViewData.Len() ) 99 { 100 ReadUserData( sSwViewData, sal_False ); 101 sSwViewData.Erase(); 102 } 103 104 AttrChangedNotify(pWrtShell); 105 106 // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR) 107 sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId(); 108 SfxViewFrame* pVFrame = GetViewFrame(); 109 SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId); 110 if (pWrp) 111 pWrp->ReInitDlg(GetDocShell()); 112 113 // RedlineDlg ggf neu initialisieren 114 nId = SwRedlineAcceptChild::GetChildWindowId(); 115 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId); 116 if (pRed) 117 pRed->ReInitDlg(GetDocShell()); 118 119 // reinit IdxMarkDlg 120 nId = SwInsertIdxMarkWrapper::GetChildWindowId(); 121 SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId); 122 if (pIdxMrk) 123 pIdxMrk->ReInitDlg(*pWrtShell); 124 125 // reinit AuthMarkDlg 126 nId = SwInsertAuthMarkWrapper::GetChildWindowId(); 127 SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame-> 128 GetChildWindow(nId); 129 if (pAuthMrk) 130 pAuthMrk->ReInitDlg(*pWrtShell); 131 } 132 else 133 //Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter 134 AttrChangedNotify(pWrtShell); 135 136 SfxViewShell::Activate(bMDIActivate); 137 138 ContextChangeEventMultiplexer::NotifyContextChange( 139 GetController(), 140 ::sfx2::sidebar::EnumContext::Context_Default); 141 } 142 143 /*-------------------------------------------------------------------- 144 Beschreibung: 145 --------------------------------------------------------------------*/ 146 147 148 void SwView::Deactivate(sal_Bool bMDIActivate) 149 { 150 extern sal_Bool bFlushCharBuffer ; 151 // Befinden sich noch Zeichen im Input Buffer? 152 if( bFlushCharBuffer ) 153 GetEditWin().FlushInBuffer(); 154 155 if( bMDIActivate ) 156 { 157 pWrtShell->ShLooseFcs(); // Selektionen unsichtbar 158 159 pHRuler->SetActive( sal_False ); 160 pVRuler->SetActive( sal_False ); 161 } 162 SfxViewShell::Deactivate(bMDIActivate); 163 } 164 165 /*-------------------------------------------------------------------- 166 Beschreibung: 167 --------------------------------------------------------------------*/ 168 169 void SwView::MarginChanged() 170 { 171 GetWrtShell().SetBrowseBorder( GetMargin() ); 172 } 173 174 /*-------------------------------------------------------------------- 175 --------------------------------------------------------------------*/ 176 177 void SwView::ExecFormatPaintbrush(SfxRequest& rReq) 178 { 179 if(!pFormatClipboard) 180 return; 181 182 if( pFormatClipboard->HasContent() ) 183 { 184 pFormatClipboard->Erase(); 185 186 SwApplyTemplate aTemplate; 187 GetEditWin().SetApplyTemplate(aTemplate); 188 } 189 else 190 { 191 bool bPersistentCopy = false; 192 const SfxItemSet *pArgs = rReq.GetArgs(); 193 if( pArgs && pArgs->Count() >= 1 ) 194 { 195 bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get( 196 SID_FORMATPAINTBRUSH)).GetValue()); 197 } 198 199 pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy ); 200 201 SwApplyTemplate aTemplate; 202 aTemplate.pFormatClipboard = pFormatClipboard; 203 GetEditWin().SetApplyTemplate(aTemplate); 204 } 205 GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH); 206 } 207 208 void SwView::StateFormatPaintbrush(SfxItemSet &rSet) 209 { 210 if(!pFormatClipboard) 211 return; 212 213 bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent(); 214 rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent)); 215 if(!bHasContent) 216 { 217 if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) ) 218 rSet.DisableItem( SID_FORMATPAINTBRUSH ); 219 } 220 } 221