26 #include <rtl/ref.hxx>
30 #include <osl/diagnose.h>
44 bool bRightActive)
const
53 if(rLineStartEnd.
isDefault() || (!bLeftActive && !bRightActive))
61 if(bLeftActive && bRightActive)
88 const double fDistance(aLine.
getLength());
89 const double fAngle(atan2(aLine.
getY(), aLine.
getX()));
90 bool bAutoUpsideDown(
false);
100 double fTestAngle(fAngle);
102 if(getTextRotation())
104 aTextMatrix.
rotate(-M_PI_2);
105 fTestAngle -= (M_PI_2);
107 if(getTextAutoAngle() && fTestAngle < -M_PI)
109 fTestAngle += 2 * M_PI;
113 if(getTextAutoAngle())
115 if(fTestAngle > (M_PI / 4.0) || fTestAngle < (-M_PI * (3.0 / 4.0)))
117 bAutoUpsideDown =
true;
133 aTextRange = xBlockText->getB2DRange(aViewInformation);
141 bool bArrowsOutside(
false);
142 bool bMainLineSplitted(
false);
144 double fStartArrowW(0.0);
145 double fStartArrowH(0.0);
146 double fEndArrowW(0.0);
147 double fEndArrowH(0.0);
176 const double fSpaceNeededByArrows(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.5));
177 const double fArrowsOutsideLen((fStartArrowH + fEndArrowH + fStartArrowW + fEndArrowW) * 0.5);
178 const double fHalfLineWidth(rLineAttribute.
getWidth() * 0.5);
180 if(fSpaceNeededByArrows > fDistance)
182 bArrowsOutside =
true;
195 bMainLineSplitted =
true;
200 if(aTextRange.
getWidth() > fDistance)
209 if(bMainLineSplitted)
211 if(aTextRange.
getWidth() + fSpaceNeededByArrows > fDistance)
213 bArrowsOutside =
true;
218 const double fSmallArrowNeed(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.125));
220 if(aTextRange.
getWidth() + fSmallArrowNeed > fDistance)
222 bArrowsOutside =
true;
229 bArrowsOutside =
true;
233 if(getBelow() || (bAutoUpsideDown && !getTextRotation()))
245 const double fMainLineOffset(getBelow() ? getDistance() : -getDistance());
252 double fLenLeft(fArrowsOutsideLen);
253 double fLenRight(fArrowsOutsideLen);
255 if(!bMainLineSplitted)
259 fLenLeft = fStartArrowH + aTextRange.
getWidth();
263 fLenRight = fEndArrowH + aTextRange.
getWidth();
270 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aMainLeftLeft, aMainLeft,
false,
true));
271 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aMainRight, aMainRightRight,
true,
false));
275 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight,
false,
false));
280 if(bMainLineSplitted)
282 const double fHalfLength((fDistance - (aTextRange.
getWidth() + (fStartArrowH + fEndArrowH) * 0.25)) * 0.5);
286 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainInnerLeft,
true,
false));
287 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aMainInnerRight, aMainRight,
false,
true));
291 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight,
true,
true));
296 const double fTopEdge(getBelow() ? getUpper() + getDistance() : -getUpper() - getDistance());
297 const double fBottomLeft(getBelow() ? getLower() - getLeftDelta() : getLeftDelta() - getLower());
298 const double fBottomRight(getBelow() ? getLower() - getRightDelta() : getRightDelta() - getLower());
304 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aLeftDown, aLeftUp,
false,
false));
310 aRetval.push_back(impCreatePart(rLineAttribute, aObjectMatrix, aRightDown, aRightUp,
false,
false));
316 const double fSmall(fArrowsOutsideLen * 0.18);
317 fTextX = aMainLeft.
getX() - (fStartArrowH + aTextRange.
getWidth() + fSmall + fHalfLineWidth);
319 if(bMainLineSplitted)
321 fTextX -= (fArrowsOutsideLen - fStartArrowH);
332 const double fSmall(fArrowsOutsideLen * 0.18);
333 fTextX = aMainRight.
getX() + (fEndArrowH + fSmall + fHalfLineWidth);
335 if(bMainLineSplitted)
337 fTextX += (fArrowsOutsideLen - fEndArrowH);
348 fTextX = aMainLeft.
getX() + ((fDistance - aTextRange.
getWidth()) * 0.5);
360 const double fSmall(fArrowsOutsideLen * 0.10);
361 fTextY = aMainLeft.
getY() - (aTextRange.
getHeight() + fSmall + fHalfLineWidth);
371 const double fSmall(fArrowsOutsideLen * 0.10);
372 fTextY = aMainLeft.
getY() + (fSmall + fHalfLineWidth);
391 if(getSdrLSTAttribute().getLine().isDefault())
414 aChange *= aObjectMatrix;
418 OSL_ENSURE(pNewBlockText,
"SdrMeasurePrimitive2D::create2DDecomposition: Could not create transformed clone of text primitive (!)");
422 aRetval.push_back(pNewBlockText);
426 if(!getSdrLSTAttribute().getShadow().isDefault())
430 getSdrLSTAttribute().getShadow());
433 rContainer.insert(rContainer.end(), aRetval.begin(), aRetval.end());
436 SdrMeasurePrimitive2D::SdrMeasurePrimitive2D(
450 : maSdrLSTAttribute(rSdrLSTAttribute),
453 meHorizontal(eHorizontal),
454 meVertical(eVertical),
455 mfDistance(fDistance),
458 mfLeftDelta(fLeftDelta),
459 mfRightDelta(fRightDelta),
461 mbTextRotation(bTextRotation),
462 mbTextAutoAngle(bTextAutoAngle)
468 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
MeasureTextPosition getVertical() const
sal_Int32 getTextUpperDistance() const
double getRightDelta() const
sal_Int32 getTextRightDistance() const
const basegfx::B2DPoint & getStart() const
const basegfx::B2DPolyPolygon & getStartPolyPolygon() const
double getDistance() const
Primitive2DContainer createEmbeddedShadowPrimitive(Primitive2DContainer &&rContent, const attribute::SdrShadowAttribute &rShadow, const basegfx::B2DHomMatrix &rObjectMatrix, const Primitive2DContainer *pContentForShadow)
double getLeftDelta() const
virtual sal_uInt32 getPrimitive2DID() const override
double getStartWidth() const
const OutlinerParaObject & getOutlinerParaObject() const
const basegfx::B2DPolyPolygon & getEndPolyPolygon() const
void rotate(double fRadiant)
const attribute::SdrLineEffectsTextAttribute & getSdrLSTAttribute() const
MeasureTextPosition getHorizontal() const
B2DRange getRange(const B2DPolygon &rCandidate)
sal_Int32 getTextLowerDistance() const
void transform(const basegfx::B2DHomMatrix &rMatrix)
bool getTextRotation() const
bool getTextAutoAngle() const
virtual bool operator==(const BasePrimitive2D &rPrimitive) const override
bool isStartCentered() const
sal_Int32 getTextLeftDistance() const
const SdrText & getSdrText() const
#define PRIMITIVE2D_ID_SDRMEASUREPRIMITIVE2D
bool isStartActive() const
void translate(double fX, double fY)
const basegfx::B2DPoint & getEnd() const
bool isEndCentered() const
B2DHomMatrix createShearXRotateTranslateB2DHomMatrix(double fShearX, double fRadiant, double fTranslateX, double fTranslateY)
Primitive2DReference createPolygonLinePrimitive(const basegfx::B2DPolygon &rPolygon, const attribute::SdrLineAttribute &rLine, const attribute::SdrLineStartEndAttribute &rStroke)
double getEndWidth() const