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