23#include <osl/diagnose.h>
24#include <rtl/ustrbuf.hxx>
26#include <com/sun/star/uno/Any.hxx>
27#include <com/sun/star/drawing/FillStyle.hpp>
28#include <com/sun/star/style/DropCapFormat.hpp>
29#include <com/sun/star/text/FontRelief.hpp>
30#include <com/sun/star/text/WrapTextMode.hpp>
31#include <com/sun/star/text/XTextColumns.hpp>
32#include <com/sun/star/text/TextColumn.hpp>
33#include <com/sun/star/text/RelOrientation.hpp>
34#include <com/sun/star/text/HoriOrientation.hpp>
35#include <com/sun/star/text/VertOrientation.hpp>
36#include <com/sun/star/text/RubyAdjust.hpp>
37#include <com/sun/star/text/RubyPosition.hpp>
38#include <com/sun/star/text/FontEmphasis.hpp>
39#include <com/sun/star/text/ParagraphVertAlign.hpp>
40#include <com/sun/star/graphic/XGraphic.hpp>
53#include <com/sun/star/text/WrapInfluenceOnPosition.hpp>
54#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
94 {
XML_PAGE, RelOrientation::PAGE_FRAME },
112 {
XML_PAGE, RelOrientation::PAGE_FRAME },
137 {
XML_TOP, VertOrientation::TOP },
138 {
XML_TOP, VertOrientation::CHAR_TOP },
139 {
XML_TOP, VertOrientation::LINE_TOP },
144 {
XML_BELOW, VertOrientation::CHAR_BOTTOM },
155 {
XML_PAGE, RelOrientation::PAGE_FRAME },
162 {
XML_LINE, RelOrientation::TEXT_LINE },
168 {
XML_PAGE, RelOrientation::FRAME },
170 {
XML_PAGE, RelOrientation::PAGE_FRAME },
189 {
XML_TEXT, VertOrientation::CHAR_TOP },
190 {
XML_TEXT, VertOrientation::CHAR_CENTER },
191 {
XML_TEXT, VertOrientation::CHAR_BOTTOM },
192 {
XML_LINE, VertOrientation::LINE_TOP },
193 {
XML_LINE, VertOrientation::LINE_CENTER },
194 {
XML_LINE, VertOrientation::LINE_BOTTOM },
226 {
XML_TOP, ParagraphVertAlign::TOP },
230 {
XML_AUTO, ParagraphVertAlign::AUTOMATIC },
246 {
XML_TOP, drawing::TextVerticalAdjust_TOP },
247 {
XML_MIDDLE, drawing::TextVerticalAdjust_CENTER },
248 {
XML_BOTTOM, drawing::TextVerticalAdjust_BOTTOM },
249 {
XML_JUSTIFY, drawing::TextVerticalAdjust_BLOCK },
259 const css::uno::Any& r1,
260 const css::uno::Any& r2 )
const override;
264 const OUString& rStrImpValue,
265 css::uno::Any& rValue,
268 OUString& rStrExpValue,
269 const css::uno::Any& rValue,
275bool XMLDropCapPropHdl_Impl::equals(
277 const Any& r2 )
const
279 DropCapFormat aFormat1, aFormat2;
283 return (aFormat1.Lines <=1 && aFormat2.Lines <=1) ||
284 (aFormat1.Lines == aFormat2.Lines &&
285 aFormat1.Count == aFormat2.Count &&
286 aFormat1.Distance == aFormat2.Distance);
294 SAL_WARN(
"xmloff",
"drop caps are an element import property" );
303 SAL_WARN(
"xmloff",
"drop caps are an element export property" );
313 const OUString& rStrImpValue,
314 css::uno::Any& rValue,
317 OUString& rStrExpValue,
318 const css::uno::Any& rValue,
325 const OUString& rStrImpValue,
343 OUString& rStrExpValue,
347 if( *o3tl::doAccess<bool>(rValue) )
361 const OUString& rStrImpValue,
362 css::uno::Any& rValue,
365 OUString& rStrExpValue,
366 const css::uno::Any& rValue,
373 const OUString& rStrImpValue,
391 OUString& rStrExpValue,
395 if( *o3tl::doAccess<bool>(rValue) )
409 const OUString& rStrImpValue,
410 css::uno::Any& rValue,
413 OUString& rStrExpValue,
414 const css::uno::Any& rValue,
421 const OUString& rStrImpValue,
442 OUString& rStrExpValue,
446 if( *o3tl::doAccess<bool>(rValue) )
471 const OUString& rStrImpValue,
472 css::uno::Any& rValue,
475 OUString& rStrExpValue,
476 const css::uno::Any& rValue,
483 const OUString& rStrImpValue,
498 OUString& rStrExpValue,
509 rStrExpValue = aOut.makeStringAndClear();
520 explicit XMLFrameProtectPropHdl_Impl(
enum XMLTokenEnum eVal ) :
524 const OUString& rStrImpValue,
525 css::uno::Any& rValue,
528 OUString& rStrExpValue,
529 const css::uno::Any& rValue,
536 const OUString& rStrImpValue,
546 std::u16string_view aToken;
547 while( aTokenEnum.getNextToken( aToken ) )
565 OUString& rStrExpValue,
569 if( *o3tl::doAccess<bool>(rValue) )
571 if( rStrExpValue.isEmpty() ||
578 rStrExpValue +=
" " + sVal;
581 else if( rStrExpValue.isEmpty() )
591 {
XML_CHAR, TextContentAnchorType_AT_CHARACTER },
592 {
XML_PAGE, TextContentAnchorType_AT_PAGE },
593 {
XML_FRAME, TextContentAnchorType_AT_FRAME },
595 {
XML_AS_CHAR, TextContentAnchorType_AS_CHARACTER },
600 const OUString& rStrImpValue,
604 TextContentAnchorType nAnchor;
615 OUString& rStrExpValue,
620 TextContentAnchorType eVal;
626 rStrExpValue = aOut.makeStringAndClear();
636 TextContentAnchorType& rType )
638 TextContentAnchorType nAnchor;
652 const Any& r2 )
const
654 Reference < XTextColumns > xColumns1;
657 Reference < XTextColumns > xColumns2;
660 if (!xColumns1 || !xColumns2)
661 return (!xColumns1 && !xColumns2);
663 if( xColumns1->getColumnCount() != xColumns2->getColumnCount() ||
664 xColumns1->getReferenceValue() != xColumns2->getReferenceValue() )
667 const Sequence < TextColumn > aColumns1 = xColumns1->getColumns();
668 const Sequence < TextColumn > aColumns2 = xColumns2->getColumns();
670 return std::equal(aColumns1.begin(), aColumns1.end(), aColumns2.begin(), aColumns2.end(),
671 [](
const TextColumn&
a,
const TextColumn& b) {
672 return a.Width == b.Width
673 && a.LeftMargin == b.LeftMargin
674 && a.RightMargin == b.RightMargin;
683 SAL_WARN(
"xmloff",
"columns are an element import property" );
692 SAL_WARN(
"xmloff",
"columns are an element export property" );
702 const OUString& rStrImpValue,
703 css::uno::Any& rValue,
706 OUString& rStrExpValue,
707 const css::uno::Any& rValue,
714 const OUString& rStrImpValue,
724 rValue <<= nHoriMirror;
735 SAL_WARN(
"xmloff",
"HorMirror property shouldn't be exported" );
748 XMLGrfMirrorPropHdl_Impl(
enum XMLTokenEnum eVal,
bool bH ) :
753 const OUString& rStrImpValue,
754 css::uno::Any& rValue,
757 OUString& rStrExpValue,
758 const css::uno::Any& rValue,
765 const OUString& rStrImpValue,
775 std::u16string_view aToken;
776 while( aTokenEnum.getNextToken( aToken ) )
779 if( aToken == sVal ||
795 OUString& rStrExpValue,
799 if( *o3tl::doAccess<bool>(rValue) )
801 if( rStrExpValue.isEmpty() ||
818 rStrExpValue +=
" " + sVal;
821 else if( rStrExpValue.isEmpty() )
832 {
XML_DOT, FontEmphasis::DOT_ABOVE },
834 {
XML_DISC, FontEmphasis::DISK_ABOVE },
844 XMLTextEmphasizePropHdl_Impl() {}
847 const OUString& rStrImpValue,
848 css::uno::Any& rValue,
851 OUString& rStrExpValue,
852 const css::uno::Any& rValue,
859 const OUString& rStrImpValue,
864 sal_uInt16 nVal = FontEmphasis::NONE;
866 bool bHasPos =
false, bHasType =
false;
867 std::u16string_view aToken;
870 while( aTokenEnum.getNextToken( aToken ) )
882 else if( !bHasType &&
897 if( FontEmphasis::NONE != nVal && bBelow )
899 rValue <<= static_cast<sal_Int16>(nVal);
906 OUString& rStrExpValue,
910 OUStringBuffer aOut( 15 );
912 sal_uInt16
nType = sal_uInt16();
913 if( rValue >>= nType )
931 rStrExpValue = aOut.makeStringAndClear();
943 XMLTextCombineCharPropHdl_Impl() {}
946 const OUString& rStrImpValue,
947 css::uno::Any& rValue,
950 OUString& rStrExpValue,
951 const css::uno::Any& rValue,
958 const OUString& rStrImpValue,
962 if( !rStrImpValue.isEmpty() )
963 rValue <<= rStrImpValue.copy( 0, 1 );
965 rValue <<= rStrImpValue;
971 OUString& rStrExpValue,
975 rValue >>= rStrExpValue;
978 return (1 == rStrExpValue.getLength());
986 XMLTextRelWidthHeightPropHdl_Impl() {}
989 const OUString& rStrImpValue,
990 css::uno::Any& rValue,
993 OUString& rStrExpValue,
994 const css::uno::Any& rValue,
1001 const OUString& rStrImpValue,
1008 rValue <<= static_cast<sal_Int16>(nValue);
1014 OUString& rStrExpValue,
1019 sal_Int16
nValue = sal_Int16();
1020 if( (rValue >>= nValue) && nValue > 0 )
1022 OUStringBuffer aOut;
1024 rStrExpValue = aOut.makeStringAndClear();
1036 const OUString sValue;
1039 explicit XMLTextSyncWidthHeightPropHdl_Impl(
enum XMLTokenEnum eValue ) :
1043 const OUString& rStrImpValue,
1044 css::uno::Any& rValue,
1047 OUString& rStrExpValue,
1048 const css::uno::Any& rValue,
1055 const OUString& rStrImpValue,
1059 rValue <<= (rStrImpValue == sValue);
1065 OUString& rStrExpValue,
1070 if( *o3tl::doAccess<bool>(rValue) )
1072 rStrExpValue = sValue;
1085 XMLTextRotationAnglePropHdl_Impl() {}
1088 const OUString& rStrImpValue,
1089 css::uno::Any& rValue,
1092 OUString& rStrExpValue,
1093 const css::uno::Any& rValue,
1100 const OUString& rStrImpValue,
1112 if( nValue < 45 || nValue > 315 )
1114 else if( nValue < 180 )
1125 OUString& rStrExpValue,
1129 sal_Int16 nAngle = sal_Int16();
1130 bool bRet = ( rValue >>= nAngle );
1133 rStrExpValue = OUString::number( nAngle / 10 );
1135 OSL_ENSURE( bRet,
"illegal rotation angle" );
1146 XMLNumber8OneBasedHdl() {}
1149 const OUString& rStrImpValue,
1150 css::uno::Any& rValue,
1153 OUString& rStrExpValue,
1154 const css::uno::Any& rValue,
1161 const OUString& rStrImpValue,
1168 rValue <<= static_cast<sal_Int8>( nValue - 1 );
1173 OUString& rStrExpValue,
1178 bool bRet = ( rValue >>=
nValue );
1181 rStrExpValue = OUString::number( nValue + 1 );
1191 XMLGraphicPropertyHandler() {}
1195 SAL_WARN(
"xmloff",
"drop caps are an element import property" );
1201 SAL_WARN(
"xmloff",
"drop caps are an element import property" );
1205 virtual bool equals(
const css::uno::Any& rAny1,
const css::uno::Any& rAny2)
const override;
1210bool XMLGraphicPropertyHandler::equals(
const Any& rAny1,
const Any& rAny2)
const
1212 uno::Reference<graphic::XGraphic> xGraphic1;
1213 uno::Reference<graphic::XGraphic> xGraphic2;
1214 rAny1 >>= xGraphic1;
1215 rAny2 >>= xGraphic2;
1219 return aGraphic1 == aGraphic2;
1229 pHdl =
new XMLDropCapPropHdl_Impl;
1232 pHdl =
new XMLWrapPropHdl_Impl;
1235 pHdl =
new XMLParagraphOnlyPropHdl_Impl;
1238 pHdl =
new XMLContourModePropHdl_Impl;
1241 pHdl =
new XMLOpaquePropHdl_Impl;
1244 pHdl =
new XMLFrameProtectPropHdl_Impl(
XML_CONTENT );
1247 pHdl =
new XMLFrameProtectPropHdl_Impl(
XML_SIZE );
1250 pHdl =
new XMLFrameProtectPropHdl_Impl(
XML_POSITION );
1271 pHdl =
new XMLHoriMirrorPropHdl_Impl;
1289 pHdl =
new XMLGrfMirrorPropHdl_Impl(
XML_VERTICAL,
false );
1306 pHdl =
new XMLTextEmphasizePropHdl_Impl;
1317 pHdl =
new XMLTextCombineCharPropHdl_Impl;
1332 pHdl =
new XMLTextRelWidthHeightPropHdl_Impl;
1335 pHdl =
new XMLTextSyncWidthHeightPropHdl_Impl(
XML_SCALE );
1338 pHdl =
new XMLTextSyncWidthHeightPropHdl_Impl(
XML_SCALE_MIN );
1347 pHdl =
new XMLTextRotationAnglePropHdl_Impl;
1387 pHdl =
new XMLNumber8OneBasedHdl();
1413 pHdl =
new XMLGraphicPropertyHandler;
1420 OSL_ENSURE(
false,
"XMLPropertyHandler missing (!)");
1433 sal_Int32 nType )
const
css::chart::ChartAxisLabelPosition ePos
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...
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 ~XMLAnchorTypePropHdl() override
static bool convert(std::string_view rStrImpValue, css::text::TextContentAnchorType &rType)
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.
Abstract base-class for different XML-types.
Abstract base-class for different XML-types.
PropertyHandler for the XML-data-type:
Abstract base-class for different XML-types.
PropertyHandler for a generic xml enumeration type:
Abstract base-class for different XML-types.
PropertyHandler for a named xml bool type:
void PutHdlCache(sal_Int32 nType, const XMLPropertyHandler *pHdl) const
Puts a PropertyHandler into the internal cache.
virtual const XMLPropertyHandler * GetPropertyHandler(sal_Int32 nType) const
This method retrieves a PropertyHandler for the given XML-type.
Abstract base-class for different XML-types.
virtual bool exportXML(OUString &rStrExpValue, const css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const =0
Exports 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 =0
Imports the given value according to the XML-data-type corresponding to the derived class.
virtual bool equals(const css::uno::Any &r1, const css::uno::Any &r2) const
Compares two Any's in case of the given XML-data-type.
PropertyHandler for the XML-data-type:
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 bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
TabStops will be imported/exported as XML-Elements. So the Import/Export-work must be done at another...
virtual ~XMLTextColumnsPropertyHandler() override
virtual bool equals(const css::uno::Any &r1, const css::uno::Any &r2) const override
Compares two Any's in case of the given XML-data-type.
virtual const XMLPropertyHandler * GetPropertyHandler(sal_Int32 nType) const override
This method retrieves a PropertyHandler for the given XML-type.
XMLTextPropertyHandlerFactory()
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
#define SAL_WARN(area, stream)
XMLOFF_DLLPUBLIC bool importXML(css::uno::Reference< css::xml::sax::XFastAttributeList > const &xAttrList, css::uno::Any &rValue, OUString &rStrName, SvXMLImport &rImport)
XMLOFF_DLLPUBLIC void exportXML(OUString const &rStrName, css::uno::Any const &rValue, SvXMLExport &rExport)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
@ XML_PAGE_CONTENT_BOTTOM
@ XML_PARAGRAPH_START_MARGIN
@ XML_PARAGRAPH_END_MARGIN
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
SvXMLEnumMapEntry< drawing::FillStyle > const aXML_FillStyle_EnumMap[]
SvXMLEnumMapEntry< drawing::BitmapMode > const aXML_BitmapMode_EnumMap[]
SvXMLEnumMapEntry< drawing::RectanglePoint > const aXML_RefPoint_EnumMap[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_HoriPos_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_HoriRel_Enum[]
SvXMLEnumMapEntry< bool > const pXML_HoriMirror_Enum[]
static const XMLPropertyHandler * GetPropertyHandler(sal_Int32 nType)
SvXMLEnumMapEntry< sal_uInt16 > const pXML_VertRelFrame_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_HoriRelFrame_Enum[]
SvXMLEnumMapEntry< RubyAdjust > const pXML_RubyAdjust_Enum[]
SvXMLEnumMapEntry< sal_Int16 > const pXML_RubyPosition_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_VertRel_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_WrapInfluenceOnPosition_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_VertRelAsChar_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_ParaVerticalAlign_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_Emphasize_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_HoriPosMirrored_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_FontRelief_Enum[]
SvXMLEnumMapEntry< TextContentAnchorType > const pXML_Anchor_Enum[]
SvXMLEnumMapEntry< drawing::TextVerticalAdjust > const pXML_VerticalAlign_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_VertPosAtChar_Enum[]
SvXMLEnumMapEntry< sal_uInt16 > const pXML_VertRelPage_Enum[]
SvXMLEnumMapEntry< WrapTextMode > const pXML_Wrap_Enum[]
#define XML_SW_TYPE_BITMAPREPOFFSETY
#define XML_TYPE_TEXT_LINE_BREAK
#define XML_TYPE_TEXT_NUMBER8_ONE_BASED
#define XML_TYPE_TEXT_WRAP_OUTSIDE
#define XML_TYPE_TEXT_PUNCTUATION_WRAP
#define XML_TYPE_TEXT_HORIZONTAL_REL
#define XML_TYPE_VERTICAL_ALIGN
#define XML_TYPE_TEXT_REL_WIDTH_HEIGHT
#define XML_TYPE_TEXT_PARAGRAPH_ONLY
#define XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT
#define XML_TYPE_TEXT_SYNC_WIDTH_HEIGHT_MIN
#define XML_TYPE_TEXT_ROTATION_SCALE
#define XML_TYPE_TEXT_HORIZONTAL_POS_MIRRORED
#define XML_TYPE_TEXT_ROTATION_ANGLE
#define XML_TYPE_TEXT_HORIZONTAL_MIRROR
#define XML_TYPE_TEXT_LINE_MODE
#define XML_TYPE_TEXT_VERTICAL_REL_FRAME
#define XML_TYPE_TEXT_OPAQUE
#define XML_TYPE_TEXT_VERTICAL_REL_AS_CHAR
#define XML_TYPE_TEXT_RUBY_ADJUST
#define XML_TYPE_TEXT_HORIZONTAL_REL_FRAME
#define XML_TYPE_TEXT_MIRROR_VERTICAL
#define XML_TYPE_TEXT_AUTOSPACE
#define XML_TYPE_TEXT_COMBINE
#define XML_TYPE_BORDER_MODEL
#define XML_TYPE_TEXT_RUBY_IS_ABOVE
#define XML_TYPE_TEXT_PROTECT_SIZE
#define XML_TYPE_TEXT_PROTECT_POSITION
#define XML_TYPE_TEXT_WRAP
#define XML_TYPE_WRAP_INFLUENCE_ON_POSITION
#define XML_TYPE_TEXT_MIRROR_HORIZONTAL_LEFT
#define XML_TYPE_TEXT_EMPHASIZE
#define XML_TYPE_TEXT_VERTICAL_ALIGN
#define XML_TYPE_TEXT_COMBINECHAR
#define XML_SW_TYPE_FILLSTYLE
#define XML_TYPE_TEXT_DROPCAP
#define XML_SW_TYPE_LOGICAL_SIZE
#define XML_TYPE_TEXT_COMBINE_CHARACTERS
#define XML_TYPE_TEXT_ANCHOR_TYPE
#define XML_SW_TYPE_BITMAP_REFPOINT
#define XML_TYPE_TEXT_MIRROR_HORIZONTAL_RIGHT
#define XML_TYPE_TEXT_VERTICAL_REL_PAGE
#define XML_TYPE_COMPLEX_COLOR
#define XML_TYPE_TEXT_PROTECT_CONTENT
#define XML_TYPE_TEXT_HORIZONTAL_POS
#define XML_TYPE_TEXT_NKEEP
#define XML_TYPE_TEXT_KEEP
#define XML_TYPE_TEXT_CLIP
#define XML_TYPE_TEXT_COLUMNS
#define XML_SW_TYPE_BITMAP_MODE
#define XML_TYPE_TEXT_VERTICAL_REL
#define XML_SW_TYPE_FILLBITMAPSIZE
#define XML_TYPE_TEXT_RUBY_POSITION
#define XML_TYPE_TEXT_VERTICAL_POS_AT_CHAR
#define XML_TYPE_TEXT_CLIP11
#define XML_TYPE_TEXT_FONT_RELIEF
#define XML_SW_TYPE_BITMAPREPOFFSETX