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 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_sw.hxx" 24 25 #include <svx/svdmodel.hxx> 26 #include <svx/svdpage.hxx> 27 #include <tools/shl.hxx> 28 #include <swmodule.hxx> 29 #include <svtools/accessibilityoptions.hxx> 30 #include <svx/svdpagv.hxx> 31 #include <fmtanchr.hxx> 32 #include <frmfmt.hxx> 33 #include <svx/svdoutl.hxx> 34 #ifdef DBG_UTIL 35 #include <svx/fmglob.hxx> 36 #endif 37 #include "fesh.hxx" 38 #include "pagefrm.hxx" 39 #include "rootfrm.hxx" 40 #include "viewimp.hxx" 41 #include "dflyobj.hxx" 42 #include "viewopt.hxx" 43 #include "printdata.hxx" 44 #include "dcontact.hxx" 45 #include "dview.hxx" 46 #include "flyfrm.hxx" 47 #include <vcl/svapp.hxx> 48 #include <IDocumentDrawModelAccess.hxx> 49 #include <drawdoc.hxx> 50 51 /************************************************************************* 52 |* 53 |* SwSaveHdl 54 |* 55 |* Ersterstellung MA 14. Feb. 95 56 |* Letzte Aenderung MA 02. Jun. 98 57 |* 58 |*************************************************************************/ 59 //SwSaveHdl::SwSaveHdl( SwViewImp *pI ) : 60 // pImp( pI ), 61 // bXorVis( sal_False ) 62 //{ 63 //if ( pImp->HasDrawView() ) 64 //{ 65 // bXorVis = pImp->GetDrawView()->IsShownXorVisible( pImp->GetShell()->GetOut()); 66 // if ( bXorVis ) 67 // pImp->GetDrawView()->HideShownXor( pImp->GetShell()->GetOut() ); 68 //} 69 //} 70 71 72 //SwSaveHdl::~SwSaveHdl() 73 //{ 74 //if ( bXorVis ) 75 // pImp->GetDrawView()->ShowShownXor( pImp->GetShell()->GetOut() ); 76 //} 77 78 79 /************************************************************************* 80 |* 81 |* SwViewImp::StartAction(), EndAction() 82 |* 83 |* Ersterstellung MA 14. Feb. 95 84 |* Letzte Aenderung MA 14. Sep. 98 85 |* 86 |*************************************************************************/ 87 88 89 void SwViewImp::StartAction() 90 { 91 if ( HasDrawView() ) 92 { 93 SET_CURR_SHELL( GetShell() ); 94 if ( pSh->ISA(SwFEShell) ) 95 ((SwFEShell*)pSh)->HideChainMarker(); //Kann sich geaendert haben 96 //bResetXorVisibility = GetDrawView()->IsShownXorVisible( GetShell()->GetOut()); 97 //GetDrawView()->HideShownXor( GetShell()->GetOut() ); 98 } 99 } 100 101 102 103 void SwViewImp::EndAction() 104 { 105 if ( HasDrawView() ) 106 { 107 SET_CURR_SHELL( GetShell() ); 108 //if ( bResetXorVisibility ) 109 // GetDrawView()->ShowShownXor( GetShell()->GetOut() ); 110 if ( pSh->ISA(SwFEShell) ) 111 ((SwFEShell*)pSh)->SetChainMarker(); //Kann sich geaendert haben 112 } 113 } 114 115 /************************************************************************* 116 |* 117 |* SwViewImp::LockPaint(), UnlockPaint() 118 |* 119 |* Ersterstellung MA 11. Jun. 96 120 |* Letzte Aenderung MA 11. Jun. 96 121 |* 122 |*************************************************************************/ 123 124 125 void SwViewImp::LockPaint() 126 { 127 if ( HasDrawView() ) 128 { 129 //HMHbShowHdlPaint = GetDrawView()->IsMarkHdlShown(); 130 //HMHif ( bShowHdlPaint ) 131 //HMH GetDrawView()->HideMarkHdl(); 132 bResetHdlHiddenPaint = !GetDrawView()->areMarkHandlesHidden(); 133 GetDrawView()->hideMarkHandles(); 134 } 135 else 136 { 137 //HMHbShowHdlPaint = sal_False; 138 bResetHdlHiddenPaint = sal_False; 139 } 140 } 141 142 143 144 void SwViewImp::UnlockPaint() 145 { 146 if ( bResetHdlHiddenPaint ) 147 GetDrawView()->showMarkHandles(); 148 //HMHif ( bShowHdlPaint ) 149 //HMH GetDrawView()->ShowMarkHdl(); 150 } 151 152 153 /************************************************************************* 154 |* 155 |* SwViewImp::PaintLayer(), PaintDispatcher() 156 |* 157 |* Ersterstellung MA 20. Dec. 94 158 |* Letzte Aenderung AMA 04. Jun. 98 159 |* 160 |*************************************************************************/ 161 // OD 29.08.2002 #102450# 162 // add 3rd parameter <const Color* pPageBackgrdColor> for setting this 163 // color as the background color at the outliner of the draw view. 164 // OD 09.12.2002 #103045# - add 4th parameter for the horizontal text direction 165 // of the page in order to set the default horizontal text direction at the 166 // outliner of the draw view for painting layers <hell> and <heaven>. 167 // OD 25.06.2003 #108784# - correct type of 1st parameter 168 void SwViewImp::PaintLayer( const SdrLayerID _nLayerID, 169 SwPrintData const*const pPrintData, 170 const SwRect& , 171 const Color* _pPageBackgrdColor, 172 const bool _bIsPageRightToLeft, 173 sdr::contact::ViewObjectContactRedirector* pRedirector ) const 174 { 175 if ( HasDrawView() ) 176 { 177 //change the draw mode in high contrast mode 178 OutputDevice* pOutDev = GetShell()->GetOut(); 179 sal_uLong nOldDrawMode = pOutDev->GetDrawMode(); 180 if( GetShell()->GetWin() && 181 Application::GetSettings().GetStyleSettings().GetHighContrastMode() && 182 (!GetShell()->IsPreView()||SW_MOD()->GetAccessibilityOptions().GetIsForPagePreviews())) 183 { 184 pOutDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | 185 DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT ); 186 } 187 188 // OD 29.08.2002 #102450# 189 // For correct handling of accessibility, high contrast, the page background 190 // color is set as the background color at the outliner of the draw view. 191 // Only necessary for the layers hell and heaven 192 Color aOldOutlinerBackgrdColor; 193 // OD 09.12.2002 #103045# - set default horizontal text direction on 194 // painting <hell> or <heaven>. 195 EEHorizontalTextDirection aOldEEHoriTextDir = EE_HTEXTDIR_L2R; 196 const IDocumentDrawModelAccess* pIDDMA = GetShell()->getIDocumentDrawModelAccess(); 197 if ( (_nLayerID == pIDDMA->GetHellId()) || 198 (_nLayerID == pIDDMA->GetHeavenId()) ) 199 { 200 ASSERT( _pPageBackgrdColor, 201 "incorrect usage of SwViewImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>"); 202 if ( _pPageBackgrdColor ) 203 { 204 aOldOutlinerBackgrdColor = 205 GetDrawView()->GetModel()->GetDrawOutliner().GetBackgroundColor(); 206 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( *_pPageBackgrdColor ); 207 } 208 209 aOldEEHoriTextDir = 210 GetDrawView()->GetModel()->GetDrawOutliner().GetDefaultHorizontalTextDirection(); 211 EEHorizontalTextDirection aEEHoriTextDirOfPage = 212 _bIsPageRightToLeft ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R; 213 GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aEEHoriTextDirOfPage ); 214 } 215 216 pOutDev->Push( PUSH_LINECOLOR ); // #114231# 217 if (pPrintData) 218 { 219 // hide drawings but not form controls (form controls are handled elsewhere) 220 SdrView &rSdrView = const_cast< SdrView & >(GetPageView()->GetView()); 221 rSdrView.setHideDraw( !pPrintData->IsPrintDraw() ); 222 } 223 GetPageView()->DrawLayer( _nLayerID, pOutDev, pRedirector ); 224 pOutDev->Pop(); 225 226 // OD 29.08.2002 #102450# 227 // reset background color of the outliner 228 // OD 09.12.2002 #103045# - reset default horizontal text direction 229 if ( (_nLayerID == pIDDMA->GetHellId()) || 230 (_nLayerID == pIDDMA->GetHeavenId()) ) 231 { 232 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( aOldOutlinerBackgrdColor ); 233 GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aOldEEHoriTextDir ); 234 } 235 236 pOutDev->SetDrawMode( nOldDrawMode ); 237 } 238 } 239 240 /************************************************************************* 241 |* 242 |* SwViewImp::IsDragPossible() 243 |* 244 |* Ersterstellung MA 19. Jan. 93 245 |* Letzte Aenderung MA 16. Jan. 95 246 |* 247 |*************************************************************************/ 248 #define WIEDUWILLST 400 249 250 sal_Bool SwViewImp::IsDragPossible( const Point &rPoint ) 251 { 252 if ( !HasDrawView() ) 253 return sal_False; 254 255 const SdrMarkList &rMrkList = GetDrawView()->GetMarkedObjectList(); 256 257 if( !rMrkList.GetMarkCount() ) 258 return sal_False; 259 260 SdrObject *pO = rMrkList.GetMark(rMrkList.GetMarkCount()-1)->GetMarkedSdrObj(); 261 262 SwRect aRect; 263 if( pO && ::CalcClipRect( pO, aRect, sal_False ) ) 264 { 265 SwRect aTmp; 266 ::CalcClipRect( pO, aTmp, sal_True ); 267 aRect.Union( aTmp ); 268 } 269 else 270 aRect = GetShell()->GetLayout()->Frm(); 271 272 aRect.Top( aRect.Top() - WIEDUWILLST ); 273 aRect.Bottom( aRect.Bottom() + WIEDUWILLST ); 274 aRect.Left( aRect.Left() - WIEDUWILLST ); 275 aRect.Right( aRect.Right() + WIEDUWILLST ); 276 return aRect.IsInside( rPoint ); 277 } 278 279 /************************************************************************* 280 |* 281 |* SwViewImp::NotifySizeChg() 282 |* 283 |* Ersterstellung MA 23. Jun. 93 284 |* Letzte Aenderung MA 05. Oct. 98 285 |* 286 |*************************************************************************/ 287 288 void SwViewImp::NotifySizeChg( const Size &rNewSz ) 289 { 290 if ( !HasDrawView() ) 291 return; 292 293 if ( GetPageView() ) 294 GetPageView()->GetPage()->SetSize( rNewSz ); 295 296 //Begrenzung des Arbeitsbereiches. 297 const Rectangle aRect( Point( DOCUMENTBORDER, DOCUMENTBORDER ), rNewSz ); 298 const Rectangle &rOldWork = GetDrawView()->GetWorkArea(); 299 sal_Bool bCheckDrawObjs = sal_False; 300 if ( aRect != rOldWork ) 301 { 302 if ( rOldWork.Bottom() > aRect.Bottom() || rOldWork.Right() > aRect.Right()) 303 bCheckDrawObjs = sal_True; 304 GetDrawView()->SetWorkArea( aRect ); 305 } 306 if ( !bCheckDrawObjs ) 307 return; 308 309 ASSERT( pSh->getIDocumentDrawModelAccess()->GetDrawModel(), "NotifySizeChg without DrawModel" ); 310 SdrPage* pPage = pSh->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 ); 311 const sal_uLong nObjs = pPage->GetObjCount(); 312 for( sal_uLong nObj = 0; nObj < nObjs; ++nObj ) 313 { 314 SdrObject *pObj = pPage->GetObj( nObj ); 315 if( !pObj->ISA(SwVirtFlyDrawObj) ) 316 { 317 //Teilfix(26793): Objekte, die in Rahmen verankert sind, brauchen 318 //nicht angepasst werden. 319 const SwContact *pCont = (SwContact*)GetUserCall(pObj); 320 //JP - 16.3.00 Bug 73920: this function might be called by the 321 // InsertDocument, when a PageDesc-Attribute is 322 // set on a node. Then the SdrObject must not have 323 // an UserCall. 324 if( !pCont || !pCont->ISA(SwDrawContact) ) 325 continue; 326 327 const SwFrm *pAnchor = ((SwDrawContact*)pCont)->GetAnchorFrm(); 328 if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->IsValid() || 329 !pAnchor->GetUpper() || !pAnchor->FindPageFrm() || 330 (FLY_AS_CHAR == pCont->GetFmt()->GetAnchor().GetAnchorId()) ) 331 { 332 continue; 333 } 334 335 // OD 19.06.2003 #108784# - no move for drawing objects in header/footer 336 if ( pAnchor->FindFooterOrHeader() ) 337 { 338 continue; 339 } 340 341 const Rectangle aBound( pObj->GetCurrentBoundRect() ); 342 if ( !aRect.IsInside( aBound ) ) 343 { 344 Size aSz; 345 if ( aBound.Left() > aRect.Right() ) 346 aSz.Width() = (aRect.Right() - aBound.Left()) - MINFLY; 347 if ( aBound.Top() > aRect.Bottom() ) 348 aSz.Height() = (aRect.Bottom() - aBound.Top()) - MINFLY; 349 if ( aSz.Width() || aSz.Height() ) 350 pObj->Move( aSz ); 351 352 //Notanker: Grosse Objekte nicht nach oben verschwinden lassen. 353 aSz.Width() = aSz.Height() = 0; 354 if ( aBound.Bottom() < aRect.Top() ) 355 aSz.Width() = (aBound.Bottom() - aRect.Top()) - MINFLY; 356 if ( aBound.Right() < aRect.Left() ) 357 aSz.Height() = (aBound.Right() - aRect.Left()) - MINFLY; 358 if ( aSz.Width() || aSz.Height() ) 359 pObj->Move( aSz ); 360 } 361 } 362 } 363 } 364 365 366 367