summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-10-08 10:52:33 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-10-08 12:55:21 +0200
commitf484f9b482dd74616ab542d74f9ec547aab71285 (patch)
tree0d03983d8095ec2d1e06e9c5706ab8e91a5198c3 /writerfilter
parentf448d677bcaa9ad68876ea292d93978f729335a0 (diff)
writerfilter: handle CT_LatentStyles and CT_LsdException in dmapper
Just store them in the document InteropGrabBag for now. Change-Id: Ia413930746ed087bcb0f6e338198c7baa5bcbdf0
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/Library_writerfilter.mk1
-rw-r--r--writerfilter/source/dmapper/LatentStyleHandler.cxx82
-rw-r--r--writerfilter/source/dmapper/LatentStyleHandler.hxx42
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx81
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.hxx2
5 files changed, 208 insertions, 0 deletions
diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk
index 24b92a842ac2..ff23bad533e6 100644
--- a/writerfilter/Library_writerfilter.mk
+++ b/writerfilter/Library_writerfilter.mk
@@ -102,6 +102,7 @@ $(eval $(call gb_Library_add_exception_objects,writerfilter,\
writerfilter/source/dmapper/FormControlHelper \
writerfilter/source/dmapper/GraphicHelpers \
writerfilter/source/dmapper/GraphicImport \
+ writerfilter/source/dmapper/LatentStyleHandler \
writerfilter/source/dmapper/MeasureHandler \
writerfilter/source/dmapper/ModelEventListener \
writerfilter/source/dmapper/NumberingManager \
diff --git a/writerfilter/source/dmapper/LatentStyleHandler.cxx b/writerfilter/source/dmapper/LatentStyleHandler.cxx
new file mode 100644
index 000000000000..013e3c05794f
--- /dev/null
+++ b/writerfilter/source/dmapper/LatentStyleHandler.cxx
@@ -0,0 +1,82 @@
+/* -*- 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 <LatentStyleHandler.hxx>
+#include <ooxml/resourceids.hxx>
+#include "dmapperLoggers.hxx"
+
+namespace writerfilter {
+namespace dmapper {
+
+using namespace ::com::sun::star;
+
+LatentStyleHandler::LatentStyleHandler() :
+ LoggedProperties(dmapper_logger, "LatentStyleHandler")
+{
+}
+
+LatentStyleHandler::~LatentStyleHandler()
+{
+}
+
+void LatentStyleHandler::lcl_attribute(Id rName, Value& rVal)
+{
+ beans::PropertyValue aValue;
+ bool bFound = true;
+ switch (rName)
+ {
+ case NS_ooxml::LN_CT_LsdException_name:
+ aValue.Name = "name";
+ break;
+ case NS_ooxml::LN_CT_LsdException_locked:
+ aValue.Name = "locked";
+ break;
+ case NS_ooxml::LN_CT_LsdException_uiPriority:
+ aValue.Name = "uiPriority";
+ break;
+ case NS_ooxml::LN_CT_LsdException_semiHidden:
+ aValue.Name = "semiHidden";
+ break;
+ case NS_ooxml::LN_CT_LsdException_unhideWhenUsed:
+ aValue.Name = "unhideWhenUsed";
+ break;
+ case NS_ooxml::LN_CT_LsdException_qFormat:
+ aValue.Name = "qFormat";
+ break;
+ default:
+ bFound = false;
+#ifdef DEBUG_DOMAINMAPPER
+ dmapper_logger->element("unhandled");
+#endif
+ break;
+ }
+ if (bFound)
+ {
+ aValue.Value = uno::makeAny(rVal.getString());
+ m_aAttributes.push_back(aValue);
+ }
+}
+
+
+void LatentStyleHandler::lcl_sprm(Sprm& /*rSprm*/)
+{
+}
+
+uno::Sequence<beans::PropertyValue> LatentStyleHandler::getAttributes() const
+{
+ uno::Sequence<beans::PropertyValue> aAttributes(m_aAttributes.size());
+ beans::PropertyValue* pAttributes = aAttributes.getArray();
+ for (std::vector<beans::PropertyValue>::const_iterator i = m_aAttributes.begin(); i != m_aAttributes.end(); ++i)
+ *pAttributes++ = *i;
+ return aAttributes;
+}
+
+} // namespace dmapper
+} // namespace writerfilter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/LatentStyleHandler.hxx b/writerfilter/source/dmapper/LatentStyleHandler.hxx
new file mode 100644
index 000000000000..081ddc25f313
--- /dev/null
+++ b/writerfilter/source/dmapper/LatentStyleHandler.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_LATENTSTYLEHANDLER_HXX
+#define INCLUDED_LATENTSTYLEHANDLER_HXX
+
+#include <resourcemodel/LoggedResources.hxx>
+#include <boost/shared_ptr.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+namespace writerfilter {
+ namespace dmapper {
+
+ /// Handler for a latent style (w:lsdException element)
+ class LatentStyleHandler
+ : public LoggedProperties
+ {
+ std::vector<beans::PropertyValue> m_aAttributes;
+
+ // Properties
+ virtual void lcl_attribute(Id Name, Value & val);
+ virtual void lcl_sprm(Sprm & sprm);
+
+ public:
+ LatentStyleHandler();
+ virtual ~LatentStyleHandler();
+
+ com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getAttributes() const;
+ };
+
+ typedef boost::shared_ptr<LatentStyleHandler> LatentStyleHandlerPtr;
+ } // namespace dmapper
+} // namespace writerfilter
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 0a232f0e3ddd..acb45f66a992 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -23,6 +23,7 @@
#include <ConversionHelper.hxx>
#include <TblStylePrHandler.hxx>
#include <BorderHandler.hxx>
+#include <LatentStyleHandler.hxx>
#include <doctok/resourceids.hxx>
#include <ooxml/resourceids.hxx>
#include <vector>
@@ -280,6 +281,9 @@ struct StyleSheetTable_Impl
StyleSheetTable_Impl(DomainMapper& rDMapper, uno::Reference< text::XTextDocument> xTextDocument, bool bIsNewDoc);
OUString HasListCharStyle( const PropertyValueVector_t& rCharProperties );
+
+ /// Appends the given key-value pair to the list of latent style properties of the current entry.
+ void AppendLatentStyleProperty(OUString aName, Value& rValue);
};
@@ -343,6 +347,14 @@ OUString StyleSheetTable_Impl::HasListCharStyle( const PropertyValueVector_t& rP
return sRet;
}
+void StyleSheetTable_Impl::AppendLatentStyleProperty(OUString aName, Value& rValue)
+{
+ beans::PropertyValue aValue;
+ aValue.Name = aName;
+ aValue.Value <<= rValue.getString();
+ m_pCurrentEntry->aLatentStyles.push_back(aValue);
+}
+
StyleSheetTable::StyleSheetTable(DomainMapper& rDMapper, uno::Reference< text::XTextDocument> xTextDocument, bool bIsNewDoc)
: LoggedProperties(dmapper_logger, "StyleSheetTable")
@@ -460,6 +472,24 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val)
case NS_ooxml::LN_CT_TblWidth_type:
dynamic_cast< StyleSheetPropertyMap* >( m_pImpl->m_pCurrentEntry->pProperties.get() )->SetCT_TblWidth_type( nIntValue );
break;
+ case NS_ooxml::LN_CT_LatentStyles_defQFormat:
+ m_pImpl->AppendLatentStyleProperty("defQFormat", val);
+ break;
+ case NS_ooxml::LN_CT_LatentStyles_defUnhideWhenUsed:
+ m_pImpl->AppendLatentStyleProperty("defUnhideWhenUsed", val);
+ break;
+ case NS_ooxml::LN_CT_LatentStyles_defSemiHidden:
+ m_pImpl->AppendLatentStyleProperty("defSemiHidden", val);
+ break;
+ case NS_ooxml::LN_CT_LatentStyles_count:
+ m_pImpl->AppendLatentStyleProperty("count", val);
+ break;
+ case NS_ooxml::LN_CT_LatentStyles_defUIPriority:
+ m_pImpl->AppendLatentStyleProperty("defUIPriority", val);
+ break;
+ case NS_ooxml::LN_CT_LatentStyles_defLockedState:
+ m_pImpl->AppendLatentStyleProperty("defLockedState", val);
+ break;
default:
{
#ifdef DEBUG_DOMAINMAPPER
@@ -587,6 +617,20 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
case NS_ooxml::LN_CT_TblPrBase_tblCellMar:
//no cell margins in styles
break;
+ case NS_ooxml::LN_CT_LatentStyles_lsdException:
+ {
+ writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
+ if (pProperties.get())
+ {
+ LatentStyleHandlerPtr pLatentStyleHandler(new LatentStyleHandler());
+ pProperties->resolve(*pLatentStyleHandler);
+ beans::PropertyValue aValue;
+ aValue.Name = "lsdException";
+ aValue.Value = uno::makeAny(pLatentStyleHandler->getAttributes());
+ m_pImpl->m_pCurrentEntry->aLsdExceptions.push_back(aValue);
+ }
+ }
+ break;
case NS_ooxml::LN_CT_Style_pPr:
// no break
case NS_ooxml::LN_CT_Style_rPr:
@@ -640,6 +684,43 @@ void StyleSheetTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>
//TODO: this entry contains the default settings - they have to be added to the settings
}
+ if (!m_pImpl->m_pCurrentEntry->aLatentStyles.empty())
+ {
+ // We have latent styles for this entry, then process them.
+ std::vector<beans::PropertyValue>& rLatentStyles = m_pImpl->m_pCurrentEntry->aLatentStyles;
+
+ if (!m_pImpl->m_pCurrentEntry->aLsdExceptions.empty())
+ {
+ std::vector<beans::PropertyValue>& rLsdExceptions = m_pImpl->m_pCurrentEntry->aLsdExceptions;
+ uno::Sequence<beans::PropertyValue> aLsdExceptions(rLsdExceptions.size());
+ beans::PropertyValue* pLsdExceptions = aLsdExceptions.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = rLsdExceptions.begin(); i != rLsdExceptions.end(); ++i)
+ *pLsdExceptions++ = *i;
+
+ beans::PropertyValue aValue;
+ aValue.Name = "lsdExceptions";
+ aValue.Value = uno::makeAny(aLsdExceptions);
+ rLatentStyles.push_back(aValue);
+ }
+
+ uno::Sequence<beans::PropertyValue> aLatentStyles(rLatentStyles.size());
+ beans::PropertyValue* pLatentStyles = aLatentStyles.getArray();
+ for (std::vector<beans::PropertyValue>::iterator i = rLatentStyles.begin(); i != rLatentStyles.end(); ++i)
+ *pLatentStyles++ = *i;
+
+ // We can put all latent style info directly to the document interop
+ // grab bag, as we can be sure that only a single style entry has
+ // latent style info.
+ uno::Reference<beans::XPropertySet> xPropertySet(m_pImpl->m_xTextDocument, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aGrabBag;
+ xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
+ sal_Int32 nLength = aGrabBag.getLength();
+ aGrabBag.realloc(nLength + 1);
+ aGrabBag[nLength].Name = "latentStyles";
+ aGrabBag[nLength].Value = uno::makeAny(aLatentStyles);
+ xPropertySet->setPropertyValue("InteropGrabBag", uno::makeAny(aGrabBag));
+ }
+
StyleSheetEntryPtr pEmptyEntry;
m_pImpl->m_pCurrentEntry = pEmptyEntry;
}
diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx
index 05f5748ae00f..eb3c87fa2251 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.hxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.hxx
@@ -63,6 +63,8 @@ public:
OUString sStyleName1;
PropertyMapPtr pProperties;
OUString sConvertedStyleName;
+ std::vector<beans::PropertyValue> aLatentStyles; ///< Attributes of latentStyles
+ std::vector<beans::PropertyValue> aLsdExceptions; ///< List of lsdException attribute lists
StyleSheetEntry();
virtual ~StyleSheetEntry();