1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_svx.hxx" 25cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> 26cdf0e10cSrcweir #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 27cdf0e10cSrcweir #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> 28cdf0e10cSrcweir #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> 29cdf0e10cSrcweir #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx> 30cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 31cdf0e10cSrcweir #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> 32cdf0e10cSrcweir #include <drawinglayer/attribute/strokeattribute.hxx> 33cdf0e10cSrcweir #include <drawinglayer/attribute/linestartendattribute.hxx> 34cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> 35035a2f44SArmin Le Grand #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx> 36cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 37cdf0e10cSrcweir #include <drawinglayer/primitive2d/shadowprimitive2d.hxx> 38cdf0e10cSrcweir #include <svx/sdr/attribute/sdrtextattribute.hxx> 39cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx> 40cdf0e10cSrcweir #include <svx/svdotext.hxx> 41cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx> 42cdf0e10cSrcweir #include <drawinglayer/primitive2d/animatedprimitive2d.hxx> 43cdf0e10cSrcweir #include <drawinglayer/animation/animationtiming.hxx> 44cdf0e10cSrcweir #include <drawinglayer/primitive2d/maskprimitive2d.hxx> 45cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx> 46cdf0e10cSrcweir #include <drawinglayer/geometry/viewinformation2d.hxx> 47cdf0e10cSrcweir #include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx> 48cdf0e10cSrcweir #include <drawinglayer/attribute/sdrfillattribute.hxx> 49cdf0e10cSrcweir #include <drawinglayer/attribute/sdrlineattribute.hxx> 50cdf0e10cSrcweir #include <drawinglayer/attribute/sdrlinestartendattribute.hxx> 51cdf0e10cSrcweir #include <drawinglayer/attribute/sdrshadowattribute.hxx> 52cdf0e10cSrcweir 53cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 54cdf0e10cSrcweir 55cdf0e10cSrcweir using namespace com::sun::star; 56cdf0e10cSrcweir 57cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 58cdf0e10cSrcweir 59cdf0e10cSrcweir namespace drawinglayer 60cdf0e10cSrcweir { 61cdf0e10cSrcweir namespace primitive2d 62cdf0e10cSrcweir { 63cdf0e10cSrcweir Primitive2DReference createPolyPolygonFillPrimitive( 64*64b14621SArmin Le Grand const basegfx::B2DPolyPolygon& rPolyPolygon, 65cdf0e10cSrcweir const attribute::SdrFillAttribute& rFill, 66cdf0e10cSrcweir const attribute::FillGradientAttribute& rFillGradient) 67cdf0e10cSrcweir { 68*64b14621SArmin Le Grand // when we have no given definition range, use the range of the given geometry 69*64b14621SArmin Le Grand // also for definition (simplest case) 70*64b14621SArmin Le Grand const basegfx::B2DRange aRange(basegfx::tools::getRange(rPolyPolygon)); 71*64b14621SArmin Le Grand 72*64b14621SArmin Le Grand return createPolyPolygonFillPrimitive( 73*64b14621SArmin Le Grand rPolyPolygon, 74*64b14621SArmin Le Grand aRange, 75*64b14621SArmin Le Grand rFill, 76*64b14621SArmin Le Grand rFillGradient); 77*64b14621SArmin Le Grand } 78*64b14621SArmin Le Grand 79*64b14621SArmin Le Grand Primitive2DReference createPolyPolygonFillPrimitive( 80*64b14621SArmin Le Grand const basegfx::B2DPolyPolygon& rPolyPolygon, 81*64b14621SArmin Le Grand const basegfx::B2DRange& rDefinitionRange, 82*64b14621SArmin Le Grand const attribute::SdrFillAttribute& rFill, 83*64b14621SArmin Le Grand const attribute::FillGradientAttribute& rFillGradient) 84*64b14621SArmin Le Grand { 85*64b14621SArmin Le Grand if(basegfx::fTools::moreOrEqual(rFill.getTransparence(), 1.0)) 86*64b14621SArmin Le Grand { 87*64b14621SArmin Le Grand return Primitive2DReference(); 88*64b14621SArmin Le Grand } 89*64b14621SArmin Le Grand 90cdf0e10cSrcweir // prepare fully scaled polygon 91cdf0e10cSrcweir BasePrimitive2D* pNewFillPrimitive = 0; 92cdf0e10cSrcweir 93cdf0e10cSrcweir if(!rFill.getGradient().isDefault()) 94cdf0e10cSrcweir { 95*64b14621SArmin Le Grand pNewFillPrimitive = new PolyPolygonGradientPrimitive2D( 96*64b14621SArmin Le Grand rPolyPolygon, 97*64b14621SArmin Le Grand rDefinitionRange, 98*64b14621SArmin Le Grand rFill.getGradient()); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir else if(!rFill.getHatch().isDefault()) 101cdf0e10cSrcweir { 102*64b14621SArmin Le Grand pNewFillPrimitive = new PolyPolygonHatchPrimitive2D( 103*64b14621SArmin Le Grand rPolyPolygon, 104*64b14621SArmin Le Grand rDefinitionRange, 105*64b14621SArmin Le Grand rFill.getColor(), 106*64b14621SArmin Le Grand rFill.getHatch()); 107cdf0e10cSrcweir } 108035a2f44SArmin Le Grand else if(!rFill.getFillGraphic().isDefault()) 109cdf0e10cSrcweir { 110*64b14621SArmin Le Grand pNewFillPrimitive = new PolyPolygonGraphicPrimitive2D( 111*64b14621SArmin Le Grand rPolyPolygon, 112*64b14621SArmin Le Grand rDefinitionRange, 113*64b14621SArmin Le Grand rFill.getFillGraphic().createFillGraphicAttribute(rDefinitionRange)); 114cdf0e10cSrcweir } 115cdf0e10cSrcweir else 116cdf0e10cSrcweir { 117*64b14621SArmin Le Grand pNewFillPrimitive = new PolyPolygonColorPrimitive2D( 118*64b14621SArmin Le Grand rPolyPolygon, 119*64b14621SArmin Le Grand rFill.getColor()); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir if(0.0 != rFill.getTransparence()) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir // create simpleTransparencePrimitive, add created fill primitive 125cdf0e10cSrcweir const Primitive2DReference xRefA(pNewFillPrimitive); 126cdf0e10cSrcweir const Primitive2DSequence aContent(&xRefA, 1L); 127cdf0e10cSrcweir return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rFill.getTransparence())); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir else if(!rFillGradient.isDefault()) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir // create sequence with created fill primitive 132cdf0e10cSrcweir const Primitive2DReference xRefA(pNewFillPrimitive); 133cdf0e10cSrcweir const Primitive2DSequence aContent(&xRefA, 1L); 134cdf0e10cSrcweir 135cdf0e10cSrcweir // create FillGradientPrimitive2D for transparence and add to new sequence 136cdf0e10cSrcweir // fillGradientPrimitive is enough here (compared to PolyPolygonGradientPrimitive2D) since float transparence will be masked anyways 137*64b14621SArmin Le Grand const basegfx::B2DRange aRange(basegfx::tools::getRange(rPolyPolygon)); 138cdf0e10cSrcweir const Primitive2DReference xRefB(new FillGradientPrimitive2D(aRange, rFillGradient)); 139cdf0e10cSrcweir const Primitive2DSequence aAlpha(&xRefB, 1L); 140cdf0e10cSrcweir 141cdf0e10cSrcweir // create TransparencePrimitive2D using alpha and content 142cdf0e10cSrcweir return Primitive2DReference(new TransparencePrimitive2D(aContent, aAlpha)); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir else 145cdf0e10cSrcweir { 146cdf0e10cSrcweir // add to decomposition 147cdf0e10cSrcweir return Primitive2DReference(pNewFillPrimitive); 148cdf0e10cSrcweir } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir Primitive2DReference createPolygonLinePrimitive( 152*64b14621SArmin Le Grand const basegfx::B2DPolygon& rPolygon, 153cdf0e10cSrcweir const attribute::SdrLineAttribute& rLine, 154cdf0e10cSrcweir const attribute::SdrLineStartEndAttribute& rStroke) 155cdf0e10cSrcweir { 156cdf0e10cSrcweir // create line and stroke attribute 1575aaf853bSArmin Le Grand const attribute::LineAttribute aLineAttribute(rLine.getColor(), rLine.getWidth(), rLine.getJoin(), rLine.getCap()); 158cdf0e10cSrcweir const attribute::StrokeAttribute aStrokeAttribute(rLine.getDotDashArray(), rLine.getFullDotDashLen()); 159cdf0e10cSrcweir BasePrimitive2D* pNewLinePrimitive = 0L; 160cdf0e10cSrcweir 161*64b14621SArmin Le Grand if(!rPolygon.isClosed() && !rStroke.isDefault()) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir attribute::LineStartEndAttribute aStart(rStroke.getStartWidth(), rStroke.getStartPolyPolygon(), rStroke.isStartCentered()); 164cdf0e10cSrcweir attribute::LineStartEndAttribute aEnd(rStroke.getEndWidth(), rStroke.getEndPolyPolygon(), rStroke.isEndCentered()); 165cdf0e10cSrcweir 166cdf0e10cSrcweir // create data 167*64b14621SArmin Le Grand pNewLinePrimitive = new PolygonStrokeArrowPrimitive2D(rPolygon, aLineAttribute, aStrokeAttribute, aStart, aEnd); 168cdf0e10cSrcweir } 169cdf0e10cSrcweir else 170cdf0e10cSrcweir { 171cdf0e10cSrcweir // create data 172*64b14621SArmin Le Grand pNewLinePrimitive = new PolygonStrokePrimitive2D(rPolygon, aLineAttribute, aStrokeAttribute); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir if(0.0 != rLine.getTransparence()) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir // create simpleTransparencePrimitive, add created fill primitive 178cdf0e10cSrcweir const Primitive2DReference xRefA(pNewLinePrimitive); 179cdf0e10cSrcweir const Primitive2DSequence aContent(&xRefA, 1L); 180cdf0e10cSrcweir return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rLine.getTransparence())); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir else 183cdf0e10cSrcweir { 184cdf0e10cSrcweir // add to decomposition 185cdf0e10cSrcweir return Primitive2DReference(pNewLinePrimitive); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir Primitive2DReference createTextPrimitive( 190cdf0e10cSrcweir const basegfx::B2DPolyPolygon& rUnitPolyPolygon, 191cdf0e10cSrcweir const basegfx::B2DHomMatrix& rObjectTransform, 192cdf0e10cSrcweir const attribute::SdrTextAttribute& rText, 193cdf0e10cSrcweir const attribute::SdrLineAttribute& rStroke, 194cdf0e10cSrcweir bool bCellText, 195cdf0e10cSrcweir bool bWordWrap, 196cdf0e10cSrcweir bool bClipOnBounds) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir basegfx::B2DHomMatrix aAnchorTransform(rObjectTransform); 199cdf0e10cSrcweir SdrTextPrimitive2D* pNew = 0; 200cdf0e10cSrcweir 201cdf0e10cSrcweir if(rText.isContour()) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir // contour text 204cdf0e10cSrcweir if(!rStroke.isDefault() && 0.0 != rStroke.getWidth()) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir // take line width into account and shrink contour polygon accordingly 207cdf0e10cSrcweir // decompose to get scale 208cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 209cdf0e10cSrcweir double fRotate, fShearX; 210cdf0e10cSrcweir rObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX); 211cdf0e10cSrcweir 212cdf0e10cSrcweir // scale outline to object's size to allow growing with value relative to that size 213cdf0e10cSrcweir // and also to keep aspect ratio 214cdf0e10cSrcweir basegfx::B2DPolyPolygon aScaledUnitPolyPolygon(rUnitPolyPolygon); 215cdf0e10cSrcweir aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix( 216cdf0e10cSrcweir fabs(aScale.getX()), fabs(aScale.getY()))); 217cdf0e10cSrcweir 218cdf0e10cSrcweir // grow the polygon. To shrink, use negative value (half width) 219cdf0e10cSrcweir aScaledUnitPolyPolygon = basegfx::tools::growInNormalDirection(aScaledUnitPolyPolygon, -(rStroke.getWidth() * 0.5)); 220cdf0e10cSrcweir 221cdf0e10cSrcweir // scale back to unit polygon 222cdf0e10cSrcweir aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix( 223cdf0e10cSrcweir 0.0 != aScale.getX() ? 1.0 / aScale.getX() : 1.0, 224cdf0e10cSrcweir 0.0 != aScale.getY() ? 1.0 / aScale.getY() : 1.0)); 225cdf0e10cSrcweir 226cdf0e10cSrcweir // create with unit polygon 227cdf0e10cSrcweir pNew = new SdrContourTextPrimitive2D( 228cdf0e10cSrcweir &rText.getSdrText(), 229cdf0e10cSrcweir rText.getOutlinerParaObject(), 230cdf0e10cSrcweir aScaledUnitPolyPolygon, 231cdf0e10cSrcweir rObjectTransform); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir else 234cdf0e10cSrcweir { 235cdf0e10cSrcweir // create with unit polygon 236cdf0e10cSrcweir pNew = new SdrContourTextPrimitive2D( 237cdf0e10cSrcweir &rText.getSdrText(), 238cdf0e10cSrcweir rText.getOutlinerParaObject(), 239cdf0e10cSrcweir rUnitPolyPolygon, 240cdf0e10cSrcweir rObjectTransform); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir } 243cdf0e10cSrcweir else if(!rText.getSdrFormTextAttribute().isDefault()) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir // text on path, use scaled polygon 246cdf0e10cSrcweir basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon); 247cdf0e10cSrcweir aScaledPolyPolygon.transform(rObjectTransform); 248cdf0e10cSrcweir pNew = new SdrPathTextPrimitive2D( 249cdf0e10cSrcweir &rText.getSdrText(), 250cdf0e10cSrcweir rText.getOutlinerParaObject(), 251cdf0e10cSrcweir aScaledPolyPolygon, 252cdf0e10cSrcweir rText.getSdrFormTextAttribute()); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir else 255cdf0e10cSrcweir { 256cdf0e10cSrcweir // rObjectTransform is the whole SdrObject transformation from unit rectangle 257cdf0e10cSrcweir // to it's size and position. Decompose to allow working with single values. 258cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 259cdf0e10cSrcweir double fRotate, fShearX; 260cdf0e10cSrcweir rObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX); 261cdf0e10cSrcweir 262cdf0e10cSrcweir // extract mirroring 263cdf0e10cSrcweir const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0)); 264cdf0e10cSrcweir const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0)); 265cdf0e10cSrcweir aScale = basegfx::absolute(aScale); 266cdf0e10cSrcweir 267cdf0e10cSrcweir // Get the real size, since polygon ountline and scale 268cdf0e10cSrcweir // from the object transformation may vary (e.g. ellipse segments) 269cdf0e10cSrcweir basegfx::B2DHomMatrix aJustScaleTransform; 270cdf0e10cSrcweir aJustScaleTransform.set(0, 0, aScale.getX()); 271cdf0e10cSrcweir aJustScaleTransform.set(1, 1, aScale.getY()); 272cdf0e10cSrcweir basegfx::B2DPolyPolygon aScaledUnitPolyPolygon(rUnitPolyPolygon); 273cdf0e10cSrcweir aScaledUnitPolyPolygon.transform(aJustScaleTransform); 274cdf0e10cSrcweir const basegfx::B2DRange aSnapRange(basegfx::tools::getRange(aScaledUnitPolyPolygon)); 275cdf0e10cSrcweir 276cdf0e10cSrcweir // create a range describing the wanted text position and size (aTextAnchorRange). This 277cdf0e10cSrcweir // means to use the text distance values here 278cdf0e10cSrcweir const basegfx::B2DPoint aTopLeft(aSnapRange.getMinX() + rText.getTextLeftDistance(), aSnapRange.getMinY() + rText.getTextUpperDistance()); 279cdf0e10cSrcweir const basegfx::B2DPoint aBottomRight(aSnapRange.getMaxX() - rText.getTextRightDistance(), aSnapRange.getMaxY() - rText.getTextLowerDistance()); 280cdf0e10cSrcweir basegfx::B2DRange aTextAnchorRange; 281cdf0e10cSrcweir aTextAnchorRange.expand(aTopLeft); 282cdf0e10cSrcweir aTextAnchorRange.expand(aBottomRight); 283cdf0e10cSrcweir 284cdf0e10cSrcweir // now create a transformation from this basic range (aTextAnchorRange) 285cdf0e10cSrcweir aAnchorTransform = basegfx::tools::createScaleTranslateB2DHomMatrix( 286cdf0e10cSrcweir aTextAnchorRange.getWidth(), aTextAnchorRange.getHeight(), 287cdf0e10cSrcweir aTextAnchorRange.getMinX(), aTextAnchorRange.getMinY()); 288cdf0e10cSrcweir 289cdf0e10cSrcweir // apply mirroring 290cdf0e10cSrcweir aAnchorTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); 291cdf0e10cSrcweir 292cdf0e10cSrcweir // apply object's other transforms 293cdf0e10cSrcweir aAnchorTransform = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate) 294cdf0e10cSrcweir * aAnchorTransform; 295cdf0e10cSrcweir 296cdf0e10cSrcweir if(rText.isFitToSize()) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir // streched text in range 299cdf0e10cSrcweir pNew = new SdrStretchTextPrimitive2D( 300cdf0e10cSrcweir &rText.getSdrText(), 301cdf0e10cSrcweir rText.getOutlinerParaObject(), 302cdf0e10cSrcweir aAnchorTransform, 303cdf0e10cSrcweir rText.isFixedCellHeight()); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir else // text in range 306cdf0e10cSrcweir { 307cdf0e10cSrcweir // build new primitive 308cdf0e10cSrcweir pNew = new SdrBlockTextPrimitive2D( 309cdf0e10cSrcweir &rText.getSdrText(), 310cdf0e10cSrcweir rText.getOutlinerParaObject(), 311cdf0e10cSrcweir aAnchorTransform, 312cdf0e10cSrcweir rText.getSdrTextHorzAdjust(), 313cdf0e10cSrcweir rText.getSdrTextVertAdjust(), 314cdf0e10cSrcweir rText.isFixedCellHeight(), 315cdf0e10cSrcweir rText.isScroll(), 316cdf0e10cSrcweir bCellText, 317cdf0e10cSrcweir bWordWrap, 318cdf0e10cSrcweir bClipOnBounds); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir OSL_ENSURE(pNew != 0, "createTextPrimitive: no text primitive created (!)"); 323cdf0e10cSrcweir 324cdf0e10cSrcweir if(rText.isBlink()) 325cdf0e10cSrcweir { 326cdf0e10cSrcweir // prepare animation and primitive list 327cdf0e10cSrcweir drawinglayer::animation::AnimationEntryList aAnimationList; 328cdf0e10cSrcweir rText.getBlinkTextTiming(aAnimationList); 329cdf0e10cSrcweir 330cdf0e10cSrcweir if(0.0 != aAnimationList.getDuration()) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir // create content sequence 333cdf0e10cSrcweir const Primitive2DReference xRefA(pNew); 334cdf0e10cSrcweir const Primitive2DSequence aContent(&xRefA, 1L); 335cdf0e10cSrcweir 336cdf0e10cSrcweir // create and add animated switch primitive 337cdf0e10cSrcweir return Primitive2DReference(new AnimatedBlinkPrimitive2D(aAnimationList, aContent, true)); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir else 340cdf0e10cSrcweir { 341cdf0e10cSrcweir // add to decomposition 342cdf0e10cSrcweir return Primitive2DReference(pNew); 343cdf0e10cSrcweir } 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir if(rText.isScroll()) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir // suppress scroll when FontWork 349cdf0e10cSrcweir if(rText.getSdrFormTextAttribute().isDefault()) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir // get scroll direction 352cdf0e10cSrcweir const SdrTextAniDirection eDirection(rText.getSdrText().GetObject().GetTextAniDirection()); 353cdf0e10cSrcweir const bool bHorizontal(SDRTEXTANI_LEFT == eDirection || SDRTEXTANI_RIGHT == eDirection); 354cdf0e10cSrcweir 355cdf0e10cSrcweir // decompose to get separated values for the scroll box 356cdf0e10cSrcweir basegfx::B2DVector aScale, aTranslate; 357cdf0e10cSrcweir double fRotate, fShearX; 358cdf0e10cSrcweir aAnchorTransform.decompose(aScale, aTranslate, fRotate, fShearX); 359cdf0e10cSrcweir 360cdf0e10cSrcweir // build transform from scaled only to full AnchorTransform and inverse 361cdf0e10cSrcweir const basegfx::B2DHomMatrix aSRT(basegfx::tools::createShearXRotateTranslateB2DHomMatrix( 362cdf0e10cSrcweir fShearX, fRotate, aTranslate)); 363cdf0e10cSrcweir basegfx::B2DHomMatrix aISRT(aSRT); 364cdf0e10cSrcweir aISRT.invert(); 365cdf0e10cSrcweir 366cdf0e10cSrcweir // bring the primitive back to scaled only and get scaled range, create new clone for this 367cdf0e10cSrcweir SdrTextPrimitive2D* pNew2 = pNew->createTransformedClone(aISRT); 368cdf0e10cSrcweir OSL_ENSURE(pNew2, "createTextPrimitive: Could not create transformed clone of text primitive (!)"); 369cdf0e10cSrcweir delete pNew; 370cdf0e10cSrcweir pNew = pNew2; 371cdf0e10cSrcweir 372cdf0e10cSrcweir // create neutral geometry::ViewInformation2D for local range and decompose calls. This is okay 373cdf0e10cSrcweir // since the decompose is view-independent 374cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > xViewParameters; 375cdf0e10cSrcweir geometry::ViewInformation2D aViewInformation2D(xViewParameters); 376cdf0e10cSrcweir 377cdf0e10cSrcweir // get range 378cdf0e10cSrcweir const basegfx::B2DRange aScaledRange(pNew->getB2DRange(aViewInformation2D)); 379cdf0e10cSrcweir 380cdf0e10cSrcweir // create left outside and right outside transformations. Also take care 381cdf0e10cSrcweir // of the clip rectangle 382cdf0e10cSrcweir basegfx::B2DHomMatrix aLeft, aRight; 383cdf0e10cSrcweir basegfx::B2DPoint aClipTopLeft(0.0, 0.0); 384cdf0e10cSrcweir basegfx::B2DPoint aClipBottomRight(aScale.getX(), aScale.getY()); 385cdf0e10cSrcweir 386cdf0e10cSrcweir if(bHorizontal) 387cdf0e10cSrcweir { 388cdf0e10cSrcweir aClipTopLeft.setY(aScaledRange.getMinY()); 389cdf0e10cSrcweir aClipBottomRight.setY(aScaledRange.getMaxY()); 390cdf0e10cSrcweir aLeft.translate(-aScaledRange.getMaxX(), 0.0); 391cdf0e10cSrcweir aRight.translate(aScale.getX() - aScaledRange.getMinX(), 0.0); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir else 394cdf0e10cSrcweir { 395cdf0e10cSrcweir aClipTopLeft.setX(aScaledRange.getMinX()); 396cdf0e10cSrcweir aClipBottomRight.setX(aScaledRange.getMaxX()); 397cdf0e10cSrcweir aLeft.translate(0.0, -aScaledRange.getMaxY()); 398cdf0e10cSrcweir aRight.translate(0.0, aScale.getY() - aScaledRange.getMinY()); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir aLeft *= aSRT; 402cdf0e10cSrcweir aRight *= aSRT; 403cdf0e10cSrcweir 404cdf0e10cSrcweir // prepare animation list 405cdf0e10cSrcweir drawinglayer::animation::AnimationEntryList aAnimationList; 406cdf0e10cSrcweir 407cdf0e10cSrcweir if(bHorizontal) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir rText.getScrollTextTiming(aAnimationList, aScale.getX(), aScaledRange.getWidth()); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir else 412cdf0e10cSrcweir { 413cdf0e10cSrcweir rText.getScrollTextTiming(aAnimationList, aScale.getY(), aScaledRange.getHeight()); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir if(0.0 != aAnimationList.getDuration()) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir // create a new Primitive2DSequence containing the animated text in it's scaled only state. 419cdf0e10cSrcweir // use the decomposition to force to simple text primitives, those will no longer 420cdf0e10cSrcweir // need the outliner for formatting (alternatively it is also possible to just add 421cdf0e10cSrcweir // pNew to aNewPrimitiveSequence) 422cdf0e10cSrcweir Primitive2DSequence aAnimSequence(pNew->get2DDecomposition(aViewInformation2D)); 423cdf0e10cSrcweir delete pNew; 424cdf0e10cSrcweir 425cdf0e10cSrcweir // create a new animatedInterpolatePrimitive and add it 426cdf0e10cSrcweir std::vector< basegfx::B2DHomMatrix > aMatrixStack; 427cdf0e10cSrcweir aMatrixStack.push_back(aLeft); 428cdf0e10cSrcweir aMatrixStack.push_back(aRight); 429cdf0e10cSrcweir const Primitive2DReference xRefA(new AnimatedInterpolatePrimitive2D(aMatrixStack, aAnimationList, aAnimSequence, true)); 430cdf0e10cSrcweir const Primitive2DSequence aContent(&xRefA, 1L); 431cdf0e10cSrcweir 432cdf0e10cSrcweir // scrolling needs an encapsulating clipping primitive 433cdf0e10cSrcweir const basegfx::B2DRange aClipRange(aClipTopLeft, aClipBottomRight); 434cdf0e10cSrcweir basegfx::B2DPolygon aClipPolygon(basegfx::tools::createPolygonFromRect(aClipRange)); 435cdf0e10cSrcweir aClipPolygon.transform(aSRT); 436cdf0e10cSrcweir return Primitive2DReference(new MaskPrimitive2D(basegfx::B2DPolyPolygon(aClipPolygon), aContent)); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir else 439cdf0e10cSrcweir { 440cdf0e10cSrcweir // add to decomposition 441cdf0e10cSrcweir return Primitive2DReference(pNew); 442cdf0e10cSrcweir } 443cdf0e10cSrcweir } 444cdf0e10cSrcweir } 445cdf0e10cSrcweir 446cdf0e10cSrcweir if(rText.isInEditMode()) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir // #i97628# 449cdf0e10cSrcweir // encapsulate with TextHierarchyEditPrimitive2D to allow renderers 450cdf0e10cSrcweir // to suppress actively edited content if needed 451cdf0e10cSrcweir const Primitive2DReference xRefA(pNew); 452cdf0e10cSrcweir const Primitive2DSequence aContent(&xRefA, 1L); 453cdf0e10cSrcweir 454cdf0e10cSrcweir // create and add TextHierarchyEditPrimitive2D primitive 455cdf0e10cSrcweir return Primitive2DReference(new TextHierarchyEditPrimitive2D(aContent)); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir else 458cdf0e10cSrcweir { 459cdf0e10cSrcweir // add to decomposition 460cdf0e10cSrcweir return Primitive2DReference(pNew); 461cdf0e10cSrcweir } 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir Primitive2DSequence createEmbeddedShadowPrimitive( 465cdf0e10cSrcweir const Primitive2DSequence& rContent, 466cdf0e10cSrcweir const attribute::SdrShadowAttribute& rShadow) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir if(rContent.hasElements()) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir Primitive2DSequence aRetval(2); 471cdf0e10cSrcweir basegfx::B2DHomMatrix aShadowOffset; 472cdf0e10cSrcweir 473cdf0e10cSrcweir // prepare shadow offset 474cdf0e10cSrcweir aShadowOffset.set(0, 2, rShadow.getOffset().getX()); 475cdf0e10cSrcweir aShadowOffset.set(1, 2, rShadow.getOffset().getY()); 476cdf0e10cSrcweir 477cdf0e10cSrcweir // create shadow primitive and add content 478cdf0e10cSrcweir aRetval[0] = Primitive2DReference( 479cdf0e10cSrcweir new ShadowPrimitive2D( 480cdf0e10cSrcweir aShadowOffset, 481cdf0e10cSrcweir rShadow.getColor(), 482cdf0e10cSrcweir rContent)); 483cdf0e10cSrcweir 484cdf0e10cSrcweir if(0.0 != rShadow.getTransparence()) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir // create SimpleTransparencePrimitive2D 487cdf0e10cSrcweir const Primitive2DSequence aTempContent(&aRetval[0], 1); 488cdf0e10cSrcweir 489cdf0e10cSrcweir aRetval[0] = Primitive2DReference( 490cdf0e10cSrcweir new UnifiedTransparencePrimitive2D( 491cdf0e10cSrcweir aTempContent, 492cdf0e10cSrcweir rShadow.getTransparence())); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir 495cdf0e10cSrcweir aRetval[1] = Primitive2DReference(new GroupPrimitive2D(rContent)); 496cdf0e10cSrcweir return aRetval; 497cdf0e10cSrcweir } 498cdf0e10cSrcweir else 499cdf0e10cSrcweir { 500cdf0e10cSrcweir return rContent; 501cdf0e10cSrcweir } 502cdf0e10cSrcweir } 503cdf0e10cSrcweir } // end of namespace primitive2d 504cdf0e10cSrcweir } // end of namespace drawinglayer 505cdf0e10cSrcweir 506cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 507cdf0e10cSrcweir // eof 508