25#include <rtl/ustrbuf.hxx>
26#include <com/sun/star/uno/Any.hxx>
27#include <com/sun/star/table/BorderLine2.hpp>
28#include <com/sun/star/table/BorderLineStyle.hpp>
35#define DEF_LINE_WIDTH_0 1
36#define DEF_LINE_WIDTH_1 35
37#define DEF_LINE_WIDTH_2 88
39#define SVX_XML_BORDER_WIDTH_THIN 0
40#define SVX_XML_BORDER_WIDTH_MIDDLE 1
41#define SVX_XML_BORDER_WIDTH_THICK 2
45 {
XML_NONE, table::BorderLineStyle::NONE },
47 {
XML_SOLID, table::BorderLineStyle::SOLID },
48 {
XML_DOUBLE, table::BorderLineStyle::DOUBLE },
50 {
XML_DOTTED, table::BorderLineStyle::DOTTED },
51 {
XML_DASHED, table::BorderLineStyle::DASHED },
52 {
XML_GROOVE, table::BorderLineStyle::ENGRAVED },
53 {
XML_RIDGE, table::BorderLineStyle::EMBOSSED },
54 {
XML_INSET, table::BorderLineStyle::INSET },
55 {
XML_OUTSET, table::BorderLineStyle::OUTSET },
80 sal_Int16 eStyle = -1;
81 if (nStyle != table::BorderLineStyle::NONE)
82 eStyle = sal_Int16( nStyle );
84 rBorderLine.LineStyle = eStyle;
99 sal_Int32 nInWidth, nDistance, nOutWidth;
101 std::u16string_view aToken;
120 table::BorderLine2 aBorderLine;
121 if(!(rValue >>= aBorderLine))
122 aBorderLine.Color = 0;
124 aBorderLine.InnerLineWidth = sal::static_int_cast< sal_Int16 >(nInWidth);
125 aBorderLine.OuterLineWidth = sal::static_int_cast< sal_Int16 >(nOutWidth);
126 aBorderLine.LineDistance = sal::static_int_cast< sal_Int16 >(nDistance);
128 rValue <<= aBorderLine;
136 table::BorderLine2 aBorderLine;
137 if(!(rValue >>= aBorderLine))
140 bool bDouble =
false;
141 switch ( aBorderLine.LineStyle )
143 case table::BorderLineStyle::DOUBLE:
144 case table::BorderLineStyle::DOUBLE_THIN:
145 case table::BorderLineStyle::THINTHICK_SMALLGAP:
146 case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
147 case table::BorderLineStyle::THINTHICK_LARGEGAP:
148 case table::BorderLineStyle::THICKTHIN_SMALLGAP:
149 case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
150 case table::BorderLineStyle::THICKTHIN_LARGEGAP:
157 if( ( aBorderLine.LineDistance == 0 && aBorderLine.InnerLineWidth == 0 ) || !bDouble )
166 rStrExpValue = aOut.makeStringAndClear();
180 std::u16string_view aToken;
183 bool bHasStyle =
false;
184 bool bHasWidth =
false;
185 bool bHasColor =
false;
187 sal_uInt16 nStyle = USHRT_MAX;
188 sal_uInt16 nWidth = 0;
189 sal_uInt16 nNamedWidth = USHRT_MAX;
190 sal_Int32 nColor = 0;
193 while( aTokens.
getNextToken( aToken ) && !aToken.empty() )
201 else if( !bHasStyle &&
211 else if( !bHasWidth &&
215 nWidth =
static_cast<sal_uInt16
>(nTemp);
227 if (!bHasStyle || (table::BorderLineStyle::NONE != nStyle && !bHasWidth))
230 table::BorderLine2 aBorderLine;
231 if(!(rValue >>= aBorderLine))
233 aBorderLine.Color = 0;
234 aBorderLine.InnerLineWidth = 0;
235 aBorderLine.OuterLineWidth = 0;
236 aBorderLine.LineDistance = 0;
237 aBorderLine.LineWidth = 0;
241 if (table::BorderLineStyle::NONE == nStyle ||
242 (bHasWidth && USHRT_MAX == nNamedWidth && 0 == nWidth) )
244 aBorderLine.InnerLineWidth = 0;
245 aBorderLine.OuterLineWidth = 0;
246 aBorderLine.LineDistance = 0;
247 aBorderLine.LineWidth = 0;
251 if( USHRT_MAX != nNamedWidth )
257 aBorderLine.LineWidth = nWidth;
265 aBorderLine.Color = nColor;
268 rValue <<= aBorderLine;
276 table::BorderLine2 aBorderLine;
277 if(!(rValue >>= aBorderLine))
280 sal_Int32 nWidth = aBorderLine.LineWidth;
289 util::MeasureUnit::MM_100TH, util::MeasureUnit::POINT);
294 switch ( aBorderLine.LineStyle )
296 case table::BorderLineStyle::DASHED:
299 case table::BorderLineStyle::DOTTED:
302 case table::BorderLineStyle::DOUBLE:
303 case table::BorderLineStyle::THINTHICK_SMALLGAP:
304 case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
305 case table::BorderLineStyle::THINTHICK_LARGEGAP:
306 case table::BorderLineStyle::THICKTHIN_SMALLGAP:
307 case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
308 case table::BorderLineStyle::THICKTHIN_LARGEGAP:
311 case table::BorderLineStyle::EMBOSSED:
314 case table::BorderLineStyle::ENGRAVED:
317 case table::BorderLineStyle::OUTSET:
320 case table::BorderLineStyle::INSET:
323 case table::BorderLineStyle::FINE_DASHED:
326 case table::BorderLineStyle::DASH_DOT:
329 case table::BorderLineStyle::DASH_DOT_DOT:
332 case table::BorderLineStyle::DOUBLE_THIN:
335 case table::BorderLineStyle::SOLID:
344 rStrExpValue = aOut.makeStringAndClear();
SvXMLEnumMapEntry< sal_uInt16 > const pXML_NamedBorderWidths[]
#define SVX_XML_BORDER_WIDTH_MIDDLE
#define SVX_XML_BORDER_WIDTH_THIN
static void lcl_frmitems_setXMLBorderStyle(table::BorderLine2 &rBorderLine, sal_uInt16 nStyle)
sal_uInt16 const aBorderWidths[]
#define SVX_XML_BORDER_WIDTH_THICK
SvXMLEnumMapEntry< sal_uInt16 > const pXML_BorderStyles[]
bool getNextToken(std::u16string_view &rToken)
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
convert string to measure with meCoreMeasureUnit, using optional min and max values
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
virtual ~XMLBorderHdl() override
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
virtual ~XMLBorderWidthHdl() override
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Exports the given value according to the XML-data-type corresponding to the derived class.
static bool convertMeasure(sal_Int32 &rValue, std::u16string_view rString, sal_Int16 nTargetUnit=css::util::MeasureUnit::MM_100TH, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken