[Libreoffice-commits] core.git: 2 commits - include/writerperfect Repository.mk writerperfect/CppunitTest_writerperfect_stream.mk writerperfect/Library_wpftdraw.mk writerperfect/Library_wpftimpress.mk writerperfect/Library_wpftwriter.mk writerperfect/Library_writerperfect.mk writerperfect/Module_writerperfect.mk writerperfect/qa writerperfect/source writerperfect/StaticLibrary_writerperfect.mk
David Tardon
dtardon at redhat.com
Thu Apr 24 07:35:07 PDT 2014
Repository.mk | 1
include/writerperfect/DirectoryStream.hxx | 50
include/writerperfect/DocumentHandler.hxx | 56
include/writerperfect/WPXSvInputStream.hxx | 59
include/writerperfect/writerperfectdllapi.h | 23
writerperfect/CppunitTest_writerperfect_stream.mk | 1
writerperfect/Library_wpftdraw.mk | 11
writerperfect/Library_wpftimpress.mk | 10
writerperfect/Library_wpftwriter.mk | 10
writerperfect/Library_writerperfect.mk | 54
writerperfect/Module_writerperfect.mk | 2
writerperfect/StaticLibrary_writerperfect.mk | 46
writerperfect/qa/unit/WPXSvStreamTest.cxx | 4
writerperfect/source/common/DirectoryStream.cxx | 4
writerperfect/source/common/DirectoryStream.hxx | 48
writerperfect/source/common/DocumentHandler.cxx | 12
writerperfect/source/common/DocumentHandler.hxx | 48
writerperfect/source/common/WPXSvInputStream.cxx | 961 ++++++++++++++++
writerperfect/source/common/WPXSvStream.cxx | 953 ---------------
writerperfect/source/common/WPXSvStream.hxx | 50
writerperfect/source/draw/CDRImportFilter.cxx | 147 --
writerperfect/source/draw/CDRImportFilter.hxx | 55
writerperfect/source/draw/CMXImportFilter.cxx | 147 --
writerperfect/source/draw/CMXImportFilter.hxx | 55
writerperfect/source/draw/FreehandImportFilter.cxx | 147 --
writerperfect/source/draw/FreehandImportFilter.hxx | 55
writerperfect/source/draw/ImportFilterBase.cxx | 180 ++
writerperfect/source/draw/ImportFilterBase.hxx | 100 +
writerperfect/source/draw/MSPUBImportFilter.cxx | 145 --
writerperfect/source/draw/MSPUBImportFilter.hxx | 55
writerperfect/source/draw/VisioImportFilter.cxx | 147 --
writerperfect/source/draw/VisioImportFilter.hxx | 55
writerperfect/source/draw/WPGImportFilter.cxx | 148 --
writerperfect/source/draw/WPGImportFilter.hxx | 55
writerperfect/source/impress/KeynoteImportFilter.cxx | 11
writerperfect/source/writer/AbiWordImportFilter.cxx | 7
writerperfect/source/writer/EBookImportFilter.cxx | 7
writerperfect/source/writer/MSWorksImportFilter.cxx | 7
writerperfect/source/writer/MWAWImportFilter.cxx | 8
writerperfect/source/writer/WordPerfectImportFilter.cxx | 7
40 files changed, 1672 insertions(+), 2269 deletions(-)
New commits:
commit ec544e5329b413fa6add9eef07ae598b15837eb1
Author: David Tardon <dtardon at redhat.com>
Date: Thu Apr 24 16:25:59 2014 +0200
refactor to decrease the amount of copypasta
Change-Id: Iedfa2a358bf098f6a5e28b994c4c340654a7c295
diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk
index faf805d..2f730ea 100644
--- a/writerperfect/Library_wpftdraw.mk
+++ b/writerperfect/Library_wpftdraw.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_exception_objects,wpftdraw,\
writerperfect/source/draw/CDRImportFilter \
writerperfect/source/draw/CMXImportFilter \
writerperfect/source/draw/FreehandImportFilter \
+ writerperfect/source/draw/ImportFilterBase \
writerperfect/source/draw/MSPUBImportFilter \
writerperfect/source/draw/VisioImportFilter \
writerperfect/source/draw/WPGImportFilter \
diff --git a/writerperfect/source/draw/CDRImportFilter.cxx b/writerperfect/source/draw/CDRImportFilter.cxx
index 2464860..396ab45 100644
--- a/writerperfect/source/draw/CDRImportFilter.cxx
+++ b/writerperfect/source/draw/CDRImportFilter.cxx
@@ -11,166 +11,42 @@
* Corel Corporation or Corel Corporation Limited."
*/
-#include <osl/diagnose.h>
-#include <rtl/tencinfo.h>
-
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <writerperfect/DocumentHandler.hxx>
-#include <writerperfect/WPXSvInputStream.hxx>
-
-#include <xmloff/attrlist.hxx>
-
#include <libcdr/libcdr.h>
#include <libodfgen/libodfgen.hxx>
#include "CDRImportFilter.hxx"
-#include <iostream>
-
-using namespace ::com::sun::star::uno;
using com::sun::star::uno::Reference;
-using com::sun::star::io::XInputStream;
-using com::sun::star::io::XSeekable;
-using com::sun::star::uno::Sequence;
-using com::sun::star::uno::Any;
-using com::sun::star::uno::UNO_QUERY;
-using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
-using com::sun::star::beans::PropertyValue;
-using com::sun::star::document::XFilter;
-using com::sun::star::document::XExtendedFilterDetection;
-using com::sun::star::document::XImporter;
-using com::sun::star::xml::sax::InputSource;
-using com::sun::star::xml::sax::XAttributeList;
-using com::sun::star::xml::sax::XDocumentHandler;
-using com::sun::star::xml::sax::XParser;
-
-using writerperfect::DocumentHandler;
-using writerperfect::WPXSvInputStream;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XComponentContext;
+using com::sun::star::uno::XInterface;
-sal_Bool SAL_CALL CDRImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
-throw (RuntimeException, std::exception)
+bool CDRImportFilter::doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator )
{
- SAL_INFO("writerperfect", "CDRImportFilter::filter");
- sal_Int32 nLength = aDescriptor.getLength();
- const PropertyValue *pValue = aDescriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
- }
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( false );
- return sal_False;
- }
-
- // An XML import service: what we push sax messages to..
- Reference < XDocumentHandler > xInternalHandler(
- mxContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
- css::uno::UNO_QUERY_THROW);
-
- // The XImporter sets up an empty target document for XDocumentHandler to write to..
- Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
- xImporter->setTargetDocument( mxDoc );
-
- // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
- // writes to in-memory target doc
- DocumentHandler xHandler(xInternalHandler);
-
- WPXSvInputStream input( xInputStream );
+ SAL_INFO("writerperfect", "CDRImportFilter::doImportDocument");
- OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
- bool tmpParseResult = libcdr::CDRDocument::parse(&input, &exporter);
- return tmpParseResult;
+ return libcdr::CDRDocument::parse(&rInput, &rGenerator);
}
-void SAL_CALL CDRImportFilter::cancel( )
-throw (RuntimeException, std::exception)
+bool CDRImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName )
{
- SAL_INFO("writerperfect", "CDRImportFilter::cancel");
-}
-
-// XImporter
-void SAL_CALL CDRImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
-throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "CDRImportFilter::setTargetDocument");
- mxDoc = xDoc;
-}
+ SAL_INFO("writerperfect", "CDRImportFilter::doDetectFormat");
-// XExtendedFilterDetection
-OUString SAL_CALL CDRImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
-throw( com::sun::star::uno::RuntimeException, std::exception )
-{
- SAL_INFO("writerperfect", "CDRImportFilter::detect");
- OUString sTypeName;
- sal_Int32 nLength = Descriptor.getLength();
- sal_Int32 location = nLength;
- const PropertyValue *pValue = Descriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
+ if (libcdr::CDRDocument::isSupported(&rInput))
{
- if ( pValue[i].Name == "TypeName" )
- location=i;
- else if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
+ rTypeName = "draw_CorelDraw_Document";
+ return true;
}
- if (!xInputStream.is())
- return OUString();
-
- WPXSvInputStream input( xInputStream );
-
- if (libcdr::CDRDocument::isSupported(&input))
- sTypeName = "draw_CorelDraw_Document";
-
- if (!sTypeName.isEmpty())
- {
- if ( location == nLength )
- {
- Descriptor.realloc(nLength+1);
- Descriptor[location].Name = "TypeName";
- }
-
- Descriptor[location].Value <<=sTypeName;
- }
- return sTypeName;
+ return false;
}
-
-// XInitialization
-void SAL_CALL CDRImportFilter::initialize( const Sequence< Any >& aArguments )
-throw (Exception, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "CDRImportFilter::initialize");
- Sequence < PropertyValue > aAnySeq;
- sal_Int32 nLength = aArguments.getLength();
- if ( nLength && ( aArguments[0] >>= aAnySeq ) )
- {
- const PropertyValue *pValue = aAnySeq.getConstArray();
- nLength = aAnySeq.getLength();
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "Type" )
- {
- pValue[i].Value >>= msFilterName;
- break;
- }
- }
- }
-}
OUString CDRImportFilter_getImplementationName ()
throw (RuntimeException)
{
diff --git a/writerperfect/source/draw/CDRImportFilter.hxx b/writerperfect/source/draw/CDRImportFilter.hxx
index 351a3e8..cf8a254 100644
--- a/writerperfect/source/draw/CDRImportFilter.hxx
+++ b/writerperfect/source/draw/CDRImportFilter.hxx
@@ -11,58 +11,18 @@
#ifndef _CDRIMPORTFILTER_HXX
#define _CDRIMPORTFILTER_HXX
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/document/XExtendedFilterDetection.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <cppuhelper/implbase5.hxx>
-
-#include <stdio.h>
+#include "ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
-class CDRImportFilter : public cppu::WeakImplHelper5
- <
- com::sun::star::document::XFilter,
- com::sun::star::document::XImporter,
- com::sun::star::document::XExtendedFilterDetection,
- com::sun::star::lang::XInitialization,
- com::sun::star::lang::XServiceInfo
- >
+class CDRImportFilter : public writerperfect::draw::ImportFilterBase
{
-protected:
- // oo.org declares
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
- OUString msFilterName;
- ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
-
public:
- CDRImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
- : mxContext( rxContext ) {}
- virtual ~CDRImportFilter() {}
-
- // XFilter
- virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL cancel( )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XImporter
- virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- //XExtendedFilterDetection
- virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
- throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ CDRImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : writerperfect::draw::ImportFilterBase( rxContext )
+ {
+ }
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
@@ -72,6 +32,9 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+private:
+ virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE;
+ virtual bool doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator ) SAL_OVERRIDE;
};
OUString CDRImportFilter_getImplementationName()
diff --git a/writerperfect/source/draw/CMXImportFilter.cxx b/writerperfect/source/draw/CMXImportFilter.cxx
index fe94432..cc8f1e8 100644
--- a/writerperfect/source/draw/CMXImportFilter.cxx
+++ b/writerperfect/source/draw/CMXImportFilter.cxx
@@ -11,166 +11,42 @@
* Corel Corporation or Corel Corporation Limited."
*/
-#include <osl/diagnose.h>
-#include <rtl/tencinfo.h>
-
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <writerperfect/DocumentHandler.hxx>
-#include <writerperfect/WPXSvInputStream.hxx>
-
-#include <xmloff/attrlist.hxx>
-
#include <libcdr/libcdr.h>
#include <libodfgen/libodfgen.hxx>
#include "CMXImportFilter.hxx"
-#include <iostream>
-
-using namespace ::com::sun::star::uno;
using com::sun::star::uno::Reference;
-using com::sun::star::io::XInputStream;
-using com::sun::star::io::XSeekable;
-using com::sun::star::uno::Sequence;
-using com::sun::star::uno::Any;
-using com::sun::star::uno::UNO_QUERY;
-using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
-using com::sun::star::beans::PropertyValue;
-using com::sun::star::document::XFilter;
-using com::sun::star::document::XExtendedFilterDetection;
-using com::sun::star::document::XImporter;
-using com::sun::star::xml::sax::InputSource;
-using com::sun::star::xml::sax::XAttributeList;
-using com::sun::star::xml::sax::XDocumentHandler;
-using com::sun::star::xml::sax::XParser;
-
-using writerperfect::DocumentHandler;
-using writerperfect::WPXSvInputStream;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XComponentContext;
+using com::sun::star::uno::XInterface;
-sal_Bool SAL_CALL CMXImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
-throw (RuntimeException, std::exception)
+bool CMXImportFilter::doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator )
{
- SAL_INFO("writerperfect", "CMXImportFilter::filter");
- sal_Int32 nLength = aDescriptor.getLength();
- const PropertyValue *pValue = aDescriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
- }
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( false );
- return sal_False;
- }
-
- // An XML import service: what we push sax messages to..
- Reference < XDocumentHandler > xInternalHandler(
- mxContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
- css::uno::UNO_QUERY_THROW);
-
- // The XImporter sets up an empty target document for XDocumentHandler to write to..
- Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
- xImporter->setTargetDocument( mxDoc );
-
- // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
- // writes to in-memory target doc
- DocumentHandler xHandler(xInternalHandler);
-
- WPXSvInputStream input( xInputStream );
+ SAL_INFO("writerperfect", "CMXImportFilter::doImportDocument");
- OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
- bool tmpParseResult = libcdr::CMXDocument::parse(&input, &exporter);
- return tmpParseResult;
+ return libcdr::CMXDocument::parse(&rInput, &rGenerator);
}
-void SAL_CALL CMXImportFilter::cancel( )
-throw (RuntimeException, std::exception)
+bool CMXImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName )
{
- SAL_INFO("writerperfect", "CMXImportFilter::cancel");
-}
-
-// XImporter
-void SAL_CALL CMXImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
-throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "CMXImportFilter::setTargetDocument");
- mxDoc = xDoc;
-}
+ SAL_INFO("writerperfect", "CMXImportFilter::doDetectFormat");
-// XExtendedFilterDetection
-OUString SAL_CALL CMXImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
-throw( com::sun::star::uno::RuntimeException, std::exception )
-{
- SAL_INFO("writerperfect", "CMXImportFilter::detect");
- OUString sTypeName;
- sal_Int32 nLength = Descriptor.getLength();
- sal_Int32 location = nLength;
- const PropertyValue *pValue = Descriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
+ if (libcdr::CMXDocument::isSupported(&rInput))
{
- if ( pValue[i].Name == "TypeName" )
- location=i;
- else if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
+ rTypeName = "draw_Corel_Presentation_Exchange";
+ return true;
}
- if (!xInputStream.is())
- return OUString();
-
- WPXSvInputStream input( xInputStream );
-
- if (libcdr::CMXDocument::isSupported(&input))
- sTypeName = "draw_Corel_Presentation_Exchange";
-
- if (!sTypeName.isEmpty())
- {
- if ( location == nLength )
- {
- Descriptor.realloc(nLength+1);
- Descriptor[location].Name = "TypeName";
- }
-
- Descriptor[location].Value <<=sTypeName;
- }
- return sTypeName;
+ return false;
}
-
-// XInitialization
-void SAL_CALL CMXImportFilter::initialize( const Sequence< Any >& aArguments )
-throw (Exception, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "CMXImportFilter::initialize");
- Sequence < PropertyValue > aAnySeq;
- sal_Int32 nLength = aArguments.getLength();
- if ( nLength && ( aArguments[0] >>= aAnySeq ) )
- {
- const PropertyValue *pValue = aAnySeq.getConstArray();
- nLength = aAnySeq.getLength();
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "Type" )
- {
- pValue[i].Value >>= msFilterName;
- break;
- }
- }
- }
-}
OUString CMXImportFilter_getImplementationName ()
throw (RuntimeException)
{
diff --git a/writerperfect/source/draw/CMXImportFilter.hxx b/writerperfect/source/draw/CMXImportFilter.hxx
index 0c0e49f..4bc37eb 100644
--- a/writerperfect/source/draw/CMXImportFilter.hxx
+++ b/writerperfect/source/draw/CMXImportFilter.hxx
@@ -11,58 +11,18 @@
#ifndef _CMXIMPORTFILTER_HXX
#define _CMXIMPORTFILTER_HXX
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/document/XExtendedFilterDetection.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <cppuhelper/implbase5.hxx>
-
-#include <stdio.h>
+#include "ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
-class CMXImportFilter : public cppu::WeakImplHelper5
- <
- com::sun::star::document::XFilter,
- com::sun::star::document::XImporter,
- com::sun::star::document::XExtendedFilterDetection,
- com::sun::star::lang::XInitialization,
- com::sun::star::lang::XServiceInfo
- >
+class CMXImportFilter : public writerperfect::draw::ImportFilterBase
{
-protected:
- // oo.org declares
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
- OUString msFilterName;
- ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
-
public:
- CMXImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
- : mxContext( rxContext ) {}
- virtual ~CMXImportFilter() {}
-
- // XFilter
- virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL cancel( )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XImporter
- virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- //XExtendedFilterDetection
- virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
- throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ CMXImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : writerperfect::draw::ImportFilterBase( rxContext )
+ {
+ }
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
@@ -72,6 +32,9 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+private:
+ virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) SAL_OVERRIDE;
+ virtual bool doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator ) SAL_OVERRIDE;
};
OUString CMXImportFilter_getImplementationName()
diff --git a/writerperfect/source/draw/FreehandImportFilter.cxx b/writerperfect/source/draw/FreehandImportFilter.cxx
index b73aa4a..cfc0a49 100644
--- a/writerperfect/source/draw/FreehandImportFilter.cxx
+++ b/writerperfect/source/draw/FreehandImportFilter.cxx
@@ -7,166 +7,42 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <osl/diagnose.h>
-#include <rtl/tencinfo.h>
-
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <writerperfect/DocumentHandler.hxx>
-#include <writerperfect/WPXSvInputStream.hxx>
-
-#include <xmloff/attrlist.hxx>
-
#include <libfreehand/libfreehand.h>
#include <libodfgen/libodfgen.hxx>
#include "FreehandImportFilter.hxx"
-#include <iostream>
-
-using namespace ::com::sun::star::uno;
using com::sun::star::uno::Reference;
-using com::sun::star::io::XInputStream;
-using com::sun::star::io::XSeekable;
-using com::sun::star::uno::Sequence;
-using com::sun::star::uno::Any;
-using com::sun::star::uno::UNO_QUERY;
-using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
-using com::sun::star::beans::PropertyValue;
-using com::sun::star::document::XFilter;
-using com::sun::star::document::XExtendedFilterDetection;
-using com::sun::star::document::XImporter;
-using com::sun::star::xml::sax::InputSource;
-using com::sun::star::xml::sax::XAttributeList;
-using com::sun::star::xml::sax::XDocumentHandler;
-using com::sun::star::xml::sax::XParser;
-
-using writerperfect::DocumentHandler;
-using writerperfect::WPXSvInputStream;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XComponentContext;
+using com::sun::star::uno::XInterface;
-sal_Bool SAL_CALL FreehandImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
-throw (RuntimeException, std::exception)
+bool FreehandImportFilter::doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator )
{
- SAL_INFO("writerperfect", "FreehandImportFilter::filter");
- sal_Int32 nLength = aDescriptor.getLength();
- const PropertyValue *pValue = aDescriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
- }
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( false );
- return sal_False;
- }
-
- // An XML import service: what we push sax messages to..
- Reference < XDocumentHandler > xInternalHandler(
- mxContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
- css::uno::UNO_QUERY_THROW);
-
- // The XImporter sets up an empty target document for XDocumentHandler to write to..
- Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
- xImporter->setTargetDocument( mxDoc );
-
- // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
- // writes to in-memory target doc
- DocumentHandler xHandler(xInternalHandler);
-
- WPXSvInputStream input( xInputStream );
+ SAL_INFO("writerperfect", "FreehandImportFilter::doImportDocument");
- OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
- bool tmpParseResult = libfreehand::FreeHandDocument::parse(&input, &exporter);
- return tmpParseResult;
+ return libfreehand::FreeHandDocument::parse(&rInput, &rGenerator);
}
-void SAL_CALL FreehandImportFilter::cancel( )
-throw (RuntimeException, std::exception)
+bool FreehandImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName )
{
- SAL_INFO("writerperfect", "FreehandImportFilter::cancel");
-}
-
-// XImporter
-void SAL_CALL FreehandImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
-throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "FreehandImportFilter::setTargetDocument");
- mxDoc = xDoc;
-}
+ SAL_INFO("writerperfect", "FreehandImportFilter::doDetectFormat");
-// XExtendedFilterDetection
-OUString SAL_CALL FreehandImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
-throw( com::sun::star::uno::RuntimeException, std::exception )
-{
- SAL_INFO("writerperfect", "FreehandImportFilter::detect");
- OUString sTypeName;
- sal_Int32 nLength = Descriptor.getLength();
- sal_Int32 location = nLength;
- const PropertyValue *pValue = Descriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
+ if (libfreehand::FreeHandDocument::isSupported(&rInput))
{
- if ( pValue[i].Name == "TypeName" )
- location=i;
- else if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
+ rTypeName = "draw_Freehand_Document";
+ return true;
}
- if (!xInputStream.is())
- return OUString();
-
- WPXSvInputStream input( xInputStream );
-
- if (libfreehand::FreeHandDocument::isSupported(&input))
- sTypeName = "draw_Freehand_Document";
-
- if (!sTypeName.isEmpty())
- {
- if ( location == nLength )
- {
- Descriptor.realloc(nLength+1);
- Descriptor[location].Name = "TypeName";
- }
-
- Descriptor[location].Value <<=sTypeName;
- }
- return sTypeName;
+ return false;
}
-
-// XInitialization
-void SAL_CALL FreehandImportFilter::initialize( const Sequence< Any >& aArguments )
-throw (Exception, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "FreehandImportFilter::initialize");
- Sequence < PropertyValue > aAnySeq;
- sal_Int32 nLength = aArguments.getLength();
- if ( nLength && ( aArguments[0] >>= aAnySeq ) )
- {
- const PropertyValue *pValue = aAnySeq.getConstArray();
- nLength = aAnySeq.getLength();
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "Type" )
- {
- pValue[i].Value >>= msFilterName;
- break;
- }
- }
- }
-}
OUString FreehandImportFilter_getImplementationName ()
throw (RuntimeException)
{
diff --git a/writerperfect/source/draw/FreehandImportFilter.hxx b/writerperfect/source/draw/FreehandImportFilter.hxx
index 455e23f..adb6833 100644
--- a/writerperfect/source/draw/FreehandImportFilter.hxx
+++ b/writerperfect/source/draw/FreehandImportFilter.hxx
@@ -8,58 +8,18 @@
#ifndef _FREEHANDIMPORTFILTER_HXX
#define _FREEHANDIMPORTFILTER_HXX
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/document/XExtendedFilterDetection.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <cppuhelper/implbase5.hxx>
-
-#include <stdio.h>
+#include "ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
-class FreehandImportFilter : public cppu::WeakImplHelper5
- <
- com::sun::star::document::XFilter,
- com::sun::star::document::XImporter,
- com::sun::star::document::XExtendedFilterDetection,
- com::sun::star::lang::XInitialization,
- com::sun::star::lang::XServiceInfo
- >
+class FreehandImportFilter : public writerperfect::draw::ImportFilterBase
{
-protected:
- // oo.org declares
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
- OUString msFilterName;
- ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
-
public:
- FreehandImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
- : mxContext( rxContext ) {}
- virtual ~FreehandImportFilter() {}
-
- // XFilter
- virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL cancel( )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XImporter
- virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- //XExtendedFilterDetection
- virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
- throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ FreehandImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : writerperfect::draw::ImportFilterBase( rxContext )
+ {
+ }
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
@@ -69,6 +29,9 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+private:
+ virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName );
+ virtual bool doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator );
};
OUString FreehandImportFilter_getImplementationName()
diff --git a/writerperfect/source/draw/ImportFilterBase.cxx b/writerperfect/source/draw/ImportFilterBase.cxx
new file mode 100644
index 0000000..4488c6a
--- /dev/null
+++ b/writerperfect/source/draw/ImportFilterBase.cxx
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/uno/Reference.h>
+
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
+#include <xmloff/attrlist.hxx>
+
+#include <libodfgen/libodfgen.hxx>
+
+#include "ImportFilterBase.hxx"
+
+namespace writerperfect
+{
+namespace draw
+{
+
+using com::sun::star::uno::Reference;
+using com::sun::star::io::XInputStream;
+using com::sun::star::io::XSeekable;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Any;
+using com::sun::star::uno::UNO_QUERY;
+using com::sun::star::uno::XInterface;
+using com::sun::star::uno::Exception;
+using com::sun::star::uno::RuntimeException;
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::document::XFilter;
+using com::sun::star::document::XExtendedFilterDetection;
+using com::sun::star::document::XImporter;
+using com::sun::star::xml::sax::InputSource;
+using com::sun::star::xml::sax::XAttributeList;
+using com::sun::star::xml::sax::XDocumentHandler;
+using com::sun::star::xml::sax::XParser;
+
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
+
+ImportFilterImpl::ImportFilterImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : mxContext( rxContext )
+{
+}
+
+ImportFilterImpl::~ImportFilterImpl()
+{
+}
+
+sal_Bool SAL_CALL ImportFilterImpl::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+throw (RuntimeException, std::exception)
+{
+ SAL_INFO("writerperfect", "ImportFilterImpl::filter");
+ sal_Int32 nLength = aDescriptor.getLength();
+ const PropertyValue *pValue = aDescriptor.getConstArray();
+ Reference < XInputStream > xInputStream;
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue[i].Name == "InputStream" )
+ pValue[i].Value >>= xInputStream;
+ }
+ if ( !xInputStream.is() )
+ {
+ OSL_ASSERT( false );
+ return sal_False;
+ }
+
+ // An XML import service: what we push sax messages to..
+ Reference < XDocumentHandler > xInternalHandler(
+ mxContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
+ css::uno::UNO_QUERY_THROW);
+
+ // The XImporter sets up an empty target document for XDocumentHandler to write to..
+ Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
+ xImporter->setTargetDocument( mxDoc );
+
+ // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
+ // writes to in-memory target doc
+ DocumentHandler xHandler(xInternalHandler);
+
+ WPXSvInputStream input( xInputStream );
+
+ OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
+
+ return doImportDocument(input, exporter);
+}
+
+void SAL_CALL ImportFilterImpl::cancel( )
+throw (RuntimeException, std::exception)
+{
+ SAL_INFO("writerperfect", "ImportFilterImpl::cancel");
+}
+
+// XImporter
+void SAL_CALL ImportFilterImpl::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
+throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
+{
+ SAL_INFO("writerperfect", "ImportFilterImpl::setTargetDocument");
+ mxDoc = xDoc;
+}
+
+// XExtendedFilterDetection
+OUString SAL_CALL ImportFilterImpl::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
+throw( com::sun::star::uno::RuntimeException, std::exception )
+{
+ SAL_INFO("writerperfect", "ImportFilterImpl::detect");
+ OUString sTypeName;
+ sal_Int32 nLength = Descriptor.getLength();
+ sal_Int32 location = nLength;
+ const PropertyValue *pValue = Descriptor.getConstArray();
+ Reference < XInputStream > xInputStream;
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue[i].Name == "TypeName" )
+ location=i;
+ else if ( pValue[i].Name == "InputStream" )
+ pValue[i].Value >>= xInputStream;
+ }
+
+ if (!xInputStream.is())
+ return OUString();
+
+ WPXSvInputStream input( xInputStream );
+
+ if ( doDetectFormat( input, sTypeName ) )
+ {
+ assert (!sTypeName.isEmpty());
+
+ if ( location == nLength )
+ {
+ Descriptor.realloc(nLength+1);
+ Descriptor[location].Name = "TypeName";
+ }
+
+ Descriptor[location].Value <<=sTypeName;
+ }
+
+ return sTypeName;
+}
+
+
+// XInitialization
+void SAL_CALL ImportFilterImpl::initialize( const Sequence< Any >& aArguments )
+throw (Exception, RuntimeException, std::exception)
+{
+ SAL_INFO("writerperfect", "ImportFilterImpl::initialize");
+ Sequence < PropertyValue > aAnySeq;
+ sal_Int32 nLength = aArguments.getLength();
+ if ( nLength && ( aArguments[0] >>= aAnySeq ) )
+ {
+ const PropertyValue *pValue = aAnySeq.getConstArray();
+ nLength = aAnySeq.getLength();
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue[i].Name == "Type" )
+ {
+ pValue[i].Value >>= msFilterName;
+ break;
+ }
+ }
+ }
+}
+
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/ImportFilterBase.hxx b/writerperfect/source/draw/ImportFilterBase.hxx
new file mode 100644
index 0000000..7287a5a
--- /dev/null
+++ b/writerperfect/source/draw/ImportFilterBase.hxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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_WRITERPERFECT_SOURCE_DRAW_IMPORTFILTERBASE_HXX
+#define INCLUDED_WRITERPERFECT_SOURCE_DRAW_IMPORTFILTERBASE_HXX
+
+#include <libwpd-stream/libwpd-stream.h>
+
+#include <libwpg/libwpg.h>
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase4.hxx>
+
+namespace com { namespace sun { namespace star {
+namespace beans
+{
+ class PropertyValue;
+}
+namespace lang
+{
+ class XComponent;
+}
+namespace uno
+{
+ class XComponentContext;
+}
+namespace xml { namespace sax {
+ class XDocumentHandler;
+}
+}
+} } }
+
+namespace writerperfect
+{
+namespace draw
+{
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class ImportFilterImpl : public cppu::WeakImplHelper4
+ <
+ com::sun::star::document::XFilter,
+ com::sun::star::document::XImporter,
+ com::sun::star::document::XExtendedFilterDetection,
+ com::sun::star::lang::XInitialization
+ >
+{
+public:
+ ImportFilterImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext );
+ virtual ~ImportFilterImpl();
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+ throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL cancel( )
+ throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XImporter
+ virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ //XExtendedFilterDetection
+ virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
+ throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+private:
+ virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName ) = 0;
+ virtual bool doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator ) = 0;
+
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
+ OUString msFilterName;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
+};
+
+/** A base class for import filters.
+ */
+typedef cppu::ImplInheritanceHelper1<ImportFilterImpl, com::sun::star::lang::XServiceInfo> ImportFilterBase;
+
+}
+}
+
+#endif // INCLUDED_WRITERPERFECT_SOURCE_DRAW_IMPORTFILTERBASE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/MSPUBImportFilter.cxx b/writerperfect/source/draw/MSPUBImportFilter.cxx
index b7537b0..ca6c8a2 100644
--- a/writerperfect/source/draw/MSPUBImportFilter.cxx
+++ b/writerperfect/source/draw/MSPUBImportFilter.cxx
@@ -7,23 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <osl/diagnose.h>
-#include <rtl/tencinfo.h>
-
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <writerperfect/DocumentHandler.hxx>
-#include <writerperfect/WPXSvInputStream.hxx>
-
-#include <xmloff/attrlist.hxx>
-
#include <libmspub/libmspub.h>
#include <libodfgen/libodfgen.hxx>
@@ -31,142 +18,33 @@
#include <iostream>
-using namespace ::com::sun::star::uno;
using com::sun::star::uno::Reference;
-using com::sun::star::io::XInputStream;
-using com::sun::star::io::XSeekable;
-using com::sun::star::uno::Sequence;
-using com::sun::star::uno::Any;
-using com::sun::star::uno::UNO_QUERY;
-using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
-using com::sun::star::beans::PropertyValue;
-using com::sun::star::document::XFilter;
-using com::sun::star::document::XExtendedFilterDetection;
-using com::sun::star::document::XImporter;
-using com::sun::star::xml::sax::InputSource;
-using com::sun::star::xml::sax::XAttributeList;
-using com::sun::star::xml::sax::XDocumentHandler;
-using com::sun::star::xml::sax::XParser;
-
-using writerperfect::DocumentHandler;
-using writerperfect::WPXSvInputStream;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XComponentContext;
+using com::sun::star::uno::XInterface;
-sal_Bool SAL_CALL MSPUBImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
-throw (RuntimeException, std::exception)
+bool MSPUBImportFilter::doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator )
{
- SAL_INFO("writerperfect", "MSPUBImportFilter::filter");
- sal_Int32 nLength = aDescriptor.getLength();
- const PropertyValue *pValue = aDescriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
- }
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( false );
- return sal_False;
- }
-
- // An XML import service: what we push sax messages to..
- Reference < XDocumentHandler > xInternalHandler(
- mxContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
- css::uno::UNO_QUERY_THROW);
-
- // The XImporter sets up an empty target document for XDocumentHandler to write to..
- Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
- xImporter->setTargetDocument( mxDoc );
-
- // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
- // writes to in-memory target doc
- DocumentHandler xHandler(xInternalHandler);
-
- WPXSvInputStream input( xInputStream );
+ SAL_INFO("writerperfect", "MSPUBImportFilter::doImportDocument");
- OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
- bool tmpParseResult = libmspub::MSPUBDocument::parse(&input, &exporter);
- return tmpParseResult;
+ return libmspub::MSPUBDocument::parse(&rInput, &rGenerator);
}
-void SAL_CALL MSPUBImportFilter::cancel( )
-throw (RuntimeException, std::exception)
+bool MSPUBImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName )
{
- SAL_INFO("writerperfect", "MSPUBImportFilter::cancel");
-}
-
-// XImporter
-void SAL_CALL MSPUBImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
-throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "MSPUBImportFilter::setTargetDocument");
- mxDoc = xDoc;
-}
+ SAL_INFO("writerperfect", "MSPUBImportFilter::doDetectFormat");
-// XExtendedFilterDetection
-OUString SAL_CALL MSPUBImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
-throw( com::sun::star::uno::RuntimeException, std::exception )
-{
- SAL_INFO("writerperfect", "MSPUBImportFilter::detect");
- OUString sTypeName;
- sal_Int32 nLength = Descriptor.getLength();
- sal_Int32 location = nLength;
- const PropertyValue *pValue = Descriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
+ if (libmspub::MSPUBDocument::isSupported(&rInput))
{
- if ( pValue[i].Name == "TypeName" )
- location=i;
- else if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
+ rTypeName = "draw_Publisher_Document";
+ return true;
}
- if (!xInputStream.is())
- return OUString();
-
- WPXSvInputStream input( xInputStream );
-
- if (libmspub::MSPUBDocument::isSupported(&input))
- sTypeName = "draw_Publisher_Document";
-
- if (!sTypeName.isEmpty())
- {
- if ( location == nLength )
- {
- Descriptor.realloc(nLength+1);
- Descriptor[location].Name = "TypeName";
- }
-
- Descriptor[location].Value <<=sTypeName;
- }
- return sTypeName;
+ return false;
}
-
-// XInitialization
-void SAL_CALL MSPUBImportFilter::initialize( const Sequence< Any >& aArguments )
-throw (Exception, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "MSPUBImportFilter::initialize");
- Sequence < PropertyValue > aAnySeq;
- sal_Int32 nLength = aArguments.getLength();
- if ( nLength && ( aArguments[0] >>= aAnySeq ) )
- {
- const PropertyValue *pValue = aAnySeq.getConstArray();
- nLength = aAnySeq.getLength();
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "Type" )
- {
- pValue[i].Value >>= msFilterName;
- break;
- }
- }
- }
-}
OUString MSPUBImportFilter_getImplementationName ()
throw (RuntimeException)
{
diff --git a/writerperfect/source/draw/MSPUBImportFilter.hxx b/writerperfect/source/draw/MSPUBImportFilter.hxx
index 3ef2510..c92fb19 100644
--- a/writerperfect/source/draw/MSPUBImportFilter.hxx
+++ b/writerperfect/source/draw/MSPUBImportFilter.hxx
@@ -8,58 +8,18 @@
#ifndef _MSPUBIMPORTFILTER_HXX
#define _MSPUBIMPORTFILTER_HXX
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/document/XExtendedFilterDetection.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <cppuhelper/implbase5.hxx>
-
-#include <stdio.h>
+#include "ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
-class MSPUBImportFilter : public cppu::WeakImplHelper5
- <
- com::sun::star::document::XFilter,
- com::sun::star::document::XImporter,
- com::sun::star::document::XExtendedFilterDetection,
- com::sun::star::lang::XInitialization,
- com::sun::star::lang::XServiceInfo
- >
+class MSPUBImportFilter : public writerperfect::draw::ImportFilterBase
{
-protected:
- // oo.org declares
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
- OUString msFilterName;
- ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
-
public:
- MSPUBImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
- : mxContext( rxContext ) {}
- virtual ~MSPUBImportFilter() {}
-
- // XFilter
- virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL cancel( )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XImporter
- virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- //XExtendedFilterDetection
- virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
- throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ MSPUBImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : writerperfect::draw::ImportFilterBase( rxContext )
+ {
+ }
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
@@ -69,6 +29,9 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+private:
+ virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName );
+ virtual bool doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator );
};
OUString MSPUBImportFilter_getImplementationName()
diff --git a/writerperfect/source/draw/VisioImportFilter.cxx b/writerperfect/source/draw/VisioImportFilter.cxx
index 7d38821..0c5d32f 100644
--- a/writerperfect/source/draw/VisioImportFilter.cxx
+++ b/writerperfect/source/draw/VisioImportFilter.cxx
@@ -7,166 +7,42 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <osl/diagnose.h>
-#include <rtl/tencinfo.h>
-
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <writerperfect/DocumentHandler.hxx>
-#include <writerperfect/WPXSvInputStream.hxx>
-
-#include <xmloff/attrlist.hxx>
-
#include <libvisio/libvisio.h>
#include <libodfgen/libodfgen.hxx>
#include "VisioImportFilter.hxx"
-#include <iostream>
-
-using namespace ::com::sun::star::uno;
using com::sun::star::uno::Reference;
-using com::sun::star::io::XInputStream;
-using com::sun::star::io::XSeekable;
-using com::sun::star::uno::Sequence;
-using com::sun::star::uno::Any;
-using com::sun::star::uno::UNO_QUERY;
-using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
-using com::sun::star::beans::PropertyValue;
-using com::sun::star::document::XFilter;
-using com::sun::star::document::XExtendedFilterDetection;
-using com::sun::star::document::XImporter;
-using com::sun::star::xml::sax::InputSource;
-using com::sun::star::xml::sax::XAttributeList;
-using com::sun::star::xml::sax::XDocumentHandler;
-using com::sun::star::xml::sax::XParser;
-
-using writerperfect::DocumentHandler;
-using writerperfect::WPXSvInputStream;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XComponentContext;
+using com::sun::star::uno::XInterface;
-sal_Bool SAL_CALL VisioImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
-throw (RuntimeException, std::exception)
+bool VisioImportFilter::doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator )
{
- SAL_INFO("writerperfect", "VisioImportFilter::filter");
- sal_Int32 nLength = aDescriptor.getLength();
- const PropertyValue *pValue = aDescriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
- }
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( false );
- return sal_False;
- }
-
- // An XML import service: what we push sax messages to..
- Reference < XDocumentHandler > xInternalHandler(
- mxContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
- css::uno::UNO_QUERY_THROW);
-
- // The XImporter sets up an empty target document for XDocumentHandler to write to..
- Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
- xImporter->setTargetDocument( mxDoc );
-
- // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
- // writes to in-memory target doc
- DocumentHandler xHandler(xInternalHandler);
-
- WPXSvInputStream input( xInputStream );
+ SAL_INFO("writerperfect", "VisioImportFilter::doImportDocument");
- OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
- bool tmpParseResult = libvisio::VisioDocument::parse(&input, &exporter);
- return tmpParseResult;
+ return libvisio::VisioDocument::parse(&rInput, &rGenerator);
}
-void SAL_CALL VisioImportFilter::cancel( )
-throw (RuntimeException, std::exception)
+bool VisioImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName )
{
- SAL_INFO("writerperfect", "VisioImportFilter::cancel");
-}
-
-// XImporter
-void SAL_CALL VisioImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
-throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "VisioImportFilter::setTargetDocument");
- mxDoc = xDoc;
-}
+ SAL_INFO("writerperfect", "VisioImportFilter::doDetectFormat");
-// XExtendedFilterDetection
-OUString SAL_CALL VisioImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
-throw( com::sun::star::uno::RuntimeException, std::exception )
-{
- SAL_INFO("writerperfect", "VisioImportFilter::detect");
- OUString sTypeName;
- sal_Int32 nLength = Descriptor.getLength();
- sal_Int32 location = nLength;
- const PropertyValue *pValue = Descriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
+ if (libvisio::VisioDocument::isSupported(&rInput))
{
- if ( pValue[i].Name == "TypeName" )
- location=i;
- else if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
+ rTypeName = "draw_Visio_Document";
+ return true;
}
- if (!xInputStream.is())
- return OUString();
-
- WPXSvInputStream input( xInputStream );
-
- if (libvisio::VisioDocument::isSupported(&input))
- sTypeName = "draw_Visio_Document";
-
- if (!sTypeName.isEmpty())
- {
- if ( location == nLength )
- {
- Descriptor.realloc(nLength+1);
- Descriptor[location].Name = "TypeName";
- }
-
- Descriptor[location].Value <<=sTypeName;
- }
- return sTypeName;
+ return false;
}
-
-// XInitialization
-void SAL_CALL VisioImportFilter::initialize( const Sequence< Any >& aArguments )
-throw (Exception, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "VisioImportFilter::initialize");
- Sequence < PropertyValue > aAnySeq;
- sal_Int32 nLength = aArguments.getLength();
- if ( nLength && ( aArguments[0] >>= aAnySeq ) )
- {
- const PropertyValue *pValue = aAnySeq.getConstArray();
- nLength = aAnySeq.getLength();
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "Type" )
- {
- pValue[i].Value >>= msFilterName;
- break;
- }
- }
- }
-}
OUString VisioImportFilter_getImplementationName ()
throw (RuntimeException)
{
diff --git a/writerperfect/source/draw/VisioImportFilter.hxx b/writerperfect/source/draw/VisioImportFilter.hxx
index 56f0395..b35c44b 100644
--- a/writerperfect/source/draw/VisioImportFilter.hxx
+++ b/writerperfect/source/draw/VisioImportFilter.hxx
@@ -8,58 +8,18 @@
#ifndef _VISIOIMPORTFILTER_HXX
#define _VISIOIMPORTFILTER_HXX
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/document/XExtendedFilterDetection.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <cppuhelper/implbase5.hxx>
-
-#include <stdio.h>
+#include "ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
-class VisioImportFilter : public cppu::WeakImplHelper5
- <
- com::sun::star::document::XFilter,
- com::sun::star::document::XImporter,
- com::sun::star::document::XExtendedFilterDetection,
- com::sun::star::lang::XInitialization,
- com::sun::star::lang::XServiceInfo
- >
+class VisioImportFilter : public writerperfect::draw::ImportFilterBase
{
-protected:
- // oo.org declares
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
- OUString msFilterName;
- ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
-
public:
- VisioImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
- : mxContext( rxContext ) {}
- virtual ~VisioImportFilter() {}
-
- // XFilter
- virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL cancel( )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XImporter
- virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- //XExtendedFilterDetection
- virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
- throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ VisioImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : writerperfect::draw::ImportFilterBase( rxContext )
+ {
+ }
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
@@ -69,6 +29,9 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+private:
+ virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName );
+ virtual bool doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator );
};
OUString VisioImportFilter_getImplementationName()
diff --git a/writerperfect/source/draw/WPGImportFilter.cxx b/writerperfect/source/draw/WPGImportFilter.cxx
index b5b3d7f..6e4dd3a 100644
--- a/writerperfect/source/draw/WPGImportFilter.cxx
+++ b/writerperfect/source/draw/WPGImportFilter.cxx
@@ -13,166 +13,41 @@
* Corel Corporation or Corel Corporation Limited."
*/
-#include <osl/diagnose.h>
-#include <rtl/tencinfo.h>
-
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
-#include <writerperfect/DocumentHandler.hxx>
-#include <writerperfect/WPXSvInputStream.hxx>
-
-#include <xmloff/attrlist.hxx>
-
#include <libodfgen/libodfgen.hxx>
#include "WPGImportFilter.hxx"
-#include <iostream>
-
-using namespace ::com::sun::star::uno;
using com::sun::star::uno::Reference;
-using com::sun::star::io::XInputStream;
-using com::sun::star::io::XSeekable;
-using com::sun::star::uno::Sequence;
-using namespace ::rtl;
-using com::sun::star::uno::Any;
-using com::sun::star::uno::UNO_QUERY;
-using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
-using com::sun::star::beans::PropertyValue;
-using com::sun::star::document::XFilter;
-using com::sun::star::document::XExtendedFilterDetection;
-using com::sun::star::document::XImporter;
-using com::sun::star::xml::sax::InputSource;
-using com::sun::star::xml::sax::XAttributeList;
-using com::sun::star::xml::sax::XDocumentHandler;
-using com::sun::star::xml::sax::XParser;
-
-using writerperfect::DocumentHandler;
-using writerperfect::WPXSvInputStream;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::XComponentContext;
+using com::sun::star::uno::XInterface;
-sal_Bool SAL_CALL WPGImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
-throw (RuntimeException, std::exception)
+bool WPGImportFilter::doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator )
{
- SAL_INFO("writerperfect", "WPGImportFilter::filter");
- sal_Int32 nLength = aDescriptor.getLength();
- const PropertyValue *pValue = aDescriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
- }
- if ( !xInputStream.is() )
- {
- OSL_ASSERT( false );
- return sal_False;
- }
-
- // An XML import service: what we push sax messages to..
- Reference < XDocumentHandler > xInternalHandler(
- mxContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
- css::uno::UNO_QUERY_THROW);
-
- // The XImporter sets up an empty target document for XDocumentHandler to write to..
- Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
- xImporter->setTargetDocument( mxDoc );
-
- // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
- // writes to in-memory target doc
- DocumentHandler xHandler(xInternalHandler);
-
- WPXSvInputStream input( xInputStream );
+ SAL_INFO("writerperfect", "WPGImportFilter::doImportDocument");
- OdgGenerator exporter(&xHandler, ODF_FLAT_XML);
- bool tmpParseResult = libwpg::WPGraphics::parse(&input, &exporter);
- return tmpParseResult;
+ return libwpg::WPGraphics::parse(&rInput, &rGenerator);
}
-void SAL_CALL WPGImportFilter::cancel( )
-throw (RuntimeException, std::exception)
+bool WPGImportFilter::doDetectFormat( WPXInputStream &rInput, OUString &rTypeName )
{
- SAL_INFO("writerperfect", "WPGImportFilter::cancel");
-}
-
-// XImporter
-void SAL_CALL WPGImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
-throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "WPGImportFilter::setTargetDocument");
- mxDoc = xDoc;
-}
+ SAL_INFO("writerperfect", "WPGImportFilter::doDetectFormat");
-// XExtendedFilterDetection
-OUString SAL_CALL WPGImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
-throw( com::sun::star::uno::RuntimeException, std::exception )
-{
- SAL_INFO("writerperfect", "WPGImportFilter::detect");
- OUString sTypeName;
- sal_Int32 nLength = Descriptor.getLength();
- sal_Int32 location = nLength;
- const PropertyValue *pValue = Descriptor.getConstArray();
- Reference < XInputStream > xInputStream;
- for ( sal_Int32 i = 0 ; i < nLength; i++)
+ if (libwpg::WPGraphics::isSupported(&rInput))
{
- if ( pValue[i].Name == "TypeName" )
- location=i;
- else if ( pValue[i].Name == "InputStream" )
- pValue[i].Value >>= xInputStream;
+ rTypeName = "draw_WordPerfect_Graphics";
+ return true;
}
- if (!xInputStream.is())
- return OUString();
-
- WPXSvInputStream input( xInputStream );
-
- if (libwpg::WPGraphics::isSupported(&input))
- sTypeName = "draw_WordPerfect_Graphics";
-
- if (!sTypeName.isEmpty())
- {
- if ( location == nLength )
- {
- Descriptor.realloc(nLength+1);
- Descriptor[location].Name = "TypeName";
- }
-
- Descriptor[location].Value <<=sTypeName;
- }
- return sTypeName;
+ return false;
}
-
-// XInitialization
-void SAL_CALL WPGImportFilter::initialize( const Sequence< Any >& aArguments )
-throw (Exception, RuntimeException, std::exception)
-{
- SAL_INFO("writerperfect", "WPGImportFilter::initialize");
- Sequence < PropertyValue > aAnySeq;
- sal_Int32 nLength = aArguments.getLength();
- if ( nLength && ( aArguments[0] >>= aAnySeq ) )
- {
- const PropertyValue *pValue = aAnySeq.getConstArray();
- nLength = aAnySeq.getLength();
- for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
- if ( pValue[i].Name == "Type" )
- {
- pValue[i].Value >>= msFilterName;
- break;
- }
- }
- }
-}
OUString WPGImportFilter_getImplementationName ()
throw (RuntimeException)
{
diff --git a/writerperfect/source/draw/WPGImportFilter.hxx b/writerperfect/source/draw/WPGImportFilter.hxx
index 8b3b767..53c487c 100644
--- a/writerperfect/source/draw/WPGImportFilter.hxx
+++ b/writerperfect/source/draw/WPGImportFilter.hxx
@@ -13,58 +13,18 @@
#ifndef _WPGIMPORTFILTER_HXX
#define _WPGIMPORTFILTER_HXX
-#include <com/sun/star/document/XFilter.hpp>
-#include <com/sun/star/document/XImporter.hpp>
-#include <com/sun/star/document/XExtendedFilterDetection.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
-#include <cppuhelper/implbase5.hxx>
-
-#include <stdio.h>
+#include "ImportFilterBase.hxx"
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
-class WPGImportFilter : public cppu::WeakImplHelper5
- <
- com::sun::star::document::XFilter,
- com::sun::star::document::XImporter,
- com::sun::star::document::XExtendedFilterDetection,
- com::sun::star::lang::XInitialization,
- com::sun::star::lang::XServiceInfo
- >
+class WPGImportFilter : public writerperfect::draw::ImportFilterBase
{
-protected:
- // oo.org declares
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
- OUString msFilterName;
- ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
-
public:
- WPGImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
- : mxContext( rxContext ) {}
- virtual ~WPGImportFilter() {}
-
- // XFilter
- virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual void SAL_CALL cancel( )
- throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- // XImporter
- virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
- throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- //XExtendedFilterDetection
- virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
- throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-
- // XInitialization
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ WPGImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext )
+ : writerperfect::draw::ImportFilterBase( rxContext )
+ {
+ }
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
@@ -74,6 +34,9 @@ public:
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+private:
+ virtual bool doDetectFormat( WPXInputStream &rInput, OUString &rTypeName );
+ virtual bool doImportDocument( WPXInputStream &rInput, libwpg::WPGPaintInterface &rGenerator );
};
OUString WPGImportFilter_getImplementationName()
commit b7fa9950a9ef68bf2652b8c93887b6d531866471
Author: David Tardon <dtardon at redhat.com>
Date: Thu Apr 24 14:02:23 2014 +0200
change libwriterperfect to shared library
There are already 3 libs linking with it and there will be another one
in near future. It is time to stop the duplication :-)
Change-Id: Ia7d24882c37a8bf49fa031b73fa1bd5296f78820
diff --git a/Repository.mk b/Repository.mk
index d009288..589d49a 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -362,6 +362,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
$(if $(ENABLE_KDE4),vclplug_kde4) \
$(if $(ENABLE_HEADLESS),,vclplug_svp) \
) \
+ writerperfect \
xmlscript \
xmlfa \
xmlfd \
diff --git a/writerperfect/source/common/DirectoryStream.hxx b/include/writerperfect/DirectoryStream.hxx
similarity index 81%
rename from writerperfect/source/common/DirectoryStream.hxx
rename to include/writerperfect/DirectoryStream.hxx
index ab10bbf..7c8e9b0 100644
--- a/writerperfect/source/common/DirectoryStream.hxx
+++ b/include/writerperfect/DirectoryStream.hxx
@@ -7,13 +7,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef DIRECTORYSTREAM_H_INCLUDED
-#define DIRECTORYSTREAM_H_INCLUDED
+#ifndef INCLUDED_WRITERPERFECT_DIRECTORYSTREAM_HXX
+#define INCLUDED_WRITERPERFECT_DIRECTORYSTREAM_HXX
#include <libwpd-stream/libwpd-stream.h>
#include <com/sun/star/uno/Reference.h>
+#include <writerperfect/writerperfectdllapi.h>
+
namespace com { namespace sun { namespace star { namespace ucb {
class XContent;
} } } }
@@ -21,7 +23,7 @@ namespace com { namespace sun { namespace star { namespace ucb {
namespace writerperfect
{
-class DirectoryStream : public WPXInputStream
+class WRITERPERFECT_DLLPUBLIC DirectoryStream : public WPXInputStream
{
struct Impl;
@@ -43,6 +45,6 @@ private:
}
-#endif // DIRECTORYSTREAM_H_INCLUDED
+#endif // INCLUDED_WRITERPERFECT_DIRECTORYSTREAM_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/DocumentHandler.hxx b/include/writerperfect/DocumentHandler.hxx
similarity index 66%
rename from writerperfect/source/common/DocumentHandler.hxx
rename to include/writerperfect/DocumentHandler.hxx
index dad1e0f..db18e35 100644
--- a/writerperfect/source/common/DocumentHandler.hxx
+++ b/include/writerperfect/DocumentHandler.hxx
@@ -17,22 +17,28 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _DOCUMENTHANDLER_HXX_
-#define _DOCUMENTHANDLER_HXX_
+#ifndef INCLUDED_WRITERPERFECT_DOCUMENTHANDLER_HXX
+#define INCLUDED_WRITERPERFECT_DOCUMENTHANDLER_HXX
-#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <libodfgen/libodfgen.hxx>
#include <libwpd/libwpd.h>
-#include <libodfgen/libodfgen.hxx>
+#include <com/sun/star/uno/Reference.h>
+
+#include <writerperfect/writerperfectdllapi.h>
-using com::sun::star::uno::Reference;
-using com::sun::star::xml::sax::XDocumentHandler;
+namespace com { namespace sun { namespace star { namespace xml { namespace sax {
+ class XDocumentHandler;
+} } } } }
-class DocumentHandler: public OdfDocumentHandler
+namespace writerperfect
+{
+
+class WRITERPERFECT_DLLPUBLIC DocumentHandler: public OdfDocumentHandler
{
public:
- DocumentHandler(Reference < XDocumentHandler > &xHandler);
+ DocumentHandler(com::sun::star::uno::Reference < com::sun::star::xml::sax::XDocumentHandler > &xHandler);
void startDocument() SAL_OVERRIDE;
void endDocument() SAL_OVERRIDE;
void startElement(const char *psName, const WPXPropertyList &xPropList) SAL_OVERRIDE;
@@ -40,9 +46,11 @@ public:
void characters(const WPXString &sCharacters) SAL_OVERRIDE;
private:
- Reference < XDocumentHandler > mxHandler;
+ com::sun::star::uno::Reference < com::sun::star::xml::sax::XDocumentHandler > mxHandler;
};
-#endif // _DOCUMENTHANDLER_HXX_
+}
+
+#endif // INCLUDED_WRITERPERFECT_DOCUMENTHANDLER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/WPXSvStream.hxx b/include/writerperfect/WPXSvInputStream.hxx
similarity index 69%
rename from writerperfect/source/common/WPXSvStream.hxx
rename to include/writerperfect/WPXSvInputStream.hxx
index 337bf16..379e061 100644
--- a/writerperfect/source/common/WPXSvStream.hxx
+++ b/include/writerperfect/WPXSvInputStream.hxx
@@ -7,22 +7,29 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#ifndef WPXSVSTREAM_H
-#define WPXSVSTREAM_H
-
-#include <sot/storage.hxx>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
+#ifndef INCLUDED_WRITERPERFECT_WPXSVINPUTSTREAM_HXX
+#define INCLUDED_WRITERPERFECT_WPXSVSINPUTTREAM_HXX
#include <libwpd-stream/libwpd-stream.h>
+#include <com/sun/star/uno/Reference.h>
+
+#include <writerperfect/writerperfectdllapi.h>
+
+namespace com { namespace sun { namespace star { namespace io {
+ class XInputStream;
+ class XSeekable;
+} } } }
+
+namespace writerperfect
+{
+
class WPXSvInputStreamImpl;
-class WPXSvInputStream : public WPXInputStream
+class WRITERPERFECT_DLLPUBLIC WPXSvInputStream : public WPXInputStream
{
public:
- WPXSvInputStream( ::com::sun::star::uno::Reference<
- ::com::sun::star::io::XInputStream > xStream );
+ WPXSvInputStream( ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xStream );
virtual ~WPXSvInputStream();
virtual bool isStructured();
@@ -45,6 +52,8 @@ private:
WPXSvInputStreamImpl *mpImpl;
};
-#endif
+}
+
+#endif // INCLUDED_WRITERPERFECT_WPXSVINPUTSTREAM_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/writerperfect/writerperfectdllapi.h b/include/writerperfect/writerperfectdllapi.h
new file mode 100644
index 0000000..d549571
--- /dev/null
+++ b/include/writerperfect/writerperfectdllapi.h
@@ -0,0 +1,23 @@
+/* -*- 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_WRITERPERFECT_WRITERPERFECTDLLAPI_H
+#define INCLUDED_WRITERPERFECT_WRITERPERFECTDLLAPI_H
+
+#if defined WRITERPERFECT_DLLIMPLEMENTATION
+
+#define WRITERPERFECT_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define WRITERPERFECT_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+#define WRITERPERFECT_DLLPRIVATE SAL_DLLPRIVATE
+
+#endif /* INCLUDED_WRITERPERFECT_WRITERPERFECTDLLAPI_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/CppunitTest_writerperfect_stream.mk b/writerperfect/CppunitTest_writerperfect_stream.mk
index b469658..141b415 100644
--- a/writerperfect/CppunitTest_writerperfect_stream.mk
+++ b/writerperfect/CppunitTest_writerperfect_stream.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_CppunitTest_use_libraries,writerperfect_stream,\
tl \
unotest \
utl \
+ writerperfect \
))
$(eval $(call gb_CppunitTest_use_static_libraries,writerperfect_stream,\
diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk
index 8b1a611..faf805d 100644
--- a/writerperfect/Library_wpftdraw.mk
+++ b/writerperfect/Library_wpftdraw.mk
@@ -21,11 +21,6 @@ $(eval $(call gb_Library_Library,wpftdraw))
$(eval $(call gb_Library_set_componentfile,wpftdraw,writerperfect/source/draw/wpftdraw))
-$(eval $(call gb_Library_set_include,wpftdraw,\
- $$(INCLUDE) \
- -I$(SRCDIR)/writerperfect/source \
-))
-
$(eval $(call gb_Library_use_sdk_api,wpftdraw))
$(eval $(call gb_Library_use_libraries,wpftdraw,\
@@ -36,14 +31,11 @@ $(eval $(call gb_Library_use_libraries,wpftdraw,\
sot \
tl \
utl \
+ writerperfect \
xo \
$(gb_UWINAPI) \
))
-$(eval $(call gb_Library_use_static_libraries,wpftdraw,\
- writerperfect \
-))
-
$(eval $(call gb_Library_use_externals,wpftdraw,\
cdr \
etonyek \
diff --git a/writerperfect/Library_wpftimpress.mk b/writerperfect/Library_wpftimpress.mk
index f8a8a15..db7218c 100644
--- a/writerperfect/Library_wpftimpress.mk
+++ b/writerperfect/Library_wpftimpress.mk
@@ -21,11 +21,6 @@ $(eval $(call gb_Library_Library,wpftimpress))
$(eval $(call gb_Library_set_componentfile,wpftimpress,writerperfect/source/impress/wpftimpress))
-$(eval $(call gb_Library_set_include,wpftimpress,\
- $$(INCLUDE) \
- -I$(SRCDIR)/writerperfect/source \
-))
-
$(eval $(call gb_Library_use_sdk_api,wpftimpress))
$(eval $(call gb_Library_use_libraries,wpftimpress,\
@@ -37,14 +32,11 @@ $(eval $(call gb_Library_use_libraries,wpftimpress,\
tl \
ucbhelper \
utl \
+ writerperfect \
xo \
$(gb_UWINAPI) \
))
-$(eval $(call gb_Library_use_static_libraries,wpftimpress,\
- writerperfect \
-))
-
$(eval $(call gb_Library_use_externals,wpftimpress,\
boost_headers \
etonyek \
diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk
index fab462b..f6f8d3f 100644
--- a/writerperfect/Library_wpftwriter.mk
+++ b/writerperfect/Library_wpftwriter.mk
@@ -21,11 +21,6 @@ $(eval $(call gb_Library_Library,wpftwriter))
$(eval $(call gb_Library_set_componentfile,wpftwriter,writerperfect/source/writer/wpftwriter))
-$(eval $(call gb_Library_set_include,wpftwriter,\
- $$(INCLUDE) \
- -I$(SRCDIR)/writerperfect/source \
-))
-
$(eval $(call gb_Library_use_sdk_api,wpftwriter))
$(eval $(call gb_Library_use_libraries,wpftwriter,\
@@ -39,14 +34,11 @@ $(eval $(call gb_Library_use_libraries,wpftwriter,\
tl \
ucbhelper \
utl \
+ writerperfect \
xo \
$(gb_UWINAPI) \
))
-$(eval $(call gb_Library_use_static_libraries,wpftwriter,\
- writerperfect \
-))
-
$(eval $(call gb_Library_use_externals,wpftwriter,\
abw \
boost_headers \
diff --git a/writerperfect/StaticLibrary_writerperfect.mk b/writerperfect/Library_writerperfect.mk
similarity index 68%
rename from writerperfect/StaticLibrary_writerperfect.mk
rename to writerperfect/Library_writerperfect.mk
index 6b21c02..072b483 100644
--- a/writerperfect/StaticLibrary_writerperfect.mk
+++ b/writerperfect/Library_writerperfect.mk
@@ -17,14 +17,13 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-$(eval $(call gb_StaticLibrary_StaticLibrary,writerperfect))
+$(eval $(call gb_Library_Library,writerperfect))
-$(eval $(call gb_StaticLibrary_set_include,writerperfect,\
- $$(INCLUDE) \
- -I$(SRCDIR)/writerperfect/source \
+$(eval $(call gb_Library_add_defs,writerperfect,\
+ -DWRITERPERFECT_DLLIMPLEMENTATION \
))
-$(eval $(call gb_StaticLibrary_use_externals,writerperfect,\
+$(eval $(call gb_Library_use_externals,writerperfect,\
boost_headers \
etonyek \
odfgen \
@@ -32,15 +31,24 @@ $(eval $(call gb_StaticLibrary_use_externals,writerperfect,\
wpg \
))
-$(eval $(call gb_StaticLibrary_use_api,writerperfect,\
- offapi \
- udkapi \
+$(eval $(call gb_Library_use_sdk_api,writerperfect))
+
+$(eval $(call gb_Library_use_libraries,writerperfect,\
+ comphelper \
+ cppu \
+ sal \
+ sot \
+ tl \
+ ucbhelper \
+ utl \
+ xo \
+ $(gb_UWINAPI) \
))
-$(eval $(call gb_StaticLibrary_add_exception_objects,writerperfect,\
+$(eval $(call gb_Library_add_exception_objects,writerperfect,\
writerperfect/source/common/DirectoryStream \
writerperfect/source/common/DocumentHandler \
- writerperfect/source/common/WPXSvStream \
+ writerperfect/source/common/WPXSvInputStream \
))
# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 423329d..24decb4 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -23,7 +23,7 @@ $(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftdraw \
Library_wpftimpress \
Library_wpftwriter \
- StaticLibrary_writerperfect \
+ Library_writerperfect \
))
$(eval $(call gb_Module_add_check_targets,writerperfect,\
diff --git a/writerperfect/qa/unit/WPXSvStreamTest.cxx b/writerperfect/qa/unit/WPXSvStreamTest.cxx
index 3452bf6..1d28ec8 100644
--- a/writerperfect/qa/unit/WPXSvStreamTest.cxx
+++ b/writerperfect/qa/unit/WPXSvStreamTest.cxx
@@ -26,7 +26,7 @@
#include "test/bootstrapfixture.hxx"
-#include "WPXSvStream.hxx"
+#include <writerperfect/WPXSvInputStream.hxx>
namespace io = com::sun::star::io;
namespace ucb = com::sun::star::ucb;
@@ -36,6 +36,8 @@ using boost::shared_ptr;
using std::equal;
+using writerperfect::WPXSvInputStream;
+
namespace
{
diff --git a/writerperfect/source/common/DirectoryStream.cxx b/writerperfect/source/common/DirectoryStream.cxx
index 90aeb59..c125694 100644
--- a/writerperfect/source/common/DirectoryStream.cxx
+++ b/writerperfect/source/common/DirectoryStream.cxx
@@ -35,8 +35,8 @@
#include <ucbhelper/content.hxx>
-#include "DirectoryStream.hxx"
-#include "WPXSvStream.hxx"
+#include <writerperfect/DirectoryStream.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
namespace io = com::sun::star::io;
namespace sdbc = com::sun::star::sdbc;
diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx
index 073b942..239f20e 100644
--- a/writerperfect/source/common/DocumentHandler.cxx
+++ b/writerperfect/source/common/DocumentHandler.cxx
@@ -6,15 +6,23 @@
*
* For further information visit http://libwpd.sourceforge.net
*/
-#include "DocumentHandler.hxx"
+
+#include <writerperfect/DocumentHandler.hxx>
#include <string.h>
+
+#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <xmloff/attrlist.hxx>
+namespace writerperfect
+{
+
+using com::sun::star::uno::Reference;
using com::sun::star::xml::sax::XAttributeList;
+using com::sun::star::xml::sax::XDocumentHandler;
DocumentHandler::DocumentHandler(Reference < XDocumentHandler > &xHandler) :
mxHandler(xHandler)
@@ -63,4 +71,6 @@ void DocumentHandler::characters(const WPXString &sCharacters)
mxHandler->characters(sCharU16);
}
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/common/WPXSvStream.cxx b/writerperfect/source/common/WPXSvInputStream.cxx
similarity index 99%
rename from writerperfect/source/common/WPXSvStream.cxx
rename to writerperfect/source/common/WPXSvInputStream.cxx
index 818830d..b2ad2a8 100644
--- a/writerperfect/source/common/WPXSvStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -7,7 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include "WPXSvStream.hxx"
+#include <writerperfect/WPXSvInputStream.hxx>
#include <com/sun/star/packages/zip/XZipFileAccess2.hpp>
#include <com/sun/star/uno/Any.hxx>
@@ -16,6 +16,9 @@
#include <comphelper/seekableinput.hxx>
#include <rtl/string.hxx>
+
+#include <sot/storage.hxx>
+
#include <tools/stream.hxx>
#include <unotools/streamwrap.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -27,6 +30,9 @@
#include <boost/scoped_ptr.hpp>
#include <boost/unordered_map.hpp>
+namespace writerperfect
+{
+
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::io;
@@ -950,4 +956,6 @@ WPXInputStream *WPXSvInputStream::getDocumentOLEStream(const char *name)
return getSubStreamByName(name);
}
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/CDRImportFilter.cxx b/writerperfect/source/draw/CDRImportFilter.cxx
index 0b57b70..2464860 100644
--- a/writerperfect/source/draw/CDRImportFilter.cxx
+++ b/writerperfect/source/draw/CDRImportFilter.cxx
@@ -23,13 +23,14 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <libcdr/libcdr.h>
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "CDRImportFilter.hxx"
#include <iostream>
@@ -53,6 +54,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL CDRImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException, std::exception)
diff --git a/writerperfect/source/draw/CMXImportFilter.cxx b/writerperfect/source/draw/CMXImportFilter.cxx
index 2949ce1..fe94432 100644
--- a/writerperfect/source/draw/CMXImportFilter.cxx
+++ b/writerperfect/source/draw/CMXImportFilter.cxx
@@ -23,13 +23,14 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <libcdr/libcdr.h>
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "CMXImportFilter.hxx"
#include <iostream>
@@ -53,6 +54,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL CMXImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException, std::exception)
diff --git a/writerperfect/source/draw/FreehandImportFilter.cxx b/writerperfect/source/draw/FreehandImportFilter.cxx
index 0052072..b73aa4a 100644
--- a/writerperfect/source/draw/FreehandImportFilter.cxx
+++ b/writerperfect/source/draw/FreehandImportFilter.cxx
@@ -19,13 +19,14 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <libfreehand/libfreehand.h>
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "FreehandImportFilter.hxx"
#include <iostream>
@@ -49,6 +50,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL FreehandImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException, std::exception)
diff --git a/writerperfect/source/draw/MSPUBImportFilter.cxx b/writerperfect/source/draw/MSPUBImportFilter.cxx
index 85b33c3..b7537b0 100644
--- a/writerperfect/source/draw/MSPUBImportFilter.cxx
+++ b/writerperfect/source/draw/MSPUBImportFilter.cxx
@@ -19,13 +19,14 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <libmspub/libmspub.h>
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "MSPUBImportFilter.hxx"
#include <iostream>
@@ -49,6 +50,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL MSPUBImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException, std::exception)
diff --git a/writerperfect/source/draw/VisioImportFilter.cxx b/writerperfect/source/draw/VisioImportFilter.cxx
index fb7d2e0..7d38821 100644
--- a/writerperfect/source/draw/VisioImportFilter.cxx
+++ b/writerperfect/source/draw/VisioImportFilter.cxx
@@ -19,13 +19,14 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <libvisio/libvisio.h>
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "VisioImportFilter.hxx"
#include <iostream>
@@ -49,6 +50,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL VisioImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException, std::exception)
diff --git a/writerperfect/source/draw/WPGImportFilter.cxx b/writerperfect/source/draw/WPGImportFilter.cxx
index fa1461e..b5b3d7f 100644
--- a/writerperfect/source/draw/WPGImportFilter.cxx
+++ b/writerperfect/source/draw/WPGImportFilter.cxx
@@ -25,12 +25,13 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "WPGImportFilter.hxx"
#include <iostream>
@@ -55,6 +56,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL WPGImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException, std::exception)
diff --git a/writerperfect/source/impress/KeynoteImportFilter.cxx b/writerperfect/source/impress/KeynoteImportFilter.cxx
index 6eab1fd..b1019b2 100644
--- a/writerperfect/source/impress/KeynoteImportFilter.cxx
+++ b/writerperfect/source/impress/KeynoteImportFilter.cxx
@@ -28,11 +28,13 @@
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <ucbhelper/content.hxx>
+
+#include <writerperfect/DirectoryStream.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
-#include "common/DirectoryStream.hxx"
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "KeynoteImportFilter.hxx"
using boost::shared_ptr;
@@ -56,6 +58,9 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
+
namespace beans = com::sun::star::beans;
namespace container = com::sun::star::container;
namespace ucb = com::sun::star::ucb;
diff --git a/writerperfect/source/writer/AbiWordImportFilter.cxx b/writerperfect/source/writer/AbiWordImportFilter.cxx
index 6c10871..04048e2 100644
--- a/writerperfect/source/writer/AbiWordImportFilter.cxx
+++ b/writerperfect/source/writer/AbiWordImportFilter.cxx
@@ -21,6 +21,9 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <ucbhelper/content.hxx>
@@ -28,8 +31,6 @@
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "AbiWordImportFilter.hxx"
#include <iostream>
@@ -54,6 +55,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL AbiWordImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException)
diff --git a/writerperfect/source/writer/EBookImportFilter.cxx b/writerperfect/source/writer/EBookImportFilter.cxx
index 9110c67..f566be5 100644
--- a/writerperfect/source/writer/EBookImportFilter.cxx
+++ b/writerperfect/source/writer/EBookImportFilter.cxx
@@ -21,6 +21,9 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <ucbhelper/content.hxx>
@@ -28,8 +31,6 @@
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "EBookImportFilter.hxx"
#include <iostream>
@@ -54,6 +55,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL EBookImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException)
diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx
index e22fc1d..0a43e64 100644
--- a/writerperfect/source/writer/MSWorksImportFilter.cxx
+++ b/writerperfect/source/writer/MSWorksImportFilter.cxx
@@ -21,6 +21,9 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <ucbhelper/content.hxx>
@@ -28,8 +31,6 @@
#include <libodfgen/libodfgen.hxx>
-#include "common/DocumentHandler.hxx"
-#include "common/WPXSvStream.hxx"
#include "MSWorksImportFilter.hxx"
#include <iostream>
@@ -54,6 +55,8 @@ using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
+using writerperfect::DocumentHandler;
+using writerperfect::WPXSvInputStream;
sal_Bool SAL_CALL MSWorksImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException)
diff --git a/writerperfect/source/writer/MWAWImportFilter.cxx b/writerperfect/source/writer/MWAWImportFilter.cxx
index 82d2e26..b5a4a71 100644
--- a/writerperfect/source/writer/MWAWImportFilter.cxx
+++ b/writerperfect/source/writer/MWAWImportFilter.cxx
@@ -18,14 +18,15 @@
#include <com/sun/star/uno/Reference.h>
#include <cppuhelper/supportsservice.hxx>
+#include <writerperfect/DocumentHandler.hxx>
+#include <writerperfect/WPXSvInputStream.hxx>
+
#include <xmloff/attrlist.hxx>
#include <ucbhelper/content.hxx>
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list