Kaydet (Commit) 660800d6 authored tarafından Fridrich Štrba's avatar Fridrich Štrba Kaydeden (comit) Fridrich Strba

BIPU Freehand importer

Change-Id: I5b233343269b4107bbcfef5ea1c9b1fc7b735ed2
Reviewed-on: https://gerrit.libreoffice.org/6511Reviewed-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
Tested-by: 's avatarFridrich Strba <fridrich@documentfoundation.org>
üst 67153d76
......@@ -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,\
......
<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>
<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>
......@@ -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 \
......
......@@ -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 \
......
/* -*- 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: */
/* -*- 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: */
......@@ -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,
......
......@@ -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"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment