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_svx.hxx" 26 #include <svx/sdr/contact/viewcontactofsdrpage.hxx> 27 #include <svx/sdr/contact/viewobjectcontact.hxx> 28 #include <svx/svdpage.hxx> 29 #include <svx/sdr/contact/displayinfo.hxx> 30 #include <svx/sdr/contact/viewobjectcontactofsdrpage.hxx> 31 #include <basegfx/polygon/b2dpolygontools.hxx> 32 #include <basegfx/matrix/b2dhommatrix.hxx> 33 #include <svx/svdpagv.hxx> 34 #include <svx/svdview.hxx> 35 #include <vcl/svapp.hxx> 36 #include <svx/sdr/contact/objectcontact.hxx> 37 #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx> 38 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> 39 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 40 #include <basegfx/polygon/b2dpolygon.hxx> 41 #include <svx/sdr/primitive2d/sdrattributecreator.hxx> 42 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> 43 #include <vcl/lazydelete.hxx> 44 #include <svx/svdstr.hrc> 45 #include <svx/svdglob.hxx> 46 #include <drawinglayer/primitive2d/discreteshadowprimitive2d.hxx> 47 #include <drawinglayer/attribute/sdrfillattribute.hxx> 48 49 ////////////////////////////////////////////////////////////////////////////// 50 51 #define PAPER_SHADOW(SIZE) (SIZE >> 8) 52 53 ////////////////////////////////////////////////////////////////////////////// 54 55 namespace sdr 56 { 57 namespace contact 58 { ViewContactOfPageSubObject(ViewContactOfSdrPage & rParentViewContactOfSdrPage)59 ViewContactOfPageSubObject::ViewContactOfPageSubObject(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 60 : mrParentViewContactOfSdrPage(rParentViewContactOfSdrPage) 61 { 62 } 63 ~ViewContactOfPageSubObject()64 ViewContactOfPageSubObject::~ViewContactOfPageSubObject() 65 { 66 } 67 GetParentContact() const68 ViewContact* ViewContactOfPageSubObject::GetParentContact() const 69 { 70 return &mrParentViewContactOfSdrPage; 71 } 72 getPage() const73 const SdrPage& ViewContactOfPageSubObject::getPage() const 74 { 75 return mrParentViewContactOfSdrPage.GetSdrPage(); 76 } 77 } // end of namespace contact 78 } // end of namespace sdr 79 80 ////////////////////////////////////////////////////////////////////////////// 81 82 namespace sdr 83 { 84 namespace contact 85 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)86 ViewObjectContact& ViewContactOfPageBackground::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 87 { 88 ViewObjectContact* pRetval = new ViewObjectContactOfPageBackground(rObjectContact, *this); 89 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 90 91 return *pRetval; 92 } 93 createViewIndependentPrimitive2DSequence() const94 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageBackground::createViewIndependentPrimitive2DSequence() const 95 { 96 // We have only the page information, not the view information. Use the 97 // svtools::DOCCOLOR color for initialization 98 const svtools::ColorConfig aColorConfig; 99 const Color aInitColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor); 100 const basegfx::BColor aRGBColor(aInitColor.getBColor()); 101 const drawinglayer::primitive2d::Primitive2DReference xReference( 102 new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor)); 103 104 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 105 } 106 ViewContactOfPageBackground(ViewContactOfSdrPage & rParentViewContactOfSdrPage)107 ViewContactOfPageBackground::ViewContactOfPageBackground(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 108 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage) 109 { 110 } 111 ~ViewContactOfPageBackground()112 ViewContactOfPageBackground::~ViewContactOfPageBackground() 113 { 114 } 115 } // end of namespace contact 116 } // end of namespace sdr 117 118 ////////////////////////////////////////////////////////////////////////////// 119 120 namespace sdr 121 { 122 namespace contact 123 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)124 ViewObjectContact& ViewContactOfPageShadow::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 125 { 126 ViewObjectContact* pRetval = new ViewObjectContactOfPageShadow(rObjectContact, *this); 127 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 128 129 return *pRetval; 130 } 131 createViewIndependentPrimitive2DSequence() const132 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageShadow::createViewIndependentPrimitive2DSequence() const 133 { 134 static bool bUseOldPageShadow(true); 135 const SdrPage& rPage = getPage(); 136 basegfx::B2DHomMatrix aPageMatrix; 137 aPageMatrix.set(0, 0, (double)rPage.GetWdt()); 138 aPageMatrix.set(1, 1, (double)rPage.GetHgt()); 139 140 if(bUseOldPageShadow) 141 { 142 // create page shadow polygon 143 // const double fPageBorderFactor(1.0 / 256.0); 144 basegfx::B2DPolygon aPageShadowPolygon; 145 // aPageShadowPolygon.append(basegfx::B2DPoint(1.0, fPageBorderFactor)); 146 // aPageShadowPolygon.append(basegfx::B2DPoint(1.0 + fPageBorderFactor, fPageBorderFactor)); 147 // aPageShadowPolygon.append(basegfx::B2DPoint(1.0 + fPageBorderFactor, 1.0 + fPageBorderFactor)); 148 // aPageShadowPolygon.append(basegfx::B2DPoint(fPageBorderFactor, 1.0 + fPageBorderFactor)); 149 // aPageShadowPolygon.append(basegfx::B2DPoint(fPageBorderFactor, 1.0)); 150 // aPageShadowPolygon.append(basegfx::B2DPoint(1.0, 1.0)); 151 // aPageShadowPolygon.setClosed(true); 152 // aPageShadowPolygon.transform(aPageMatrix); 153 154 // We have only the page information, not the view information. Use the 155 // svtools::FONTCOLOR color for initialization 156 const svtools::ColorConfig aColorConfig; 157 const Color aShadowColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); 158 const basegfx::BColor aRGBShadowColor(aShadowColor.getBColor()); 159 const drawinglayer::primitive2d::Primitive2DReference xReference( 160 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( 161 basegfx::B2DPolyPolygon(aPageShadowPolygon), 162 aRGBShadowColor)); 163 164 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 165 } 166 else 167 { 168 static vcl::DeleteOnDeinit< drawinglayer::primitive2d::DiscreteShadow > aDiscreteShadow( 169 new drawinglayer::primitive2d::DiscreteShadow( 170 BitmapEx( 171 ResId( 172 SIP_SA_PAGESHADOW35X35, 173 *ImpGetResMgr())))); 174 175 if(aDiscreteShadow.get()) 176 { 177 const drawinglayer::primitive2d::Primitive2DReference xReference( 178 new drawinglayer::primitive2d::DiscreteShadowPrimitive2D( 179 aPageMatrix, 180 *aDiscreteShadow.get())); 181 182 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 183 } 184 185 return drawinglayer::primitive2d::Primitive2DSequence(); 186 } 187 } 188 ViewContactOfPageShadow(ViewContactOfSdrPage & rParentViewContactOfSdrPage)189 ViewContactOfPageShadow::ViewContactOfPageShadow(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 190 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage) 191 { 192 } 193 ~ViewContactOfPageShadow()194 ViewContactOfPageShadow::~ViewContactOfPageShadow() 195 { 196 } 197 } // end of namespace contact 198 } // end of namespace sdr 199 200 ////////////////////////////////////////////////////////////////////////////// 201 202 namespace sdr 203 { 204 namespace contact 205 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)206 ViewObjectContact& ViewContactOfMasterPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 207 { 208 ViewObjectContact* pRetval = new ViewObjectContactOfMasterPage(rObjectContact, *this); 209 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 210 211 return *pRetval; 212 } 213 createViewIndependentPrimitive2DSequence() const214 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPage::createViewIndependentPrimitive2DSequence() const 215 { 216 drawinglayer::primitive2d::Primitive2DSequence xRetval; 217 218 // this class is used when the page is a MasterPage and is responsible to 219 // create a visualization for the MPBGO, if exists. This needs to be suppressed 220 // when a SdrPage which uses a MasterPage creates its output. Suppression 221 // is done in the corresponding VOC since DisplayInfo data is needed 222 const SdrPage& rPage = getPage(); 223 224 if(rPage.IsMasterPage()) 225 { 226 if(0 == rPage.GetPageNum()) 227 { 228 // #i98063# 229 // filter MasterPage 0 since it's the HandoutPage. Thus, it's a 230 // MasterPage, but has no MPBGO, so there is nothing to do here. 231 } 232 else 233 { 234 drawinglayer::attribute::SdrFillAttribute aFill; 235 236 // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets, 237 // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all 238 // MasterPages should have a StyleSheet excactly for this reason, but historically 239 // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others). 240 if(rPage.getSdrPageProperties().GetStyleSheet()) 241 { 242 // create page fill attributes with correct properties 243 aFill = drawinglayer::primitive2d::createNewSdrFillAttribute( 244 rPage.getSdrPageProperties().GetItemSet()); 245 } 246 247 if(!aFill.isDefault()) 248 { 249 // direct model data is the page size, get and use it 250 const basegfx::B2DRange aInnerRange( 251 rPage.GetLftBorder(), rPage.GetUppBorder(), 252 rPage.GetWdt() - rPage.GetRgtBorder(), rPage.GetHgt() - rPage.GetLwrBorder()); 253 const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange)); 254 const drawinglayer::primitive2d::Primitive2DReference xReference( 255 drawinglayer::primitive2d::createPolyPolygonFillPrimitive( 256 basegfx::B2DPolyPolygon(aInnerPolgon), 257 aFill, 258 drawinglayer::attribute::FillGradientAttribute())); 259 260 xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 261 } 262 } 263 } 264 265 return xRetval; 266 } 267 ViewContactOfMasterPage(ViewContactOfSdrPage & rParentViewContactOfSdrPage)268 ViewContactOfMasterPage::ViewContactOfMasterPage(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 269 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage) 270 { 271 } 272 ~ViewContactOfMasterPage()273 ViewContactOfMasterPage::~ViewContactOfMasterPage() 274 { 275 } 276 } // end of namespace contact 277 } // end of namespace sdr 278 279 ////////////////////////////////////////////////////////////////////////////// 280 281 namespace sdr 282 { 283 namespace contact 284 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)285 ViewObjectContact& ViewContactOfPageFill::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 286 { 287 ViewObjectContact* pRetval = new ViewObjectContactOfPageFill(rObjectContact, *this); 288 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 289 290 return *pRetval; 291 } 292 createViewIndependentPrimitive2DSequence() const293 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageFill::createViewIndependentPrimitive2DSequence() const 294 { 295 const SdrPage& rPage = getPage(); 296 const basegfx::B2DRange aPageFillRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt()); 297 const basegfx::B2DPolygon aPageFillPolygon(basegfx::tools::createPolygonFromRect(aPageFillRange)); 298 299 // We have only the page information, not the view information. Use the 300 // svtools::DOCCOLOR color for initialization 301 const svtools::ColorConfig aColorConfig; 302 const Color aPageFillColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor); 303 304 // create and add primitive 305 const basegfx::BColor aRGBColor(aPageFillColor.getBColor()); 306 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon), aRGBColor)); 307 308 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 309 } 310 ViewContactOfPageFill(ViewContactOfSdrPage & rParentViewContactOfSdrPage)311 ViewContactOfPageFill::ViewContactOfPageFill(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 312 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage) 313 { 314 } 315 ~ViewContactOfPageFill()316 ViewContactOfPageFill::~ViewContactOfPageFill() 317 { 318 } 319 } // end of namespace contact 320 } // end of namespace sdr 321 322 ////////////////////////////////////////////////////////////////////////////// 323 324 namespace sdr 325 { 326 namespace contact 327 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)328 ViewObjectContact& ViewContactOfOuterPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 329 { 330 ViewObjectContact* pRetval = new ViewObjectContactOfOuterPageBorder(rObjectContact, *this); 331 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 332 333 return *pRetval; 334 } 335 createViewIndependentPrimitive2DSequence() const336 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfOuterPageBorder::createViewIndependentPrimitive2DSequence() const 337 { 338 drawinglayer::primitive2d::Primitive2DSequence xRetval; 339 const SdrPage& rPage = getPage(); 340 const basegfx::B2DRange aPageBorderRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt()); 341 342 // Changed to 0x000000 as in Writer, before svtools::FONTCOLOR was used. 343 // Added old case as fallback for HighContrast. 344 basegfx::BColor aRGBBorderColor(0x00 / (double)0xff, 0x00 / (double)0xff, 0x00 / (double)0xff); 345 346 if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 347 { 348 const svtools::ColorConfig aColorConfig; 349 const Color aBorderColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); 350 351 aRGBBorderColor = aBorderColor.getBColor(); 352 } 353 354 if(rPage.getPageBorderOnlyLeftRight()) 355 { 356 // #i93597# for Report Designer, the page border shall be only displayed right and left, 357 // but not top and bottom. Create simplified geometry. 358 basegfx::B2DPolygon aLeft, aRight; 359 360 aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMinY())); 361 aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMaxY())); 362 363 aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMinY())); 364 aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMaxY())); 365 366 xRetval.realloc(2); 367 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aLeft, aRGBBorderColor)); 368 xRetval[1] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aRight, aRGBBorderColor)); 369 } 370 else 371 { 372 xRetval.realloc(1); 373 const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange)); 374 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor)); 375 } 376 377 return xRetval; 378 } 379 ViewContactOfOuterPageBorder(ViewContactOfSdrPage & rParentViewContactOfSdrPage)380 ViewContactOfOuterPageBorder::ViewContactOfOuterPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 381 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage) 382 { 383 } 384 ~ViewContactOfOuterPageBorder()385 ViewContactOfOuterPageBorder::~ViewContactOfOuterPageBorder() 386 { 387 } 388 } // end of namespace contact 389 } // end of namespace sdr 390 391 ////////////////////////////////////////////////////////////////////////////// 392 393 namespace sdr 394 { 395 namespace contact 396 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)397 ViewObjectContact& ViewContactOfInnerPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 398 { 399 ViewObjectContact* pRetval = new ViewObjectContactOfInnerPageBorder(rObjectContact, *this); 400 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 401 402 return *pRetval; 403 } 404 createViewIndependentPrimitive2DSequence() const405 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfInnerPageBorder::createViewIndependentPrimitive2DSequence() const 406 { 407 const SdrPage& rPage = getPage(); 408 const basegfx::B2DRange aPageBorderRange( 409 (double)rPage.GetLftBorder(), (double)rPage.GetUppBorder(), 410 (double)(rPage.GetWdt() - rPage.GetRgtBorder()), (double)(rPage.GetHgt() - rPage.GetLwrBorder())); 411 const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange)); 412 413 // We have only the page information, not the view information. Use the 414 // svtools::FONTCOLOR or svtools::DOCBOUNDARIES color for initialization 415 const svtools::ColorConfig aColorConfig; 416 Color aBorderColor; 417 418 if(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) 419 { 420 aBorderColor = aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor; 421 } 422 else 423 { 424 aBorderColor = aColorConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor; 425 } 426 427 // create page outer border primitive 428 const basegfx::BColor aRGBBorderColor(aBorderColor.getBColor()); 429 const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor)); 430 431 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); 432 } 433 ViewContactOfInnerPageBorder(ViewContactOfSdrPage & rParentViewContactOfSdrPage)434 ViewContactOfInnerPageBorder::ViewContactOfInnerPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 435 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage) 436 { 437 } 438 ~ViewContactOfInnerPageBorder()439 ViewContactOfInnerPageBorder::~ViewContactOfInnerPageBorder() 440 { 441 } 442 } // end of namespace contact 443 } // end of namespace sdr 444 445 ////////////////////////////////////////////////////////////////////////////// 446 447 namespace sdr 448 { 449 namespace contact 450 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)451 ViewObjectContact& ViewContactOfPageHierarchy::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 452 { 453 ViewObjectContact* pRetval = new ViewObjectContactOfPageHierarchy(rObjectContact, *this); 454 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 455 456 return *pRetval; 457 } 458 createViewIndependentPrimitive2DSequence() const459 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageHierarchy::createViewIndependentPrimitive2DSequence() const 460 { 461 // collect sub-hierarchy 462 drawinglayer::primitive2d::Primitive2DSequence xRetval; 463 const sal_uInt32 nObjectCount(GetObjectCount()); 464 465 // collect all sub-primitives 466 for(sal_uInt32 a(0); a < nObjectCount; a++) 467 { 468 const ViewContact& rCandidate(GetViewContact(a)); 469 const drawinglayer::primitive2d::Primitive2DSequence aCandSeq(rCandidate.getViewIndependentPrimitive2DSequence()); 470 471 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aCandSeq); 472 } 473 474 return xRetval; 475 } 476 ViewContactOfPageHierarchy(ViewContactOfSdrPage & rParentViewContactOfSdrPage)477 ViewContactOfPageHierarchy::ViewContactOfPageHierarchy(ViewContactOfSdrPage& rParentViewContactOfSdrPage) 478 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage) 479 { 480 } 481 ~ViewContactOfPageHierarchy()482 ViewContactOfPageHierarchy::~ViewContactOfPageHierarchy() 483 { 484 } 485 GetObjectCount() const486 sal_uInt32 ViewContactOfPageHierarchy::GetObjectCount() const 487 { 488 return getPage().GetObjCount(); 489 } 490 GetViewContact(sal_uInt32 nIndex) const491 ViewContact& ViewContactOfPageHierarchy::GetViewContact(sal_uInt32 nIndex) const 492 { 493 SdrObject* pObj = getPage().GetObj(nIndex); 494 DBG_ASSERT(pObj, "ViewContactOfPageHierarchy::GetViewContact: Corrupt SdrObjList (!)"); 495 return pObj->GetViewContact(); 496 } 497 } // end of namespace contact 498 } // end of namespace sdr 499 500 ////////////////////////////////////////////////////////////////////////////// 501 502 namespace sdr 503 { 504 namespace contact 505 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)506 ViewObjectContact& ViewContactOfGrid::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 507 { 508 ViewObjectContact* pRetval = new ViewObjectContactOfPageGrid(rObjectContact, *this); 509 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 510 511 return *pRetval; 512 } 513 createViewIndependentPrimitive2DSequence() const514 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGrid::createViewIndependentPrimitive2DSequence() const 515 { 516 // We have only the page information, not the view information and thus no grid settings. Create empty 517 // default. For the view-dependent implementation, see ViewObjectContactOfPageGrid::createPrimitive2DSequence 518 return drawinglayer::primitive2d::Primitive2DSequence(); 519 } 520 ViewContactOfGrid(ViewContactOfSdrPage & rParentViewContactOfSdrPage,bool bFront)521 ViewContactOfGrid::ViewContactOfGrid(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront) 522 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage), 523 mbFront(bFront) 524 { 525 } 526 ~ViewContactOfGrid()527 ViewContactOfGrid::~ViewContactOfGrid() 528 { 529 } 530 } // end of namespace contact 531 } // end of namespace sdr 532 533 ////////////////////////////////////////////////////////////////////////////// 534 535 namespace sdr 536 { 537 namespace contact 538 { CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)539 ViewObjectContact& ViewContactOfHelplines::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 540 { 541 ViewObjectContact* pRetval = new ViewObjectContactOfPageHelplines(rObjectContact, *this); 542 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 543 544 return *pRetval; 545 } 546 createViewIndependentPrimitive2DSequence() const547 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfHelplines::createViewIndependentPrimitive2DSequence() const 548 { 549 // We have only the page information, not the view information and thus no helplines. Create empty 550 // default. For the view-dependent implementation, see ViewObjectContactOfPageHelplines::createPrimitive2DSequence 551 return drawinglayer::primitive2d::Primitive2DSequence(); 552 } 553 ViewContactOfHelplines(ViewContactOfSdrPage & rParentViewContactOfSdrPage,bool bFront)554 ViewContactOfHelplines::ViewContactOfHelplines(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront) 555 : ViewContactOfPageSubObject(rParentViewContactOfSdrPage), 556 mbFront(bFront) 557 { 558 } 559 ~ViewContactOfHelplines()560 ViewContactOfHelplines::~ViewContactOfHelplines() 561 { 562 } 563 } // end of namespace contact 564 } // end of namespace sdr 565 566 ////////////////////////////////////////////////////////////////////////////// 567 568 namespace sdr 569 { 570 namespace contact 571 { 572 // Create a Object-Specific ViewObjectContact, set ViewContact and 573 // ObjectContact. Always needs to return something. CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)574 ViewObjectContact& ViewContactOfSdrPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact) 575 { 576 ViewObjectContact* pRetval = new ViewObjectContactOfSdrPage(rObjectContact, *this); 577 DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)"); 578 579 return *pRetval; 580 } 581 ViewContactOfSdrPage(SdrPage & rPage)582 ViewContactOfSdrPage::ViewContactOfSdrPage(SdrPage& rPage) 583 : ViewContact(), 584 mrPage(rPage), 585 maViewContactOfPageBackground(*this), 586 maViewContactOfPageShadow(*this), 587 maViewContactOfPageFill(*this), 588 maViewContactOfMasterPage(*this), 589 maViewContactOfOuterPageBorder(*this), 590 maViewContactOfInnerPageBorder(*this), 591 maViewContactOfGridBack(*this, false), 592 maViewContactOfHelplinesBack(*this, false), 593 maViewContactOfPageHierarchy(*this), 594 maViewContactOfGridFront(*this, true), 595 maViewContactOfHelplinesFront(*this, true) 596 { 597 } 598 ~ViewContactOfSdrPage()599 ViewContactOfSdrPage::~ViewContactOfSdrPage() 600 { 601 } 602 603 // Access to possible sub-hierarchy GetObjectCount() const604 sal_uInt32 ViewContactOfSdrPage::GetObjectCount() const 605 { 606 // Fixed count of content. It contains PageBackground (Wiese), PageShadow, PageFill, 607 // then - depending on if the page has a MasterPage - either MasterPage Hierarchy 608 // or MPBGO. Also OuterPageBorder, InnerPageBorder and two pairs of Grid and Helplines 609 // (for front and back) which internally are visible or not depending on the current 610 // front/back setting for those. 611 return 11; 612 } 613 GetViewContact(sal_uInt32 nIndex) const614 ViewContact& ViewContactOfSdrPage::GetViewContact(sal_uInt32 nIndex) const 615 { 616 switch(nIndex) 617 { 618 case 0: return (ViewContact&)maViewContactOfPageBackground; 619 case 1: return (ViewContact&)maViewContactOfPageShadow; 620 case 2: return (ViewContact&)maViewContactOfPageFill; 621 case 3: 622 { 623 const SdrPage& rPage = GetSdrPage(); 624 625 if(rPage.TRG_HasMasterPage()) 626 { 627 return rPage.TRG_GetMasterPageDescriptorViewContact(); 628 } 629 else 630 { 631 return (ViewContact&)maViewContactOfMasterPage; 632 } 633 } 634 case 4: return (ViewContact&)maViewContactOfOuterPageBorder; 635 case 5: return (ViewContact&)maViewContactOfInnerPageBorder; 636 case 6: return (ViewContact&)maViewContactOfGridBack; 637 case 7: return (ViewContact&)maViewContactOfHelplinesBack; 638 case 8: return (ViewContact&)maViewContactOfPageHierarchy; 639 case 9: return (ViewContact&)maViewContactOfGridFront; 640 default: return (ViewContact&)maViewContactOfHelplinesFront; 641 } 642 } 643 644 // React on changes of the object of this ViewContact ActionChanged()645 void ViewContactOfSdrPage::ActionChanged() 646 { 647 // call parent 648 ViewContact::ActionChanged(); 649 650 // apply to local viewContacts, they all rely on page information. Exception 651 // is the sub hierarchy; this will not be influenced by the change 652 maViewContactOfPageBackground.ActionChanged(); 653 maViewContactOfPageShadow.ActionChanged(); 654 maViewContactOfPageFill.ActionChanged(); 655 656 const SdrPage& rPage = GetSdrPage(); 657 658 if(rPage.TRG_HasMasterPage()) 659 { 660 rPage.TRG_GetMasterPageDescriptorViewContact().ActionChanged(); 661 } 662 else if(rPage.IsMasterPage()) 663 { 664 maViewContactOfMasterPage.ActionChanged(); 665 } 666 667 maViewContactOfOuterPageBorder.ActionChanged(); 668 maViewContactOfInnerPageBorder.ActionChanged(); 669 maViewContactOfGridBack.ActionChanged(); 670 maViewContactOfHelplinesBack.ActionChanged(); 671 maViewContactOfGridFront.ActionChanged(); 672 maViewContactOfHelplinesFront.ActionChanged(); 673 } 674 675 // overload for accessing the SdrPage TryToGetSdrPage() const676 SdrPage* ViewContactOfSdrPage::TryToGetSdrPage() const 677 { 678 return &GetSdrPage(); 679 } 680 createViewIndependentPrimitive2DSequence() const681 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrPage::createViewIndependentPrimitive2DSequence() const 682 { 683 drawinglayer::primitive2d::Primitive2DSequence xRetval; 684 685 // collect all sub-sequences including sub hierarchy. 686 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageBackground.getViewIndependentPrimitive2DSequence()); 687 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageShadow.getViewIndependentPrimitive2DSequence()); 688 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageFill.getViewIndependentPrimitive2DSequence()); 689 690 const SdrPage& rPage = GetSdrPage(); 691 692 if(rPage.TRG_HasMasterPage()) 693 { 694 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, 695 rPage.TRG_GetMasterPageDescriptorViewContact().getViewIndependentPrimitive2DSequence()); 696 } 697 else if(rPage.IsMasterPage()) 698 { 699 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, 700 maViewContactOfMasterPage.getViewIndependentPrimitive2DSequence()); 701 } 702 703 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfOuterPageBorder.getViewIndependentPrimitive2DSequence()); 704 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfInnerPageBorder.getViewIndependentPrimitive2DSequence()); 705 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageHierarchy.getViewIndependentPrimitive2DSequence()); 706 707 // Only add front versions of grid and helplines since no visibility test is done, 708 // so adding the back incarnations is not necessary. This makes the Front 709 // visualization the default when no visibility tests are done. 710 // 711 // Since we have no view here, no grid and helpline definitions are available currently. The used 712 // methods at ViewContactOfHelplines and ViewContactOfGrid return only empty sequences and 713 // do not need to be called ATM. This may change later if grid or helpline info gets 714 // model data (it should not). Keeping the lines commented to hold this hint. 715 // 716 // drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfGridFront.getViewIndependentPrimitive2DSequence()); 717 // drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfHelplinesFront.getViewIndependentPrimitive2DSequence()); 718 719 return xRetval; 720 } 721 } // end of namespace contact 722 } // end of namespace sdr 723 724 ////////////////////////////////////////////////////////////////////////////// 725 // eof 726