summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Repository.mk1
-rw-r--r--RepositoryExternal.mk27
-rw-r--r--configure.in22
-rw-r--r--filter/Configuration_filter.mk2
-rw-r--r--filter/source/config/fragments/filters/CorelDrawDocument.xcu13
-rw-r--r--filter/source/config/fragments/types/draw_CDR_Document.xcu12
-rw-r--r--libcdr/makefile.mk67
-rw-r--r--libcdr/prj/build.lst3
-rw-r--r--libcdr/prj/d.lst5
-rw-r--r--postprocess/packcomponents/makefile.mk1
-rw-r--r--scp2/source/graphicfilter/file_graphicfilter.scp2
-rwxr-xr-xset_soenv.in19
-rw-r--r--writerperfect/Library_cdrimport.mk68
-rw-r--r--writerperfect/Module_writerperfect.mk1
-rw-r--r--writerperfect/prj/build.lst2
-rw-r--r--writerperfect/source/cdrimp/CDRImportFilter.cxx280
-rw-r--r--writerperfect/source/cdrimp/CDRImportFilter.hxx117
-rw-r--r--writerperfect/source/cdrimp/cdrimport_genericfilter.cxx68
-rw-r--r--writerperfect/util/cdrfilter.component8
19 files changed, 709 insertions, 9 deletions
diff --git a/Repository.mk b/Repository.mk
index 3c2c93e8629a..f5cd0a48be6a 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -229,6 +229,7 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
vclplug_kde \
vclplug_kde4 \
vclplug_svp \
+ cdrimport \
visioimport \
wpft \
wpgimport \
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 6da9253ae1fe..3f407c432472 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -506,6 +506,33 @@ endef
endif # SYSTEM_OPENSSL
+ifeq ($(SYSTEM_LIBCDR),YES)
+
+define gb_LinkTarget__use_cdr
+$(call gb_LinkTarget_set_include,$(1),\
+ $$(INCLUDE) \
+ $(CDR_CFLAGS) \
+)
+$(call gb_LinkTarget_add_libs,$(1),$(CDR_LIBS))
+
+endef
+
+else # !SYSTEM_LIBCDR
+
+$(eval $(call gb_Helper_register_static_libraries,PLAINLIBS, \
+ cdrlib \
+))
+
+define gb_LinkTarget__use_cdr
+$(call gb_LinkTarget_add_linked_static_libs,$(1),\
+ cdrlib \
+)
+
+endef
+
+endif # SYSTEM_LIBCDR
+
+
ifeq ($(SYSTEM_LIBVISIO),YES)
define gb_LinkTarget__use_visio
diff --git a/configure.in b/configure.in
index 1c9a08d965fd..4cfeae07ee24 100644
--- a/configure.in
+++ b/configure.in
@@ -1033,6 +1033,11 @@ AC_ARG_WITH(system-libcmis,
[Use libcmis already on system.]),,
[with_system_libcmis="$with_system_libs"])
+AC_ARG_WITH(system-libcdr,
+ AS_HELP_STRING([--with-system-libcdr],
+ [Use libvisio already on system.]),,
+ [with_system_libcdr="no"])
+
AC_ARG_WITH(system-libvisio,
AS_HELP_STRING([--with-system-libvisio],
[Use libvisio already on system.]),,
@@ -4719,6 +4724,23 @@ fi
AC_SUBST(SYSTEM_EXPAT)
dnl ===================================================================
+dnl Check for system libcdr
+dnl ===================================================================
+AC_MSG_CHECKING([which libcdr to use])
+if test "$with_system_libcdr" = "yes"; then
+ AC_MSG_RESULT([external])
+ SYSTEM_LIBCDR=YES
+ PKG_CHECK_MODULES( CDR, libcdr-0.0 )
+else
+ AC_MSG_RESULT([internal])
+ SYSTEM_LIBCDR=NO
+ BUILD_TYPE="$BUILD_TYPE LIBCDR"
+fi
+AC_SUBST(SYSTEM_LIBCDR)
+AC_SUBST(CDR_CFLAGS)
+AC_SUBST(CDR_LIBS)
+
+dnl ===================================================================
dnl Check for system libvisio
dnl ===================================================================
AC_MSG_CHECKING([which libvisio to use])
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index c8e5593c34d4..ae2789a71e84 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -545,6 +545,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_draw_types.xcu,filter/s
draw8_template \
draw_WordPerfect_Graphics \
draw_Visio_Document \
+ draw_CDR_Document \
)
$(call filter_Configuration_add_filters,fcfg_langpack,fcfg_draw_filters.xcu,filter/source/config/fragments/filters,\
@@ -555,6 +556,7 @@ $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_draw_filters.xcu,filt
draw8_template \
WordPerfectGraphics \
VisioDocument \
+ CorelDrawDocument \
)
$(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fragments/filters,\
diff --git a/filter/source/config/fragments/filters/CorelDrawDocument.xcu b/filter/source/config/fragments/filters/CorelDrawDocument.xcu
new file mode 100644
index 000000000000..7de8ac1af7c2
--- /dev/null
+++ b/filter/source/config/fragments/filters/CorelDrawDocument.xcu
@@ -0,0 +1,13 @@
+ <node oor:name="Corel Draw 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.CDRImportFilter</value></prop>
+ <prop oor:name="UserData"><value></value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="x-default">Corel Draw</value>
+ </prop>
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>draw_CDR_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_CDR_Document.xcu b/filter/source/config/fragments/types/draw_CDR_Document.xcu
new file mode 100644
index 000000000000..5b07b6200db9
--- /dev/null
+++ b/filter/source/config/fragments/types/draw_CDR_Document.xcu
@@ -0,0 +1,12 @@
+ <node oor:name="draw_CDR_Document" oor:op="replace" >
+ <prop oor:name="DetectService"><value>com.sun.star.comp.Draw.CDRImportFilter</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>cdr</value></prop>
+ <prop oor:name="MediaType"><value>application/vnd.corel-draw</value></prop>
+ <prop oor:name="Preferred"><value>true</value></prop>
+ <prop oor:name="PreferredFilter"><value>Corel Draw Document</value></prop>
+ <prop oor:name="UIName">
+ <value>Corel Draw</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"/>
+ </node>
diff --git a/libcdr/makefile.mk b/libcdr/makefile.mk
new file mode 100644
index 000000000000..ce9e91d6bdb1
--- /dev/null
+++ b/libcdr/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=.
+
+PRJNAME=visio
+TARGET=visio
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(SYSTEM_LIBCDR)" == "YES"
+@all:
+ @echo "Using system libcdr..."
+.ENDIF
+
+# libcdr depends on the libwpd and libwpg
+.IF "$(SYSTEM_LIBWPD)" == "YES"
+INCPRE+=$(WPD_CFLAGS)
+.ELSE
+INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpd
+INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpd-stream
+.ENDIF
+.IF "$(SYSTEM_LIBWPG)" == "YES"
+INCPRE+=$(WPG_CFLAGS)
+.ELSE
+INCPRE+=$(SOLARVER)$/$(UPD)$/$(INPATH)$/inc$/libwpg
+.ENDIF
+
+TARFILE_NAME=libcdr-0.0.0
+TARFILE_MD5=9c9811817dccbd517ff25af8b2e8a86e
+
+BUILD_ACTION=dmake $(MFLAGS) $(CALLMACROS)
+BUILD_DIR=src$/lib
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_ext.mk
+.INCLUDE : target.mk
+.INCLUDE : tg_ext.mk
diff --git a/libcdr/prj/build.lst b/libcdr/prj/build.lst
new file mode 100644
index 000000000000..30bd3e4ffa9a
--- /dev/null
+++ b/libcdr/prj/build.lst
@@ -0,0 +1,3 @@
+cdr libcdr : LIBWPD:libwpd LIBWPG:libwpg soltools NULL
+cdr libcdr usr1 - all cdr_mkout NULL
+cdr libcdr nmake - all cdr_libcdr NULL
diff --git a/libcdr/prj/d.lst b/libcdr/prj/d.lst
new file mode 100644
index 000000000000..86806ba40287
--- /dev/null
+++ b/libcdr/prj/d.lst
@@ -0,0 +1,5 @@
+mkdir: %_DEST%\inc\libcdr
+..\%__SRC%\misc\build\libcdr*\src\lib\libcdr.h %_DEST%\inc\libcdr
+..\%__SRC%\misc\build\libcdr*\src\lib\CDRDocument.h %_DEST%\inc\libcdr\
+..\%__SRC%\lib\*.a %_DEST%\lib\*.a
+..\%__SRC%\slb\*.lib %_DEST%\lib\*.lib
diff --git a/postprocess/packcomponents/makefile.mk b/postprocess/packcomponents/makefile.mk
index 02d871be6f81..c1ec972a52f4 100644
--- a/postprocess/packcomponents/makefile.mk
+++ b/postprocess/packcomponents/makefile.mk
@@ -131,6 +131,7 @@ my_components = \
component/writerperfect/util/visiofilter \
component/writerperfect/util/wpft \
component/writerperfect/util/wpgfilter \
+ component/writerperfect/util/cdrfilter \
component/xmloff/source/transform/xof \
component/xmloff/util/xo \
component/xmlscript/util/xcr \
diff --git a/scp2/source/graphicfilter/file_graphicfilter.scp b/scp2/source/graphicfilter/file_graphicfilter.scp
index a968866bade8..17761ded9054 100644
--- a/scp2/source/graphicfilter/file_graphicfilter.scp
+++ b/scp2/source/graphicfilter/file_graphicfilter.scp
@@ -41,3 +41,5 @@ STD_LIB_FILE( gid_File_Lib_Svg, svgfilter )
STD_FILTER_FILE( gid_File_Lib_WPGImport, wpgimport )
STD_FILTER_FILE( gid_File_Lib_VisioImport, visioimport )
+
+STD_FILTER_FILE( gid_File_Lib_CDRImport, cdrimport )
diff --git a/set_soenv.in b/set_soenv.in
index d97560d59f2e..bef940502c13 100755
--- a/set_soenv.in
+++ b/set_soenv.in
@@ -1907,17 +1907,20 @@ ToFile( "XRANDR_DLOPEN", "@XRANDR_DLOPEN@", "e" );
ToFile( "LIBPNG_CFLAGS", "@LIBPNG_CFLAGS@", "e" );
ToFile( "LIBPNG_LIBS", "@LIBPNG_LIBS@", "e" );
ToFile( "SYSTEM_LIBWPD", "@SYSTEM_LIBWPD@", "e" );
-ToFile( "WPD_CFLAGS", "@WPD_CFLAGS@", "e" );
-ToFile( "WPD_LIBS", "@WPD_LIBS@", "e" );
+ToFile( "WPD_CFLAGS", "@WPD_CFLAGS@", "e" );
+ToFile( "WPD_LIBS", "@WPD_LIBS@", "e" );
ToFile( "SYSTEM_LIBWPS", "@SYSTEM_LIBWPS@", "e" );
-ToFile( "WPS_CFLAGS", "@WPS_CFLAGS@", "e" );
-ToFile( "WPS_LIBS", "@WPS_LIBS@", "e" );
+ToFile( "WPS_CFLAGS", "@WPS_CFLAGS@", "e" );
+ToFile( "WPS_LIBS", "@WPS_LIBS@", "e" );
ToFile( "SYSTEM_LIBWPG", "@SYSTEM_LIBWPG@", "e" );
-ToFile( "WPG_CFLAGS", "@WPG_CFLAGS@", "e" );
-ToFile( "WPG_LIBS", "@WPG_LIBS@", "e" );
+ToFile( "WPG_CFLAGS", "@WPG_CFLAGS@", "e" );
+ToFile( "WPG_LIBS", "@WPG_LIBS@", "e" );
ToFile( "SYSTEM_LIBVISIO", "@SYSTEM_LIBVISIO@", "e" );
-ToFile( "VISIO_CFLAGS", "@VISIO_CFLAGS@", "e" );
-ToFile( "VISIO_LIBS", "@VISIO_LIBS@", "e" );
+ToFile( "VISIO_CFLAGS", "@VISIO_CFLAGS@", "e" );
+ToFile( "VISIO_LIBS", "@VISIO_LIBS@", "e" );
+ToFile( "SYSTEM_LIBCDR", "@SYSTEM_LIBCDR@", "e" );
+ToFile( "CDR_CFLAGS", "@CDR_CFLAGS@", "e" );
+ToFile( "CDR_LIBS", "@CDR_LIBS@", "e" );
ToFile( "SYSTEM_LIBCMIS", "@SYSTEM_LIBCMIS@", "e" );
ToFile( "LIBCMIS_CFLAGS", "@LIBCMIS_CFLAGS@", "e" );
ToFile( "LIBCMIS_LIBS", "@LIBCMIS_LIBS@", "e" );
diff --git a/writerperfect/Library_cdrimport.mk b/writerperfect/Library_cdrimport.mk
new file mode 100644
index 000000000000..90bcb2e6bac7
--- /dev/null
+++ b/writerperfect/Library_cdrimport.mk
@@ -0,0 +1,68 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2011 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+$(eval $(call gb_Library_Library,cdrimport))
+
+$(eval $(call gb_Library_set_componentfile,cdrimport,writerperfect/util/cdrfilter))
+
+$(eval $(call gb_Library_set_include,cdrimport,\
+ $$(INCLUDE) \
+ -I$(realpath $(SRCDIR)/writerperfect/source) \
+))
+
+$(eval $(call gb_Library_add_api,cdrimport,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_Library_add_linked_libs,cdrimport,\
+ cppu \
+ cppuhelper \
+ sal \
+ sot \
+ tl \
+ utl \
+ xo \
+))
+
+$(eval $(call gb_Library_add_linked_static_libs,cdrimport,\
+ writerperfect \
+))
+
+$(eval $(call gb_Library_use_externals,cdrimport,\
+ wpd \
+ wpg \
+ cdr \
+))
+
+$(eval $(call gb_Library_add_exception_objects,cdrimport,\
+ writerperfect/source/cdrimp/CDRImportFilter \
+ writerperfect/source/cdrimp/cdrimport_genericfilter \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk
index 9d0c77ad3f51..4b2faadbc854 100644
--- a/writerperfect/Module_writerperfect.mk
+++ b/writerperfect/Module_writerperfect.mk
@@ -29,6 +29,7 @@
$(eval $(call gb_Module_Module,writerperfect))
$(eval $(call gb_Module_add_targets,writerperfect,\
+ Library_cdrimport \
Library_msworks \
Library_visioimport \
Library_wpft \
diff --git a/writerperfect/prj/build.lst b/writerperfect/prj/build.lst
index 23f35dcc25cf..e680feaa8d32 100644
--- a/writerperfect/prj/build.lst
+++ b/writerperfect/prj/build.lst
@@ -1,3 +1,3 @@
-wp writerperfect : LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd LIBVISIO:libvisio sot comphelper xmloff svtools sfx2 LIBXSLT:libxslt NULL
+wp writerperfect : LIBWPG:libwpg LIBWPS:libwps LIBWPD:libwpd LIBVISIO:libvisio LIBCDR:libcdr sot comphelper xmloff svtools sfx2 LIBXSLT:libxslt NULL
wp writerperfect usr1 - all wp_mkout NULL
wp writerperfect\prj nmake - all wp_prj NULL
diff --git a/writerperfect/source/cdrimp/CDRImportFilter.cxx b/writerperfect/source/cdrimp/CDRImportFilter.cxx
new file mode 100644
index 000000000000..f5cce836d660
--- /dev/null
+++ b/writerperfect/source/cdrimp/CDRImportFilter.cxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* CDRImportFilter: Sets up the filter, and calls OdgExporter
+ * to do the actual filtering
+ *
+ * Copyright (C) 2000 by Sun Microsystems, Inc.
+ * Copyright (C) 2002-2004 William Lachance (wlach@interlog.com)
+ * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
+ * Copyright (C) 2004-2006 Fridrich Strba <fridrich.strba@bluewin.ch>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+
+#include <osl/diagnose.h>
+#include <rtl/tencinfo.h>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/uno/Reference.h>
+
+#include <xmloff/attrlist.hxx>
+
+#include <libcdr/libcdr.h>
+#include "filter/DocumentHandler.hxx"
+#include "filter/OdgGenerator.hxx"
+#include "CDRImportFilter.hxx"
+#include "stream/WPXSvStream.h"
+
+#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 rtl::OString;
+using rtl::OUString;
+using com::sun::star::uno::Sequence;
+using com::sun::star::uno::Reference;
+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::lang::XMultiServiceFactory;
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::document::XFilter;
+using com::sun::star::document::XExtendedFilterDetection;
+
+using com::sun::star::io::XInputStream;
+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 CDRImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::filter" << std::endl;
+#endif
+ sal_Int32 nLength = aDescriptor.getLength();
+ const PropertyValue *pValue = aDescriptor.getConstArray();
+ OUString sURL;
+ Reference < XInputStream > xInputStream;
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
+ pValue[i].Value >>= xInputStream;
+ else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "URL" ) ) )
+ pValue[i].Value >>= sURL;
+ }
+ if ( !xInputStream.is() )
+ {
+ OSL_ASSERT( 0 );
+ return sal_False;
+ }
+ OString sFileName;
+ sFileName = OUStringToOString(sURL, RTL_TEXTENCODING_INFO_ASCII);
+
+ // An XML import service: what we push sax messages to..
+ OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.XMLOasisImporter" ) );
+ Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
+
+ // 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 = libcdr::CDRDocument::parse(&input, &exporter);
+ return tmpParseResult;
+}
+
+void SAL_CALL CDRImportFilter::cancel( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::cancel" << std::endl;
+#endif
+}
+
+// XImporter
+void SAL_CALL CDRImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
+throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::setTargetDocument" << std::endl;
+#endif
+ meType = FILTER_IMPORT;
+ mxDoc = xDoc;
+}
+
+// XExtendedFilterDetection
+OUString SAL_CALL CDRImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
+throw( com::sun::star::uno::RuntimeException )
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::detect" << std::endl;
+#endif
+ 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.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "TypeName" ) ) )
+ location=i;
+ else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "InputStream" ) ) )
+ pValue[i].Value >>= xInputStream;
+ }
+
+ WPXSvInputStream input( xInputStream );
+
+ if (libcdr::CDRDocument::isSupported(&input))
+ sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_Visio_Document" ) );
+
+ if (sTypeName.getLength())
+ {
+ if ( location == Descriptor.getLength() )
+ {
+ Descriptor.realloc(nLength+1);
+ Descriptor[location].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeName"));
+ }
+
+ Descriptor[location].Value <<=sTypeName;
+ }
+ return sTypeName;
+}
+
+
+// XInitialization
+void SAL_CALL CDRImportFilter::initialize( const Sequence< Any >& aArguments )
+throw (Exception, RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::initialize" << std::endl;
+#endif
+ 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.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "Type" ) ) )
+ {
+ pValue[i].Value >>= msFilterName;
+ break;
+ }
+ }
+ }
+}
+OUString CDRImportFilter_getImplementationName ()
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter_getImplementationName" << std::endl;
+#endif
+ return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.CDRImportFilter" ) );
+}
+
+#define SERVICE_NAME1 "com.sun.star.document.ImportFilter"
+#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection"
+sal_Bool SAL_CALL CDRImportFilter_supportsService( const OUString &ServiceName )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter_supportsService" << std::endl;
+#endif
+ return (ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME1 ) ) ||
+ ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME2 ) ) );
+}
+Sequence< OUString > SAL_CALL CDRImportFilter_getSupportedServiceNames( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter_getSupportedServiceNames" << std::endl;
+#endif
+ Sequence < OUString > aRet(2);
+ OUString *pArray = aRet.getArray();
+ pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME1 ) );
+ pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME2 ) );
+ return aRet;
+}
+#undef SERVICE_NAME2
+#undef SERVICE_NAME1
+
+Reference< XInterface > SAL_CALL CDRImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+throw( Exception )
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter_createInstance" << std::endl;
+#endif
+ return (cppu::OWeakObject *) new CDRImportFilter( rSMgr );
+}
+
+// XServiceInfo
+OUString SAL_CALL CDRImportFilter::getImplementationName( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::getImplementationName" << std::endl;
+#endif
+ return CDRImportFilter_getImplementationName();
+}
+sal_Bool SAL_CALL CDRImportFilter::supportsService( const OUString &rServiceName )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::supportsService" << std::endl;
+#endif
+ return CDRImportFilter_supportsService( rServiceName );
+}
+Sequence< OUString > SAL_CALL CDRImportFilter::getSupportedServiceNames( )
+throw (RuntimeException)
+{
+#ifdef DEBUG
+ std::cerr << "CDRImportFilter::getSupportedServiceNames" << std::endl;
+#endif
+ return CDRImportFilter_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/cdrimp/CDRImportFilter.hxx b/writerperfect/source/cdrimp/CDRImportFilter.hxx
new file mode 100644
index 000000000000..8f52805d4138
--- /dev/null
+++ b/writerperfect/source/cdrimp/CDRImportFilter.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2000 by Sun Microsystems, Inc.
+ * Copyright (C) 2002-2004 William Lachance (wlach@interlog.com)
+ * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
+ * Copyright (C) 2004 Fridrich Strba <fridrich.strba@bluewin.ch>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Contributor(s): Martin Gallwey (gallwey@sun.com)
+ *
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+#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/xml/sax/XDocumentHandler.hpp>
+#include <cppuhelper/implbase5.hxx>
+
+#include <stdio.h>
+
+enum FilterType
+{
+ FILTER_IMPORT,
+ FILTER_EXPORT
+};
+/* 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
+ >
+{
+protected:
+ // oo.org declares
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
+ ::rtl::OUString msFilterName;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
+
+ FilterType meType;
+
+public:
+ CDRImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF ), meType((FilterType)0) {}
+ 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);
+ 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 ::rtl::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 ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString &ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+::rtl::OUString CDRImportFilter_getImplementationName()
+throw ( ::com::sun::star::uno::RuntimeException );
+
+sal_Bool SAL_CALL CDRImportFilter_supportsService( const ::rtl::OUString &ServiceName )
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL CDRImportFilter_getSupportedServiceNames( )
+throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL CDRImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+throw ( ::com::sun::star::uno::Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/source/cdrimp/cdrimport_genericfilter.cxx b/writerperfect/source/cdrimp/cdrimport_genericfilter.cxx
new file mode 100644
index 000000000000..dd13f38bbf0b
--- /dev/null
+++ b/writerperfect/source/cdrimp/cdrimport_genericfilter.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* genericfilter: mostly generic code for registering the filter
+ *
+ * Portions of this code Copyright 2000 by Sun Microsystems, Inc.
+ * Rest is Copyright (C) 2002 William Lachance (wlach@interlog.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+#include <stdio.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <cppuhelper/factory.hxx>
+
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+#include "CDRImportFilter.hxx"
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+extern "C"
+{
+ SAL_DLLPUBLIC_EXPORT void *SAL_CALL component_getFactory(
+ const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ )
+ {
+ void *pRet = 0;
+
+ OUString implName = OUString::createFromAscii( pImplName );
+ if ( pServiceManager && implName.equals(CDRImportFilter_getImplementationName()) )
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ CDRImportFilter_createInstance, CDRImportFilter_getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerperfect/util/cdrfilter.component b/writerperfect/util/cdrfilter.component
new file mode 100644
index 000000000000..44beeae07d01
--- /dev/null
+++ b/writerperfect/util/cdrfilter.component
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component loader="com.sun.star.loader.SharedLibrary"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.Draw.CDRImportFilter">
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExtendedTypeDetection"/>
+ </implementation>
+</component>