22#include <com/sun/star/text/WritingMode2.hpp>
23#include <com/sun/star/style/ParagraphAdjust.hpp>
24#include <com/sun/star/xml/sax/SAXException.hpp>
25#include <com/sun/star/graphic/XGraphic.hpp>
26#include <com/sun/star/awt/Size.hpp>
27#include <com/sun/star/uno/Reference.hxx>
40#include <oox/token/namespaces.hxx>
41#include <oox/token/properties.hxx>
42#include <oox/token/tokens.hxx>
54double lclGetGraphicAspectRatio(
const Reference< XGraphic >& rxGraphic )
57 Reference< com::sun::star::beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
58 css::awt::Size aSizeHmm( 0, 0 );
59 xGraphicPropertySet->getPropertyValue(
"Size100thMM" ) >>= aSizeHmm;
61 if( aSizeHmm.Width > 0 && aSizeHmm.Height > 0)
62 return double(aSizeHmm.Width)/double(aSizeHmm.Height);
65 css::awt::Size aSourceSizePixel( 0, 0 );
66 xGraphicPropertySet->getPropertyValue(
"SizePixel" ) >>= aSourceSizePixel;
68 if( aSourceSizePixel.Width > 0 && aSourceSizePixel.Height > 0 )
69 return double(aSourceSizePixel.Width)/double(aSourceSizePixel.Height);
81, mrTextParagraphProperties( rTextParagraphProperties )
82, mrBulletList( rTextParagraphProperties.getBulletList() )
108 bool bLatinLineBrk = rAttribs.
getBool( XML_latinLnBrk,
true );
119 bool bHangingPunct = rAttribs.
getBool( XML_hangingPunct,
false );
132 sal_Int32 nLevel = rAttribs.
getInteger( XML_lvl, 0 );
133 if( nLevel > 8 || nLevel < 0 )
140 char name[] =
"Outline X";
141 name[8] =
static_cast<char>(
'1' + nLevel );
142 const OUString sStyleNameValue( OUString::createFromAscii(
name ) );
157 sal_Int32 nMarR = sValue.isEmpty() ? 0 :
GetCoordinate( sValue ) ;
163 bool bRtl = rAttribs.
getBool( XML_rtl,
false );
176 ::std::vector< TabStop >::size_type nTabCount =
maTabList.size();
181 OSL_ENSURE( aArray !=
nullptr,
"sequence array is NULL" );
195 rPropertyMap.
setProperty( PROP_NumberingLevel, nLevel);
196 rPropertyMap.
setProperty( PROP_NumberingIsNumber,
true);
204 switch( aElementToken )
206 case A_TOKEN( lnSpc ):
208 case A_TOKEN( spcBef ):
210 case A_TOKEN( spcAft ):
213 case A_TOKEN( buClrTx ):
216 case A_TOKEN( buClr ):
219 case A_TOKEN( buSzTx ):
222 case A_TOKEN( buSzPct ):
225 case A_TOKEN( buSzPts ):
231 case A_TOKEN( buFontTx ):
234 case A_TOKEN( buFont ):
239 case A_TOKEN( buNone ):
242 case A_TOKEN( buAutoNum ):
246 sal_Int32 nStartAt = rAttribs.
getInteger( XML_startAt, 1 );
247 if( nStartAt > 32767 )
251 else if( nStartAt < 1 )
258 catch(SAXException& )
264 case A_TOKEN( buChar ):
270 catch(SAXException& )
275 case A_TOKEN( buBlip ):
277 mxBlipProps = std::make_shared<BlipFillProperties>();
280 case A_TOKEN( tabLst ):
282 case A_TOKEN( defRPr ):
286 std::optional< OUString > oParaAdjust = rAttribs.
getString( W_TOKEN(val) );
287 if( oParaAdjust.has_value() && !oParaAdjust.value().isEmpty() )
289 const OUString& sParaAdjust = oParaAdjust.value();
290 if( sParaAdjust ==
"left" )
292 else if ( sParaAdjust ==
"right" )
294 else if ( sParaAdjust ==
"center" )
296 else if ( sParaAdjust ==
"both" )
301 case W_TOKEN( spacing ):
304 if( !rAttribs.
getBool(W_TOKEN(beforeAutospacing),
false) )
306 std::optional<sal_Int32> oBefore = rAttribs.
getInteger(W_TOKEN(before));
307 if (oBefore.has_value())
316 std::optional<sal_Int32> oBeforeLines = rAttribs.
getInteger(W_TOKEN(beforeLines));
317 if (oBeforeLines.has_value())
328 if( !rAttribs.
getBool(W_TOKEN(afterAutospacing),
false) )
330 std::optional<sal_Int32> oAfter = rAttribs.
getInteger(W_TOKEN(after));
331 if (oAfter.has_value())
340 std::optional<sal_Int32> oAfterLines = rAttribs.
getInteger(W_TOKEN(afterLines));
341 if (oAfterLines.has_value())
352 std::optional<OUString> oLineRule = rAttribs.
getString(W_TOKEN(lineRule));
353 std::optional<sal_Int32> oLineSpacing = rAttribs.
getInteger(W_TOKEN(
line));
354 if (oLineSpacing.has_value())
357 if( !oLineRule.has_value() || oLineRule.value() ==
"auto" )
372 SAL_WARN(
"oox",
"TextParagraphPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
constexpr auto convertTwipToMm100(N n)
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< 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.
A helper that maps property identifiers to property values.
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
Context handler that imports the a:blipFill element.
css::uno::Any mbBulletFontFollowText
void setBulletAspectRatio(double nAspectRatio)
void setBulletSize(sal_Int16 nSize)
void setStartAt(sal_Int32 nStartAt)
void setBulletChar(const OUString &sChar)
void setType(sal_Int32 nType)
css::uno::Any mbBulletSizeFollowText
void setFontSize(sal_Int16 nSize)
void setGraphic(css::uno::Reference< css::graphic::XGraphic > const &rXGraphic)
void setStyleName(const OUString &rStyleName)
::oox::drawingml::TextFont maBulletFont
std::shared_ptr< ::oox::drawingml::Color > maBulletColorPtr
css::uno::Any mbBulletColorFollowText
Context handler for elements that contain a color value element (a:scrgbClr, a:srgbClr,...
void setAttributes(const AttributeList &rAttribs)
Sets attributes from the passed attribute list.
TextParagraphProperties & mrTextParagraphProperties
virtual ~TextParagraphPropertiesContext() override
TextParagraphPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttributes, TextParagraphProperties &rTextParagraphProperties)
BulletList & mrBulletList
std::shared_ptr< BlipFillProperties > mxBlipProps
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
std::vector< css::style::TabStop > maTabList
std::optional< sal_Int32 > & getParaLeftMargin()
std::optional< sal_Int32 > & getFirstLineIndentation()
TextSpacing & getParaTopMargin()
std::optional< sal_Int32 > & getDefaultTabSize()
std::optional< css::style::ParagraphAdjust > & getParaAdjust()
TextCharacterProperties & getTextCharacterProperties()
TextSpacing & getParaBottomMargin()
sal_Int16 getLevel() const
void setLevel(sal_Int16 nLevel)
TextSpacing & getLineSpacing()
void setParaAdjust(css::style::ParagraphAdjust nParaAdjust)
PropertyMap & getTextParagraphPropertyMap()
css::style::LineSpacing toLineSpacing() const
#define TOOLS_WARN_EXCEPTION(area, stream)
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm
ParagraphAdjust GetParaAdjust(sal_Int32 nAlign)
converts a paragraph align to a ParaAdjust
const sal_Int32 MAX_PERCENT
sal_Int32 GetPercent(std::u16string_view sValue)
converts a ST_Percentage % string into 1/1000th of %
float GetTextSize(std::u16string_view sValue)
converts the ST_TextFontSize to point
constexpr OUStringLiteral PROP_WritingMode
constexpr OUStringLiteral PROP_ParaIsHyphenation
constexpr OUStringLiteral PROP_ParaTabStops
constexpr OUStringLiteral PROP_ParaRightMargin
constexpr OUStringLiteral PROP_ParaLineSpacing
constexpr OUStringLiteral PROP_ParaIsHangingPunctuation
constexpr OUStringLiteral PROP_ParaAdjust