summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-12-12 09:02:19 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-12-12 09:04:42 +0100
commiteb14f3d4e4da72ba19e28eb9ee796c04ab3b8d84 (patch)
treeb73e52ba1ee3d4425f58b10f3e97656b8ccc4997 /writerfilter
parent170616e9f2d30c1302bbb5a7a4b588bc05cd5cc9 (diff)
writerfilter: add a factory for DomainMapper
Ideally the XFilter implementations should only know that DomainMapper implements Stream, nothing more. Add a factory and use it in RtfFilter. When ImportFilter will do the same, then the DomainMapper class definition can be an implementation detail. Change-Id: If19cf23e61c2f78189d834261d57c569b9173b12
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/Library_writerfilter.mk1
-rw-r--r--writerfilter/inc/dmapper/DomainMapper.hxx7
-rw-r--r--writerfilter/inc/dmapper/DomainMapperFactory.hxx48
-rw-r--r--writerfilter/source/dmapper/domainmapperfactory.cxx31
-rw-r--r--writerfilter/source/filter/RtfFilter.cxx5
5 files changed, 84 insertions, 8 deletions
diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk
index 63d17f0316aa..2c6d01ecbef1 100644
--- a/writerfilter/Library_writerfilter.mk
+++ b/writerfilter/Library_writerfilter.mk
@@ -81,6 +81,7 @@ $(eval $(call gb_Library_add_exception_objects,writerfilter,\
writerfilter/source/dmapper/DomainMapperTableHandler \
writerfilter/source/dmapper/DomainMapperTableManager \
writerfilter/source/dmapper/DomainMapper_Impl \
+ writerfilter/source/dmapper/domainmapperfactory \
writerfilter/source/dmapper/FFDataHandler \
writerfilter/source/dmapper/FontTable \
writerfilter/source/dmapper/FormControlHelper \
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index 94f233f35ee8..6564e32d897a 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -19,6 +19,7 @@
#ifndef INCLUDED_WRITERFILTER_INC_DMAPPER_DOMAINMAPPER_HXX
#define INCLUDED_WRITERFILTER_INC_DMAPPER_DOMAINMAPPER_HXX
+#include <dmapper/DomainMapperFactory.hxx>
#include <resourcemodel/LoggedResources.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/style/TabAlign.hpp>
@@ -63,12 +64,6 @@ enum SprmType
SPRM_DEFAULT,
SPRM_LIST
};
-enum SourceDocumentType
-{
- DOCUMENT_DOC,
- DOCUMENT_OOXML,
- DOCUMENT_RTF
-};
class DomainMapper : public LoggedProperties, public LoggedTable,
public BinaryObj, public LoggedStream
{
diff --git a/writerfilter/inc/dmapper/DomainMapperFactory.hxx b/writerfilter/inc/dmapper/DomainMapperFactory.hxx
new file mode 100644
index 000000000000..28563ac912c3
--- /dev/null
+++ b/writerfilter/inc/dmapper/DomainMapperFactory.hxx
@@ -0,0 +1,48 @@
+/*
+ * 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_INC_DMAPPER_DOMAINMAPPERFACTORY_HXX
+#define INCLUDED_WRITERFILTER_INC_DMAPPER_DOMAINMAPPERFACTORY_HXX
+
+#include <resourcemodel/WW8ResourceModel.hxx>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+namespace writerfilter
+{
+namespace dmapper
+{
+
+enum SourceDocumentType
+{
+ DOCUMENT_DOC,
+ DOCUMENT_OOXML,
+ DOCUMENT_RTF
+};
+
+/// Interface to create a DomainMapper instance.
+class DomainMapperFactory
+{
+public:
+ static Stream::Pointer_t
+ createMapper(css::uno::Reference<css::uno::XComponentContext> const& xContext,
+ css::uno::Reference<css::io::XInputStream> const& xInputStream,
+ css::uno::Reference<css::lang::XComponent> const& xModel,
+ bool bRepairStorage,
+ SourceDocumentType eDocumentType,
+ css::uno::Reference<css::text::XTextRange> const& xInsertTextRange,
+ bool bIsNewDoc = true);
+};
+} // namespace dmapper
+} // namespace writerfilter
+
+#endif // INCLUDED_WRITERFILTER_INC_DMAPPER_DOMAINMAPPERFACTORY_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/domainmapperfactory.cxx b/writerfilter/source/dmapper/domainmapperfactory.cxx
new file mode 100644
index 000000000000..e3965348ac19
--- /dev/null
+++ b/writerfilter/source/dmapper/domainmapperfactory.cxx
@@ -0,0 +1,31 @@
+/* -*- 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 <dmapper/DomainMapper.hxx>
+
+namespace writerfilter
+{
+namespace dmapper
+{
+
+Stream::Pointer_t DomainMapperFactory::createMapper(css::uno::Reference<css::uno::XComponentContext> const& xContext,
+ css::uno::Reference<css::io::XInputStream> const& xInputStream,
+ css::uno::Reference<css::lang::XComponent> const& xModel,
+ bool bRepairStorage,
+ SourceDocumentType eDocumentType,
+ css::uno::Reference<css::text::XTextRange> const& xInsertTextRange,
+ bool bIsNewDoc)
+{
+ return Stream::Pointer_t(new DomainMapper(xContext, xInputStream, xModel, bRepairStorage, eDocumentType, xInsertTextRange, bIsNewDoc));
+}
+
+} // namespace dmapper
+} // namespace writerfilter
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index 62438180085e..aaa533cef397 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -21,7 +21,8 @@
#include <RtfFilter.hxx>
#include <unotools/mediadescriptor.hxx>
#include <cppuhelper/supportsservice.hxx>
-#include <dmapper/DomainMapper.hxx>
+#include <dmapper/DomainMapperFactory.hxx>
+#include <resourcemodel/TagLogger.hxx>
#include <rtftok/RTFDocument.hxx>
#include <com/sun/star/io/WrongFormatException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -113,7 +114,7 @@ sal_Bool RtfFilter::filter(const uno::Sequence< beans::PropertyValue >& aDescrip
uno::Reference<task::XStatusIndicator>());
writerfilter::Stream::Pointer_t pStream(
- new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, writerfilter::dmapper::DOCUMENT_RTF, xInsertTextRange, bIsNewDoc));
+ writerfilter::dmapper::DomainMapperFactory::createMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, writerfilter::dmapper::DOCUMENT_RTF, xInsertTextRange, bIsNewDoc));
writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator));
pDocument->resolve(*pStream);