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;
73 m_ePropType = ePropType;
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 );
523 nValue = 100 - nValue;
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" );
virtual ~XMLStyleOASISTContext() override
XMLTransformerActionInit const aTablePropertyOASISAttrActionTable[]
XMLTransformerActionInit const aTableCellPropertyOASISAttrActionTable[]
constexpr sal_uInt16 XML_NAMESPACE_CHART
XMLTransformerActionInit const aTableRowPropertyOASISAttrActionTable[]
const sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END]
XMLTransformerActionInit const aParagraphPropertyOASISAttrActionTable[]
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
bool const m_bControlStyle
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
XMLTransformerActionInit const aTableColumnPropertyOASISAttrActionTable[]
virtual bool IsPersistent() const override
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
virtual void EndElement() override
XMLTransformerActionInit const aGraphicPropertyOASISAttrActionTable[]
virtual void Characters(const OUString &rChars) override
XMLTransformerActionInit const aSectionPropertyOASISAttrActionTable[]
static XMLTransformerActions * CreateTransformerActions(sal_uInt16 nType)
constexpr sal_uInt16 XML_NAMESPACE_DRAW
XMLTokenEnum
The enumeration of all XML tokens.
static OUString const & MergeUnderline(XMLTokenEnum eUnderline, bool bBold, bool bDouble)
css::uno::Reference< css::xml::sax::XAttributeList > m_xAttrList
virtual void Export() override
constexpr sal_uInt16 XML_NAMESPACE_FO
bool getNextToken(std::u16string_view &rToken)
XMLTransformerActionInit const aChartPropertyOASISAttrActionTable[]
static OUString const & MergeLineThrough(XMLTokenEnum eLineThrough, bool bBold, bool bDouble, sal_Unicode c)
XMLPropertiesTContext_Impl(XMLTransformerBase &rTransformer, const OUString &rQName, XMLPropType eP, bool _bControlStyle)
XMLStyleOASISTContext(XMLTransformerBase &rTransformer, const OUString &rQName, bool bPersistent)
XMLTransformerActionInit const aListLevelPropertyOASISAttrActionTable[]
void SetQName(const OUString &rQName)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
XMLTransformerActionInit const aTextPropertyOASISAttrActionTable[]
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
const OUString & GetExportQName() const
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
XMLTransformerActionInit const aHeaderFooterPropertyOASISAttrActionTable[]
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
XMLTransformerBase & GetTransformer()
virtual void ExportContent() override
::rtl::Reference< XMLPropertiesTContext_Impl > m_xPropContext
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
XMLTransformerActionInit const aPageLayoutPropertyOASISAttrActionTable[]
Handling of tokens in XML:
virtual void ExportContent() override
XMLTransformerActionInit const aDrawingPagePropertyOASISAttrActionTable[]
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
static XMLPropType GetPropType(std::u16string_view rLocalName)
virtual void EndElement() override
constexpr sal_uInt16 XML_NAMESPACE_STYLE
virtual rtl::Reference< XMLTransformerContext > CreateChildContext(sal_uInt16 nPrefix, const OUString &rLocalName, const OUString &rQName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
void SetQNameAndPropType(const OUString &rQName, XMLPropType ePropType)