diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-01 09:48:03 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-12-01 10:06:55 +0100 |
commit | 3eb6f422e079c6e64b6585a5624fc741eb3c7e98 (patch) | |
tree | d17a703b28cfaf9c57b8d777e800880f43817333 | |
parent | 5507e539db2cec477787e75993ae2be07d03ae9a (diff) |
DOCX import: tokenize <w:smartTag>
Change-Id: I2c408a25880ad0e87f0b5a246a350e45c8378ce5
-rw-r--r-- | writerfilter/Library_writerfilter.mk | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SmartTagHandler.cxx | 70 | ||||
-rw-r--r-- | writerfilter/source/dmapper/SmartTagHandler.hxx | 42 | ||||
-rw-r--r-- | writerfilter/source/ooxml/model.xml | 3 |
6 files changed, 129 insertions, 1 deletions
diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk index 6149401d284c..fb5eecb7f35a 100644 --- a/writerfilter/Library_writerfilter.mk +++ b/writerfilter/Library_writerfilter.mk @@ -101,6 +101,7 @@ $(eval $(call gb_Library_add_exception_objects,writerfilter,\ writerfilter/source/dmapper/SdtHelper \ writerfilter/source/dmapper/SectionColumnHandler \ writerfilter/source/dmapper/SettingsTable \ + writerfilter/source/dmapper/SmartTagHandler \ writerfilter/source/dmapper/StyleSheetTable \ writerfilter/source/dmapper/TDefTableHandler \ writerfilter/source/dmapper/TableManager \ diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 07350c9aa018..86fcb86c21fb 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -626,8 +626,10 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) } break; case NS_ooxml::LN_CT_SmartTagRun_uri: + m_pImpl->getSmartTagHandler().setURI(val.getString()); + break; case NS_ooxml::LN_CT_SmartTagRun_element: - //TODO: add handling of SmartTags + m_pImpl->getSmartTagHandler().setElement(val.getString()); break; case NS_ooxml::LN_CT_Br_type : //TODO: attributes for break (0x12) are not supported @@ -2639,6 +2641,13 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) m_pImpl->SetRubyInfo(aInfo); } break; + case NS_ooxml::LN_CT_SmartTagRun_smartTagPr: + { + writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); + if (pProperties.get()) + pProperties->resolve(m_pImpl->getSmartTagHandler()); + } + break; default: { #ifdef DEBUG_WRITERFILTER diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index be6bb2625ac0..14199bb4a78d 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -48,6 +48,7 @@ #include "GraphicImport.hxx" #include "OLEHandler.hxx" #include "FFDataHandler.hxx" +#include "SmartTagHandler.hxx" #include "FormControlHelper.hxx" #include <map> @@ -460,6 +461,7 @@ private: css::uno::Reference<css::beans::XPropertySet> GetDocumentSettings(); std::map<sal_Int32, css::uno::Any> deferredCharacterProperties; + SmartTagHandler m_aSmartTagHandler; public: css::uno::Reference<css::text::XTextRange> m_xInsertTextRange; @@ -849,6 +851,7 @@ public: std::queue<OUString> m_aPositivePercentages; bool isInIndexContext() { return m_bStartIndex;} bool isInBibliographyContext() { return m_bStartBibliography;} + SmartTagHandler& getSmartTagHandler() { return m_aSmartTagHandler; } void substream(Id rName, ::writerfilter::Reference<Stream>::Pointer_t const& ref); diff --git a/writerfilter/source/dmapper/SmartTagHandler.cxx b/writerfilter/source/dmapper/SmartTagHandler.cxx new file mode 100644 index 000000000000..7c44cde2d544 --- /dev/null +++ b/writerfilter/source/dmapper/SmartTagHandler.cxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <SmartTagHandler.hxx> +#include <ooxml/resourceids.hxx> + +namespace writerfilter +{ +namespace dmapper +{ + +using namespace ::com::sun::star; + +SmartTagHandler::SmartTagHandler() + : LoggedProperties("SmartTagHandler") +{ +} + +SmartTagHandler::~SmartTagHandler() +{ +} + +void SmartTagHandler::lcl_attribute(Id nName, Value& rValue) +{ + switch (nName) + { + case NS_ooxml::LN_CT_Attr_name: + break; + case NS_ooxml::LN_CT_Attr_val: + break; + default: + SAL_WARN("writerfilter", "SmartTagHandler::lcl_attribute: unhandled attribute " << nName << " (string value: '"<<rValue.getString()<<"')"); + break; + } +} + +void SmartTagHandler::lcl_sprm(Sprm& rSprm) +{ + switch (rSprm.getId()) + { + case NS_ooxml::LN_CT_SmartTagPr_attr: + { + writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); + if (pProperties.get()) + pProperties->resolve(*this); + break; + } + } +} + +void SmartTagHandler::setURI(const OUString& rURI) +{ + m_aURI = rURI; +} + +void SmartTagHandler::setElement(const OUString& rElement) +{ + m_aElement = rElement; +} + +} // namespace dmapper +} // namespace writerfilter + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/SmartTagHandler.hxx b/writerfilter/source/dmapper/SmartTagHandler.hxx new file mode 100644 index 000000000000..ae5996b2d73c --- /dev/null +++ b/writerfilter/source/dmapper/SmartTagHandler.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_SMARTTAGHANDLER_HXX +#define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_SMARTTAGHANDLER_HXX + +#include "LoggedResources.hxx" + +namespace writerfilter +{ +namespace dmapper +{ + +/// Handler for smart tags, i.e. <w:smartTag> and below. +class SmartTagHandler + : public LoggedProperties +{ + OUString m_aURI; + OUString m_aElement; + +public: + SmartTagHandler(); + virtual ~SmartTagHandler(); + + virtual void lcl_attribute(Id Name, Value& val) override; + virtual void lcl_sprm(Sprm& sprm) override; + + void setURI(const OUString& rURI); + void setElement(const OUString& rElement); +}; + +} // namespace dmapper +} // namespace writerfilter + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 260aa3dfac2c..e3b462262f01 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -18166,6 +18166,9 @@ <attribute name="uri" tokenid="ooxml:CT_SmartTagRun_uri"/> <attribute name="element" tokenid="ooxml:CT_SmartTagRun_element"/> </resource> + <resource name="CT_SmartTagPr" resource="Properties"> + <element name="attr" tokenid="ooxml:CT_SmartTagPr_attr"/> + </resource> <resource name="EG_PContent" resource="Properties"> <element name="fldSimple" tokenid="ooxml:EG_PContent_fldSimple"/> <element name="hyperlink" tokenid="ooxml:EG_PContent_hyperlink"/> |