1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #include <sdr/primitive2d/sdrtextprimitive2d.hxx> 21 #include <svx/svdotext.hxx> 22 #include <basegfx/color/bcolor.hxx> 23 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> 24 #include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx> 25 #include <editeng/outlobj.hxx> 26 #include <editeng/editobj.hxx> 27 #include <editeng/flditem.hxx> 28 #include <drawinglayer/geometry/viewinformation2d.hxx> 29 #include <svx/unoapi.hxx> 30 #include <svx/svdpage.hxx> 31 #include <svx/svdmodel.hxx> 32 #include <svx/svdoutl.hxx> 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 35 36 using namespace com::sun::star; 37 38 39 namespace 40 { getPageNumber(const uno::Reference<drawing::XDrawPage> & rxDrawPage)41 sal_Int16 getPageNumber(const uno::Reference< drawing::XDrawPage >& rxDrawPage) 42 { 43 sal_Int16 nRetval(0); 44 uno::Reference< beans::XPropertySet > xSet(rxDrawPage, uno::UNO_QUERY); 45 46 if (xSet.is()) 47 { 48 try 49 { 50 const uno::Any aNumber(xSet->getPropertyValue("Number")); 51 aNumber >>= nRetval; 52 } 53 catch(const uno::Exception&) 54 { 55 OSL_ASSERT(false); 56 } 57 } 58 59 return nRetval; 60 } 61 getPageCount(const uno::Reference<drawing::XDrawPage> & rxDrawPage)62 sal_Int16 getPageCount(const uno::Reference< drawing::XDrawPage >& rxDrawPage) 63 { 64 sal_Int16 nRetval(0); 65 SdrPage* pPage = GetSdrPageFromXDrawPage(rxDrawPage); 66 67 if(pPage) 68 { 69 if( (pPage->GetPageNum() == 0) && !pPage->IsMasterPage() ) 70 { 71 // handout page! 72 return pPage->getSdrModelFromSdrPage().getHandoutPageCount(); 73 } 74 else 75 { 76 const sal_uInt16 nPageCount(pPage->getSdrModelFromSdrPage().GetPageCount()); 77 nRetval = (static_cast<sal_Int16>(nPageCount) - 1) / 2; 78 } 79 } 80 81 return nRetval; 82 } 83 } // end of anonymous namespace 84 85 86 namespace drawinglayer 87 { 88 namespace primitive2d 89 { 90 // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments 91 // for slideshow. This uses TextHierarchyBlockPrimitive2D to mark a text block. 92 // ATM there is only one text block per SdrObject, this may get more in the future encapsulateWithTextHierarchyBlockPrimitive2D(Primitive2DContainer & rContainer,const Primitive2DContainer & rCandidate)93 void SdrTextPrimitive2D::encapsulateWithTextHierarchyBlockPrimitive2D(Primitive2DContainer& rContainer, const Primitive2DContainer& rCandidate) 94 { 95 rContainer.push_back(new TextHierarchyBlockPrimitive2D(rCandidate)); 96 } 97 SdrTextPrimitive2D(const SdrText * pSdrText,const OutlinerParaObject & rOutlinerParaObject)98 SdrTextPrimitive2D::SdrTextPrimitive2D( 99 const SdrText* pSdrText, 100 const OutlinerParaObject& rOutlinerParaObject) 101 : BufferedDecompositionPrimitive2D(), 102 mrSdrText(const_cast< SdrText* >(pSdrText)), 103 maOutlinerParaObject(rOutlinerParaObject), 104 mxLastVisualizingPage(), 105 mnLastPageNumber(0), 106 mnLastPageCount(0), 107 maLastTextBackgroundColor(), 108 mbContainsPageField(false), 109 mbContainsPageCountField(false), 110 mbContainsOtherFields(false) 111 { 112 const EditTextObject& rETO = maOutlinerParaObject.GetTextObject(); 113 114 mbContainsPageField = rETO.HasField(SvxPageField::CLASS_ID); 115 mbContainsPageCountField = rETO.HasField(SvxPagesField::CLASS_ID); 116 mbContainsOtherFields = rETO.HasField(SvxHeaderField::CLASS_ID) 117 || rETO.HasField(SvxFooterField::CLASS_ID) 118 || rETO.HasField(SvxDateTimeField::CLASS_ID) 119 || rETO.HasField(SvxAuthorField::CLASS_ID); 120 } 121 getSdrText() const122 const SdrText* SdrTextPrimitive2D::getSdrText() const { return mrSdrText.get(); } 123 operator ==(const BasePrimitive2D & rPrimitive) const124 bool SdrTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 125 { 126 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) 127 { 128 const SdrTextPrimitive2D& rCompare = static_cast<const SdrTextPrimitive2D&>(rPrimitive); 129 130 return ( 131 132 // compare OPO and content, but not WrongList 133 getOutlinerParaObject() == rCompare.getOutlinerParaObject() 134 135 // also compare WrongList (not-persistent data, but visualized) 136 && getOutlinerParaObject().isWrongListEqual(rCompare.getOutlinerParaObject())); 137 } 138 139 return false; 140 } 141 get2DDecomposition(Primitive2DDecompositionVisitor & rVisitor,const geometry::ViewInformation2D & rViewInformation) const142 void SdrTextPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const 143 { 144 uno::Reference< drawing::XDrawPage > xCurrentlyVisualizingPage; 145 bool bCurrentlyVisualizingPageIsSet(false); 146 Color aNewTextBackgroundColor; 147 bool bNewTextBackgroundColorIsSet(false); 148 sal_Int16 nCurrentlyValidPageNumber(0); 149 sal_Int16 nCurrentlyValidPageCount(0); 150 151 if(!getBuffered2DDecomposition().empty()) 152 { 153 bool bDoDelete(false); 154 155 // check visualized page 156 if(mbContainsPageField || mbContainsPageCountField || mbContainsOtherFields) 157 { 158 // get visualized page and remember 159 xCurrentlyVisualizingPage = rViewInformation.getVisualizedPage(); 160 bCurrentlyVisualizingPageIsSet = true; 161 162 if(xCurrentlyVisualizingPage != mxLastVisualizingPage) 163 { 164 bDoDelete = true; 165 } 166 167 // #i98870# check visualized PageNumber 168 if(!bDoDelete && mbContainsPageField) 169 { 170 nCurrentlyValidPageNumber = getPageNumber(xCurrentlyVisualizingPage); 171 172 if(nCurrentlyValidPageNumber != mnLastPageNumber) 173 { 174 bDoDelete = true; 175 } 176 } 177 178 // #i98870# check visualized PageCount, too 179 if(!bDoDelete && mbContainsPageCountField) 180 { 181 nCurrentlyValidPageCount = getPageCount(xCurrentlyVisualizingPage); 182 183 if(nCurrentlyValidPageCount != mnLastPageCount) 184 { 185 bDoDelete = true; 186 } 187 } 188 } 189 190 // #i101443# check change of TextBackgroundolor 191 if(!bDoDelete && getSdrText()) 192 { 193 SdrOutliner& rDrawOutliner = getSdrText()->GetObject().getSdrModelFromSdrObject().GetDrawOutliner(); 194 aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor(); 195 bNewTextBackgroundColorIsSet = true; 196 197 if(aNewTextBackgroundColor != maLastTextBackgroundColor) 198 { 199 bDoDelete = true; 200 } 201 } 202 203 if(bDoDelete) 204 { 205 const_cast< SdrTextPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer()); 206 } 207 } 208 209 if(getBuffered2DDecomposition().empty()) 210 { 211 if(!bCurrentlyVisualizingPageIsSet && mbContainsPageField) 212 { 213 xCurrentlyVisualizingPage = rViewInformation.getVisualizedPage(); 214 } 215 216 if(!nCurrentlyValidPageNumber && mbContainsPageField) 217 { 218 nCurrentlyValidPageNumber = getPageNumber(xCurrentlyVisualizingPage); 219 } 220 221 if(!nCurrentlyValidPageCount && mbContainsPageCountField) 222 { 223 nCurrentlyValidPageCount = getPageCount(xCurrentlyVisualizingPage); 224 } 225 226 if(!bNewTextBackgroundColorIsSet && getSdrText()) 227 { 228 SdrOutliner& rDrawOutliner = getSdrText()->GetObject().getSdrModelFromSdrObject().GetDrawOutliner(); 229 aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor(); 230 } 231 232 const_cast< SdrTextPrimitive2D* >(this)->mxLastVisualizingPage = xCurrentlyVisualizingPage; 233 const_cast< SdrTextPrimitive2D* >(this)->mnLastPageNumber = nCurrentlyValidPageNumber; 234 const_cast< SdrTextPrimitive2D* >(this)->mnLastPageCount = nCurrentlyValidPageCount; 235 const_cast< SdrTextPrimitive2D* >(this)->maLastTextBackgroundColor = aNewTextBackgroundColor; 236 } 237 238 // call parent 239 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation); 240 } 241 } // end of namespace primitive2d 242 } // end of namespace drawinglayer 243 244 245 namespace drawinglayer 246 { 247 namespace primitive2d 248 { create2DDecomposition(Primitive2DContainer & rContainer,const geometry::ViewInformation2D & aViewInformation) const249 void SdrContourTextPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const 250 { 251 Primitive2DContainer aRetval; 252 getSdrText()->GetObject().impDecomposeContourTextPrimitive(aRetval, *this, aViewInformation); 253 254 encapsulateWithTextHierarchyBlockPrimitive2D(rContainer, aRetval); 255 } 256 SdrContourTextPrimitive2D(const SdrText * pSdrText,const OutlinerParaObject & rOutlinerParaObject,const basegfx::B2DPolyPolygon & rUnitPolyPolygon,const basegfx::B2DHomMatrix & rObjectTransform)257 SdrContourTextPrimitive2D::SdrContourTextPrimitive2D( 258 const SdrText* pSdrText, 259 const OutlinerParaObject& rOutlinerParaObject, 260 const basegfx::B2DPolyPolygon& rUnitPolyPolygon, 261 const basegfx::B2DHomMatrix& rObjectTransform) 262 : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject), 263 maUnitPolyPolygon(rUnitPolyPolygon), 264 maObjectTransform(rObjectTransform) 265 { 266 } 267 operator ==(const BasePrimitive2D & rPrimitive) const268 bool SdrContourTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 269 { 270 if(SdrTextPrimitive2D::operator==(rPrimitive)) 271 { 272 const SdrContourTextPrimitive2D& rCompare = static_cast<const SdrContourTextPrimitive2D&>(rPrimitive); 273 274 return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon() 275 && getObjectTransform() == rCompare.getObjectTransform()); 276 } 277 278 return false; 279 } 280 createTransformedClone(const basegfx::B2DHomMatrix & rTransform) const281 std::unique_ptr<SdrTextPrimitive2D> SdrContourTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const 282 { 283 return std::make_unique<SdrContourTextPrimitive2D>( 284 getSdrText(), 285 getOutlinerParaObject(), 286 getUnitPolyPolygon(), 287 rTransform * getObjectTransform()); 288 } 289 290 // provide unique ID 291 ImplPrimitive2DIDBlock(SdrContourTextPrimitive2D, PRIMITIVE2D_ID_SDRCONTOURTEXTPRIMITIVE2D) 292 293 } // end of namespace primitive2d 294 } // end of namespace drawinglayer 295 296 297 namespace drawinglayer 298 { 299 namespace primitive2d 300 { create2DDecomposition(Primitive2DContainer & rContainer,const geometry::ViewInformation2D & aViewInformation) const301 void SdrPathTextPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const 302 { 303 Primitive2DContainer aRetval; 304 getSdrText()->GetObject().impDecomposePathTextPrimitive(aRetval, *this, aViewInformation); 305 306 encapsulateWithTextHierarchyBlockPrimitive2D(rContainer, aRetval); 307 } 308 SdrPathTextPrimitive2D(const SdrText * pSdrText,const OutlinerParaObject & rOutlinerParaObject,const basegfx::B2DPolyPolygon & rPathPolyPolygon,const attribute::SdrFormTextAttribute & rSdrFormTextAttribute)309 SdrPathTextPrimitive2D::SdrPathTextPrimitive2D( 310 const SdrText* pSdrText, 311 const OutlinerParaObject& rOutlinerParaObject, 312 const basegfx::B2DPolyPolygon& rPathPolyPolygon, 313 const attribute::SdrFormTextAttribute& rSdrFormTextAttribute) 314 : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject), 315 maPathPolyPolygon(rPathPolyPolygon), 316 maSdrFormTextAttribute(rSdrFormTextAttribute) 317 { 318 } 319 operator ==(const BasePrimitive2D & rPrimitive) const320 bool SdrPathTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 321 { 322 if(SdrTextPrimitive2D::operator==(rPrimitive)) 323 { 324 const SdrPathTextPrimitive2D& rCompare = static_cast<const SdrPathTextPrimitive2D&>(rPrimitive); 325 326 return (getPathPolyPolygon() == rCompare.getPathPolyPolygon() 327 && getSdrFormTextAttribute() == rCompare.getSdrFormTextAttribute()); 328 } 329 330 return false; 331 } 332 createTransformedClone(const basegfx::B2DHomMatrix & rTransform) const333 std::unique_ptr<SdrTextPrimitive2D> SdrPathTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const 334 { 335 basegfx::B2DPolyPolygon aNewPolyPolygon(getPathPolyPolygon()); 336 aNewPolyPolygon.transform(rTransform); 337 338 return std::make_unique<SdrPathTextPrimitive2D>( 339 getSdrText(), 340 getOutlinerParaObject(), 341 aNewPolyPolygon, 342 getSdrFormTextAttribute()); 343 } 344 345 // provide unique ID 346 ImplPrimitive2DIDBlock(SdrPathTextPrimitive2D, PRIMITIVE2D_ID_SDRPATHTEXTPRIMITIVE2D) 347 348 } // end of namespace primitive2d 349 } // end of namespace drawinglayer 350 351 352 namespace drawinglayer 353 { 354 namespace primitive2d 355 { create2DDecomposition(Primitive2DContainer & rContainer,const geometry::ViewInformation2D & aViewInformation) const356 void SdrBlockTextPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const 357 { 358 Primitive2DContainer aRetval; 359 getSdrText()->GetObject().impDecomposeBlockTextPrimitive(aRetval, *this, aViewInformation); 360 361 encapsulateWithTextHierarchyBlockPrimitive2D(rContainer, aRetval); 362 } 363 SdrBlockTextPrimitive2D(const SdrText * pSdrText,const OutlinerParaObject & rOutlinerParaObject,const basegfx::B2DHomMatrix & rTextRangeTransform,SdrTextHorzAdjust aSdrTextHorzAdjust,SdrTextVertAdjust aSdrTextVertAdjust,bool bFixedCellHeight,bool bUnlimitedPage,bool bCellText,bool bWordWrap,bool bClipOnBounds)364 SdrBlockTextPrimitive2D::SdrBlockTextPrimitive2D( 365 const SdrText* pSdrText, 366 const OutlinerParaObject& rOutlinerParaObject, 367 const basegfx::B2DHomMatrix& rTextRangeTransform, 368 SdrTextHorzAdjust aSdrTextHorzAdjust, 369 SdrTextVertAdjust aSdrTextVertAdjust, 370 bool bFixedCellHeight, 371 bool bUnlimitedPage, 372 bool bCellText, 373 bool bWordWrap, 374 bool bClipOnBounds) 375 : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject), 376 maTextRangeTransform(rTextRangeTransform), 377 maSdrTextHorzAdjust(aSdrTextHorzAdjust), 378 maSdrTextVertAdjust(aSdrTextVertAdjust), 379 mbFixedCellHeight(bFixedCellHeight), 380 mbUnlimitedPage(bUnlimitedPage), 381 mbCellText(bCellText), 382 mbWordWrap(bWordWrap), 383 mbClipOnBounds(bClipOnBounds) 384 { 385 } 386 operator ==(const BasePrimitive2D & rPrimitive) const387 bool SdrBlockTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 388 { 389 if(SdrTextPrimitive2D::operator==(rPrimitive)) 390 { 391 const SdrBlockTextPrimitive2D& rCompare = static_cast<const SdrBlockTextPrimitive2D&>(rPrimitive); 392 393 return (getTextRangeTransform() == rCompare.getTextRangeTransform() 394 && getSdrTextHorzAdjust() == rCompare.getSdrTextHorzAdjust() 395 && getSdrTextVertAdjust() == rCompare.getSdrTextVertAdjust() 396 && isFixedCellHeight() == rCompare.isFixedCellHeight() 397 && getUnlimitedPage() == rCompare.getUnlimitedPage() 398 && getCellText() == rCompare.getCellText() 399 && getWordWrap() == rCompare.getWordWrap() 400 && getClipOnBounds() == rCompare.getClipOnBounds()); 401 } 402 403 return false; 404 } 405 createTransformedClone(const basegfx::B2DHomMatrix & rTransform) const406 std::unique_ptr<SdrTextPrimitive2D> SdrBlockTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const 407 { 408 return std::make_unique<SdrBlockTextPrimitive2D>( 409 getSdrText(), 410 getOutlinerParaObject(), 411 rTransform * getTextRangeTransform(), 412 getSdrTextHorzAdjust(), 413 getSdrTextVertAdjust(), 414 isFixedCellHeight(), 415 getUnlimitedPage(), 416 getCellText(), 417 getWordWrap(), 418 getClipOnBounds()); 419 } 420 421 // provide unique ID 422 ImplPrimitive2DIDBlock(SdrBlockTextPrimitive2D, PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D) 423 424 } // end of namespace primitive2d 425 } // end of namespace drawinglayer 426 427 428 namespace drawinglayer 429 { 430 namespace primitive2d 431 { create2DDecomposition(Primitive2DContainer & rContainer,const geometry::ViewInformation2D & aViewInformation) const432 void SdrAutoFitTextPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const 433 { 434 Primitive2DContainer aRetval; 435 getSdrText()->GetObject().impDecomposeAutoFitTextPrimitive(aRetval, *this, aViewInformation); 436 437 encapsulateWithTextHierarchyBlockPrimitive2D(rContainer, aRetval); 438 } 439 SdrAutoFitTextPrimitive2D(const SdrText * pSdrText,const OutlinerParaObject & rParaObj,const::basegfx::B2DHomMatrix & rTextRangeTransform,bool bWordWrap)440 SdrAutoFitTextPrimitive2D::SdrAutoFitTextPrimitive2D( 441 const SdrText* pSdrText, 442 const OutlinerParaObject& rParaObj, 443 const ::basegfx::B2DHomMatrix& rTextRangeTransform, 444 bool bWordWrap) 445 : SdrTextPrimitive2D(pSdrText, rParaObj), 446 maTextRangeTransform(rTextRangeTransform), 447 mbWordWrap(bWordWrap) 448 { 449 } 450 operator ==(const BasePrimitive2D & rPrimitive) const451 bool SdrAutoFitTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 452 { 453 if(SdrTextPrimitive2D::operator==(rPrimitive)) 454 { 455 const SdrBlockTextPrimitive2D& rCompare = static_cast<const SdrBlockTextPrimitive2D&>(rPrimitive); 456 457 return (getTextRangeTransform() == rCompare.getTextRangeTransform() 458 && getWordWrap() == rCompare.getWordWrap()); 459 } 460 461 return false; 462 } 463 createTransformedClone(const::basegfx::B2DHomMatrix & rTransform) const464 std::unique_ptr<SdrTextPrimitive2D> SdrAutoFitTextPrimitive2D::createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const 465 { 466 return std::make_unique<SdrAutoFitTextPrimitive2D>(getSdrText(), getOutlinerParaObject(), rTransform * getTextRangeTransform(), getWordWrap()); 467 } 468 469 // provide unique ID 470 ImplPrimitive2DIDBlock(SdrAutoFitTextPrimitive2D, PRIMITIVE2D_ID_SDRAUTOFITTEXTPRIMITIVE2D) 471 472 } // end of namespace primitive2d 473 } // end of namespace drawinglayer 474 475 namespace drawinglayer 476 { 477 namespace primitive2d 478 { 479 SdrChainedTextPrimitive2D(const SdrText * pSdrText,const OutlinerParaObject & rOutlinerParaObject,const basegfx::B2DHomMatrix & rTextRangeTransform)480 SdrChainedTextPrimitive2D::SdrChainedTextPrimitive2D( 481 const SdrText* pSdrText, 482 const OutlinerParaObject& rOutlinerParaObject, 483 const basegfx::B2DHomMatrix& rTextRangeTransform) 484 : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject), 485 maTextRangeTransform(rTextRangeTransform) 486 { } 487 create2DDecomposition(Primitive2DContainer & rContainer,const geometry::ViewInformation2D & aViewInformation) const488 void SdrChainedTextPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const 489 { 490 Primitive2DContainer aRetval; 491 getSdrText()->GetObject().impDecomposeChainedTextPrimitive(aRetval, *this, aViewInformation); 492 493 encapsulateWithTextHierarchyBlockPrimitive2D(rContainer, aRetval); 494 } 495 operator ==(const BasePrimitive2D & rPrimitive) const496 bool SdrChainedTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 497 { 498 if(SdrTextPrimitive2D::operator==(rPrimitive)) 499 { 500 const SdrBlockTextPrimitive2D& rCompare = static_cast<const SdrBlockTextPrimitive2D&>(rPrimitive); 501 502 return (getTextRangeTransform() == rCompare.getTextRangeTransform()); 503 } 504 505 return false; 506 } 507 createTransformedClone(const basegfx::B2DHomMatrix & rTransform) const508 std::unique_ptr<SdrTextPrimitive2D> SdrChainedTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const 509 { 510 return std::make_unique<SdrChainedTextPrimitive2D>(getSdrText(), getOutlinerParaObject(), rTransform * getTextRangeTransform()); 511 } 512 513 // provide unique ID 514 ImplPrimitive2DIDBlock(SdrChainedTextPrimitive2D, PRIMITIVE2D_ID_SDRCHAINEDTEXTPRIMITIVE2D) 515 } // end of namespace primitive2d 516 } // end of namespace drawinglayer 517 518 519 namespace drawinglayer 520 { 521 namespace primitive2d 522 { create2DDecomposition(Primitive2DContainer & rContainer,const geometry::ViewInformation2D & aViewInformation) const523 void SdrStretchTextPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const 524 { 525 Primitive2DContainer aRetval; 526 getSdrText()->GetObject().impDecomposeStretchTextPrimitive(aRetval, *this, aViewInformation); 527 528 encapsulateWithTextHierarchyBlockPrimitive2D(rContainer, aRetval); 529 } 530 SdrStretchTextPrimitive2D(const SdrText * pSdrText,const OutlinerParaObject & rOutlinerParaObject,const basegfx::B2DHomMatrix & rTextRangeTransform,bool bFixedCellHeight)531 SdrStretchTextPrimitive2D::SdrStretchTextPrimitive2D( 532 const SdrText* pSdrText, 533 const OutlinerParaObject& rOutlinerParaObject, 534 const basegfx::B2DHomMatrix& rTextRangeTransform, 535 bool bFixedCellHeight) 536 : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject), 537 maTextRangeTransform(rTextRangeTransform), 538 mbFixedCellHeight(bFixedCellHeight) 539 { 540 } 541 operator ==(const BasePrimitive2D & rPrimitive) const542 bool SdrStretchTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 543 { 544 if(SdrTextPrimitive2D::operator==(rPrimitive)) 545 { 546 const SdrStretchTextPrimitive2D& rCompare = static_cast<const SdrStretchTextPrimitive2D&>(rPrimitive); 547 548 return (getTextRangeTransform() == rCompare.getTextRangeTransform() 549 && isFixedCellHeight() == rCompare.isFixedCellHeight()); 550 } 551 552 return false; 553 } 554 createTransformedClone(const basegfx::B2DHomMatrix & rTransform) const555 std::unique_ptr<SdrTextPrimitive2D> SdrStretchTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const 556 { 557 return std::make_unique<SdrStretchTextPrimitive2D>( 558 getSdrText(), 559 getOutlinerParaObject(), 560 rTransform * getTextRangeTransform(), 561 isFixedCellHeight()); 562 } 563 564 // provide unique ID 565 ImplPrimitive2DIDBlock(SdrStretchTextPrimitive2D, PRIMITIVE2D_ID_SDRSTRETCHTEXTPRIMITIVE2D) 566 567 } // end of namespace primitive2d 568 } // end of namespace drawinglayer 569 570 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 571