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>
54 double 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() )
104 bool bLatinLineBrk = rAttribs.
getBool( XML_latinLnBrk,
true );
105 rPropertyMap.setProperty( PROP_ParaIsHyphenation, bLatinLineBrk);
115 bool bHangingPunct = rAttribs.
getBool( XML_hangingPunct,
false );
116 rPropertyMap.setProperty( PROP_ParaIsHangingPunctuation, bHangingPunct);
128 sal_Int32 nLevel = rAttribs.
getInteger( XML_lvl, 0 );
129 if( nLevel > 8 || nLevel < 0 )
136 char name[] =
"Outline X";
137 name[8] =
static_cast<char>(
'1' + nLevel );
138 const OUString sStyleNameValue( OUString::createFromAscii( name ) );
153 sal_Int32 nMarR = sValue.isEmpty() ? 0 :
GetCoordinate( sValue ) ;
154 rPropertyMap.setProperty( PROP_ParaRightMargin, nMarR);
159 bool bRtl = rAttribs.
getBool( XML_rtl,
false );
160 rPropertyMap.setProperty( PROP_WritingMode, ( bRtl ? WritingMode2::RL_TB : WritingMode2::LR_TB ));
170 rPropertyMap.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 ));
172 ::std::vector< TabStop >::size_type nTabCount =
maTabList.size();
176 TabStop * aArray = aSeq.getArray();
177 OSL_ENSURE( aArray !=
nullptr,
"sequence array is NULL" );
179 rPropertyMap.setProperty( PROP_ParaTabStops, aSeq);
189 rPropertyMap.setProperty( PROP_IsNumbering,
true);
191 rPropertyMap.setProperty( PROP_NumberingLevel, nLevel);
192 rPropertyMap.setProperty( PROP_NumberingIsNumber,
true);
200 switch( aElementToken )
202 case A_TOKEN( lnSpc ):
204 case A_TOKEN( spcBef ):
206 case A_TOKEN( spcAft ):
209 case A_TOKEN( buClrTx ):
212 case A_TOKEN( buClr ):
215 case A_TOKEN( buSzTx ):
218 case A_TOKEN( buSzPct ):
221 case A_TOKEN( buSzPts ):
227 case A_TOKEN( buFontTx ):
230 case A_TOKEN( buFont ):
235 case A_TOKEN( buNone ):
238 case A_TOKEN( buAutoNum ):
242 sal_Int32 nStartAt = rAttribs.
getInteger( XML_startAt, 1 );
243 if( nStartAt > 32767 )
247 else if( nStartAt < 1 )
254 catch(SAXException& )
260 case A_TOKEN( buChar ):
266 catch(SAXException& )
271 case A_TOKEN( buBlip ):
273 mxBlipProps = std::make_shared<BlipFillProperties>();
276 case A_TOKEN( tabLst ):
278 case A_TOKEN( defRPr ):
283 if( oParaAdjust.
has() && !oParaAdjust.
get().isEmpty() )
285 const OUString& sParaAdjust = oParaAdjust.
get();
286 if( sParaAdjust ==
"left" )
288 else if ( sParaAdjust ==
"right" )
290 else if ( sParaAdjust ==
"center" )
292 else if ( sParaAdjust ==
"both" )
297 case W_TOKEN( spacing ):
300 if( !rAttribs.
getBool(W_TOKEN(beforeAutospacing),
false) )
313 if (oBeforeLines.
has())
324 if( !rAttribs.
getBool(W_TOKEN(afterAutospacing),
false) )
337 if (oAfterLines.
has())
350 if (oLineSpacing.
has())
353 if( !oLineRule.
has() || oLineRule.
get() ==
"auto" )
368 SAL_WARN(
"oox",
"TextParagraphPropertiesContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
Context handler that imports the a:blipFill element.
std::shared_ptr< BlipFillProperties > mxBlipProps
std::optional< css::style::ParagraphAdjust > & getParaAdjust()
A helper that maps property identifiers to property values.
OptValue< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
css::uno::Any mbBulletColorFollowText
css::style::LineSpacing toLineSpacing() const
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
void setBulletSize(sal_Int16 nSize)
void setType(sal_Int32 nType)
void setBulletChar(const OUString &sChar)
constexpr auto convertTwipToMm100(N n)
std::optional< sal_Int32 > & getFirstLineIndentation()
::oox::drawingml::TextFont maBulletFont
void setBulletAspectRatio(double nAspectRatio)
sal_Int32 GetPercent(std::u16string_view sValue)
converts a ST_Percentage % string into 1/1000th of %
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
css::uno::Any mbBulletFontFollowText
sal_Int16 getLevel() const
#define TOOLS_WARN_EXCEPTION(area, stream)
TextSpacing & getParaBottomMargin()
void setStyleName(const OUString &rStyleName)
const sal_Int32 MAX_PERCENT
Context handler for elements that contain a color value element (a:scrgbClr, a:srgbClr, a:hslClr, a:sysClr, a:schemeClr, a:prstClr).
css::uno::Any mbBulletSizeFollowText
PropertyMap & getTextParagraphPropertyMap()
virtual ~TextParagraphPropertiesContext() override
void setAttributes(const AttributeList &rAttribs)
Sets attributes from the passed attribute list.
Provides access to attribute values of an element.
void setGraphic(css::uno::Reference< css::graphic::XGraphic > const &rXGraphic)
std::vector< css::style::TabStop > maTabList
TextSpacing & getParaTopMargin()
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm
void setStartAt(sal_Int32 nStartAt)
TextSpacing & getLineSpacing()
ParagraphAdjust GetParaAdjust(sal_Int32 nAlign)
converts a paragraph align to a ParaAdjust
std::optional< sal_Int32 > & getParaLeftMargin()
TextParagraphProperties & mrTextParagraphProperties
void setFontSize(sal_Int16 nSize)
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
std::shared_ptr< ::oox::drawingml::Color > maBulletColorPtr
void(* f)(TrueTypeTable *)
BulletList & mrBulletList
TextCharacterProperties & getTextCharacterProperties()
Helper class that provides a context stack.
TextParagraphPropertiesContext(::oox::core::ContextHandler2Helper const &rParent, const ::oox::AttributeList &rAttributes, TextParagraphProperties &rTextParagraphProperties)
float GetTextSize(std::u16string_view sValue)
converts the ST_TextFontSize to point
void setParaAdjust(css::style::ParagraphAdjust nParaAdjust)
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
void setLevel(sal_Int16 nLevel)