21#include <com/sun/star/awt/FontUnderline.hpp>
22#include <com/sun/star/awt/FontStrikeout.hpp>
23#include <com/sun/star/drawing/Hatch.hpp>
24#include <com/sun/star/style/CaseMap.hpp>
25#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
29#include <osl/diagnose.h>
31#include <oox/token/tokens.hxx>
33using ::com::sun::star::uno::Reference;
34using ::com::sun::star::xml::sax::XFastAttributeList;
75 double fPercent = sValue.toFloat() / 100000.;
82 return awt::Point(
GetPercent(xAttribs->getOptionalValue(XML_x)),
GetPercent(xAttribs->getOptionalValue(XML_y)));
91 fRet =
static_cast< float >(
static_cast< double >( nRet ) / 100.0 );
116 return static_cast< float >( nHeight / 100.0 );
121 OSL_ASSERT((
nToken & sal_Int32(0xFFFF0000))==0);
124 case XML_none:
return awt::FontUnderline::NONE;
125 case XML_dash:
return awt::FontUnderline::DASH;
126 case XML_dashHeavy:
return awt::FontUnderline::BOLDDASH;
127 case XML_dashLong:
return awt::FontUnderline::LONGDASH;
128 case XML_dashLongHeavy:
return awt::FontUnderline::BOLDLONGDASH;
129 case XML_dbl:
return awt::FontUnderline::DOUBLE;
130 case XML_dotDash:
return awt::FontUnderline::DASHDOT;
131 case XML_dotDashHeavy:
return awt::FontUnderline::BOLDDASHDOT;
132 case XML_dotDotDash:
return awt::FontUnderline::DASHDOTDOT;
133 case XML_dotDotDashHeavy:
return awt::FontUnderline::BOLDDASHDOTDOT;
134 case XML_dotted:
return awt::FontUnderline::DOTTED;
135 case XML_dottedHeavy:
return awt::FontUnderline::BOLDDOTTED;
136 case XML_heavy:
return awt::FontUnderline::BOLD;
137 case XML_sng:
return awt::FontUnderline::SINGLE;
138 case XML_wavy:
return awt::FontUnderline::WAVE;
139 case XML_wavyDbl:
return awt::FontUnderline::DOUBLEWAVE;
140 case XML_wavyHeavy:
return awt::FontUnderline::BOLDWAVE;
143 return awt::FontUnderline::DONTKNOW;
148 OSL_ASSERT((
nToken & sal_Int32(0xFFFF0000))==0);
151 case XML_dblStrike:
return awt::FontStrikeout::DOUBLE;
152 case XML_noStrike:
return awt::FontStrikeout::NONE;
153 case XML_sngStrike:
return awt::FontStrikeout::SINGLE;
155 return awt::FontStrikeout::DONTKNOW;
162 case XML_all:
return CaseMap::UPPERCASE;
163 case XML_small:
return CaseMap::SMALLCAPS;
165 return CaseMap::NONE;
171 OSL_ASSERT((nAlign & sal_Int32(0xFFFF0000))==0);
172 ParagraphAdjust nEnum;
176 nEnum = ParagraphAdjust_CENTER;
180 nEnum = ParagraphAdjust_BLOCK;
183 nEnum = ParagraphAdjust_RIGHT;
187 nEnum = ParagraphAdjust_STRETCH;
191 nEnum = ParagraphAdjust_LEFT;
199 TextVerticalAdjust aVertAdjust;
203 aVertAdjust = TextVerticalAdjust_BOTTOM;
208 aVertAdjust = TextVerticalAdjust_CENTER;
212 aVertAdjust = TextVerticalAdjust_TOP;
220 const char* sVerticalAdjust =
nullptr;
223 case TextVerticalAdjust_BOTTOM:
224 sVerticalAdjust =
"b";
226 case TextVerticalAdjust_CENTER:
227 sVerticalAdjust =
"ctr";
229 case TextVerticalAdjust_TOP:
231 sVerticalAdjust =
"t";
234 return sVerticalAdjust;
239 OSL_ASSERT((aToken & sal_Int32(0xFFFF0000))==0);
244 nEnum = TabAlign_CENTER;
247 nEnum = TabAlign_DECIMAL;
250 nEnum = TabAlign_LEFT;
253 nEnum = TabAlign_RIGHT;
256 nEnum = TabAlign_DEFAULT;
264 const char* sPattern =
nullptr;
265 const sal_Int32 nAngle = rHatch.Angle > 1800 ? rHatch.Angle - 1800 : rHatch.Angle;
267 if( (nAngle >= 0 && nAngle < 225) || nAngle >= 1575 )
269 switch( rHatch.Style )
271 case drawing::HatchStyle_SINGLE:
273 if( rHatch.Distance < 75 )
280 case drawing::HatchStyle_DOUBLE:
281 case drawing::HatchStyle_TRIPLE:
283 if( rHatch.Distance < 75 )
294 else if( nAngle < 675 )
296 switch( rHatch.Style )
298 case drawing::HatchStyle_SINGLE:
300 if( rHatch.Distance < 75 )
301 sPattern =
"ltUpDiag";
303 sPattern =
"wdUpDiag";
307 case drawing::HatchStyle_DOUBLE:
308 case drawing::HatchStyle_TRIPLE:
310 if( rHatch.Distance < 75 )
311 sPattern =
"smCheck";
313 sPattern =
"openDmnd";
321 else if( nAngle < 1125 )
323 switch( rHatch.Style )
325 case drawing::HatchStyle_SINGLE:
328 if( rHatch.Distance < 50 )
330 else if( rHatch.Distance < 75 )
337 case drawing::HatchStyle_DOUBLE:
338 case drawing::HatchStyle_TRIPLE:
340 if( rHatch.Distance < 75 )
351 else if( nAngle < 1575 )
353 switch( rHatch.Style )
355 case drawing::HatchStyle_SINGLE:
357 if( rHatch.Distance < 75 )
358 sPattern =
"ltDnDiag";
360 sPattern =
"wdDnDiag";
364 case drawing::HatchStyle_DOUBLE:
365 case drawing::HatchStyle_TRIPLE:
367 if( rHatch.Distance < 75 )
368 sPattern =
"smCheck";
370 sPattern =
"openDmnd";
382 switch (nRotateAngle)
396sal_Int32 GetST_Percentage(std::u16string_view s)
407 IntegerRectangle2D r;
409 r.X1 = GetST_Percentage(xAttribs->getOptionalValue( XML_l ));
410 r.Y1 = GetST_Percentage(xAttribs->getOptionalValue( XML_t ));
411 r.X2 = GetST_Percentage(xAttribs->getOptionalValue( XML_r ));
412 r.Y2 = GetST_Percentage(xAttribs->getOptionalValue( XML_b ));
419 rRelativeRectangle.
mnLeft = GetST_Percentage(xAttribs->getOptionalValue(XML_l));
420 rRelativeRectangle.
mnTop = GetST_Percentage(xAttribs->getOptionalValue(XML_t));
421 rRelativeRectangle.
mnRight = GetST_Percentage(xAttribs->getOptionalValue(XML_r));
422 rRelativeRectangle.
mnBottom = GetST_Percentage(xAttribs->getOptionalValue(XML_b));
428 return awt::Size(
GetCoordinate( xAttribs->getOptionalValue( XML_cx ) ),
GetCoordinate( xAttribs->getOptionalValue( XML_cy ) ) );
434 range.
start = xAttributes->getOptionalValue( XML_st ).toInt32();
435 range.
end = xAttributes->getOptionalValue( XML_end ).toInt32();
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
constexpr bool ends_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
double toDouble(std::u16string_view str)
IndexRange GetIndexRange(const Reference< XFastAttributeList > &xAttributes)
TextVerticalAdjust GetTextVerticalAdjust(sal_Int32 nToken)
float GetFontHeight(sal_Int32 nHeight)
sal_Int16 GetCaseMap(sal_Int32 nToken)
awt::Point GetPointPercent(const Reference< XFastAttributeList > &xAttribs)
converts the attributes from a CT_TLPoint into an awt Point with 1/1000%
TabAlign GetTabAlign(sal_Int32 aToken)
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm
sal_Int16 GetFontUnderline(sal_Int32 nToken)
awt::Size GetSize2D(const Reference< XFastAttributeList > &xAttribs)
converts the attributes from a CT_Size2D into an awt Size with 1/100thmm
model::RectangleAlignment convertToRectangleAlignment(sal_Int32 nToken)
std::optional< OString > GetTextVerticalType(sal_Int32 nRotateAngle)
Converts nRotate angle to TextVerticalType string appearing in ooxml.
sal_Int32 GetPointFromCoordinate(sal_Int32 nValue)
converts 1/100mm to EMU
ParagraphAdjust GetParaAdjust(sal_Int32 nAlign)
converts a paragraph align to a ParaAdjust
IntegerRectangle2D GetRelativeRect(const Reference< XFastAttributeList > &xAttribs)
converts the attributes from a CT_RelativeRect to an IntegerRectangle2D
double GetPositiveFixedPercentage(const OUString &sValue)
Converts a ST_PositiveFixedPercentage to a float.
void fillRelativeRectangle(model::RelativeRectangle &rRelativeRectangle, const Reference< XFastAttributeList > &xAttribs)
sal_Int32 GetTextSpacingPoint(std::u16string_view sValue)
converts the ST_TextSpacingPoint to 1/100mm
sal_Int32 GetPercent(std::u16string_view sValue)
converts a ST_Percentage % string into 1/1000th of %
sal_Int16 GetFontStrikeout(sal_Int32 nToken)
float GetTextSize(std::u16string_view sValue)
converts the ST_TextFontSize to point
const char * GetHatchPattern(const drawing::Hatch &rHatch)