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 <idxmrk.hxx> 32 #ifndef _VIEW_HXX 33 #include <view.hxx> 34 #endif 35 #include <wrtsh.hxx> 36 #include <swmodule.hxx> 37 #include <viewopt.hxx> 38 #ifndef _DOCSH_HXX 39 #include <docsh.hxx> 40 #endif 41 #ifndef _GLOBDOC_HXX 42 #include <globdoc.hxx> 43 #endif 44 #include <navipi.hxx> 45 #include <fldwrap.hxx> 46 #ifndef _REDLNDLG_HXX 47 #include <redlndlg.hxx> 48 #endif 49 #include <dpage.hxx> 50 #include <edtwin.hxx> 51 #include "formatclipboard.hxx" 52 #ifndef _CMDID_H 53 #include <cmdid.h> 54 #endif 55 // header for class SfxRequest 56 #include <sfx2/request.hxx> 57 58 #include <sfx2/viewfrm.hxx> 59 60 extern int bDocSzUpdated; 61 62 63 /*-------------------------------------------------------------------- 64 Beschreibung: 65 --------------------------------------------------------------------*/ 66 67 68 void SwView::Activate(sal_Bool bMDIActivate) 69 { 70 // aktuelle View anmelden an der DocShell 71 // die View bleibt solange an der DocShell 72 // aktiv bis Sie zerstoert wird oder durch Activate eine 73 // neue gesetzt wird 74 SwDocShell* pDocSh = GetDocShell(); 75 if(pDocSh) 76 pDocSh->SetView(this); 77 SwModule* pSwMod = SW_MOD(); 78 pSwMod->SetView(this); 79 80 // Dokumentgroesse hat sich geaendert 81 if(!bDocSzUpdated) 82 DocSzChgd(aDocSz); 83 84 // #b6330459# make selection visible 85 if(bMakeSelectionVisible) 86 { 87 pWrtShell->MakeSelVisible(); 88 bMakeSelectionVisible = sal_False; 89 } 90 pHRuler->SetActive( sal_True ); 91 pVRuler->SetActive( sal_True ); 92 93 if ( bMDIActivate ) 94 { 95 pWrtShell->ShGetFcs(sal_False); // Selektionen sichtbar 96 97 if( sSwViewData.Len() ) 98 { 99 ReadUserData( sSwViewData, sal_False ); 100 sSwViewData.Erase(); 101 } 102 103 AttrChangedNotify(pWrtShell); 104 105 // Flddlg ggf neu initialisieren (z.B. fuer TYP_SETVAR) 106 sal_uInt16 nId = SwFldDlgWrapper::GetChildWindowId(); 107 SfxViewFrame* pVFrame = GetViewFrame(); 108 SwFldDlgWrapper *pWrp = (SwFldDlgWrapper*)pVFrame->GetChildWindow(nId); 109 if (pWrp) 110 pWrp->ReInitDlg(GetDocShell()); 111 112 // RedlineDlg ggf neu initialisieren 113 nId = SwRedlineAcceptChild::GetChildWindowId(); 114 SwRedlineAcceptChild *pRed = (SwRedlineAcceptChild*)pVFrame->GetChildWindow(nId); 115 if (pRed) 116 pRed->ReInitDlg(GetDocShell()); 117 118 // reinit IdxMarkDlg 119 nId = SwInsertIdxMarkWrapper::GetChildWindowId(); 120 SwInsertIdxMarkWrapper *pIdxMrk = (SwInsertIdxMarkWrapper*)pVFrame->GetChildWindow(nId); 121 if (pIdxMrk) 122 pIdxMrk->ReInitDlg(*pWrtShell); 123 124 // reinit AuthMarkDlg 125 nId = SwInsertAuthMarkWrapper::GetChildWindowId(); 126 SwInsertAuthMarkWrapper *pAuthMrk = (SwInsertAuthMarkWrapper*)pVFrame-> 127 GetChildWindow(nId); 128 if (pAuthMrk) 129 pAuthMrk->ReInitDlg(*pWrtShell); 130 } 131 else 132 //Wenigstens das Notify rufen (vorsichtshalber wegen der SlotFilter 133 AttrChangedNotify(pWrtShell); 134 135 SfxViewShell::Activate(bMDIActivate); 136 } 137 138 /*-------------------------------------------------------------------- 139 Beschreibung: 140 --------------------------------------------------------------------*/ 141 142 143 void SwView::Deactivate(sal_Bool bMDIActivate) 144 { 145 extern sal_Bool bFlushCharBuffer ; 146 // Befinden sich noch Zeichen im Input Buffer? 147 if( bFlushCharBuffer ) 148 GetEditWin().FlushInBuffer(); 149 150 if( bMDIActivate ) 151 { 152 pWrtShell->ShLooseFcs(); // Selektionen unsichtbar 153 154 pHRuler->SetActive( sal_False ); 155 pVRuler->SetActive( sal_False ); 156 } 157 SfxViewShell::Deactivate(bMDIActivate); 158 } 159 160 /*-------------------------------------------------------------------- 161 Beschreibung: 162 --------------------------------------------------------------------*/ 163 164 void SwView::MarginChanged() 165 { 166 GetWrtShell().SetBrowseBorder( GetMargin() ); 167 } 168 169 /*-------------------------------------------------------------------- 170 --------------------------------------------------------------------*/ 171 172 void SwView::ExecFormatPaintbrush(SfxRequest& rReq) 173 { 174 if(!pFormatClipboard) 175 return; 176 177 if( pFormatClipboard->HasContent() ) 178 { 179 pFormatClipboard->Erase(); 180 181 SwApplyTemplate aTemplate; 182 GetEditWin().SetApplyTemplate(aTemplate); 183 } 184 else 185 { 186 bool bPersistentCopy = false; 187 const SfxItemSet *pArgs = rReq.GetArgs(); 188 if( pArgs && pArgs->Count() >= 1 ) 189 { 190 bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get( 191 SID_FORMATPAINTBRUSH)).GetValue()); 192 } 193 194 pFormatClipboard->Copy( GetWrtShell(), GetPool(), bPersistentCopy ); 195 196 SwApplyTemplate aTemplate; 197 aTemplate.pFormatClipboard = pFormatClipboard; 198 GetEditWin().SetApplyTemplate(aTemplate); 199 } 200 GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH); 201 } 202 203 void SwView::StateFormatPaintbrush(SfxItemSet &rSet) 204 { 205 if(!pFormatClipboard) 206 return; 207 208 bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent(); 209 rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH, bHasContent)); 210 if(!bHasContent) 211 { 212 if( !pFormatClipboard->CanCopyThisType( GetWrtShell().GetSelectionType() ) ) 213 rSet.DisableItem( SID_FORMATPAINTBRUSH ); 214 } 215 } 216