From 9284c50f975ce91fcb50e3849bbe38af50dbcb6c Mon Sep 17 00:00:00 2001 From: Fridrich Štrba Date: Thu, 19 Apr 2012 14:33:09 +0200 Subject: Diminish the number of writerperfect libraries Instead of a pleiade of libraries, one for graphic filters (wpftdraw) and one for text document filters (wpftwriter) to diminish duplicate static linking. --- writerperfect/Library_cdrimport.mk | 72 ---- writerperfect/Library_msworks.mk | 69 --- writerperfect/Library_visioimport.mk | 69 --- writerperfect/Library_wpft.mk | 71 ---- writerperfect/Library_wpftdraw.mk | 75 ++++ writerperfect/Library_wpftwriter.mk | 73 ++++ writerperfect/Library_wpgimport.mk | 68 --- writerperfect/Module_writerperfect.mk | 26 +- writerperfect/source/cdrimp/CDRImportFilter.cxx | 276 ------------ writerperfect/source/cdrimp/CDRImportFilter.hxx | 110 ----- writerperfect/source/cdrimp/CMXImportFilter.cxx | 276 ------------ writerperfect/source/cdrimp/CMXImportFilter.hxx | 110 ----- .../source/cdrimp/cdrimport_genericfilter.cxx | 82 ---- writerperfect/source/draw/CDRImportFilter.cxx | 276 ++++++++++++ writerperfect/source/draw/CDRImportFilter.hxx | 110 +++++ writerperfect/source/draw/CMXImportFilter.cxx | 276 ++++++++++++ writerperfect/source/draw/CMXImportFilter.hxx | 110 +++++ writerperfect/source/draw/VisioImportFilter.cxx | 276 ++++++++++++ writerperfect/source/draw/VisioImportFilter.hxx | 110 +++++ writerperfect/source/draw/WPGImportFilter.cxx | 275 ++++++++++++ writerperfect/source/draw/WPGImportFilter.hxx | 110 +++++ .../source/draw/wpftdraw_genericfilter.cxx | 110 +++++ writerperfect/source/vsdimp/VisioImportFilter.cxx | 276 ------------ writerperfect/source/vsdimp/VisioImportFilter.hxx | 115 ----- .../source/vsdimp/visioimport_genericfilter.cxx | 68 --- .../source/wpdimp/WordPerfectImportFilter.cxx | 461 --------------------- .../source/wpdimp/WordPerfectImportFilter.hxx | 176 -------- writerperfect/source/wpdimp/wpft_genericfilter.cxx | 67 --- writerperfect/source/wpgimp/WPGImportFilter.cxx | 275 ------------ writerperfect/source/wpgimp/WPGImportFilter.hxx | 115 ----- .../source/wpgimp/wpgimport_genericfilter.cxx | 68 --- .../source/wpsimp/MSWorksImportFilter.cxx | 277 ------------- .../source/wpsimp/MSWorksImportFilter.hxx | 112 ----- .../source/wpsimp/msworks_genericfilter.cxx | 68 --- .../source/writer/MSWorksImportFilter.cxx | 277 +++++++++++++ .../source/writer/MSWorksImportFilter.hxx | 112 +++++ .../source/writer/WordPerfectImportFilter.cxx | 461 +++++++++++++++++++++ .../source/writer/WordPerfectImportFilter.hxx | 176 ++++++++ .../source/writer/wpftwriter_genericfilter.cxx | 81 ++++ writerperfect/util/cdrfilter.component | 12 - writerperfect/util/msworksfilter.component | 8 - writerperfect/util/visiofilter.component | 8 - writerperfect/util/wpft.component | 35 -- writerperfect/util/wpftdraw.component | 20 + writerperfect/util/wpftwriter.component | 39 ++ writerperfect/util/wpgfilter.component | 8 - 46 files changed, 2975 insertions(+), 3370 deletions(-) delete mode 100644 writerperfect/Library_cdrimport.mk delete mode 100644 writerperfect/Library_msworks.mk delete mode 100644 writerperfect/Library_visioimport.mk delete mode 100644 writerperfect/Library_wpft.mk create mode 100644 writerperfect/Library_wpftdraw.mk create mode 100644 writerperfect/Library_wpftwriter.mk delete mode 100644 writerperfect/Library_wpgimport.mk delete mode 100644 writerperfect/source/cdrimp/CDRImportFilter.cxx delete mode 100644 writerperfect/source/cdrimp/CDRImportFilter.hxx delete mode 100644 writerperfect/source/cdrimp/CMXImportFilter.cxx delete mode 100644 writerperfect/source/cdrimp/CMXImportFilter.hxx delete mode 100644 writerperfect/source/cdrimp/cdrimport_genericfilter.cxx create mode 100644 writerperfect/source/draw/CDRImportFilter.cxx create mode 100644 writerperfect/source/draw/CDRImportFilter.hxx create mode 100644 writerperfect/source/draw/CMXImportFilter.cxx create mode 100644 writerperfect/source/draw/CMXImportFilter.hxx create mode 100644 writerperfect/source/draw/VisioImportFilter.cxx create mode 100644 writerperfect/source/draw/VisioImportFilter.hxx create mode 100644 writerperfect/source/draw/WPGImportFilter.cxx create mode 100644 writerperfect/source/draw/WPGImportFilter.hxx create mode 100644 writerperfect/source/draw/wpftdraw_genericfilter.cxx delete mode 100644 writerperfect/source/vsdimp/VisioImportFilter.cxx delete mode 100644 writerperfect/source/vsdimp/VisioImportFilter.hxx delete mode 100644 writerperfect/source/vsdimp/visioimport_genericfilter.cxx delete mode 100644 writerperfect/source/wpdimp/WordPerfectImportFilter.cxx delete mode 100644 writerperfect/source/wpdimp/WordPerfectImportFilter.hxx delete mode 100644 writerperfect/source/wpdimp/wpft_genericfilter.cxx delete mode 100644 writerperfect/source/wpgimp/WPGImportFilter.cxx delete mode 100644 writerperfect/source/wpgimp/WPGImportFilter.hxx delete mode 100644 writerperfect/source/wpgimp/wpgimport_genericfilter.cxx delete mode 100644 writerperfect/source/wpsimp/MSWorksImportFilter.cxx delete mode 100644 writerperfect/source/wpsimp/MSWorksImportFilter.hxx delete mode 100644 writerperfect/source/wpsimp/msworks_genericfilter.cxx create mode 100644 writerperfect/source/writer/MSWorksImportFilter.cxx create mode 100644 writerperfect/source/writer/MSWorksImportFilter.hxx create mode 100644 writerperfect/source/writer/WordPerfectImportFilter.cxx create mode 100644 writerperfect/source/writer/WordPerfectImportFilter.hxx create mode 100644 writerperfect/source/writer/wpftwriter_genericfilter.cxx delete mode 100644 writerperfect/util/cdrfilter.component delete mode 100644 writerperfect/util/msworksfilter.component delete mode 100644 writerperfect/util/visiofilter.component delete mode 100644 writerperfect/util/wpft.component create mode 100644 writerperfect/util/wpftdraw.component create mode 100644 writerperfect/util/wpftwriter.component delete mode 100644 writerperfect/util/wpgfilter.component (limited to 'writerperfect') diff --git a/writerperfect/Library_cdrimport.mk b/writerperfect/Library_cdrimport.mk deleted file mode 100644 index 257757c32888..000000000000 --- a/writerperfect/Library_cdrimport.mk +++ /dev/null @@ -1,72 +0,0 @@ -# -*- 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 -# -# 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$(SRCDIR)/writerperfect/source \ -)) - -$(eval $(call gb_Library_use_api,cdrimport,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_Library_use_libraries,cdrimport,\ - cppu \ - cppuhelper \ - sal \ - sot \ - tl \ - utl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_Library_use_static_libraries,cdrimport,\ - writerperfect \ -)) - -$(eval $(call gb_Library_use_externals,cdrimport,\ - wpd \ - wpg \ - cdr \ - lcms2 \ - zlib \ -)) - -$(eval $(call gb_Library_add_exception_objects,cdrimport,\ - writerperfect/source/cdrimp/CDRImportFilter \ - writerperfect/source/cdrimp/CMXImportFilter \ - writerperfect/source/cdrimp/cdrimport_genericfilter \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Library_msworks.mk b/writerperfect/Library_msworks.mk deleted file mode 100644 index 7efb9944a24d..000000000000 --- a/writerperfect/Library_msworks.mk +++ /dev/null @@ -1,69 +0,0 @@ -# -*- 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 -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -$(eval $(call gb_Library_Library,msworks)) - -$(eval $(call gb_Library_set_componentfile,msworks,writerperfect/util/msworksfilter)) - -$(eval $(call gb_Library_set_include,msworks,\ - $$(INCLUDE) \ - -I$(SRCDIR)/writerperfect/source \ -)) - -$(eval $(call gb_Library_use_api,msworks,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_Library_use_libraries,msworks,\ - cppu \ - cppuhelper \ - sal \ - sot \ - ucbhelper \ - tl \ - utl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_Library_use_static_libraries,msworks,\ - writerperfect \ -)) - -$(eval $(call gb_Library_use_externals,msworks,\ - wpd \ - wps \ -)) - -$(eval $(call gb_Library_add_exception_objects,msworks,\ - writerperfect/source/wpsimp/MSWorksImportFilter \ - writerperfect/source/wpsimp/msworks_genericfilter \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Library_visioimport.mk b/writerperfect/Library_visioimport.mk deleted file mode 100644 index 7db2b04bbd9e..000000000000 --- a/writerperfect/Library_visioimport.mk +++ /dev/null @@ -1,69 +0,0 @@ -# -*- 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 -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -$(eval $(call gb_Library_Library,visioimport)) - -$(eval $(call gb_Library_set_componentfile,visioimport,writerperfect/util/visiofilter)) - -$(eval $(call gb_Library_set_include,visioimport,\ - $$(INCLUDE) \ - -I$(SRCDIR)/writerperfect/source \ -)) - -$(eval $(call gb_Library_use_api,visioimport,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_Library_use_libraries,visioimport,\ - cppu \ - cppuhelper \ - sal \ - sot \ - tl \ - utl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_Library_use_static_libraries,visioimport,\ - writerperfect \ -)) - -$(eval $(call gb_Library_use_externals,visioimport,\ - wpd \ - wpg \ - visio \ -)) - -$(eval $(call gb_Library_add_exception_objects,visioimport,\ - writerperfect/source/vsdimp/VisioImportFilter \ - writerperfect/source/vsdimp/visioimport_genericfilter \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Library_wpft.mk b/writerperfect/Library_wpft.mk deleted file mode 100644 index 113cb17fad60..000000000000 --- a/writerperfect/Library_wpft.mk +++ /dev/null @@ -1,71 +0,0 @@ -# -*- 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 -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -$(eval $(call gb_Library_Library,wpft)) - -$(eval $(call gb_Library_set_componentfile,wpft,writerperfect/util/wpft)) - -$(eval $(call gb_Library_set_include,wpft,\ - $$(INCLUDE) \ - -I$(SRCDIR)/writerperfect/source \ -)) - -$(eval $(call gb_Library_use_api,wpft,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_Library_use_libraries,wpft,\ - cppu \ - cppuhelper \ - vcl \ - sal \ - sfx \ - sot \ - tl \ - ucbhelper \ - utl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_Library_use_static_libraries,wpft,\ - writerperfect \ -)) - -$(eval $(call gb_Library_use_externals,wpft,\ - wpd \ - wpg \ -)) - -$(eval $(call gb_Library_add_exception_objects,wpft,\ - writerperfect/source/wpdimp/WordPerfectImportFilter \ - writerperfect/source/wpdimp/wpft_genericfilter \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk new file mode 100644 index 000000000000..e4c3b51de2db --- /dev/null +++ b/writerperfect/Library_wpftdraw.mk @@ -0,0 +1,75 @@ +# -*- 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 +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +$(eval $(call gb_Library_Library,wpftdraw)) + +$(eval $(call gb_Library_set_componentfile,wpftdraw,writerperfect/util/wpftdraw)) + +$(eval $(call gb_Library_set_include,wpftdraw,\ + $$(INCLUDE) \ + -I$(SRCDIR)/writerperfect/source \ +)) + +$(eval $(call gb_Library_use_api,wpftdraw,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_Library_use_libraries,wpftdraw,\ + cppu \ + cppuhelper \ + sal \ + sot \ + tl \ + utl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_Library_use_static_libraries,wpftdraw,\ + writerperfect \ +)) + +$(eval $(call gb_Library_use_externals,wpftdraw,\ + wpd \ + wpg \ + visio \ + cdr \ + lcms2 \ + zlib \ +)) + +$(eval $(call gb_Library_add_exception_objects,wpftdraw,\ + writerperfect/source/draw/CDRImportFilter \ + writerperfect/source/draw/CMXImportFilter \ + writerperfect/source/draw/VisioImportFilter \ + writerperfect/source/draw/WPGImportFilter \ + writerperfect/source/draw/wpftdraw_genericfilter \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Library_wpftwriter.mk b/writerperfect/Library_wpftwriter.mk new file mode 100644 index 000000000000..611003524dd5 --- /dev/null +++ b/writerperfect/Library_wpftwriter.mk @@ -0,0 +1,73 @@ +# -*- 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 +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +$(eval $(call gb_Library_Library,wpftwriter)) + +$(eval $(call gb_Library_set_componentfile,wpftwriter,writerperfect/util/wpftwriter)) + +$(eval $(call gb_Library_set_include,wpftwriter,\ + $$(INCLUDE) \ + -I$(SRCDIR)/writerperfect/source \ +)) + +$(eval $(call gb_Library_use_api,wpftwriter,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_Library_use_libraries,wpftwriter,\ + cppu \ + cppuhelper \ + vcl \ + sal \ + sfx \ + sot \ + tl \ + ucbhelper \ + utl \ + xo \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_Library_use_static_libraries,wpftwriter,\ + writerperfect \ +)) + +$(eval $(call gb_Library_use_externals,wpftwriter,\ + wpd \ + wpg \ + wps \ +)) + +$(eval $(call gb_Library_add_exception_objects,wpftwriter,\ + writerperfect/source/writer/MSWorksImportFilter \ + writerperfect/source/writer/WordPerfectImportFilter \ + writerperfect/source/writer/wpftwriter_genericfilter \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Library_wpgimport.mk b/writerperfect/Library_wpgimport.mk deleted file mode 100644 index b2cbd66e238a..000000000000 --- a/writerperfect/Library_wpgimport.mk +++ /dev/null @@ -1,68 +0,0 @@ -# -*- 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 -# -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -$(eval $(call gb_Library_Library,wpgimport)) - -$(eval $(call gb_Library_set_componentfile,wpgimport,writerperfect/util/wpgfilter)) - -$(eval $(call gb_Library_set_include,wpgimport,\ - $$(INCLUDE) \ - -I$(SRCDIR)/writerperfect/source \ -)) - -$(eval $(call gb_Library_use_api,wpgimport,\ - offapi \ - udkapi \ -)) - -$(eval $(call gb_Library_use_libraries,wpgimport,\ - cppu \ - cppuhelper \ - sal \ - sot \ - tl \ - utl \ - xo \ - $(gb_STDLIBS) \ -)) - -$(eval $(call gb_Library_use_static_libraries,wpgimport,\ - writerperfect \ -)) - -$(eval $(call gb_Library_use_externals,wpgimport,\ - wpd \ - wpg \ -)) - -$(eval $(call gb_Library_add_exception_objects,wpgimport,\ - writerperfect/source/wpgimp/WPGImportFilter \ - writerperfect/source/wpgimp/wpgimport_genericfilter \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/writerperfect/Module_writerperfect.mk b/writerperfect/Module_writerperfect.mk index dc2039c8f604..0e1bee0f2188 100644 --- a/writerperfect/Module_writerperfect.mk +++ b/writerperfect/Module_writerperfect.mk @@ -28,42 +28,32 @@ $(eval $(call gb_Module_Module,writerperfect)) -ifneq (,$(filter YES,$(SYSTEM_LIBCDR))$(filter LIBCDR,$(BUILD_TYPE))) -$(eval $(call gb_Module_add_targets,writerperfect,\ - Library_cdrimport \ -)) -endif - ifneq (,$(filter YES,$(SYSTEM_LIBWPD))$(filter LIBWPD,$(BUILD_TYPE))) ifneq (,$(filter YES,$(SYSTEM_LIBWPS))$(filter LIBWPS,$(BUILD_TYPE))) $(eval $(call gb_Module_add_targets,writerperfect,\ - Library_msworks \ + Library_wpftwriter \ )) endif endif +ifneq (,$(filter YES,$(SYSTEM_LIBWPD))$(filter LIBWPD,$(BUILD_TYPE))) +ifneq (,$(filter YES,$(SYSTEM_LIBWPG))$(filter LIBWPG,$(BUILD_TYPE))) ifneq (,$(filter YES,$(SYSTEM_LIBVISIO))$(filter LIBVISIO,$(BUILD_TYPE))) +ifneq (,$(filter YES,$(SYSTEM_LIBCDR))$(filter LIBCDR,$(BUILD_TYPE))) $(eval $(call gb_Module_add_targets,writerperfect,\ - Library_visioimport \ + Library_wpftdraw \ )) endif - -ifneq (,$(filter YES,$(SYSTEM_LIBWPD))$(filter LIBWPD,$(BUILD_TYPE))) -$(eval $(call gb_Module_add_targets,writerperfect,\ - Library_wpft \ -)) endif - -ifneq (,$(filter YES,$(SYSTEM_LIBWPG))$(filter LIBWPG,$(BUILD_TYPE))) -$(eval $(call gb_Module_add_targets,writerperfect,\ - Library_wpgimport \ -)) +endif endif ifneq (,$(filter YES,$(SYSTEM_LIBWPD))$(filter LIBWPD,$(BUILD_TYPE))) +ifneq (,$(filter YES,$(SYSTEM_LIBWPG))$(filter LIBWPG,$(BUILD_TYPE))) $(eval $(call gb_Module_add_targets,writerperfect,\ StaticLibrary_writerperfect \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/writerperfect/source/cdrimp/CDRImportFilter.cxx b/writerperfect/source/cdrimp/CDRImportFilter.cxx deleted file mode 100644 index 2476a5567476..000000000000 --- a/writerperfect/source/cdrimp/CDRImportFilter.cxx +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- 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 - * - * 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 -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "filter/DocumentHandler.hxx" -#include "filter/OdgGenerator.hxx" -#include "CDRImportFilter.hxx" -#include "stream/WPXSvStream.h" - -#include - -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 == "InputStream" ) - pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "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 - 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 == "TypeName" ) - location=i; - else if ( pValue[i].Name == "InputStream" ) - pValue[i].Value >>= xInputStream; - } - - WPXSvInputStream input( xInputStream ); - - if (libcdr::CDRDocument::isSupported(&input)) - sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_CorelDraw_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 == "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 == SERVICE_NAME1 || ServiceName == 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 deleted file mode 100644 index 56f124ea8ebe..000000000000 --- a/writerperfect/source/cdrimp/CDRImportFilter.hxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- 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 - * - * 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 _CDRIMPORTFILTER_HXX -#define _CDRIMPORTFILTER_HXX - -#include -#include -#include -#include -#include -#include -#include - -#include - -/* 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; - -public: - CDRImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) {} - 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/CMXImportFilter.cxx b/writerperfect/source/cdrimp/CMXImportFilter.cxx deleted file mode 100644 index 76a9d06431a6..000000000000 --- a/writerperfect/source/cdrimp/CMXImportFilter.cxx +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* CMXImportFilter: 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 - * - * 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 -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "filter/DocumentHandler.hxx" -#include "filter/OdgGenerator.hxx" -#include "CMXImportFilter.hxx" -#include "stream/WPXSvStream.h" - -#include - -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 CMXImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::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 == "InputStream" ) - pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "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::CMXDocument::parse(&input, &exporter); - return tmpParseResult; -} - -void SAL_CALL CMXImportFilter::cancel( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::cancel" << std::endl; -#endif -} - -// XImporter -void SAL_CALL CMXImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) -throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::setTargetDocument" << std::endl; -#endif - mxDoc = xDoc; -} - -// XExtendedFilterDetection -OUString SAL_CALL CMXImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) -throw( com::sun::star::uno::RuntimeException ) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::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 == "TypeName" ) - location=i; - else if ( pValue[i].Name == "InputStream" ) - pValue[i].Value >>= xInputStream; - } - - WPXSvInputStream input( xInputStream ); - - if (libcdr::CMXDocument::isSupported(&input)) - sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_CorelDraw_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 CMXImportFilter::initialize( const Sequence< Any >& aArguments ) -throw (Exception, RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::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 == "Type" ) - { - pValue[i].Value >>= msFilterName; - break; - } - } - } -} -OUString CMXImportFilter_getImplementationName () -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter_getImplementationName" << std::endl; -#endif - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.CMXImportFilter" ) ); -} - -#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" -#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" -sal_Bool SAL_CALL CMXImportFilter_supportsService( const OUString &ServiceName ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter_supportsService" << std::endl; -#endif - return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); -} -Sequence< OUString > SAL_CALL CMXImportFilter_getSupportedServiceNames( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter_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 CMXImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) -throw( Exception ) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter_createInstance" << std::endl; -#endif - return (cppu::OWeakObject *) new CMXImportFilter( rSMgr ); -} - -// XServiceInfo -OUString SAL_CALL CMXImportFilter::getImplementationName( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::getImplementationName" << std::endl; -#endif - return CMXImportFilter_getImplementationName(); -} -sal_Bool SAL_CALL CMXImportFilter::supportsService( const OUString &rServiceName ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::supportsService" << std::endl; -#endif - return CMXImportFilter_supportsService( rServiceName ); -} -Sequence< OUString > SAL_CALL CMXImportFilter::getSupportedServiceNames( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "CMXImportFilter::getSupportedServiceNames" << std::endl; -#endif - return CMXImportFilter_getSupportedServiceNames(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/cdrimp/CMXImportFilter.hxx b/writerperfect/source/cdrimp/CMXImportFilter.hxx deleted file mode 100644 index a9ec8f430ec5..000000000000 --- a/writerperfect/source/cdrimp/CMXImportFilter.hxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- 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 - * - * 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 _CMXIMPORTFILTER_HXX -#define _CMXIMPORTFILTER_HXX - -#include -#include -#include -#include -#include -#include -#include - -#include - -/* 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 - > -{ -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; - -public: - CMXImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) {} - 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); - 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 CMXImportFilter_getImplementationName() -throw ( ::com::sun::star::uno::RuntimeException ); - -sal_Bool SAL_CALL CMXImportFilter_supportsService( const ::rtl::OUString &ServiceName ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL CMXImportFilter_getSupportedServiceNames( ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL CMXImportFilter_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 deleted file mode 100644 index 56126105048f..000000000000 --- a/writerperfect/source/cdrimp/cdrimport_genericfilter.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- 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 - -#include -#include -#include - -#include - -#include "CDRImportFilter.hxx" -#include "CMXImportFilter.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 cdrfilter_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(); - } - } - if ( pServiceManager && implName.equals(CMXImportFilter_getImplementationName()) ) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - CMXImportFilter_createInstance, CMXImportFilter_getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/draw/CDRImportFilter.cxx b/writerperfect/source/draw/CDRImportFilter.cxx new file mode 100644 index 000000000000..2476a5567476 --- /dev/null +++ b/writerperfect/source/draw/CDRImportFilter.cxx @@ -0,0 +1,276 @@ +/* -*- 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 + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "filter/DocumentHandler.hxx" +#include "filter/OdgGenerator.hxx" +#include "CDRImportFilter.hxx" +#include "stream/WPXSvStream.h" + +#include + +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 == "InputStream" ) + pValue[i].Value >>= xInputStream; + else if ( pValue[i].Name == "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 + 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 == "TypeName" ) + location=i; + else if ( pValue[i].Name == "InputStream" ) + pValue[i].Value >>= xInputStream; + } + + WPXSvInputStream input( xInputStream ); + + if (libcdr::CDRDocument::isSupported(&input)) + sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_CorelDraw_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 == "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 == SERVICE_NAME1 || ServiceName == 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/draw/CDRImportFilter.hxx b/writerperfect/source/draw/CDRImportFilter.hxx new file mode 100644 index 000000000000..56f124ea8ebe --- /dev/null +++ b/writerperfect/source/draw/CDRImportFilter.hxx @@ -0,0 +1,110 @@ +/* -*- 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 + * + * 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 _CDRIMPORTFILTER_HXX +#define _CDRIMPORTFILTER_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include + +/* 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; + +public: + CDRImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) + : mxMSF( rxMSF ) {} + 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/draw/CMXImportFilter.cxx b/writerperfect/source/draw/CMXImportFilter.cxx new file mode 100644 index 000000000000..76a9d06431a6 --- /dev/null +++ b/writerperfect/source/draw/CMXImportFilter.cxx @@ -0,0 +1,276 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* CMXImportFilter: 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 + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "filter/DocumentHandler.hxx" +#include "filter/OdgGenerator.hxx" +#include "CMXImportFilter.hxx" +#include "stream/WPXSvStream.h" + +#include + +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 CMXImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::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 == "InputStream" ) + pValue[i].Value >>= xInputStream; + else if ( pValue[i].Name == "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::CMXDocument::parse(&input, &exporter); + return tmpParseResult; +} + +void SAL_CALL CMXImportFilter::cancel( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::cancel" << std::endl; +#endif +} + +// XImporter +void SAL_CALL CMXImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) +throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::setTargetDocument" << std::endl; +#endif + mxDoc = xDoc; +} + +// XExtendedFilterDetection +OUString SAL_CALL CMXImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) +throw( com::sun::star::uno::RuntimeException ) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::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 == "TypeName" ) + location=i; + else if ( pValue[i].Name == "InputStream" ) + pValue[i].Value >>= xInputStream; + } + + WPXSvInputStream input( xInputStream ); + + if (libcdr::CMXDocument::isSupported(&input)) + sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_CorelDraw_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 CMXImportFilter::initialize( const Sequence< Any >& aArguments ) +throw (Exception, RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::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 == "Type" ) + { + pValue[i].Value >>= msFilterName; + break; + } + } + } +} +OUString CMXImportFilter_getImplementationName () +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter_getImplementationName" << std::endl; +#endif + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.CMXImportFilter" ) ); +} + +#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" +#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" +sal_Bool SAL_CALL CMXImportFilter_supportsService( const OUString &ServiceName ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter_supportsService" << std::endl; +#endif + return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); +} +Sequence< OUString > SAL_CALL CMXImportFilter_getSupportedServiceNames( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter_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 CMXImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) +throw( Exception ) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter_createInstance" << std::endl; +#endif + return (cppu::OWeakObject *) new CMXImportFilter( rSMgr ); +} + +// XServiceInfo +OUString SAL_CALL CMXImportFilter::getImplementationName( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::getImplementationName" << std::endl; +#endif + return CMXImportFilter_getImplementationName(); +} +sal_Bool SAL_CALL CMXImportFilter::supportsService( const OUString &rServiceName ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::supportsService" << std::endl; +#endif + return CMXImportFilter_supportsService( rServiceName ); +} +Sequence< OUString > SAL_CALL CMXImportFilter::getSupportedServiceNames( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "CMXImportFilter::getSupportedServiceNames" << std::endl; +#endif + return CMXImportFilter_getSupportedServiceNames(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/draw/CMXImportFilter.hxx b/writerperfect/source/draw/CMXImportFilter.hxx new file mode 100644 index 000000000000..a9ec8f430ec5 --- /dev/null +++ b/writerperfect/source/draw/CMXImportFilter.hxx @@ -0,0 +1,110 @@ +/* -*- 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 + * + * 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 _CMXIMPORTFILTER_HXX +#define _CMXIMPORTFILTER_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include + +/* 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 + > +{ +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; + +public: + CMXImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) + : mxMSF( rxMSF ) {} + 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); + 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 CMXImportFilter_getImplementationName() +throw ( ::com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL CMXImportFilter_supportsService( const ::rtl::OUString &ServiceName ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL CMXImportFilter_getSupportedServiceNames( ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL CMXImportFilter_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/draw/VisioImportFilter.cxx b/writerperfect/source/draw/VisioImportFilter.cxx new file mode 100644 index 000000000000..13bf08922fa7 --- /dev/null +++ b/writerperfect/source/draw/VisioImportFilter.cxx @@ -0,0 +1,276 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* VisioImportFilter: 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 + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "filter/DocumentHandler.hxx" +#include "filter/OdgGenerator.hxx" +#include "VisioImportFilter.hxx" +#include "stream/WPXSvStream.h" + +#include + +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 VisioImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::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 == "InputStream" ) + pValue[i].Value >>= xInputStream; + else if ( pValue[i].Name == "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 = libvisio::VisioDocument::parse(&input, &exporter); + return tmpParseResult; +} + +void SAL_CALL VisioImportFilter::cancel( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::cancel" << std::endl; +#endif +} + +// XImporter +void SAL_CALL VisioImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) +throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::setTargetDocument" << std::endl; +#endif + mxDoc = xDoc; +} + +// XExtendedFilterDetection +OUString SAL_CALL VisioImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) +throw( com::sun::star::uno::RuntimeException ) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::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 == "TypeName" ) + location=i; + else if ( pValue[i].Name == "InputStream" ) + pValue[i].Value >>= xInputStream; + } + + WPXSvInputStream input( xInputStream ); + + if (libvisio::VisioDocument::isSupported(&input)) + sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_Visio_Document" ) ); + + if (!sTypeName.isEmpty()) + { + 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 VisioImportFilter::initialize( const Sequence< Any >& aArguments ) +throw (Exception, RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::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 == "Type" ) + { + pValue[i].Value >>= msFilterName; + break; + } + } + } +} +OUString VisioImportFilter_getImplementationName () +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter_getImplementationName" << std::endl; +#endif + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.VisioImportFilter" ) ); +} + +#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" +#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" +sal_Bool SAL_CALL VisioImportFilter_supportsService( const OUString &ServiceName ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter_supportsService" << std::endl; +#endif + return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); +} +Sequence< OUString > SAL_CALL VisioImportFilter_getSupportedServiceNames( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter_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 VisioImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) +throw( Exception ) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter_createInstance" << std::endl; +#endif + return (cppu::OWeakObject *) new VisioImportFilter( rSMgr ); +} + +// XServiceInfo +OUString SAL_CALL VisioImportFilter::getImplementationName( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::getImplementationName" << std::endl; +#endif + return VisioImportFilter_getImplementationName(); +} +sal_Bool SAL_CALL VisioImportFilter::supportsService( const OUString &rServiceName ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::supportsService" << std::endl; +#endif + return VisioImportFilter_supportsService( rServiceName ); +} +Sequence< OUString > SAL_CALL VisioImportFilter::getSupportedServiceNames( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "VisioImportFilter::getSupportedServiceNames" << std::endl; +#endif + return VisioImportFilter_getSupportedServiceNames(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/draw/VisioImportFilter.hxx b/writerperfect/source/draw/VisioImportFilter.hxx new file mode 100644 index 000000000000..377c007c1053 --- /dev/null +++ b/writerperfect/source/draw/VisioImportFilter.hxx @@ -0,0 +1,110 @@ +/* -*- 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 + * + * 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 +#include +#include +#include +#include +#include +#include + +#include + +/* 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 + > +{ +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; + +public: + VisioImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) + : mxMSF( rxMSF ) {} + 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); + 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 VisioImportFilter_getImplementationName() +throw ( ::com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL VisioImportFilter_supportsService( const ::rtl::OUString &ServiceName ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL VisioImportFilter_getSupportedServiceNames( ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL VisioImportFilter_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/draw/WPGImportFilter.cxx b/writerperfect/source/draw/WPGImportFilter.cxx new file mode 100644 index 000000000000..ff7612b1e433 --- /dev/null +++ b/writerperfect/source/draw/WPGImportFilter.cxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* WPGImportFilter: 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 + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "filter/DocumentHandler.hxx" +#include "filter/OdgGenerator.hxx" +#include "WPGImportFilter.hxx" +#include "stream/WPXSvStream.h" + +#include + +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 WPGImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::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 == "InputStream" ) + pValue[i].Value >>= xInputStream; + else if ( pValue[i].Name == "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 = libwpg::WPGraphics::parse(&input, &exporter); + return tmpParseResult; +} + +void SAL_CALL WPGImportFilter::cancel( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::cancel" << std::endl; +#endif +} + +// XImporter +void SAL_CALL WPGImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) +throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::setTargetDocument" << std::endl; +#endif + mxDoc = xDoc; +} + +// XExtendedFilterDetection +OUString SAL_CALL WPGImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) +throw( com::sun::star::uno::RuntimeException ) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::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 == "TypeName" ) + location=i; + else if ( pValue[i].Name == "InputStream" ) + pValue[i].Value >>= xInputStream; + } + + WPXSvInputStream input( xInputStream ); + + if (libwpg::WPGraphics::isSupported(&input)) + sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_WordPerfect_Graphics" ) ); + + if (!sTypeName.isEmpty()) + { + 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 WPGImportFilter::initialize( const Sequence< Any >& aArguments ) +throw (Exception, RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::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 == "Type" ) + { + pValue[i].Value >>= msFilterName; + break; + } + } + } +} +OUString WPGImportFilter_getImplementationName () +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter_getImplementationName" << std::endl; +#endif + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.WPGImportFilter" ) ); +} + +#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" +#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" +sal_Bool SAL_CALL WPGImportFilter_supportsService( const OUString &ServiceName ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter_supportsService" << std::endl; +#endif + return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); +} +Sequence< OUString > SAL_CALL WPGImportFilter_getSupportedServiceNames( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter_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 WPGImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) +throw( Exception ) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter_createInstance" << std::endl; +#endif + return (cppu::OWeakObject *) new WPGImportFilter( rSMgr ); +} + +// XServiceInfo +OUString SAL_CALL WPGImportFilter::getImplementationName( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::getImplementationName" << std::endl; +#endif + return WPGImportFilter_getImplementationName(); +} +sal_Bool SAL_CALL WPGImportFilter::supportsService( const OUString &rServiceName ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::supportsService" << std::endl; +#endif + return WPGImportFilter_supportsService( rServiceName ); +} +Sequence< OUString > SAL_CALL WPGImportFilter::getSupportedServiceNames( ) +throw (RuntimeException) +{ +#ifdef DEBUG + std::cerr << "WPGImportFilter::getSupportedServiceNames" << std::endl; +#endif + return WPGImportFilter_getSupportedServiceNames(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/draw/WPGImportFilter.hxx b/writerperfect/source/draw/WPGImportFilter.hxx new file mode 100644 index 000000000000..091c821a552b --- /dev/null +++ b/writerperfect/source/draw/WPGImportFilter.hxx @@ -0,0 +1,110 @@ +/* -*- 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 + * + * 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 _WPGIMPORTFILTER_HXX +#define _WPGIMPORTFILTER_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include + +/* 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 + > +{ +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; + +public: + WPGImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) + : mxMSF( rxMSF ) {} + 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); + 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 WPGImportFilter_getImplementationName() +throw ( ::com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL WPGImportFilter_supportsService( const ::rtl::OUString &ServiceName ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WPGImportFilter_getSupportedServiceNames( ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL WPGImportFilter_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/draw/wpftdraw_genericfilter.cxx b/writerperfect/source/draw/wpftdraw_genericfilter.cxx new file mode 100644 index 000000000000..cbecb4faeb2d --- /dev/null +++ b/writerperfect/source/draw/wpftdraw_genericfilter.cxx @@ -0,0 +1,110 @@ +/* -*- 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 + +#include +#include +#include + +#include + +#include "CDRImportFilter.hxx" +#include "CMXImportFilter.hxx" +#include "VisioImportFilter.hxx" +#include "WPGImportFilter.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 wpftdraw_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(); + } + } + if ( pServiceManager && implName.equals(CMXImportFilter_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + CMXImportFilter_createInstance, CMXImportFilter_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + if ( pServiceManager && implName.equals(WPGImportFilter_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + WPGImportFilter_createInstance, WPGImportFilter_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + if ( pServiceManager && implName.equals(VisioImportFilter_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + VisioImportFilter_createInstance, VisioImportFilter_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/vsdimp/VisioImportFilter.cxx b/writerperfect/source/vsdimp/VisioImportFilter.cxx deleted file mode 100644 index 13bf08922fa7..000000000000 --- a/writerperfect/source/vsdimp/VisioImportFilter.cxx +++ /dev/null @@ -1,276 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* VisioImportFilter: 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 - * - * 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 -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "filter/DocumentHandler.hxx" -#include "filter/OdgGenerator.hxx" -#include "VisioImportFilter.hxx" -#include "stream/WPXSvStream.h" - -#include - -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 VisioImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::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 == "InputStream" ) - pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "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 = libvisio::VisioDocument::parse(&input, &exporter); - return tmpParseResult; -} - -void SAL_CALL VisioImportFilter::cancel( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::cancel" << std::endl; -#endif -} - -// XImporter -void SAL_CALL VisioImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) -throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::setTargetDocument" << std::endl; -#endif - mxDoc = xDoc; -} - -// XExtendedFilterDetection -OUString SAL_CALL VisioImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) -throw( com::sun::star::uno::RuntimeException ) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::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 == "TypeName" ) - location=i; - else if ( pValue[i].Name == "InputStream" ) - pValue[i].Value >>= xInputStream; - } - - WPXSvInputStream input( xInputStream ); - - if (libvisio::VisioDocument::isSupported(&input)) - sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_Visio_Document" ) ); - - if (!sTypeName.isEmpty()) - { - 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 VisioImportFilter::initialize( const Sequence< Any >& aArguments ) -throw (Exception, RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::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 == "Type" ) - { - pValue[i].Value >>= msFilterName; - break; - } - } - } -} -OUString VisioImportFilter_getImplementationName () -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter_getImplementationName" << std::endl; -#endif - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.VisioImportFilter" ) ); -} - -#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" -#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" -sal_Bool SAL_CALL VisioImportFilter_supportsService( const OUString &ServiceName ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter_supportsService" << std::endl; -#endif - return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); -} -Sequence< OUString > SAL_CALL VisioImportFilter_getSupportedServiceNames( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter_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 VisioImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) -throw( Exception ) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter_createInstance" << std::endl; -#endif - return (cppu::OWeakObject *) new VisioImportFilter( rSMgr ); -} - -// XServiceInfo -OUString SAL_CALL VisioImportFilter::getImplementationName( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::getImplementationName" << std::endl; -#endif - return VisioImportFilter_getImplementationName(); -} -sal_Bool SAL_CALL VisioImportFilter::supportsService( const OUString &rServiceName ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::supportsService" << std::endl; -#endif - return VisioImportFilter_supportsService( rServiceName ); -} -Sequence< OUString > SAL_CALL VisioImportFilter::getSupportedServiceNames( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "VisioImportFilter::getSupportedServiceNames" << std::endl; -#endif - return VisioImportFilter_getSupportedServiceNames(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/vsdimp/VisioImportFilter.hxx b/writerperfect/source/vsdimp/VisioImportFilter.hxx deleted file mode 100644 index a4e7d7fbbd72..000000000000 --- a/writerperfect/source/vsdimp/VisioImportFilter.hxx +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- 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 - * - * 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 -#include -#include -#include -#include -#include -#include - -#include - -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 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 - > -{ -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; - -public: - VisioImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) {} - 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); - 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 VisioImportFilter_getImplementationName() -throw ( ::com::sun::star::uno::RuntimeException ); - -sal_Bool SAL_CALL VisioImportFilter_supportsService( const ::rtl::OUString &ServiceName ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL VisioImportFilter_getSupportedServiceNames( ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL VisioImportFilter_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/vsdimp/visioimport_genericfilter.cxx b/writerperfect/source/vsdimp/visioimport_genericfilter.cxx deleted file mode 100644 index 04172b0d3060..000000000000 --- a/writerperfect/source/vsdimp/visioimport_genericfilter.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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 - -#include -#include -#include - -#include - -#include "VisioImportFilter.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 visiofilter_component_getFactory( - const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ ) - { - void *pRet = 0; - - OUString implName = OUString::createFromAscii( pImplName ); - if ( pServiceManager && implName.equals(VisioImportFilter_getImplementationName()) ) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - VisioImportFilter_createInstance, VisioImportFilter_getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx b/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx deleted file mode 100644 index f98d65e4b520..000000000000 --- a/writerperfect/source/wpdimp/WordPerfectImportFilter.cxx +++ /dev/null @@ -1,461 +0,0 @@ -/* -*- 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 - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "filter/FilterInternal.hxx" -#include "filter/DocumentHandler.hxx" -#include "stream/WPXSvStream.h" - -#if defined _MSC_VER -#pragma warning( push, 1 ) -#endif -#include -#if defined _MSC_VER -#pragma warning( pop ) -#endif - -#include "filter/OdtGenerator.hxx" -#include "filter/OdgGenerator.hxx" -#include "WordPerfectImportFilter.hxx" - -using namespace ::rtl; -using namespace ::com::sun::star; - -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::ucb::XCommandEnvironment; - -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; - -void callHandler(uno::Reference < XDocumentHandler > xDocHandler); - - -static bool handleEmbeddedWPGObject(const WPXBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) -{ - OdgGenerator exporter(pHandler, streamType); - - libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; - - if (!libwpg::WPGraphics::isSupported(const_cast(data.getDataStream()))) - fileFormat = libwpg::WPG_WPG1; - - return libwpg::WPGraphics::parse(const_cast(data.getDataStream()), &exporter, fileFormat); -} - -static bool handleEmbeddedWPGImage(const WPXBinaryData &input, WPXBinaryData &output) -{ - WPXString svgOutput; - libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; - - if (!libwpg::WPGraphics::isSupported(const_cast(input.getDataStream()))) - fileFormat = libwpg::WPG_WPG1; - - if (!libwpg::WPGraphics::generateSVG(const_cast(input.getDataStream()), svgOutput, fileFormat)) - return false; - - output.clear(); - output.append((unsigned char *)svgOutput.cstr(), strlen(svgOutput.cstr())); - return true; -} - -sal_Bool SAL_CALL WordPerfectImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) -throw (RuntimeException) -{ - WRITER_DEBUG_MSG(("WordPerfectImportFilter::importImpl: Got here!\n")); - - sal_Int32 nLength = aDescriptor.getLength(); - const PropertyValue *pValue = aDescriptor.getConstArray(); - OUString sURL; - uno::Reference < XInputStream > xInputStream; - for ( sal_Int32 i = 0 ; i < nLength; i++) - { - if ( pValue[i].Name == "InputStream" ) - pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; - } - if ( !xInputStream.is() ) - { - OSL_ASSERT( 0 ); - return sal_False; - } - - WPXSvInputStream input( xInputStream ); - - OString aUtf8Passwd; - - WPDConfidence confidence = WPDocument::isFileFormatSupported(&input); - - if (WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) - { - int unsuccessfulAttempts = 0; - while (true ) - { - SfxPasswordDialog aPasswdDlg( 0 ); - aPasswdDlg.SetMinLen(0); - if(!aPasswdDlg.Execute()) - return sal_False; - String aPasswd = aPasswdDlg.GetPassword(); - OUString aUniPasswd(aPasswd.GetBuffer() /*, aPasswd.Len(), RTL_TEXTENCODING_UCS2 */); - aUtf8Passwd = OUStringToOString(aUniPasswd, RTL_TEXTENCODING_UTF8); - if (WPD_PASSWORD_MATCH_OK == WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) - break; - else - unsuccessfulAttempts++; - if (unsuccessfulAttempts == 3) // timeout after 3 password atempts - return sal_False; - } - } - - // An XML import service: what we push sax messages to.. - OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.XMLOasisImporter" ) ); - uno::Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY ); - - // The XImporter sets up an empty target document for XDocumentHandler to write to.. - uno::Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY); - xImporter->setTargetDocument(mxDoc); - - // OO Document Handler: abstract class to handle document SAX messages, concrete implementation here - // writes to in-memory target doc - DocumentHandler xHandler(xInternalHandler); - - OdtGenerator collector(&xHandler, ODF_FLAT_XML); - collector.registerEmbeddedObjectHandler("image/x-wpg", &handleEmbeddedWPGObject); - collector.registerEmbeddedImageHandler("image/x-wpg", &handleEmbeddedWPGImage); - if (WPD_OK == WPDocument::parse(&input, &collector, aUtf8Passwd.isEmpty() ? 0 : aUtf8Passwd.getStr())) - return sal_True; - return sal_False; -} - -sal_Bool SAL_CALL WordPerfectImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) -throw (RuntimeException) -{ - WRITER_DEBUG_MSG(("WordPerfectImportFilter::filter: Got here!\n")); - return importImpl ( aDescriptor ); -} -void SAL_CALL WordPerfectImportFilter::cancel( ) -throw (RuntimeException) -{ - WRITER_DEBUG_MSG(("WordPerfectImportFilter::cancel: Got here!\n")); -} - -// XImporter -void SAL_CALL WordPerfectImportFilter::setTargetDocument( const uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) -throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) -{ - WRITER_DEBUG_MSG(("WordPerfectImportFilter::getTargetDocument: Got here!\n")); - mxDoc = xDoc; -} - -// XExtendedFilterDetection -OUString SAL_CALL WordPerfectImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) -throw( com::sun::star::uno::RuntimeException ) -{ - WRITER_DEBUG_MSG(("WordPerfectImportFilter::detect: Got here!\n")); - - WPDConfidence confidence = WPD_CONFIDENCE_NONE; - OUString sTypeName; - sal_Int32 nLength = Descriptor.getLength(); - sal_Int32 location = nLength; - OUString sURL; - const PropertyValue *pValue = Descriptor.getConstArray(); - uno::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; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; - } - - uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv; - if (!xInputStream.is()) - { - try - { - ::ucbhelper::Content aContent(sURL, xEnv); - xInputStream = aContent.openStream(); - } - catch ( ... ) - { - return ::rtl::OUString(); - } - - if (!xInputStream.is()) - return ::rtl::OUString(); - } - - WPXSvInputStream input( xInputStream ); - - if (input.atEOS()) - return ::rtl::OUString(); - - confidence = WPDocument::isFileFormatSupported(&input); - - if (confidence == WPD_CONFIDENCE_EXCELLENT || confidence == WPD_CONFIDENCE_SUPPORTED_ENCRYPTION) - sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer_WordPerfect_Document" ) ); - - if (!sTypeName.isEmpty()) - { - 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 WordPerfectImportFilter::initialize( const Sequence< Any >& aArguments ) -throw (Exception, RuntimeException) -{ - WRITER_DEBUG_MSG(("WordPerfectImportFilter::initialize: Got here!\n")); - 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 WordPerfectImportFilter_getImplementationName () -throw (RuntimeException) -{ - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.WordPerfectImportFilter" ) ); -} - -#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" -#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" -sal_Bool SAL_CALL WordPerfectImportFilter_supportsService( const OUString &ServiceName ) -throw (RuntimeException) -{ - return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); -} -Sequence< OUString > SAL_CALL WordPerfectImportFilter_getSupportedServiceNames( ) -throw (RuntimeException) -{ - 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 - -uno::Reference< XInterface > SAL_CALL WordPerfectImportFilter_createInstance( const uno::Reference< XMultiServiceFactory > & rSMgr) -throw( Exception ) -{ - return (cppu::OWeakObject *) new WordPerfectImportFilter( rSMgr ); -} - -// XServiceInfo -OUString SAL_CALL WordPerfectImportFilter::getImplementationName( ) -throw (RuntimeException) -{ - return WordPerfectImportFilter_getImplementationName(); -} -sal_Bool SAL_CALL WordPerfectImportFilter::supportsService( const OUString &rServiceName ) -throw (RuntimeException) -{ - return WordPerfectImportFilter_supportsService( rServiceName ); -} -Sequence< OUString > SAL_CALL WordPerfectImportFilter::getSupportedServiceNames( ) -throw (RuntimeException) -{ - return WordPerfectImportFilter_getSupportedServiceNames(); -} - - -WordPerfectImportFilterDialog::WordPerfectImportFilterDialog(const ::com::sun::star::uno::Reference &r ) : - mxMSF( r ) {} - -WordPerfectImportFilterDialog::~WordPerfectImportFilterDialog() -{ -} - -void SAL_CALL WordPerfectImportFilterDialog::setTitle( const ::rtl::OUString & ) -throw (::com::sun::star::uno::RuntimeException) -{ -} - -sal_Int16 SAL_CALL WordPerfectImportFilterDialog::execute() -throw (::com::sun::star::uno::RuntimeException) -{ - WPXSvInputStream input( mxInputStream ); - - OString aUtf8Passwd; - - WPDConfidence confidence = WPDocument::isFileFormatSupported(&input); - - if (WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) - { - int unsuccessfulAttempts = 0; - while (true ) - { - SfxPasswordDialog aPasswdDlg(0); - aPasswdDlg.SetMinLen(0); - if(!aPasswdDlg.Execute()) - return com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL; - msPassword = ::rtl::OUString(aPasswdDlg.GetPassword().GetBuffer()); - aUtf8Passwd = OUStringToOString(msPassword, RTL_TEXTENCODING_UTF8); - if (WPD_PASSWORD_MATCH_OK == WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) - break; - else - unsuccessfulAttempts++; - if (unsuccessfulAttempts == 3) // timeout after 3 password atempts - return com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL; - } - } - return com::sun::star::ui::dialogs::ExecutableDialogResults::OK; -} - -uno::Sequence SAL_CALL WordPerfectImportFilterDialog::getPropertyValues() throw(uno::RuntimeException) -{ - uno::Sequence aRet(1); - beans::PropertyValue *pArray = aRet.getArray(); - - pArray[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Password") ); - pArray[0].Value <<= msPassword; - - return aRet; -} - -void SAL_CALL WordPerfectImportFilterDialog::setPropertyValues( const uno::Sequence& aProps) -throw(beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) -{ - const beans::PropertyValue *pPropArray = aProps.getConstArray(); - long nPropCount = aProps.getLength(); - for (long i = 0; i < nPropCount; i++) - { - const beans::PropertyValue &rProp = pPropArray[i]; - ::rtl::OUString aPropName = rProp.Name; - - if ( aPropName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Password")) ) - rProp.Value >>= msPassword; - else if ( aPropName == "InputStream" ) - rProp.Value >>= mxInputStream; - } -} - - -// XServiceInfo -OUString SAL_CALL WordPerfectImportFilterDialog::getImplementationName( ) -throw (RuntimeException) -{ - return WordPerfectImportFilterDialog_getImplementationName(); -} - -sal_Bool SAL_CALL WordPerfectImportFilterDialog::supportsService( const OUString &rServiceName ) -throw (RuntimeException) -{ - return WordPerfectImportFilterDialog_supportsService( rServiceName ); -} - -Sequence< OUString > SAL_CALL WordPerfectImportFilterDialog::getSupportedServiceNames( ) -throw (RuntimeException) -{ - return WordPerfectImportFilterDialog_getSupportedServiceNames(); -} - -OUString WordPerfectImportFilterDialog_getImplementationName () -throw (RuntimeException) -{ - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.WordPerfectImportFilterDialog" ) ); -} - -#define SERVICE_NAME "com.sun.star.ui.dialogs.FilterOptionsDialog" -sal_Bool SAL_CALL WordPerfectImportFilterDialog_supportsService( const OUString &ServiceName ) -throw (RuntimeException) -{ - return ( ServiceName == SERVICE_NAME ); -} - -Sequence< OUString > SAL_CALL WordPerfectImportFilterDialog_getSupportedServiceNames( ) -throw (RuntimeException) -{ - Sequence < OUString > aRet(1); - OUString *pArray = aRet.getArray(); - pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); - return aRet; -} -#undef SERVICE_NAME - -uno::Reference< XInterface > SAL_CALL WordPerfectImportFilterDialog_createInstance( const uno::Reference< XMultiServiceFactory > & rSMgr) -throw( Exception ) -{ - return (cppu::OWeakObject *) new WordPerfectImportFilterDialog( rSMgr ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/wpdimp/WordPerfectImportFilter.hxx b/writerperfect/source/wpdimp/WordPerfectImportFilter.hxx deleted file mode 100644 index 777be1d21577..000000000000 --- a/writerperfect/source/wpdimp/WordPerfectImportFilter.hxx +++ /dev/null @@ -1,176 +0,0 @@ -/* -*- 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 - * - * 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 _WORDPERFECTIMPORTFILTER_HXX -#define _WORDPERFECTIMPORTFILTER_HXX - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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 WordPerfectImportFilter : 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; - - sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) - throw (::com::sun::star::uno::RuntimeException); - -public: - WordPerfectImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) {} - virtual ~WordPerfectImportFilter() {} - - // 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 WordPerfectImportFilter_getImplementationName() -throw ( ::com::sun::star::uno::RuntimeException ); - -sal_Bool SAL_CALL WordPerfectImportFilter_supportsService( const ::rtl::OUString &ServiceName ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WordPerfectImportFilter_getSupportedServiceNames( ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL WordPerfectImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) -throw ( ::com::sun::star::uno::Exception ); - - -class WordPerfectImportFilterDialog : public cppu::WeakImplHelper3 < - com::sun::star::ui::dialogs::XExecutableDialog, - com::sun::star::lang::XServiceInfo, - com::sun::star::beans::XPropertyAccess - > -{ - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; - ::rtl::OUString msPassword; - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxInputStream; - - ~WordPerfectImportFilterDialog(); - - // XExecutableDialog - virtual void SAL_CALL setTitle( const ::rtl::OUString &aTitle ) - throw (::com::sun::star::uno::RuntimeException); - virtual sal_Int16 SAL_CALL execute() - throw (::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); - - // XPropertyAccess - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > - SAL_CALL getPropertyValues() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< - ::com::sun::star::beans::PropertyValue >& aProps ) - throw (::com::sun::star::beans::UnknownPropertyException, - ::com::sun::star::beans::PropertyVetoException, - ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException); - -public: - WordPerfectImportFilterDialog(const ::com::sun::star::uno::Reference &r ); - -}; - -::rtl::OUString WordPerfectImportFilterDialog_getImplementationName() -throw ( ::com::sun::star::uno::RuntimeException ); - -sal_Bool SAL_CALL WordPerfectImportFilterDialog_supportsService( const ::rtl::OUString &ServiceName ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WordPerfectImportFilterDialog_getSupportedServiceNames( ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL WordPerfectImportFilterDialog_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/wpdimp/wpft_genericfilter.cxx b/writerperfect/source/wpdimp/wpft_genericfilter.cxx deleted file mode 100644 index 5e0f141efe64..000000000000 --- a/writerperfect/source/wpdimp/wpft_genericfilter.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- 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 - -#include -#include -#include -#include - -#include "WordPerfectImportFilter.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 wpft_component_getFactory( - const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ ) - { - void *pRet = 0; - - OUString implName = OUString::createFromAscii( pImplName ); - if ( pServiceManager && implName.equals(WordPerfectImportFilter_getImplementationName()) ) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - WordPerfectImportFilter_createInstance, WordPerfectImportFilter_getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/wpgimp/WPGImportFilter.cxx b/writerperfect/source/wpgimp/WPGImportFilter.cxx deleted file mode 100644 index ff7612b1e433..000000000000 --- a/writerperfect/source/wpgimp/WPGImportFilter.cxx +++ /dev/null @@ -1,275 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* WPGImportFilter: 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 - * - * 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 -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "filter/DocumentHandler.hxx" -#include "filter/OdgGenerator.hxx" -#include "WPGImportFilter.hxx" -#include "stream/WPXSvStream.h" - -#include - -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 WPGImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::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 == "InputStream" ) - pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "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 = libwpg::WPGraphics::parse(&input, &exporter); - return tmpParseResult; -} - -void SAL_CALL WPGImportFilter::cancel( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::cancel" << std::endl; -#endif -} - -// XImporter -void SAL_CALL WPGImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) -throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::setTargetDocument" << std::endl; -#endif - mxDoc = xDoc; -} - -// XExtendedFilterDetection -OUString SAL_CALL WPGImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) -throw( com::sun::star::uno::RuntimeException ) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::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 == "TypeName" ) - location=i; - else if ( pValue[i].Name == "InputStream" ) - pValue[i].Value >>= xInputStream; - } - - WPXSvInputStream input( xInputStream ); - - if (libwpg::WPGraphics::isSupported(&input)) - sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "draw_WordPerfect_Graphics" ) ); - - if (!sTypeName.isEmpty()) - { - 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 WPGImportFilter::initialize( const Sequence< Any >& aArguments ) -throw (Exception, RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::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 == "Type" ) - { - pValue[i].Value >>= msFilterName; - break; - } - } - } -} -OUString WPGImportFilter_getImplementationName () -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter_getImplementationName" << std::endl; -#endif - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Draw.WPGImportFilter" ) ); -} - -#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" -#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" -sal_Bool SAL_CALL WPGImportFilter_supportsService( const OUString &ServiceName ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter_supportsService" << std::endl; -#endif - return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); -} -Sequence< OUString > SAL_CALL WPGImportFilter_getSupportedServiceNames( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter_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 WPGImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) -throw( Exception ) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter_createInstance" << std::endl; -#endif - return (cppu::OWeakObject *) new WPGImportFilter( rSMgr ); -} - -// XServiceInfo -OUString SAL_CALL WPGImportFilter::getImplementationName( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::getImplementationName" << std::endl; -#endif - return WPGImportFilter_getImplementationName(); -} -sal_Bool SAL_CALL WPGImportFilter::supportsService( const OUString &rServiceName ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::supportsService" << std::endl; -#endif - return WPGImportFilter_supportsService( rServiceName ); -} -Sequence< OUString > SAL_CALL WPGImportFilter::getSupportedServiceNames( ) -throw (RuntimeException) -{ -#ifdef DEBUG - std::cerr << "WPGImportFilter::getSupportedServiceNames" << std::endl; -#endif - return WPGImportFilter_getSupportedServiceNames(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/wpgimp/WPGImportFilter.hxx b/writerperfect/source/wpgimp/WPGImportFilter.hxx deleted file mode 100644 index 03fb1231d29f..000000000000 --- a/writerperfect/source/wpgimp/WPGImportFilter.hxx +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- 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 - * - * 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 _WPGIMPORTFILTER_HXX -#define _WPGIMPORTFILTER_HXX - -#include -#include -#include -#include -#include -#include -#include - -#include - -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 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 - > -{ -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; - -public: - WPGImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) {} - 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); - 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 WPGImportFilter_getImplementationName() -throw ( ::com::sun::star::uno::RuntimeException ); - -sal_Bool SAL_CALL WPGImportFilter_supportsService( const ::rtl::OUString &ServiceName ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WPGImportFilter_getSupportedServiceNames( ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL WPGImportFilter_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/wpgimp/wpgimport_genericfilter.cxx b/writerperfect/source/wpgimp/wpgimport_genericfilter.cxx deleted file mode 100644 index 22e99d89f7f9..000000000000 --- a/writerperfect/source/wpgimp/wpgimport_genericfilter.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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 - -#include -#include -#include - -#include - -#include "WPGImportFilter.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 wpgfilter_component_getFactory( - const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ ) - { - void *pRet = 0; - - OUString implName = OUString::createFromAscii( pImplName ); - if ( pServiceManager && implName.equals(WPGImportFilter_getImplementationName()) ) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - WPGImportFilter_createInstance, WPGImportFilter_getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/wpsimp/MSWorksImportFilter.cxx b/writerperfect/source/wpsimp/MSWorksImportFilter.cxx deleted file mode 100644 index 2cca078c7561..000000000000 --- a/writerperfect/source/wpsimp/MSWorksImportFilter.cxx +++ /dev/null @@ -1,277 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* MSWorksImportFilter: Sets up the filter, and calls DocumentCollector - * 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 Fridrich Strba - * - * 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 -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "filter/FilterInternal.hxx" -#include "filter/DocumentHandler.hxx" -#include "filter/OdtGenerator.hxx" -#include "stream/WPXSvStream.h" - -#include -#include "MSWorksImportFilter.hxx" - -// 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::ucb::XCommandEnvironment; - -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; - -void callHandler(Reference < XDocumentHandler > xDocHandler); - -sal_Bool SAL_CALL MSWorksImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) -throw (RuntimeException) -{ - WRITER_DEBUG_MSG(("MSWorksImportFilter::importImpl: Got here!\n")); - - 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 == "InputStream" ) - pValue[i].Value >>= xInputStream; - else if ( pValue[i].Name == "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.Writer.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 Document Handler: abstract class to handle document SAX messages, concrete implementation here - // writes to in-memory target doc - DocumentHandler xHandler(xInternalHandler); - - WPXSvInputStream input( xInputStream ); - - OdtGenerator collector(&xHandler, ODF_FLAT_XML); - if (WPS_OK == WPSDocument::parse(&input, &collector)) - return sal_True; - return sal_False; -} - -sal_Bool SAL_CALL MSWorksImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) -throw (RuntimeException) -{ - WRITER_DEBUG_MSG(("MSWorksImportFilter::filter: Got here!\n")); - return importImpl ( aDescriptor ); -} -void SAL_CALL MSWorksImportFilter::cancel( ) -throw (RuntimeException) -{ - WRITER_DEBUG_MSG(("MSWorksImportFilter::cancel: Got here!\n")); -} - -// XImporter -void SAL_CALL MSWorksImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) -throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) -{ - WRITER_DEBUG_MSG(("MSWorksImportFilter::getTargetDocument: Got here!\n")); - mxDoc = xDoc; -} - -// XExtendedFilterDetection -OUString SAL_CALL MSWorksImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) -throw( com::sun::star::uno::RuntimeException ) -{ - WRITER_DEBUG_MSG(("MSWorksImportFilter::detect: Got here!\n")); - - WPSConfidence confidence = WPS_CONFIDENCE_NONE; - OUString sTypeName; - sal_Int32 nLength = Descriptor.getLength(); - sal_Int32 location = nLength; - OUString sURL; - 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; - else if ( pValue[i].Name == "URL" ) - pValue[i].Value >>= sURL; - } - - Reference< com::sun::star::ucb::XCommandEnvironment > xEnv; - if (!xInputStream.is()) - { - try - { - ::ucbhelper::Content aContent(sURL, xEnv); - xInputStream = aContent.openStream(); - } - catch ( ... ) - { - return ::rtl::OUString(); - } - - if (!xInputStream.is()) - return ::rtl::OUString(); - } - - WPXSvInputStream input( xInputStream ); - - if (input.atEOS()) - return ::rtl::OUString(); - - confidence = WPSDocument::isFileFormatSupported(&input); - - if ((confidence == WPS_CONFIDENCE_EXCELLENT) || (confidence == WPS_CONFIDENCE_GOOD)) - sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer_MS_Works_Document" ) ); - - if (!sTypeName.isEmpty()) - { - 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 MSWorksImportFilter::initialize( const Sequence< Any >& aArguments ) -throw (Exception, RuntimeException) -{ - WRITER_DEBUG_MSG(("MSWorksImportFilter::initialize: Got here!\n")); - 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 MSWorksImportFilter_getImplementationName () -throw (RuntimeException) -{ - return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.MSWorksImportFilter" ) ); -} - -#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" -#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" -sal_Bool SAL_CALL MSWorksImportFilter_supportsService( const OUString &ServiceName ) -throw (RuntimeException) -{ - return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); -} -Sequence< OUString > SAL_CALL MSWorksImportFilter_getSupportedServiceNames( ) -throw (RuntimeException) -{ - 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 MSWorksImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) -throw( Exception ) -{ - return (cppu::OWeakObject *) new MSWorksImportFilter( rSMgr ); -} - -// XServiceInfo -OUString SAL_CALL MSWorksImportFilter::getImplementationName( ) -throw (RuntimeException) -{ - return MSWorksImportFilter_getImplementationName(); -} -sal_Bool SAL_CALL MSWorksImportFilter::supportsService( const OUString &rServiceName ) -throw (RuntimeException) -{ - return MSWorksImportFilter_supportsService( rServiceName ); -} -Sequence< OUString > SAL_CALL MSWorksImportFilter::getSupportedServiceNames( ) -throw (RuntimeException) -{ - return MSWorksImportFilter_getSupportedServiceNames(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/wpsimp/MSWorksImportFilter.hxx b/writerperfect/source/wpsimp/MSWorksImportFilter.hxx deleted file mode 100644 index 6ef54858dac4..000000000000 --- a/writerperfect/source/wpsimp/MSWorksImportFilter.hxx +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- 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 - * - * 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 _MSWORKSIMPORTFILTER_HXX -#define _MSWORKSIMPORTFILTER_HXX - -#include -#include -#include -#include -#include -#include -#include - -/* 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 MSWorksImportFilter : 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; - - sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) - throw (::com::sun::star::uno::RuntimeException); - -public: - MSWorksImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) - : mxMSF( rxMSF ) - {} - virtual ~MSWorksImportFilter() {} - - // 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 MSWorksImportFilter_getImplementationName() -throw ( ::com::sun::star::uno::RuntimeException ); - -sal_Bool SAL_CALL MSWorksImportFilter_supportsService( const ::rtl::OUString &ServiceName ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MSWorksImportFilter_getSupportedServiceNames( ) -throw ( ::com::sun::star::uno::RuntimeException ); - -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > -SAL_CALL MSWorksImportFilter_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/wpsimp/msworks_genericfilter.cxx b/writerperfect/source/wpsimp/msworks_genericfilter.cxx deleted file mode 100644 index ae9c701548c0..000000000000 --- a/writerperfect/source/wpsimp/msworks_genericfilter.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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 - -#include -#include -#include - -#include - -#include "MSWorksImportFilter.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 msworksfilter_component_getFactory( - const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ ) - { - void *pRet = 0; - - OUString implName = OUString::createFromAscii( pImplName ); - if ( pServiceManager && implName.equals(MSWorksImportFilter_getImplementationName()) ) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - MSWorksImportFilter_createInstance, MSWorksImportFilter_getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx new file mode 100644 index 000000000000..2cca078c7561 --- /dev/null +++ b/writerperfect/source/writer/MSWorksImportFilter.cxx @@ -0,0 +1,277 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* MSWorksImportFilter: Sets up the filter, and calls DocumentCollector + * 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 Fridrich Strba + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "filter/FilterInternal.hxx" +#include "filter/DocumentHandler.hxx" +#include "filter/OdtGenerator.hxx" +#include "stream/WPXSvStream.h" + +#include +#include "MSWorksImportFilter.hxx" + +// 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::ucb::XCommandEnvironment; + +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; + +void callHandler(Reference < XDocumentHandler > xDocHandler); + +sal_Bool SAL_CALL MSWorksImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ + WRITER_DEBUG_MSG(("MSWorksImportFilter::importImpl: Got here!\n")); + + 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 == "InputStream" ) + pValue[i].Value >>= xInputStream; + else if ( pValue[i].Name == "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.Writer.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 Document Handler: abstract class to handle document SAX messages, concrete implementation here + // writes to in-memory target doc + DocumentHandler xHandler(xInternalHandler); + + WPXSvInputStream input( xInputStream ); + + OdtGenerator collector(&xHandler, ODF_FLAT_XML); + if (WPS_OK == WPSDocument::parse(&input, &collector)) + return sal_True; + return sal_False; +} + +sal_Bool SAL_CALL MSWorksImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ + WRITER_DEBUG_MSG(("MSWorksImportFilter::filter: Got here!\n")); + return importImpl ( aDescriptor ); +} +void SAL_CALL MSWorksImportFilter::cancel( ) +throw (RuntimeException) +{ + WRITER_DEBUG_MSG(("MSWorksImportFilter::cancel: Got here!\n")); +} + +// XImporter +void SAL_CALL MSWorksImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc ) +throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) +{ + WRITER_DEBUG_MSG(("MSWorksImportFilter::getTargetDocument: Got here!\n")); + mxDoc = xDoc; +} + +// XExtendedFilterDetection +OUString SAL_CALL MSWorksImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) +throw( com::sun::star::uno::RuntimeException ) +{ + WRITER_DEBUG_MSG(("MSWorksImportFilter::detect: Got here!\n")); + + WPSConfidence confidence = WPS_CONFIDENCE_NONE; + OUString sTypeName; + sal_Int32 nLength = Descriptor.getLength(); + sal_Int32 location = nLength; + OUString sURL; + 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; + else if ( pValue[i].Name == "URL" ) + pValue[i].Value >>= sURL; + } + + Reference< com::sun::star::ucb::XCommandEnvironment > xEnv; + if (!xInputStream.is()) + { + try + { + ::ucbhelper::Content aContent(sURL, xEnv); + xInputStream = aContent.openStream(); + } + catch ( ... ) + { + return ::rtl::OUString(); + } + + if (!xInputStream.is()) + return ::rtl::OUString(); + } + + WPXSvInputStream input( xInputStream ); + + if (input.atEOS()) + return ::rtl::OUString(); + + confidence = WPSDocument::isFileFormatSupported(&input); + + if ((confidence == WPS_CONFIDENCE_EXCELLENT) || (confidence == WPS_CONFIDENCE_GOOD)) + sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer_MS_Works_Document" ) ); + + if (!sTypeName.isEmpty()) + { + 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 MSWorksImportFilter::initialize( const Sequence< Any >& aArguments ) +throw (Exception, RuntimeException) +{ + WRITER_DEBUG_MSG(("MSWorksImportFilter::initialize: Got here!\n")); + 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 MSWorksImportFilter_getImplementationName () +throw (RuntimeException) +{ + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.MSWorksImportFilter" ) ); +} + +#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" +#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" +sal_Bool SAL_CALL MSWorksImportFilter_supportsService( const OUString &ServiceName ) +throw (RuntimeException) +{ + return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); +} +Sequence< OUString > SAL_CALL MSWorksImportFilter_getSupportedServiceNames( ) +throw (RuntimeException) +{ + 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 MSWorksImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) +throw( Exception ) +{ + return (cppu::OWeakObject *) new MSWorksImportFilter( rSMgr ); +} + +// XServiceInfo +OUString SAL_CALL MSWorksImportFilter::getImplementationName( ) +throw (RuntimeException) +{ + return MSWorksImportFilter_getImplementationName(); +} +sal_Bool SAL_CALL MSWorksImportFilter::supportsService( const OUString &rServiceName ) +throw (RuntimeException) +{ + return MSWorksImportFilter_supportsService( rServiceName ); +} +Sequence< OUString > SAL_CALL MSWorksImportFilter::getSupportedServiceNames( ) +throw (RuntimeException) +{ + return MSWorksImportFilter_getSupportedServiceNames(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/writer/MSWorksImportFilter.hxx b/writerperfect/source/writer/MSWorksImportFilter.hxx new file mode 100644 index 000000000000..6ef54858dac4 --- /dev/null +++ b/writerperfect/source/writer/MSWorksImportFilter.hxx @@ -0,0 +1,112 @@ +/* -*- 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 + * + * 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 _MSWORKSIMPORTFILTER_HXX +#define _MSWORKSIMPORTFILTER_HXX + +#include +#include +#include +#include +#include +#include +#include + +/* 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 MSWorksImportFilter : 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; + + sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) + throw (::com::sun::star::uno::RuntimeException); + +public: + MSWorksImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) + : mxMSF( rxMSF ) + {} + virtual ~MSWorksImportFilter() {} + + // 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 MSWorksImportFilter_getImplementationName() +throw ( ::com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL MSWorksImportFilter_supportsService( const ::rtl::OUString &ServiceName ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL MSWorksImportFilter_getSupportedServiceNames( ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL MSWorksImportFilter_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/writer/WordPerfectImportFilter.cxx b/writerperfect/source/writer/WordPerfectImportFilter.cxx new file mode 100644 index 000000000000..f98d65e4b520 --- /dev/null +++ b/writerperfect/source/writer/WordPerfectImportFilter.cxx @@ -0,0 +1,461 @@ +/* -*- 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "filter/FilterInternal.hxx" +#include "filter/DocumentHandler.hxx" +#include "stream/WPXSvStream.h" + +#if defined _MSC_VER +#pragma warning( push, 1 ) +#endif +#include +#if defined _MSC_VER +#pragma warning( pop ) +#endif + +#include "filter/OdtGenerator.hxx" +#include "filter/OdgGenerator.hxx" +#include "WordPerfectImportFilter.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star; + +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::ucb::XCommandEnvironment; + +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; + +void callHandler(uno::Reference < XDocumentHandler > xDocHandler); + + +static bool handleEmbeddedWPGObject(const WPXBinaryData &data, OdfDocumentHandler *pHandler, const OdfStreamType streamType) +{ + OdgGenerator exporter(pHandler, streamType); + + libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; + + if (!libwpg::WPGraphics::isSupported(const_cast(data.getDataStream()))) + fileFormat = libwpg::WPG_WPG1; + + return libwpg::WPGraphics::parse(const_cast(data.getDataStream()), &exporter, fileFormat); +} + +static bool handleEmbeddedWPGImage(const WPXBinaryData &input, WPXBinaryData &output) +{ + WPXString svgOutput; + libwpg::WPGFileFormat fileFormat = libwpg::WPG_AUTODETECT; + + if (!libwpg::WPGraphics::isSupported(const_cast(input.getDataStream()))) + fileFormat = libwpg::WPG_WPG1; + + if (!libwpg::WPGraphics::generateSVG(const_cast(input.getDataStream()), svgOutput, fileFormat)) + return false; + + output.clear(); + output.append((unsigned char *)svgOutput.cstr(), strlen(svgOutput.cstr())); + return true; +} + +sal_Bool SAL_CALL WordPerfectImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ + WRITER_DEBUG_MSG(("WordPerfectImportFilter::importImpl: Got here!\n")); + + sal_Int32 nLength = aDescriptor.getLength(); + const PropertyValue *pValue = aDescriptor.getConstArray(); + OUString sURL; + uno::Reference < XInputStream > xInputStream; + for ( sal_Int32 i = 0 ; i < nLength; i++) + { + if ( pValue[i].Name == "InputStream" ) + pValue[i].Value >>= xInputStream; + else if ( pValue[i].Name == "URL" ) + pValue[i].Value >>= sURL; + } + if ( !xInputStream.is() ) + { + OSL_ASSERT( 0 ); + return sal_False; + } + + WPXSvInputStream input( xInputStream ); + + OString aUtf8Passwd; + + WPDConfidence confidence = WPDocument::isFileFormatSupported(&input); + + if (WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) + { + int unsuccessfulAttempts = 0; + while (true ) + { + SfxPasswordDialog aPasswdDlg( 0 ); + aPasswdDlg.SetMinLen(0); + if(!aPasswdDlg.Execute()) + return sal_False; + String aPasswd = aPasswdDlg.GetPassword(); + OUString aUniPasswd(aPasswd.GetBuffer() /*, aPasswd.Len(), RTL_TEXTENCODING_UCS2 */); + aUtf8Passwd = OUStringToOString(aUniPasswd, RTL_TEXTENCODING_UTF8); + if (WPD_PASSWORD_MATCH_OK == WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) + break; + else + unsuccessfulAttempts++; + if (unsuccessfulAttempts == 3) // timeout after 3 password atempts + return sal_False; + } + } + + // An XML import service: what we push sax messages to.. + OUString sXMLImportService ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.XMLOasisImporter" ) ); + uno::Reference < XDocumentHandler > xInternalHandler( mxMSF->createInstance( sXMLImportService ), UNO_QUERY ); + + // The XImporter sets up an empty target document for XDocumentHandler to write to.. + uno::Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY); + xImporter->setTargetDocument(mxDoc); + + // OO Document Handler: abstract class to handle document SAX messages, concrete implementation here + // writes to in-memory target doc + DocumentHandler xHandler(xInternalHandler); + + OdtGenerator collector(&xHandler, ODF_FLAT_XML); + collector.registerEmbeddedObjectHandler("image/x-wpg", &handleEmbeddedWPGObject); + collector.registerEmbeddedImageHandler("image/x-wpg", &handleEmbeddedWPGImage); + if (WPD_OK == WPDocument::parse(&input, &collector, aUtf8Passwd.isEmpty() ? 0 : aUtf8Passwd.getStr())) + return sal_True; + return sal_False; +} + +sal_Bool SAL_CALL WordPerfectImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) +throw (RuntimeException) +{ + WRITER_DEBUG_MSG(("WordPerfectImportFilter::filter: Got here!\n")); + return importImpl ( aDescriptor ); +} +void SAL_CALL WordPerfectImportFilter::cancel( ) +throw (RuntimeException) +{ + WRITER_DEBUG_MSG(("WordPerfectImportFilter::cancel: Got here!\n")); +} + +// XImporter +void SAL_CALL WordPerfectImportFilter::setTargetDocument( const uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) +throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException) +{ + WRITER_DEBUG_MSG(("WordPerfectImportFilter::getTargetDocument: Got here!\n")); + mxDoc = xDoc; +} + +// XExtendedFilterDetection +OUString SAL_CALL WordPerfectImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor ) +throw( com::sun::star::uno::RuntimeException ) +{ + WRITER_DEBUG_MSG(("WordPerfectImportFilter::detect: Got here!\n")); + + WPDConfidence confidence = WPD_CONFIDENCE_NONE; + OUString sTypeName; + sal_Int32 nLength = Descriptor.getLength(); + sal_Int32 location = nLength; + OUString sURL; + const PropertyValue *pValue = Descriptor.getConstArray(); + uno::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; + else if ( pValue[i].Name == "URL" ) + pValue[i].Value >>= sURL; + } + + uno::Reference< com::sun::star::ucb::XCommandEnvironment > xEnv; + if (!xInputStream.is()) + { + try + { + ::ucbhelper::Content aContent(sURL, xEnv); + xInputStream = aContent.openStream(); + } + catch ( ... ) + { + return ::rtl::OUString(); + } + + if (!xInputStream.is()) + return ::rtl::OUString(); + } + + WPXSvInputStream input( xInputStream ); + + if (input.atEOS()) + return ::rtl::OUString(); + + confidence = WPDocument::isFileFormatSupported(&input); + + if (confidence == WPD_CONFIDENCE_EXCELLENT || confidence == WPD_CONFIDENCE_SUPPORTED_ENCRYPTION) + sTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "writer_WordPerfect_Document" ) ); + + if (!sTypeName.isEmpty()) + { + 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 WordPerfectImportFilter::initialize( const Sequence< Any >& aArguments ) +throw (Exception, RuntimeException) +{ + WRITER_DEBUG_MSG(("WordPerfectImportFilter::initialize: Got here!\n")); + 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 WordPerfectImportFilter_getImplementationName () +throw (RuntimeException) +{ + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.WordPerfectImportFilter" ) ); +} + +#define SERVICE_NAME1 "com.sun.star.document.ImportFilter" +#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" +sal_Bool SAL_CALL WordPerfectImportFilter_supportsService( const OUString &ServiceName ) +throw (RuntimeException) +{ + return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 ); +} +Sequence< OUString > SAL_CALL WordPerfectImportFilter_getSupportedServiceNames( ) +throw (RuntimeException) +{ + 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 + +uno::Reference< XInterface > SAL_CALL WordPerfectImportFilter_createInstance( const uno::Reference< XMultiServiceFactory > & rSMgr) +throw( Exception ) +{ + return (cppu::OWeakObject *) new WordPerfectImportFilter( rSMgr ); +} + +// XServiceInfo +OUString SAL_CALL WordPerfectImportFilter::getImplementationName( ) +throw (RuntimeException) +{ + return WordPerfectImportFilter_getImplementationName(); +} +sal_Bool SAL_CALL WordPerfectImportFilter::supportsService( const OUString &rServiceName ) +throw (RuntimeException) +{ + return WordPerfectImportFilter_supportsService( rServiceName ); +} +Sequence< OUString > SAL_CALL WordPerfectImportFilter::getSupportedServiceNames( ) +throw (RuntimeException) +{ + return WordPerfectImportFilter_getSupportedServiceNames(); +} + + +WordPerfectImportFilterDialog::WordPerfectImportFilterDialog(const ::com::sun::star::uno::Reference &r ) : + mxMSF( r ) {} + +WordPerfectImportFilterDialog::~WordPerfectImportFilterDialog() +{ +} + +void SAL_CALL WordPerfectImportFilterDialog::setTitle( const ::rtl::OUString & ) +throw (::com::sun::star::uno::RuntimeException) +{ +} + +sal_Int16 SAL_CALL WordPerfectImportFilterDialog::execute() +throw (::com::sun::star::uno::RuntimeException) +{ + WPXSvInputStream input( mxInputStream ); + + OString aUtf8Passwd; + + WPDConfidence confidence = WPDocument::isFileFormatSupported(&input); + + if (WPD_CONFIDENCE_SUPPORTED_ENCRYPTION == confidence) + { + int unsuccessfulAttempts = 0; + while (true ) + { + SfxPasswordDialog aPasswdDlg(0); + aPasswdDlg.SetMinLen(0); + if(!aPasswdDlg.Execute()) + return com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL; + msPassword = ::rtl::OUString(aPasswdDlg.GetPassword().GetBuffer()); + aUtf8Passwd = OUStringToOString(msPassword, RTL_TEXTENCODING_UTF8); + if (WPD_PASSWORD_MATCH_OK == WPDocument::verifyPassword(&input, aUtf8Passwd.getStr())) + break; + else + unsuccessfulAttempts++; + if (unsuccessfulAttempts == 3) // timeout after 3 password atempts + return com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL; + } + } + return com::sun::star::ui::dialogs::ExecutableDialogResults::OK; +} + +uno::Sequence SAL_CALL WordPerfectImportFilterDialog::getPropertyValues() throw(uno::RuntimeException) +{ + uno::Sequence aRet(1); + beans::PropertyValue *pArray = aRet.getArray(); + + pArray[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Password") ); + pArray[0].Value <<= msPassword; + + return aRet; +} + +void SAL_CALL WordPerfectImportFilterDialog::setPropertyValues( const uno::Sequence& aProps) +throw(beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + const beans::PropertyValue *pPropArray = aProps.getConstArray(); + long nPropCount = aProps.getLength(); + for (long i = 0; i < nPropCount; i++) + { + const beans::PropertyValue &rProp = pPropArray[i]; + ::rtl::OUString aPropName = rProp.Name; + + if ( aPropName == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Password")) ) + rProp.Value >>= msPassword; + else if ( aPropName == "InputStream" ) + rProp.Value >>= mxInputStream; + } +} + + +// XServiceInfo +OUString SAL_CALL WordPerfectImportFilterDialog::getImplementationName( ) +throw (RuntimeException) +{ + return WordPerfectImportFilterDialog_getImplementationName(); +} + +sal_Bool SAL_CALL WordPerfectImportFilterDialog::supportsService( const OUString &rServiceName ) +throw (RuntimeException) +{ + return WordPerfectImportFilterDialog_supportsService( rServiceName ); +} + +Sequence< OUString > SAL_CALL WordPerfectImportFilterDialog::getSupportedServiceNames( ) +throw (RuntimeException) +{ + return WordPerfectImportFilterDialog_getSupportedServiceNames(); +} + +OUString WordPerfectImportFilterDialog_getImplementationName () +throw (RuntimeException) +{ + return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.WordPerfectImportFilterDialog" ) ); +} + +#define SERVICE_NAME "com.sun.star.ui.dialogs.FilterOptionsDialog" +sal_Bool SAL_CALL WordPerfectImportFilterDialog_supportsService( const OUString &ServiceName ) +throw (RuntimeException) +{ + return ( ServiceName == SERVICE_NAME ); +} + +Sequence< OUString > SAL_CALL WordPerfectImportFilterDialog_getSupportedServiceNames( ) +throw (RuntimeException) +{ + Sequence < OUString > aRet(1); + OUString *pArray = aRet.getArray(); + pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + return aRet; +} +#undef SERVICE_NAME + +uno::Reference< XInterface > SAL_CALL WordPerfectImportFilterDialog_createInstance( const uno::Reference< XMultiServiceFactory > & rSMgr) +throw( Exception ) +{ + return (cppu::OWeakObject *) new WordPerfectImportFilterDialog( rSMgr ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/writer/WordPerfectImportFilter.hxx b/writerperfect/source/writer/WordPerfectImportFilter.hxx new file mode 100644 index 000000000000..777be1d21577 --- /dev/null +++ b/writerperfect/source/writer/WordPerfectImportFilter.hxx @@ -0,0 +1,176 @@ +/* -*- 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 + * + * 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 _WORDPERFECTIMPORTFILTER_HXX +#define _WORDPERFECTIMPORTFILTER_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 WordPerfectImportFilter : 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; + + sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor ) + throw (::com::sun::star::uno::RuntimeException); + +public: + WordPerfectImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF) + : mxMSF( rxMSF ) {} + virtual ~WordPerfectImportFilter() {} + + // 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 WordPerfectImportFilter_getImplementationName() +throw ( ::com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL WordPerfectImportFilter_supportsService( const ::rtl::OUString &ServiceName ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WordPerfectImportFilter_getSupportedServiceNames( ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL WordPerfectImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) +throw ( ::com::sun::star::uno::Exception ); + + +class WordPerfectImportFilterDialog : public cppu::WeakImplHelper3 < + com::sun::star::ui::dialogs::XExecutableDialog, + com::sun::star::lang::XServiceInfo, + com::sun::star::beans::XPropertyAccess + > +{ + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + ::rtl::OUString msPassword; + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > mxInputStream; + + ~WordPerfectImportFilterDialog(); + + // XExecutableDialog + virtual void SAL_CALL setTitle( const ::rtl::OUString &aTitle ) + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL execute() + throw (::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); + + // XPropertyAccess + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + SAL_CALL getPropertyValues() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& aProps ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +public: + WordPerfectImportFilterDialog(const ::com::sun::star::uno::Reference &r ); + +}; + +::rtl::OUString WordPerfectImportFilterDialog_getImplementationName() +throw ( ::com::sun::star::uno::RuntimeException ); + +sal_Bool SAL_CALL WordPerfectImportFilterDialog_supportsService( const ::rtl::OUString &ServiceName ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL WordPerfectImportFilterDialog_getSupportedServiceNames( ) +throw ( ::com::sun::star::uno::RuntimeException ); + +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL WordPerfectImportFilterDialog_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/writer/wpftwriter_genericfilter.cxx b/writerperfect/source/writer/wpftwriter_genericfilter.cxx new file mode 100644 index 000000000000..75f53f3969b0 --- /dev/null +++ b/writerperfect/source/writer/wpftwriter_genericfilter.cxx @@ -0,0 +1,81 @@ +/* -*- 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 + +#include +#include +#include +#include + +#include "WordPerfectImportFilter.hxx" +#include "MSWorksImportFilter.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 wpftwriter_component_getFactory( + const sal_Char *pImplName, void *pServiceManager, void * /* pRegistryKey */ ) + { + void *pRet = 0; + + OUString implName = OUString::createFromAscii( pImplName ); + if ( pServiceManager && implName.equals(WordPerfectImportFilter_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + WordPerfectImportFilter_createInstance, WordPerfectImportFilter_getSupportedServiceNames() ) ); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + if ( pServiceManager && implName.equals(MSWorksImportFilter_getImplementationName()) ) + { + Reference< XSingleServiceFactory > xFactory( createSingleFactory( + reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), + OUString::createFromAscii( pImplName ), + MSWorksImportFilter_createInstance, MSWorksImportFilter_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 deleted file mode 100644 index 902bf9a87123..000000000000 --- a/writerperfect/util/cdrfilter.component +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/writerperfect/util/msworksfilter.component b/writerperfect/util/msworksfilter.component deleted file mode 100644 index 8fc2120a7f02..000000000000 --- a/writerperfect/util/msworksfilter.component +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/writerperfect/util/visiofilter.component b/writerperfect/util/visiofilter.component deleted file mode 100644 index a1842d992603..000000000000 --- a/writerperfect/util/visiofilter.component +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/writerperfect/util/wpft.component b/writerperfect/util/wpft.component deleted file mode 100644 index 57cb3a429ff0..000000000000 --- a/writerperfect/util/wpft.component +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/writerperfect/util/wpftdraw.component b/writerperfect/util/wpftdraw.component new file mode 100644 index 000000000000..a8a262467231 --- /dev/null +++ b/writerperfect/util/wpftdraw.component @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + diff --git a/writerperfect/util/wpftwriter.component b/writerperfect/util/wpftwriter.component new file mode 100644 index 000000000000..d6a0f042dd48 --- /dev/null +++ b/writerperfect/util/wpftwriter.component @@ -0,0 +1,39 @@ + + + + + + + + + + + + + diff --git a/writerperfect/util/wpgfilter.component b/writerperfect/util/wpgfilter.component deleted file mode 100644 index 236d98ed683f..000000000000 --- a/writerperfect/util/wpgfilter.component +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - -- cgit