22#include <com/sun/star/text/WritingMode.hpp>
23#include <com/sun/star/text/WritingMode2.hpp>
24#include <com/sun/star/drawing/TextFitToSizeType.hpp>
25#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
26#include <com/sun/star/text/XTextColumns.hpp>
36#include <oox/token/namespaces.hxx>
37#include <oox/token/properties.hxx>
38#include <oox/token/tokens.hxx>
52 const AttributeList& rAttribs,
54 : TextBodyPropertiesContext(rParent, rAttribs, pShapePtr->getTextBody()->getTextProperties())
56 mpShapePtr = pShapePtr;
59TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper
const & rParent,
60 const AttributeList& rAttribs, TextBodyProperties& rTextBodyProp )
61: ContextHandler2( rParent )
62, mrTextBodyProp( rTextBodyProp )
65 sal_Int32 nWrappingType = rAttribs.getToken( XML_wrap, XML_square );
66 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWordWrap, nWrappingType == XML_square );
70 sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
71 for( sal_Int32
i = 0;
i < sal_Int32(std::size( aIns ));
i++)
73 sValue = rAttribs.getStringDefaulted( aIns[
i] );
74 if( !sValue.isEmpty() )
80 bool bFromWordArt = rAttribs.getBool(XML_fromWordArt,
false);
81 mrTextBodyProp.maPropertyMap.setProperty(PROP_FromWordArt, bFromWordArt);
84 mrTextBodyProp.msHorzOverflow = rAttribs.getStringDefaulted(XML_horzOverflow);
86 mrTextBodyProp.msVertOverflow = rAttribs.getStringDefaulted(XML_vertOverflow);
89 if (
const sal_Int32 nColumns = rAttribs.getInteger(XML_numCol, 0); nColumns > 0)
92 css::uno::UNO_QUERY_THROW);
93 xCols->setColumnCount(nColumns);
94 css::uno::Reference<css::beans::XPropertySet> xProps(xCols, css::uno::UNO_QUERY_THROW);
96 const sal_Int32 nSpacing =
o3tl::convert(rAttribs.getInteger(XML_spcCol, 0),
98 xProps->setPropertyValue(
"AutomaticDistance", css::uno::Any(nSpacing));
99 mrTextBodyProp.maPropertyMap.setAnyProperty(PROP_TextColumns, css::uno::Any(xCols));
103 if (rAttribs.getInteger(XML_rot).has_value())
104 mrTextBodyProp.moTextAreaRotation = rAttribs.getInteger(XML_rot).value();
111 bool bUpright = rAttribs.getBool(XML_upright,
false);
113 mrTextBodyProp.moUpright =
true;
116 if( rAttribs.hasAttribute( XML_vert ) ) {
117 mrTextBodyProp.moVert = rAttribs.getToken( XML_vert );
118 sal_Int32 tVert = mrTextBodyProp.moVert.value_or( XML_horz );
119 if (tVert == XML_eaVert)
121 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextWritingMode, WritingMode_TB_RL);
122 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::TB_RL);
124 else if (tVert == XML_vert)
126 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::TB_RL90);
128 else if (tVert == XML_mongolianVert)
131 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::TB_LR);
133 else if (tVert == XML_vert270)
135 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::BT_LR);
138 bool bRtl = rAttribs.getBool( XML_rtl,
false );
139 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWritingMode,
140 ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ));
141 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode,
142 ( bRtl ? text::WritingMode2::RL_TB : text::WritingMode2::LR_TB));
147 mrTextBodyProp.mbAnchorCtr = rAttribs.getBool(XML_anchorCtr,
false );
148 if (rAttribs.hasAttribute(XML_anchor))
152 sal_Int32 tVert = mrTextBodyProp.moVert.value_or(XML_horz);
153 if (tVert == XML_eaVert || tVert == XML_mongolianVert)
155 if (mrTextBodyProp.mbAnchorCtr)
156 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextVerticalAdjust,
157 TextVerticalAdjust_CENTER);
159 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextVerticalAdjust,
160 TextVerticalAdjust_TOP);
162 if (mrTextBodyProp.meVA == TextVerticalAdjust_CENTER)
163 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextHorizontalAdjust,
164 TextHorizontalAdjust_CENTER);
165 else if (mrTextBodyProp.meVA == TextVerticalAdjust_TOP)
167 mrTextBodyProp.maPropertyMap.setProperty(
168 PROP_TextHorizontalAdjust,
169 tVert == XML_eaVert ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT);
173 mrTextBodyProp.maPropertyMap.setProperty(
174 PROP_TextHorizontalAdjust,
175 tVert == XML_eaVert ? TextHorizontalAdjust_LEFT : TextHorizontalAdjust_RIGHT);
180 if (mrTextBodyProp.mbAnchorCtr)
181 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextHorizontalAdjust,
182 TextHorizontalAdjust_CENTER);
184 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextHorizontalAdjust,
185 TextHorizontalAdjust_BLOCK);
186 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextVerticalAdjust, mrTextBodyProp.meVA);
190 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight,
false);
191 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, drawing::TextFitToSizeType_NONE);
196 switch( aElementToken )
199 case A_TOKEN( prstTxWarp ):
202 const std::optional<OUString> sPrst = rAttribs.
getString( XML_prst );
203 if( sPrst.has_value() )
205 mrTextBodyProp.msPrst = sPrst.value();
206 if( mrTextBodyProp.msPrst !=
"textNoShape" )
208 *( mpShapePtr->getCustomShapeProperties() ) );
213 case A_TOKEN( prot ):
217 case A_TOKEN( noAutofit ):
220 case A_TOKEN( normAutofit ):
222 mrTextBodyProp.maPropertyMap.setProperty(
PROP_TextFitToSize, TextFitToSizeType_AUTOFIT);
224 mrTextBodyProp.mnFontScale = rAttribs.
getInteger(XML_fontScale, 100000);
227 case A_TOKEN( spAutoFit ):
229 const sal_Int32 tVert = mrTextBodyProp.moVert.value_or( XML_horz );
230 if( tVert != XML_vert && tVert != XML_eaVert && tVert != XML_vert270 && tVert != XML_mongolianVert )
235 case A_TOKEN( scene3d ):
237 if(mpShapePtr && mpShapePtr->getServiceName() ==
"com.sun.star.drawing.CustomShape")
244 case A_TOKEN( sp3d ):
246 if (mpShapePtr && mpShapePtr->getServiceName() ==
"com.sun.star.drawing.CustomShape")
249 mpShapePtr->getTextBody()->get3DProperties().mnExtrusionH = rAttribs.
getInteger(XML_extrusionH, 0);
251 mpShapePtr->getTextBody()->get3DProperties().mnContourW = rAttribs.
getInteger(XML_contourW, 0);
253 mpShapePtr->getTextBody()->get3DProperties().mnShapeZ = rAttribs.
getInteger(XML_z, 0);
255 mpShapePtr->getTextBody()->get3DProperties().mnMaterial = rAttribs.
getToken(XML_prstMaterial,
XML_none);
261 case A_TOKEN( flatTx ):
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxXTextColumns_createInstance() noexcept
Provides access to attribute values of an element.
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< OUString > getString(sal_Int32 nAttrToken) const
Returns the string 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.
TextBodyPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttributes, TextBodyProperties &rTextBodyProp)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
TextVerticalAdjust GetTextVerticalAdjust(sal_Int32 nToken)
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm
std::shared_ptr< Shape > ShapePtr
constexpr OUStringLiteral PROP_TextFitToSize
constexpr OUStringLiteral PROP_TextAutoGrowHeight