Rebased ref, commits from common ancestor: commit 942fe55273924125be666315fc1c15bb6e2fc88d Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Tue Mar 3 15:03:20 2015 +0100
OControlStyleContext fix changes Change-Id: Ic915ebfd717b699e13a8a82984346b897f4528f3 diff --git a/reportdesign/source/filter/xml/xmlStyleImport.cxx b/reportdesign/source/filter/xml/xmlStyleImport.cxx index e5758c3..4b9db69 100644 --- a/reportdesign/source/filter/xml/xmlStyleImport.cxx +++ b/reportdesign/source/filter/xml/xmlStyleImport.cxx @@ -87,12 +87,9 @@ OControlStyleContext::OControlStyleContext( ORptFilter& rImport, sal_Int32 Element, const Reference< XFastAttributeList >& xAttrList, SvXMLStylesContext& rStyles, sal_uInt16 nFamily, bool bDefaultStyle ) : XMLPropStyleContext( rImport, Element, xAttrList, rStyles, nFamily, bDefaultStyle ), - sNumberFormat(OUString("NumberFormat")), pStyles(&rStyles), m_nNumberFormat(-1), - m_rImport(rImport), - bConditionalFormatCreated(false), - bParentSet(false) + m_rImport(rImport) { } commit b7e937a3b43eba964400f9f4aaae3c206654eaf3 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 11:54:00 2015 +0100 XMLChartPropertyContext method implementation complete Change-Id: Ibd914008a55bdfa73e36abab6059bfba4fb20f40 diff --git a/xmloff/source/chart/XMLChartPropertyContext.cxx b/xmloff/source/chart/XMLChartPropertyContext.cxx index 7e97be6..92142f6 100644 --- a/xmloff/source/chart/XMLChartPropertyContext.cxx +++ b/xmloff/source/chart/XMLChartPropertyContext.cxx @@ -82,11 +82,32 @@ SvXMLImportContext* XMLChartPropertyContext::CreateChildContext( uno::Reference< xml::sax::XFastContextHandler > XMLChartPropertyContext::createFastChildContext( - sal_Int32 /*Element*/, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/, - std::vector< XMLPropertyState >& /*rProperties*/, - const XMLPropertyState& /*rProp*/ ) + sal_Int32 Element, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + std::vector< XMLPropertyState >& rProperties, + const XMLPropertyState& rProp ) { - return uno::Reference< xml::sax::XFastContextHandler >(); + uno::Reference< xml::sax::XFastContextHandler > pContext = 0; + + switch( mxMapper->getPropertySetMapper()->GetEntryContextId( rProp.mnIndex ) ) + { + case XML_SCH_CONTEXT_SPECIAL_SYMBOL_IMAGE: + pContext = new XMLSymbolImageContext( GetImport(), Element, + rProp, rProperties ); + break; + case XML_SCH_CONTEXT_SPECIAL_LABEL_SEPARATOR: + pContext = new XMLLabelSeparatorContext( GetImport(), Element, + rProp, rProperties ); + break; + } + + // default / no context yet: create child context by base class + if( !pContext.is() ) + { + pContext = SvXMLPropertySetContext::createFastChildContext( + Element, xAttrList, rProperties, rProp ); + } + + return pContext; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 66f0aec5e23471875a7ebc4cab7809a1fcae8503 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 11:53:05 2015 +0100 XMLSymbolImageContext implements fastparser ... interface Change-Id: Icc797d62c42a2fe90472cb4e8866cc73f3f631c1 diff --git a/xmloff/source/chart/XMLSymbolImageContext.cxx b/xmloff/source/chart/XMLSymbolImageContext.cxx index 8154e77..0126c81 100644 --- a/xmloff/source/chart/XMLSymbolImageContext.cxx +++ b/xmloff/source/chart/XMLSymbolImageContext.cxx @@ -66,6 +66,14 @@ XMLSymbolImageContext::XMLSymbolImageContext( { } +XMLSymbolImageContext::XMLSymbolImageContext( + SvXMLImport& rImport, sal_Int32 Element, + const XMLPropertyState& rProp, + ::std::vector< XMLPropertyState >& rProps ) +: XMLElementPropertyContext( rImport, Element, rProp, rProps ) +{ +} + XMLSymbolImageContext::~XMLSymbolImageContext() {} @@ -98,6 +106,30 @@ void XMLSymbolImageContext::StartElement( const uno::Reference< xml::sax::XAttri } } +void SAL_CALL XMLSymbolImageContext::startFastElement( sal_Int32 /*Element*/, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + SvXMLTokenMap aTokenMap( aSymbolImageAttrTokenMap ); + uno::Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + + for( xml::FastAttribute atrribute : attributes ) + { + switch( aTokenMap.Get( atrribute.Token ) ) + { + case XML_TOK_SYMBOL_IMAGE_HREF: + msURL = atrribute.Value; + break; + case XML_TOK_SYMBOL_IMAGE_ACTUATE: + case XML_TOK_SYMBOL_IMAGE_TYPE: + case XML_TOK_SYMBOL_IMAGE_SHOW: + // these values are currently not interpreted + // it is always assumed 'actuate=onLoad', 'type=simple', 'show=embed' + break; + } + } +} + SvXMLImportContext* XMLSymbolImageContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > & xAttrList ) @@ -123,6 +155,31 @@ SvXMLImportContext* XMLSymbolImageContext::CreateChildContext( return pContext; } +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL + XMLSymbolImageContext::createFastChildContext( sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + uno::Reference< xml::sax::XFastContextHandler > pContext = NULL; + if( XML_binary_data == (Element & XML_binary_data) ) + { + if( msURL.isEmpty() && !mxBase64Stream.is() ) + { + mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); + if( mxBase64Stream.is() ) + pContext = new XMLBase64ImportContext( GetImport(), + Element, xAttrList, mxBase64Stream ); + } + } + + if( !pContext.is() ) + { + pContext = new SvXMLImportContext( GetImport() ); + } + + return pContext; +} + void XMLSymbolImageContext::EndElement() { OUString sResolvedURL; @@ -147,4 +204,30 @@ void XMLSymbolImageContext::EndElement() XMLElementPropertyContext::EndElement(); } +void SAL_CALL XMLSymbolImageContext::endFastElement( sal_Int32 Element ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + OUString sResolvedURL; + + if( !msURL.isEmpty() ) + { + sResolvedURL = GetImport().ResolveGraphicObjectURL( msURL, false ); + } + else if( mxBase64Stream.is() ) + { + sResolvedURL = GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream ); + mxBase64Stream = 0; + } + + if( !sResolvedURL.isEmpty()) + { + // aProp is a member of XMLElementPropertyContext + aProp.maValue <<= sResolvedURL; + SetInsert( true ); + } + + XMLElementPropertyContext::endFastElement(Element); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/chart/XMLSymbolImageContext.hxx b/xmloff/source/chart/XMLSymbolImageContext.hxx index 718101c..5eeafed 100644 --- a/xmloff/source/chart/XMLSymbolImageContext.hxx +++ b/xmloff/source/chart/XMLSymbolImageContext.hxx @@ -34,14 +34,28 @@ public: const OUString& rLName, const XMLPropertyState& rProp, ::std::vector< XMLPropertyState > &rProps ); + XMLSymbolImageContext( SvXMLImport& rImport, sal_Int32 Element, + const XMLPropertyState& rProp, + ::std::vector< XMLPropertyState >& rProps ); virtual ~XMLSymbolImageContext(); virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual void SAL_CALL startFastElement( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; + virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; private: OUString msURL; commit dade552eb901136e15dcf17b44a70b7ef658c571 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 11:29:45 2015 +0100 XMLLabelSeparatorContext implements fastparser ... interface Change-Id: I3e7885659720a2af43ce0400822fb04bef2b3879 diff --git a/xmloff/source/chart/XMLLabelSeparatorContext.cxx b/xmloff/source/chart/XMLLabelSeparatorContext.cxx index bf7a9c3..e3961b3 100644 --- a/xmloff/source/chart/XMLLabelSeparatorContext.cxx +++ b/xmloff/source/chart/XMLLabelSeparatorContext.cxx @@ -25,6 +25,7 @@ #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmlimp.hxx> #include <xmloff/nmspmap.hxx> +#include <xmloff/token/tokens.hxx> TYPEINIT1( XMLLabelSeparatorContext, XMLElementPropertyContext ); @@ -41,6 +42,15 @@ XMLLabelSeparatorContext::XMLLabelSeparatorContext( { } +XMLLabelSeparatorContext::XMLLabelSeparatorContext( + SvXMLImport& rImport, sal_Int32 Element, + const XMLPropertyState& rProp, + ::std::vector< XMLPropertyState >& rProps ) +: XMLElementPropertyContext( rImport, Element, rProp, rProps ), + m_aSeparator() +{ +} + XMLLabelSeparatorContext::~XMLLabelSeparatorContext() {} @@ -48,6 +58,12 @@ void XMLLabelSeparatorContext::StartElement( const uno::Reference< xml::sax::XAt { } +void SAL_CALL XMLLabelSeparatorContext::startFastElement( sal_Int32 /*Element*/, + const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ +} + SvXMLImportContext* XMLLabelSeparatorContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< xml::sax::XAttributeList > & /*xAttrList*/ ) @@ -64,6 +80,23 @@ SvXMLImportContext* XMLLabelSeparatorContext::CreateChildContext( return pContext; } +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL + XMLLabelSeparatorContext::createFastChildContext( sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + uno::Reference< xml::sax::XFastContextHandler > pContext = NULL; + if( xmloff::XML_p == (Element & xmloff::XML_p) ) + { + pContext = new SchXMLParagraphContext( GetImport(), Element, + m_aSeparator ); + } + if( !pContext.is() ) + pContext = new SvXMLImportContext( GetImport() ); + + return pContext; +} + void XMLLabelSeparatorContext::EndElement() { if( !m_aSeparator.isEmpty() ) @@ -76,4 +109,17 @@ void XMLLabelSeparatorContext::EndElement() XMLElementPropertyContext::EndElement(); } +void SAL_CALL XMLLabelSeparatorContext::endFastElement( sal_Int32 Element ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + if( !m_aSeparator.isEmpty() ) + { + // aProp is a member of XMLElementPropertyContext + aProp.maValue <<= m_aSeparator; + SetInsert( true ); + } + + XMLElementPropertyContext::endFastElement( Element ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/chart/XMLLabelSeparatorContext.hxx b/xmloff/source/chart/XMLLabelSeparatorContext.hxx index aee92d6..0fdeefd 100644 --- a/xmloff/source/chart/XMLLabelSeparatorContext.hxx +++ b/xmloff/source/chart/XMLLabelSeparatorContext.hxx @@ -30,14 +30,28 @@ public: const OUString& rLName, const XMLPropertyState& rProp, ::std::vector< XMLPropertyState > &rProps ); + XMLLabelSeparatorContext( SvXMLImport& rImport, sal_Int32 Element, + const XMLPropertyState& rProp, + ::std::vector< XMLPropertyState >& rProps ); virtual ~XMLLabelSeparatorContext(); virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual void SAL_CALL startFastElement( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; + virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; + virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; private: OUString m_aSeparator; commit 8d6e0f30b38221ffda8c9c69abe52258af914b53 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 11:27:08 2015 +0100 SchXMLParagraphContext implements fastparser ... interface Change-Id: I4a2cf0d047faad624fa303fa8fc9dc5548c087e6 diff --git a/xmloff/source/chart/SchXMLParagraphContext.cxx b/xmloff/source/chart/SchXMLParagraphContext.cxx index ba8a254..bf02b8b 100644 --- a/xmloff/source/chart/SchXMLParagraphContext.cxx +++ b/xmloff/source/chart/SchXMLParagraphContext.cxx @@ -24,9 +24,13 @@ #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/nmspmap.hxx> +#include <xmloff/token/tokens.hxx> +#include <com/sun/star/xml/sax/FastToken.hpp> using namespace com::sun::star; using namespace ::xmloff::token; +using namespace xmloff; +using css::xml::sax::FastToken::NAMESPACE; SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport& rImport, const OUString& rLocalName, @@ -38,6 +42,15 @@ SchXMLParagraphContext::SchXMLParagraphContext( SvXMLImport& rImport, { } +SchXMLParagraphContext::SchXMLParagraphContext( + SvXMLImport& rImport, sal_Int32 /*Element*/, + OUString& rText, OUString * pOutId /* = 0 */ ) +: SvXMLImportContext( rImport ), + mrText( rText ), + mpId( pOutId ) +{ +} + SchXMLParagraphContext::~SchXMLParagraphContext() {} @@ -75,11 +88,39 @@ void SchXMLParagraphContext::StartElement( const uno::Reference< xml::sax::XAttr } } +void SAL_CALL SchXMLParagraphContext::startFastElement( sal_Int32 /*Element*/, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + // remember the id. It is used for storing the original cell range string in + // a local table (cached data) + if( mpId ) + { + bool bHaveXmlId( false ); + if( xAttrList->hasAttribute( NAMESPACE | XML_NAMESPACE_XML | XML_id ) ) + { + (*mpId) = xAttrList->getValue( NAMESPACE | XML_NAMESPACE_XML | XML_id ); + bHaveXmlId = true; + } + if( !bHaveXmlId // text:id shall be ignored if xml:id exists + && xAttrList->hasAttribute( NAMESPACE | XML_NAMESPACE_TEXT | XML_id ) ) + { + (*mpId) = xAttrList->getValue( NAMESPACE | XML_NAMESPACE_TEXT | XML_id ); + } + } +} + void SchXMLParagraphContext::EndElement() { mrText = maBuffer.makeStringAndClear(); } +void SAL_CALL SchXMLParagraphContext::endFastElement( sal_Int32 /*Element*/ ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + mrText = maBuffer.makeStringAndClear(); +} + SvXMLImportContext* SchXMLParagraphContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, @@ -100,9 +141,32 @@ SvXMLImportContext* SchXMLParagraphContext::CreateChildContext( return new SvXMLImportContext( GetImport(), nPrefix, rLocalName ); } +uno::Reference< xml::sax::XFastContextHandler > SAL_CALL + SchXMLParagraphContext::createFastChildContext( sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList >& ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + if( Element == (NAMESPACE | XML_NAMESPACE_TEXT | XML_tab_stop) ) + { + maBuffer.append( sal_Unicode( 0x0009 )); // tabulator + } + else if( Element == (NAMESPACE | XML_NAMESPACE_TEXT | XML_line_break) ) + { + maBuffer.append( sal_Unicode( 0x000A )); // linefedd + } + + return new SvXMLImportContext( GetImport() ); +} + void SchXMLParagraphContext::Characters( const OUString& rChars ) { maBuffer.append( rChars ); } +void SAL_CALL SchXMLParagraphContext::characters( const OUString& rChars ) + throw(uno::RuntimeException, xml::sax::SAXException, std::exception) +{ + maBuffer.append( rChars ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/chart/SchXMLParagraphContext.hxx b/xmloff/source/chart/SchXMLParagraphContext.hxx index 970e434..1522c55 100644 --- a/xmloff/source/chart/SchXMLParagraphContext.hxx +++ b/xmloff/source/chart/SchXMLParagraphContext.hxx @@ -39,16 +39,30 @@ public: const OUString& rLocalName, OUString& rText, OUString * pOutId = 0 ); + SchXMLParagraphContext( SvXMLImport& rImport, sal_Int32 Element, + OUString& rText, OUString *pOutId = 0); virtual ~SchXMLParagraphContext(); virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual void SAL_CALL startFastElement( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; + virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; virtual SvXMLImportContext* CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; virtual void Characters( const OUString& rChars ) SAL_OVERRIDE; + virtual void SAL_CALL characters( const OUString& rChars ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; #endif // INCLUDED_XMLOFF_SOURCE_CHART_SCHXMLPARAGRAPHCONTEXT_HXX commit 5332caff51bfe3a527a0eec27bfc6190152c3fb8 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 10:32:52 2015 +0100 XMLTableCellPropsContext method implementation ... complete Change-Id: I2ed9666fd3b23b003f88b98781107ec50396f8b8 diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 3c21db0..282c503 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -367,12 +367,30 @@ SvXMLImportContext* XMLTableCellPropsContext::CreateChildContext( sal_uInt16 nPr } uno::Reference< xml::sax::XFastContextHandler > - XMLTableCellPropsContext::createFastChildContext( sal_Int32 /*Element*/, - const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/, - std::vector< XMLPropertyState >& /*rProperties*/, - const XMLPropertyState& /*rProp*/ ) + XMLTableCellPropsContext::createFastChildContext( sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + std::vector< XMLPropertyState >& rProperties, + const XMLPropertyState& rProp ) { - return uno::Reference< xml::sax::XFastContextHandler >(); + // no need for a custom context or indeed a SvXMLTokenMap to grab just the + // single attribute ( href ) that we are interested in. + // still though, we will check namespaces etd. + if( Element == (FastToken::NAMESPACE | XML_NAMESPACE_STYLE | XML_hyperlink) ) + { + OUString sURL; + if( xAttrList->hasAttribute( FastToken::NAMESPACE | XML_NAMESPACE_XLINK | XML_href) ) + { + sURL = xAttrList->getValue( FastToken::NAMESPACE | XML_NAMESPACE_XLINK | XML_href ); + } + if( !sURL.isEmpty() ) + { + XMLPropertyState aProp( rProp ); + aProp.maValue <<= sURL; + rProperties.push_back( aProp ); + } + } + return SvXMLPropertySetContext::createFastChildContext( Element, + xAttrList, rProperties, rProp ); } class ScXMLMapContext : public SvXMLImportContext commit 5fce3ebc9cac5061ec224032be7709ea602bcf00 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 10:21:49 2015 +0100 XMLTextShapePropertySetContext_Impl method ... implementation complete Change-Id: I305be7c2c08199da06a5d97b5111bee1b71af3d1 diff --git a/xmloff/source/text/XMLTextShapeStyleContext.cxx b/xmloff/source/text/XMLTextShapeStyleContext.cxx index 05f14ce..784646e 100644 --- a/xmloff/source/text/XMLTextShapeStyleContext.cxx +++ b/xmloff/source/text/XMLTextShapeStyleContext.cxx @@ -154,7 +154,7 @@ Reference< XFastContextHandler > switch( mxMapper->getPropertySetMapper()->GetEntryContextId( rProp.mnIndex ) ) { case CTF_TEXTCOLUMNS: - //pContext = new XMLTextColumnsContext( GetImport(), Element, xAttrList, rProp, rProperties ); + pContext = new XMLTextColumnsContext( GetImport(), Element, xAttrList, rProp, rProperties ); break; case CTF_BACKGROUND_URL: DBG_ASSERT( rProp.mnIndex >= 3 && @@ -166,9 +166,9 @@ Reference< XFastContextHandler > CTF_BACKGROUND_FILTER == mxMapper->getPropertySetMapper() ->GetEntryContextId( rProp.mnIndex-1 ), "invalid property map!" ); - //pContext = new XMLBackgroundImageContext( GetImport(), Element, - // xAttrList, rProp, rProp.mnIndex-2, rProp.mnIndex-1, - // rProp.mnIndex-3, rProperties ); + pContext = new XMLBackgroundImageContext( GetImport(), Element, + xAttrList, rProp, rProp.mnIndex-2, rProp.mnIndex-1, + rProp.mnIndex-3, rProperties ); break; } commit 2c7d7145197f354c4a672a62986645abcd4631b1 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 10:15:40 2015 +0100 XMLBackgroundImageContext implements fastparser .. interface Change-Id: I1f364a9acefae7e782e359dd4ee1b5c634a05eb2 diff --git a/xmloff/inc/XMLBackgroundImageContext.hxx b/xmloff/inc/XMLBackgroundImageContext.hxx index 3fb3ca1..7bac0550 100644 --- a/xmloff/inc/XMLBackgroundImageContext.hxx +++ b/xmloff/inc/XMLBackgroundImageContext.hxx @@ -44,6 +44,8 @@ private: void ProcessAttrs( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); + void ProcessAttrs( + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ); public: TYPEINFO_OVERRIDE(); @@ -59,6 +61,11 @@ public: sal_Int32 nFilterIdx, sal_Int32 nTransparencyIdx, ::std::vector< XMLPropertyState > &rProps ); + XMLBackgroundImageContext( SvXMLImport& rImport, sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + const XMLPropertyState& rProp, + sal_Int32 nPosIdx, sal_Int32 nFilterIdx, sal_Int32 nTransparencyIdx, + ::std::vector< XMLPropertyState >& rProps ); virtual ~XMLBackgroundImageContext(); @@ -66,8 +73,14 @@ public: const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; diff --git a/xmloff/source/style/XMLBackgroundImageContext.cxx b/xmloff/source/style/XMLBackgroundImageContext.cxx index 6459f15..a204f5e 100644 --- a/xmloff/source/style/XMLBackgroundImageContext.cxx +++ b/xmloff/source/style/XMLBackgroundImageContext.cxx @@ -337,6 +337,155 @@ void XMLBackgroundImageContext::ProcessAttrs( } +void XMLBackgroundImageContext::ProcessAttrs( + const Reference< xml::sax::XFastAttributeList >& xAttrList ) +{ + SvXMLTokenMap aTokenMap( lcl_getBGImgAttributesAttrTokenMap() ); + + ePos = GraphicLocation_NONE; + + uno::Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( xml::FastAttribute attribute : attributes ) + { + switch( aTokenMap.Get( attribute.Token ) ) + { + case XML_TOK_BGIMG_HREF: + sURL = attribute.Value; + if( GraphicLocation_NONE == ePos ) + ePos = GraphicLocation_TILED; + break; + case XML_TOK_BGIMG_TYPE: + case XML_TOK_BGIMG_ACTUATE: + case XML_TOK_BGIMG_SHOW: + break; + case XML_TOK_BGIMG_POSITION: + { + GraphicLocation eNewPos = GraphicLocation_NONE, eTmp; + sal_uInt16 nTmp; + SvXMLTokenEnumerator aTokenEnum( attribute.Value ); + OUString aToken; + bool bHori = false, bVert = false; + bool bOK = true; + while( bOK && aTokenEnum.getNextToken( aToken ) ) + { + if( bHori && bVert ) + { + bOK = false; + } + else if( -1 != aToken.indexOf( '%' ) ) + { + sal_Int32 nPrc = 50; + if (::sax::Converter::convertPercent( nPrc, aToken )) + { + if( !bHori ) + { + eNewPos = nPrc < 25 + ? GraphicLocation_LEFT_TOP + : (nPrc < 75 ? GraphicLocation_MIDDLE_MIDDLE + : GraphicLocation_RIGHT_BOTTOM); + bHori = true; + } + else + { + eTmp = nPrc < 25 + ? GraphicLocation_LEFT_TOP + : (nPrc < 75 ? GraphicLocation_LEFT_MIDDLE + : GraphicLocation_LEFT_BOTTOM); + lcl_xmlbic_MergeVertPos( eNewPos, eTmp ); + bVert = true; + } + } + else + { + // wrong percentage + bOK = false; + } + } + else if( aToken.equals( "center" ) ) + { + if( bHori ) + lcl_xmlbic_MergeVertPos( eNewPos, + GraphicLocation_MIDDLE_MIDDLE ); + else if( bVert ) + lcl_xmlbic_MergeHoriPos( eNewPos, + GraphicLocation_MIDDLE_MIDDLE ); + else + eNewPos = GraphicLocation_MIDDLE_MIDDLE; + } + else if( SvXMLUnitConverter::convertEnum( nTmp, aToken, + psXML_BrushHoriPos ) ) + { + if( bVert ) + lcl_xmlbic_MergeHoriPos( eNewPos, + (GraphicLocation)nTmp ); + else if( !bHori ) + eNewPos = (GraphicLocation)nTmp; + else + bOK = false; + bHori = true; + } + else if( SvXMLUnitConverter::convertEnum( nTmp, aToken, + psXML_BrushVertPos ) ) + { + if( bHori ) + lcl_xmlbic_MergeVertPos( eNewPos, + (GraphicLocation)nTmp ); + else if( !bVert ) + eNewPos = (GraphicLocation)nTmp; + else + bOK = false; + bVert = true; + } + else + { + bOK = false; + } + } + + bOK &= GraphicLocation_NONE != eNewPos; + if( bOK ) + ePos = eNewPos; + } + break; + case XML_TOK_BGIMG_REPEAT: + { + sal_uInt16 nPos = GraphicLocation_NONE; + static const SvXMLEnumMapEntry psXML_BrushRepeat[] = + { + { XML_BACKGROUND_REPEAT, GraphicLocation_TILED }, + { XML_BACKGROUND_NO_REPEAT, GraphicLocation_MIDDLE_MIDDLE }, + { XML_BACKGROUND_STRETCH, GraphicLocation_AREA }, + { xmloff::token::XML_TOKEN_INVALID, 0 } + }; + if( SvXMLUnitConverter::convertEnum( nPos, attribute.Value, + psXML_BrushRepeat ) ) + { + if( GraphicLocation_MIDDLE_MIDDLE != nPos || + GraphicLocation_NONE == ePos || + GraphicLocation_AREA == ePos || + GraphicLocation_TILED == ePos ) + ePos = (GraphicLocation)nPos; + } + } + break; + case XML_TOK_BGIMG_FILTER: + sFilter = attribute.Value; + break; + case XML_TOK_BGIMG_OPACITY: + { + sal_Int32 nTmp; + // convert from percent and clip + if( ::sax::Converter::convertPercent( nTmp, attribute.Value ) ) + { + if( (nTmp >= 0) && (nTmp <= 100) ) + nTransparency = static_cast<sal_Int8>( 100-nTmp ); + } + } + break; + } + } +} + XMLBackgroundImageContext::XMLBackgroundImageContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLName, @@ -355,6 +504,21 @@ XMLBackgroundImageContext::XMLBackgroundImageContext( ProcessAttrs( xAttrList ); } +XMLBackgroundImageContext::XMLBackgroundImageContext( + SvXMLImport& rImport, sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList, + const XMLPropertyState& rProp, sal_Int32 nPosIdx, + sal_Int32 nFilterIdx, sal_Int32 nTransparencyIdx, + ::std::vector< XMLPropertyState >& rProps ) +: XMLElementPropertyContext( rImport, Element, rProp, rProps ), + aPosProp( nPosIdx ), + aFilterProp( nFilterIdx ), + aTransparencyProp( nTransparencyIdx ), + nTransparency( 0 ) +{ + ProcessAttrs( xAttrList ); +} + XMLBackgroundImageContext::~XMLBackgroundImageContext() { } @@ -385,6 +549,31 @@ SvXMLImportContext *XMLBackgroundImageContext::CreateChildContext( return pContext; } +Reference< xml::sax::XFastContextHandler > SAL_CALL + XMLBackgroundImageContext::createFastChildContext( sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + Reference< XFastContextHandler > pContext = NULL; + + if( Element == (NAMESPACE | XML_NAMESPACE_OFFICE | XML_binary_data) ) + { + if( sURL.isEmpty() && !xBase64Stream.is() ) + { + xBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64(); + if( xBase64Stream.is() ) + pContext = new XMLBase64ImportContext( GetImport(), + Element, xAttrList, xBase64Stream ); + } + } + if( !pContext.is() ) + { + pContext = new SvXMLImportContext( GetImport() ); + } + + return pContext; +} + void XMLBackgroundImageContext::EndElement() { if( !sURL.isEmpty() ) @@ -418,4 +607,38 @@ void XMLBackgroundImageContext::EndElement() rProperties.push_back( aTransparencyProp ); } +void SAL_CALL XMLBackgroundImageContext::endFastElement( sal_Int32 Element ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + if( !sURL.isEmpty() ) + { + sURL = GetImport().ResolveGraphicObjectURL( sURL, false ); + } + else if( xBase64Stream.is() ) + { + sURL = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream ); + xBase64Stream = 0; + } + + if( sURL.isEmpty() ) + ePos = GraphicLocation_NONE; + else if( GraphicLocation_NONE == ePos ) + ePos = GraphicLocation_TILED; + + aProp.maValue <<= sURL; + aPosProp.maValue <<= ePos; + aFilterProp.maValue <<= sFilter; + aTransparencyProp.maValue <<= nTransparency; + + SetInsert( true ); + XMLElementPropertyContext::endFastElement(Element); + + if( -1 != aPosProp.mnIndex ) + rProperties.push_back( aPosProp ); + if( -1 != aFilterProp.mnIndex ) + rProperties.push_back( aFilterProp ); + if( -1 != aTransparencyProp.mnIndex ) + rProperties.push_back( aTransparencyProp ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 9ebc1820c80f55f2d6e1953d364dbba44e427397 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 09:37:17 2015 +0100 XMLTextColumnsContext implements fastparser ... interface Change-Id: Idcd82c684d4c88731f68596852183eeb389616bc diff --git a/xmloff/inc/XMLTextColumnsContext.hxx b/xmloff/inc/XMLTextColumnsContext.hxx index 9a10ac6..b3a57af 100644 --- a/xmloff/inc/XMLTextColumnsContext.hxx +++ b/xmloff/inc/XMLTextColumnsContext.hxx @@ -57,14 +57,24 @@ public: ::com::sun::star::xml::sax::XAttributeList > & xAttrList, const XMLPropertyState& rProp, ::std::vector< XMLPropertyState > &rProps ); + XMLTextColumnsContext( SvXMLImport& rImport, sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + const XMLPropertyState& rProp, + ::std::vector< XMLPropertyState >& rProps ); virtual ~XMLTextColumnsContext(); virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; diff --git a/xmloff/source/text/XMLTextColumnsContext.cxx b/xmloff/source/text/XMLTextColumnsContext.cxx index 751c53e..a96a4e2 100644 --- a/xmloff/source/text/XMLTextColumnsContext.cxx +++ b/xmloff/source/text/XMLTextColumnsContext.cxx @@ -428,6 +428,45 @@ XMLTextColumnsContext::XMLTextColumnsContext( } } +XMLTextColumnsContext::XMLTextColumnsContext( + SvXMLImport& rImport, sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList, + const XMLPropertyState& rProp, + ::std::vector< XMLPropertyState >& rProps ) +: XMLElementPropertyContext( rImport, Element, rProp, rProps ) +, sSeparatorLineIsOn("SeparatorLineIsOn") +, sSeparatorLineWidth("SeparatorLineWidth") +, sSeparatorLineColor("SeparatorLineColor") +, sSeparatorLineRelativeHeight("SeparatorLineRelativeHeight") +, sSeparatorLineVerticalAlignment("SeparatorLineVerticalAlignment") +, sAutomaticDistance("AutomaticDistance") +, sSeparatorLineStyle("SeparatorLineStyle") +, pColumns( 0 ) +, pColumnSep( 0 ) +, pColumnAttrTokenMap( new SvXMLTokenMap(aColAttrTokenMap) ) +, pColumnSepAttrTokenMap( new SvXMLTokenMap(aColSepAttrTokenMap) ) +, nCount( 0 ) +, bAutomatic( false ) +, nAutomaticDistance( 0 ) +{ + sal_Int32 nVal; + if( xAttrList->hasAttribute( NAMESPACE | XML_NAMESPACE_FO | XML_column_count ) ) + { + if( ::sax::Converter::convertNumber( nVal, + xAttrList->getValue( NAMESPACE | XML_NAMESPACE_FO | XML_column_count ), + 0, SHRT_MAX ) ) + { + nCount = static_cast< sal_Int16 >( nVal ); + } + } + else if( xAttrList->hasAttribute( NAMESPACE | XML_NAMESPACE_FO | XML_column_gap ) ) + { + bAutomatic = GetImport().GetMM100UnitConverter(). + convertMeasureToCore( nAutomaticDistance, + xAttrList->getValue( NAMESPACE | XML_NAMESPACE_FO | XML_column_gap ) ); + } +} + XMLTextColumnsContext::~XMLTextColumnsContext() { if( pColumns ) @@ -487,6 +526,44 @@ SvXMLImportContext *XMLTextColumnsContext::CreateChildContext( return pContext; } +Reference< xml::sax::XFastContextHandler > SAL_CALL + XMLTextColumnsContext::createFastChildContext( sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + SvXMLImportContext *pContext = 0; + + if( Element == (NAMESPACE | XML_NAMESPACE_STYLE | XML_column) ) + { + XMLTextColumnContext_Impl *pColumn = + new XMLTextColumnContext_Impl( GetImport(), Element, + xAttrList, *pColumnAttrTokenMap ); + + // add new tabstop to array of tabstops + if( !pColumns ) + pColumns = new XMLTextColumnsArray_Impl; + + pColumns->push_back( pColumn ); + pColumn->AddFirstRef(); + + pContext = pColumn; + } + else if( Element == (NAMESPACE | XML_NAMESPACE_STYLE | XML_column_sep) ) + { + pColumnSep = new XMLTextColumnSepContext_Impl( GetImport(), + Element, xAttrList, *pColumnSepAttrTokenMap ); + pColumnSep->AddFirstRef(); + + pContext = pColumnSep; + } + else + { + pContext = new SvXMLImportContext( GetImport() ); + } + + return pContext; +} + void XMLTextColumnsContext::EndElement( ) { Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY); @@ -608,4 +685,126 @@ void XMLTextColumnsContext::EndElement( ) } +void SAL_CALL XMLTextColumnsContext::endFastElement( sal_Int32 Element ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY); + if( !xFactory.is() ) + return; + + Reference<XInterface> xIfc = xFactory->createInstance("com.sun.star.text.TextColumns"); + if( !xIfc.is() ) + return; + + Reference< XTextColumns > xColumns( xIfc, UNO_QUERY ); + if ( 0 == nCount ) + { + // zero columns = no columns -> 1 column + xColumns->setColumnCount( 1 ); + } + else if( !bAutomatic && pColumns && + pColumns->size() == (sal_uInt16)nCount ) + { + // if we have column descriptions, one per column, and we don't use + // automatic width, then set the column widths + + sal_Int32 nRelWidth = 0; + sal_uInt16 nColumnsWithWidth = 0; + sal_Int16 i; + + for( i = 0; i < nCount; i++ ) + { + const TextColumn& rColumn = + (*pColumns)[(sal_uInt16)i]->getTextColumn(); + if( rColumn.Width > 0 ) + { + nRelWidth += rColumn.Width; + nColumnsWithWidth++; + } + } + if( nColumnsWithWidth < nCount ) + { + sal_Int32 nColWidth = 0==nRelWidth + ? USHRT_MAX / nCount + : nRelWidth / nColumnsWithWidth; + + for( i=0; i < nCount; i++ ) + { + TextColumn& rColumn = + (*pColumns)[(sal_uInt16)i]->getTextColumn(); + if( rColumn.Width == 0 ) + { + rColumn.Width = nColWidth; + nRelWidth += rColumn.Width; + if( 0 == --nColumnsWithWidth ) + break; + } + } + } + + Sequence< TextColumn > aColumns( (sal_Int32)nCount ); + TextColumn *pTextColumns = aColumns.getArray(); + for( i=0; i < nCount; i++ ) + *pTextColumns++ = (*pColumns)[(sal_uInt16)i]->getTextColumn(); + + xColumns->setColumns( aColumns ); + } + else + { + // only set column count (and let the columns be distributed + // automatically) + + xColumns->setColumnCount( nCount ); + } + + Reference < XPropertySet > xPropSet( xColumns, UNO_QUERY ); + if( xPropSet.is() ) + { + Any aAny; + sal_Bool bOn = pColumnSep != 0; + + aAny.setValue( &bOn, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sSeparatorLineIsOn, aAny ); + + if( pColumnSep ) + { + if( pColumnSep->GetWidth() ) + { + aAny <<= pColumnSep->GetWidth(); + xPropSet->setPropertyValue( sSeparatorLineWidth, aAny ); + } + if( pColumnSep->GetHeight() ) + { + aAny <<= pColumnSep->GetHeight(); + xPropSet->setPropertyValue( sSeparatorLineRelativeHeight, + aAny ); + } + if ( pColumnSep->GetStyle() ) + { + aAny <<= pColumnSep->GetStyle(); + xPropSet->setPropertyValue( sSeparatorLineStyle, aAny ); + } + + aAny <<= pColumnSep->GetColor(); + xPropSet->setPropertyValue( sSeparatorLineColor, aAny ); + + aAny <<= pColumnSep->GetVertAlign(); + xPropSet->setPropertyValue( sSeparatorLineVerticalAlignment, aAny ); + } + + // handle 'automatic columns': column distance + if( bAutomatic ) + { + aAny <<= nAutomaticDistance; + xPropSet->setPropertyValue( sAutomaticDistance, aAny ); + } + } + + aProp.maValue <<= xColumns; + + SetInsert( true ); + XMLElementPropertyContext::endFastElement(Element); + +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 050c11d4f880ff627ebb0115e0d753c1c0f33961 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 09:36:23 2015 +0100 XMLTextColumnSepContext_Impl implements fastparser ... interface Change-Id: I193c46caa7dee76a77a6d5bc017ac95c5f97509e diff --git a/xmloff/source/text/XMLTextColumnsContext.cxx b/xmloff/source/text/XMLTextColumnsContext.cxx index e93800c..751c53e 100644 --- a/xmloff/source/text/XMLTextColumnsContext.cxx +++ b/xmloff/source/text/XMLTextColumnsContext.cxx @@ -245,6 +245,9 @@ public: const uno::Reference< xml::sax::XAttributeList > & xAttrList, const SvXMLTokenMap& rTokenMap ); + XMLTextColumnSepContext_Impl( SvXMLImport& rImport, sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + const SvXMLTokenMap& rTokenMap ); virtual ~XMLTextColumnSepContext_Impl(); @@ -318,6 +321,58 @@ XMLTextColumnSepContext_Impl::XMLTextColumnSepContext_Impl( } } +XMLTextColumnSepContext_Impl::XMLTextColumnSepContext_Impl( + SvXMLImport& rImport, sal_Int32 /*Element*/, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + const SvXMLTokenMap& rTokenMap ) +: SvXMLImportContext( rImport ), + nWidth( 2 ), + nColor( 0 ), + nHeight( 100 ), + nStyle( 1 ), + eVertAlign( VerticalAlignment_TOP ) +{ + uno::Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( xml::FastAttribute attribute : attributes ) + { + sal_Int32 nVal; + switch( rTokenMap.Get( attribute.Token ) ) + { + case XML_TOK_COLUMN_SEP_WIDTH: + if( GetImport().GetMM100UnitConverter(). + convertMeasureToCore( nVal, attribute.Value ) ) + nWidth = nVal; + break; + case XML_TOK_COLUMN_SEP_HEIGHT: + if( ::sax::Converter::convertPercent( nVal, attribute.Value ) + && nVal >= 1 && nVal <= 100 ) + nHeight = (sal_Int8)nVal; + break; + case XML_TOK_COLUMN_SEP_COLOR: + { + ::sax::Converter::convertColor( nColor, attribute.Value ); + } + break; + case XML_TOK_COLUMN_SEP_ALIGN: + { + sal_uInt16 nAlign; + if( SvXMLUnitConverter::convertEnum( nAlign, attribute.Value, + pXML_Sep_Align_Enum ) ) + eVertAlign = (VerticalAlignment)nAlign; + } + break; + case XML_TOK_COLUMN_SEP_STYLE: + { + sal_uInt16 nStyleVal; + if( SvXMLUnitConverter::convertEnum( nStyleVal, attribute.Value, + pXML_Sep_Style_Enum ) ) + nStyle = (sal_Int8)nStyleVal; + } + break; + } + } +} + XMLTextColumnSepContext_Impl::~XMLTextColumnSepContext_Impl() { } commit 42e294714566e6ff53aed0aaff79cd7fc10e7c1e Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 09:35:09 2015 +0100 XMLTextColumnContext_Impl implements fastparser .. interface Change-Id: I42463ad08bcdf9e03338d8cdfb0db6caa582b4f9 diff --git a/xmloff/source/text/XMLTextColumnsContext.cxx b/xmloff/source/text/XMLTextColumnsContext.cxx index ab6776d..e93800c 100644 --- a/xmloff/source/text/XMLTextColumnsContext.cxx +++ b/xmloff/source/text/XMLTextColumnsContext.cxx @@ -116,6 +116,9 @@ public: const uno::Reference< xml::sax::XAttributeList > & xAttrList, const SvXMLTokenMap& rTokenMap ); + XMLTextColumnContext_Impl( SvXMLImport& rImport, sal_Int32 Element, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + const SvXMLTokenMap& rTokenMap ); virtual ~XMLTextColumnContext_Impl(); @@ -178,6 +181,50 @@ XMLTextColumnContext_Impl::XMLTextColumnContext_Impl( } } +XMLTextColumnContext_Impl::XMLTextColumnContext_Impl( + SvXMLImport& rImport, sal_Int32 /*Element*/, + const uno::Reference< xml::sax::XFastAttributeList >& xAttrList, + const SvXMLTokenMap& rTokenMap ) +: SvXMLImportContext( rImport ) +{ + aColumn.Width = 0; + aColumn.LeftMargin = 0; + aColumn.RightMargin = 0; + + uno::Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( xml::FastAttribute attribute : attributes ) + { + sal_Int32 nVal; + switch( rTokenMap.Get( attribute.Token ) ) + { + case XML_TOK_COLUMN_WIDTH: + { + sal_Int32 nPos = attribute.Value.indexOf( (sal_Unicode)'*' ); + if( nPos != -1 && nPos+1 == attribute.Value.getLength() ) + { + OUString sTmp( attribute.Value.copy( 0, nPos ) ); + if( ::sax::Converter::convertNumber( + nVal, sTmp, 0, USHRT_MAX ) ) + aColumn.Width = nVal; + } + } + break; + case XML_TOK_COLUMN_MARGIN_LEFT: + if( GetImport().GetMM100UnitConverter(). + convertMeasureToCore( nVal, attribute.Value ) ) + aColumn.LeftMargin = nVal; + break; + case XML_TOK_COLUMN_MARGIN_RIGHT: + if( GetImport().GetMM100UnitConverter(). + convertMeasureToCore( nVal, attribute.Value ) ) + aColumn.RightMargin = nVal; + break; + default: + break; + } + } +} + XMLTextColumnContext_Impl::~XMLTextColumnContext_Impl() { } commit 88cba687d497b23d9d19af4b3a0d6ea08281701e Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 09:32:29 2015 +0100 XMLElementPropertyContext implements fastparser .. interface Change-Id: I0703a6f8cb4fcfe121260a56a743369afb69300e diff --git a/xmloff/inc/XMLElementPropertyContext.hxx b/xmloff/inc/XMLElementPropertyContext.hxx index f89630b..b16153f 100644 --- a/xmloff/inc/XMLElementPropertyContext.hxx +++ b/xmloff/inc/XMLElementPropertyContext.hxx @@ -46,10 +46,15 @@ public: const OUString& rLName, const XMLPropertyState& rProp, ::std::vector< XMLPropertyState > &rProps ); + XMLElementPropertyContext( SvXMLImport& rImport, sal_Int32 Element, + const XMLPropertyState& rProp, + ::std::vector< XMLPropertyState >& rProps ); virtual ~XMLElementPropertyContext(); virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; diff --git a/xmloff/source/style/XMLElementPropertyContext.cxx b/xmloff/source/style/XMLElementPropertyContext.cxx index 79198a7..02b23e5 100644 --- a/xmloff/source/style/XMLElementPropertyContext.cxx +++ b/xmloff/source/style/XMLElementPropertyContext.cxx @@ -34,6 +34,17 @@ XMLElementPropertyContext::XMLElementPropertyContext ( { } +XMLElementPropertyContext::XMLElementPropertyContext( + SvXMLImport& rImport, sal_Int32 /*Element*/, + const XMLPropertyState& rProp, + std::vector< XMLPropertyState >& rProps ) +: SvXMLImportContext( rImport ), + bInsert( false ), + rProperties( rProps ), + aProp( rProp ) +{ +} + XMLElementPropertyContext::~XMLElementPropertyContext() { } @@ -44,5 +55,12 @@ void XMLElementPropertyContext::EndElement( ) rProperties.push_back( aProp ); } +void SAL_CALL XMLElementPropertyContext::endFastElement( sal_Int32 /*Element*/ ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) +{ + if( bInsert ) + rProperties.push_back( aProp ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 50e22cdf6c4b40efa9c51cea07497124cca12273 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:39:55 2015 +0100 XMLTextFrameContext method implementation ... for fastparser usage Change-Id: If0566704ba269c0fbee0890e5d7284385a8bde58 diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 64e5b2f..50c7e28 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -1656,6 +1656,35 @@ XMLTextFrameContext::XMLTextFrameContext( m_HasAutomaticStyleWithoutParentStyle( false ), m_bSupportsReplacement( false ) { + if( xAttrList.is() ) + { + if( xAttrList->hasAttribute( NAMESPACE | XML_NAMESPACE_DRAW | XML_style_name ) ) + { + OUString aStyleName = xAttrList->getValue( NAMESPACE | XML_NAMESPACE_DRAW | XML_style_name ); + if( !aStyleName.isEmpty() ) + { + rtl::Reference< XMLTextImportHelper > xTxtImport = + GetImport().GetTextImport(); + XMLPropStyleContext* pStyle( 0L ); + pStyle = xTxtImport->FindAutoFrameStyle( aStyleName ); + if( pStyle && pStyle->GetParentName().isEmpty() ) + { + m_HasAutomaticStyleWithoutParentStyle = true; + } + } + } + else if( xAttrList->hasAttribute( NAMESPACE | XML_NAMESPACE_TEXT | XML_anchor_type ) ) + { + TextContentAnchorType eNew; + if( XMLAnchorTypePropHdl::convert( + xAttrList->getValue( NAMESPACE | XML_NAMESPACE_TEXT | XML_anchor_type ), eNew ) + && ( TextContentAnchorType_AT_PARAGRAPH == eNew || + TextContentAnchorType_AT_CHARACTER == eNew || + TextContentAnchorType_AS_CHARACTER == eNew || + TextContentAnchorType_AT_PAGE == eNew ) ) + m_eDefaultAnchorType = eNew; + } + } } XMLTextFrameContext::~XMLTextFrameContext() @@ -1706,6 +1735,43 @@ void XMLTextFrameContext::EndElement() void SAL_CALL XMLTextFrameContext::endFastElement( sal_Int32 /*Element*/ ) throw(RuntimeException, SAXException, std::exception) { + /// solve if multiple image child contexts were imported + SvXMLImportContextRef const pMultiContext(solveMultipleImages()); + + SvXMLImportContext const*const pContext = + (pMultiContext) ? &pMultiContext : &m_xImplContext; + XMLTextFrameContext_Impl *pImpl = const_cast<XMLTextFrameContext_Impl*>(PTR_CAST( XMLTextFrameContext_Impl, pContext )); + assert(!pMultiContext || pImpl); + if( pImpl ) + { + pImpl->CreateIfNotThere(); + + // fdo#68839: in case the surviving image was not the first one, + // it will have a counter added to its name - set the original name + if (pMultiContext) // do this only when necessary; esp. not for text + { // frames that may have entries in GetRenameMap()! + pImpl->SetName(); + } + + if( !m_sTitle.isEmpty() ) + { + pImpl->SetTitle( m_sTitle ); + } + if( !m_sDesc.isEmpty() ) + { + pImpl->SetDesc( m_sDesc ); + } + + if( m_pHyperlink ) + { + pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(), + m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() ); + delete m_pHyperlink; + m_pHyperlink = 0; + } + + } + } SvXMLImportContext *XMLTextFrameContext::CreateChildContext( @@ -1918,11 +1984,186 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( } Reference< XFastContextHandler > SAL_CALL - XMLTextFrameContext::createFastChildContext( sal_Int32 /*Element*/, - const Reference< XFastAttributeList >& /*xAttrList*/ ) + XMLTextFrameContext::createFastChildContext( sal_Int32 Element, + const Reference< XFastAttributeList >& xAttrList ) throw(RuntimeException, SAXException, std::exception) { - Reference< XFastContextHandler > pContext = 0; + SvXMLImportContext *pContext = 0; + + if( !m_xImplContext.Is() ) + { + // no child exists + sal_uInt16 nFrameType = USHRT_MAX; + if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_text_box) ) + nFrameType = XML_TEXT_FRAME_TEXTBOX; + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_image) ) + nFrameType = XML_TEXT_FRAME_GRAPHIC; + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_object) ) + nFrameType = XML_TEXT_FRAME_OBJECT; + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_object_ole) ) + nFrameType = XML_TEXT_FRAME_OBJECT_OLE; + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_applet) ) + nFrameType = XML_TEXT_FRAME_APPLET; + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_plugin) ) + nFrameType = XML_TEXT_FRAME_PLUGIN; + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_floating_frame) ) + nFrameType = XML_TEXT_FRAME_FLOATING_FRAME; + + if( USHRT_MAX != nFrameType ) + { + // Shapes in Writer cannot be named via context menu (#i51726#) + if( ( XML_TEXT_FRAME_TEXTBOX == nFrameType || + XML_TEXT_FRAME_GRAPHIC == nFrameType ) && + m_HasAutomaticStyleWithoutParentStyle ) + { + Reference< XShapes > xShapes; + pContext = GetImport().GetShapeImport()->CreateFrameChildContext( + GetImport(), Element, xAttrList, xShapes, m_xFastAttrList ); + } + else if( XML_TEXT_FRAME_PLUGIN == nFrameType ) + { + bool bMedia = false; + + // check, if we have a media object + if( xAttrList->hasAttribute( NAMESPACE | XML_NAMESPACE_DRAW | XML_mime_type ) ) + { + bMedia = xAttrList->getValue( NAMESPACE | XML_NAMESPACE_DRAW | XML_mime_type ).equals( + "application/vnd.sun.star.media" ); + } + + if( bMedia ) + { + Reference< XShapes > xShapes; + pContext = GetImport().GetShapeImport()->CreateFrameChildContext( + GetImport(), Element, xAttrList, xShapes, m_xFastAttrList ); + } + } + else if( XML_TEXT_FRAME_OBJECT == nFrameType || + XML_TEXT_FRAME_OBJECT_OLE == nFrameType ) + { + m_bSupportsReplacement = true; + } + else if( XML_TEXT_FRAME_GRAPHIC == nFrameType ) + { + setSupportsMultipleContents( xAttrList->hasAttribute( + NAMESPACE | XML_NAMESPACE_DRAW | XML_image ) ); + } + + if( !pContext ) + { + pContext = new XMLTextFrameContext_Impl( GetImport(), + Element, xAttrList, m_eDefaultAnchorType, + nFrameType, m_xFastAttrList ); + } + + m_xImplContext = pContext; + + if( getSupportsMultipleContents() + && XML_TEXT_FRAME_GRAPHIC == nFrameType ) + { + addContent(*m_xImplContext); + } + } + } + else if( getSupportsMultipleContents() && + Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_image) ) + { + // read another image + pContext = new XMLTextFrameContext_Impl( + GetImport(), Element, xAttrList, + m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xFastAttrList ); + + m_xImplContext = pContext; + addContent(*m_xImplContext); + } + else if( m_bSupportsReplacement && !m_xReplImplContext && + Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_image) ) + { + // read replacement image + Reference< XPropertySet > xPropSet; + if( CreateIfNotThere( xPropSet ) ) + { + pContext = new XMLReplacementImageContext( GetImport(), + Element, xAttrList, xPropSet ); + m_xReplImplContext = pContext; + } + } + else if( m_xImplContext-ISA( XMLTextFrameContext_Impl ) ) + { + // the child is a writer frame + // Implement Title/Description Elements UI (#i73249#) + const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion(); + if( Element == (NAMESPACE | XML_NAMESPACE_SVG | XML_desc) ) + { + if( bOld ) + { + pContext = new XMLTextFrameTitleOrDescContext_Impl( + GetImport(), Element, m_sTitle ); + } + else + { + pContext = new XMLTextFrameTitleOrDescContext_Impl( + GetImport(), Element, m_sDesc ); + } + } + else if( Element == (NAMESPACE | XML_NAMESPACE_SVG | XML_title) ) + { + pContext= new XMLTextFrameTitleOrDescContext_Impl( + GetImport(), Element, m_sTitle ); + } + else + { + Reference< XPropertySet > xPropSet; + if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_contour_polygon) ) + { + if( CreateIfNotThere( xPropSet ) ) + pContext = new XMLTextFrameContourContext_Impl( + GetImport(), Element, xAttrList, xPropSet, false ); + } + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_contour_path) ) + { + if( CreateIfNotThere( xPropSet ) ) + pContext = new XMLTextFrameContourContext_Impl( + GetImport(), Element, xAttrList, xPropSet, true ); + } + else if( Element == (NAMESPACE | XML_NAMESPACE_DRAW | XML_image_map) ) + { + if( CreateIfNotThere( xPropSet ) ) + pContext = new XMLImageMapContext( + GetImport(), Element, xPropSet ); + } + else if( Element == (NAMESPACE | XML_NAMESPACE_OFFICE | XML_event_listeners) ) + { + // do we still have the frame object? + if( CreateIfNotThere( xPropSet ) ) + { + // is it an event supplier? + Reference< XEventsSupplier > xEventsSupplier(xPropSet, UNO_QUERY); + if( xEventsSupplier.is() ) + { + // OK, we have the events, so create the context + pContext = new XMLEventsImportContext( + GetImport(), Element, xEventsSupplier ); + } + } + } + } + } + else if( Element == (NAMESPACE | XML_NAMESPACE_SVG | XML_title) // #i68101# + || Element == (NAMESPACE | XML_NAMESPACE_SVG | XML_desc) ) + { + pContext = static_cast< SvXMLImportContext* >( + m_xImplContext->createFastChildContext( Element, xAttrList ).get() ); + } + else + { + // the child is a drawing shape + pContext = GetImport().GetShapeImport()->CreateFrameChildContext( + &m_xImplContext, Element, xAttrList ); + } + + if( !pContext ) + pContext = new SvXMLImportContext( GetImport() ); return pContext; } commit a2bca0a87bc97de0aaf5ba9379f44aaee11e6dab Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:38:01 2015 +0100 XMLImageMapContext implements fastparser interface Change-Id: Ic070707a473bbb40f933bef71689ee2c6e30f7db diff --git a/xmloff/inc/XMLImageMapContext.hxx b/xmloff/inc/XMLImageMapContext.hxx index 6110522..2734df38 100644 --- a/xmloff/inc/XMLImageMapContext.hxx +++ b/xmloff/inc/XMLImageMapContext.hxx @@ -53,6 +53,8 @@ public: const OUString& rLocalName, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> & rPropertySet); + XMLImageMapContext( SvXMLImport& rImport, sal_Int32 Element, + css::uno::Reference< css::beans::XPropertySet >& rPropertySet ); virtual ~XMLImageMapContext(); @@ -61,8 +63,14 @@ public: const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; #endif diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index 2e3e06a..5d1497f 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -825,6 +825,27 @@ XMLImageMapContext::XMLImageMapContext( } } +XMLImageMapContext::XMLImageMapContext( + SvXMLImport& rImport, sal_Int32 /*Element*/, + Reference< XPropertySet >& rPropertySet ) +: SvXMLImportContext( rImport ), + sImageMap("ImageMap"), + xPropertySet(rPropertySet) +{ + try + { + Reference< XPropertySetInfo > xInfo = + xPropertySet->getPropertySetInfo(); + if( xInfo.is() && xInfo->hasPropertyByName( sImageMap ) ) + xPropertySet->getPropertyValue(sImageMap) >>= xImageMap; + } + catch(const com::sun::star::uno::Exception& e) + { + uno::Sequence<OUString> aSeq(0); + rImport.SetError( XMLERROR_FLAG_WARNING | XMLERROR_API , aSeq, e.Message, NULL ); + } +} + XMLImageMapContext::~XMLImageMapContext() { } @@ -861,6 +882,35 @@ SvXMLImportContext *XMLImageMapContext::CreateChildContext( return pContext; } +Reference< XFastContextHandler > SAL_CALL + XMLImageMapContext::createFastChildContext( sal_Int32 Element, + const Reference< XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + Reference< XFastContextHandler > pContext = NULL; + + if( Element == (FastToken::NAMESPACE | XML_NAMESPACE_DRAW | XML_area_rectangle) ) + { + pContext = new XMLImageMapRectangleContext( + GetImport(), Element, xImageMap ); + } + else if( Element == (FastToken::NAMESPACE | XML_NAMESPACE_DRAW | XML_area_polygon) ) + { + pContext = new XMLImageMapPolygonContext( + GetImport(), Element, xImageMap ); + } + else if( Element == (FastToken::NAMESPACE | XML_NAMESPACE_DRAW | XML_area_circle) ) + { + pContext = new XMLImageMapCircleContext( + GetImport(), Element, xImageMap ); + } + else + pContext = SvXMLImportContext::createFastChildContext( + Element, xAttrList ); + + return pContext; +} + void XMLImageMapContext::EndElement() { Reference < XPropertySetInfo > xInfo = @@ -869,4 +919,14 @@ void XMLImageMapContext::EndElement() xPropertySet->setPropertyValue(sImageMap, uno::makeAny( xImageMap ) ); } +void SAL_CALL XMLImageMapContext::endFastElement( sal_Int32 /*Element*/ ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + Reference < XPropertySetInfo > xInfo = + xPropertySet->getPropertySetInfo(); + if( xInfo.is() && xInfo->hasPropertyByName( sImageMap ) ) + xPropertySet->setPropertyValue(sImageMap, uno::makeAny( xImageMap ) ); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 37715fcb3e79c22bdb60feb6b53d575d59b2ae68 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:36:25 2015 +0100 XMLImageMapCircleContext implements fastparser ... interface Change-Id: I7922186249d7d7afeab0c3b6033a4a1bf0da0439 diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index 6d016da..2e3e06a 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -689,6 +689,8 @@ public: const OUString& rLocalName, ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer> xMap); + XMLImageMapCircleContext( SvXMLImport& rImport, sal_Int32 Element, + css::uno::Reference< css::container::XIndexContainer > xMap ); virtual ~XMLImageMapCircleContext(); @@ -718,6 +720,18 @@ XMLImageMapCircleContext::XMLImageMapCircleContext( { } +XMLImageMapCircleContext::XMLImageMapCircleContext( + SvXMLImport& rImport, sal_Int32 Element, + Reference< XIndexContainer > xMap ) +: XMLImageMapObjectContext( rImport, Element, xMap, + "com.sun.star.image.ImageMapCircleObject" ), + nRadius(0), + bXOK(false), + bYOK(false), + bRadiusOK(false) +{ +} + XMLImageMapCircleContext::~XMLImageMapCircleContext() { } commit cb79a52e36e85a0a651797c07b2db1dd2681ae5a Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:35:37 2015 +0100 XMLImageMapPolygonContext implements fastparser .. interface Change-Id: I6bc4a707edacc7006d8b2621b4c07ba862110ca4 diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index ccff4c5..6d016da 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -579,6 +579,8 @@ public: const OUString& rLocalName, ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer> xMap); + XMLImageMapPolygonContext( SvXMLImport& rImport, sal_Int32 Element, + css::uno::Reference< css::container::XIndexContainer > xMap ); virtual ~XMLImageMapPolygonContext(); @@ -608,6 +610,16 @@ XMLImageMapPolygonContext::XMLImageMapPolygonContext( { } +XMLImageMapPolygonContext::XMLImageMapPolygonContext( + SvXMLImport& rImport, sal_Int32 Element, + Reference< XIndexContainer > xMap ) +: XMLImageMapObjectContext( rImport, Element, xMap, + "com.sun.star.image.ImageMapPolygonObject" ), + bViewBoxOK(false), + bPointsOK(false) +{ +} + XMLImageMapPolygonContext::~XMLImageMapPolygonContext() { } commit 0be16099497e3fddcb79e584eac7a67b55bfac49 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:34:33 2015 +0100 XMLImageMapRectangleContext implements fastparser interface Change-Id: Idf8dd856ea53c338f48b112c29526d430bc617c2 diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index 279ccfe..ccff4c5 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -455,6 +455,8 @@ public: const OUString& rLocalName, ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer> xMap); + XMLImageMapRectangleContext( SvXMLImport& rImport, sal_Int32 Element, + css::uno::Reference< css::container::XIndexContainer > xMap ); virtual ~XMLImageMapRectangleContext(); @@ -486,6 +488,18 @@ XMLImageMapRectangleContext::XMLImageMapRectangleContext( { } +XMLImageMapRectangleContext::XMLImageMapRectangleContext( + SvXMLImport& rImport, sal_Int32 Element, + Reference< XIndexContainer > xMap ) +: XMLImageMapObjectContext( rImport, Element, xMap, + "com.sun.star.image.ImageMapRectangleObject" ), + bXOK(false), + bYOK(false), + bWidthOK(false), + bHeightOK(false) +{ +} + XMLImageMapRectangleContext::~XMLImageMapRectangleContext() { } commit 6b80061b687f2c7c84cac28b5a0300ccdf8c92f5 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:32:29 2015 +0100 XMLImageMapObjectContext implements fastparser ... interface Change-Id: I5c902b83bb28ccd055c9e5e8d63a7baa78ce57b2 diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index d50ffeb..279ccfe 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -151,18 +151,30 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer> xMap, const sal_Char* pServiceName); + XMLImageMapObjectContext( SvXMLImport& rImport, sal_Int32 Element, + css::uno::Reference< css::container::XIndexContainer > xMap, + const sal_Char* pServiceName ); void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual void SAL_CALL startFastElement( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList> & xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; protected: @@ -220,6 +232,47 @@ XMLImageMapObjectContext::XMLImageMapObjectContext( // else: can't even get factory -> ignore } +XMLImageMapObjectContext::XMLImageMapObjectContext( + SvXMLImport& rImport, sal_Int32 /*Element*/, + Reference<XIndexContainer> xMap, + const sal_Char* pServiceName) +: SvXMLImportContext(rImport), + sBoundary("Boundary"), + sCenter("Center"), + sTitle("Title"), + sDescription("Description"), + sImageMap("ImageMap"), + sIsActive("IsActive"), + sName("Name"), + sPolygon("Polygon"), + sRadius("Radius"), + sTarget("Target"), + sURL("URL"), + xImageMap(xMap), + bIsActive(true), + bValid(false) +{ + DBG_ASSERT(NULL != pServiceName, + "Please supply the image map object service name"); + + Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY); + if( xFactory.is() ) + { + Reference<XInterface> xIfc = xFactory->createInstance( + OUString::createFromAscii(pServiceName)); + DBG_ASSERT(xIfc.is(), "can't create image map object!"); + if( xIfc.is() ) + { + Reference<XPropertySet> xPropertySet( xIfc, UNO_QUERY ); + + xMapEntry = xPropertySet; + } + // else: can't create service -> ignore + } + // else: can't even get factory -> ignore +} + + void XMLImageMapObjectContext::StartElement( const Reference<XAttributeList >& xAttrList ) { @@ -239,6 +292,20 @@ void XMLImageMapObjectContext::StartElement( } } +void SAL_CALL XMLImageMapObjectContext::startFastElement( sal_Int32 /*Element*/, + const Reference< XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + SvXMLTokenMap aMap(aImageMapObjectTokenMap); + + css::uno::Sequence< css::xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( css::xml::FastAttribute attribute : attributes ) + { + ProcessAttribute((enum XMLImageMapToken)aMap.Get( attribute.Token ), + attribute.Value ); + } +} + void XMLImageMapObjectContext::EndElement() { // only create and insert image map object if validity flag is set @@ -256,6 +323,24 @@ void XMLImageMapObjectContext::EndElement() // else: not valid -> don't create and insert } +void SAL_CALL XMLImageMapObjectContext::endFastElement( sal_Int32 /*Element*/ ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + // only create and insert image map object if validity flag is set + // (and we actually have an image map) + if ( bValid && xImageMap.is() && xMapEntry.is() ) + { + // set values + Prepare( xMapEntry ); + + // insert into image map + Any aAny; + aAny <<= xMapEntry; + xImageMap->insertByIndex( xImageMap->getCount(), aAny ); + } + // else: not valid -> don't create and insert +} + SvXMLImportContext* XMLImageMapObjectContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, @@ -286,6 +371,32 @@ SvXMLImportContext* XMLImageMapObjectContext::CreateChildContext( } +Reference< XFastContextHandler > SAL_CALL + XMLImageMapObjectContext::createFastChildContext( sal_Int32 Element, + const Reference< XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + if( Element == (FastToken::NAMESPACE | XML_NAMESPACE_OFFICE | XML_event_listeners) ) + { + Reference< XEventsSupplier > xEvents( xMapEntry, UNO_QUERY ); + return new XMLEventsImportContext( + GetImport(), Element, xEvents ); + } + else if( Element == (FastToken::NAMESPACE | XML_NAMESPACE_SVG | XML_title) ) + { + return new XMLStringBufferImportContext( + GetImport(), Element, sTitleBuffer ); + } + else if( Element == (FastToken::NAMESPACE | XML_NAMESPACE_SVG | XML_desc) ) + { + return new XMLStringBufferImportContext( + GetImport(), Element, sDescriptionBuffer ); + } + else + return SvXMLImportContext::createFastChildContext( + Element, xAttrList ); +} + void XMLImageMapObjectContext::ProcessAttribute( enum XMLImageMapToken eToken, const OUString& rValue) commit de228da0af827dfee5fcc8684f492cc8ee25b7e3 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:30:24 2015 +0100 XMLStringBufferImportContext implements fastparser interface Change-Id: I4cb0a48035b10fefbbf3bc15bbaeef66a8ae55bb diff --git a/xmloff/inc/XMLStringBufferImportContext.hxx b/xmloff/inc/XMLStringBufferImportContext.hxx index 332dc2d..d71cf17 100644 --- a/xmloff/inc/XMLStringBufferImportContext.hxx +++ b/xmloff/inc/XMLStringBufferImportContext.hxx @@ -43,6 +43,8 @@ public: sal_uInt16 nPrefix, const OUString& sLocalName, OUStringBuffer& rBuffer); + XMLStringBufferImportContext( SvXMLImport& rImport, sal_Int32 Element, + OUStringBuffer& rBuffer ); virtual ~XMLStringBufferImportContext(); @@ -51,11 +53,19 @@ public: const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; virtual void Characters( const OUString& rChars ) SAL_OVERRIDE; + virtual void SAL_CALL characters( const OUString& rChars ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; #endif diff --git a/xmloff/source/text/XMLStringBufferImportContext.cxx b/xmloff/source/text/XMLStringBufferImportContext.cxx index dbbfc41..51596ed 100644 --- a/xmloff/source/text/XMLStringBufferImportContext.cxx +++ b/xmloff/source/text/XMLStringBufferImportContext.cxx @@ -20,12 +20,17 @@ #include "XMLStringBufferImportContext.hxx" #include <xmloff/xmltoken.hxx> #include <xmloff/xmlnmspe.hxx> +#include <xmloff/token/tokens.hxx> +#include <com/sun/star/xml/sax/FastToken.hpp> using ::com::sun::star::uno::Reference; using ::com::sun::star::xml::sax::XAttributeList; using ::xmloff::token::IsXMLToken; using ::xmloff::token::XML_P; +using xmloff::XML_p; +using css::xml::sax::FastToken::NAMESPACE; +using namespace css::xml::sax; TYPEINIT1(XMLStringBufferImportContext, SvXMLImportContext); @@ -40,6 +45,14 @@ XMLStringBufferImportContext::XMLStringBufferImportContext( { } +XMLStringBufferImportContext::XMLStringBufferImportContext( + SvXMLImport& rImport, sal_Int32 /*Element*/, + OUStringBuffer& rBuffer ) +: SvXMLImportContext( rImport ), + rTextBuffer(rBuffer) +{ +} + XMLStringBufferImportContext::~XMLStringBufferImportContext() { } @@ -53,12 +66,27 @@ SvXMLImportContext *XMLStringBufferImportContext::CreateChildContext( rLocalName, rTextBuffer); } +Reference< XFastContextHandler > SAL_CALL + XMLStringBufferImportContext::createFastChildContext( sal_Int32 Element, + const Reference< XFastAttributeList >& /*xAttrList*/ ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + return new XMLStringBufferImportContext( GetImport(), + Element, rTextBuffer ); +} + void XMLStringBufferImportContext::Characters( const OUString& rChars ) { rTextBuffer.append(rChars); } +void SAL_CALL XMLStringBufferImportContext::characters( const OUString& rChars ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + rTextBuffer.append(rChars); +} + void XMLStringBufferImportContext::EndElement() { // add return for paragraph elements @@ -69,4 +97,14 @@ void XMLStringBufferImportContext::EndElement() } } +void SAL_CALL XMLStringBufferImportContext::endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, SAXException, std::exception) +{ + // add return for paragraph elements + if( Element == (NAMESPACE | XML_NAMESPACE_TEXT | XML_p) ) + { + rTextBuffer.append(sal_Unicode(0x0a)); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 0e2b8e1a92d21e262cc41df37488f316fa6de011 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Fri Feb 27 08:19:25 2015 +0100 changed ctor XMLEventsImportContext Change-Id: Id6912a1edbf96d2287fad7d67a69b29980e55179 diff --git a/include/xmloff/XMLEventsImportContext.hxx b/include/xmloff/XMLEventsImportContext.hxx index e3b0c30..128f57d 100644 --- a/include/xmloff/XMLEventsImportContext.hxx +++ b/include/xmloff/XMLEventsImportContext.hxx @@ -70,7 +70,7 @@ public: SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName); - XMLEventsImportContext( SvXMLImport& rImport ); + XMLEventsImportContext( SvXMLImport& rImport, sal_Int32 Element ); XMLEventsImportContext( SvXMLImport& rImport, @@ -78,7 +78,7 @@ public: const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier> & xEventsSupplier); - XMLEventsImportContext( SvXMLImport& rImport, + XMLEventsImportContext( SvXMLImport& rImport, sal_Int32 Element, const css::uno::Reference< css::document::XEventsSupplier >& xEventsSupplier ); XMLEventsImportContext( @@ -87,7 +87,7 @@ public: const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace> & xNameRepl); - XMLEventsImportContext( SvXMLImport& rImport, + XMLEventsImportContext( SvXMLImport& rImport, sal_Int32 Element, const css::uno::Reference< css::container::XNameReplace >& xNameRepl); virtual ~XMLEventsImportContext(); diff --git a/xmloff/source/script/XMLEventsImportContext.cxx b/xmloff/source/script/XMLEventsImportContext.cxx index c8e1b24..abc993b 100644 --- a/xmloff/source/script/XMLEventsImportContext.cxx +++ b/xmloff/source/script/XMLEventsImportContext.cxx @@ -52,7 +52,8 @@ XMLEventsImportContext::XMLEventsImportContext( { } -XMLEventsImportContext::XMLEventsImportContext( SvXMLImport& rImport ) +XMLEventsImportContext::XMLEventsImportContext( + SvXMLImport& rImport, sal_Int32 /*Element*/ ) : SvXMLImportContext( rImport ) { } @@ -67,7 +68,8 @@ XMLEventsImportContext::XMLEventsImportContext( { } -XMLEventsImportContext::XMLEventsImportContext( SvXMLImport& rImport, +XMLEventsImportContext::XMLEventsImportContext( + SvXMLImport& rImport, sal_Int32 /*Element*/, const Reference< XEventsSupplier >& xEventsSupplier ) : SvXMLImportContext( rImport ), xEvents( xEventsSupplier->getEvents() ) @@ -84,7 +86,8 @@ XMLEventsImportContext::XMLEventsImportContext( { } -XMLEventsImportContext::XMLEventsImportContext( SvXMLImport& rImport, +XMLEventsImportContext::XMLEventsImportContext( + SvXMLImport& rImport, sal_Int32 /*Element*/, const Reference< XNameReplace >& xNameReplace ) : SvXMLImportContext( rImport ), xEvents( xNameReplace ) diff --git a/xmloff/source/text/XMLTextShapeStyleContext.cxx b/xmloff/source/text/XMLTextShapeStyleContext.cxx index 2f81b3c..05f14ce 100644 --- a/xmloff/source/text/XMLTextShapeStyleContext.cxx +++ b/xmloff/source/text/XMLTextShapeStyleContext.cxx @@ -279,7 +279,7 @@ Reference< XFastContextHandler > SAL_CALL { // create and remember events import context // (for delayed processing of events) - pContext = new XMLEventsImportContext( GetImport() ); + pContext = new XMLEventsImportContext( GetImport(), Element ); xEventContext = pContext; } else diff --git a/xmloff/source/text/txtstyli.cxx b/xmloff/source/text/txtstyli.cxx index ff19227..119858b 100644 --- a/xmloff/source/text/txtstyli.cxx +++ b/xmloff/source/text/txtstyli.cxx @@ -238,7 +238,7 @@ Reference< XFastContextHandler > SAL_CALL { //create and remember events import context //(for delayed processing of events) - pEventContext = new XMLEventsImportContext( GetImport() ); + pEventContext = new XMLEventsImportContext( GetImport(), Element ); pEventContext->AddFirstRef(); pContext = pEventContext; } commit 64f0fe4098058ae076682d6b28cdd4eb735ac810 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Thu Feb 26 10:47:35 2015 +0100 XMLTextFrameContourContext_Impl implements ... fastparser interface Change-Id: I394ad0fba88c7ecfcc84d8c6a964862e87d01fa3 diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 381f84f..64e5b2f 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -240,6 +240,9 @@ public: ::com::sun::star::xml::sax::XAttributeList > & xAttrList, const Reference < XPropertySet >& rPropSet, bool bPath ); + XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + const Reference< XPropertySet >& rPropSet, bool bPath ); virtual ~XMLTextFrameContourContext_Impl(); }; @@ -370,6 +373,123 @@ XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( } } +XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl( + SvXMLImport& rImport, sal_Int32 Element, + const Reference< XFastAttributeList >& xAttrList, + const Reference< XPropertySet >& rPropSet, + bool bPath ) +: SvXMLImportContext( rImport ), + xPropSet( rPropSet ) +{ + OUString sD, sPoints, sViewBox; + bool bPixelWidth = false, bPixelHeight = false; + sal_Bool bAuto = sal_False; + sal_Int32 nWidth = 0; + sal_Int32 nHeight = 0; + + const SvXMLTokenMap& rTokenMap = + GetImport().GetTextImport()->GetTextContourAttrTokenMap(); + + Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( xml::FastAttribute attribute : attributes ) + { + switch( rTokenMap.Get( attribute.Token ) ) + { + case XML_TOK_TEXT_CONTOUR_VIEWBOX: + sViewBox = attribute.Value; + break; + case XML_TOK_TEXT_CONTOUR_D: + if( bPath ) + sD = attribute.Value; + break; + case XML_TOK_TEXT_CONTOUR_POINTS: + if( !bPath ) + sPoints = attribute.Value; + break; + case XML_TOK_TEXT_CONTOUR_WIDTH: + if( ::sax::Converter::convertMeasurePx( nWidth, attribute.Value ) ) + bPixelWidth = true; + else + GetImport().GetMM100UnitConverter().convertMeasureToCore( + nWidth, attribute.Value ); + break; + case XML_TOK_TEXT_CONTOUR_HEIGHT: + if( ::sax::Converter::convertMeasurePx( nHeight, attribute.Value ) ) + bPixelHeight = true; + else + GetImport().GetMM100UnitConverter().convertMeasureToCore( + nHeight, attribute.Value ); + break; + case XML_TOK_TEXT_CONTOUR_AUTO: + bAuto = attribute.Value.equals( "true" ); + break; + } + } + + OUString sContourPolyPolygon("ContourPolyPolygon"); + Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo(); + + if(xPropSetInfo->hasPropertyByName(sContourPolyPolygon) && nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && (bPath ? sD : sPoints).getLength()) + { + const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter()); + basegfx::B2DPolyPolygon aPolyPolygon; + Any aAny; + + if( bPath ) + { + basegfx::tools::importFromSvgD(aPolyPolygon, sD, GetImport().needFixPositionAfterZ(), 0); + } + else + { + basegfx::B2DPolygon aPolygon; + + if(basegfx::tools::importFromSvgPoints(aPolygon, sPoints)) + { + aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon); + } + } + + if(aPolyPolygon.count()) + { + const basegfx::B2DRange aSourceRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); + const basegfx::B2DRange aTargetRange( + 0.0, 0.0, + nWidth, nHeight); + + if(!aSourceRange.equal(aTargetRange)) + { + aPolyPolygon.transform( + basegfx::tools::createSourceRangeTargetRangeTransform( + aSourceRange, + aTargetRange)); + } + + com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence; + basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence); + aAny <<= aPointSequenceSequence; + xPropSet->setPropertyValue( sContourPolyPolygon, aAny ); + } + + const OUString sIsPixelContour("IsPixelContour"); + + if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) ) + { + aAny.setValue( &bPixelWidth, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsPixelContour, aAny ); + } + + const OUString sIsAutomaticContour("IsAutomaticContour"); + + if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) ) + { + aAny.setValue( &bAuto, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsAutomaticContour, aAny ); + } + } +} + XMLTextFrameContourContext_Impl::~XMLTextFrameContourContext_Impl() { } commit 8002fb41c75a4634e2949cf8082053133343b7c5 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Thu Feb 26 10:46:00 2015 +0100 XMLTextFrameTitleOrDescContext_Impl implements ... fastparser interface Change-Id: I799279c0a0e58a612070c25d0b37d6c8e49ccc25 diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 70b8a94..381f84f 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -126,9 +126,13 @@ public: sal_uInt16 nPrfx, const OUString& rLName, OUString& rTitleOrDesc ); + XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport, + sal_Int32 Element, OUString& rTitleOrDesc ); virtual ~XMLTextFrameTitleOrDescContext_Impl(); virtual void Characters( const OUString& rText ) SAL_OVERRIDE; + virtual void SAL_CALL characters( const OUString& rChars ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext ); @@ -143,6 +147,14 @@ XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl( { } +XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl( + SvXMLImport& rImport, sal_Int32 /*Element*/, + OUString& rTitleOrDesc ) +: SvXMLImportContext( rImport ), + mrTitleOrDesc( rTitleOrDesc ) +{ +} + XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl() { } @@ -152,6 +164,12 @@ void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText ) mrTitleOrDesc += rText; } +void SAL_CALL XMLTextFrameTitleOrDescContext_Impl::characters( const OUString& rChars ) + throw(RuntimeException, SAXException, std::exception) +{ + mrTitleOrDesc += rChars; +} + class XMLTextFrameParam_Impl : public SvXMLImportContext { public: commit 474b0c7a6e720cc11a824323b39e94a38586c873 Author: Daniel Sikeler <d.sikele...@gmail.com> Date: Thu Feb 26 10:08:09 2015 +0100 XMLReplacementImageContext implements fastparser interface Change-Id: I7283d1e2acf4b28dd778bd9f7f6cb63a0b1e13fa diff --git a/xmloff/inc/XMLReplacementImageContext.hxx b/xmloff/inc/XMLReplacementImageContext.hxx index 0560f1d..abb421c 100644 --- a/xmloff/inc/XMLReplacementImageContext.hxx +++ b/xmloff/inc/XMLReplacementImageContext.hxx @@ -49,14 +49,23 @@ public: ::com::sun::star::xml::sax::XAttributeList > & rAttrList, const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& rPropSet ); + XMLReplacementImageContext( SvXMLImport& rImport, sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + const css::uno::Reference< css::beans::XPropertySet >& rPropSet ); virtual ~XMLReplacementImageContext(); virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; diff --git a/xmloff/source/draw/XMLReplacementImageContext.cxx b/xmloff/source/draw/XMLReplacementImageContext.cxx index 80e075b..a540842 100644 --- a/xmloff/source/draw/XMLReplacementImageContext.cxx +++ b/xmloff/source/draw/XMLReplacementImageContext.cxx @@ -19,9 +19,11 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/xml/sax/FastToken.hpp> #include <osl/diagnose.h> #include <xmloff/xmlimp.hxx> #include <xmloff/xmltoken.hxx> +#include <xmloff/token/tokens.hxx> #include <xmloff/xmlnmspe.hxx> #include <xmloff/nmspmap.hxx> #include <xmloff/XMLBase64ImportContext.hxx> @@ -29,8 +31,10 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::makeAny; +using css::xml::sax::FastToken::NAMESPACE; using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::beans; +using namespace css::uno; TYPEINIT1( XMLReplacementImageContext, SvXMLImportContext ); @@ -67,6 +71,29 @@ XMLReplacementImageContext::XMLReplacementImageContext( } } +XMLReplacementImageContext::XMLReplacementImageContext( + SvXMLImport& rImport, sal_Int32 Element, + const Reference< XFastAttributeList >& xAttrList, + const Reference< XPropertySet >& rPropSet ) +: SvXMLImportContext( rImport ), + m_xPropSet( rPropSet ), + m_sGraphicURL("GraphicURL") +{ + const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()-> + GetTextFrameAttrTokenMap(); + + Sequence< css::xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( css::xml::FastAttribute attribute : attributes ) + { + switch( rTokenMap.Get( attribute.Token ) ) + { + case XML_TOK_TEXT_FRAME_HREF: + m_sHRef = attribute.Value; + break; + } + } +} + XMLReplacementImageContext::~XMLReplacementImageContext() { } @@ -98,6 +125,34 @@ void XMLReplacementImageContext::EndElement() m_xPropSet->setPropertyValue( m_sGraphicURL, makeAny( sHRef ) ); } +void SAL_CALL XMLReplacementImageContext::endFastElement( sal_Int32 Element ) + throw(RuntimeException, SAXException, std::exception) +{ + OSL_ENSURE( !m_sHRef.isEmpty() || m_xBase64Stream.is(), + "neither URL nor base64 image data given" ); + rtl::Reference < XMLTextImportHelper > xTxtImport = + GetImport().GetTextImport(); + OUString sHRef; + if( !m_sHRef.isEmpty() ) + { + bool bForceLoad = xTxtImport->IsInsertMode() || + xTxtImport->IsBlockMode() || + xTxtImport->IsStylesOnlyMode() || + xTxtImport->IsOrganizerMode(); + sHRef = GetImport().ResolveGraphicObjectURL( m_sHRef, !bForceLoad ); + } + else if( m_xBase64Stream.is() ) + { + sHRef = GetImport().ResolveGraphicObjectURLFromBase64( m_xBase64Stream ); + m_xBase64Stream = 0; + } + + Reference < XPropertySetInfo > xPropSetInfo = + m_xPropSet->getPropertySetInfo(); + if( xPropSetInfo->hasPropertyByName( m_sGraphicURL ) ) + m_xPropSet->setPropertyValue( m_sGraphicURL, makeAny( sHRef ) ); +} + ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits