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