[Libreoffice-commits] core.git: filter/Configuration_filter.mk filter/source writerperfect/Library_wpftdraw.mk writerperfect/Module_writerperfect.mk writerperfect/source writerperfect/util
Fridrich Å trba
fridrich.strba at bluewin.ch
Thu Oct 31 13:51:32 CET 2013
filter/Configuration_filter.mk | 2
filter/source/config/fragments/filters/FreehandDocument.xcu | 13
filter/source/config/fragments/types/draw_Freehand_Document.xcu | 12
writerperfect/Library_wpftdraw.mk | 2
writerperfect/Module_writerperfect.mk | 2
writerperfect/source/draw/FreehandImportFilter.cxx | 212 ++++++++++
writerperfect/source/draw/FreehandImportFilter.hxx | 86 ++++
writerperfect/source/draw/wpftdraw_genericfilter.cxx | 5
writerperfect/util/wpftdraw.component | 4
9 files changed, 338 insertions(+)
New commits:
commit 660800d6f33a01ad53fc0f5717e1c33868440d2f
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date: Thu Oct 31 13:23:30 2013 +0100
BIPU Freehand importer
Change-Id: I5b233343269b4107bbcfef5ea1c9b1fc7b735ed2
Reviewed-on: https://gerrit.libreoffice.org/6511
Reviewed-by: Fridrich Strba <fridrich at documentfoundation.org>
Tested-by: Fridrich Strba <fridrich at documentfoundation.org>
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index 62f21b6..269866b 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -556,6 +556,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_draw_types.xcu,filter/s
draw_Publisher_Document \
draw_CorelDraw_Document \
draw_Corel_Presentation_Exchange \
+ draw_Freehand_Document \
)
$(call filter_Configuration_add_filters,fcfg_langpack,fcfg_draw_filters.xcu,filter/source/config/fragments/filters,\
@@ -569,6 +570,7 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_draw_filters.xcu,filt
PublisherDocument \
CorelDrawDocument \
CorelPresentationExchange \
+ FreehandDocument \
)
$(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fragments/filters,\
diff --git a/filter/source/config/fragments/filters/FreehandDocument.xcu b/filter/source/config/fragments/filters/FreehandDocument.xcu
new file mode 100644
index 0000000..12bfd5f
--- /dev/null
+++ b/filter/source/config/fragments/filters/FreehandDocument.xcu
@@ -0,0 +1,13 @@
+ <node oor:name="Freehand Document" oor:op="replace">
+ <prop oor:name="Flags"><value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Draw.FreehandImportFilter</value></prop>
+ <prop oor:name="UserData"><value></value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="x-default">Adobe/Macromedia Freehand</value>
+ </prop>
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>draw_Freehand_Document</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
+ </node>
diff --git a/filter/source/config/fragments/types/draw_Freehand_Document.xcu b/filter/source/config/fragments/types/draw_Freehand_Document.xcu
new file mode 100644
index 0000000..1cc887e
--- /dev/null
+++ b/filter/source/config/fragments/types/draw_Freehand_Document.xcu
@@ -0,0 +1,12 @@
+ <node oor:name="draw_Freehand_Document" oor:op="replace" >
+ <prop oor:name="DetectService"><value>com.sun.star.comp.Draw.FreehandImportFilter</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>fh fh1 fh2 fh3 fh4 fh5 fh6 fh7 fh8 fh9 fh10 fh11</value></prop>
+ <prop oor:name="MediaType"><value>application/x-freehand</value></prop>
+ <prop oor:name="Preferred"><value>true</value></prop>
+ <prop oor:name="PreferredFilter"><value>Freehand Document</value></prop>
+ <prop oor:name="UIName">
+ <value>Adobe/Macromedia Freehand</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"/>
+ </node>
diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk
index 5be55c8..84bb959 100644
--- a/writerperfect/Library_wpftdraw.mk
+++ b/writerperfect/Library_wpftdraw.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_Library_use_static_libraries,wpftdraw,\
$(eval $(call gb_Library_use_externals,wpftdraw,\
cdr \
etonyek \
+ freehand \
mspub \
odfgen \
visio \
@@ -63,6 +64,7 @@ $(eval $(call gb_Library_use_externals,wpftdraw,\
$(eval $(call gb_Library_add_exception_objects,wpftdraw,\
writerperfect/source/draw/CDRImportFilter \
writerperfect/source/draw/CMXImportFilter \
+ writerperfect/source/draw/FreehandImportFilter \
writerperfect/source/draw/MSPUBImportFilter \
writerperfect/source/draw/VisioImportFilter \
writerperfect/source/draw/WPGImportFilter \
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 8f02300..06115f2 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -34,6 +34,7 @@ ifneq (,$(SYSTEM_WPG))
ifneq (,$(SYSTEM_VISIO))
ifneq (,$(SYSTEM_CDR))
ifneq (,$(SYSTEM_MSPUB))
+ifneq (,$(SYSTEM_FREEHAND))
ifneq (,$(SYSTEM_ODFGEN))
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftdraw \
@@ -44,6 +45,7 @@ endif
endif
endif
endif
+endif
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftimpress \
diff --git a/writerperfect/source/draw/FreehandImportFilter.cxx b/writerperfect/source/draw/FreehandImportFilter.cxx
new file mode 100644
index 0000000..733d936
--- /dev/null
+++ b/writerperfect/source/draw/FreehandImportFilter.cxx
@@ -0,0 +1,212 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* FreehandImportFilter: Sets up the filter, and calls OdgExporter
+ * to do the actual filtering
+ *
+ * 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 <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 <cppuhelper/supportsservice.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>
+
+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;
+
+
+sal_Bool SAL_CALL FreehandImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+throw (RuntimeException)
+{
+ 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( 0 );
+ 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);
+ bool tmpParseResult = libfreehand::FreeHandDocument::parse(&input, &exporter);
+ return tmpParseResult;
+}
+
+void SAL_CALL FreehandImportFilter::cancel( )
+throw (RuntimeException)
+{
+ 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)
+{
+ SAL_INFO("writerperfect", "FreehandImportFilter::setTargetDocument");
+ mxDoc = xDoc;
+}
+
+// XExtendedFilterDetection
+OUString SAL_CALL FreehandImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
+throw( com::sun::star::uno::RuntimeException )
+{
+ 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 ( 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 (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;
+}
+
+
+// XInitialization
+void SAL_CALL FreehandImportFilter::initialize( const Sequence< Any >& aArguments )
+throw (Exception, RuntimeException)
+{
+ 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)
+{
+ SAL_INFO("writerperfect", "FreehandImportFilter_getImplementationName");
+ return OUString ( "com.sun.star.comp.Draw.FreehandImportFilter" );
+}
+
+Sequence< OUString > SAL_CALL FreehandImportFilter_getSupportedServiceNames( )
+throw (RuntimeException)
+{
+ SAL_INFO("writerperfect", "FreehandImportFilter_getSupportedServiceNames");
+ Sequence < OUString > aRet(2);
+ OUString *pArray = aRet.getArray();
+ pArray[0] = OUString ( "com.sun.star.document.ImportFilter" );
+ pArray[1] = OUString ( "com.sun.star.document.ExtendedTypeDetection" );
+ return aRet;
+}
+
+Reference< XInterface > SAL_CALL FreehandImportFilter_createInstance( const Reference< XComponentContext > & rContext)
+throw( Exception )
+{
+ SAL_INFO("writerperfect", "FreehandImportFilter_createInstance");
+ return (cppu::OWeakObject *) new FreehandImportFilter( rContext );
+}
+
+// XServiceInfo
+OUString SAL_CALL FreehandImportFilter::getImplementationName( )
+throw (RuntimeException)
+{
+ SAL_INFO("writerperfect", "FreehandImportFilter::getImplementationName");
+ return FreehandImportFilter_getImplementationName();
+}
+sal_Bool SAL_CALL FreehandImportFilter::supportsService( const OUString &rServiceName )
+throw (RuntimeException)
+{
+ SAL_INFO("writerperfect", "FreehandImportFilter::supportsService");
+ return cppu::supportsService( this, rServiceName );
+}
+Sequence< OUString > SAL_CALL FreehandImportFilter::getSupportedServiceNames( )
+throw (RuntimeException)
+{
+ SAL_INFO("writerperfect", "FreehandImportFilter::getSupportedServiceNames");
+ return FreehandImportFilter_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/FreehandImportFilter.hxx b/writerperfect/source/draw/FreehandImportFilter.hxx
new file mode 100644
index 0000000..b88013c
--- /dev/null
+++ b/writerperfect/source/draw/FreehandImportFilter.hxx
@@ -0,0 +1,86 @@
+/* -*- 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 _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>
+
+/* 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
+ >
+{
+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);
+ virtual void SAL_CALL cancel( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // 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);
+
+ //XExtendedFilterDetection
+ virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // 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);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString &ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+OUString FreehandImportFilter_getImplementationName()
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< OUString > SAL_CALL FreehandImportFilter_getSupportedServiceNames( )
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL FreehandImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
+throw ( ::com::sun::star::uno::Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/draw/wpftdraw_genericfilter.cxx b/writerperfect/source/draw/wpftdraw_genericfilter.cxx
index f2a3247..43cabc1 100644
--- a/writerperfect/source/draw/wpftdraw_genericfilter.cxx
+++ b/writerperfect/source/draw/wpftdraw_genericfilter.cxx
@@ -32,6 +32,7 @@
#include "CDRImportFilter.hxx"
#include "CMXImportFilter.hxx"
#include "MSPUBImportFilter.hxx"
+#include "FreehandImportFilter.hxx"
#include "VisioImportFilter.hxx"
#include "WPGImportFilter.hxx"
@@ -44,6 +45,10 @@ static cppu::ImplementationEntry const services[] = {
{ &CMXImportFilter_createInstance, &CMXImportFilter_getImplementationName,
&CMXImportFilter_getSupportedServiceNames,
&cppu::createSingleComponentFactory, 0, 0 },
+ { &FreehandImportFilter_createInstance,
+ &FreehandImportFilter_getImplementationName,
+ &FreehandImportFilter_getSupportedServiceNames,
+ &cppu::createSingleComponentFactory, 0, 0 },
{ &MSPUBImportFilter_createInstance,
&MSPUBImportFilter_getImplementationName,
&MSPUBImportFilter_getSupportedServiceNames,
diff --git a/writerperfect/util/wpftdraw.component b/writerperfect/util/wpftdraw.component
index be4fd8d..ec82171 100644
--- a/writerperfect/util/wpftdraw.component
+++ b/writerperfect/util/wpftdraw.component
@@ -17,6 +17,10 @@
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>
</implementation>
+ <implementation name="com.sun.star.comp.Draw.FreehandImportFilter">
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
<implementation name="com.sun.star.comp.Draw.MSPUBImportFilter">
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>
More information about the Libreoffice-commits
mailing list