31#include <oox/token/namespaces.hxx>
33#include <com/sun/star/awt/Rectangle.hpp>
56 sal_Int32 nTextAreaRot =
mrShape.
getTextBody()->getTextProperties().moTextAreaRotation.value_or(0);
64bool ConstructPresetTextRectangle(
Shape& rShape, awt::Rectangle& rRect)
75 rRect.Y = rShape.
getPosition().Y + rShape.
getSize().Height * ((1.0 - M_SQRT1_2) / 2.0);
76 rRect.Width = rShape.
getSize().Width * M_SQRT1_2;
77 rRect.Height = rShape.
getSize().Height * M_SQRT1_2;
80 case XML_round2SameRect:
84 double fAdj = aAdjGdList.empty() ? 16667 : aAdjGdList[0].maFormula.toDouble();
85 sal_Int32 nWidth = rShape.
getSize().Width;
86 sal_Int32 nHeight = rShape.
getSize().Height;
87 if (nWidth == 0 || nHeight == 0)
89 double fMaxAdj = 50000.0 * nWidth / std::min(nWidth, nHeight);
90 fAdj = std::clamp<double>(fAdj, 0, fMaxAdj);
91 sal_Int32 nTextLeft = std::min(nWidth, nHeight) * fAdj / 100000.0 * 0.29289;
92 sal_Int32 nTextTop = nTextLeft;
95 rRect.Width = nWidth - 2 * nTextLeft;
96 rRect.Height = nHeight - (
nType == XML_roundRect ? 2 : 1) * nTextTop;
102 double fAdj = aAdjGdList.empty() ? 25000 : aAdjGdList[0].maFormula.toDouble();
103 sal_Int32 nWidth = rShape.
getSize().Width;
104 sal_Int32 nHeight = rShape.
getSize().Height;
105 if (nWidth == 0 || nHeight == 0)
107 double fMaxAdj = 50000.0 * nWidth / std::min(nWidth, nHeight);
108 fAdj = std::clamp<double>(fAdj, 0, fMaxAdj);
109 sal_Int32 nTextLeft = nWidth / 3.0 * fAdj / fMaxAdj;
110 sal_Int32 nTextTop = nHeight / 3.0 * fAdj / fMaxAdj;
113 rRect.Width = nWidth - 2 * nTextLeft;
114 rRect.Height = nHeight - 2 * nTextTop;
117 case XML_flowChartManualOperation:
119 sal_Int32 nWidth = rShape.
getSize().Width;
120 sal_Int32 nTextLeft = nWidth / 5;
123 rRect.Width = nWidth - 2 * nTextLeft;
124 rRect.Height = rShape.
getSize().Height;
129 case XML_wedgeRectCallout:
134 rRect.Width = rShape.
getSize().Width;
135 rRect.Height = rShape.
getSize().Height;
143 if (w <= 0 || h <= 0)
148 if (aAdjGdList.size() == 2)
150 a1 = aAdjGdList[0].maFormula.toDouble();
151 a2 = aAdjGdList[1].maFormula.toDouble();
152 a1 = std::clamp<double>(a1, 0, 20000);
153 a2 = std::clamp<double>(a2, 0, 5358);
155 double th = std::min(w, h) * a1 / 100000.0;
156 double l2 = std::min(w, h) * a2 / 100000.0 / 2.0;
157 double l3 = th / 2.0 + l2;
159 double rh =
h / 2.0 - th;
160 double rw =
w / 2.0 - th;
162 double maxr = std::min(rw, rh);
163 double ha = atan2(l3, maxr);
166 double ta11 = rw * cos(aA1);
167 double ta12 = rh * sin(aA1);
168 double bA1 = atan2(ta12, ta11);
169 double cta1 = rh * cos(bA1);
170 double sta1 = rw * sin(bA1);
171 double ma1 = std::hypot(cta1, sta1);
172 double na1 = rw * rh / ma1;
173 double dxa1 = na1 * cos(bA1);
174 double dya1 = na1 * sin(bA1);
176 double xA1 =
w / 2.0 + dxa1;
177 double yA1 =
h / 2.0 + dya1;
178 double yD2 =
h - yA1;
179 double xD5 =
w - xA1;
183 rRect.Width = xA1 - xD5;
184 rRect.Height = yD2 - yA1;
190 double fAdj = aAdjGdList.empty() ? 25000 : aAdjGdList[0].maFormula.toDouble();
191 sal_Int32 nWidth = rShape.
getSize().Width;
192 sal_Int32 nHeight = rShape.
getSize().Height;
193 if (nWidth == 0 || nHeight == 0)
195 double fMaxAdj = 50000.0 * nWidth / std::min(nWidth, nHeight);
196 fAdj = std::clamp<double>(fAdj, 0, fMaxAdj);
197 double fFactor = fAdj / fMaxAdj / 6.0 + 1.0 / 12.0;
198 sal_Int32 nTextLeft = nWidth * fFactor;
199 sal_Int32 nTextTop = nHeight * fFactor;
202 rRect.Width = nWidth - 2 * nTextLeft;
203 rRect.Height = nHeight - 2 * nTextTop;
208 sal_Int32 nWidth = rShape.
getSize().Width;
209 sal_Int32 nHeight = rShape.
getSize().Height;
210 if (nWidth == 0 || nHeight == 0)
213 double fAdj = aAdjGdList.empty() ? 16667.0 : aAdjGdList[0].maFormula.toDouble();
214 fAdj = std::clamp<double>(fAdj, 0.0, 50000.0);
215 double fDx = std::min(nWidth, nHeight) * fAdj / 100000.0 * 0.29289;
218 rRect.Width = nWidth - fDx;
219 rRect.Height = nHeight;
225 sal_Int32 nWidth = rShape.
getSize().Width;
226 sal_Int32 nHeight = rShape.
getSize().Height;
227 if (nWidth == 0 || nHeight == 0)
232 if (aAdjGdList.size() == 2)
234 a1 = aAdjGdList[0].maFormula.toDouble();
235 a2 = aAdjGdList[1].maFormula.toDouble();
236 a1 = std::clamp<double>(a1, 0, 100000);
238 double maxAdj2 = 100000.0 * nWidth / std::min(nWidth, nHeight);
239 a2 = std::clamp<double>(a2, 0, maxAdj2);
240 double dx1 = std::min(nWidth, nHeight) * a2 / 100000.0;
241 double x1 = nWidth - dx1;
242 double dy1 = nHeight * a1 / 200000.0;
243 double y1 = nHeight / 2.0 - dy1;
244 double y2 = nHeight / 2.0 + dy1;
245 double dx2 = y1 * dx1 / (nHeight / 2.0);
246 double x2 = x1 + dx2;
250 rRect.Height = y2 - y1;
260 return basegfx::B2DPoint(rRect.X + rRect.Width / 2.0, rRect.Y + rRect.Height / 2.0);
273 awt::Rectangle aPresetTextRectangle;
274 if (!ConstructPresetTextRectangle(
mrShape, aPresetTextRectangle))
277 switch (aElementToken)
284 if (!sXValue.isEmpty() && !sYValue.isEmpty())
294 awt::Rectangle aUnrotatedTxXfrm = aPresetTextRectangle;
297 if (!sCXValue.isEmpty() && !sCYValue.isEmpty())
299 aUnrotatedTxXfrm.Width = sCXValue.toInt32();
300 aUnrotatedTxXfrm.Height = sCYValue.toInt32();
320 if (!aXfrmCenter.
equal(aPresetCenter))
326 aUnrotatedTxXfrm.X += aNewCenter.
getX() - aXfrmCenter.getX();
327 aUnrotatedTxXfrm.Y += aNewCenter.
getY() - aXfrmCenter.getY();
334 sal_Int32 nOffsetLeft = aUnrotatedTxXfrm.X - aPresetTextRectangle.X;
335 sal_Int32 nOffsetTop = aUnrotatedTxXfrm.Y - aPresetTextRectangle.Y;
336 sal_Int32 nOffsetRight
337 = aPresetTextRectangle.Width - aUnrotatedTxXfrm.Width - nOffsetLeft;
338 sal_Int32 nOffsetBottom
339 = aPresetTextRectangle.Height - aUnrotatedTxXfrm.Height - nOffsetTop;
360 switch( aElementToken )
368 case A_TOKEN( chOff ):
371 case A_TOKEN( chExt ):
373 sal_Int32 nChExtCx = rAttribs.
getInteger(XML_cx, 0);
378 sal_Int32 nChExtCy = rAttribs.
getInteger(XML_cy, 0);
bool equal(const Tuple2D< TYPE > &rTup) const
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
CustomShapePropertiesPtr & getCustomShapeProperties()
void setSize(css::awt::Size aSize)
const css::awt::Size & getSize() const
void setRotation(sal_Int32 nRotation)
const css::awt::Point & getPosition() const
void setFlip(bool bFlipH, bool bFlipV)
void setChildPosition(css::awt::Point nPosition)
sal_Int32 getRotation() const
void setPosition(css::awt::Point nPosition)
void setChildSize(css::awt::Size aSize)
const TextBodyPtr & getTextBody() const
Transform2DContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttributes, Shape &rShape, bool btxXfrm=false)
context to import a CT_Transform2D
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
std::optional< sal_Int32 > mno_txXfrmOffX
std::optional< sal_Int32 > mno_txXfrmOffY
std::optional< sal_Int32 > mno_txXfrmRot
B2DHomMatrix createRotateAroundPoint(double fPointX, double fPointY, double fRadiant)
constexpr double deg2rad(double v)
::rtl::Reference< ContextHandler > ContextHandlerRef
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm