16#include <com/sun/star/beans/XPropertySet.hpp>
17#include <com/sun/star/beans/XPropertyState.hpp>
18#include <com/sun/star/container/XEnumerationAccess.hpp>
19#include <com/sun/star/drawing/HomogenMatrix3.hpp>
20#include <com/sun/star/lang/XServiceInfo.hpp>
21#include <com/sun/star/text/XText.hpp>
22#include <com/sun/star/text/XTextCursor.hpp>
23#include <com/sun/star/text/WritingMode.hpp>
26#include <oox/token/namespaces.hxx>
27#include <oox/token/tokens.hxx>
48 if (
const auto pParent =
dynamic_cast<const WpgContext*
>(&rParent))
59 switch (getBaseToken(nElementToken))
67 uno::Reference<lang::XServiceInfo> xServiceInfo(
mxShape, uno::UNO_QUERY);
68 uno::Reference<beans::XPropertySet> xPropertySet(
mxShape, uno::UNO_QUERY);
69 sal_Int32 nVert = rAttribs.
getToken(XML_vert, XML_horz);
70 if (nVert == XML_eaVert)
72 xPropertySet->setPropertyValue(
"TextWritingMode",
75 else if (nVert != XML_horz)
78 drawing::HomogenMatrix3 aMatrix;
79 xPropertySet->getPropertyValue(
"Transformation") >>= aMatrix;
81 aTransformation.
set(0, 0, aMatrix.Line1.Column1);
82 aTransformation.
set(0, 1, aMatrix.Line1.Column2);
83 aTransformation.
set(0, 2, aMatrix.Line1.Column3);
84 aTransformation.
set(1, 0, aMatrix.Line1.Column1);
85 aTransformation.
set(1, 1, aMatrix.Line2.Column2);
86 aTransformation.
set(1, 2, aMatrix.Line3.Column3);
87 aTransformation.
set(2, 0, aMatrix.Line1.Column1);
88 aTransformation.
set(2, 1, aMatrix.Line2.Column2);
89 aTransformation.
set(2, 2, aMatrix.Line3.Column3);
94 aTransformation.
decompose(aScale, aTranslate, fRotate, fShearX);
97 const sal_Int32 nRotation = nVert == XML_vert270 ? -270 : -90;
102 xPropertySet->getPropertyValue(
"CustomShapeGeometry"));
103 aCustomShapeGeometry[
"TextPreRotateAngle"] <<= nRotation;
104 xPropertySet->setPropertyValue(
105 "CustomShapeGeometry",
110 if (
bool bUpright = rAttribs.
getBool(XML_upright,
false))
112 uno::Sequence<beans::PropertyValue> aGrabBag;
113 xPropertySet->getPropertyValue(
"InteropGrabBag") >>= aGrabBag;
114 sal_Int32
length = aGrabBag.getLength();
115 aGrabBag.realloc(
length + 1);
116 auto pGrabBag = aGrabBag.getArray();
117 pGrabBag[
length].Name =
"Upright";
118 pGrabBag[
length].Value <<= bUpright;
119 xPropertySet->setPropertyValue(
"InteropGrabBag",
uno::Any(aGrabBag));
122 if (xServiceInfo.is())
125 sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
126 std::optional<sal_Int32> oInsets[4];
129 std::optional<OUString> oValue = rAttribs.
getString(aInsets[
i]);
130 if (oValue.has_value())
135 = (aInsets[
i] == XML_lIns || aInsets[
i] == XML_rIns) ? 254 : 127;
137 const OUString aShapeProps[]
138 = { OUString(
"TextLeftDistance"), OUString(
"TextUpperDistance"),
139 OUString(
"TextRightDistance"), OUString(
"TextLowerDistance") };
142 xPropertySet->setPropertyValue(aShapeProps[
i],
uno::Any(*oInsets[
i]));
148 drawing::TextVerticalAdjust eAdjust
150 xPropertySet->setPropertyValue(
"TextVerticalAdjust",
uno::Any(eAdjust));
154 uno::Reference<text::XText> xText(
mxShape, uno::UNO_QUERY);
155 uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor();
156 xTextCursor->gotoStart(
false);
157 xTextCursor->gotoEnd(
true);
158 uno::Reference<beans::XPropertySet> xTextBoxPropertySet(xTextCursor,
160 uno::Any xCharColor = xPropertySet->getPropertyValue(
"CharColor");
162 if ((xCharColor >>= aColor) && aColor !=
COL_AUTO)
164 const uno::Reference<beans::XPropertyState> xPropertyState(xTextCursor,
166 const beans::PropertyState ePropertyState
167 = xPropertyState->getPropertyState(
"CharColor");
168 if (ePropertyState == beans::PropertyState_DEFAULT_VALUE)
170 xTextBoxPropertySet->setPropertyValue(
"CharColor", xCharColor);
176 uno::Reference<container::XEnumerationAccess> paraEnumAccess(
177 xText, uno::UNO_QUERY);
178 if (paraEnumAccess.is())
180 uno::Reference<container::XEnumeration> paraEnum(
181 paraEnumAccess->createEnumeration());
183 while (paraEnum->hasMoreElements())
185 uno::Reference<text::XTextRange> xParagraph(paraEnum->nextElement(),
187 uno::Reference<container::XEnumerationAccess> runEnumAccess(
188 xParagraph, uno::UNO_QUERY);
189 if (!runEnumAccess.is())
192 uno::Reference<container::XEnumeration> runEnum
193 = runEnumAccess->createEnumeration();
195 while (runEnum->hasMoreElements())
197 uno::Reference<text::XTextRange> xRun(runEnum->nextElement(),
199 const uno::Reference<beans::XPropertyState> xRunState(
200 xRun, uno::UNO_QUERY);
201 if (xRunState->getPropertyState(
"CharColor")
202 == beans::PropertyState_DEFAULT_VALUE)
204 uno::Reference<beans::XPropertySet> xRunPropSet(
205 xRun, uno::UNO_QUERY);
206 xRunPropSet->setPropertyValue(
"CharColor", xCharColor);
214 auto nWrappingType = rAttribs.
getToken(XML_wrap, XML_square);
215 xPropertySet->setPropertyValue(
"TextWordWrap",
216 uno::Any(nWrappingType == XML_square));
231 drawing::TextVerticalAdjust eAdjust
233 pTextBody->getTextProperties().meVA = eAdjust;
236 sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
237 for (
int i = 0;
i < 4; ++
i)
241 std::optional<OUString> oValue = rAttribs.
getString(aInsets[
i]);
242 if (oValue.has_value())
243 pTextBody->getTextProperties().moInsets[
i]
247 pTextBody->getTextProperties().moInsets[
i]
248 = (aInsets[
i] == XML_lIns || aInsets[
i] == XML_rIns) ? 254 : 127;
258 uno::Reference<lang::XServiceInfo> xServiceInfo(
mxShape, uno::UNO_QUERY);
262 uno::Reference<beans::XPropertySet> xPropertySet(
mxShape, uno::UNO_QUERY);
263 if (xPropertySet.is())
265 if (xServiceInfo->supportsService(
"com.sun.star.text.TextFrame"))
266 xPropertySet->setPropertyValue(
267 "FrameIsAutomaticHeight",
268 uno::Any(getBaseToken(nElementToken) == XML_spAutoFit));
270 xPropertySet->setPropertyValue(
271 "TextAutoGrowHeight",
272 uno::Any(getBaseToken(nElementToken) == XML_spAutoFit));
279 uno::Reference<beans::XPropertySet> xPropertySet(
mxShape, uno::UNO_QUERY);
280 if (xPropertySet.is())
282 std::optional<OUString> presetShapeName = rAttribs.
getString(XML_prst);
283 const OUString& preset = presetShapeName.value();
285 xPropertySet->getPropertyValue(
"CustomShapeGeometry"));
286 aCustomShapeGeometry[
"PresetTextWarp"] <<= preset;
287 xPropertySet->setPropertyValue(
288 "CustomShapeGeometry",
295 mpShapePtr->getCustomShapeProperties()->setShapeTypeOverride(
true);
301 std::optional<OUString>
id = rAttribs.
getString(XML_id);
305 linkedTxtBoxAttr.
id =
id.value().toInt32();
307 mpShapePtr->setLinkedTxbxAttributes(linkedTxtBoxAttr);
317 mpShapePtr->getCustomShapeProperties()->setShapeTypeOverride(
true);
319 std::optional<OUString>
id = rAttribs.
getString(XML_id);
320 std::optional<OUString> seq = rAttribs.
getString(XML_seq);
321 if (
id.has_value() && seq.has_value())
324 linkedTxtBoxAttr.
id =
id.value().toInt32();
325 linkedTxtBoxAttr.
seq = seq.value().toInt32();
327 mpShapePtr->setLinkedTxbxAttributes(linkedTxtBoxAttr);
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
Provides access to attribute values of an element.
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
Helper class that provides a context stack.
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
Wpg is the drawingML equivalent of v:group.
oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElementToken, const oox::AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
WpsContext(oox::core::ContextHandler2Helper const &rParent, css::uno::Reference< css::drawing::XShape > xShape, oox::drawingml::ShapePtr const &pMasterShapePtr, oox::drawingml::ShapePtr const &pShapePtr)
css::uno::Reference< css::drawing::XShape > mxShape
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define SAL_N_ELEMENTS(arr)
constexpr double rad2deg(double v)
TextVerticalAdjust GetTextVerticalAdjust(sal_Int32 nToken)
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm
std::shared_ptr< Shape > ShapePtr
std::shared_ptr< TextBody > TextBodyPtr
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
uno::Reference< drawing::XShape > const mxShape
Attributes for a linked textbox.
SVXCORE_DLLPUBLIC Degree100 NormAngle36000(Degree100 a)