20#include <com/sun/star/xml/sax/SAXException.hpp>
21#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
22#include <com/sun/star/xml/sax/XAttributeList.hpp>
23#include <rtl/ustrbuf.hxx>
24#include <osl/diagnose.h>
63 css::uno::Reference< css::xml::sax::XAttributeList >
m_xAttrList;
78 const OUString& rQName,
80 bool _bControlStyle );
82 virtual void StartElement(
const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList )
override;
84 virtual void Export()
override;
89 bool bBold,
bool bDouble );
91 bool bBold,
bool bDouble,
97 bool _bControlStyle ) :
101 m_bControlStyle( _bControlStyle )
106 const Reference< XAttributeList >& rAttrList )
113 OSL_ENSURE( pActions,
"go no actions" );
131 bool bBoldUnderline =
false, bDoubleUnderline =
false;
133 bool bBoldLineThrough =
false, bDoubleLineThrough =
false;
136 bool bIntervalMinorFound =
false;
137 double fIntervalMajor = 0.0;
138 sal_Int32 nIntervalMinorDivisor = 0;
141 OUString aOpacityValueRemember;
142 OUString aImageOpacityValueRemember;
144 sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
145 for( sal_Int16
i=0;
i < nAttrCount;
i++ )
147 const OUString& rAttrName = rAttrList->getNameByIndex(
i );
148 const OUString& rAttrValue = rAttrList->getValueByIndex(
i );
154 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
155 XMLTransformerActions::const_iterator aIter =
156 pActions->find( aKey );
157 if( aIter != pActions->end() )
159 switch( (*aIter).second.m_nActionType )
164 pAttrList->AddAttribute( rAttrName, rAttrValue );
168 OUString aNewAttrQName(
170 (*aIter).second.GetQNamePrefixFromParam1(),
172 (*aIter).second.GetQNameTokenFromParam1()) ) );
173 pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
178 OUString aAttrValue( rAttrValue );
181 pAttrList->AddAttribute( rAttrName, aAttrValue );
186 OUString aAttrValue( rAttrValue );
189 pAttrList->AddAttribute( rAttrName, aAttrValue );
194 OUString aAttrValue( rAttrValue );
196 pAttrList->AddAttribute( rAttrName, aAttrValue );
201 OUString aNewAttrQName(
203 (*aIter).second.GetQNamePrefixFromParam1(),
205 (*aIter).second.GetQNameTokenFromParam1()) ) );
206 OUString aAttrValue( rAttrValue );
208 pAttrList->AddAttribute( aNewAttrQName, aAttrValue );
213 OUString aAttrValue( rAttrValue );
215 pAttrList->AddAttribute( rAttrName, aAttrValue );
220 OUString aNewAttrQName(
222 (*aIter).second.GetQNamePrefixFromParam1(),
224 (*aIter).second.GetQNameTokenFromParam1()) ) );
225 OUString aAttrValue( rAttrValue );
227 pAttrList->AddAttribute( aNewAttrQName, aAttrValue );
239 pAttrList->GetIndexByName( aAttrQName );
244 const OUString& rOldValue =
245 pAttrList->getValueByIndex(
nIndex );
248 pAttrList->SetValueByIndex(
nIndex,
258 pAttrList->AddAttribute( aAttrQName, aAttrValue );
268 pAttrList->AddAttribute( rAttrName, aAttrValue );
273 bBoldUnderline =
true;
277 bDoubleUnderline =
true;
284 bBoldLineThrough =
true;
288 bDoubleLineThrough =
true;
294 if( !rAttrValue.isEmpty() )
295 cLineThroughChar = rAttrValue[0];
300 sal_Int32 nSplineType = 0;
306 pAttrList->AddAttribute(
310 OUString::number( nSplineType ));
314 pAttrList->AddAttribute( rAttrName, rAttrValue );
319 bIntervalMinorFound =
true;
325 sal_Int32 nSymbolType = 0;
333 if( nSymbolType < 0 )
334 pAttrList->AddAttribute(
338 OUString::number( nSymbolType ));
344 sal_Int32 nSymbolType = -3;
377 if( nSymbolType >= 0 )
378 pAttrList->AddAttribute(
382 OUString::number( nSymbolType ));
387 aOpacityValueRemember = rAttrValue;
393 aImageOpacityValueRemember = rAttrValue;
398 pAttrList->AddAttribute(
410 OUString aNewAttrQName(
415 pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
419 OUString aNewAttrQName(
424 pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
430 OUString aAttrValue( rAttrValue );
431 if( aAttrValue.indexOf(
'%' ) != -1 )
440 aAttrValue = aOut.makeStringAndClear();
448 pAttrList->AddAttribute( rAttrName, aAttrValue );
454 pAttrList->AddAttribute( rAttrName, rAttrValue );
457 pAttrList->AddAttribute(
GetTransformer().GetNamespaceMap().GetQNameByKey(
462 pAttrList->AddAttribute(
GetTransformer().GetNamespaceMap().GetQNameByKey(
472 OUStringBuffer aNewAttrValue;
474 std::u16string_view aToken;
477 if ( !aNewAttrValue.isEmpty() )
479 aNewAttrValue.append(
" ");
492 aNewAttrValue.append(aToken);
495 pAttrList->AddAttribute( rAttrName, aNewAttrValue.makeStringAndClear() );
499 pAttrList->AddAttribute(
GetTransformer().GetNamespaceMap().GetQNameByKey(
508 const double fValue =
static_cast<double>(
nValue) / 100.0;
509 pAttrList->AddAttribute( rAttrName, OUString::number( fValue ) );
515 if( rAttrValue.indexOf(
'%' ) != -1 )
521 nValue = sal_Int32( rAttrValue.toDouble() * 100.0 );
527 pAttrList->AddAttribute( rAttrName, aOut.makeStringAndClear() );
531 OSL_ENSURE(
false,
"unknown action" );
537 pAttrList->AddAttribute( rAttrName, rAttrValue );
541 pAttrList->AddAttribute(
546 bDoubleUnderline ) );
548 pAttrList->AddAttribute(
553 bDoubleLineThrough, cLineThroughChar ) );
554 if( bIntervalMinorFound )
556 double fIntervalMinor = 0.0;
557 if( nIntervalMinorDivisor != 0)
558 fIntervalMinor = fIntervalMajor /
static_cast< double >( nIntervalMinorDivisor );
562 pAttrList->AddAttribute(
566 aBuf.makeStringAndClear());
570 if(!aOpacityValueRemember.isEmpty() || !aImageOpacityValueRemember.isEmpty())
572 pAttrList->AddAttribute(
576 !aImageOpacityValueRemember.isEmpty()
577 ? aImageOpacityValueRemember : aOpacityValueRemember );
589 ->AppendAttributeList( rAttrList );
678 OSL_FAIL(
"xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" );
693 OSL_FAIL(
"xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" );
718 const OUString& rQName,
bool bPersistent)
720 , m_bPersistent(bPersistent)
721 , m_bControlStyle(false)
730 , m_bPersistent(bPersistent)
731 , m_bControlStyle(false)
741 const OUString& rLocalName,
742 const OUString& rQName,
743 const Reference< XAttributeList >& rAttrList )
773 nPrefix, rLocalName, rQName, rAttrList )
775 nPrefix, rLocalName, rQName, rAttrList );
782 const Reference< XAttributeList >& rAttrList )
786 OSL_ENSURE( pActions,
"go no actions" );
788 Reference< XAttributeList > xAttrList( rAttrList );
790 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
791 sal_Int16 nFamilyAttr = -1;
794 for( sal_Int16
i=0;
i < nAttrCount;
i++ )
796 const OUString& rAttrName = xAttrList->getNameByIndex(
i );
801 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
802 XMLTransformerActions::const_iterator aIter =
803 pActions->find( aKey );
804 if( aIter != pActions->end() )
806 if( !pMutableAttrList )
810 xAttrList = pMutableAttrList;
812 const OUString& rAttrValue = xAttrList->getValueByIndex(
i );
813 switch( (*aIter).second.m_nActionType )
818 pMutableAttrList->SetValueByIndex(
830 pMutableAttrList->RemoveAttributeByIndex(
i );
839 OUString aAttrValue( rAttrValue );
841 pMutableAttrList->SetValueByIndex(
i, aAttrValue );
846 OUString aAttrValue( rAttrValue );
849 pMutableAttrList->SetValueByIndex(
i, aAttrValue );
854 OUString aAttrValue( rAttrValue );
856 pMutableAttrList->SetValueByIndex(
i, aAttrValue );
861 OUString aAttrValue( rAttrValue );
863 static_cast< bool >((*aIter).second.m_nParam1)))
864 pMutableAttrList->SetValueByIndex(
i, aAttrValue );
868 OSL_ENSURE(
false,
"unknown action" );
@ PROP_OASIS_SECTION_ATTR_ACTIONS
@ PROP_OASIS_DRAWING_PAGE_ATTR_ACTIONS
@ PROP_OASIS_LIST_LEVEL_ATTR_ACTIONS
@ PROP_OASIS_TABLE_ROW_ATTR_ACTIONS
@ PROP_OASIS_HEADER_FOOTER_ATTR_ACTIONS
@ PROP_OASIS_PARAGRAPH_ATTR_ACTIONS
@ PROP_OASIS_TABLE_COLUMN_ATTR_ACTIONS
@ PROP_OASIS_GRAPHIC_ATTR_ACTIONS
@ PROP_OASIS_TABLE_CELL_ATTR_ACTIONS
@ PROP_OASIS_TABLE_ATTR_ACTIONS
@ PROP_OASIS_PAGE_LAYOUT_ATTR_ACTIONS
@ PROP_OASIS_TEXT_ATTR_ACTIONS
@ PROP_OASIS_CHART_ATTR_ACTIONS
@ XML_PROP_TYPE_TABLE_ROW
@ XML_PROP_TYPE_PAGE_LAYOUT
@ XML_PROP_TYPE_TABLE_COLUMN
@ XML_PROP_TYPE_TABLE_CELL
@ XML_PROP_TYPE_PARAGRAPH
@ XML_PROP_TYPE_LIST_LEVEL
@ XML_PROP_TYPE_HEADER_FOOTER
@ XML_PROP_TYPE_DRAWING_PAGE
XMLTransformerActionInit const aTableColumnPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aPageLayoutPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aHeaderFooterPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aGraphicPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aSectionPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aListLevelPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aParagraphPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aDrawingPagePropertyOASISAttrActionTable[]
XMLTransformerActionInit const aChartPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTableRowPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTableCellPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTextPropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTablePropertyOASISAttrActionTable[]
@ XML_OPTACTION_SYMBOL_NAME
@ XML_OPTACTION_INTERPOLATION
@ XML_OPTACTION_INTERVAL_MINOR_DIVISOR
@ XML_ATACTION_CAPTION_ESCAPE_OASIS
@ XML_OPTACTION_LINE_MODE
@ XML_OPTACTION_SYMBOL_TYPE
@ XML_OPTACTION_LINETHROUGH_STYLE
@ XML_OPTACTION_KEEP_WITH_NEXT
@ XML_OPTACTION_LINETHROUGH_TEXT
@ XML_OPTACTION_CONTROL_TEXT_ALIGN
@ XML_OPTACTION_UNDERLINE_WIDTH
@ XML_OPTACTION_INTERVAL_MAJOR
@ XML_OPTACTION_UNDERLINE_TYPE
@ XML_ATACTION_DECODE_PROTECT
@ XML_OPTACTION_LINETHROUGH_TYPE
@ XML_OPTACTION_LINETHROUGH_WIDTH
@ XML_OPTACTION_IMAGE_OPACITY
@ XML_OPTACTION_UNDERLINE_STYLE
@ XML_OPTACTION_KEEP_TOGETHER
const sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END]
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
bool getNextToken(std::u16string_view &rToken)
const OUString & GetExportQName() const
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual void EndElement() override
virtual void ExportContent() override
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList
virtual void Export() override
static XMLPropType GetPropType(std::u16string_view rLocalName)
bool const m_bControlStyle
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
void SetQNameAndPropType(const OUString &rQName, XMLPropType ePropType)
static OUString const & MergeUnderline(XMLTokenEnum eUnderline, bool bBold, bool bDouble)
static OUString const & MergeLineThrough(XMLTokenEnum eLineThrough, bool bBold, bool bDouble, sal_Unicode c)
XMLPropertiesTContext_Impl(XMLTransformerBase &rTransformer, const OUString &rQName, XMLPropType eP, bool _bControlStyle)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual ~XMLStyleOASISTContext() override
::rtl::Reference< XMLPropertiesTContext_Impl > m_xPropContext
virtual void EndElement() override
static XMLTransformerActions * CreateTransformerActions(sal_uInt16 nType)
virtual bool IsPersistent() const override
virtual void ExportContent() override
XMLStyleOASISTContext(XMLTransformerBase &rTransformer, const OUString &rQName, bool bPersistent)
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual void Characters(const OUString &rChars) override
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
void SetQName(const OUString &rQName)
XMLTransformerBase & GetTransformer()
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
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)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
@ XML_TABLE_CELL_PROPERTIES
@ XML_LIST_LEVEL_PROPERTIES
@ XML_DRAWING_PAGE_PROPERTIES
@ XML_GRADIENTSTYLE_SQUARE
@ XML_HEADER_FOOTER_PROPERTIES
@ XML_HORIZONTAL_ON_RIGHT_PAGES
@ XML_HORIZONTAL_ON_LEFT_PAGES
@ XML_TABLE_COLUMN_PROPERTIES
@ XML_PARAGRAPH_PROPERTIES
@ XML_PAGE_LAYOUT_PROPERTIES
@ XML_TABLE_ROW_PROPERTIES
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
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr sal_uInt16 XML_NAMESPACE_FO