1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10*f6e50924SAndrew Rist * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f6e50924SAndrew Rist * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19*f6e50924SAndrew Rist * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_svx.hxx" 25cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx> 26cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx> 27cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 28cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx> 29cdf0e10cSrcweir #include <svx/sdr/attribute/sdrtextattribute.hxx> 30cdf0e10cSrcweir #include <basegfx/polygon/b2dpolypolygontools.hxx> 31cdf0e10cSrcweir #include <basegfx/tools/canvastools.hxx> 32cdf0e10cSrcweir #include <drawinglayer/primitive2d/groupprimitive2d.hxx> 33cdf0e10cSrcweir #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> 34cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx> 35cdf0e10cSrcweir #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 38cdf0e10cSrcweir 39cdf0e10cSrcweir using namespace com::sun::star; 40cdf0e10cSrcweir 41cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace drawinglayer 44cdf0e10cSrcweir { 45cdf0e10cSrcweir namespace primitive2d 46cdf0e10cSrcweir { impCreatePart(const attribute::SdrLineAttribute & rLineAttribute,const basegfx::B2DHomMatrix & rObjectMatrix,const basegfx::B2DPoint & rStart,const basegfx::B2DPoint & rEnd,bool bLeftActive,bool bRightActive) const47cdf0e10cSrcweir Primitive2DReference SdrMeasurePrimitive2D::impCreatePart( 48cdf0e10cSrcweir const attribute::SdrLineAttribute& rLineAttribute, 49cdf0e10cSrcweir const basegfx::B2DHomMatrix& rObjectMatrix, 50cdf0e10cSrcweir const basegfx::B2DPoint& rStart, 51cdf0e10cSrcweir const basegfx::B2DPoint& rEnd, 52cdf0e10cSrcweir bool bLeftActive, 53cdf0e10cSrcweir bool bRightActive) const 54cdf0e10cSrcweir { 55cdf0e10cSrcweir const attribute::SdrLineStartEndAttribute& rLineStartEnd = getSdrLSTAttribute().getLineStartEnd(); 56cdf0e10cSrcweir basegfx::B2DPolygon aPolygon; 57cdf0e10cSrcweir 58cdf0e10cSrcweir aPolygon.append(rStart); 59cdf0e10cSrcweir aPolygon.append(rEnd); 60cdf0e10cSrcweir 61cdf0e10cSrcweir if(rLineStartEnd.isDefault() || (!bLeftActive && !bRightActive)) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir return createPolygonLinePrimitive( 64cdf0e10cSrcweir aPolygon, 65cdf0e10cSrcweir rObjectMatrix, 66cdf0e10cSrcweir rLineAttribute, 67cdf0e10cSrcweir attribute::SdrLineStartEndAttribute()); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir if(bLeftActive && bRightActive) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir return createPolygonLinePrimitive( 73cdf0e10cSrcweir aPolygon, 74cdf0e10cSrcweir rObjectMatrix, 75cdf0e10cSrcweir rLineAttribute, 76cdf0e10cSrcweir rLineStartEnd); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir const basegfx::B2DPolyPolygon aEmpty; 80cdf0e10cSrcweir const attribute::SdrLineStartEndAttribute aLineStartEnd( 81cdf0e10cSrcweir bLeftActive ? rLineStartEnd.getStartPolyPolygon() : aEmpty, bRightActive ? rLineStartEnd.getEndPolyPolygon() : aEmpty, 82cdf0e10cSrcweir bLeftActive ? rLineStartEnd.getStartWidth() : 0.0, bRightActive ? rLineStartEnd.getEndWidth() : 0.0, 83cdf0e10cSrcweir bLeftActive ? rLineStartEnd.isStartActive() : false, bRightActive ? rLineStartEnd.isEndActive() : false, 84cdf0e10cSrcweir bLeftActive ? rLineStartEnd.isStartCentered() : false, bRightActive? rLineStartEnd.isEndCentered() : false); 85cdf0e10cSrcweir 86cdf0e10cSrcweir return createPolygonLinePrimitive(aPolygon, rObjectMatrix, rLineAttribute, aLineStartEnd); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir create2DDecomposition(const geometry::ViewInformation2D & aViewInformation) const89cdf0e10cSrcweir Primitive2DSequence SdrMeasurePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const 90cdf0e10cSrcweir { 91cdf0e10cSrcweir Primitive2DSequence aRetval; 92cdf0e10cSrcweir SdrBlockTextPrimitive2D* pBlockText = 0; 93cdf0e10cSrcweir basegfx::B2DRange aTextRange; 94cdf0e10cSrcweir double fTextX((getStart().getX() + getEnd().getX()) * 0.5); 95cdf0e10cSrcweir double fTextY((getStart().getX() + getEnd().getX()) * 0.5); 96cdf0e10cSrcweir const basegfx::B2DVector aLine(getEnd() - getStart()); 97cdf0e10cSrcweir const double fDistance(aLine.getLength()); 98cdf0e10cSrcweir const double fAngle(atan2(aLine.getY(), aLine.getX())); 99cdf0e10cSrcweir bool bAutoUpsideDown(false); 100cdf0e10cSrcweir const attribute::SdrTextAttribute rTextAttribute = getSdrLSTAttribute().getText(); 101cdf0e10cSrcweir const basegfx::B2DHomMatrix aObjectMatrix( 102cdf0e10cSrcweir basegfx::tools::createShearXRotateTranslateB2DHomMatrix(0.0, fAngle, getStart())); 103cdf0e10cSrcweir 104cdf0e10cSrcweir // preapare text, but do not add yet; it needs to be aligned to 105cdf0e10cSrcweir // the line geometry 106cdf0e10cSrcweir if(!rTextAttribute.isDefault()) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir basegfx::B2DHomMatrix aTextMatrix; 109cdf0e10cSrcweir double fTestAngle(fAngle); 110cdf0e10cSrcweir 111cdf0e10cSrcweir if(getTextRotation()) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir aTextMatrix.rotate(-90.0 * F_PI180); 114cdf0e10cSrcweir fTestAngle -= (90.0 * F_PI180); 115cdf0e10cSrcweir 116cdf0e10cSrcweir if(getTextAutoAngle() && fTestAngle < -F_PI) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir fTestAngle += F_2PI; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir if(getTextAutoAngle()) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir if(fTestAngle > (F_PI / 4.0) || fTestAngle < (-F_PI * (3.0 / 4.0))) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir bAutoUpsideDown = true; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir // create primitive and get text range 131cdf0e10cSrcweir pBlockText = new SdrBlockTextPrimitive2D( 132cdf0e10cSrcweir &rTextAttribute.getSdrText(), 133cdf0e10cSrcweir rTextAttribute.getOutlinerParaObject(), 134cdf0e10cSrcweir aTextMatrix, 135cdf0e10cSrcweir SDRTEXTHORZADJUST_CENTER, 136cdf0e10cSrcweir SDRTEXTVERTADJUST_CENTER, 137cdf0e10cSrcweir rTextAttribute.isScroll(), 138cdf0e10cSrcweir false, 139cdf0e10cSrcweir false, 140cdf0e10cSrcweir false, 141cdf0e10cSrcweir false); 142cdf0e10cSrcweir 143cdf0e10cSrcweir aTextRange = pBlockText->getB2DRange(aViewInformation); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir // prepare line attribute and result 147cdf0e10cSrcweir { 148cdf0e10cSrcweir const attribute::SdrLineAttribute rLineAttribute(getSdrLSTAttribute().getLine()); 149cdf0e10cSrcweir bool bArrowsOutside(false); 150cdf0e10cSrcweir bool bMainLineSplitted(false); 151cdf0e10cSrcweir const attribute::SdrLineStartEndAttribute& rLineStartEnd = getSdrLSTAttribute().getLineStartEnd(); 152cdf0e10cSrcweir double fStartArrowW(0.0); 153cdf0e10cSrcweir double fStartArrowH(0.0); 154cdf0e10cSrcweir double fEndArrowW(0.0); 155cdf0e10cSrcweir double fEndArrowH(0.0); 156cdf0e10cSrcweir 157cdf0e10cSrcweir if(!rLineStartEnd.isDefault()) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir if(rLineStartEnd.isStartActive()) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir const basegfx::B2DRange aArrowRange(basegfx::tools::getRange(rLineStartEnd.getStartPolyPolygon())); 162cdf0e10cSrcweir fStartArrowW = rLineStartEnd.getStartWidth(); 163cdf0e10cSrcweir fStartArrowH = aArrowRange.getHeight() * fStartArrowW / aArrowRange.getWidth(); 164cdf0e10cSrcweir 165cdf0e10cSrcweir if(rLineStartEnd.isStartCentered()) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir fStartArrowH *= 0.5; 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir if(rLineStartEnd.isEndActive()) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir const basegfx::B2DRange aArrowRange(basegfx::tools::getRange(rLineStartEnd.getEndPolyPolygon())); 174cdf0e10cSrcweir fEndArrowW = rLineStartEnd.getEndWidth(); 175cdf0e10cSrcweir fEndArrowH = aArrowRange.getHeight() * fEndArrowW / aArrowRange.getWidth(); 176cdf0e10cSrcweir 177cdf0e10cSrcweir if(rLineStartEnd.isEndCentered()) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir fEndArrowH *= 0.5; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir const double fSpaceNeededByArrows(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.5)); 185cdf0e10cSrcweir const double fArrowsOutsideLen((fStartArrowH + fEndArrowH + fStartArrowW + fEndArrowW) * 0.5); 186cdf0e10cSrcweir const double fHalfLineWidth(rLineAttribute.getWidth() * 0.5); 187cdf0e10cSrcweir 188cdf0e10cSrcweir if(fSpaceNeededByArrows > fDistance) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir bArrowsOutside = true; 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir MeasureTextPosition eHorizontal(getHorizontal()); 194cdf0e10cSrcweir MeasureTextPosition eVertical(getVertical()); 195cdf0e10cSrcweir 196cdf0e10cSrcweir if(MEASURETEXTPOSITION_AUTOMATIC == eVertical) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir eVertical = MEASURETEXTPOSITION_NEGATIVE; 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir if(MEASURETEXTPOSITION_CENTERED == eVertical) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir bMainLineSplitted = true; 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir if(MEASURETEXTPOSITION_AUTOMATIC == eHorizontal) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir if(aTextRange.getWidth() > fDistance) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir eHorizontal = MEASURETEXTPOSITION_NEGATIVE; 211cdf0e10cSrcweir } 212cdf0e10cSrcweir else 213cdf0e10cSrcweir { 214cdf0e10cSrcweir eHorizontal = MEASURETEXTPOSITION_CENTERED; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir if(bMainLineSplitted) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir if(aTextRange.getWidth() + fSpaceNeededByArrows > fDistance) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir bArrowsOutside = true; 222cdf0e10cSrcweir } 223cdf0e10cSrcweir } 224cdf0e10cSrcweir else 225cdf0e10cSrcweir { 226cdf0e10cSrcweir const double fSmallArrowNeed(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.125)); 227cdf0e10cSrcweir 228cdf0e10cSrcweir if(aTextRange.getWidth() + fSmallArrowNeed > fDistance) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir bArrowsOutside = true; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir if(MEASURETEXTPOSITION_CENTERED != eHorizontal) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir bArrowsOutside = true; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir // switch text above/below? 241cdf0e10cSrcweir if(getBelow() || (bAutoUpsideDown && !getTextRotation())) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir if(MEASURETEXTPOSITION_NEGATIVE == eVertical) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir eVertical = MEASURETEXTPOSITION_POSITIVE; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir else if(MEASURETEXTPOSITION_POSITIVE == eVertical) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir eVertical = MEASURETEXTPOSITION_NEGATIVE; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir const double fMainLineOffset(getBelow() ? getDistance() : -getDistance()); 254cdf0e10cSrcweir const basegfx::B2DPoint aMainLeft(0.0, fMainLineOffset); 255cdf0e10cSrcweir const basegfx::B2DPoint aMainRight(fDistance, fMainLineOffset); 256cdf0e10cSrcweir 257cdf0e10cSrcweir // main line 258cdf0e10cSrcweir if(bArrowsOutside) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir double fLenLeft(fArrowsOutsideLen); 261cdf0e10cSrcweir double fLenRight(fArrowsOutsideLen); 262cdf0e10cSrcweir 263cdf0e10cSrcweir if(!bMainLineSplitted) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir if(MEASURETEXTPOSITION_NEGATIVE == eHorizontal) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir fLenLeft = fStartArrowH + aTextRange.getWidth(); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir else if(MEASURETEXTPOSITION_POSITIVE == eHorizontal) 270cdf0e10cSrcweir { 271cdf0e10cSrcweir fLenRight = fEndArrowH + aTextRange.getWidth(); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir const basegfx::B2DPoint aMainLeftLeft(aMainLeft.getX() - fLenLeft, aMainLeft.getY()); 276cdf0e10cSrcweir const basegfx::B2DPoint aMainRightRight(aMainRight.getX() + fLenRight, aMainRight.getY()); 277cdf0e10cSrcweir 278cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeftLeft, aMainLeft, false, true)); 279cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainRight, aMainRightRight, true, false)); 280cdf0e10cSrcweir 281cdf0e10cSrcweir if(!bMainLineSplitted || MEASURETEXTPOSITION_CENTERED != eHorizontal) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight, false, false)); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir } 286cdf0e10cSrcweir else 287cdf0e10cSrcweir { 288cdf0e10cSrcweir if(bMainLineSplitted) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir const double fHalfLength((fDistance - (aTextRange.getWidth() + (fStartArrowH + fEndArrowH) * 0.25)) * 0.5); 291cdf0e10cSrcweir const basegfx::B2DPoint aMainInnerLeft(aMainLeft.getX() + fHalfLength, aMainLeft.getY()); 292cdf0e10cSrcweir const basegfx::B2DPoint aMainInnerRight(aMainRight.getX() - fHalfLength, aMainRight.getY()); 293cdf0e10cSrcweir 294cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainInnerLeft, true, false)); 295cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainInnerRight, aMainRight, false, true)); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir else 298cdf0e10cSrcweir { 299cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight, true, true)); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir // left/right help line value preparation 304cdf0e10cSrcweir const double fTopEdge(getBelow() ? getUpper() + getDistance() : -getUpper() - getDistance()); 305cdf0e10cSrcweir const double fBottomLeft(getBelow() ? getLower() - getLeftDelta() : getLeftDelta() - getLower()); 306cdf0e10cSrcweir const double fBottomRight(getBelow() ? getLower() - getRightDelta() : getRightDelta() - getLower()); 307cdf0e10cSrcweir 308cdf0e10cSrcweir // left help line 309cdf0e10cSrcweir const basegfx::B2DPoint aLeftUp(0.0, fTopEdge); 310cdf0e10cSrcweir const basegfx::B2DPoint aLeftDown(0.0, fBottomLeft); 311cdf0e10cSrcweir 312cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aLeftDown, aLeftUp, false, false)); 313cdf0e10cSrcweir 314cdf0e10cSrcweir // right help line 315cdf0e10cSrcweir const basegfx::B2DPoint aRightUp(fDistance, fTopEdge); 316cdf0e10cSrcweir const basegfx::B2DPoint aRightDown(fDistance, fBottomRight); 317cdf0e10cSrcweir 318cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aRightDown, aRightUp, false, false)); 319cdf0e10cSrcweir 320cdf0e10cSrcweir // text horizontal position 321cdf0e10cSrcweir if(MEASURETEXTPOSITION_NEGATIVE == eHorizontal) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir // left 324cdf0e10cSrcweir const double fSmall(fArrowsOutsideLen * 0.18); 325cdf0e10cSrcweir fTextX = aMainLeft.getX() - (fStartArrowH + aTextRange.getWidth() + fSmall + fHalfLineWidth); 326cdf0e10cSrcweir 327cdf0e10cSrcweir if(bMainLineSplitted) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir fTextX -= (fArrowsOutsideLen - fStartArrowH); 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir if(!rTextAttribute.isDefault()) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir fTextX -= rTextAttribute.getTextRightDistance(); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir else if(MEASURETEXTPOSITION_POSITIVE == eHorizontal) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir // right 340cdf0e10cSrcweir const double fSmall(fArrowsOutsideLen * 0.18); 341cdf0e10cSrcweir fTextX = aMainRight.getX() + (fEndArrowH + fSmall + fHalfLineWidth); 342cdf0e10cSrcweir 343cdf0e10cSrcweir if(bMainLineSplitted) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir fTextX += (fArrowsOutsideLen - fEndArrowH); 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir if(!rTextAttribute.isDefault()) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir fTextX += rTextAttribute.getTextLeftDistance(); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir } 353cdf0e10cSrcweir else // MEASURETEXTPOSITION_CENTERED 354cdf0e10cSrcweir { 355cdf0e10cSrcweir // centered 356cdf0e10cSrcweir fTextX = aMainLeft.getX() + ((fDistance - aTextRange.getWidth()) * 0.5); 357cdf0e10cSrcweir 358cdf0e10cSrcweir if(!rTextAttribute.isDefault()) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir fTextX += (rTextAttribute.getTextLeftDistance() - rTextAttribute.getTextRightDistance()) / 2L; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir // text vertical position 365cdf0e10cSrcweir if(MEASURETEXTPOSITION_NEGATIVE == eVertical) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir // top 368cdf0e10cSrcweir const double fSmall(fArrowsOutsideLen * 0.10); 369cdf0e10cSrcweir fTextY = aMainLeft.getY() - (aTextRange.getHeight() + fSmall + fHalfLineWidth); 370cdf0e10cSrcweir 371cdf0e10cSrcweir if(!rTextAttribute.isDefault()) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir fTextY -= rTextAttribute.getTextLowerDistance(); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir } 376cdf0e10cSrcweir else if(MEASURETEXTPOSITION_POSITIVE == eVertical) 377cdf0e10cSrcweir { 378cdf0e10cSrcweir // bottom 379cdf0e10cSrcweir const double fSmall(fArrowsOutsideLen * 0.10); 380cdf0e10cSrcweir fTextY = aMainLeft.getY() + (fSmall + fHalfLineWidth); 381cdf0e10cSrcweir 382cdf0e10cSrcweir if(!rTextAttribute.isDefault()) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir fTextY += rTextAttribute.getTextUpperDistance(); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir } 387cdf0e10cSrcweir else // MEASURETEXTPOSITION_CENTERED 388cdf0e10cSrcweir { 389cdf0e10cSrcweir // centered 390cdf0e10cSrcweir fTextY = aMainLeft.getY() - (aTextRange.getHeight() * 0.5); 391cdf0e10cSrcweir 392cdf0e10cSrcweir if(!rTextAttribute.isDefault()) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir fTextY += (rTextAttribute.getTextUpperDistance() - rTextAttribute.getTextLowerDistance()) / 2L; 395cdf0e10cSrcweir } 396cdf0e10cSrcweir } 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir if(getSdrLSTAttribute().getLine().isDefault()) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir // embed line geometry to invisible (100% transparent) line group for HitTest 402cdf0e10cSrcweir const Primitive2DReference xHiddenLines(new HiddenGeometryPrimitive2D(aRetval)); 403cdf0e10cSrcweir 404cdf0e10cSrcweir aRetval = Primitive2DSequence(&xHiddenLines, 1); 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir if(pBlockText) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir // create transformation to text primitive end position 410cdf0e10cSrcweir basegfx::B2DHomMatrix aChange; 411cdf0e10cSrcweir 412cdf0e10cSrcweir // handle auto text rotation 413cdf0e10cSrcweir if(bAutoUpsideDown) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir aChange.rotate(F_PI); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir // move from aTextRange.TopLeft to fTextX, fTextY 419cdf0e10cSrcweir aChange.translate(fTextX - aTextRange.getMinX(), fTextY - aTextRange.getMinY()); 420cdf0e10cSrcweir 421cdf0e10cSrcweir // apply object matrix 422cdf0e10cSrcweir aChange *= aObjectMatrix; 423cdf0e10cSrcweir 424cdf0e10cSrcweir // apply to existing text primitive 425cdf0e10cSrcweir SdrTextPrimitive2D* pNewBlockText = pBlockText->createTransformedClone(aChange); 426cdf0e10cSrcweir OSL_ENSURE(pNewBlockText, "SdrMeasurePrimitive2D::create2DDecomposition: Could not create transformed clone of text primitive (!)"); 427cdf0e10cSrcweir delete pBlockText; 428cdf0e10cSrcweir 429cdf0e10cSrcweir // add to local primitives 430cdf0e10cSrcweir appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, Primitive2DReference(pNewBlockText)); 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir // add shadow 434cdf0e10cSrcweir if(!getSdrLSTAttribute().getShadow().isDefault()) 435cdf0e10cSrcweir { 436cdf0e10cSrcweir aRetval = createEmbeddedShadowPrimitive( 437cdf0e10cSrcweir aRetval, 438cdf0e10cSrcweir getSdrLSTAttribute().getShadow()); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir return aRetval; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir SdrMeasurePrimitive2D(const attribute::SdrLineShadowTextAttribute & rSdrLSTAttribute,const basegfx::B2DPoint & rStart,const basegfx::B2DPoint & rEnd,MeasureTextPosition eHorizontal,MeasureTextPosition eVertical,double fDistance,double fUpper,double fLower,double fLeftDelta,double fRightDelta,bool bBelow,bool bTextRotation,bool bTextAutoAngle)444cdf0e10cSrcweir SdrMeasurePrimitive2D::SdrMeasurePrimitive2D( 445cdf0e10cSrcweir const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute, 446cdf0e10cSrcweir const basegfx::B2DPoint& rStart, 447cdf0e10cSrcweir const basegfx::B2DPoint& rEnd, 448cdf0e10cSrcweir MeasureTextPosition eHorizontal, 449cdf0e10cSrcweir MeasureTextPosition eVertical, 450cdf0e10cSrcweir double fDistance, 451cdf0e10cSrcweir double fUpper, 452cdf0e10cSrcweir double fLower, 453cdf0e10cSrcweir double fLeftDelta, 454cdf0e10cSrcweir double fRightDelta, 455cdf0e10cSrcweir bool bBelow, 456cdf0e10cSrcweir bool bTextRotation, 457cdf0e10cSrcweir bool bTextAutoAngle) 458cdf0e10cSrcweir : BufferedDecompositionPrimitive2D(), 459cdf0e10cSrcweir maSdrLSTAttribute(rSdrLSTAttribute), 460cdf0e10cSrcweir maStart(rStart), 461cdf0e10cSrcweir maEnd(rEnd), 462cdf0e10cSrcweir meHorizontal(eHorizontal), 463cdf0e10cSrcweir meVertical(eVertical), 464cdf0e10cSrcweir mfDistance(fDistance), 465cdf0e10cSrcweir mfUpper(fUpper), 466cdf0e10cSrcweir mfLower(fLower), 467cdf0e10cSrcweir mfLeftDelta(fLeftDelta), 468cdf0e10cSrcweir mfRightDelta(fRightDelta), 469cdf0e10cSrcweir mbBelow(bBelow), 470cdf0e10cSrcweir mbTextRotation(bTextRotation), 471cdf0e10cSrcweir mbTextAutoAngle(bTextAutoAngle) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir } 474cdf0e10cSrcweir operator ==(const BasePrimitive2D & rPrimitive) const475cdf0e10cSrcweir bool SdrMeasurePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 476cdf0e10cSrcweir { 477cdf0e10cSrcweir if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir const SdrMeasurePrimitive2D& rCompare = (SdrMeasurePrimitive2D&)rPrimitive; 480cdf0e10cSrcweir 481cdf0e10cSrcweir return (getStart() == rCompare.getStart() 482cdf0e10cSrcweir && getEnd() == rCompare.getEnd() 483cdf0e10cSrcweir && getHorizontal() == rCompare.getHorizontal() 484cdf0e10cSrcweir && getVertical() == rCompare.getVertical() 485cdf0e10cSrcweir && getDistance() == rCompare.getDistance() 486cdf0e10cSrcweir && getUpper() == rCompare.getUpper() 487cdf0e10cSrcweir && getLower() == rCompare.getLower() 488cdf0e10cSrcweir && getLeftDelta() == rCompare.getLeftDelta() 489cdf0e10cSrcweir && getRightDelta() == rCompare.getRightDelta() 490cdf0e10cSrcweir && getBelow() == rCompare.getBelow() 491cdf0e10cSrcweir && getTextRotation() == rCompare.getTextRotation() 492cdf0e10cSrcweir && getTextAutoAngle() == rCompare.getTextAutoAngle() 493cdf0e10cSrcweir && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute()); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir return false; 497cdf0e10cSrcweir } 498cdf0e10cSrcweir 499cdf0e10cSrcweir // provide unique ID 500cdf0e10cSrcweir ImplPrimitrive2DIDBlock(SdrMeasurePrimitive2D, PRIMITIVE2D_ID_SDRMEASUREPRIMITIVE2D) 501cdf0e10cSrcweir 502cdf0e10cSrcweir } // end of namespace primitive2d 503cdf0e10cSrcweir } // end of namespace drawinglayer 504cdf0e10cSrcweir 505cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 506cdf0e10cSrcweir // eof 507