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