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 if( rAttribs.hasAttribute(XML_vertOverflow) )
88 mrTextBodyProp.moVertOverflow = rAttribs.getToken(XML_vertOverflow);
89 switch( mrTextBodyProp.moVertOverflow.value_or(XML_overflow) )
93 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextClipVerticalOverflow,
true);
101 if (
const sal_Int32 nColumns = rAttribs.getInteger(XML_numCol, 0); nColumns > 0)
104 css::uno::UNO_QUERY_THROW);
105 xCols->setColumnCount(nColumns);
106 css::uno::Reference<css::beans::XPropertySet> xProps(xCols, css::uno::UNO_QUERY_THROW);
108 const sal_Int32 nSpacing =
o3tl::convert(rAttribs.getInteger(XML_spcCol, 0),
110 xProps->setPropertyValue(
"AutomaticDistance", css::uno::Any(nSpacing));
111 mrTextBodyProp.maPropertyMap.setAnyProperty(PROP_TextColumns, css::uno::Any(xCols));
115 if (rAttribs.getInteger(XML_rot).has_value())
116 mrTextBodyProp.moTextAreaRotation = rAttribs.getInteger(XML_rot).value();
123 bool bUpright = rAttribs.getBool(XML_upright,
false);
125 mrTextBodyProp.moUpright =
true;
128 if( rAttribs.hasAttribute( XML_vert ) ) {
129 mrTextBodyProp.moVert = rAttribs.getToken( XML_vert );
130 sal_Int32 tVert = mrTextBodyProp.moVert.value_or( XML_horz );
131 if (tVert == XML_eaVert)
133 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextWritingMode, WritingMode_TB_RL);
134 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::TB_RL);
136 else if (tVert == XML_vert)
138 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::TB_RL90);
140 else if (tVert == XML_mongolianVert)
143 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::TB_LR);
145 else if (tVert == XML_vert270)
147 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode, text::WritingMode2::BT_LR);
150 bool bRtl = rAttribs.getBool( XML_rtl,
false );
151 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWritingMode,
152 ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ));
153 mrTextBodyProp.maPropertyMap.setProperty(PROP_WritingMode,
154 ( bRtl ? text::WritingMode2::RL_TB : text::WritingMode2::LR_TB));
159 mrTextBodyProp.mbAnchorCtr = rAttribs.getBool(XML_anchorCtr,
false );
160 if (rAttribs.hasAttribute(XML_anchor))
164 sal_Int32 tVert = mrTextBodyProp.moVert.value_or(XML_horz);
165 if (tVert == XML_eaVert || tVert == XML_mongolianVert)
167 if (mrTextBodyProp.mbAnchorCtr)
168 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextVerticalAdjust,
169 TextVerticalAdjust_CENTER);
171 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextVerticalAdjust,
172 TextVerticalAdjust_TOP);
174 if (mrTextBodyProp.meVA == TextVerticalAdjust_CENTER)
175 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextHorizontalAdjust,
176 TextHorizontalAdjust_CENTER);
177 else if (mrTextBodyProp.meVA == TextVerticalAdjust_TOP)
179 mrTextBodyProp.maPropertyMap.setProperty(
180 PROP_TextHorizontalAdjust,
181 tVert == XML_eaVert ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT);
185 mrTextBodyProp.maPropertyMap.setProperty(
186 PROP_TextHorizontalAdjust,
187 tVert == XML_eaVert ? TextHorizontalAdjust_LEFT : TextHorizontalAdjust_RIGHT);
192 if (mrTextBodyProp.mbAnchorCtr)
193 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextHorizontalAdjust,
194 TextHorizontalAdjust_CENTER);
196 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextHorizontalAdjust,
197 TextHorizontalAdjust_BLOCK);
198 mrTextBodyProp.maPropertyMap.setProperty(PROP_TextVerticalAdjust, mrTextBodyProp.meVA);
202 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight,
false);
203 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, drawing::TextFitToSizeType_NONE);
208 switch( aElementToken )
211 case A_TOKEN( prstTxWarp ):
214 const std::optional<OUString> sPrst = rAttribs.
getString( XML_prst );
215 if( sPrst.has_value() )
217 mrTextBodyProp.msPrst = sPrst.value();
218 if( mrTextBodyProp.msPrst !=
"textNoShape" )
220 *( mpShapePtr->getCustomShapeProperties() ) );
225 case A_TOKEN( prot ):
229 case A_TOKEN( noAutofit ):
232 case A_TOKEN( normAutofit ):
234 mrTextBodyProp.maPropertyMap.setProperty(
PROP_TextFitToSize, TextFitToSizeType_AUTOFIT);
236 mrTextBodyProp.mnFontScale = rAttribs.
getInteger(XML_fontScale, 100000);
239 case A_TOKEN( spAutoFit ):
241 const sal_Int32 tVert = mrTextBodyProp.moVert.value_or( XML_horz );
242 if( tVert != XML_vert && tVert != XML_eaVert && tVert != XML_vert270 && tVert != XML_mongolianVert )
247 case A_TOKEN( scene3d ):
249 if(mpShapePtr && mpShapePtr->getServiceName() ==
"com.sun.star.drawing.CustomShape")
256 case A_TOKEN( sp3d ):
258 if (mpShapePtr && mpShapePtr->getServiceName() ==
"com.sun.star.drawing.CustomShape")
261 mpShapePtr->getTextBody()->get3DProperties().mnExtrusionH = rAttribs.
getInteger(XML_extrusionH, 0);
263 mpShapePtr->getTextBody()->get3DProperties().mnContourW = rAttribs.
getInteger(XML_contourW, 0);
265 mpShapePtr->getTextBody()->get3DProperties().mnShapeZ = rAttribs.
getInteger(XML_z, 0);
267 mpShapePtr->getTextBody()->get3DProperties().mnMaterial = rAttribs.
getToken(XML_prstMaterial,
XML_none);
273 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