diff options
176 files changed, 3 insertions, 23813 deletions
diff --git a/bin/distro-install-desktop-integration b/bin/distro-install-desktop-integration index ab7da92f173b..e925924d0f0e 100755 --- a/bin/distro-install-desktop-integration +++ b/bin/distro-install-desktop-integration @@ -122,7 +122,6 @@ rm -rf $sysui_temp # we do not want some stuff from the plain packages rm -f $DESTDIR/$PREFIXDIR/bin/$INSTALLDIRNAME-printeradmin -rm -f $DESTDIR$PREFIXDIR/share/applications/libreoffice-javafilter.desktop rm -f $DESTDIR$PREFIXDIR/share/applications/libreoffice-printeradmin.desktop if test -d $DESTDIR/opt ; then rm -f $DESTDIR/opt/$INSTALLDIRNAME diff --git a/bin/distro-install-file-lists b/bin/distro-install-file-lists index a902107a6f1b..d83855b738cc 100755 --- a/bin/distro-install-file-lists +++ b/bin/distro-install-file-lists @@ -132,7 +132,6 @@ if test "z$OOO_VENDOR" != "zDebian" ; then if test "z$OOO_VENDOR" = "zMandriva" ; then merge_flists gid_Module_Optional_Grfflt $FILELISTSDIR/draw_list.txt merge_flists gid_Module_Optional_Headless $FILELISTSDIR/common_list.txt - merge_flists gid_Module_Optional_Javafilter $FILELISTSDIR/common_list.txt merge_flists gid_Module_Optional_Pymailmerge $FILELISTSDIR/pyuno_list.txt merge_flists gid_Module_Optional_Pyuno $FILELISTSDIR/pyuno_list.txt merge_flists gid_Module_Optional_Extensions_Script_Provider_For_Python $FILELISTSDIR/pyuno_list.txt @@ -141,7 +140,6 @@ if test "z$OOO_VENDOR" != "zDebian" ; then else merge_flists gid_Module_Optional_Grfflt $FILELISTSDIR/common_list.txt merge_flists gid_Module_Optional_Headless $FILELISTSDIR/common_list.txt - merge_flists gid_Module_Optional_Javafilter $FILELISTSDIR/filters_list.txt merge_flists gid_Module_Optional_Pymailmerge $FILELISTSDIR/mailmerge_list.txt merge_flists gid_Module_Optional_Pyuno $FILELISTSDIR/pyuno_list.txt merge_flists gid_Module_Optional_Pyuno_LibreLogo $FILELISTSDIR/pyuno_list.txt @@ -151,7 +149,6 @@ if test "z$OOO_VENDOR" != "zDebian" ; then else merge_flists gid_Module_Optional_Grfflt $FILELISTSDIR/common_list.txt merge_flists gid_Module_Optional_Headless $FILELISTSDIR/common_list.txt - merge_flists gid_Module_Optional_Javafilter $FILELISTSDIR/common_list.txt merge_flists gid_Module_Optional_Pymailmerge $FILELISTSDIR/common_list.txt merge_flists gid_Module_Optional_Pyuno $FILELISTSDIR/common_list.txt merge_flists gid_Module_Optional_Pyuno_LibreLogo $FILELISTSDIR/common_list.txt @@ -403,7 +400,6 @@ else create_package_directory gid_Module_Root_Files_Images pkg/libreoffice-common create_package_directory gid_Module_Oo_Linguistic pkg/libreoffice-common create_package_directory gid_Module_Optional_Xsltfiltersamples pkg/libreoffice-common - create_package_directory gid_Module_Optional_Javafilter pkg/libreoffice-common create_package_directory gid_Module_Optional_Grfflt pkg/libreoffice-draw create_package_directory gid_Module_Prg_Calc_Bin pkg/libreoffice-calc create_package_directory gid_Module_Prg_Math_Bin pkg/libreoffice-math diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk index 4cf025d2c0c6..c37d4ad50f90 100644 --- a/filter/Configuration_filter.mk +++ b/filter/Configuration_filter.mk @@ -878,33 +878,6 @@ $(call filter_Configuration_add_internal_filters,fcfg_langpack,fcfg_internalgrap xpm_Import \ ) -# fcfg_palm -$(call filter_Configuration_add_types,fcfg_langpack,fcfg_palm_types.xcu,filter/source/config/fragments/types,\ - writer_AportisDoc_PalmDB_File \ -) - -$(call filter_Configuration_add_filters,fcfg_langpack,fcfg_palm_filters.xcu,filter/source/config/fragments/filters,\ - AportisDoc_Palm_DB \ -) - -# fcfg_pocketexcel -$(call filter_Configuration_add_types,fcfg_langpack,fcfg_pocketexcel_types.xcu,filter/source/config/fragments/types,\ - calc_Pocket_Excel_File \ -) - -$(call filter_Configuration_add_filters,fcfg_langpack,fcfg_pocketexcel_filters.xcu,filter/source/config/fragments/filters,\ - Pocket_Excel \ -) - -# fcfg_pocketword -$(call filter_Configuration_add_types,fcfg_langpack,fcfg_pocketword_types.xcu,filter/source/config/fragments/types,\ - writer_PocketWord_File \ -) - -$(call filter_Configuration_add_filters,fcfg_langpack,fcfg_pocketword_filters.xcu,filter/source/config/fragments/filters,\ - PocketWord_File \ -) - # fcfg_xslt $(call filter_Configuration_add_types,fcfg_langpack,fcfg_xslt_types.xcu,filter/source/config/fragments/types,\ calc_ODS_FlatXML \ diff --git a/filter/source/config/fragments/filters/AportisDoc_Palm_DB.xcu b/filter/source/config/fragments/filters/AportisDoc_Palm_DB.xcu deleted file mode 100644 index 1ef8017faa41..000000000000 --- a/filter/source/config/fragments/filters/AportisDoc_Palm_DB.xcu +++ /dev/null @@ -1,30 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="AportisDoc Palm DB" oor:op="replace"> - <prop oor:name="FileFormatVersion"><value>0</value></prop> - <prop oor:name="Type"><value>writer_AportisDoc_PalmDB_File</value></prop> - <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UserData"><value>com.sun.star.documentconversion.XMergeBridge classes/aportisdoc.jar com.sun.star.comp.Writer.XMLImporter com.sun.star.comp.Writer.XMLExporter staroffice/sxw application/x-aportisdoc</value></prop> - <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop> - <prop oor:name="TemplateName"/> - <prop oor:name="UIName"> - <value>AportisDoc (Palm)</value> - </prop> - <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> - </node> diff --git a/filter/source/config/fragments/filters/MiniCalc__Palm_.xcu b/filter/source/config/fragments/filters/MiniCalc__Palm_.xcu deleted file mode 100644 index 6d3797c994bc..000000000000 --- a/filter/source/config/fragments/filters/MiniCalc__Palm_.xcu +++ /dev/null @@ -1,30 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="MiniCalc (Palm)" oor:op="replace"> - <prop oor:name="FileFormatVersion"><value>1</value></prop> - <prop oor:name="Type"><value>calc_MiniCalc_PalmDB_File</value></prop> - <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UserData"><value>com.sun.star.documentconversion.XMergeBridge classes/minicalc.jar com.sun.star.comp.Calc.XMLImporter com.sun.star.comp.Calc.XMLExporter staroffice/sxc application/x-minicalc</value></prop> - <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop> - <prop oor:name="TemplateName"/> - <prop oor:name="UIName"> - <value>MiniCalc (Palm)</value> - </prop> - <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> - </node> diff --git a/filter/source/config/fragments/filters/PocketWord_File.xcu b/filter/source/config/fragments/filters/PocketWord_File.xcu deleted file mode 100644 index aeee0494e1a8..000000000000 --- a/filter/source/config/fragments/filters/PocketWord_File.xcu +++ /dev/null @@ -1,30 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="PocketWord File" oor:op="replace"> - <prop oor:name="FileFormatVersion"><value>0</value></prop> - <prop oor:name="Type"><value>writer_PocketWord_File</value></prop> - <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UserData"><value>com.sun.star.documentconversion.XMergeBridge classes/pocketword.jar com.sun.star.comp.Writer.XMLImporter com.sun.star.comp.Writer.XMLExporter staroffice/sxw application/x-pocket-word</value></prop> - <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop> - <prop oor:name="TemplateName"/> - <prop oor:name="UIName"> - <value>Pocket Word</value> - </prop> - <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> - </node> diff --git a/filter/source/config/fragments/filters/Pocket_Excel.xcu b/filter/source/config/fragments/filters/Pocket_Excel.xcu deleted file mode 100644 index ae698a62f0ef..000000000000 --- a/filter/source/config/fragments/filters/Pocket_Excel.xcu +++ /dev/null @@ -1,30 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="Pocket Excel" oor:op="replace"> - <prop oor:name="FileFormatVersion"><value>1</value></prop> - <prop oor:name="Type"><value>calc_Pocket_Excel_File</value></prop> - <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop> - <prop oor:name="UIComponent"/> - <prop oor:name="UserData"><value>com.sun.star.documentconversion.XMergeBridge classes/pexcel.jar com.sun.star.comp.Calc.XMLImporter com.sun.star.comp.Calc.XMLExporter staroffice/sxc application/x-pocket-excel</value></prop> - <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop> - <prop oor:name="TemplateName"/> - <prop oor:name="UIName"> - <value>Pocket Excel</value> - </prop> - <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop> - </node> diff --git a/filter/source/config/fragments/types/calc_MiniCalc_PalmDB_File.xcu b/filter/source/config/fragments/types/calc_MiniCalc_PalmDB_File.xcu deleted file mode 100644 index 6b94ffdae596..000000000000 --- a/filter/source/config/fragments/types/calc_MiniCalc_PalmDB_File.xcu +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="calc_MiniCalc_PalmDB_File" oor:op="replace" > - <prop oor:name="DetectService"/> - <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>pdb</value></prop> - <prop oor:name="MediaType"/> - <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"><value>MiniCalc (Palm)</value></prop> - <prop oor:name="UIName"> - <value>MiniCalc (Palm)</value> - </prop> - <prop oor:name="ClipboardFormat"/> - </node> diff --git a/filter/source/config/fragments/types/calc_Pocket_Excel_File.xcu b/filter/source/config/fragments/types/calc_Pocket_Excel_File.xcu deleted file mode 100644 index ed710ab7e2c7..000000000000 --- a/filter/source/config/fragments/types/calc_Pocket_Excel_File.xcu +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="calc_Pocket_Excel_File" oor:op="replace" > - <prop oor:name="DetectService"/> - <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>pxl</value></prop> - <prop oor:name="MediaType"/> - <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"><value>Pocket Excel</value></prop> - <prop oor:name="UIName"> - <value>Pocket Excel</value> - </prop> - <prop oor:name="ClipboardFormat"/> - </node> diff --git a/filter/source/config/fragments/types/writer_AportisDoc_PalmDB_File.xcu b/filter/source/config/fragments/types/writer_AportisDoc_PalmDB_File.xcu deleted file mode 100644 index 9384437d2531..000000000000 --- a/filter/source/config/fragments/types/writer_AportisDoc_PalmDB_File.xcu +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="writer_AportisDoc_PalmDB_File" oor:op="replace" > - <prop oor:name="DetectService"><value>com.sun.star.comp.filters.XMLFilterDetect</value></prop> - <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>pdb</value></prop> - <prop oor:name="MediaType"><value>application/x-aportisdoc</value></prop> - <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"><value>AportisDoc Palm DB</value></prop> - <prop oor:name="UIName"> - <value>AportisDoc (Palm)</value> - </prop> - <prop oor:name="ClipboardFormat"><value>doctype:TEXt</value></prop> - </node> diff --git a/filter/source/config/fragments/types/writer_PocketWord_File.xcu b/filter/source/config/fragments/types/writer_PocketWord_File.xcu deleted file mode 100644 index d07a362ea369..000000000000 --- a/filter/source/config/fragments/types/writer_PocketWord_File.xcu +++ /dev/null @@ -1,29 +0,0 @@ -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <node oor:name="writer_PocketWord_File" oor:op="replace" > - <prop oor:name="DetectService"><value>com.sun.star.comp.filters.XMLFilterDetect</value></prop> - <prop oor:name="URLPattern"/> - <prop oor:name="Extensions"><value>psw</value></prop> - <prop oor:name="MediaType"><value>application/x-pocket-word</value></prop> - <prop oor:name="Preferred"><value>false</value></prop> - <prop oor:name="PreferredFilter"><value>PocketWord File</value></prop> - <prop oor:name="UIName"> - <value>Pocket Word</value> - </prop> - <prop oor:name="ClipboardFormat"><value>doctype:pwi</value></prop> - </node> diff --git a/postprocess/CustomTarget_registry.mk b/postprocess/CustomTarget_registry.mk index b88e4ef44db2..181c78247ab1 100644 --- a/postprocess/CustomTarget_registry.mk +++ b/postprocess/CustomTarget_registry.mk @@ -32,9 +32,6 @@ postprocess_XCDS := \ lingucomponent.xcd \ main.xcd \ math.xcd \ - palm.xcd \ - pocketexcel.xcd \ - pocketword.xcd \ pyuno.xcd \ writer.xcd \ xsltfilter.xcd @@ -366,21 +363,6 @@ postprocess_FILES_math := \ $(postprocess_MOD)/org/openoffice/Office/Embedding-math.xcu \ $(postprocess_MOD)/org/openoffice/Setup-math.xcu -postprocess_DEPS_palm := main -postprocess_FILES_palm := \ - $(postprocess_MOD)/fcfg_palm_filters.xcu \ - $(postprocess_MOD)/fcfg_palm_types.xcu - -postprocess_DEPS_pocketexcel := main -postprocess_FILES_pocketexcel := \ - $(postprocess_MOD)/fcfg_pocketexcel_filters.xcu \ - $(postprocess_MOD)/fcfg_pocketexcel_types.xcu - -postprocess_DEPS_pocketword := main -postprocess_FILES_pocketword := \ - $(postprocess_MOD)/fcfg_pocketword_filters.xcu \ - $(postprocess_MOD)/fcfg_pocketword_types.xcu - postprocess_DEPS_pyuno := main postprocess_FILES_pyuno := \ $(postprocess_MOD)/org/openoffice/Office/Scripting-python.xcu diff --git a/scp2/InstallModule_javafilter.mk b/scp2/InstallModule_javafilter.mk deleted file mode 100644 index ce2210937b3c..000000000000 --- a/scp2/InstallModule_javafilter.mk +++ /dev/null @@ -1,47 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# Major Contributor(s): -# Copyright (C) 2012 Red Hat, Inc., David Tardon <dtardon@redhat.com> -# (initial developer) -# -# All Rights Reserved. -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. - -$(eval $(call gb_InstallModule_InstallModule,scp2/javafilter)) - -$(eval $(call gb_InstallModule_add_defs,scp2/javafilter,\ - $(if $(WINDOWS_SDK_HOME),\ - -DHAVE_WINDOWS_SDK \ - ) \ -)) - -$(eval $(call gb_InstallModule_add_scpfiles,scp2/javafilter,\ - scp2/source/javafilter/file_javafilter \ -)) - -$(eval $(call gb_InstallModule_add_localized_scpfiles,scp2/javafilter,\ - scp2/source/javafilter/module_javafilter \ - $(if $(filter WNT,$(OS)),\ - scp2/source/javafilter/registryitem_javafilter \ - ) \ -)) - -# vim: set shiftwidth=4 tabstop=4 noexpandtab: diff --git a/scp2/InstallScript_setup_osl.mk b/scp2/InstallScript_setup_osl.mk index 166ab4268d5f..7dd47590d080 100644 --- a/scp2/InstallScript_setup_osl.mk +++ b/scp2/InstallScript_setup_osl.mk @@ -58,9 +58,6 @@ $(eval $(call gb_InstallScript_use_modules,setup_osl,\ $(if $(filter TRUE,$(ENABLE_EVOAB2) $(ENABLE_GCONF) $(ENABLE_GNOMEVFS) $(ENABLE_GIO) $(ENABLE_GTK) $(ENABLE_GTK3)),\ scp2/gnome \ ) \ - $(if $(filter TRUE,$(SOLAR_JAVA)),\ - scp2/javafilter \ - ) \ $(if $(filter TRUE,$(ENABLE_KDE) $(ENABLE_KDE4)),\ scp2/kde \ ) \ diff --git a/scp2/Module_scp2.mk b/scp2/Module_scp2.mk index e2b92b4c9af7..4d12b8f8a3f9 100644 --- a/scp2/Module_scp2.mk +++ b/scp2/Module_scp2.mk @@ -64,9 +64,6 @@ $(eval $(call gb_Module_add_targets,scp2,\ $(if $(filter TRUE,$(ENABLE_EVOAB2) $(ENABLE_GCONF) $(ENABLE_GNOMEVFS) $(ENABLE_GIO) $(ENABLE_GTK) $(ENABLE_GTK3)),\ InstallModule_gnome \ ) \ - $(if $(filter TRUE,$(SOLAR_JAVA)),\ - InstallModule_javafilter \ - ) \ $(if $(filter TRUE,$(ENABLE_KDE) $(ENABLE_KDE4)),\ InstallModule_kde \ ) \ diff --git a/scp2/source/javafilter/file_javafilter.scp b/scp2/source/javafilter/file_javafilter.scp deleted file mode 100644 index 906bf06fe604..000000000000 --- a/scp2/source/javafilter/file_javafilter.scp +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "macros.inc" - -#ifdef WNT - -File gid_File_Lib_Xmergesync - LIB_FILE_BODY; - Styles = (PACKED); - Dir = SCP2_OOO_BIN_DIR; - Name = "xmergesync.dll"; -End - -#endif - -#if defined(WNT) && defined(HAVE_WINDOWS_SDK) - -File gid_File_Lib_Jfregca - LIB_FILE_BODY; - Styles = (PACKED, BINARYTABLE, BINARYTABLE_ONLY); - Dir = SCP2_OOO_BIN_DIR; - Name = "jfregca.dll"; -End - -#endif - -File gid_File_Share_Registry_Palm_Xcd - TXT_FILE_BODY; - Styles = (PACKED); - Dir = gid_Brand_Dir_Share_Registry; - Name = "palm.xcd"; -End - -File gid_File_Share_Registry_Pocketexcel_Xcd - TXT_FILE_BODY; - Styles = (PACKED); - Dir = gid_Brand_Dir_Share_Registry; - Name = "pocketexcel.xcd"; -End - -File gid_File_Share_Registry_Pocketword_Xcd - TXT_FILE_BODY; - Styles = (PACKED); - Dir = gid_Brand_Dir_Share_Registry; - Name = "pocketword.xcd"; -End - -#ifdef SOLAR_JAVA - -STD_JAR_FILE( gid_File_Jar_Aportisdoc, aportisdoc ) -STD_JAR_FILE( gid_File_Jar_Pexcel, pexcel ) -STD_JAR_FILE( gid_File_Jar_Pocketword, pocketword ) -STD_JAR_FILE( gid_File_Jar_Xmerge, xmerge ) -STD_JAR_FILE( gid_File_Jar_Xmergebridge, XMergeBridge ) - -#endif diff --git a/scp2/source/javafilter/module_javafilter.scp b/scp2/source/javafilter/module_javafilter.scp deleted file mode 100644 index dd69d014caf7..000000000000 --- a/scp2/source/javafilter/module_javafilter.scp +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "macros.inc" - -Module gid_Module_Optional_Javafilter - PackageInfo = "packinfo_office.txt"; - MOD_NAME_DESC(MODULE_OPTIONAL_JAVAFILTER); - Sortkey = "900"; - ParentID = gid_Module_Optional; - Files = ( gid_File_Lib_Jfregca ); - Minimal = NO; - Default = NO; - Styles (en-US) = (); - Styles (de) = (); - Styles (ja) = (HIDDEN_ROOT); - Styles (ko) = (HIDDEN_ROOT); - Styles (zh-CN) = (HIDDEN_ROOT); - Styles (zh-TW) = (HIDDEN_ROOT); -End - -Module gid_Module_Optional_Javafilter_Palm - MOD_NAME_DESC(MODULE_OPTIONAL_JAVAFILTER_PALM); - ParentID = gid_Module_Optional_Javafilter; - Sortkey = "100"; - Minimal = NO; - Default = NO; - Styles (en-US) = (); - Styles (de) = (); - Styles (ja) = (HIDDEN_ROOT); - Styles (ko) = (HIDDEN_ROOT); - Styles (zh-CN) = (HIDDEN_ROOT); - Styles (zh-TW) = (HIDDEN_ROOT); -End - -Module gid_Module_Optional_Javafilter_Palm_Aportisdoc - MOD_NAME_DESC(MODULE_OPTIONAL_JAVAFILTER_PALM_APORTISDOC); - ParentID = gid_Module_Optional_Javafilter_Palm; - Files = ( gid_File_Jar_Aportisdoc, gid_File_Share_Registry_Palm_Xcd ); - Sortkey = "100"; - Minimal = NO; - Default = NO; - Styles (en-US) = (); - Styles (de) = (); - Styles (ja) = (HIDDEN_ROOT); - Styles (ko) = (HIDDEN_ROOT); - Styles (zh-CN) = (HIDDEN_ROOT); - Styles (zh-TW) = (HIDDEN_ROOT); -End - -Module gid_Module_Optional_Javafilter_Pocketpc - ALL_LANG(Name,STR_NAME_MODULE_OPTIONAL_JAVAFILTER_POCKETPC); - #ifdef WNT - ALL_LANG(Description,STR_DESC_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_WNT); - #else - ALL_LANG(Description,STR_DESC_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_UNIX); - #endif - ParentID = gid_Module_Optional_Javafilter; - Sortkey = "200"; - Files = ( gid_File_Lib_Xmergesync ); - Minimal = NO; - Default = NO; - Styles (en-US) = (); - Styles (de) = (); - Styles (ja) = (HIDDEN_ROOT); - Styles (ko) = (HIDDEN_ROOT); - Styles (zh-CN) = (HIDDEN_ROOT); - Styles (zh-TW) = (HIDDEN_ROOT); -End - -Module gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word - MOD_NAME_DESC(MODULE_OPTIONAL_JAVAFILTER_POCKETPC_POCKET_WORD); - ParentID = gid_Module_Optional_Javafilter_Pocketpc; - Sortkey = "100"; - Files = ( gid_File_Lib_Xmergesync,gid_File_Jar_Pocketword, gid_File_Share_Registry_Pocketword_Xcd, gid_File_Tmp_Userinstall_Pocketpcword_Inf ); - Minimal = NO; - Default = NO; - Styles (en-US) = (); - Styles (de) = (); - Styles (ja) = (HIDDEN_ROOT); - Styles (ko) = (HIDDEN_ROOT); - Styles (zh-CN) = (HIDDEN_ROOT); - Styles (zh-TW) = (HIDDEN_ROOT); -End - -Module gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel - MOD_NAME_DESC(MODULE_OPTIONAL_JAVAFILTER_POCKETPC_POCKET_EXCEL); - ParentID = gid_Module_Optional_Javafilter_Pocketpc; - Sortkey = "200"; - Files = ( gid_File_Lib_Xmergesync,gid_File_Jar_Pexcel, gid_File_Share_Registry_Pocketexcel_Xcd, gid_File_Tmp_Userinstall_Pocketpcexcel_Inf ); - Minimal = NO; - Default = NO; - Styles (en-US) = (); - Styles (de) = (); - Styles (ja) = (HIDDEN_ROOT); - Styles (ko) = (HIDDEN_ROOT); - Styles (zh-CN) = (HIDDEN_ROOT); - Styles (zh-TW) = (HIDDEN_ROOT); -End diff --git a/scp2/source/javafilter/module_javafilter.ulf b/scp2/source/javafilter/module_javafilter.ulf deleted file mode 100644 index cca3a5ef9be5..000000000000 --- a/scp2/source/javafilter/module_javafilter.ulf +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -[STR_NAME_MODULE_OPTIONAL_JAVAFILTER] -en-US = "Mobile Device Filters" - -[STR_DESC_MODULE_OPTIONAL_JAVAFILTER] -en-US = "Text and spreadsheet filters to support import/export for Palm handheld or Pocket PC (Java required)." - -[STR_NAME_MODULE_OPTIONAL_JAVAFILTER_PALM] -en-US = "Palm" - -[STR_DESC_MODULE_OPTIONAL_JAVAFILTER_PALM] -en-US = "Filters for Palm OS compatible handhelds" - -[STR_NAME_MODULE_OPTIONAL_JAVAFILTER_PALM_APORTISDOC] -en-US = "AportisDoc" - -[STR_DESC_MODULE_OPTIONAL_JAVAFILTER_PALM_APORTISDOC] -en-US = "Support for the AportisDoc format" - -[STR_NAME_MODULE_OPTIONAL_JAVAFILTER_POCKETPC] -en-US = "Pocket PC" - -[STR_DESC_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_WNT] -en-US = "Filters and ActiveSync support for Pocket PC compatible handhelds" - -[STR_DESC_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_UNIX] -en-US = "Filters for Pocket PC compatible handhelds." - -[STR_NAME_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_POCKET_WORD] -en-US = "Pocket Word" - -[STR_DESC_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_POCKET_WORD] -en-US = "Support for Pocket Word" - -[STR_NAME_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_POCKET_EXCEL] -en-US = "Pocket Excel" - -[STR_DESC_MODULE_OPTIONAL_JAVAFILTER_POCKETPC_POCKET_EXCEL] -en-US = "Support for Pocket Excel" - - - diff --git a/scp2/source/javafilter/registryitem_javafilter.scp b/scp2/source/javafilter/registryitem_javafilter.scp deleted file mode 100644 index 3626d914bef4..000000000000 --- a/scp2/source/javafilter/registryitem_javafilter.scp +++ /dev/null @@ -1,437 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "macros.inc" - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c_ - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - ALL_LANG_STR_VALUE_LNG(_43887C67_4D5D_4127_BAAC_87A288494C7C_); -End - - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c__Defaulticon - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}\DefaultIcon"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c__Inprocserver32 - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = "[INSTALLLOCATION]program\xmergesync.dll"; -End - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c__Inprocserver32_Threadingmodel - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "ThreadingModel"; - Value = "Apartment"; -End - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c__Pegasusfilter - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c__Pegasusfilter_Description - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "Description"; - ALL_LANG_STR_VALUE_LNG(_43887C67_4D5D_4127_BAAC_87A288494C7C__PEGASUSFILTER_DESCRIPTION); -End - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c__Pegasusfilter_Import - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "Import"; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__43887c67_4d5d_4127_Baac_87a288494c7c__Pegasusfilter_Newextension - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{43887C67-4D5D-4127-BAAC-87A288494C7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "NewExtension"; - Value = "pxl"; -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020_ - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - ALL_LANG_STR_VALUE_LNG(_BDD611C3_7BAB_460F_8711_5B9AC9EF6020_); -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020__Defaulticon - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}\DefaultIcon"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020__Inprocserver32 - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = "[INSTALLLOCATION]program\xmergesync.dll"; -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020__Inprocserver32_Threadingmodel - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "ThreadingModel"; - Value = "Apartment"; -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020__Pegasusfilter - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020__Pegasusfilter_Description - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "Description"; - ALL_LANG_STR_VALUE_LNG(_BDD611C3_7BAB_460F_8711_5B9AC9EF6020__PEGASUSFILTER_DESCRIPTION); -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020__Pegasusfilter_Export - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "Export"; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__Bdd611c3_7bab_460f_8711_5b9ac9ef6020__Pegasusfilter_Newextension - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "NewExtension"; - Value = "sxw"; -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c_ - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - ALL_LANG_STR_VALUE_LNG(_C6AB3E74_9F4F_4370_8120_A8A6FABB7A7C_); -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c__Defaulticon - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}\DefaultIcon"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c__Inprocserver32 - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = "[INSTALLLOCATION]program\xmergesync.dll"; -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c__Inprocserver32_Threadingmodel - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "ThreadingModel"; - Value = "Apartment"; -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c__Pegasusfilter - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c__Pegasusfilter_Description - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "Description"; - ALL_LANG_STR_VALUE_LNG(_C6AB3E74_9F4F_4370_8120_A8A6FABB7A7C__PEGASUSFILTER_DESCRIPTION); -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c__Pegasusfilter_Export - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "Export"; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__C6ab3e74_9f4f_4370_8120_A8a6fabb7a7c__Pegasusfilter_Newextension - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "NewExtension"; - Value = "sxc"; -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439_ - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - ALL_LANG_STR_VALUE_LNG(_CB43F086_838D_4FA4_B5F6_3406B9A57439_); -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439__Defaulticon - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}\DefaultIcon"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439__Inprocserver32 - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = "[INSTALLLOCATION]program\xmergesync.dll"; -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439__Inprocserver32_Threadingmodel - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}\InProcServer32"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "ThreadingModel"; - Value = "Apartment"; -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439__Pegasusfilter - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439__Pegasusfilter_Description - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "Description"; - ALL_LANG_STR_VALUE_LNG(_CB43F086_838D_4FA4_B5F6_3406B9A57439__PEGASUSFILTER_DESCRIPTION); -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439__Pegasusfilter_Import - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "Import"; - Value = ""; -End - -RegistryItem gid_Regitem_Clsid__Cb43f086_838d_4fa4_B5f6_3406b9a57439__Pegasusfilter_Newextension - ParentID = PREDEFINED_HKEY_CLASSES_ROOT; - Subkey = "CLSID\{CB43F086-838D-4FA4-B5F6-3406B9A57439}\PegasusFilter"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "NewExtension"; - Value = "psw"; -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Classpath_Pocket_Excel - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "Classpath"; - ALL_LANG_STR_VALUE_LNG(HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_CLASSPATH); -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Classpath_Pocket_Word - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "Classpath"; - ALL_LANG_STR_VALUE_LNG(HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_CLASSPATH); -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Java_Pocket_Excel - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "Java"; - ALL_LANG_STR_VALUE_LNG(HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_JAVA); -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Java_Pocket_Word - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "Java"; - ALL_LANG_STR_VALUE_LNG(HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_JAVA); -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Javainit_Pocket_Excel - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "JavaInit"; - ALL_LANG_STR_VALUE_LNG(HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_JAVAINIT); -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Javainit_Pocket_Word - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "JavaInit"; - ALL_LANG_STR_VALUE_LNG(HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_JAVAINIT); -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Pocket_Excel - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Error_Pocket_Word - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages\Error"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Pocket_Excel - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Hklm_Soft_Sun_Staroffice_Xmergesync_Msgs_Pocket_Word - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Sun Microsystems\StarOffice\XMergeSync\Messages"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Psw_Writer - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.psw\InstalledFilters"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}"; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Pxl_Calc - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.pxl\InstalledFilters"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}"; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxc - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxc"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxc_Default_Export - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxc"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "DefaultExport"; - Value = "Binary Copy"; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxc_Default_Import - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxc"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "DefaultImport"; - Value = "{43887C67-4D5D-4127-BAAC-87A288494C7C}"; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxc_Installed_Filters - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxc\InstalledFilters"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxc_Installed_Filters_Pxl - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxc\InstalledFilters"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Excel; - Name = "{43887C67-4D5D-4127-BAAC-87A288494C7C}"; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxw - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxw"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxw_Default_Export - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxw"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "DefaultExport"; - Value = "Binary Copy"; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxw_Default_Import - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxw"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "DefaultImport"; - Value = "{CB43F086-838D-4FA4-B5F6-3406B9A57439}"; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxw_Installed_Filters - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxw\InstalledFilters"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Value = ""; -End - -RegistryItem gid_Regitem_Wince_Services_Filters_Sxw_Installed_Filters_Psw - ParentID = PREDEFINED_HKEY_LOCAL_MACHINE; - Subkey = "Software\Microsoft\Windows CE Services\Filters\.sxw\InstalledFilters"; - ModuleID = gid_Module_Optional_Javafilter_Pocketpc_Pocket_Word; - Name = "{CB43F086-838D-4FA4-B5F6-3406B9A57439}"; - Value = ""; -End diff --git a/scp2/source/javafilter/registryitem_javafilter.ulf b/scp2/source/javafilter/registryitem_javafilter.ulf deleted file mode 100644 index ea0ae370c077..000000000000 --- a/scp2/source/javafilter/registryitem_javafilter.ulf +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -[STR_VALUE__43887C67_4D5D_4127_BAAC_87A288494C7C_] -en-US = "Pocket Excel" - -[STR_VALUE__43887C67_4D5D_4127_BAAC_87A288494C7C__PEGASUSFILTER_DESCRIPTION] -en-US = "Pocket Excel Workbook" - -[STR_VALUE__BDD611C3_7BAB_460F_8711_5B9AC9EF6020_] -en-US = "%PRODUCTNAME Writer" - -[STR_VALUE__BDD611C3_7BAB_460F_8711_5B9AC9EF6020__PEGASUSFILTER_DESCRIPTION] -en-US = "%PRODUCTNAME Writer XML Document" - -[STR_VALUE__C6AB3E74_9F4F_4370_8120_A8A6FABB7A7C_] -en-US = "%PRODUCTNAME Calc" - -[STR_VALUE__C6AB3E74_9F4F_4370_8120_A8A6FABB7A7C__PEGASUSFILTER_DESCRIPTION] -en-US = "%PRODUCTNAME Calc XML Document" - -[STR_VALUE__CB43F086_838D_4FA4_B5F6_3406B9A57439_] -en-US = "Pocket Word" - -[STR_VALUE__CB43F086_838D_4FA4_B5F6_3406B9A57439__PEGASUSFILTER_DESCRIPTION] -en-US = "Pocket Word Document - Pocket PC" - -[STR_VALUE_HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_CLASSPATH] -en-US = "The %PRODUCTNAME mobile device filters cannot be located." - -[STR_VALUE_HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_JAVA] -en-US = "A Java 1.4 installation cannot be located." - -[STR_VALUE_HKLM_SOFT_SUN_STAROFFICE_XMERGESYNC_MSGS_ERROR_JAVAINIT] -en-US = "There was an error while initializing the Java Runtime Environment." diff --git a/scp2/source/ooo/common_brand.scp b/scp2/source/ooo/common_brand.scp index 4194becac3bb..4dfe36f810f6 100644 --- a/scp2/source/ooo/common_brand.scp +++ b/scp2/source/ooo/common_brand.scp @@ -77,7 +77,6 @@ Module gid_Module_Root_Brand gid_Brand_File_Share_Xdg_Draw, gid_Brand_File_Share_Xdg_Extension, gid_Brand_File_Share_Xdg_Impress, - gid_Brand_File_Share_Xdg_JavaFilter, gid_Brand_File_Share_Xdg_Math, gid_Brand_File_Share_Xdg_Printeradmin, gid_Brand_File_Share_Xdg_QStart, @@ -736,15 +735,6 @@ End #endif #if defined UNX && ! defined MACOSX -File gid_Brand_File_Share_Xdg_JavaFilter - TXT_FILE_BODY; - Dir = gid_Brand_Dir_Share_Xdg; - Name = "javafilter.desktop"; - Styles = (PACKED,SCPZIP_REPLACE); -End -#endif - -#if defined UNX && ! defined MACOSX File gid_Brand_File_Share_Xdg_XsltFilter TXT_FILE_BODY; Dir = gid_Brand_Dir_Share_Xdg; diff --git a/scp2/source/ooo/file_ooo.scp b/scp2/source/ooo/file_ooo.scp index a5c2eb952943..64c7ed967794 100644 --- a/scp2/source/ooo/file_ooo.scp +++ b/scp2/source/ooo/file_ooo.scp @@ -435,6 +435,8 @@ STD_JAR_FILE( gid_File_Jar_Table, table ) STD_JAR_FILE( gid_File_Jar_Form, form ) STD_JAR_FILE( gid_File_Jar_Query, query ) STD_JAR_FILE( gid_File_Jar_Web, web ) +STD_JAR_FILE( gid_File_Jar_Xmerge, xmerge ) +STD_JAR_FILE( gid_File_Jar_Xmergebridge, XMergeBridge ) #endif #if defined SOLAR_JAVA && defined WNT diff --git a/scp2/source/ooo/windowscustomaction_ooo.scp b/scp2/source/ooo/windowscustomaction_ooo.scp index 4242fcdf5d04..31b133f79d9f 100644 --- a/scp2/source/ooo/windowscustomaction_ooo.scp +++ b/scp2/source/ooo/windowscustomaction_ooo.scp @@ -83,24 +83,6 @@ End #ifdef HAVE_WINDOWS_SDK -WindowsCustomAction gid_Customaction_Jfregcadll1 - Name = "Jfregcadll1"; - Typ = "65"; - Source = "jfregca.dll"; - Target = "install_jf"; - Inbinarytable = 1; - Assignment1 = ("InstallExecuteSequence", "\&FEATURETEMPLATE=3 And Not PATCH", "end"); -End - -WindowsCustomAction gid_Customaction_Jfregcadll2 - Name = "Jfregcadll2"; - Typ = "65"; - Source = "jfregca.dll"; - Target = "uninstall_jf"; - Inbinarytable = 1; - Assignment1 = ("InstallExecuteSequence", "\&FEATURETEMPLATE=2 And \!FEATURETEMPLATE=3 And Not PATCH", "end"); -End - WindowsCustomAction gid_Customaction_sdqsmsidll Name = "sdqsmsidll"; Typ = "65"; diff --git a/setup_native/Library_jfregca.mk b/setup_native/Library_jfregca.mk deleted file mode 100644 index c213e81d1eb2..000000000000 --- a/setup_native/Library_jfregca.mk +++ /dev/null @@ -1,37 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -$(eval $(call gb_Library_Library,jfregca)) - -$(eval $(call gb_Library_add_defs,jfregca,\ - -U_DLL \ -)) - -$(eval $(call gb_Library_add_cxxflags,jfregca,\ - /MT \ -)) - -$(eval $(call gb_Library_add_ldflags,jfregca,\ - /DEF:$(SRCDIR)/setup_native/source/win32/customactions/javafilter/jfregca.def \ - /NODEFAULTLIB \ -)) - -$(eval $(call gb_Library_add_exception_objects,jfregca,\ - setup_native/source/win32/customactions/javafilter/jfregca \ -)) - -$(eval $(call gb_Library_use_system_win32_libs,jfregca,\ - libcmt \ - libcpmt \ - kernel32 \ - msi \ - advapi32 \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/setup_native/Module_setup_native.mk b/setup_native/Module_setup_native.mk index 407065704d2f..1f6ad5c4cdf5 100644 --- a/setup_native/Module_setup_native.mk +++ b/setup_native/Module_setup_native.mk @@ -27,7 +27,6 @@ endif ifeq ($(OS)$(COM),WNTMSC) $(eval $(call gb_Module_add_targets,setup_native,\ Library_instooofiltmsi \ - Library_jfregca \ Library_qslnkmsi \ Library_reg4allmsdoc \ Library_regactivex \ diff --git a/setup_native/source/packinfo/package_names.txt b/setup_native/source/packinfo/package_names.txt index 64fa6f52fef2..ec2593d6b615 100644 --- a/setup_native/source/packinfo/package_names.txt +++ b/setup_native/source/packinfo/package_names.txt @@ -30,7 +30,6 @@ %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-headless Headless display module for LibreOffice %PRODUCTVERSION %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-images Images module for LibreOffice %PRODUCTVERSION %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-impress Impress module for LibreOffice %PRODUCTVERSION -%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-javafilter Java filter module for LibreOffice %PRODUCTVERSION %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-kde-integration KDE integration module for LibreOffice %PRODUCTVERSION %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-math Math module for LibreOffice %PRODUCTVERSION %BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-onlineupdate Online update modul for LibreOffice %PRODUCTVERSION diff --git a/setup_native/source/packinfo/packinfo_office.txt b/setup_native/source/packinfo/packinfo_office.txt index 3e8c89eb489a..f67453e72e5d 100644 --- a/setup_native/source/packinfo/packinfo_office.txt +++ b/setup_native/source/packinfo/packinfo_office.txt @@ -253,21 +253,6 @@ packageversion = "%ABOUTBOXPRODUCTVERSION" End Start -module = "gid_Module_Optional_Javafilter" -solarispackagename = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-javafilter" -solarisrequires = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01" -packagename = "%BASISPACKAGEPREFIX%PRODUCTVERSION-javafilter" -freebsdrequires = "%BASISPACKAGEPREFIX%PRODUCTVERSION-core01" -requires = "%BASISPACKAGEPREFIX%PRODUCTVERSION-core01" -copyright = "2012 The Document Foundation" -solariscopyright = "solariscopyrightfile" -vendor = "The Document Foundation" -description = "Java filter module for %PRODUCTNAME %PRODUCTVERSION" -destpath = "/opt" -packageversion = "%ABOUTBOXPRODUCTVERSION" -End - -Start module = "gid_Module_Optional_Activexcontrol" solarispackagename = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-activex" solarisrequires = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01" diff --git a/setup_native/source/win32/customactions/javafilter/jfregca.cxx b/setup_native/source/win32/customactions/javafilter/jfregca.cxx deleted file mode 100644 index 841bdf6e066e..000000000000 --- a/setup_native/source/win32/customactions/javafilter/jfregca.cxx +++ /dev/null @@ -1,323 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifdef _MSC_VER -#pragma warning(push, 1) /* disable warnings within system headers */ -#endif -#include <windows.h> -#include <msi.h> -#include <msiquery.h> -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#if defined UNICODE -#define _UNICODE -#endif -#include <tchar.h> - -//Simple function prototypes -bool update_activesync_regvalues(bool, bool, char** ); -void createKeys(HKEY hKey, char **); -void deleteKeys(HKEY hKey, char **); -bool isMulti(MSIHANDLE); - -//Simple data arrays for registry values -TCHAR *pxlData[8]= { - "{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}", //CLSID 1 - key name at InstalledFilters Key - "{43887C67-4D5D-4127-BAAC-87A288494C7C}", //CLSID 2 - key value for Default Export - ".pxl", //Registry key for device type - already there if ActiveSync installerd - ".sxc", //New registry key for SO docs - "InstalledFilters", //Sub-key of device/so doc key - "DefaultImport", //Key name added at device/so level key - "DefaultExport", //Key name added at device/so level key - "Binary Copy", //Key value for DefaultImport -}; - -TCHAR *pswData[8] = { - "{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}", //CLSID 1 - key name at InstalledFilters Key - "{CB43F086-838D-4FA4-B5F6-3406B9A57439}", //CLSID 2 - key value for Default Export - ".psw", //Registry key for device type - already there if ActiveSync installe - ".sxw", //New registry key for SO docs - "InstalledFilters", //Sub-key of device/so doc key - "DefaultImport", //Key name added at device/so level key - "DefaultExport", //Key name added at device/so level key - "Binary Copy", //Key value for DefaultImport -}; - - -//index into registry value arrays -#define CLSID1 0 -#define CLSID2 1 -#define DEVICE_PATH 2 -#define SO_PATH 3 -#define IF_PATH 4 -#define DEFIMPORT_KEY 5 -#define DEFEXPORT_KEY 6 -#define BC_VALUE 7 - -//Constants for Registry buffers -const int MAX_KEY_LENGTH=255; -const int MAX_VALUE_NAME=16383; - -BOOL APIENTRY DllMain( HANDLE, - DWORD ul_reason, - LPVOID - ) -{ - switch (ul_reason) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -extern "C" UINT __declspec(dllexport) install_jf ( MSIHANDLE hModule ) { - bool bMulti = isMulti(hModule); -#ifdef _JRGREG_DEBUG - MessageBox(NULL, bMulti ? "Multi" : "Single", "Install", MB_OK); -#endif - update_activesync_regvalues(bMulti, true, pxlData); - update_activesync_regvalues(bMulti, true, pswData); - - return ERROR_SUCCESS; -} - -extern "C" UINT _declspec(dllexport) uninstall_jf ( MSIHANDLE hModule ) { - bool bMulti = isMulti(hModule); -#ifdef _JRGREG_DEBUG - MessageBox(NULL, bMulti ? "Multi" : "Single", "Uninstall", MB_OK); -#endif - update_activesync_regvalues(false, bMulti, pxlData); - update_activesync_regvalues(false, bMulti, pswData); - - return ERROR_SUCCESS; -} - -/** - Determines if this is being installed on a per user or a machine wide basis - @param hModule - [in] a valid msi handle. - - - @returns - <TRUE/>if this is a multi-user install. -*/ -bool isMulti( MSIHANDLE hModule ) { - TCHAR* szValueBuf = NULL; - DWORD cchValueBuf = 0; - bool bRet = false; - UINT uiStat = MsiGetProperty(hModule, TEXT("ALLUSERS"), TEXT(""), &cchValueBuf); - if (ERROR_MORE_DATA == uiStat) - { - ++cchValueBuf; // on output does not include terminating null, so add 1 - szValueBuf = new TCHAR[cchValueBuf]; - if (szValueBuf) - { - uiStat = MsiGetProperty(hModule, TEXT("ALLUSERS"), szValueBuf, &cchValueBuf); - } - } - if (ERROR_SUCCESS != uiStat) - { - return false; - } - bRet = _tcscmp(szValueBuf, TEXT("1")) == 0; - delete [] szValueBuf; - - return bRet; -} - -/** - Add or remove ActiveSync integration entries from the registry - @param bMultiUser - [in] <TRUE/>if this is a multiuser install (<FALSE/> for single user install) - - @param bInstall - [in] <TRUE/>if installing - - @param data - [in] an array of string containing names of registry keys and values - - - @returns - <TRUE/>if this is a multi-user install. -*/ - -bool update_activesync_regvalues(bool bMultiUser, bool bInstall, char **data) { - bool bReturn = false; - CHAR SUKey[] = "Software\\Microsoft\\Windows CE Services\\Partners"; - CHAR MUKey[] = "Software\\Microsoft\\Windows CE Services\\Filters"; - HKEY hKey; - - if (bMultiUser) { - if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCSTR)MUKey, 0, KEY_ALL_ACCESS, &hKey)) { - return false; - } - if (bInstall) { - createKeys(hKey, data); - } else { - deleteKeys(hKey, data); - } - bReturn = true; - } else { - if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_CURRENT_USER, (LPCSTR)SUKey, 0, KEY_ALL_ACCESS, &hKey)) { - return false; - } - - CHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name - DWORD cbName; // size of name string - CHAR achClass[MAX_PATH] = ""; // buffer for class name - DWORD cchClassName = MAX_PATH; // size of class string - DWORD cSubKeys=0; // number of subkeys - DWORD cbMaxSubKey; // longest subkey size - DWORD cchMaxClass; // longest class string - DWORD cValues; // number of values for key - DWORD cchMaxValue; // longest value name - DWORD cbMaxValueData; // longest value data - DWORD cbSecurityDescriptor; // size of security descriptor - FILETIME ftLastWriteTime; // last write time - - // Get the class name and the value count. - if (ERROR_SUCCESS == RegQueryInfoKey( - hKey, // key handle - achClass, // buffer for class name - &cchClassName, // size of class string - NULL, // reserved - &cSubKeys, // number of subkeys - &cbMaxSubKey, // longest subkey size - &cchMaxClass, // longest class string - &cValues, // number of values for this key - &cchMaxValue, // longest value name - &cbMaxValueData, // longest value data - &cbSecurityDescriptor, // security descriptor - &ftLastWriteTime)) { // last write time - - if (cSubKeys) { - for (DWORD i=0; i<cSubKeys; i++) { - cbName = 1024; - if (ERROR_SUCCESS == RegEnumKeyEx(hKey,i,achKey,&cbName,NULL,NULL,NULL,&ftLastWriteTime)) { - HKEY subKey; - if (ERROR_SUCCESS == RegOpenKeyEx(hKey, achKey, 0, KEY_ALL_ACCESS, &subKey)) { - if (ERROR_SUCCESS == RegOpenKeyEx(subKey, "Filters", 0, KEY_ALL_ACCESS, &subKey)) { - if (bInstall) { - createKeys(subKey, data); - } else { - deleteKeys(subKey, data); - } - RegCloseKey(subKey); - } - } - } - } - } - - bReturn = true; - } - } - if (hKey != NULL) { - RegCloseKey(hKey); - } - - return bReturn; -} - -/** - Create Registry Keys - - @param hKey - [in] Handle to the parent registry key - - @param data - [in] an array of string containing names of registry keys and values -*/ - -void createKeys(HKEY hKey, char **data) { - - LPCSTR clsid1 = data[CLSID1]; - LPCSTR clsid2 = data[CLSID2]; - LPCSTR devicePath = data[DEVICE_PATH]; - LPCSTR soPath = data[SO_PATH]; - LPCSTR defImport = data[DEFIMPORT_KEY]; - LPCSTR defExport = data[DEFEXPORT_KEY]; - LPCSTR binaryCopy = data[BC_VALUE]; - LPCSTR IFPath = data[IF_PATH]; - - HKEY deviceKey, deviceIFKey, soKey, soIFKey; - - if (ERROR_SUCCESS == RegOpenKeyEx(hKey,devicePath,0,KEY_ALL_ACCESS, &deviceKey)) { - if (ERROR_SUCCESS == RegOpenKeyEx(deviceKey,IFPath,0,KEY_ALL_ACCESS, &deviceIFKey)) { - RegSetValueEx(deviceIFKey, clsid1, 0, REG_SZ, NULL, NULL); - } - } - - if (ERROR_SUCCESS == RegCreateKeyEx(hKey, soPath, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &soKey, NULL)) { - RegSetValueEx(soKey, defExport, 0, REG_SZ, (LPBYTE)binaryCopy, strlen(binaryCopy)); - RegSetValueEx(soKey, defImport, 0, REG_SZ, (LPBYTE)clsid2, strlen(clsid2)); - - - if (ERROR_SUCCESS == RegCreateKeyEx(soKey, IFPath, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &soIFKey, NULL)) { - RegSetValueEx(soIFKey, clsid2, 0, REG_SZ, NULL, NULL); - } - } -} - -/** - Delete registry keys - - @param hKey - [in] Handle to the parent registry key -*/ -void deleteKeys(HKEY hKey, TCHAR **data) { - LPCSTR clsid1 = data[CLSID1]; - LPCSTR clsid2 = data[CLSID2]; - LPCSTR devicePath = data[DEVICE_PATH]; - LPCSTR soPath = data[SO_PATH]; - LPCSTR defImport = data[DEFIMPORT_KEY]; - LPCSTR defExport = data[DEFEXPORT_KEY]; - LPCSTR IFPath = data[IF_PATH]; - - HKEY deviceKey, deviceIFKey, soKey, soIFKey; - - if (ERROR_SUCCESS == RegOpenKeyEx(hKey,devicePath,0,KEY_ALL_ACCESS, &deviceKey)) { - if (ERROR_SUCCESS == RegOpenKeyEx(deviceKey,IFPath,0,KEY_ALL_ACCESS, &deviceIFKey)) { - RegDeleteValue(deviceIFKey, clsid1); - } - } - - if (ERROR_SUCCESS == RegOpenKeyEx(hKey, soPath, 0, KEY_ALL_ACCESS, &soKey)) { - RegDeleteValue(soKey, defExport); - RegDeleteValue(soKey, defImport); - - if (ERROR_SUCCESS == RegOpenKeyEx(soKey, IFPath, 0, KEY_ALL_ACCESS, &soIFKey)) { - RegDeleteValue(soIFKey, clsid2); - RegCloseKey(soIFKey); - RegDeleteKey(soKey, IFPath); - } - RegCloseKey(soKey); - RegDeleteKey(hKey, soPath); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/setup_native/source/win32/customactions/javafilter/jfregca.def b/setup_native/source/win32/customactions/javafilter/jfregca.def deleted file mode 100644 index 20af5388de0a..000000000000 --- a/setup_native/source/win32/customactions/javafilter/jfregca.def +++ /dev/null @@ -1,4 +0,0 @@ -LIBRARY "jfregca.dll" -EXPORTS - install_jf - uninstall_jf
\ No newline at end of file diff --git a/solenv/bin/modules/installer/windows/idtglobal.pm b/solenv/bin/modules/installer/windows/idtglobal.pm index e5ce42d13050..0c9f55e2c945 100644 --- a/solenv/bin/modules/installer/windows/idtglobal.pm +++ b/solenv/bin/modules/installer/windows/idtglobal.pm @@ -54,7 +54,6 @@ sub shorten_feature_gid $$stringref =~ s/_Optional_/_o_/; $$stringref =~ s/_Tools_/_tl_/; $$stringref =~ s/_Wrt_Flt_/_w_f_/; - $$stringref =~ s/_Javafilter_/_jf_/; $$stringref =~ s/_Productivity_/_pr_/; } diff --git a/solenv/bin/modules/installer/windows/registry.pm b/solenv/bin/modules/installer/windows/registry.pm index edeb868d70fd..54d13d165458 100644 --- a/solenv/bin/modules/installer/windows/registry.pm +++ b/solenv/bin/modules/installer/windows/registry.pm @@ -66,7 +66,6 @@ sub get_registry_component_name $componentname =~ s/gid_module_/g_m_/g; $componentname =~ s/_optional_/_o_/g; - $componentname =~ s/_javafilter_/_jf_/g; # This componentname must be more specific my $addon = "_"; diff --git a/sysui/CustomTarget_share.mk b/sysui/CustomTarget_share.mk index 7a43a0e081f5..aa1ab2af3b75 100644 --- a/sysui/CustomTarget_share.mk +++ b/sysui/CustomTarget_share.mk @@ -11,7 +11,7 @@ share_WORKDIR := $(call gb_CustomTarget_get_workdir,sysui/share) share_SRCDIR := $(SRCDIR)/sysui/desktop LAUNCHERLIST_APPS := writer calc draw impress math base printeradmin startcenter -LAUNCHERLIST := $(LAUNCHERLIST_APPS) qstart javafilter xsltfilter +LAUNCHERLIST := $(LAUNCHERLIST_APPS) qstart xsltfilter LAUNCHERS := $(foreach launcher,$(LAUNCHERLIST),$(share_SRCDIR)/menus/$(launcher).desktop) MIMELIST := \ diff --git a/sysui/desktop/freedesktop/freedesktop-menus.spec b/sysui/desktop/freedesktop/freedesktop-menus.spec index 76fd7a7767eb..0c1d776979cf 100755 --- a/sysui/desktop/freedesktop/freedesktop-menus.spec +++ b/sysui/desktop/freedesktop/freedesktop-menus.spec @@ -402,7 +402,6 @@ done /usr/share/applications/%unixfilename-printeradmin.desktop /usr/share/applications/%unixfilename-writer.desktop /usr/share/applications/%unixfilename-startcenter.desktop -/usr/share/applications/%unixfilename-javafilter.desktop /usr/share/applications/%unixfilename-xsltfilter.desktop /usr/share/icons/gnome/*/apps/*png /usr/share/icons/gnome/*/mimetypes/*png diff --git a/sysui/desktop/menus/javafilter.desktop b/sysui/desktop/menus/javafilter.desktop deleted file mode 100755 index f8681f6fb5e0..000000000000 --- a/sysui/desktop/menus/javafilter.desktop +++ /dev/null @@ -1,26 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# -[Desktop Entry] -Version=1.0 -Terminal=false -Type=Application -Exec=${UNIXBASISROOTNAME} --writer %U -MimeType=application/x-aportisdoc;application/x-pocket-word;application/x-pocket-excel; -Name=%PRODUCTNAME Small Device Format Importer -GenericName=Small Device Format Importer -NoDisplay=true diff --git a/sysui/desktop/share/launcher_genericname.ulf b/sysui/desktop/share/launcher_genericname.ulf index 492bdf534130..108d0e87786f 100644 --- a/sysui/desktop/share/launcher_genericname.ulf +++ b/sysui/desktop/share/launcher_genericname.ulf @@ -19,8 +19,5 @@ en-US = "Drawing Program" [startcenter] en-US = "Office" -[javafilter] -en-US = "Small Device Format Importer" - [xsltfilter] en-US = "XSLT based filters" diff --git a/sysui/desktop/share/launcher_unityquicklist.ulf b/sysui/desktop/share/launcher_unityquicklist.ulf index d1b0c8614f53..0f489bb1ed40 100644 --- a/sysui/desktop/share/launcher_unityquicklist.ulf +++ b/sysui/desktop/share/launcher_unityquicklist.ulf @@ -18,6 +18,3 @@ en-US = "New Drawing" [startcenter] en-US = "" - -[javafilter] -en-US = "" diff --git a/sysui/desktop/suse/suse-menus.spec b/sysui/desktop/suse/suse-menus.spec index ec950e654864..58dae1d5808f 100755 --- a/sysui/desktop/suse/suse-menus.spec +++ b/sysui/desktop/suse/suse-menus.spec @@ -373,7 +373,6 @@ done /usr/share/applications/%unixfilename-base.desktop /usr/share/applications/%unixfilename-printeradmin.desktop /usr/share/applications/%unixfilename-startcenter.desktop -/usr/share/applications/%unixfilename-javafilter.desktop /usr/share/applications/%unixfilename-xsltfilter.desktop /opt/gnome/share/mime-info/*.keys /opt/gnome/share/mime-info/*.mime diff --git a/xmerge/Jar_aportisdoc.mk b/xmerge/Jar_aportisdoc.mk deleted file mode 100644 index 282b339186ce..000000000000 --- a/xmerge/Jar_aportisdoc.mk +++ /dev/null @@ -1,49 +0,0 @@ -# -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Peter Foley <pefoley2@verizon.net> -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -# - -$(eval $(call gb_Jar_Jar,aportisdoc)) - -$(eval $(call gb_Jar_add_packagefile,aportisdoc,META-INF/converter.xml,$(SRCDIR)/xmerge/source/aportisdoc/converter.xml)) - -$(eval $(call gb_Jar_set_packageroot,aportisdoc,org)) - -$(eval $(call gb_Jar_use_jars,aportisdoc,\ - xmerge \ -)) - -$(eval $(call gb_Jar_add_sourcefiles,aportisdoc,\ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl \ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants \ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder \ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder \ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl \ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl \ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl \ - xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl \ -)) diff --git a/xmerge/Jar_htmlsoff.mk b/xmerge/Jar_htmlsoff.mk deleted file mode 100644 index fca57f670e9f..000000000000 --- a/xmerge/Jar_htmlsoff.mk +++ /dev/null @@ -1,37 +0,0 @@ -# -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Peter Foley <pefoley2@verizon.net> -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -# - -$(eval $(call gb_Jar_Jar,htmlsoff)) - -$(eval $(call gb_Jar_add_packagefile,htmlsoff,META-INF/converter.xml,$(SRCDIR)/xmerge/source/htmlsoff/converter.xml)) -$(eval $(call gb_Jar_add_packagefile,htmlsoff,htmltosoff.xsl,$(SRCDIR)/xmerge/source/htmlsoff/htmltosoff.xsl)) -$(eval $(call gb_Jar_add_packagefile,htmlsoff,sofftohtml.xsl,$(SRCDIR)/xmerge/source/htmlsoff/sofftohtml.xsl)) - -$(eval $(call gb_Jar_set_packageroot,htmlsoff,*.xsl)) - diff --git a/xmerge/Jar_pexcel.mk b/xmerge/Jar_pexcel.mk deleted file mode 100644 index 0f79852aa0b3..000000000000 --- a/xmerge/Jar_pexcel.mk +++ /dev/null @@ -1,91 +0,0 @@ -# -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Peter Foley <pefoley2@verizon.net> -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -# - -$(eval $(call gb_Jar_Jar,pexcel)) - -$(eval $(call gb_Jar_add_packagefile,pexcel,META-INF/converter.xml,$(SRCDIR)/xmerge/source/pexcel/converter.xml)) - -$(eval $(call gb_Jar_set_packageroot,pexcel,org)) - -$(eval $(call gb_Jar_use_jars,pexcel,\ - xmerge \ -)) - -$(eval $(call gb_Jar_add_sourcefiles,pexcel,\ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1 \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2 \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl \ - xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl \ -)) diff --git a/xmerge/Jar_pocketword.mk b/xmerge/Jar_pocketword.mk deleted file mode 100644 index 2aba7807438a..000000000000 --- a/xmerge/Jar_pocketword.mk +++ /dev/null @@ -1,51 +0,0 @@ -# -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Peter Foley <pefoley2@verizon.net> -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -# - -$(eval $(call gb_Jar_Jar,pocketword)) - -$(eval $(call gb_Jar_add_packagefile,pocketword,META-INF/converter.xml,$(SRCDIR)/xmerge/source/pocketword/converter.xml)) - -$(eval $(call gb_Jar_set_packageroot,pocketword,org)) - -$(eval $(call gb_Jar_use_jars,pocketword,\ - xmerge \ -)) - -$(eval $(call gb_Jar_add_sourcefiles,pocketword,\ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants \ - xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument \ -)) diff --git a/xmerge/Module_xmerge.mk b/xmerge/Module_xmerge.mk index 3b8503c5536b..695d21d1b1e9 100644 --- a/xmerge/Module_xmerge.mk +++ b/xmerge/Module_xmerge.mk @@ -30,12 +30,7 @@ $(eval $(call gb_Module_Module,xmerge)) $(eval $(call gb_Module_add_targets,xmerge,\ $(if $(SOLAR_JAVA), \ - Jar_aportisdoc \ - Jar_htmlsoff \ - Jar_pexcel \ - Jar_pocketword \ Jar_xmerge \ Jar_XMergeBridge \ ) \ - Package_xmergesync \ )) diff --git a/xmerge/Package_xmergesync.mk b/xmerge/Package_xmergesync.mk deleted file mode 100644 index ef08b060a436..000000000000 --- a/xmerge/Package_xmergesync.mk +++ /dev/null @@ -1,34 +0,0 @@ -# -# Version: MPL 1.1 / GPLv3+ / LGPLv3+ -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License or as specified alternatively below. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Initial Developer of the Original Code is -# Peter Foley <pefoley2@verizon.net> -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Major Contributor(s): -# -# For minor contributions see the git repository. -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 3 or later (the "GPLv3+"), or -# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), -# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable -# instead of those above. -# - -$(eval $(call gb_Package_Package,xmergesync,$(SRCDIR)/xmerge/source/activesync/BIN)) - -ifeq ($(OS),WNT) -$(eval $(call gb_Package_add_file,xmergesync,bin/xmergesync.dll,xmergesync.dll)) -endif diff --git a/xmerge/source/activesync/BIN/xmergesync.dll b/xmerge/source/activesync/BIN/xmergesync.dll Binary files differdeleted file mode 100644 index 768dea87d2bd..000000000000 --- a/xmerge/source/activesync/BIN/xmergesync.dll +++ /dev/null diff --git a/xmerge/source/activesync/XMergeFactory.cpp b/xmerge/source/activesync/XMergeFactory.cpp deleted file mode 100644 index 486d128fc3a3..000000000000 --- a/xmerge/source/activesync/XMergeFactory.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// XMergeFactory.cpp: implementation of the CXMergeFactory class. -// -////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" - -#include "XMergeFilter.h" -#include "XMergeFactory.h" - -////////////////////////////////////////////////////////////////////// -// IUnknown implementation -////////////////////////////////////////////////////////////////////// -STDMETHODIMP CXMergeFactory::QueryInterface(REFIID riid, void **ppvObject) -{ - if(ppvObject == NULL) - return E_INVALIDARG; - - if(::IsEqualIID(riid, IID_IUnknown) || ::IsEqualIID(riid, IID_IClassFactory)) - { - *ppvObject = static_cast<IClassFactory*>(this); - } - else - { - *ppvObject = NULL; - return E_NOINTERFACE; - } - - reinterpret_cast<IUnknown*>(*ppvObject)->AddRef(); - return S_OK; -} - - -STDMETHODIMP_(ULONG) CXMergeFactory::AddRef() -{ - return ::InterlockedIncrement(&m_cRef); -} - - -STDMETHODIMP_(ULONG) CXMergeFactory::Release() -{ - if(::InterlockedDecrement(&m_cRef) == 0) - { - delete this; - return 0; - } - - return m_cRef; -} - - -////////////////////////////////////////////////////////////////////// -// IUnknown implementation -////////////////////////////////////////////////////////////////////// -STDMETHODIMP CXMergeFactory::CreateInstance(IUnknown *pUnkOuter, REFIID iid, void **ppvObject) -{ - if (ppvObject == NULL) - return E_INVALIDARG; - - if (pUnkOuter != NULL) // cannot aggregate - { - *ppvObject = NULL; - return CLASS_E_NOAGGREGATION; - } - - if (iid == IID_ICeFileFilter) - { - CXMergeFilter *pFilter = new CXMergeFilter(); - HRESULT hr = pFilter->QueryInterface(iid, ppvObject); - pFilter->Release(); - - return hr; - } - - return E_INVALIDARG; -} - - -STDMETHODIMP CXMergeFactory::LockServer(BOOL fLock) -{ - _Module.LockServer(fLock); - return S_OK; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/XMergeFactory.h b/xmerge/source/activesync/XMergeFactory.h deleted file mode 100644 index 640bc5638c3e..000000000000 --- a/xmerge/source/activesync/XMergeFactory.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// XMergeFactory.h: interface for the CXMergeFactory class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_XMERGEFACTORY_H__3150043C_57FB_4BC8_9104_379506FA6B9F__INCLUDED_) -#define AFX_XMERGEFACTORY_H__3150043C_57FB_4BC8_9104_379506FA6B9F__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -class CXMergeFactory : public IClassFactory -{ -private: - LONG m_cRef; - virtual ~CXMergeFactory() {}; - -public: - CXMergeFactory() : m_cRef(1) {}; // Set reference count when first created - - - /********** IUnknown methods **********/ - STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(); - - - /********** IUnknown methods **********/ - STDMETHODIMP CreateInstance(IUnknown* pUnkOuter, REFIID riid, void **ppvObject); - STDMETHODIMP LockServer(BOOL fLock); -}; - -#endif // !defined(AFX_XMERGEFACTORY_H__3150043C_57FB_4BC8_9104_379506FA6B9F__INCLUDED_) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/XMergeFilter.cpp b/xmerge/source/activesync/XMergeFilter.cpp deleted file mode 100644 index e7d1a91e2cce..000000000000 --- a/xmerge/source/activesync/XMergeFilter.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -// XMergeFilter.cpp: implementation of the CXMergeFilter class. -// -////////////////////////////////////////////////////////////////////// - - -#include "stdafx.h" - -#include "XMergeFilter.h" - -#include <string> - - -#define ERR_NOJAVA 1 -#define ERR_BADCLASSPATH 2 -#define ERR_INITJAVA 3 - - -const LPTSTR CXMergeFilter::m_pszPSWExportCLSID = _T("{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}"); -const LPTSTR CXMergeFilter::m_pszPSWExportExt = _T("sxw"); -const LPTSTR CXMergeFilter::m_pszPSWExportDesc = _T("OpenOffice.org Writer XML Document"); -const LPTSTR CXMergeFilter::m_pszPSWExportShortDesc = _T("OpenOffice.org Writer"); - -const LPTSTR CXMergeFilter::m_pszPSWImportCLSID = _T("{CB43F086-838D-4FA4-B5F6-3406B9A57439}"); -const LPTSTR CXMergeFilter::m_pszPSWImportExt = _T("psw"); -const LPTSTR CXMergeFilter::m_pszPSWImportDesc = _T("Pocket Word Document - Pocket PC"); -const LPTSTR CXMergeFilter::m_pszPSWImportShortDesc = _T("Pocket Word"); - -const LPTSTR CXMergeFilter::m_pszPXLExportCLSID = _T("{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}"); -const LPTSTR CXMergeFilter::m_pszPXLExportExt = _T("sxc"); -const LPTSTR CXMergeFilter::m_pszPXLExportDesc = _T("OpenOffice.org Calc XML Document"); -const LPTSTR CXMergeFilter::m_pszPXLExportShortDesc = _T("OpenOffice.org Calc"); - -const LPTSTR CXMergeFilter::m_pszPXLImportCLSID = _T("{43887C67-4D5D-4127-BAAC-87A288494C7C}"); -const LPTSTR CXMergeFilter::m_pszPXLImportExt = _T("pxl"); -const LPTSTR CXMergeFilter::m_pszPXLImportDesc = _T("Pocket Excel Document - Pocket PC"); -const LPTSTR CXMergeFilter::m_pszPXLImportShortDesc = _T("Pocket Excel"); - - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CXMergeFilter::CXMergeFilter() : m_cRef(1) -{ - m_bHaveExcel = FALSE; - m_bHaveWord = FALSE; - - m_szClasspath = NULL; - m_szJavaBaseDir = NULL; -} - -CXMergeFilter::~CXMergeFilter() -{ - if (m_szClasspath != NULL) - { - delete m_szClasspath; - } - - if (m_szJavaBaseDir != NULL) - { - delete m_szJavaBaseDir; - } - -} - - -////////////////////////////////////////////////////////////////////// -// IUnknown Methods -////////////////////////////////////////////////////////////////////// - -STDMETHODIMP CXMergeFilter::QueryInterface(REFIID riid, void **ppvObject) -{ - if(ppvObject == NULL) - return E_INVALIDARG; - - if (::IsEqualIID(riid, IID_IUnknown)) - { - *ppvObject = static_cast<IUnknown *>(this); - } - else if (::IsEqualIID(riid, IID_ICeFileFilter)) - { - *ppvObject = static_cast<ICeFileFilter *>(this); - } - else - { - *ppvObject = NULL; - return E_NOINTERFACE; - } - - reinterpret_cast<IUnknown *>(*ppvObject)->AddRef(); - return S_OK; -} - - -STDMETHODIMP_(ULONG) CXMergeFilter::AddRef() -{ - return ::InterlockedIncrement(&m_cRef); -} - - -STDMETHODIMP_(ULONG) CXMergeFilter::Release() -{ - if(::InterlockedDecrement(&m_cRef) == 0) - { - delete this; - return 0; - } - return m_cRef; -} - - -////////////////////////////////////////////////////////////////////// -// ICeFileFilter -////////////////////////////////////////////////////////////////////// - -STDMETHODIMP CXMergeFilter::FilterOptions(HWND hwndParent) -{ - // We don't currently allow any options - return HRESULT_FROM_WIN32(NOERROR); -} - -STDMETHODIMP CXMergeFilter::FormatMessage(DWORD dwFlags, DWORD dwMessageId, - DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, - va_list *Arguments, DWORD *pcb) -{ - TCHAR errMsg[1024]; - - HKEY hKey = NULL; - DWORD dwSize = 1024; - - - long lRet = 0; - - // Attempt to find the messages in the registry - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Sun Microsystems\\StarOffice\\XMergeSync\\Messages\\Error"), - 0, KEY_READ, &hKey); - if (lRet != ERROR_SUCCESS) - { - // Try the user's portion of the registry - lRet = ::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Sun Microsystems\\StarOffice\\XMergeSync\\Messages\\Error"), - 0, KEY_READ, &hKey); - if (lRet != ERROR_SUCCESS) - { - hKey = NULL; - } - } - - - switch(dwMessageId) - { - case ERR_NOJAVA: - lRet = ::RegQueryValueEx(hKey, _T("Java"), 0, NULL, (LPBYTE)errMsg, &dwSize); - if (lRet != ERROR_SUCCESS) - { - lstrcpy(errMsg, "Unable to locate Java 1.4/1.5 installation."); - } - break; - - case ERR_BADCLASSPATH: - lRet = ::RegQueryValueEx(hKey, _T("Classpath"), 0, NULL, (LPBYTE)errMsg, &dwSize); - if (lRet != ERROR_SUCCESS) - { - lstrcpy(errMsg, "Unable to locate XMerge Jar files."); - } - break; - - case ERR_INITJAVA: - lRet = ::RegQueryValueEx(hKey, _T("JavaInit"), 0, NULL, (LPBYTE)errMsg, &dwSize); - if (lRet != ERROR_SUCCESS) - { - lstrcpy(errMsg, "Error initialising the Java Runtime Environment."); - } - break; - } - - char* buf = (char*)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, (lstrlen(errMsg) + 1) * sizeof(TCHAR)); - lstrcpyn(buf, errMsg, lstrlen(errMsg)); - - *(char**)lpBuffer = buf; - *pcb = strlen(errMsg); - - return HRESULT_FROM_WIN32(NOERROR); -} - - -STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, - CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, - volatile BOOL *pbCancel, CF_ERROR *perr) -{ - std::string appArgs; - std::string appName; - - STARTUPINFO si; - PROCESS_INFORMATION pi; - - ZeroMemory( &si, sizeof(si) ); - ZeroMemory( &pi, sizeof(pi) ); - - si.cb = sizeof(si); - - - /* - * First step: Locate Java and establish the classpath. If these can't - * be done successfully, then avoid all further processing. - */ - - // Locate Java Home if it hasn't already been done. - if (m_szJavaBaseDir == NULL) - { - m_szJavaBaseDir = GetJavaBaseDir(); - - if (m_szJavaBaseDir == NULL) - { - *perr = ERR_NOJAVA; - return HRESULT_FROM_WIN32(E_FAIL); - } - } - - // Get the StarOffice/OpenOffice class directory - if (m_szClasspath == NULL) - { - m_szClasspath = GetXMergeClassPath(); - - if (m_szClasspath == NULL) - { - *perr = ERR_BADCLASSPATH; - return HRESULT_FROM_WIN32(E_FAIL); - } - } - - - /* - * Second step: Check the files we're going to process. If we don't have - * an XMerge plugin for the file then we can't convert. - */ - if ((!lstrcmp(psf->szExtension, "sxw") || !lstrcmp(psf->szExtension, "psw")) - && !m_bHaveWord) - { - *perr = ERR_BADCLASSPATH; - return HRESULT_FROM_WIN32(E_FAIL); - } - else if ((!lstrcmp(psf->szExtension, "sxc") || !lstrcmp(psf->szExtension, "pxl")) - && !m_bHaveExcel) - { - *perr = ERR_BADCLASSPATH; - return HRESULT_FROM_WIN32(E_FAIL); - } - - - /* - * Third step: Locate the Java executable and build and execute the command - * line to carry out the conversion. - */ - - // Find the Java executable and make sure it exists - appName += m_szJavaBaseDir; - appName += "\\bin\\javaw.exe"; - - if (GetFileAttributes(appName.c_str()) == INVALID_FILE_SIZE) - { - *perr = ERR_NOJAVA; - return HRESULT_FROM_WIN32(E_FAIL); - } - - // Wrap the executable path in quotes in case of spaces - appName.insert(0, "\""); - appName.append("\""); - - - - // Need to build the entire command line for calling out to Java - appArgs = appName + " -Djava.class.path="; - appArgs += m_szClasspath; - appArgs += " org.openoffice.xmerge.util.ActiveSyncDriver "; - - if (!lstrcmp(psf->szExtension, "sxw")) - { - appArgs += "staroffice/sxw "; - appArgs += "application/x-pocket-word "; - } - else if(!lstrcmp(psf->szExtension, "psw")) - { - appArgs += "application/x-pocket-word "; - appArgs += "staroffice/sxw "; - } - else if(!lstrcmp(psf->szExtension, "sxc")) - { - appArgs += "staroffice/sxc "; - appArgs += "application/x-pocket-excel "; - } - else if(!lstrcmp(psf->szExtension, "pxl")) - { - appArgs += "application/x-pocket-excel "; - appArgs += "staroffice/sxc "; - } - - - // ActiveSync sometimes gives out long file names, especially when automatically syncing - appArgs += "\""; - appArgs += psf->szFullpath; - appArgs += "\" \""; - appArgs += pdf->szFullpath; - appArgs += "\""; - - if(!CreateProcess(NULL, - (char*)appArgs.c_str(), - NULL, // No Process Attributes - NULL, // No Thread Attributes - FALSE, // Don't want this process getting handles - CREATE_NO_WINDOW, // No console - NULL, // No special environment - NULL, // Current Working Directory is okay - &si, - &pi)) - { - *perr = ERR_INITJAVA; - return HRESULT_FROM_WIN32(E_FAIL); - } - - // Wait for the new process to work - WaitForSingleObject(pi.hProcess, INFINITE); - - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - - return HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS); -} - - -typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD, LPTSTR ); - - -TCHAR* CXMergeFilter::GetJavaBaseDir() -{ - HRESULT lRet; - - HKEY hKey = NULL; - HKEY hDataKey = NULL; - - TCHAR szCurrentJava[_MAX_PATH] = "\0"; - DWORD dwClassName = _MAX_PATH; - DWORD dwKeyName = _MAX_PATH; - - /* - * Java leaves registry keys at HKLM\SOFTWARE\JavaSoft. - * - * Check for a JRE installation first - */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\JavaSoft\\Java Runtime Environment"), 0, KEY_READ, &hKey); - if (lRet != ERROR_SUCCESS) - return NULL; - - // Locations shouldn't be greater than _MAX_PATH - TCHAR* szJavaHome = new TCHAR[_MAX_PATH + 1]; - DWORD dwSize = _MAX_PATH + 1; - - /* use current version */ - lRet = ::RegQueryValueEx(hKey, _T("CurrentVersion"), 0, NULL, (LPBYTE)szCurrentJava, &dwSize); - - lRet = ::RegOpenKeyEx(hKey, _T(szCurrentJava), 0, KEY_READ, &hDataKey); - if (lRet != ERROR_SUCCESS) - { - RegCloseKey(hKey); - delete [] szJavaHome; - return NULL; - } - - - // Now read the JavaHome value - dwSize = _MAX_PATH + 1; - lRet = ::RegQueryValueEx(hDataKey, _T("JavaHome"), 0, NULL, (LPBYTE)szJavaHome, &dwSize); - if (lRet != ERROR_SUCCESS) - { - RegCloseKey(hDataKey); - RegCloseKey(hKey); - delete [] szJavaHome; - return NULL; - } - - RegCloseKey(hDataKey); - RegCloseKey(hKey); - - - // Check that the directory exists before returning it - DWORD dwAttrs = GetFileAttributes(szJavaHome); - - if (((dwAttrs & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) || dwAttrs == INVALID_FILE_SIZE) - { - delete [] szJavaHome; - return NULL; - } - - return szJavaHome; -} - - - -TCHAR* CXMergeFilter::GetXMergeClassPath() -{ - /* - * The DLL will be installed by setup in the program directory of - * the installation. The XMerge Jar files, if present, will be - * located in the classes directory below program. - */ - - TCHAR szJarPath[MAX_PATH]; - TCHAR szTmpPath[MAX_PATH]; - - ZeroMemory(szJarPath, MAX_PATH); - ZeroMemory(szTmpPath, MAX_PATH); - - WIN32_FILE_ATTRIBUTE_DATA fInfo; - - std::string clsPath; - - - // Get the location of the module. - GetModuleFileName(_Module.m_hInst, szTmpPath, MAX_PATH); - - // Strip off the xmergesync.dll component - _strlwr(szTmpPath); - char* modName = strstr(szTmpPath, "xmergesync.dll"); - strncpy(szJarPath, szTmpPath, modName - szTmpPath); - - // Append the classes directory - strncat(szJarPath, "classes\\", 8); - - - // The core xmerge.jar must be present - ZeroMemory(szTmpPath, MAX_PATH); - _snprintf(szTmpPath, MAX_PATH, "%s%s\0", szJarPath, "xmerge.jar"); - - if (!GetFileAttributesEx(szTmpPath, GetFileExInfoStandard, &fInfo)) - { - return NULL; - } - else - { - clsPath += szTmpPath; - clsPath += ";"; - } - - - // Now check for Pocket Word - ZeroMemory(szTmpPath, MAX_PATH); - _snprintf(szTmpPath, MAX_PATH, "%s%s\0", szJarPath, "pocketword.jar"); - - if (!GetFileAttributesEx(szTmpPath, GetFileExInfoStandard, &fInfo)) - { - m_bHaveWord = FALSE; - } - else - { - m_bHaveWord = TRUE; - clsPath += szTmpPath; - clsPath += ";"; - } - - // Now check for Pocket Excel - ZeroMemory(szTmpPath, MAX_PATH); - _snprintf(szTmpPath, MAX_PATH, "%s%s\0", szJarPath, "pexcel.jar"); - - if (!GetFileAttributesEx(szTmpPath, GetFileExInfoStandard, &fInfo)) - { - m_bHaveExcel = FALSE; - } - else - { - m_bHaveExcel = TRUE; - clsPath += szTmpPath; - clsPath += ";"; - } - - // Quotes may be need around the ClassPath - clsPath.insert(0, "\""); - clsPath += "\""; - - - // Return the data - return _strdup(clsPath.c_str()); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/XMergeFilter.h b/xmerge/source/activesync/XMergeFilter.h deleted file mode 100644 index 9c120500d029..000000000000 --- a/xmerge/source/activesync/XMergeFilter.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// XMergeFilter.h: interface for the CXMergeFilter class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_XMERGEFILTER_H__25C39F6B_A1D7_408E_8F58_9CBEE9A666CC__INCLUDED_) -#define AFX_XMERGEFILTER_H__25C39F6B_A1D7_408E_8F58_9CBEE9A666CC__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - - - - -class CXMergeFilter : public ICeFileFilter -{ -protected: - long m_cRef; - -private: - TCHAR* GetXMergeClassPath(); - TCHAR* GetJavaBaseDir(); - - TCHAR* m_szJavaBaseDir; - TCHAR* m_szClasspath; - - BOOL m_bHaveExcel; - BOOL m_bHaveWord; - - -public: - static const LPTSTR m_pszPSWExportCLSID; - static const LPTSTR m_pszPSWExportExt; - static const LPTSTR m_pszPSWExportDesc; - static const LPTSTR m_pszPSWExportShortDesc; - - static const LPTSTR m_pszPSWImportCLSID; - static const LPTSTR m_pszPSWImportExt; - static const LPTSTR m_pszPSWImportDesc; - static const LPTSTR m_pszPSWImportShortDesc; - - static const LPTSTR m_pszPXLExportCLSID; - static const LPTSTR m_pszPXLExportExt; - static const LPTSTR m_pszPXLExportDesc; - static const LPTSTR m_pszPXLExportShortDesc; - - static const LPTSTR m_pszPXLImportCLSID; - static const LPTSTR m_pszPXLImportExt; - static const LPTSTR m_pszPXLImportDesc; - static const LPTSTR m_pszPXLImportShortDesc; - -public: - CXMergeFilter(); - virtual ~CXMergeFilter(); - - - /********** IUnknown methods **********/ - STDMETHODIMP QueryInterface(REFIID iid, void **ppvObject); - STDMETHODIMP_(ULONG) AddRef(); - STDMETHODIMP_(ULONG) Release(); - - /********** ICeFileFilter methods *********/ - STDMETHODIMP FilterOptions(HWND hwndParent); - STDMETHODIMP FormatMessage(DWORD dwFlags, DWORD dwMessageId, DWORD dwLanguageId, - LPTSTR lpBuffer, DWORD nSize, va_list *Arguments, DWORD *pcb); - STDMETHODIMP NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, - CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, - volatile BOOL *pbCancel, CF_ERROR *perr); - -}; - -#endif // !defined(AFX_XMERGEFILTER_H__25C39F6B_A1D7_408E_8F58_9CBEE9A666CC__INCLUDED_) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/XMergeSync.cpp b/xmerge/source/activesync/XMergeSync.cpp deleted file mode 100644 index 8c8178c8e613..000000000000 --- a/xmerge/source/activesync/XMergeSync.cpp +++ /dev/null @@ -1,850 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "stdafx.h" - -#include "XMergeFilter.h" -#include "XMergeFactory.h" - - -CXMergeSyncModule _Module; - - -////////////////////////////////////////////////////////////////////// -// DLL Functions -////////////////////////////////////////////////////////////////////// -BOOL WINAPI DllMain(HANDLE hInst, ULONG ulReason, LPVOID lpReserved) -{ - switch (ulReason) - { - case DLL_PROCESS_ATTACH: - _Module.m_hInst = reinterpret_cast<HINSTANCE>(hInst); - break; - - case DLL_PROCESS_DETACH: - _Module.m_hInst = NULL; - break; - - case DLL_THREAD_ATTACH: - break; - - case DLL_THREAD_DETACH: - break; - } - - return TRUE; -} - - -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) -{ - // Create the factory object - CXMergeFactory *pFactory = new CXMergeFactory(); - HRESULT hr = pFactory->QueryInterface(riid, ppv); - pFactory->Release(); - - return hr; -} - - -STDAPI DllCanUnloadNow() -{ - if (_Module.GetLockCount() == 0) - return S_OK; - - return S_FALSE; -} - - -// Utility function to close open keys during registration -static _signalRegError(long lRet, HKEY hKey, HKEY hDataKey) -{ - if (hKey) - ::RegCloseKey(hKey); - - - if (hDataKey) - ::RegCloseKey(hDataKey); - - return HRESULT_FROM_WIN32(lRet); -} - - -STDAPI DllRegisterServer() -{ - HKEY hKey = NULL; - HKEY hDataKey = NULL; - - long lRet = 0; - TCHAR sTemp[_MAX_PATH + 1] = "\0"; - - - /* - * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Writer export filter. - * - * Note that import are export are relative to the WinCE device, so files are - * exported to the desktop format. - */ - - // Get a handle to the CLSID key - lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - // Create the CLSID key for the XMergeFilter - lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPSWExportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportShortDesc, - (::_tcslen(CXMergeFilter::m_pszPSWExportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Create the DefaultIcon key. For the moment, use one of the Async supplied ones - lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) - * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - // Create the InprocServer32 key - lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - // Create the key for the DLL file. First find the filename of the dll - if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) - { - lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, - (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Setup the PegasusFilter key values - lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportDesc, - (::_tcslen(CXMergeFilter::m_pszPSWExportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("Export"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportExt, - (::_tcslen(CXMergeFilter::m_pszPSWExportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - - /* - * Following calls create the entries for the filter in - * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters - */ - - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), - 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPSWImportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), - 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPSWExportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - /* - * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Writer import filter. - * - * Note that import are export are relative to the WinCE device, so files are - * exported to the desktop format. - */ - // Get a handle to the CLSID key - lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - // Create the CLSID key for the XMergeFilter - lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPSWImportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportShortDesc, - (::_tcslen(CXMergeFilter::m_pszPSWImportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Create the DefaultIcon key. For the moment, use one of the Async supplied ones - lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) - * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Create the InprocServer32 key - lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Create the key for the DLL file. First find the filename of the dll - if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) - { - lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, - (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Setup the PegasusFilter key values - lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportDesc, - (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("Import"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportExt, - (::_tcslen(CXMergeFilter::m_pszPSWImportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - /* - * Following calls create the entries for the filter in - * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters - */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), - 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - // Add in defaults for import and export - _snprintf(sTemp, _MAX_PATH +1, "%c%s\0", '.', CXMergeFilter::m_pszPSWExportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, - (LPBYTE)CXMergeFilter::m_pszPSWImportCLSID, - (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("DefaultExport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), - (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::RegCloseKey(hDataKey); - - // Update registered filters - _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPSWExportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), - 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPSWImportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - /* - * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Calc export filter. - * - * Note that import are export are relative to the WinCE device, so files are - * exported to the desktop format. - */ - - // Get a handle to the CLSID key - lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - // Create the CLSID key for the XMerge Filter - lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPXLExportCLSID, 0, _T(""), - 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportShortDesc, - (::_tcslen(CXMergeFilter::m_pszPXLExportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Create the DefaultIcon key. For the moment, use one of the Async supplied ones - lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) - * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Create the InprocServer32 key - lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Create the key for the DLL file. First find the filename of the dll - if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) - { - lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, - (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Setup the PegasusFilter key values - lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportDesc, - (::_tcslen(CXMergeFilter::m_pszPXLExportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("Export"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportExt, - (::_tcslen(CXMergeFilter::m_pszPXLExportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - - /* - * Following calls create the entries for the filter in - * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters - */ - - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), - 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPXLImportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), - 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPXLExportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - /* - * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Calc import filter. - * - * Note that import are export are relative to the WinCE device, so files are - * exported to the desktop format. - */ - // Get a handle to the CLSID key - lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Create the CLSID key for the XMergeFilter - lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPXLImportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportShortDesc, - (::_tcslen(CXMergeFilter::m_pszPXLImportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - // Create the DefaultIcon key. For the moment, use one of the Async supplied ones - lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), - (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) - * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Create the InprocServer32 key - lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Create the key for the DLL file. First find the filename of the dll - if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) - { - lRet = ::GetLastError(); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - } - - - lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, - (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Setup the PegasusFilter key values - lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportDesc, - (::_tcslen(CXMergeFilter::m_pszPXLImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("Import"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportExt, - (::_tcslen(CXMergeFilter::m_pszPXLImportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - /* - * Following calls create the entries for the filter in - * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters - */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), - 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - // Add in defaults for import and export - _snprintf(sTemp, _MAX_PATH +1, "%c%s\0", '.', CXMergeFilter::m_pszPXLExportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, - (LPBYTE)CXMergeFilter::m_pszPXLImportCLSID, - (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - lRet = ::RegSetValueEx(hDataKey, _T("DefaultExport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), - (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::RegCloseKey(hDataKey); - - // Update registered filters - - - _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPXLExportExt); - lRet = ::RegCreateKeyEx(hKey, _T(sTemp), - 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPXLImportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::RegCloseKey(hKey); hKey = NULL; - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - return HRESULT_FROM_WIN32(lRet); -} - - -STDAPI DllUnregisterServer() -{ - long lRet = 0; - HKEY hKey = NULL; - HKEY hDataKey = NULL; - - TCHAR szClassName[_MAX_PATH] = "\0"; - TCHAR szKeyName[_MAX_PATH] = "\0"; - DWORD dwClassName = _MAX_PATH; - DWORD dwKeyName = _MAX_PATH; - - /* - * Remove HKEY_CLASS_ROOT\CLSID\{XXX} entry for the export and import filters - * - * Windows 95/98/Me allow one step deletion of a key and all subkeys. - * Windows NT/2000/XP do not so the subkeys must be deleted individually. - */ - lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // First up, the Writer export filter - lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPSWExportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) - != ERROR_NO_MORE_ITEMS) - { - lRet = ::RegDeleteKey(hDataKey, szKeyName); - - ::lstrcpy(szKeyName, "\0"); - ::lstrcpy(szClassName, "\0"); - - dwClassName = _MAX_PATH; - dwKeyName = _MAX_PATH; - } - - ::RegCloseKey(hDataKey); hDataKey = NULL; - - lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPSWExportCLSID); - if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) - return _signalRegError(lRet, hKey, hDataKey); - - - - // Next, the Writer import filter - lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPSWImportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) - != ERROR_NO_MORE_ITEMS) - { - lRet = ::RegDeleteKey(hDataKey, szKeyName); - - ::lstrcpy(szKeyName, "\0"); - ::lstrcpy(szClassName, "\0"); - - dwClassName = _MAX_PATH; - dwKeyName = _MAX_PATH; - } - - ::RegCloseKey(hDataKey); hDataKey = NULL; - - lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPSWImportCLSID); - if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) - return _signalRegError(lRet, hKey, hDataKey); - - - // Next up, the Calc export filter - lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPXLExportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) - != ERROR_NO_MORE_ITEMS) - { - lRet = ::RegDeleteKey(hDataKey, szKeyName); - - ::lstrcpy(szKeyName, "\0"); - ::lstrcpy(szClassName, "\0"); - - dwClassName = _MAX_PATH; - dwKeyName = _MAX_PATH; - } - - ::RegCloseKey(hDataKey); hDataKey = NULL; - - lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPXLExportCLSID); - if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) - return _signalRegError(lRet, hKey, hDataKey); - - - // Next, the Calc import filter - lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPXLImportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) - != ERROR_NO_MORE_ITEMS) - { - lRet = ::RegDeleteKey(hDataKey, szKeyName); - - ::lstrcpy(szKeyName, "\0"); - ::lstrcpy(szClassName, "\0"); - - dwClassName = _MAX_PATH; - dwKeyName = _MAX_PATH; - } - - ::RegCloseKey(hDataKey); hDataKey = NULL; - - lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPXLImportCLSID); - if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) - return _signalRegError(lRet, hKey, hDataKey); - - ::RegCloseKey(hKey); hKey = NULL; - - - - /* - * Remove the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters - */ - lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), - 0, KEY_ALL_ACCESS, &hKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - - // Remove the Writer export filter from the Writer import file extension subkey. - _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPSWImportExt); - lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPSWExportCLSID); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Remove the Writer import filter from the Writer export file extension subkey. - _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPSWExportExt); - lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPSWImportCLSID); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Make Binary Copy the default for Writer export file extension subkey DefaultImport - _snprintf(szKeyName, _MAX_PATH, ".%s\0", CXMergeFilter::m_pszPSWExportExt); - lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), - (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Remove the Calc export filter from the Calc import file extension subkey. - _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPXLImportExt); - lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPXLExportCLSID); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - // Remove the Calc import filter from the Calc export file extension subkey. - _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPXLExportExt); - lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPXLImportCLSID); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - // Make Binary Copy the default for Calc export file extension subkey DefaultImport - _snprintf(szKeyName, _MAX_PATH, ".%s\0", CXMergeFilter::m_pszPXLExportExt); - lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), - (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); - if (lRet != ERROR_SUCCESS) - return _signalRegError(lRet, hKey, hDataKey); - - ::lstrcpyn(szKeyName, "\0", _MAX_PATH); - ::RegCloseKey(hDataKey); hDataKey = NULL; - - - - ::RegCloseKey(hKey); hKey = NULL; - - return HRESULT_FROM_WIN32(lRet); -} - - -////////////////////////////////////////////////////////////////////// -// CXMergeSyncModule methods -////////////////////////////////////////////////////////////////////// -CXMergeSyncModule::CXMergeSyncModule () : m_lLocks(0), m_lObjs(0) -{ -} - -CXMergeSyncModule::~CXMergeSyncModule () -{ -} - -long CXMergeSyncModule::LockServer(BOOL fLock) -{ - if(fLock) - return ::InterlockedIncrement(&m_lLocks); - else - return ::InterlockedDecrement(&m_lLocks); -} - -long CXMergeSyncModule::GetLockCount() const -{ - return m_lLocks + m_lObjs; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/XMergeSync.def b/xmerge/source/activesync/XMergeSync.def deleted file mode 100644 index 89de774085f8..000000000000 --- a/xmerge/source/activesync/XMergeSync.def +++ /dev/null @@ -1,9 +0,0 @@ -
-LIBRARY "XMERGESYNC.DLL"
-DESCRIPTION 'XMerge Desktop Synchronization Module'
-
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/xmerge/source/activesync/XMergeSync.dsp b/xmerge/source/activesync/XMergeSync.dsp deleted file mode 100644 index 3c13e028e50b..000000000000 --- a/xmerge/source/activesync/XMergeSync.dsp +++ /dev/null @@ -1,143 +0,0 @@ -# Microsoft Developer Studio Project File - Name="XMergeSync" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=XMergeSync - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "XMergeSync.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "XMergeSync.mak" CFG="XMergeSync - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "XMergeSync - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "XMergeSync - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""$/XMergeSync", BAAAAAAA"
-# PROP Scc_LocalPath "."
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "XMergeSync - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\Program Files\Windows CE Tools\wce300\Pocket PC 2002\support\ActiveSync\inc" /I "C:\Java\j2sdk1.4.0\include" /I "C:\Java\j2sdk1.4.0\include\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x1809 /d "NDEBUG"
-# ADD RSC /l 0x1809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "XMergeSync - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\Program Files\Windows CE Tools\wce300\Pocket PC 2002\support\ActiveSync\inc" /I "C:\Java\j2sdk1.4.0\include" /I "C:\Java\j2sdk1.4.0\include\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /FR /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x1809 /d "_DEBUG"
-# ADD RSC /l 0x1809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"C:\Java\j2sdk1.4.0\lib"
-
-!ENDIF
-
-# Begin Target
-
-# Name "XMergeSync - Win32 Release"
-# Name "XMergeSync - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\stdafx.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeFactory.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeFilter.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeSync.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeSync.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeSync.rc
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\stdafx.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeFactory.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeFilter.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\XMergeSync.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/xmerge/source/activesync/XMergeSync.dsw b/xmerge/source/activesync/XMergeSync.dsw deleted file mode 100644 index eca2ade60ac1..000000000000 --- a/xmerge/source/activesync/XMergeSync.dsw +++ /dev/null @@ -1,33 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Project: "XMergeSync"=.\XMergeSync.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
- begin source code control
- "$/XMergeSync", BAAAAAAA
- .
- end source code control
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/xmerge/source/activesync/XMergeSync.h b/xmerge/source/activesync/XMergeSync.h deleted file mode 100644 index b5779c2ed0d0..000000000000 --- a/xmerge/source/activesync/XMergeSync.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -// XMergeSyncModule.h: interface for the CXMergeSyncModule class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_XMERGESYNCMODULE_H__0788DA0C_4DCB_4876_9722_F9EAF1EB5462__INCLUDED_) -#define AFX_XMERGESYNCMODULE_H__0788DA0C_4DCB_4876_9722_F9EAF1EB5462__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -// Used to keep track of the dll - -class CXMergeSyncModule -{ -protected: - long m_lLocks; - long m_lObjs; - -public: - long GetLockCount() const; - long LockServer(BOOL fLock); - HINSTANCE m_hInst; - CXMergeSyncModule(); - virtual ~CXMergeSyncModule(); -}; - -#endif // !defined(AFX_XMERGESYNCMODULE_H__0788DA0C_4DCB_4876_9722_F9EAF1EB5462__INCLUDED_) - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/XMergeSync.rc b/xmerge/source/activesync/XMergeSync.rc deleted file mode 100644 index 3e9d24dd9207..000000000000 --- a/xmerge/source/activesync/XMergeSync.rc +++ /dev/null @@ -1,66 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -///////////////////////////////////////////////////////////////////////////// -// English (Ireland) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENI) -#ifdef _WIN32 -//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_EIRE -LANGUAGE 0x9, 0x1 -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE DISCARDABLE -BEGIN - IDS_NOJAVA "Unable to find JRE 1.4 installation." - IDS_BADCLASSPATH "Unable to locate necessary Jar files." -END - -#endif // English (Ireland) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/xmerge/source/activesync/exports.map b/xmerge/source/activesync/exports.map deleted file mode 100644 index e78067c51ff5..000000000000 --- a/xmerge/source/activesync/exports.map +++ /dev/null @@ -1,29 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -UDK_3_0_0 { - global: - DllCanUnloadNow; - DllGetClassObject; - DllRegisterServer; - DllUnregisterServer; - - local: - *; -}; - diff --git a/xmerge/source/activesync/guids.txt b/xmerge/source/activesync/guids.txt deleted file mode 100644 index 1bde5587c169..000000000000 --- a/xmerge/source/activesync/guids.txt +++ /dev/null @@ -1,60 +0,0 @@ -INTERFACENAME = { /* bdd611c3-7bab-460f-8711-5b9ac9ef6020 - StarWriter Export*/ - 0xbdd611c3, - 0x7bab, - 0x460f, - {0x87, 0x11, 0x5b, 0x9a, 0xc9, 0xef, 0x60, 0x20} - }; -INTERFACENAME = { /* cb43f086-838d-4fa4-b5f6-3406b9a57439 - Pocket Word Import */ - 0xcb43f086, - 0x838d, - 0x4fa4, - {0xb5, 0xf6, 0x34, 0x06, 0xb9, 0xa5, 0x74, 0x39} - }; -INTERFACENAME = { /* c6ab3e74-9f4f-4370-8120-a8a6fabb7a7c - StarCalc Export*/ - 0xc6ab3e74, - 0x9f4f, - 0x4370, - {0x81, 0x20, 0xa8, 0xa6, 0xfa, 0xbb, 0x7a, 0x7c} - }; -INTERFACENAME = { /* 43887c67-4d5d-4127-baac-87a288494c7c - Pocket Excel Import*/ - 0x43887c67, - 0x4d5d, - 0x4127, - {0xba, 0xac, 0x87, 0xa2, 0x88, 0x49, 0x4c, 0x7c} - }; -INTERFACENAME = { /* 300b7580-50f6-448b-aabb-9b823cab6e88 */ - 0x300b7580, - 0x50f6, - 0x448b, - {0xaa, 0xbb, 0x9b, 0x82, 0x3c, 0xab, 0x6e, 0x88} - }; -INTERFACENAME = { /* e88b223c-ffb4-456f-b93b-0f59594b228e */ - 0xe88b223c, - 0xffb4, - 0x456f, - {0xb9, 0x3b, 0x0f, 0x59, 0x59, 0x4b, 0x22, 0x8e} - }; -INTERFACENAME = { /* 8a538ec1-7d68-4ad0-9cf9-6e4d9f8c6ff0 */ - 0x8a538ec1, - 0x7d68, - 0x4ad0, - {0x9c, 0xf9, 0x6e, 0x4d, 0x9f, 0x8c, 0x6f, 0xf0} - }; -INTERFACENAME = { /* 7b613acf-9d1b-4bb9-b58e-15e0f5e21765 */ - 0x7b613acf, - 0x9d1b, - 0x4bb9, - {0xb5, 0x8e, 0x15, 0xe0, 0xf5, 0xe2, 0x17, 0x65} - }; -INTERFACENAME = { /* fbf4de58-cfe8-4244-bf73-6162035ae0c6 */ - 0xfbf4de58, - 0xcfe8, - 0x4244, - {0xbf, 0x73, 0x61, 0x62, 0x03, 0x5a, 0xe0, 0xc6} - }; -INTERFACENAME = { /* 62bf28c1-ce42-4b56-a218-980e8c4ba080 */ - 0x62bf28c1, - 0xce42, - 0x4b56, - {0xa2, 0x18, 0x98, 0x0e, 0x8c, 0x4b, 0xa0, 0x80} - }; diff --git a/xmerge/source/activesync/makefile.mk b/xmerge/source/activesync/makefile.mk deleted file mode 100644 index 45714ce3a4fa..000000000000 --- a/xmerge/source/activesync/makefile.mk +++ /dev/null @@ -1,62 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ = ..$/.. -PRJNAME = xmerge -TARGET = xmergesync -ENABLE_EXCEPTIONS=TRUE -LIBTARGET=NO -.IF "$(POCKETPCSDK_HOME)" != "" -SOLARINC+=-I$(POCKETPCSDK_HOME)$/support$/ActiveSync$/inc -.ENDIF # "$(POCKETPCSDK_HOME)" != "" - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - -.IF 0 -.IF "$(OS)" == "WNT" -.IF "$(POCKETPCSDK_HOME)" != "" - -RCFILES=XMergeSync.rc - -SLOFILES= \ - $(SLO)$/XMergeFactory.obj \ - $(SLO)$/XMergeSync.obj \ - $(SLO)$/XMergeFilter.obj -LIBNAME=$(TARGET) -SHL1TARGETDEPN=makefile.mk -SHL1OBJS=$(SLOFILES) $(RES)$/xmergesync.res -SHL1TARGET=$(LIBNAME) -SHL1IMPLIB=i$(LIBNAME) -SHL1DEF=XMergeSync.def -USE_DEFFILE=true - -SHL1STDLIBS= uuid.lib Advapi32.lib - -.ENDIF # "$(POCKETPCSDK_HOME)" != "" -.ENDIF -.ENDIF - - -# --- Targets ------------------------------------------------------ -.INCLUDE : target.mk - -ALLTAR : - .IF "$(OS)" == "WNT" - $(COPY) BIN$/xmergesync.dll $(BIN) - .ENDIF diff --git a/xmerge/source/activesync/resource.h b/xmerge/source/activesync/resource.h deleted file mode 100644 index aceaa7f803cb..000000000000 --- a/xmerge/source/activesync/resource.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by XMergeSync.rc -// -#define IDS_NOJAVA 1 -#define IDS_BADCLASSPATH 2 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/stdafx.cpp b/xmerge/source/activesync/stdafx.cpp deleted file mode 100644 index af75dd22d522..000000000000 --- a/xmerge/source/activesync/stdafx.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// -// stdafx.cpp : source file that includes just the standard includes -// stdafx.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information -// -#include "stdafx.h" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/activesync/stdafx.h b/xmerge/source/activesync/stdafx.h deleted file mode 100644 index fd781710b688..000000000000 --- a/xmerge/source/activesync/stdafx.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently -// -#pragma once - -#include <windows.h> -#include <shlobj.h> -#include <stdio.h> -#include <tchar.h> -#include <time.h> - -#define INITGUIDS -#include <initguid.h> - -#include <cesync.h> -#include <replfilt.h> - -#include "XMergeSync.h" - -// -// This declares the one & only instance of the CXMergeSyncModule class. -// You can access any public members of this class through the -// global _Module. (Its definition is in XMergeSync.cpp.) -// -extern CXMergeSyncModule _Module; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/aportisdoc/converter.xml b/xmerge/source/aportisdoc/converter.xml deleted file mode 100644 index 01a2e05ed2b3..000000000000 --- a/xmerge/source/aportisdoc/converter.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<converters> - <converter type="staroffice/sxw" version="1.0"> - <converter-display-name> - AportisDoc - </converter-display-name> - <converter-description> - StarWriter XML to/from AportisDoc conversion - </converter-description> - <converter-vendor>OpenOffice.org</converter-vendor> - <converter-class-impl> - org.openoffice.xmerge.converter.xml.sxw.aportisdoc.PluginFactoryImpl - </converter-class-impl> - <converter-target type="application/x-aportisdoc" /> - </converter> -</converters> - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl.java deleted file mode 100644 index 169a9dc69ecd..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/ConverterCapabilitiesImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.OfficeConstants; - -/** - * <p>AportisDoc implementation of <code>ConverterCapabilities</code> for - * the {@link - * org.openoffice.xmerge.converter.xml.sxw.aportisdoc.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>Used with StarWriter XML to/from AportisDoc conversions. The - * <code>ConverterCapibilies</code> specify which "Office" - * <code>Document</code> tags and attributes are supported on the - * "Device" <code>Document</code> format.</p> - */ -public final class ConverterCapabilitiesImpl - implements ConverterCapabilities { - - public boolean canConvertTag(String tag) { - - if (OfficeConstants.TAG_OFFICE_DOCUMENT.equals(tag)) - return true; - else if (OfficeConstants.TAG_OFFICE_DOCUMENT_CONTENT.equals(tag)) - return true; - else if (OfficeConstants.TAG_OFFICE_BODY.equals(tag)) - return true; - else if (OfficeConstants.TAG_PARAGRAPH.equals(tag)) - return true; - else if (OfficeConstants.TAG_HEADING.equals(tag)) - return true; - else if (OfficeConstants.TAG_ORDERED_LIST.equals(tag)) - return true; - else if (OfficeConstants.TAG_UNORDERED_LIST.equals(tag)) - return true; - else if (OfficeConstants.TAG_LIST_ITEM.equals(tag)) - return true; - else if (OfficeConstants.TAG_LIST_HEADER.equals(tag)) - return true; - else if (OfficeConstants.TAG_SPAN.equals(tag)) - return true; - else if (OfficeConstants.TAG_HYPERLINK.equals(tag)) - return true; - else if (OfficeConstants.TAG_LINE_BREAK.equals(tag)) - return true; - else if (OfficeConstants.TAG_SPACE.equals(tag)) - return true; - else if (OfficeConstants.TAG_TAB_STOP.equals(tag)) - return true; - - return false; - } - - public boolean canConvertAttribute(String tag, - String attribute) { - - if (OfficeConstants.TAG_SPACE.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_SPACE_COUNT.equals(attribute)) - return true; - } - - return false; - } -} - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants.java deleted file mode 100644 index c5e0c1a99833..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocConstants.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import org.openoffice.xmerge.converter.palm.PdbUtil; - -/** - * Constants used for encoding and decoding the AportisDoc format. - * - */ -interface DocConstants { - - /** Creator id. */ - public static final int CREATOR_ID = PdbUtil.intID("REAd"); - - /** Type id. */ - public static final int TYPE_ID = PdbUtil.intID("TEXt"); - - /** Constant for uncompressed version. */ - public static final short UNCOMPRESSED = 1; - - /** Constant for compressed version. */ - public static final short COMPRESSED = 2; - - /** Constant used for spare fields. */ - public static final int SPARE = 0; - - /** AportisDoc record size. */ - public static final short TEXT_RECORD_SIZE = 4096; - - /** Constant for encoding scheme. */ - public static final String ENCODING = "8859_1"; - - /** Constant for TAB character. */ - public final static char TAB_CHAR = '\t'; - - /** Constant for EOL character. */ - public final static char EOL_CHAR = '\n'; - - /** Constant for SPACE character. */ - public final static char SPACE_CHAR = ' '; -} - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java deleted file mode 100644 index f6b203b68af7..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocDecoder.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; - -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.util.Resources; -import org.openoffice.xmerge.util.Debug; - -/** - * This class is used by {@link DocumentDeserializerImpl} - * to decode the AportisDoc format. It currently decodes - * the text content into a single <code>String</code> object. - * - */ -final class DocDecoder implements DocConstants { - - /** For decoding purposes. */ - private final static int COUNT_BITS = 3; - - /** Resources object for I18N. */ - private Resources res = null; - - - /** - * Default constructor creates a header and a text buffer - * for holding all the text in the AportisDoc database. - */ - DocDecoder() { - res = Resources.getInstance(); - } - - - /** - * Decode the text records into a single <code>String</code> - * of text content. - * - * @param recs <code>Record</code> array holding AportisDoc - * contents. - * - * @throws IOException If any I/O error occurs. - */ - String parseRecords(Record[] recs) throws IOException { - - // read the header record - HeaderInfo header = readHeader(recs[0].getBytes()); - - dumpHeader(header); - - // store all the characters in textBuffer - StringBuffer textBuffer = new StringBuffer(header.textLen); - - switch (header.version) { - - case COMPRESSED: - for (int i = 1; i <= header.textRecordCount; i++) { - - byte[] bytes = decompress(recs[i].getBytes(), - header.textRecordSize); - log("processing " + bytes.length + " bytes"); - String str = new String(bytes, ENCODING); - textBuffer.append(str); - } - - break; - - case UNCOMPRESSED: - for (int i = 1; i <= header.textRecordCount; i++) { - - byte[] bytes = recs[i].getBytes(); - log("processing " + bytes.length + " bytes"); - String str = new String(bytes, ENCODING); - textBuffer.append(str); - } - - break; - - default: - throw new IOException(res.getString("UNKNOWN_DOC_VERSION")); - - } - - return textBuffer.toString(); - } - - - /** - * <p>Decompress the <code>byte</code> array.</p> - * - * <p>The resulting uncompressed <code>byte</code> array should - * be within <code>textRecordSize</code> length, definitely - * within twice the size it claims, else treat it as a problem - * with the encoding of that PDB and throw - * <code>IOException</code>.</p> - * - * @param cBytes Compressed <code>byte</code> array. - * @param textRecordSize Size of uncompressed - * <code>byte</code> array. - * - * @throws IOException If <code>textRecordSize</code> < - * <code>cBytes.length</code>. - */ - private byte[] decompress(byte[] cBytes, int textRecordSize) - throws IOException { - - // create byte array for storing uncompressed bytes - // it should be within textRecordSize range, definitely - // within twice of textRecordSize! if not, then - // an ArrayIndexOutOfBoundsException will get thrown, - // and it should be converted into an IOException, and - // treat it as a conversion error. - byte[] uBytes = new byte[textRecordSize*2]; - - int up = 0; - int cp = 0; - - try { - - while (cp < cBytes.length) { - - int c = cBytes[cp++] & 0xff; - - // codes 1...8 mean copy that many bytes - if (c > 0 && c < 9) { - - while (c-- > 0) - uBytes[up++] = cBytes[cp++]; - } - - // codes 0, 9...0x7F represent themselves - else if (c < 0x80) { - uBytes[up++] = (byte) c; - } - - // codes 0xC0...0xFF represent "space + ascii char" - else if (c >= 0xC0) { - uBytes[up++] = (byte) ' '; - uBytes[up++] = (byte) (c ^ 0x80); - } - - // codes 0x80...0xBf represent sequences - else { - c <<= 8; - c += cBytes[cp++] & 0xff; - int m = (c & 0x3fff) >> COUNT_BITS; - int n = c & ((1 << COUNT_BITS) - 1); - n += COUNT_BITS; - while (n-- > 0) { - uBytes[up] = uBytes[up - m]; - up++; - } - } - } - - } catch (ArrayIndexOutOfBoundsException e) { - - throw new IOException( - res.getString("DOC_TEXT_RECORD_SIZE_EXCEEDED")); - } - - // note that ubytes may be larger that the amount of - // uncompressed bytes, so trim it to another byte array - // with the exact size. - byte[] textBytes = new byte[up]; - System.arraycopy(uBytes, 0, textBytes, 0, up); - - return textBytes; - } - - - /** - * Read the header <code>byte</code> array. - * - * @param bytes <code>byte</code> array containing header - * record data. - * - * @return <code>HeaderInfo</code> object. - * - * @throws IOException If any I/O error occurs. - */ - private HeaderInfo readHeader(byte[] bytes) throws IOException { - - HeaderInfo header = new HeaderInfo(); - - ByteArrayInputStream bis = new ByteArrayInputStream(bytes); - DataInputStream dis = new DataInputStream(bis); - - // Normally the first 2 bytes comprised of the version - // which should either be COMPRESSED or UNCOMPRESSED - // SmartDoc/Quickword would add a 0x01 to the first - // byte, thus their version would be 0x0101 for UNCOMPRESSED - // instead of 0x0001 and 0x0102 for UNCOMPRESSED instead of - // 0x0002. - - dis.readByte(); - header.version = dis.readByte(); - - // read extra 2 unused bytes - dis.readShort(); - - // Read the text length, this should be unsigned 4 bytes. - // We could store the read value into a long, but then - // our current buffer limit is the max positive of an int. - // That is a large enough limit, thus we shall stay with - // storing the value in an int. If it exceeds, then - // an IOException should be thrown. - header.textLen = dis.readInt(); - if (header.textLen < 0) { - throw new IOException(res.getString("DOC_TEXT_LENGTH_EXCEEDED")); - } - - // read the number of records - unsigned 2 bytes - header.textRecordCount = dis.readShort() & 0x0000ffff; - - // read the record size - unsigned 2 bytes - header.textRecordSize = dis.readShort() & 0x0000ffff; - - // read extra 4 unused bytes - dis.readInt(); - - return header; - } - - - /** - * Prints out header info into log. Used for debugging purposes only. - * - * @param header <code>HeaderInfo</code> structure. - */ - private void dumpHeader(HeaderInfo header) { - - log("<DOC_INFO "); - log("version=\"" + header.version + "\" "); - log("text-length=\"" + header.textLen + "\" "); - log("number-of-records=\"" + header.textRecordCount + "\" "); - log("record-size=\"" + header.textRecordSize + "\" />"); - } - - - /** - * Sends message to the log object. - * - * @param str Debug string message. - */ - private void log(String str) { - Debug.log(Debug.TRACE, str); - } - - - /** - * Inner class to store AportisDoc header information. - */ - private class HeaderInfo { - - /** length of text section */ - int textLen = 0; - - /** number of text records */ - int textRecordCount = 0; - - /** - * size of a text record. This is normally the same as - * TEXT_RECORD_SIZE, but some applications may modify this. - */ - int textRecordSize = 0; - - /** compression type */ - int version = 0; - } -} - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java deleted file mode 100644 index 70035bfa61f9..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocEncoder.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.List; -import java.util.ArrayList; - -import org.openoffice.xmerge.converter.palm.Record; - -/** - * This class is used by {@link DocumentSerializerImpl} to encode the AportisDoc format. - * It does not deal with any XML tags. It only knows how to encode - * from <code>String</code>. - * - */ -final class DocEncoder implements DocConstants { - - /** Text buffer to contain text section. */ - private StringBuffer textBuffer = null; - - /** Length of text section. */ - private int textLen = 0; - - /** Number of text records. */ - private int textRecCount = 0; - - - /** - * Default constructor creates a header and - * a text buffer for holding all the text in - * the AportisDoc database. - */ - DocEncoder() { - - textBuffer = new StringBuffer(TEXT_RECORD_SIZE); - } - - - /** - * This method appends text into the text section of - * the AportisDoc database. - * - * @param text <code>String</code> to append. - */ - void addText(String text) { - - textBuffer.append(text); - } - - - /** - * This method appends text into the text section of - * the AportisDoc database. - * - * @param text <code>char</code> array to append. - */ - void addText(char[] text) { - - textBuffer.append(text); - } - - - /** - * This method appends text character into the text - * section of the AportisDoc database. - * - * @param text <code>char</code> to append. - */ - void addText(char text) { - - textBuffer.append(text); - } - - - /** - * This method encodes the information given to a - * palm <code>Record</code> array in the AportisDoc - * database format. - * - * @return <code>Record</code> array holding AportisDoc - * contents. - * - * @throws IOException If any I/O error occurs. - */ - Record[] getRecords() throws IOException { - - byte textBytes[] = processTextBuffer(); - textLen = textBytes.length; - textRecCount = (short) (textBytes.length / TEXT_RECORD_SIZE); - - // recBytes to hold a record of bytes at a time - byte recBytes[] = new byte[TEXT_RECORD_SIZE]; - int pos = 0; - - List<Record> textRecords = new ArrayList<Record>(textRecCount + 1); - - // split textBytes into chunks of Record objects - // and store in textRecords object. - for (int i = 0; i < textRecCount; i++) { - - System.arraycopy(textBytes, pos, recBytes, 0, recBytes.length); - pos += recBytes.length; - Record zRec = new Record(recBytes); - textRecords.add(zRec); - } - - // there's more if ... - - if (pos < textLen) { - - textRecCount++; - - recBytes = new byte[textLen - pos]; - System.arraycopy(textBytes, pos, recBytes, 0, recBytes.length); - Record rec = new Record(recBytes); - textRecords.add(rec); - } - - // construct the Record array and copy - // references from textRecords. - - Record[] allRecords = new Record[textRecords.size() + 1]; - - allRecords[0] = new Record(getHeaderBytes()); - - for (int i = 1; i < allRecords.length; i++) { - - allRecords[i] = textRecords.get(i-1); - } - - return allRecords; - } - - - /** - * This method converts the text buffer into a <code>byte</code> - * array with the proper encoding of the text section of the - * AportisDoc format. - * - * TODO: do compression. - * - * @return byte[] Converted <code>byte</code> array of text - * section. - * - * @throws IOException If any I/O error occurs. - */ - private byte[] processTextBuffer() throws IOException - { - String str = textBuffer.toString(); - byte bytes[] = str.getBytes(ENCODING); - - return bytes; - } - - - /** - * This method produces the <code>byte</code> array for the header. - * - * @return <code>byte</code> array containing header record data. - * - * @throws IOException If any I/O error occurs. - */ - private byte[] getHeaderBytes() throws IOException - { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(bos); - - // TODO: for now, we shall use UNCOMPRESSED. - // later, we need to use COMPRESSED or a setting. - dos.writeShort(UNCOMPRESSED); - dos.writeShort(SPARE); - dos.writeInt(textLen); - dos.writeShort(textRecCount); - dos.writeShort(TEXT_RECORD_SIZE); - dos.writeInt(SPARE); - - byte[] bytes = bos.toByteArray(); - - return bytes; - } -} - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java deleted file mode 100644 index 2765aad24682..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentDeserializerImpl.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import java.io.IOException; -import java.util.Iterator; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.util.Debug; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -/** - * <p>AportisDoc implementation of <code>DocumentDeserializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.aportisdoc.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>This converts an file in AportisDoc PDB format to StarOffice - * XML format.</p> - * - * <p>The <code>deserialize</code> method uses a <code>DocDecoder</code> - * to read the AportisDoc format into a <code>String</code> object, then - * it calls <code>buildDocument</code> to create a <code>SxwDocument</code> - * object from it.</p> - * - */ -public final class DocumentDeserializerImpl - implements OfficeConstants, DocConstants, DocumentDeserializer { - - /** A <code>ConvertData</code> object assigned to this object. */ - private ConvertData cd = null; - - - /** - * Constructor that assigns the given <code>ConvertData</code> - * to this object as input. - * - * @param cd A <code>ConvertData</code> object to read data for - * the conversion process by the <code>deserialize</code> - * method. - */ - public DocumentDeserializerImpl(ConvertData cd) { - this.cd = cd; - } - - - /** - * Convert the given <code>ConvertData</code> object - * into a <code>SxwDocument</code> object. - * - * @return Resulting <code>SxwDocument</code> object. - * - * @throws ConvertException If any conversion error occurs. - * @throws IOException If any I/O error occurs. - */ - public Document deserialize() throws IOException, ConvertException { - - Document doc = null; - Iterator<Object> e = cd.getDocumentEnumeration(); - while (e.hasNext()) { - PalmDocument palmDoc = (PalmDocument) e.next(); - PalmDB pdb = palmDoc.getPdb(); - - log("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - log("<AportisDoc>"); - - Record[] recs = pdb.getRecords(); - String docName = palmDoc.getName(); - DocDecoder decoder = new DocDecoder(); - String text = decoder.parseRecords(recs); - doc = buildDocument(docName, text); - - log("</AportisDoc>"); - } - - return doc; - } - - - /** - * Parses the text content of an AportisDoc format and build a - * <code>SxwDocument</code>. - * - * @param docName Name of <code>Document</code>. - * @param str Text content of AportisDoc format. - * - * @return Resulting <code>SxwDocument</code> object. - * - * @throws IOException If any I/O error occurs. - */ - private SxwDocument buildDocument(String docName, String str) - throws IOException { - - // create minimum office xml document. - SxwDocument sxwDoc = new SxwDocument(docName); - sxwDoc.initContentDOM(); - - org.w3c.dom.Document doc = sxwDoc.getContentDOM(); - - // Grab hold of the office:body tag, - // Assume there should be one. - // This is where top level paragraphs will append to. - NodeList list = doc.getElementsByTagName(TAG_OFFICE_BODY); - Node bodyNode = list.item(0); - - // Store all the text in a character array. - char[] text = str.toCharArray(); - - // startIndex has 2 purposes: - // if value is -1, it means that there are no text characters - // needed to be processed for a Text node. if value >= 0, it - // is the index of the starting position of a text section - // for a Text node. - int startIndex = -1; - - // Create a paragraph node to start with. - Element paraNode = doc.createElement(TAG_PARAGRAPH); - - log("<PARA>"); - - for (int i = 0; i < text.length; i++) { - - switch (text[i]) { - - case TAB_CHAR: - - // Check if there are text to be processed first. - if (startIndex >= 0) { - addTextNode(doc, paraNode, text, startIndex, i - 1); - startIndex = -1; - } - - // Then, add tab element. - Element tabNode = doc.createElement(TAG_TAB_STOP); - paraNode.appendChild(tabNode); - - log("<TAB/>"); - break; - - case EOL_CHAR: - - // Check if there are text to be processed first. - if (startIndex >= 0) { - addTextNode(doc, paraNode, text, startIndex, i - 1); - startIndex = -1; - } - - // Then, add the current paragraph to body. - bodyNode.appendChild(paraNode); - - // Create another paragraph element. - paraNode = doc.createElement(TAG_PARAGRAPH); - - log("</PARA>"); - log("<PARA>"); - break; - - case SPACE_CHAR: - - // count is the number of space chars from i - int count = 0; - - // Do a look ahead and count the number of space chars - while (text[i + 1 + count] == SPACE_CHAR) { - count++; - } - - // Need to build a space node ONLY if count is > 1. - - if (count > 0) { - - // Check if there are text to be processed first - if (startIndex >= 0) { - addTextNode(doc, paraNode, text, - startIndex, i); - startIndex = -1; - } - - // Then, create a space element - // with the proper attribute. - Element spaceNode = doc.createElement(TAG_SPACE); - spaceNode.setAttribute(ATTRIBUTE_SPACE_COUNT, - Integer.toString(count)); - - paraNode.appendChild(spaceNode); - - // reposition i to the last space character. - i += count; - - log("<SPACE count=\"" + count + "\" />"); - - } else { - - // If there are no chars for text node yet, - // consider this one. - if (startIndex < 0) { - - startIndex = i; - log("<TEXT>"); - } - } - - break; - - default: - - // If there are no chars for text node yet, - // this should be the start. - if (startIndex < 0) { - - startIndex = i; - log("<TEXT>"); - } - - break; - } - } - - int lastIndex = text.length - 1; - - // Check if there are text to be processed first. - - if (startIndex >= 0) { - addTextNode(doc, paraNode, text, startIndex, lastIndex); - } - - // Then, add the last paragraph element if it is not added yet. - if (text[lastIndex] != EOL_CHAR) { - bodyNode.appendChild(paraNode); - } - - log("</PARA>"); - - return sxwDoc; - } - - - /** - * Add a Text <code>Node</code> to the given paragraph node with the - * text starting at the given <code>startPos</code> until - * <code>endPos</code>. - * - * @param doc <code>org.w3c.dom.Document</code> object for creating - * <code>Node</code> objects. - * @param para The current paragraph <code>Node</code> to append - * text <code>Node</code>. - * @param text Array of characters containing text. - * @param startPos Starting index position for text value. - * @param endPos End index position for text value. - */ - private void addTextNode(org.w3c.dom.Document doc, Node para, char text[], - int startPos, int endPos) { - - String str = new String(text, startPos, endPos - startPos + 1); - Text textNode = doc.createTextNode(str); - para.appendChild(textNode); - log(str); - log("</TEXT>"); - } - - /** - * Sends message to the log object. - * - * @param str Debug message. - */ - private void log(String str) { - - Debug.log(Debug.TRACE, str); - } -} - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl.java deleted file mode 100644 index f3e9f045c957..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentMergerImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import org.w3c.dom.Document; - -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.MergeException; -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.merger.DiffAlgorithm; -import org.openoffice.xmerge.merger.Difference; -import org.openoffice.xmerge.merger.NodeMergeAlgorithm; -import org.openoffice.xmerge.merger.Iterator; -import org.openoffice.xmerge.merger.diff.ParaNodeIterator; -import org.openoffice.xmerge.merger.diff.IteratorLCSAlgorithm; -import org.openoffice.xmerge.merger.merge.DocumentMerge; -import org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge; -import org.openoffice.xmerge.util.Debug; - - -/** - * AportisDoc implementation of <code>DocumentMerger</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.aportisdoc.PluginFactoryImpl - * PluginFactoryImpl}.</p> - */ -public class DocumentMergerImpl implements DocumentMerger { - - private ConverterCapabilities cc_; - private org.openoffice.xmerge.Document orig = null; - - public DocumentMergerImpl(org.openoffice.xmerge.Document doc, ConverterCapabilities cc) { - cc_ = cc; - this.orig = doc; - } - - public void merge(org.openoffice.xmerge.Document modifiedDoc) throws MergeException { - - SxwDocument wdoc1 = (SxwDocument) orig; - SxwDocument wdoc2 = (SxwDocument) modifiedDoc; - - Document doc1 = wdoc1.getContentDOM(); - Document doc2 = wdoc2.getContentDOM(); - - Iterator i1 = new ParaNodeIterator(cc_, doc1.getDocumentElement()); - Iterator i2 = new ParaNodeIterator(cc_, doc2.getDocumentElement()); - - DiffAlgorithm diffAlgo = new IteratorLCSAlgorithm(); - - // find out the paragrah level diffs - Difference[] diffTable = diffAlgo.computeDiffs(i1, i2); - - if (Debug.isFlagSet(Debug.INFO)) { - Debug.log(Debug.INFO, "Diff Result: "); - - for (int i = 0; i < diffTable.length; i++) { - Debug.log(Debug.INFO, diffTable[i].debug()); - } - } - - // merge the paragraphs - NodeMergeAlgorithm charMerge = new CharacterBaseParagraphMerge(); - DocumentMerge docMerge = new DocumentMerge(cc_, charMerge); - - docMerge.applyDifference(i1, i2, diffTable); - } -} - - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl.java deleted file mode 100644 index 45bd15832f8e..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/DocumentSerializerImpl.java +++ /dev/null @@ -1,521 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; - -import java.io.IOException; -import java.net.URLDecoder; - -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.converter.xml.sxw.aportisdoc.DocConstants; -import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.XmlUtil; - -/** - * <p>AportisDoc implementation of - * org.openoffice.xmerge.DocumentSerializer - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.aportisdoc.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>The <code>serialize</code> method traverses the DOM - * document from the given <code>Document</code> object. It uses a - * <code>DocEncoder</code> object for the actual conversion of - * contents to the AportisDoc format.</p> - * - */ - - -public final class DocumentSerializerImpl - implements OfficeConstants, DocConstants, DocumentSerializer { - - /** A <code>DocEncoder</code> object for encoding to AportisDoc. */ - private DocEncoder encoder = null; - - /** SXW <code>Document</code> object that this converter processes. */ - private SxwDocument sxwDoc = null; - - - /** - * Constructor. - * - * @param doc A SXW <code>Document</code> to be converted. - */ - public DocumentSerializerImpl(Document doc) { - sxwDoc = (SxwDocument) doc; - } - - - /** - * <p>Method to convert a <code>Document</code> into a PDB. - * It passes back the converted data as a <code>ConvertData</code> - * object.</p> - * - * <p>This method is not thread safe for performance reasons. - * This method should not be called from within two threads. - * It would be best to call this method only once per object - * instance.</p> - * - * @return The <code>ConvertData</code> object containing the output. - * - * @throws ConvertException If any conversion error occurs. - * @throws IOException If any I/O error occurs. - */ - public ConvertData serialize() throws ConvertException, IOException { - - - // get the server document name - - String docName = URLDecoder.decode(sxwDoc.getName(), DocConstants.ENCODING); - - // get DOM document - - org.w3c.dom.Document domDoc = sxwDoc.getContentDOM(); - - encoder = new DocEncoder(); - - // Traverse to the office:body element. - // There should only be one. - - NodeList list = domDoc.getElementsByTagName(TAG_OFFICE_BODY); - int len = list.getLength(); - - if (len > 0) { - Node node = list.item(0); - traverseBody(node); - } - - // create a ConvertData object. - // - Record records[] = encoder.getRecords(); - ConvertData cd = new ConvertData(); - - PalmDocument palmDoc = new PalmDocument(docName, - DocConstants.CREATOR_ID, DocConstants.TYPE_ID, - 0, PalmDB.PDB_HEADER_ATTR_BACKUP, records); - - cd.addDocument(palmDoc); - return cd; - } - - - /** - * This method traverses <i>office:body</i> element. - * - * @param node <i>office:body</i> <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseBody(Node node) throws IOException { - - log("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); - log("<AportisDOC>"); - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH) || - nodeName.equals(TAG_HEADING)) { - - traverseParagraph(child); - - } else if (nodeName.equals(TAG_UNORDERED_LIST)) { - - traverseList(child); - - } else if (nodeName.equals(TAG_ORDERED_LIST)) { - - traverseList(child); - - } else { - - log("<OTHERS " + XmlUtil.getNodeInfo(child) + " />"); - } - } - } - } - - log("</AportisDOC>"); - } - - - /** - * This method traverses the <i>text:p</i> and <i>text:h</i> - * element <code>Node</code> objects. - * - * @param node A <i>text:p</i> or <i>text:h</i> - * <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseParagraph(Node node) throws IOException { - - log("<PARA>"); - traverseParaContents(node); - encoder.addText(EOL_CHAR); - log("</PARA>"); - } - - - /** - * This method traverses a paragraph content. - * It uses the <code>traverseParaElem</code> method to - * traverse into Element <code>Node</code> objects. - * - * @param node A paragraph or content <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseParaContents(Node node) throws IOException { - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - short nodeType = child.getNodeType(); - - switch (nodeType) { - - case Node.TEXT_NODE: - // this is for grabbing text nodes. - String s = child.getNodeValue(); - - if (s.length() > 0) { - encoder.addText(s); - } - - log("<TEXT>"); - log(s); - log("</TEXT>"); - - break; - - case Node.ELEMENT_NODE: - - traverseParaElem(child); - break; - - case Node.ENTITY_REFERENCE_NODE: - - log("<ENTITY_REFERENCE>"); - traverseParaContents(child); - log("<ENTITY_REFERENCE/>"); - break; - - default: - log("<OTHERS " + XmlUtil.getNodeInfo(node) + " />"); - } - } - } - } - - - /** - * This method traverses an <code>Element</code> <code>Node</code> - * within a paragraph. - * - * @param node <code>Element</code> <code>Node</code> within a - * paragraph. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseParaElem(Node node) throws IOException { - - String nodeName = node.getNodeName(); - - if (nodeName.equals(TAG_SPACE)) { - - // this is for text:s tags. - NamedNodeMap map = node.getAttributes(); - Node attr = map.getNamedItem(ATTRIBUTE_SPACE_COUNT); - StringBuffer space = new StringBuffer(SPACE_CHAR); - int count = 1; - - if (attr != null) { - - try { - - String countStr = attr.getNodeValue(); - count = Integer.parseInt(countStr.trim()); - - } catch (NumberFormatException e) { - - // TODO: for now, throw IOException. - // later, perhaps will have to throw - // some other conversion exception instead. - throw new IOException(e.getMessage()); - } - } - - for (int j = 0; j < count; j++) { - - space.append(SPACE_CHAR); - } - - encoder.addText(space.toString()); - - log("<SPACE count=\"" + count + "\" />"); - - } else if (nodeName.equals(TAG_TAB_STOP)) { - - // this is for text:tab-stop - encoder.addText(TAB_CHAR); - - log("<TAB/>"); - - } else if (nodeName.equals(TAG_LINE_BREAK)) { - - // commented out by Csaba: There is no point to convert a linebreak - // into a EOL, because it messes up the number of XML nodes and the - // merge won't work properly. Other solution would be to implement such - // nodemerger, which would be able to merge embedded tags in a paragraph - - // this is for text:line-break - // encoder.addText(EOL_CHAR); - - log("skipped <LINE-BREAK/>"); - - } else if (nodeName.equals(TAG_SPAN)) { - - // this is for text:span - log("<SPAN>"); - traverseParaContents(node); - log("</SPAN>"); - - } else if (nodeName.equals(TAG_HYPERLINK)) { - - // this is for text:a - log("<HYPERLINK>"); - traverseParaContents(node); - log("<HYPERLINK/>"); - - } else if (nodeName.equals(TAG_BOOKMARK) || - nodeName.equals(TAG_BOOKMARK_START)) { - - log("<BOOKMARK/>"); - - } else if (nodeName.equals(TAG_TEXT_VARIABLE_SET) - || nodeName.equals(TAG_TEXT_VARIABLE_GET) - || nodeName.equals(TAG_TEXT_EXPRESSION) - || nodeName.equals(TAG_TEXT_USER_FIELD_GET) - || nodeName.equals(TAG_TEXT_PAGE_VARIABLE_GET) - || nodeName.equals(TAG_TEXT_SEQUENCE) - || nodeName.equals( TAG_TEXT_VARIABLE_INPUT) - || nodeName.equals(TAG_TEXT_TIME) - || nodeName.equals( TAG_TEXT_PAGE_COUNT) - || nodeName.equals(TAG_TEXT_PAGE_NUMBER ) - || nodeName.equals(TAG_TEXT_SUBJECT) - || nodeName.equals(TAG_TEXT_TITLE) - || nodeName.equals(TAG_TEXT_CREATION_TIME) - || nodeName.equals(TAG_TEXT_DATE) - || nodeName.equals(TAG_TEXT_TEXT_INPUT) - || nodeName.equals(TAG_TEXT_AUTHOR_INITIALS)) { - log("<FIELD>"); - traverseParaContents(node); - log("</FIELD>"); - - }else if (nodeName.startsWith(TAG_TEXT)) { - log("<Unknown text Field>"); - traverseParaContents(node); - log("</Unknown text Field>"); - - }else { - - log("<OTHERS " + XmlUtil.getNodeInfo(node) + " />"); - } - } - - - /** - * This method traverses list tags <i>text:unordered-list</i> and - * <i>text:ordered-list</i>. A list can only contain one optional - * <i>text:list-header</i> and one or more <i>text:list-item</i> - * elements. - * - * @param node A list <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseList(Node node) throws IOException { - - log("<LIST>"); - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_LIST_ITEM)) { - - traverseListItem(child); - - } else if (nodeName.equals(TAG_LIST_HEADER)) { - - traverseListHeader(child); - - } else { - - log("<INVALID-XML-BUG " + XmlUtil.getNodeInfo(child) + " />"); - } - } - } - } - - log("</LIST>"); - } - - - /** - * This method traverses a <i>text:list-header</i> element. - * It contains one or more <i>text:p</i> elements. - * - * @param node A list header <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseListHeader(Node node) throws IOException { - - log("<LIST-HEADER>"); - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH)) { - - traverseParagraph(child); - - } else { - - log("<INVALID-XML-BUG " + XmlUtil.getNodeInfo(child) + " />"); - } - } - } - } - - log("</LIST-HEADER>"); - } - - - /** - * <p>This method will traverse a <i>text:list-item</i>. - * A list item may contain one or more of <i>text:p</i>, - * <i>text:h</i>, <i>text:section</i>, <i>text:ordered-list</i> - * and <i>text:unordered-list</i>.</p> - * - * <p>This method currently only implements grabbing <i>text:p</i>, - * <i>text:h</i>, <i>text:unordered-list</i> and - * <i>text:ordered-list</i>.</p> - * - * @param node The <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseListItem(Node node) throws IOException { - - log("<LIST-ITEM>"); - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH)) { - - traverseParagraph(child); - - } else if (nodeName.equals(TAG_UNORDERED_LIST)) { - - traverseList(child); - - } else if (nodeName.equals(TAG_ORDERED_LIST)) { - - traverseList(child); - - } else { - - log("<INVALID-XML-BUG " + XmlUtil.getNodeInfo(child) + " />"); - } - } - } - } - - log("</LIST-ITEM>"); - } - - - /** - * Logs debug messages. - * - * @param str The debug message. - */ - private void log(String str) { - - Debug.log(Debug.TRACE, str); - } -} - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl.java b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl.java deleted file mode 100644 index 19bc67ba2983..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/PluginFactoryImpl.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.aportisdoc; - -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.DocumentMergerFactory; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.DocumentSerializerFactory; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.DocumentDeserializerFactory; -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.sxw.SxwPluginFactory; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.util.registry.ConverterInfo; -import java.io.IOException; -import java.io.InputStream; - -/** - * <p>AportisDoc implementation of the <code>PluginFactory</code>. - * This encapsulates conversion of StarWriter XML format to and from - * AportisDoc format.</p> - * - * <p>The superclass produces a particular - * {@link org.openoffice.xmerge.Document Document} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxw.SxwDocument - * SxwDocument} that the converters in this class works with. Thus, - * this class only implements the methods that produces the converters, - * i.e. {@link - * org.openoffice.xmerge.DocumentSerializer - * DocumentSerializer} and {@link - * org.openoffice.xmerge.DocumentDeserializer - * DocumentDeserializer}; - * as well as the {@link - * org.openoffice.xmerge.ConverterCapabilities - * ConverterCapabilities} object that is specific to this format - * conversion. That superclass also produces a {@link - * org.openoffice.xmerge.DocumentMerger DocumentMerger} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxw.aportisdoc.DocumentMergerImpl - * DocumentMergerImpl} which this class derives the functionality.</p> - * - */ -public final class PluginFactoryImpl extends SxwPluginFactory - implements DocumentDeserializerFactory, DocumentSerializerFactory, - DocumentMergerFactory { - - public PluginFactoryImpl (ConverterInfo ci) { - super(ci); - } - - /** ConverterCapabilities object for this type of conversion. */ - private final static ConverterCapabilities converterCap = - new ConverterCapabilitiesImpl(); - - - /** - * Returns an instance of <code>DocumentSerializerImpl</code>, - * which is an implementation of the <code>DocumentSerializer</code> - * interface. - * - * @param doc <code>Document</code> object to be - * converted/serialized. - * - * @return A <code>DocumentSerializerImpl</code> object. - */ - public DocumentSerializer createDocumentSerializer(Document doc) { - - return new DocumentSerializerImpl(doc); - } - - - /** - * Returns an instance of <code>DocumentDeserializerImpl</code>, - * which is an implementation of the <code>DocumentDeserializer</code> - * interface. - * - * @param cd <code>ConvertData</code> object for reading data - * which will be converted back to a - * <code>Document</code> object. - * - * @return A DocumentDeserializerImpl object. - */ - public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { - - return new DocumentDeserializerImpl(cd); - } - - - /** - * Returns an instance of <code>DocumentMergerImpl</code>, - * which is an implementation of the <code>DocumentMerger</code> - * interface. - * - * @param doc <code>Document</code> to merge. - * - * @return A DocumentMergerImpl object. - */ - public DocumentMerger createDocumentMerger(Document doc) { - - ConverterCapabilities cc = converterCap; - DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc); - return merger; - } - - public Document createDeviceDocument(String name, InputStream is) - throws IOException { - - PalmDocument palmDoc = new PalmDocument(is); - return palmDoc; - } -} - diff --git a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/package.html b/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/package.html deleted file mode 100644 index 124b4666e842..000000000000 --- a/xmerge/source/aportisdoc/java/org/openoffice/xmerge/converter/xml/sxw/aportisdoc/package.html +++ /dev/null @@ -1,228 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<html> -<head> -<title>org.openoffice.xmerge.converter.xml.sxw.aportisdoc package</title> -</head> - -<body bgcolor="white"> - -<p>Provides the tools for doing the conversion of StarWriter XML to -and from AportisDoc format.</p> - -<p>It follows the org.openoffice.xmerge framework for the conversion process.</p> - -<p>Since it converts to/from a Palm application format, these converters -follow the <a href=../../../../converter/palm/package-summary.html#streamformat> -<code>PalmDB</code> stream format</a> for writing out to the Palm sync client or -reading in from the Palm sync client.</p> - -<p>Note that <code>PluginFactoryImpl</code> also provides a -<code>DocumentMerger</code> object, i.e. {@link org.openoffice.xmerge.converter.xml.sxw.aportisdoc.DocumentMergerImpl DocumentMergerImpl}. -This functionality was derived from its superclass -{@link org.openoffice.xmerge.converter.xml.sxw.SxwPluginFactory -SxwPluginFactory}.</p> - -<h2>AportisDoc pdb format - Doc</h2> - -<p>The AportisDoc pdb format is widely used by different Palm applications, -e.g. QuickWord, AportisDoc Reader, MiniWrite, etc. Note that some -of these applications put tweaks into the format. The converters will only -support the default AportisDoc format, plus some very minor tweaks to accommodate -other applications.</p> - -<p>The text content of the format is plain text, i.e. there are no styles -or structures. There is no notion of lists, list items, paragraphs, -headings, etc. The format does have support for bookmarks.</p> - -<p>For most Doc applications, the default character encoding supported is -the extended ASCII character set, i.e. ISO-8859-1. StarWriter XML is in -UTF-8 encoding scheme. Since UTF-8 encoding scheme covers more characters, -converting UTF-8 strings into extended ASCII would mean that there can be -possible loss of character mappings.</p> - -<p>Using JAXP, XML files can be parsed and read in as Java <code>String</code>s -which is in Unicode format, there is no loss of character mapping from UTF-8 -to Java Strings. There is possible loss of character mapping in -converting Java <code>String</code>s to ASCII bytes. Java characters that -cannot be represented in extended ASCII are converted into the ASCII -character '?' or x3F in hex digit via the <code>String.getBytes(encoding)</code> -API.</p> - -<h2>SXW to DOC Conversion</h2> - -<p>The <code>DocumentSerializerImpl</code> class implements the -<code>org.openoffice.xmerge.DocumentSerializer</code>. -This class specifically provides the conversion process from a given -<code>SxwDocument</code> object to DOC formatted records, which are -then passed back to the client via the <code>ConvertData</code> object.</p> - -<p>The following XML tags are handled. [Note that some may not be implemented yet.]</p> -<ul> -<li> - <p>Paragraphs <tt><text:p></tt> and Headings <tt><text:h></tt></p> - - <p>Heading elements are classified the same as paragraph - elements since both have the same possible elements inside. - Their main difference is that they refer to different types - of style information, which is outside of their element tags. - Since there are no styles on the DOC format, headings should - be treated the same way a paragraph is converted.</p> - - <p>For paragraph elements, convert and transfer text nodes - that are essential. Text nodes directly contained within paragraph - nodes are such. There are also a number of elements that - a paragraph element may contain. These are explained in their - own context.</p> - - <p>At the end of the paragraph, an EOL character is added by - the converter to provide a separation for each paragraph, - since the Doc format does not have a notion of a paragraph.</p> -</li> -<li> - <p>White spaces <tt><text:s></tt> and Tabs <tt><text:tab-stop></tt></p> - - <p>In SXW, normally 2 or more white-space characters are collapsed into - a single space character. In order to make sure that the document - content really contains those white-space characters, there are special - elements assigned to them.</p> - - <p>The space element specifies the number of spaces are in it. - Thus, converting it just means providing the specific number of spaces - that the element requires.</p> - - <p>There is also the tab-stop element. This is a bit tricky. In a - StarWriter document, tab-stops are specified by a column position. - A tab is not an exact number of space, but rather a specific column - positioning. Say, regular tab-stops are set at every 5th column. - At column 4, if I hit a tab, it goes to column 5. At column 1, hitting - a tab would put the cursor at column 5 as well. SmartDoc and AporticDoc - applications goes by columns for the ASCII tab character. The only problem - is that in StarWriter, one could specify a different tab-stop, but not - in most of these Doc applications, at least I have not seen one. - Solution for this is just to go with the converting to the ASCII tab - character and not do anything for different tab-stop positioning.</p> -</li> -<li> - <p>Line breaks <tt><text:line-break></tt></p> - - <p>To represent line breaks, it is simpliest to just put an ASCII LF - character. Note that the side effect of this is that an end of paragraph - also contains an ASCII LF character. Thus, for the DOC to SXW conversion, - line breaks are not distinguishable from specifying the end of a - paragraph.</p> -</li> -<li> - <p>Text spans <tt><text:span></tt></p> - - <p>Text spans contain text that have different style attributes - from the paragraphs'. Text spans can be embedded within another - text span. Since it is purely for style tagging, we only needed - to convert and transfer the text elements within these.</p> -</li> -<li> - <p>Hyperlinks <tt><text:a></tt> - - <p>Convert and transfer the text portion.</p> -</li> -<li> - <p>Bookmarks <tt><text:bookmark></tt> <tt><text:bookmark-start></tt> - <tt><text:bookmark-end></tt> [Not implemented yet]</p> - - <p>In SXW, bookmark elements are embedded inside paragraph elements. - Bookmarks can either mark a text position or a text range. <tt><text:bookmark></tt> - marks a position while the pair <tt><text:bookmark-start></tt> and - <tt><text:bookmark-end></tt></p> marks a text range. The DOC format only - supports bookmarking a text position. Thus, for the conversion, - <tt><text:bookmark></tt> and <tt><text:bookmark-start></tt> will both mark - a text position.</p> -</li> -<li> - <p>Change Tracking <tt><text:tracked-changes></tt> - <tt><text:change*></tt> [Not implemented yet]</p> - - <p>Change tracking elements are not supported yet on the current - OpenOffice XML filters, will have to watch out on this. The text - within these elements have to be interpreted properly during the - conversion process.</p> -</li> -<li> - <p>Lists <tt><text:unordered-list></tt> and - <tt><text:ordered-lists></tt></p> - - <p>A list can only contain one optional <tt><text:list-header></tt> - and one or more <tt><text:list-item></tt> elements.</p> - - <p>A <tt><text:list-header></tt> contains one or more paragraph - elements. Since there are no styles, the conversion process does not - do anything special for list headers, conversion for the paragraphs - within list headers are the same as explained above.</p> - - <p>A <tt><text:list-item></tt> may contain one or more of paragraphs, - headings, list, etc. Since the Doc format does not support any list - structure, there will not be any special handling for this element. - Conversion for elements within it shall be applied according to the - element type. Thus, lists with paragraphs within it will result in just - plain paragraphs. Sublists will not be identifiable. Paragraphs in - sublists will still appear.</p> -</li> -<li> - <p><tt><text:section></tt></p> - - <p>I am not sure what this is yet, will need to investigate more on this.</p> -</li> -</ul> -<p>There may be other tags that will still need to be addressed for this conversion.</p> - -<p>Refer to {@link org.openoffice.xmerge.converter.xml.sxw.aportisdoc.DocumentSerializerImpl DocumentSerializerImpl} -for details of implementation. It uses <code>DocEncoder</code> class to do the encoding -part.</p> - -<h2>DOC to SXW Conversion</h2> - -<p>The <code>DocumentDeserializerImpl</code> class implements the -<code>org.openoffice.xmerge.DocumentDeserializer</code>. It is -passed the device document in the form of a <code>ConvertData</code> object. -It will then create a <code>SxwDocument</code> object from the conversion of -the DOC formatted records.</p> - -<p>The text content of the Doc format will be transferred as text. Paragraph -elements will be formed based on the existence of an ASCII LF character. There -will be at least one paragraph element.</p> - -<p>Bookmarks in the Doc format will be converted to the bookmark element -<tt><text:bookmark></tt> [Not implemented yet].</p> - - -<h2>Merging changes</h2> - -<p>As mentioned above, the <code>DocumentMerger</code> object produced by -<code>PluginFactoryImpl</code> is <code>DocumentMergerImpl</code>. -Refer to the javadocs for that package/class on its merging specifications. -</p> - -<h2>TODO list</h2> - -<p><ol> -<li>Investigate Palm's with different character encodings.</li> -<li>Investigate other StarWriter XML tags</li> -</ol></p> - -</body> -</html> diff --git a/xmerge/source/htmlsoff/converter.xml b/xmerge/source/htmlsoff/converter.xml deleted file mode 100644 index 2ed7f25bebc2..000000000000 --- a/xmerge/source/htmlsoff/converter.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<!--<!DOCTYPE converters SYSTEM "converter.dtd">--> -<converters> - <converter type="staroffice/sxw" version="1.0"> - <converter-display-name> - XSLT Transformation - </converter-display-name> - <converter-description> - Converter which performs xslt transformations - </converter-description> - <converter-vendor>OpenOffice.org</converter-vendor> - <converter-class-impl> - org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl - </converter-class-impl> - <converter-xslt-serialize> - sofftohtml.xsl - </converter-xslt-serialize> - <converter-xslt-deserialize> - htmltosoff.xsl - </converter-xslt-deserialize> - <converter-target type="text/html" /> - </converter> -</converters> - diff --git a/xmerge/source/htmlsoff/htmltosoff.xsl b/xmerge/source/htmlsoff/htmltosoff.xsl deleted file mode 100644 index 0b3bd6d4e816..000000000000 --- a/xmerge/source/htmlsoff/htmltosoff.xsl +++ /dev/null @@ -1,165 +0,0 @@ -<?xml version='1.0' encoding="UTF-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:office="http://openoffice.org/2000/office" - xmlns:style="http://openoffice.org/2000/style" - xmlns:text="http://openoffice.org/2000/text" - xmlns:table="http://openoffice.org/2000/table" - xmlns:draw="http://openoffice.org/2000/drawing" - xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:number="http://openoffice.org/2000/datastyle" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns:chart="http://openoffice.org/2000/chart" - xmlns:dr3d="http://openoffice.org/2000/dr3d" - xmlns:math="http://www.w3.org/1998/Math/MathML" - xmlns:form="http://openoffice.org/2000/form" - xmlns:script="http://openoffice.org/2000/script" - > -<xsl:output method="xml" /> - - -<xsl:template match="/"> - <xsl:apply-templates /> -</xsl:template> - -<xsl:template match="html"> - - <office:document-content xmlns:office="http://openoffice.org/2000/office" - xmlns:style="http://openoffice.org/2000/style" - xmlns:text="http://openoffice.org/2000/text" - xmlns:table="http://openoffice.org/2000/table" - xmlns:draw="http://openoffice.org/2000/drawing" - xmlns:fo="http://www.w3.org/1999/XSL/Format" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:number="http://openoffice.org/2000/datastyle" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns:chart="http://openoffice.org/2000/chart" - xmlns:dr3d="http://openoffice.org/2000/dr3d" - xmlns:math="http://www.w3.org/1998/Math/MathML" - xmlns:form="http://openoffice.org/2000/form" - xmlns:script="http://openoffice.org/2000/script" - office:class="text" office:version="1.0"> - -<office:script/> - <office:font-decls> - <style:font-decl style:name="Letter Gothic" fo:font-family="'Letter Gothic'" style:font-family-generic="modern" style:font-pitch="fixed"/> - <style:font-decl style:name="Arial Unicode MS" fo:font-family="'Arial Unicode MS'" style:font-pitch="variable"/> - <style:font-decl style:name="HG Mincho Light J" fo:font-family="'HG Mincho Light J'" style:font-pitch="variable"/> - <style:font-decl style:name="CG Times" fo:font-family="'CG Times'" style:font-family-generic="roman" style:font-pitch="variable"/> - <style:font-decl style:name="Thorndale" fo:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/> - <style:font-decl style:name="Antique Olive" fo:font-family="'Antique Olive'" style:font-family-generic="swiss" style:font-pitch="variable"/> - <style:font-decl style:name="Arial Black" fo:font-family="'Arial Black'" style:font-family-generic="swiss" style:font-pitch="variable"/> - </office:font-decls> - <office:automatic-styles> - <style:style style:name="Table1" style:family="table"> - <style:properties style:width="16.999cm" table:align="margins"/> - </style:style> - <style:style style:name="Table1.A" style:family="table-column"> - <style:properties style:column-width="3.399cm" style:rel-column-width="13107*"/> - </style:style> - <style:style style:name="Table1.A1" style:family="table-cell"> - <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="0.002cm solid #000000" fo:border-bottom="0.002cm solid #000000"/> - </style:style> - <style:style style:name="Table1.E1" style:family="table-cell"> - <style:properties fo:padding="0.097cm" fo:border="0.002cm solid #000000"/> - </style:style> - <style:style style:name="Table1.A2" style:family="table-cell"> - <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="none" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/> - </style:style> - <style:style style:name="Table1.E2" style:family="table-cell"> - <style:properties fo:padding="0.097cm" fo:border-left="0.002cm solid #000000" fo:border-right="0.002cm solid #000000" fo:border-top="none" fo:border-bottom="0.002cm solid #000000"/> - </style:style> - <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> - <style:properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false"/> - </style:style> - <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Table Contents"> - <style:properties style:font-name="Arial Black" fo:font-size="20pt"/> - </style:style> - </office:automatic-styles> - - - - - - <office:body> - <text:sequence-decls> - <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> - <text:sequence-decl text:display-outline-level="0" text:name="Table"/> - <text:sequence-decl text:display-outline-level="0" text:name="Text"/> - <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> - </text:sequence-decls> - - <xsl:apply-templates/> - </office:body> - </office:document-content> - -</xsl:template> - -<xsl:template match="body"> - <xsl:apply-templates /> -</xsl:template> - - - -<xsl:template match="p"> - <xsl:for-each select="."> - <text:p text:style-name="P1"> - <!--<xsl:value-of select="."/>--> - <xsl:apply-templates /> - </text:p> - </xsl:for-each> -</xsl:template> - -<xsl:template match="br"> - <xsl:if test="ancestor::p"> - <xsl:text disable-output-escaping="yes"></text:p> <text:p text:style-name="P1"></xsl:text> - </xsl:if> -</xsl:template> - -<xsl:template match="table"> - <xsl:for-each select="."> - <table:table table:name="Table1" table:style-name="Table1"> - <table:table-column table:style-name="Table1.A" table:number-columns-repeated="5"/> - <xsl:apply-templates/> - </table:table> - </xsl:for-each> -</xsl:template> - -<xsl:template match="tr"> - <xsl:for-each select="."> - <table:table-row> - <xsl:apply-templates/> - </table:table-row> - </xsl:for-each> -</xsl:template> - -<xsl:template match="td"> - <xsl:for-each select="."> - <table:table-cell table:style-name="Table1.A1" table:value-type="string"> - <text:p text:style-name="P1"> - <xsl:value-of select="."/> - </text:p> - </table:table-cell> - </xsl:for-each> -</xsl:template> - - - -</xsl:stylesheet> diff --git a/xmerge/source/htmlsoff/package.html b/xmerge/source/htmlsoff/package.html deleted file mode 100644 index f5c961784b99..000000000000 --- a/xmerge/source/htmlsoff/package.html +++ /dev/null @@ -1,56 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<HTML> -<HEAD> - <TITLE>org.openoffice.xmerge.converter.xml.xslt package</TITLE> -</HEAD> -<BODY> -<P>Provides the tools for doing the conversion of StarWriter XML to -and from supported formats, through the use of an XSLT -transformation.</P> -<P>It follows the {@link org.openoffice.xmerge} -framework for the conversion process.</P> -<P>This converter does not currently support merge.</P> -<P><FONT FACE="Times New Roman, serif"><FONT SIZE=5><B>XSLT -Transformation</B></FONT></FONT></P> -<p>The converter makes use -of one or more XSLT style sheets, which are used in the -DocumentSerializer and DocumentDeserializer, to perform the actual -translations. The location of these stylesheets is extracted from the {@link org.openoffice.xmerge.util.registry.ConverterInfo ConverterInfo} data structure, and are specified using the optional converter-xslt-serialize and converter-xsltdeserialize tags in a plugins converter.xml file. Please refer to the SDK document for more information about how to implement a Plugin Configuration XML File for a specific plugin. -A sample OpenOffice to Html stylesheet and Html to -Openffice stylesheet, has been provided as a sample implementation. -The converter also makes use of an XsltPlugin.properties file, which may be edited by the user to provide MIME-TYPE to file extension mappings. This file is used by the {@link org.openoffice.xmerge.converter.xml.xslt.PluginFactoryImpl getDeviceFileExtension} method. -</p> - -<H2>TODO list</H2> - -<p><ol> -<li>Expand XSLT style sheets to support more office/html - capabilities</li> -<li>Add support for certain character codes, such as &nbsp - which currently causes the transformer to break.</li> -<li>Change the DocumentDeserializer transformer, so that the DOMResult is serialized using the xalan serializer and create an SxwDocument from the result</li> -</ol></p> - -@see org.openoffice.xmerge.util.registry - -</BODY> -</HTML> - - diff --git a/xmerge/source/htmlsoff/sofftohtml.xsl b/xmerge/source/htmlsoff/sofftohtml.xsl deleted file mode 100644 index a596bf301e83..000000000000 --- a/xmerge/source/htmlsoff/sofftohtml.xsl +++ /dev/null @@ -1,109 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:style="http://openoffice.org/2000/style" xmlns:table="http://openoffice.org/2000/table" xmlns:text="http://openoffice.org/2000/text" xmlns:office="http://openoffice.org/2000/office" xmlns:fo="http://www.w3.org/1999/XSL/Format"> - <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" encoding="ISO-8859-1"/> - <!--doctype-system=[<!ENTITY acirc "">] --> - <xsl:strip-space elements="tokens"/> - <xsl:template match="office:document"> - <html> - <xsl:apply-templates/> - </html> - </xsl:template> - <xsl:template match="office:document-content"> - <html> - <xsl:apply-templates/> - </html> - </xsl:template> - <xsl:template match="office:automatic-styles"> - <style type="text/css">p.Table-Heading{font-weight:bold;}<xsl:apply-templates/> - </style> - </xsl:template> - <xsl:template match="office:styles"/> - <xsl:template match="office:meta"/> - <xsl:template match="office:settings"/> - <xsl:template match="style:style"> - <xsl:if test="@style:family ='paragraph'">p.<xsl:value-of select="@style:name"/>{<xsl:apply-templates/>}</xsl:if> - <xsl:if test="@style:family ='paragraph'">p.<xsl:value-of select="@style:name"/>{<xsl:if test="@style:parent-style-name='Table Heading'">font-weight:bold;font-style:italic;</xsl:if> - <xsl:apply-templates/>}</xsl:if> - <xsl:if test="@style:family ='table-cell'">td.<xsl:value-of select="@style:name"/>{<xsl:if test="@style:parent-style-name='Table Heading'">font-weight:bold;font-style:italic;</xsl:if> - <xsl:apply-templates/>}</xsl:if> - </xsl:template> - <xsl:template match="style:properties"> - <!--<xsl:param name="style" select="@fo:font-weight"/>--> - <xsl:if test="@fo:font-weight">font-weight:<xsl:value-of select="@fo:font-weight"/>;</xsl:if> - <xsl:if test="@fo:font-style">font-style:<xsl:value-of select="@fo:font-style"/>;</xsl:if> - <xsl:if test="@style:font-name">font-family:<xsl:value-of select="@style:font-name"/>;</xsl:if> - <xsl:if test="@fo:font-size">font-size:<xsl:value-of select="@fo:font-size"/>;</xsl:if> - <xsl:if test="@style:text-underline='single'">text-decoration:underline;</xsl:if> - <xsl:if test="@style:text-crossing-out='single-line'">text-decoration:line-through;</xsl:if> - <xsl:if test="@fo:text-align='start'">text-align:left</xsl:if> - <xsl:if test="@fo:text-align='center'">text-align:center</xsl:if> - <xsl:if test="@fo:text-align='end'">text-align:right</xsl:if> - <!--<xsl:value-of select="$style"/>--> - </xsl:template> - <xsl:template match="office:body"> - <xsl:apply-templates/> - </xsl:template> - <xsl:template match="table:table"> - <table border="1" cellpadding="2" width="100%"> - <xsl:apply-templates/> - </table> - </xsl:template> - <xsl:template match="table:table-header-rows"> - <th> - <xsl:apply-templates/> - </th> - </xsl:template> - <xsl:template match="table:table-row"> - <tr> - <xsl:apply-templates/> - </tr> - </xsl:template> - <xsl:template match="table:table-cell"> - <xsl:text disable-output-escaping="yes"><td class="</xsl:text> - <xsl:value-of select="@table:style-name"/> - <xsl:text disable-output-escaping="yes">"></xsl:text> - <!--<xsl:value-of select="."/>--> - <xsl:apply-templates/> - <xsl:text disable-output-escaping="yes"></td></xsl:text> - <!--<td width="20%"> - <xsl:apply-templates /> - </td>--> - </xsl:template> - <xsl:template match="text:p"> - <xsl:if test="ancestor-or-self::table:table-cell"> - <xsl:if test=".=''"> - <br/> - </xsl:if> - </xsl:if> - <xsl:text disable-output-escaping="yes"><p class="</xsl:text> - <xsl:choose> - <xsl:when test="@text:style-name ='Table Heading'">Table-Heading</xsl:when> - <xsl:otherwise> - <xsl:value-of select="@text:style-name"/> - </xsl:otherwise> - </xsl:choose> - <xsl:text disable-output-escaping="yes">"></xsl:text> - <xsl:apply-templates/> - <xsl:text disable-output-escaping="yes"></p></xsl:text> - <!--<xsl:value-of select="."/>--> - <!--<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>--> - <!--<br/>--> - </xsl:template> -</xsl:stylesheet> diff --git a/xmerge/source/minicalc/build.xml b/xmerge/source/minicalc/build.xml deleted file mode 100644 index 52ec0deb2595..000000000000 --- a/xmerge/source/minicalc/build.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<project name="minicalc" default="all" basedir="."> - - <property file="../inc/antbuild.properties"/> - - <path id="classpath"> - <pathelement location="${build.dir}/xmerge.jar"/> - </path> - - - <target name="init" > - <mkdir dir="${target.dir}"/> - </target> - - <!-- compile java sources in ${package} --> - <target name="compile" depends="init"> - <javac srcdir="${src.dir}" - destdir="${target.dir}" - debug="${debug}" - deprecation="${deprecation}" - optimize="${optimize}"> - <classpath refid="classpath"/> - </javac> - </target> - - <!-- package to jar --> - <target name="jar" depends="compile"> - <jar destfile="${target.jar}"> - <fileset dir="${target.dir}" - includes="**/*.class" /> - <metainf dir="${basedir}"> - <filename name="converter.xml"/> - </metainf> - </jar> - </target> - - <!-- clean up --> - <target name="clean"> - <delete dir="${class.dir}"/> - <delete file="${target.jar}"/> - </target> - - <target name="all" depends="jar"> - </target> - -</project> - diff --git a/xmerge/source/minicalc/converter.xml b/xmerge/source/minicalc/converter.xml deleted file mode 100644 index 1d9d404f51db..000000000000 --- a/xmerge/source/minicalc/converter.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<converters> - <converter type="staroffice/sxc" version="1.0"> - <converter-display-name> - Minicalc 6.4 - </converter-display-name> - <converter-description> - StarCalc XML to/from Minicalc 6.4 conversion - </converter-description> - <converter-vendor>OpenOffice.org</converter-vendor> - <converter-class-impl> - org.openoffice.xmerge.converter.xml.sxc.minicalc.PluginFactoryImpl - </converter-class-impl> - <converter-target type="application/x-minicalc" /> - </converter> -</converters> - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/ConverterCapabilitiesImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/ConverterCapabilitiesImpl.java deleted file mode 100644 index cb9d224e11ee..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/ConverterCapabilitiesImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.OfficeConstants; - - -/** - * <p>MiniCalc implementation of <code>ConverterCapabilities</code> for - * the {@link - * org.openoffice.xmerge.converter.xml.sxc.minicalc.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>Used with StarCalc SXC to/from MiniCalc conversions. The - * <code>ConverterCapibilies</code> specify which "Office" - * <code>Document</code> tags and attributes are supported on the - * "Device" <code>Document</code> format.</p> - */ -public final class ConverterCapabilitiesImpl - implements ConverterCapabilities { - - public boolean canConvertTag(String tag) { - - if (OfficeConstants.TAG_OFFICE_BODY.equals(tag)) - return true; - else if (OfficeConstants.TAG_PARAGRAPH.equals(tag)) - return true; - else if (OfficeConstants.TAG_TABLE.equals(tag)) - return true; - else if (OfficeConstants.TAG_TABLE_ROW.equals(tag)) - return true; - else if (OfficeConstants.TAG_TABLE_COLUMN.equals(tag)) - return false; - // TODO - we currently do not handle the table column tag - else if (OfficeConstants.TAG_TABLE_SCENARIO.equals(tag)) - return false; - // TODO - we currently do not handle the table scenario tag - else if (OfficeConstants.TAG_TABLE_CELL.equals(tag)) - return true; - - return false; - } - - public boolean canConvertAttribute(String tag, - String attribute) { - - if (OfficeConstants.TAG_TABLE.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_TABLE_NAME.equals(attribute)) - return true; - - } else if (OfficeConstants.TAG_TABLE_CELL.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_TABLE_VALUE_TYPE.equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_FORMULA. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_VALUE.equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_BOOLEAN_VALUE. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_CURRENCY. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_TIME_VALUE. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_DATE_VALUE. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED. - equals(attribute)) - return true; - - } else if (OfficeConstants.TAG_TABLE_ROW.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_TABLE_NUM_ROWS_REPEATED. - equals(attribute)) - return true; - } - - return false; - } -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcConstants.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcConstants.java deleted file mode 100644 index 4c5e7df21a77..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcConstants.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -import org.openoffice.xmerge.converter.palm.PdbUtil; - -/** - * Constants used for encoding and decoding the MiniCalc format. - */ -interface MinicalcConstants { - - /** Creator ID. */ - public static final int CREATOR_ID = PdbUtil.intID("PiMC"); - - /** Type ID. */ - public static final int TYPE_ID = PdbUtil.intID("Data"); -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDataString.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDataString.java deleted file mode 100644 index aac23c7f4daf..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDataString.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -/** - * This class is used by <code>MinicalcDecoder</code> to manipulate a - * <code>String</code> containing MiniCalc cell data. - * - */ -public class MinicalcDataString { - - /** The String representation of the MiniCalc data. */ - private String data = null; - - - /** - * Constructor stores the MiniCalc data <code>String</code>. - * - * @param data A <code>String</code> containing MiniCalc - * cell data. - */ - public MinicalcDataString(String data) { - this.data = data; - } - - - /** - * Checks if the MiniCalc data <code>String</code> is a <i>formula</i>. - * - * @return true if the MiniCalc data <code>String</code> is a - * <i>formula</i>, false if the MiniCalc data <code>String</code> - * is not a <i>formula</i>. - */ - public boolean isFormula() { - - if (data.startsWith("=")) { - return true; - } - - return false; - } - - - /** - * Checks if the MiniCalc data <code>String</code> is a <i>percentage</i>. - * - * @return true if the MiniCalc data <code>String</code> is a - * <i>percentage</i>, false if the MiniCalc data - * <code>String</code> is not a <i>percentage</i>. - */ - public boolean isPercent() { - - if (data.endsWith("%")) { - return true; - } - - return false; - } - - - /** - * Checks if the MiniCalc data <code>String</code> is a - * <i>boolean</i> value. - * - * @return true if the MiniCalc data <code>String</code> is - * a <i>boolean</i>, false if the MiniCalc data - * <code>String</code> is not a <i>boolean</i>. - */ - public boolean isBoolean() { - - if (data.equalsIgnoreCase("false") || - data.equalsIgnoreCase("true")) { - return true; - } - - return false; - } - - - /** - * Checks if the MiniCalc data <code>String</code> is a <i>date</i>. - * - * @return true if the MiniCalc data <code>String</code> is - * a <i>date</i>, false if the MiniCalc data <code>String</code> - * is not a <i>date</i>. - */ - public boolean isDate() { - - // Starting index into the date string - month - int start = 0; - - // Search for "/", which separates month from day - int end = data.indexOf("/"); - - // Separator was found - if (end > 0) { - - String monthString = data.substring(start, end); - - try { - Float f = Float.valueOf(monthString); - if ((f.intValue() < 0) || (f.intValue() > 12)) { - return false; - } - } - catch (NumberFormatException e) { - - // no, it is not a currency type - return false; - } - - // start is now the starting index of day - start = end+1; - - // Search for "/", which separates day from year - end = data.indexOf("/", start); - - // Separator was found - if (end > 0) { - - String dayString = data.substring(start, end); - - try { - Float f = Float.valueOf(dayString); - if ((f.intValue() < 0) || (f.intValue() > 31)) - return false; - } - catch (NumberFormatException e) { - // no, it is not a currency type - return false; - } - } else { - return false; - } - - // start is now at the starting index of the year - start = end + 1; - - String yearString = data.substring(start); - try { - Float f = Float.valueOf(yearString); - if (f.intValue() < 0) { - return false; - } - } - catch (NumberFormatException e) { - // no, it is not a currency type - return false; - } - - } else { - return false; - } - - return true; - } - - - /** - * Checks if the MiniCalc data <code>String</code> is a <i>time</i>. - * - * @return true if the MiniCalc data <code>String</code> - * is a <i>time</i>, false if the MiniCalc data - * <code>String</code> is not a <i>time</i>. - */ - public boolean isTime() { - - // Starting index into the time string - hour - int start = 0; - - // Search for ":", which separates hour from minute - int end = data.indexOf(":"); - - - // Separator was found - if (end > 0) { - - String hourString = data.substring(start, end); - try { - Float f = Float.valueOf(hourString); - if ((f.intValue() < 0) || (f.intValue() > 24)) - return false; - } - catch (NumberFormatException e) { - // no, it is not a time type - return false; - } - - // start is now the starting index of minute - start = end+1; - - // Search for ":", which separates minute from second - end = data.indexOf(":", start); - - // Separator was found - if (end > 0) { - - String minuteString = data.substring(start, end); - - try { - Float f = Float.valueOf(minuteString); - if ((f.intValue() < 0) || (f.intValue() > 60)) - return false; - } - catch (NumberFormatException e) { - // no, it is not a time type - return false; - } - - // start is now at the starting index of the seconds - start = end+1; - - // The seconds are in the string - if (data.length() > start) { - - String secondString = data.substring(start); - - - try { - Float f = Float.valueOf(secondString); - if ((f.intValue() < 0) || (f.intValue() > 60)) - return false; - } - catch (NumberFormatException e) { - // no, it is not a time type - return false; - } - } - - } - - return true; - - } - - return false; - } - - - /** - * Checks if the MiniCalc data <code>String</code> is a <i>currency</i> - * value. - * - * @return true if the MiniCalc data <code>String</code> is - * a <i>currency</i>, false if the MiniCalc data - * <code>String</code> is not a <i>currency</i>. - */ - public boolean isCurrency() { - - boolean result = false; - - // TODO - we currently only check for US currencies - - if (data.endsWith("$")) { - String number = data.substring(0, data.length()-1); - try { - Float f = Float.valueOf(number); - result = true; - } - catch (NumberFormatException e) { - // no, it is not a currency type - result = false; - } - } - - else if (data.startsWith("$")) { - String number = data.substring(1, data.length()); - try { - Float f = Float.valueOf(number); - result = true; - } - catch (NumberFormatException e) { - // no, it is not a currency type - result = false; - } - } - - return result; - - } - - - /** - * This method removes the percent sign from the MiniCalc data - * <code>String</code>. If the percent sign is not the last - * character of the MiniCalc data <code>String</code>, the - * MiniCalc data <code>String</code> is returned. - * - * @return The MiniCalc data <code>String</code> minus the - * percent sign. If the MiniCalc data <code>String</code> - * does not begin with a percent sign, the MiniCalc data - * <code>String</code> is returned. - */ - public String percentRemoveSign() { - - String number = data; - - if (data.endsWith("%")) { - // "%" is the last character, so remove - number = data.substring(0, data.length()-1); - - try { - Float f = Float.valueOf(number); - float f1 = f.floatValue()/100f; - Float f2 = new Float(f1); - number = f2.toString(); - } - catch (NumberFormatException e) { - // no, it is not a float type - } - } - - return number; - } - - - /** - * This method removes the currency sign from the MiniCalc data - * <code>String</code>. If the currency sign is not the first or - * last character of the MiniCalc data <code>String</code>, the - * MiniCalc data <code>String</code> is returned. - * - * @return The MiniCalc data <code>String</code> minus the currency - * sign. If the MiniCalc data <code>String</code> does not - * begin or end with a currency sign, the MiniCalc - * data <code>String</code> is returned. - */ - public String currencyRemoveSign() { - - String number = data; - - // TODO - only works with US currencies - - if (data.endsWith("$")) { - - number = data.substring(0, data.length()-1); - - } else if (data.startsWith("$")) { - - number = data.substring(1, data.length()); - } - - return number; - - } - - - /** - * <p>This method converts a MiniCalc date from MiniCalc - * format to StarOffice XML format.</p> - * - * <p>MiniCalc format:</p> - * - * <p><blockquote> - * MM/DD/YY or MM/DD/YYYY - * </blockquote></p> - * - * <p>StarOffice XML format:</p> - * - * <p><blockquote> - * YYYY-MM-DD - * </blockquote></p> - * - * @return The MiniCalc date converted to StarOffice XML - * format. - */ - public String convertToStarDate() { - - // The output date string - String out; - - String monthString = "01"; - String dayString = "01"; - String yearString = "1900"; - - // Starting index into the date string - month - int start = 0; - - // Search for "/", which separates month from day - int end = data.indexOf("/"); - - // Separator was found - if (end > 0) { - - monthString = data.substring(start, end); - - Integer monthInt = new Integer(monthString); - - // Make sure month is 2 digits - if (monthInt.intValue() < 10) { - monthString = "0" + monthString; - } - - // start is now the starting index of day - start = end+1; - - // Search for "/", which separates day from year - end = data.indexOf("/", start); - - // Separator was found - if (end > 0) { - - dayString = data.substring(start, end); - - Integer dayInt = new Integer(dayString); - - // Make sure day is 2 digits - if (dayInt.intValue() < 10) { - dayString = "0" + dayString; - } - - // start is now at the starting index of the year - start = end + 1; - - // The year is in the string - if (data.length() > start) { - - yearString = data.substring(start); - - Integer yearInt = new Integer(yearString); - int year = yearInt.intValue(); - - if (year < 31) { - - // MiniCalc years between 0 and 30 correspond to - // 2000 - 2030 - year += 2000; - - } else if (year < 100) { - - // MiniCalc years between 31 and 99 correspond - // to 1931 - 1999 - year += 1900; - } - - yearString = Integer.toString(year); - } - } - } - - // Set out to StarOffice XML date format - out = yearString + "-" + monthString + "-" + dayString; - - return out; - } - - - /** - * This method converts the MiniCalc time from MiniCalc - * format to StarOffice XML format. - * - * <p>MiniCalc format:</p> - * - * <p><blockquote> - * hh:mm:ss - * </blockquote></p> - * - * <p>StarOffice XML format:</p> - * - * <p><blockquote> - * PThhHmmMssS - * </blockquote></p> - * - * @return The MiniCalc time converted to StarOffice XML - * format. - */ - public String convertToStarTime() { - - // The output time string - String out; - - String hourString = "00"; - String minuteString = "00"; - String secondString = "00"; - - // Starting index into the time string - hour - int start = 0; - - // Search for ":", which separates hour from minute - int end = data.indexOf(":"); - - // Separator was found - if (end > 0) { - - hourString = data.substring(start, end); - - // start is now the starting index of minute - start = end+1; - - // Search for ":", which separates minute from second - end = data.indexOf(":", start); - - // Separator was found - if (end > 0) { - - minuteString = data.substring(start, end); - - // start is now at the starting index of the seconds - start = end+1; - - // The seconds are in the string - if (data.length() > start) { - - secondString = data.substring(start); - } - - } - } - - // TODO - PT is for pacific time, where can we get the - // localized value from? - - // Set to StarOffice XML time format - out = "PT"+hourString+"H"+minuteString+"M"+secondString+"S"; - - return out; - } -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDecoder.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDecoder.java deleted file mode 100644 index feeac91042d0..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcDecoder.java +++ /dev/null @@ -1,728 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -import jmc.Workbook; -import jmc.Worksheet; -import jmc.CellAttributes; -import jmc.CellDescriptor; -import jmc.JMCconstants; -import jmc.JMCException; - -import java.io.ByteArrayOutputStream; -import java.io.ByteArrayInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer; -import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; -import org.openoffice.xmerge.converter.xml.sxc.Format; - -/** - * This class is used by {@link - * org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializerImpl} - * SxcDocumentDeserializerImpl} to decode the MiniCalc format. - * - */ -final class MinicalcDecoder extends SpreadsheetDecoder { - - /** MiniCalc WorkBook to store sheets. */ - private Workbook wb; - - /** MiniCalc sheet - only one sheet can be open at a time. */ - private Worksheet ws; - - /** The current cell - only one cell can be active at a time. */ - private CellDescriptor cell = null; - - /** Format object describing the current cell. */ - private Format fmt = null; - - /** The password for the WorkBook. */ - private String password = null; - - /** The number of rows in the current WorkSheet. */ - private int maxRows = 0; - - /** The number of columns in the current WorkSheet. */ - private int maxCols = 0; - - /** The names of the worksheets. */ - private String[] worksheetNames = null; - - /** - * Constructor creates a MiniCalc WorkBook. - * - * @param name The name of the WorkBook. - * @param password The password for the workBook. - * - * @throws IOException If any I/O error occurs. - */ - MinicalcDecoder(String name, String[] worksheetNames, String password) throws IOException { - - super(name, password); - - fmt = new Format(); - - this.password = password; - this.worksheetNames = worksheetNames; - - try { - - wb = new Workbook(name, password); - - } - catch (JMCException e) { - - Debug.log(Debug.ERROR, "MinicalcDecoder.constructor:" + e.getMessage()); - - throw new IOException(e.getMessage()); - } - } - - - /** - * This method takes a <code>ConvertData</code> as input and - * converts it into a MiniCalc WorkSheet. The WorkSheet is then - * added to the WorkBook. - * - * @param InputStream An <code>ConvertData</code> containing a - * MiniCalc WorkSheet. - * - * @throws IOException If any I/O error occurs. - */ - public void addDeviceContent(ConvertData cd) throws IOException { - - try { - PalmDocument palmDoc; - int j = 0; - - Enumeration e = cd.getDocumentEnumeration(); - while(e.hasMoreElements()) { - - palmDoc = (PalmDocument) e.nextElement(); - // Convert PDB to WorkBook/WorkSheet format - PalmDB pdb = palmDoc.getPdb(); - - // This will be done at least once - String sheetName = worksheetNames[j]; - - // Get number of records in the pdb - int numRecords = pdb.getRecordCount(); - - // sheetName does not contain the WorkBook name, but we need the - // full name. - String fullSheetName = new String(wb.getWorkbookName() + "-" + sheetName); - - // Create a new (empty) WorkSheet - ws = new Worksheet(); - - // Initialize the WorkSheet - ws.initWorksheet(fullSheetName, numRecords); - - // Loop over the number of records in the PDB - for (int i = 0; i < numRecords; i++) { - - // Read record i from the PDB - Record rec = pdb.getRecord(i); - - byte cBytes[] = rec.getBytes(); - - // Create an InputStream - ByteArrayInputStream bis = new ByteArrayInputStream(cBytes); - - // Get the size of the stream - int bisSize = cBytes.length; - - // Add each record to the WorkSheet - ws.readNextRecord(bis, bisSize); - } - - - // Add the WorkSheet to the WorkBook - wb.addWorksheet(ws); - j++; - } - } - catch (JMCException e) { - - Debug.log(Debug.ERROR, "MinicalcDecoder.addPDB:" + e.getMessage()); - - throw new IOException(e.getMessage()); - } - } - - - /** - * This method returns the number of spreadsheets - * stored in the WorkBook. - * - * @return The number of sheets in the WorkBook. - */ - public int getNumberOfSheets() { - - return wb.getNumberOfSheets(); - } - - - /** - * This method gets the requested WorkSheet from the - * WorkBook and sets it as the selected WorkSheet. All - * other "get" methods will now get data from this WorkSheet. - * - * @param sheetIndex The index number of the sheet to open. - * - * @throws IOException If any I/O error occurs. - */ - public void setWorksheet(int sheetIndex) throws IOException { - - try { - - ws = wb.getWorksheet(sheetIndex); - - // Initialize access to the WorkSheet so that we can calculate - // the number of rows and columns - ws.initAccess(password); - - maxRows = 0; - maxCols = 0; - - while (goToNextCell()) { - maxRows = Math.max(maxRows, cell.getRowNumber()); - maxCols = Math.max(maxCols, cell.getColNumber()); - } - - // Re-initialize access to the WorkSheet - ws.initAccess(password); - - } - catch (JMCException e) { - - Debug.log(Debug.ERROR, "MinicalcDecoder.setWorksheet:" + e.getMessage()); - - throw new IOException(e.getMessage()); - } - } - - - /** - * This method returns the name of the current spreadsheet. - * - * @return The name of the current WorkSheet. - */ - public String getSheetName() { - - String sheetName = ws.getName(); - - return sheetName; - } - - - /** - * This method gets the next cell from the WorkSheet - * and sets it as the selected cell. All other "get" - * methods will now get data from this cell. - * - * @return True if we were able to go to another cell - * in the sheet, false if there were no cells - * left. - * - * @throws IOException If any I/O error occurs. - */ - public boolean goToNextCell() throws IOException { - - boolean gotCell = false; - - try { - cell = ws.getNextCell(); - - if (cell != null) { - gotCell = true; - } - - // As we read each cell, get its formatting info - readCellFormat(); - } - catch (JMCException e) { - - Debug.log(Debug.ERROR, "MinicalcDecoder.goToNextCell:" + e.getMessage()); - - throw new IOException(e.getMessage()); - } - - return gotCell; - } - - - /** - * This method returns the row number of the current cell. - * - * @return The row number of the current cell. Returns - * -1 if no cell is currently selected. - */ - public int getRowNumber() { - - int row = -1; - - if (cell != null) { - - row = cell.getRowNumber(); - } - - return row; - } - - /** - * This method returns the number of rows in the current sheet. - * - * @return The number of rows in the current sheet. - */ - public int getNumberOfRows() { - - return maxRows; - } - - /** - * This method returns the number of columns in the current sheet. - * - * @return The number of columns in the current sheet. - */ - public int getNumberOfColumns() { - return maxCols; - } - - - /** - * This method returns the col number of the current cell. - * - * @return The col number of the current cell. Returns - * -1 if no cell is currently selected. - */ - public int getColNumber() { - - int col = -1; - - if (cell != null) { - - col = cell.getColNumber(); - } - - return col; - } - - - /** - * This method returns the contents of the current cell. - * - * @return The contents of the current cell. Returns - * null if no cell is currently selected. - */ - public String getCellContents() { - - String contents = null; - - if (cell != null) { - contents = cell.getCellContents(); - - // Active cell, but no content - if (contents == null) - return new String(""); - - // Does the cell contain a formula? - if (contents.startsWith("=")) { - contents = parseFormula(contents); - } - // Make sure that any MiniCalc peculiarities are stripped off - if (fmt.getCategory().equalsIgnoreCase(OfficeConstants.CELLTYPE_CURRENCY)) { - contents = currencyRemoveSign(contents); - } - else if (fmt.getCategory().equalsIgnoreCase(OfficeConstants.CELLTYPE_PERCENT)) { - contents = percentRemoveSign(contents); - } - else if (fmt.getCategory().equalsIgnoreCase(OfficeConstants.CELLTYPE_DATE)) { - contents = convertToStarDate(contents); - } - else if (fmt.getCategory().equalsIgnoreCase(OfficeConstants.CELLTYPE_TIME)) { - contents = convertToStarTime(contents); - } - } - - return contents; - } - - /** - * This method is meant to return the value of the formula cell. However - * in minicalc this value is not used so hence the stubbed function - * - * @return the value fo the formula cell - */ - public String getCellValue() { - return null; - } - - /** - * <p>This method takes a formula and parses it into - * StarOffice XML formula format.</p> - * - * <p>Many spreadsheets use ',' as a separator. - * StarOffice XML format uses ';' as a separator instead.</p> - * - * <p>Many spreadsheets use '!' as a separator when refencing - * a cell in a different sheet.</p> - * - * <blockquote> - * Example: =sheet1!A1 - * </blockquote> - * - * <p>StarOffice XML format uses '.' as a separator instead.</p> - * - * <blockquote> - * Example: =sheet1.A1 - * </blockquote> - * - * @param formula A formula string. - * - * @return A StarOffice XML format formula string. - */ - protected String parseFormula(String formula) { - - formula = formula.replace(',', ';'); - formula = formula.replace('!', '.'); - - return formula; - } - - /** - * <p>This method returns the type of the data in the current cell.</p> - * - * <p>Possible Data Types:</p> - * - * <ul><li> - * Percent - MiniCalc can store as a number or as a string. - * - * When stored as a string, the % sign is stored in the - * string . The MiniCalc format is "string". - * Example 10.1% is stored as the string "10.1%" - * - * When stored as a number, the decimal representation - * is stored. The MiniCalc format is "percentage". - * Example: 10.1% is stored as "0.101" - * </li><li> - * Currency - MiniCalc stores currency as a number with the format - * set to "currency". - * A user can also enter a value with a dollar sign - * (example $18.56) into MiniCalc and not set the format - * as currency. We treat this type of data as a - * currency data type. - * </li><li> - * Boolean - MiniCalc stores in a string as "true" or "false" - * </li><li> - * - * Date - MiniCalc stores a date in a string as either - * MM/DD/YY or MM/DD/YYYY. Any variation from the above - * format will not be considered a date. - * </li><li> - * Time - MiniCalc stores a time in a string as hh:mm:ss. Any - * variation from this format will not be considered a time. - * </li><li> - * Float - MiniCalc stores as a number and it is not percent - * or currency. - * </li><li> - * String - MiniCalc stores as a string (surprise). Doesn't parse - * to any of the other data types. - * </li><li> - * @return The type of the data in the current cell. - * </li></ul> - */ - public String getCellDataType() { - - boolean isNumber = false; - - // Get format value set on the cell in MiniCalc - String format = getCellFormatType(); - - // Initialize the data type to the format - String type = format; - - String contents = getCellContents(); - - if (contents != null) { - - MinicalcDataString data = new MinicalcDataString(contents); - - // Check if it is a formula - if (data.isFormula()) { - Debug.log(Debug.INFO, " " + contents + " Is a Function Format = " - + format + "\n"); - return type; - } - - try { - // Check to see if it is a number - Double d = Double.valueOf(contents); - isNumber = true; - Debug.log(Debug.INFO, " " + contents + " Is a Number Format = " + format); - - } catch (NumberFormatException e) { - Debug.log(Debug.INFO, " " + contents + " Not a Number Format= " + format); - // no, it is not a number - isNumber = false; - } - - - if (isNumber) { - - // Numbers are Float, Currency, and Percent - if (format.equals(OfficeConstants.CELLTYPE_CURRENCY)) { - - type = OfficeConstants.CELLTYPE_CURRENCY; - - } else if (format.equals(OfficeConstants.CELLTYPE_PERCENT)) { - - type = OfficeConstants.CELLTYPE_PERCENT; - - } else { - - type = OfficeConstants.CELLTYPE_FLOAT; - } - - } else if (data.isBoolean()) { - - // Data is a Boolean type - type = OfficeConstants.CELLTYPE_BOOLEAN; - - } else if (data.isDate()) { - - // Data is a Date type - type = OfficeConstants.CELLTYPE_DATE; - - } else if (data.isTime()) { - - // Data is a Time type - type = OfficeConstants.CELLTYPE_TIME; - - } else if (data.isPercent()) { - - // Data is percent - type = OfficeConstants.CELLTYPE_PERCENT; - - } else if (data.isCurrency()) { - - // Data is a Currency type - type = OfficeConstants.CELLTYPE_CURRENCY; - - } else { - - // Data can't be float, since it isn't a number - - // We've already tried parsing it as all other data - // types, the only remaining option is a string - type = OfficeConstants.CELLTYPE_STRING; - } - } - - Debug.log(Debug.INFO, " TYPE = " + type + "\n"); - - return type; - } - - - /** - * This method returns the format of the data in the current cell. - * - * @return The format of the data in the current cell. - */ - String getCellFormatType() { - - // Set type to default data type - String type = OfficeConstants.CELLTYPE_FLOAT; - - if (cell != null) { - - // Get the attributes for the current cell - CellAttributes att = cell.getCellAttributes(); - - if (att != null) { - - // Extract the format info from the attributes - long format = att.getFormat(); - - // The cell type is stored in bits 5-8 - long cellType = format & 0x000000F0L; - - // The number of decimal places is stored in bits 1-4 - long decimals = format & 0x0000000FL; - - if (cellType == JMCconstants.FF_FORMAT_GENERIC) { - - // MiniCalc stores both Strings and Booleans - // in the generic type. We must check the contents - // to differentiate between the two. - - // Get cell's contents - String contents = getCellContents(); - - if (contents.equalsIgnoreCase("false") || - contents.equalsIgnoreCase("true")) { - - type = OfficeConstants.CELLTYPE_BOOLEAN; - - - } else { - - type = OfficeConstants.CELLTYPE_STRING; - - } - - } else if (cellType == JMCconstants.FF_FORMAT_DECIMAL) { - - type = OfficeConstants.CELLTYPE_FLOAT; - - } else if (cellType == JMCconstants.FF_FORMAT_TIME) { - - type = OfficeConstants.CELLTYPE_TIME; - - } else if (cellType == JMCconstants.FF_FORMAT_DATE) { - - type = OfficeConstants.CELLTYPE_DATE; - - } else if (cellType == JMCconstants.FF_FORMAT_CURRENCY) { - - type = OfficeConstants.CELLTYPE_CURRENCY; - - } else if (cellType == JMCconstants.FF_FORMAT_PERCENT) { - - type = OfficeConstants.CELLTYPE_PERCENT; - } - - } - } - - return type; - } - - - /** - * This method takes a <code>String</code> that contains a - * currency value and removes the $ from the <code>String</code>. - * If the dollar sign is not the first or last character of the - * input <code>String</code>, the input <code>String</code> is - * simply returned. - * - * @param contents The input <code>String</code> from which to - * remove the dollar sign. - * - * @return The input <code>String</code> minus the dollar sign. - * If the input <code>String</code> did not begin or end - * with a dollar sign, contents is returned. - */ - private String currencyRemoveSign(String contents) { - MinicalcDataString mcString = new MinicalcDataString(contents); - String currencyString = mcString.currencyRemoveSign(); - return currencyString; - } - - - /** - * This method takes a <code>String</code> that contains a percent - * value and removes the % from the <code>String</code>. If the - * percent sign is not the last character of the input - * <code>String</code>, the input <code>String</code> is simply - * returned. - * - * @param contents The input String from which to remove the - * percent sign. - * - * @return The input <code>String</code> minus the percent sign. - * If the input <code>String</code> did not begin with - * a percent sign, contents is returned. - */ - private String percentRemoveSign(String contents) { - MinicalcDataString mcString = new MinicalcDataString(contents); - String percentString = mcString.percentRemoveSign(); - return percentString; - } - - - /** - * This method returns takes a <code>String</code> that contains - * a time value and converts it from MiniCalc format to StarOffice - * XML time format. - * - * @param contents The input <code>String</code> containing a - * MiniCalc time. - * - * @return The input <code>String</code> converted to StarOffice - * XML time format. - */ - private String convertToStarTime(String contents) { - MinicalcDataString mcString = new MinicalcDataString(contents); - String timeString = mcString.convertToStarTime(); - return timeString; - } - - /** - * This method returns takes a <code>String</code> that contains - * a date value and converts it from MiniCalc format to StarOffice - * XML date format. - * - * @param contents The input <code>String</code> containing a - * MiniCalc date. - * - * @return The input <code>String</code> converted to StarOffice - * XML date format. - */ - private String convertToStarDate(String contents) { - MinicalcDataString mcString = new MinicalcDataString(contents); - String dateString = mcString.convertToStarDate(); - return dateString; - } - - - /** - * Return the Format object describing the active cell formatting. - * - * @return The Format object describing the active cell formatting. - */ - public Format getCellFormat() { - return new Format(fmt); - } - - - /** - * Create the format data for the new cell. - */ - private void readCellFormat() { - // Make sure there are no remnants from the last time - fmt.clearFormatting(); - - fmt.setCategory(getCellFormatType()); - - // TODO - Get any more formatting data here - } -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcEncoder.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcEncoder.java deleted file mode 100644 index 532d598ebbf7..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/MinicalcEncoder.java +++ /dev/null @@ -1,572 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -import jmc.Workbook; -import jmc.Worksheet; -import jmc.CellAttributes; -import jmc.CellDescriptor; -import jmc.JMCconstants; -import jmc.JMCException; - -import java.awt.Color; - -import java.io.ByteArrayOutputStream; -import java.io.ByteArrayInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.IntArrayList; - -import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetEncoder; -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.OfficeConstants; - -/** - * This class is used by {@link - * org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializerImpl - * SxcDocumentSerializerImpl} to encode the MiniCalc format. - * - */ -final class MinicalcEncoder extends SpreadsheetEncoder { - - /** MiniCalc WorkBook to store sheets. */ - private Workbook wb; - - /** MiniCalc sheet - only one sheet can be open at a time. */ - private Worksheet ws; - - /** - * Estimate of the number of Palm pixels per character. Used for - * estimating the width of a cell on a Palm device. - */ - private final static int pixelsPerChar = 6; - - /** - * The minimum width (in pixels) that we allow a column to be set to - * on a Palm device. - */ - private final static int minWidth = 10; - - /** - * The maximum width (in pixels) that we allow a column to be set to - * on a Palm device. - */ - private final static int maxWidth = 80; - - - /** - * Constructor creates a MiniCalc WorkBook. - * - * @param log Log object for logging. - * @param name The name of the WorkBook. - * @param password The password for the WorkBook. - * - * @throws IOException If any I/O error occurs. - */ - MinicalcEncoder(String name, String password) throws IOException { - - super(name, password); - - try { - wb = new Workbook(name, password); - } - catch (JMCException e) { - Debug.log(Debug.ERROR, "new Workbook threw exception:" + e.getMessage()); - throw new IOException(e.getMessage()); - } - } - - - /** - * This method creates a WorkSheet belonging to the - * WorkBook. - * - * @param sheetName The name of the WorkSheet. - * - * @throws IOException If any I/O error occurs. - */ - public void createWorksheet(String sheetName) throws IOException { - - try { - ws = wb.createWorksheet(sheetName); - } - catch (JMCException e) { - Debug.log(Debug.ERROR, "wb.createWorksheet threw exception:" + e.getMessage()); - throw new IOException(e.getMessage()); - } - } - - - /** - * This method gets the number of sheets in the WorkBook. - * - * @return The number of sheets in the WorkBook. - */ - public int getNumberOfSheets() { - - int numSheets = wb.getNumberOfSheets(); - return numSheets; - } - - - /** - * This method encodes the MiniCalc WorkBook information - * into an palm <code>Record</code> array in MiniCalc - * database format. - * - * @return Array of <code>Record</code> holding MiniCalc - * contents. - * - * @throws IOException If any I/O error occurs. - */ - public Record[] getRecords(int sheetID) throws IOException { - - // Get the WorkSheet for the input sheetID - ws = wb.getWorksheet(sheetID); - - // Need to call ws.initWrite() before we start querying the WorkSheet - try { - ws.initWrite(); - } - catch (JMCException e) { - Debug.log(Debug.ERROR, "ws.initWrite in getRecords:" + e.getMessage()); - throw new IOException(e.getMessage()); - } - - // Get the number of records in the WorkSheet - int numRecords = ws.getNumberOfRecords(); - - // Create the Record array - Record[] allRecords = new Record[numRecords]; - - - // Get each record from the WorkSheet and store in allRecords[] - try { - for (int i = 0; i < allRecords.length; i++) { - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - int length = ws.writeNextRecord(bos); - - byte cBytes[] = bos.toByteArray(); - - allRecords[i] = new Record(cBytes); - } - } - catch (Exception e) { - Debug.log(Debug.ERROR, "ws.writeNextRecord in getRecords:" + e.getMessage()); - throw new IOException(e.getMessage()); - } - - return allRecords; - } - - - /** - * A cell reference in a StarOffice formula looks like - * [.C2] (for cell C2). MiniCalc is expecting cell references - * to look like C2. This method strips out the braces and - * the period. - * - * @param formula A StarOffice formula <code>String</code>. - * - * @return A MiniCalc formula <code>String</code>. - */ - protected String parseFormula(String formula) { - - StringBuffer inFormula = new StringBuffer(formula); - StringBuffer outFormula = new StringBuffer(); - - boolean inBrace = false; - boolean firstCharAfterBrace = false; - boolean firstCharAfterColon = false; - - int len = inFormula.length(); - - for (int in = 0; in < len; in++) { - switch (inFormula.charAt(in)) { - case '[': - // We are now inside a StarOffice cell reference. - // We also need to strip out the '[' - inBrace = true; - - // If the next character is a '.', we want to strip it out - firstCharAfterBrace = true; - break; - - case ']': - // We are exiting a StarOffice cell reference - // We are stripping out the ']' - inBrace = false; - break; - - case ':': - // We have a cell range reference. - // May need to strip out the leading '.' - if (inBrace) - firstCharAfterColon = true; - outFormula.append(inFormula.charAt(in)); - break; - - case '.': - if (inBrace == true) { - if (firstCharAfterBrace == false && - firstCharAfterColon == false) { - // Not the first character after the open brace. - // We have hit a separator between a sheet reference - // and a cell reference. MiniCalc uses a ! as - // this type of separator. - outFormula.append('!'); - } - else { - firstCharAfterBrace = false; - firstCharAfterColon = false; - // Since we are in a StarOffice cell reference, - // and we are the first character, we need to - // strip out the '.' - } - break; - } else { - // We hit valid data, lets add it to the formula string - outFormula.append(inFormula.charAt(in)); - break; - } - - case ';': - // StarOffice XML format uses ';' as a separator. MiniCalc (and - // many spreadsheets) use ',' as a separator instead. - outFormula.append(','); - break; - - default: - // We hit valid data, lets add it to the formula string - outFormula.append(inFormula.charAt(in)); - - // Need to make sure that firstCharAfterBrace is not true. - firstCharAfterBrace = false; - break; - } - } - - return outFormula.toString(); - } - - /** - * Add a cell to the current WorkSheet. - * - * @param row The row number of the cell. - * @param column The column number of the cell. - * @param fmt The <code>Format</code> object describing - * the appearance of this cell. - * @param cellContents The text or formula of the cell's contents. - * - * @throws IOException If any I/O error occurs. - */ - public void addCell(int row, int column, Format fmt, String cellContents) throws IOException { - - CellAttributes ca = new CellAttributes(getFormat(fmt), - fmt.getForeground(), - fmt.getBackground()); - if (cellContents.startsWith("=")) { - cellContents = parseFormula(cellContents); - Debug.log(Debug.INFO, "YAHOO Found Formula" + cellContents); - } - - CellDescriptor cellDes = new CellDescriptor(row, column, ca, cellContents); - - try { - ws.putCell(cellDes); - } - catch (JMCException jmce) { - Debug.log(Debug.ERROR, "ws.putCell threw exception: " + jmce.getMessage()); - throw new IOException(jmce.getMessage()); - } - } - - - /** - * Set the width of the columns in the WorkBook. - * - * @param columnWidths An <code>IntArrayList</code> of column - * widths. - */ - public void setColumnWidths(IntArrayList columnWidths) throws IOException { - // Get the number of columns - int numColumns = columnWidths.size(); - - // Return if there are no columns in the listr - if (numColumns == 0) { - return; - } - - // Need to set the FORM_FLAGS_NONDEFAULT flag for the column widths - // to be used in MiniCalc - long format = JMCconstants.FORM_FLAGS_NONDEFAULT; - - CellAttributes ca = new CellAttributes(format); - - try { - for (int i = 0; i < numColumns; i++) { - // Get the column width in Palm pixels - int width = columnWidths.get(i) * pixelsPerChar; - - // Check limits on column width - if (width < minWidth) { - width = minWidth; - } else if (width > maxWidth) { - width = maxWidth; - } - - // Add the column descriptor to the WorkSheet - ws.putColumn(i + 1, width, ca); - } - } - catch (JMCException jmce) { - Debug.log(Debug.ERROR, "ws.putColumn threw exception: " + jmce.getMessage()); - throw new IOException(jmce.getMessage()); - } - } - - - /** - * This method sets the format of a cell to <i>string</i>. - * - * @param format The cell format-may already contain display info, - * such as alignment or font type. - * - * @return The updated format of the cell. - */ - private long setFormatString(long format) { - - format = clearCellFormatType(format); - - // Set format to generic, since MiniCalc does not have a string type. - format = format | JMCconstants.FF_FORMAT_GENERIC; - - return format; - } - - - /** - * This method sets the format of a cell to <i>floating point</i>. - * - * @param format The cell format. May already contain - * display info, such as alignment or - * font type. - * @param decimalPlaces The number of decimal places to - * set in the floating point number. - * - * @return The updated format of the cell. - */ - private long setFormatFloat(long format, int decimalPlaces) { - - format = clearCellFormatType(format); - - // Set format to floating point with correct number of decimal places - format = format | JMCconstants.FF_FORMAT_DECIMAL | decimalPlaces; - - return format; - } - - - /** - * This method sets the format of a cell to <i>time</i>. - * - * @param format The cell format-may already contain display info, - * such as alignment or font type. - * - * @return The updated format of the cell. - */ - private long setFormatTime(long format) { - - format = clearCellFormatType(format); - - // Set format to time. - format = format | JMCconstants.FF_FORMAT_TIME; - - return format; - } - - - /** - * This method sets the format of a cell to <i>date</i>. - * - * @param format The cell format-may already contain display info, - * such as alignment or font type. - * - * @return The updated format of the cell. - */ - private long setFormatDate(long format) { - - format = clearCellFormatType(format); - - // Set format to date. - format = format | JMCconstants.FF_FORMAT_DATE; - - return format; - } - - - /** - * This method sets the format of a cell to <i>currency</i>. - * - * @param format The cell format-may already contain - * display info, such as alignment or - * font type. - * @param decimalPlaces The number of decimal places to set. - * - * @return The updated format of the cell. - */ - private long setFormatCurrency(long format, int decimalPlaces) { - - format = clearCellFormatType(format); - - // Set format to Currency with correct number of decimal places - format = format | JMCconstants.FF_FORMAT_CURRENCY | decimalPlaces; - - return format; - } - - - /** - * This method sets the format of a cell to <i>boolean</i>. - * - * @param format The cell format-may already contain display info, - * such as alignment or font type. - * - * @return The updated format of the cell. - */ - private long setFormatBoolean(long format) { - - format = clearCellFormatType(format); - - // Set format to generic, since MiniCalc does not have a Boolean type. - format = format | JMCconstants.FF_FORMAT_GENERIC; - - return format; - } - - - /** - * This method sets the format of a cell to <i>percent</i>. - * - * @param format The cell format-may already contain - * display info, such as alignment or - * font type. - * @param decimalPlaces The number of decimal places to set. - * - * @return The updated format of the cell. - */ - private long setFormatPercent(long format, int decimalPlaces) { - - format = clearCellFormatType(format); - - // Set format to Percent with correct number of decimal places - format = format | JMCconstants.FF_FORMAT_PERCENT | decimalPlaces; - - return format; - } - - - /** - * This method clears out the format bits associated with - * the type of data (<i>float</i>, <i>time</i>, etc...) in - * a cell. - * - * @param format The original format for the cell. - * - * @return The updated cell format with the bits associated - * with the type of data (float, time, etc...) - * zeroed out. - */ - private long clearCellFormatType(long format) { - - // First 4 bits are for the number of decimal places - // bits 5-8 are for the data format (float, time, etc...) - - // Clear out first 8 bits - format = format & 0xFFFFFFFFFFFFFF00L; - - return format; - } - - - /** - * Set a cell's formatting options via a separately create - * <code>Format</code> object. - * - * @param row The row number of the cell to be changed. - * @param column The column number of the cell to be changed. - * @param fmt Object containing formatting settings for - * this cell. - */ - public void setCellFormat(int row, int column, Format fmt) { - } - - - /** - * Get the names of the sheets in the WorkBook. - * - * @param sheet The required sheet. - */ - public String getSheetName(int sheet) { - return wb.getWorksheet(sheet).getName(); - } - - - /* - * This method returns a MiniCalc style format from the - * <code>Format</code> object. - */ - private long getFormat(Format fmt) - { - String category = fmt.getCategory(); - - if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_BOOLEAN)) { - return setFormatBoolean(0); - } - else if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_CURRENCY)) { - return setFormatCurrency(0, fmt.getDecimalPlaces()); - } - else if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_DATE)) { - return setFormatDate(0); - } - else if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_FLOAT)) { - return setFormatFloat(0, fmt.getDecimalPlaces()); - } - else if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_PERCENT)) { - return setFormatPercent(0, fmt.getDecimalPlaces()); - } - else if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_STRING)) { - return setFormatString(0); - } - else if (category.equalsIgnoreCase(OfficeConstants.CELLTYPE_TIME)) { - return setFormatTime(0); - } - else { - // Should never get here, but just in case - System.out.println("XXXXX Formatting information not found"); - return 0; - } - } -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/PluginFactoryImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/PluginFactoryImpl.java deleted file mode 100644 index 26ef06dd3f92..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/PluginFactoryImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.DocumentSerializerFactory; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.DocumentDeserializerFactory; -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.sxc.DocumentMergerImpl; -import org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.util.registry.ConverterInfo; -import java.io.IOException; -import java.io.InputStream; - -/** - * <p>MiniCalc implementation of the <code>PluginFactory</code>. - * This encapsulates conversion of StarCalc XML format to and from - * MiniCalc format.</p> - * - * <p>The superclass produces a particular - * {@link org.openoffice.xmerge.Document Document} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxc.SxcDocument - * SxcDocument} that the converters in this class works with. Thus, - * this class only implements the methods that produces the converters, - * i.e. {@link - * org.openoffice.xmerge.DocumentSerializer - * DocumentSerializer} and {@link - * org.openoffice.xmerge.DocumentDeserializer - * DocumentDeserializer}; - * as well as the {@link - * org.openoffice.xmerge.ConverterCapabilities - * ConverterCapabilities} object that is specific to this format - * conversion. That superclass also produces a {@link - * org.openoffice.xmerge.DocumentMerger DocumentMerger} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxc.DocumentMergerImpl - * DocumentMergerImpl} which this class derives the functionality.</p> - */ -public final class PluginFactoryImpl extends SxcPluginFactory - implements DocumentDeserializerFactory, DocumentSerializerFactory { - - /** ConverterCapabilities object for this type of conversion. */ - private final static ConverterCapabilities converterCap = - new ConverterCapabilitiesImpl(); - - - public PluginFactoryImpl(ConverterInfo ci) { - super(ci); - } - - - /** - * Returns an instance of <code>DocumentSerializerImpl</code>, - * which is an implementation of <code>DocumentSerializer</code> - * interface. - * - * @param doc <code>Document</code> object to be - * converted/serialized. - * - * @return A <code>DocumentSerializerImpl</code> object. - */ - public DocumentSerializer createDocumentSerializer(Document doc) { - - return new SxcDocumentSerializerImpl(doc); - } - - - /** - * Returns an instance of <code>DocumentDeserializerImpl</code>, - * which is an implementation of <code>DocumentDeserializer</code> - * interface. - * - * @param cd <code>ConvertData</code> object for reading data - * which will be converted back to a - * <code>Document</code> object. - * - * @return A <code>DocumentDeserializerImpl</code> object. - */ - public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { - - return new SxcDocumentDeserializerImpl(cd); - } - - - public Document createDeviceDocument(String name, InputStream is) - throws IOException { - - PalmDocument palmDoc = new PalmDocument(is); - return palmDoc; - } - - public DocumentMerger createDocumentMerger(Document doc) { - - DocumentMergerImpl merger = new DocumentMergerImpl(doc, converterCap); - return merger; - } -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java deleted file mode 100644 index c4e825eca055..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer; -import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; -import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.converter.palm.PalmDocument; - -import java.io.IOException; -import java.util.Enumeration; - -/** - * <p>MiniCalc implementation of <code>DocumentDeserializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxc.minicalc.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>This converts a set of files in MiniCalc PDB format to a StarOffice DOM.</p> - * - */ -public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { - - /** - * Creates new <code>SxcDocumentDeserializerImpl</code>. - * - * @param cd <code>ConvertData</code> Input data to convert. - */ - public SxcDocumentDeserializerImpl(ConvertData cd) { - super(cd); - } - - - /** - * This method will be implemented by concrete subclasses and will - * return an application-specific decoder. - * - * @param workbook The WorkBook name. - * @param worksheetNames An array of WorkSheet names. - * @param password The password. - * - * @return An application-specific <code>SpreadsheetDecoder</code>. - */ - public SpreadsheetDecoder createDecoder(String workbook, - String[] worksheetNames, String password) throws IOException { - - return new MinicalcDecoder(workbook, worksheetNames, password); - } - - - /** - * This method will return the name of the WorkBook from the - * <code>ConvertData</code>. Allows for situations where the - * WorkBook name differs from the PDB name. - * - * Implemented in the Deserializer as the Decoder's constructor - * requires a name. - * - * @param cd The <code>ConvertData</code>. - * - * @return The name of the WorkBook. - */ - protected String getWorkbookName(ConvertData cd) - throws IOException { - - Enumeration e = cd.getDocumentEnumeration(); - PalmDocument palmDoc = (PalmDocument) e.nextElement(); - String workbookName = palmDoc.getName(); - - // Search for "-", which separates workbook from worksheet - int end = workbookName.indexOf("-"); - - if (end > 0) { - workbookName = workbookName.substring(0, end); - } - - return workbookName; - } - - - /** - * This method will return an array of WorkSheet names from the - * <code>ConvertData</code>. - * - * @param cd The <code>ConvertData</code>. - * - * @return The name of the WorkSheet. - */ - protected String[] getWorksheetNames(ConvertData cd) - throws IOException { - int numberOfPDBs = cd.getNumDocuments(); - String worksheetName[] = new String[numberOfPDBs]; - int i=0; - Enumeration e = cd.getDocumentEnumeration(); - while (e.hasMoreElements()) { - PalmDocument palmDoc = (PalmDocument) e.nextElement(); - worksheetName[i] = palmDoc.getName(); - - // Search for the "-", which seperates workbook from worksheet - int start = worksheetName[i].indexOf("-"); - - if (start != -1) { - worksheetName[i] = worksheetName[i].substring(start + 1); - } - i++; - } - - return worksheetName; - } -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentSerializerImpl.java b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentSerializerImpl.java deleted file mode 100644 index dfe51efb46b2..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentSerializerImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.minicalc; - -import java.awt.Color; - -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Element; - -import java.io.IOException; - -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.converter.palm.PalmDocument; - -import jmc.JMCconstants; - -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer; - -/** - * <p>MiniCalc implementation of <code>SxcDocumentDeserializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxc.minicalc.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>This converts StarOffice XML format to a set of files in - * MiniCalc PDB format.</p> - * - */ -public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { - - - /** - * Constructor. - * - * @param document The <code>Document</code> to convert. - */ - public SxcDocumentSerializerImpl(Document document) { - super(document); - } - - - public ConvertData serialize() throws ConvertException, IOException { - - - // Get the server side document name. This value should not - // contain a path or the file extension. - String docName = sxcDoc.getName(); - - // TODO - get real values for password when implemnted in XML - // Passwords are not currently stored in StarCalc XML format. - String password = null; - - encoder = new MinicalcEncoder(docName, password); - - // get dom document - org.w3c.dom.Document domDoc = sxcDoc.getContentDOM(); - - // Traverse to the office:body element. - // There should only be one. - NodeList list = domDoc.getElementsByTagName(TAG_OFFICE_BODY); - int len = list.getLength(); - - if (len > 0) { - Node node = list.item(0); - traverseBody(node); - } - - // Get the number of sheets in the workbook - // This will equal the number of PDBs we need - ConvertData cd = new ConvertData(); - int numSheets = encoder.getNumberOfSheets(); - - for (int i = 0; i < numSheets; i++) { - - // Get records for sheet i - Record records[] = ((MinicalcEncoder) encoder).getRecords(i); - - // Get the sheet name for sheet i - String fullSheetName = new String(docName - + "-" - + encoder.getSheetName(i)); - - // Create a PalmDB object - PalmDocument palmDoc = new PalmDocument(fullSheetName, - MinicalcConstants.CREATOR_ID, - MinicalcConstants.TYPE_ID, JMCconstants.AppVersion, - PalmDB.PDB_HEADER_ATTR_BACKUP, records); - - cd.addDocument(palmDoc); - } - - - // OutputStream os = new FileOutputStream(docName); - - //pdbSet.write(os); - //os.flush(); - - //ConvertDataEntry cde = new ConvertDataOutputStream(os, docName); - //cd.addCDE(cde); - - return cd; - } - - - -} - diff --git a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/package.html b/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/package.html deleted file mode 100644 index cd5469181034..000000000000 --- a/xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/package.html +++ /dev/null @@ -1,42 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<html> -<head> -<title>org.openoffice.xmerge.converter.xml.sxc.minicalc package</title> -</head> - -<body bgcolor="white"> - -<p>Provides the tools for doing the conversion of StarWriter XML to -and from MiniCalc format.</p> - -<p>It follows the {@link org.openoffice.xmerge} framework for the conversion process.</p> - -<p>Since it converts to/from a Palm application format, these converters -follow the <a href=../../../../converter/palm/package-summary.html#streamformat> -PalmDB stream format</a> for writing out to the Palm sync client or reading -in from the Palm sync client.</p> - -<p>Note that <code>PluginFactoryImpl</code> also provides a -<code>DocumentMerger</code> object, i.e. {@link org.openoffice.xmerge.converter.xml.sxw.aportisdoc.DocumentMergerImpl DocumentMergerImpl}. -This functionality was derived from its superclass -{@link org.openoffice.xmerge.converter.xml.sxw.SxwPluginFactory SxwPluginFactory}.</p> - -</body> -</html> diff --git a/xmerge/source/minicalc/makefile.mk b/xmerge/source/minicalc/makefile.mk deleted file mode 100644 index 9ceb3233f9a0..000000000000 --- a/xmerge/source/minicalc/makefile.mk +++ /dev/null @@ -1,24 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -TARGET=minicalc -PRJ=../.. -PRJNAME=xmerge - -.INCLUDE : ant.mk -ALLTAR: ANTBUILD diff --git a/xmerge/source/minicalc/minicalc.mf b/xmerge/source/minicalc/minicalc.mf deleted file mode 100644 index 1f0a0e35e276..000000000000 --- a/xmerge/source/minicalc/minicalc.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: jmc.jar - diff --git a/xmerge/source/pexcel/converter.xml b/xmerge/source/pexcel/converter.xml deleted file mode 100644 index 2e77ae9018ce..000000000000 --- a/xmerge/source/pexcel/converter.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<converters> - <converter type="staroffice/sxc" version="1.0"> - <converter-display-name> - Pocket Excel 2.0 - </converter-display-name> - <converter-description> - StarCalc XML to/from Pocket Excel 2.0 conversion - </converter-description> - <converter-vendor>OpenOffice.org</converter-vendor> - <converter-class-impl> - org.openoffice.xmerge.converter.xml.sxc.pexcel.PluginFactoryImpl - </converter-class-impl> - <converter-target type="application/x-pocket-excel" /> - </converter> -</converters> - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl.java deleted file mode 100644 index d33b7e02bfd1..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/ConverterCapabilitiesImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel; - -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.OfficeConstants; - - -/** - * <p>Pocket Excel implementation of <code>ConverterCapabilities</code> for - * the {@link - * org.openoffice.xmerge.converter.xml.sxc.pexcel.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>Used with StarCalc SXC to/from Pocket Excel conversions. The - * <code>ConverterCapibilies</code> specify which "Office" - * <code>Document</code> tags and attributes are supported on the - * "Device" <code>Document</code> format.</p> - */ -public final class ConverterCapabilitiesImpl - implements ConverterCapabilities { - - public boolean canConvertTag(String tag) { - - if (OfficeConstants.TAG_OFFICE_BODY.equals(tag)) - return true; - else if (OfficeConstants.TAG_PARAGRAPH.equals(tag)) - return true; - else if (OfficeConstants.TAG_TABLE.equals(tag)) - return true; - else if (OfficeConstants.TAG_TABLE_ROW.equals(tag)) - return true; - else if (OfficeConstants.TAG_TABLE_COLUMN.equals(tag)) - return false; - // TODO - we currently do not handle the table column tag - else if (OfficeConstants.TAG_TABLE_SCENARIO.equals(tag)) - return false; - // TODO - we currently do not handle the table scenario tag - else if (OfficeConstants.TAG_TABLE_CELL.equals(tag)) - return true; - - return false; - } - - public boolean canConvertAttribute(String tag, - String attribute) { - - if (OfficeConstants.TAG_TABLE.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_TABLE_NAME.equals(attribute)) - return true; - - } else if (OfficeConstants.TAG_TABLE_CELL.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_TABLE_VALUE_TYPE.equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_FORMULA. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_VALUE.equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_BOOLEAN_VALUE. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_CURRENCY. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_TIME_VALUE. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_DATE_VALUE. - equals(attribute)) - return true; - else if (OfficeConstants.ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED. - equals(attribute)) - return true; - - } else if (OfficeConstants.TAG_TABLE_ROW.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_TABLE_NUM_ROWS_REPEATED. - equals(attribute)) - return true; - } - - return false; - } -} - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java deleted file mode 100644 index 690f2f3dd540..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PluginFactoryImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel; - -import java.io.IOException; -import java.io.InputStream; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.DocumentSerializerFactory; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.DocumentDeserializerFactory; -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.sxc.DocumentMergerImpl; -import org.openoffice.xmerge.converter.xml.sxc.SxcPluginFactory; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.util.registry.ConverterInfo; - -/** - * <p>Pocket Excel implementation of the <code>PluginFactory</code>. - * This encapsulates conversion of StarCalc XML format to and from - * Pocket Excel format.</p> - * - * <p>The superclass produces a particular - * {@link org.openoffice.xmerge.Document Document} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxc.SxcDocument - * SxcDocument} that the converters in this class works with. Thus, - * this class only implements the methods that produces the converters, - * i.e. {@link - * org.openoffice.xmerge.DocumentSerializer - * DocumentSerializer} and {@link - * org.openoffice.xmerge.DocumentDeserializer - * DocumentDeserializer}; - * as well as the {@link - * org.openoffice.xmerge.ConverterCapabilities - * ConverterCapabilities} object that is specific to this format - * conversion. That superclass also produces a {@link - * org.openoffice.xmerge.DocumentMerger DocumentMerger} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxc.DocumentMergerImpl - * DocumentMergerImpl} which this class derives the functionality.</p> - */ -public final class PluginFactoryImpl extends SxcPluginFactory - implements DocumentDeserializerFactory, DocumentSerializerFactory { - - /** ConverterCapabilities object for this type of conversion. */ - private final static ConverterCapabilities converterCap = - new ConverterCapabilitiesImpl(); - - - public PluginFactoryImpl(ConverterInfo ci) { - super(ci); - } - - - /** - * Returns an instance of <code>DocumentSerializerImpl</code>, - * which is an implementation of <code>DocumentSerializer</code> - * interface. - * - * @param doc <code>Document</code> object to be - * converted/serialized. - * - * @return A <code>DocumentSerializerImpl</code> object. - */ - public DocumentSerializer createDocumentSerializer(Document doc) { - - return new SxcDocumentSerializerImpl(doc); - } - - - /** - * Returns an instance of <code>DocumentDeserializerImpl</code>, - * which is an implementation of <code>DocumentDeserializer</code> - * interface. - * - * @param cd <code>ConvertData</code> object for reading data - * which will be converted back to a - * <code>Document</code> object. - * - * @return A <code>DocumentDeserializerImpl</code> object. - */ - public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { - - return new SxcDocumentDeserializerImpl(cd); - } - - - public Document createDeviceDocument(String name, InputStream is) - throws IOException { - - Workbook wb = new Workbook(name, is); - return wb; - } - - public DocumentMerger createDocumentMerger(Document doc) { - - DocumentMergerImpl merger = new DocumentMergerImpl(doc, converterCap); - return merger; - } -} - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants.java deleted file mode 100644 index e5565868908c..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelConstants.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel; - - -/** - * Interface defining constants for Pocket Excel attributes. - * - */ -public interface PocketExcelConstants { - /** File extension for Pocket Word files. */ - public static final String FILE_EXTENSION = ".pxl"; - - /** Constants for pexcel BIFF records */ - public static final int BLANK_CELL = 0x01; - public static final int NUMBER_CELL = 0x03; - public static final int LABEL_CELL = 0x04; - public static final int BOOLERR_CELL = 0x05; - public static final int FORMULA_CELL = 0x06; - public static final int FORMULA_STRING = 0x07; - public static final int ROW_DESCRIPTION = 0x08; - public static final int BOF_RECORD = 0x09; - public static final int EOF_MARKER = 0x0A; - public static final int DEFINED_NAME = 0x18; - public static final int CURRENT_SELECTION = 0x1D; - public static final int NUMBER_FORMAT = 0x1E; - public static final int DEFAULT_ROW_HEIGHT = 0x25; - public static final int FONT_DESCRIPTION = 0x31; - public static final int WINDOW_INFO = 0x3D; - public static final int SHEET_WINDOW_INFO = 0x3E; - public static final int PANE_INFO = 0x41; - public static final int CODEPAGE = 0x42; - public static final int DEF_COL_WIDTH = 0x55; - public static final int COLINFO = 0x7D; - public static final int BOUND_SHEET = 0x85; - public static final int EXTENDED_FORMAT = 0xE0; - - /** Colour lookup table for mapping pexcel color values - (See util/ColourConverter.java */ - public short cLookup[] = { 0, 14, 15, 1, 2, 3, 4, 7, 6, 5, 8, 9, 10, 13, 12, 11 }; -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java deleted file mode 100644 index efbdbee06a93..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelDecoder.java +++ /dev/null @@ -1,428 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.NoSuchElementException; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxc.BookSettings; -import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.sxc.NameDefinition; -import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.BIFFRecord; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.CellValue; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.ColInfo; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.ExtendedFormat; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.FloatNumber; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.FontDescription; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Formula; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Row; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Worksheet; -import org.openoffice.xmerge.util.Debug; - -/** - * This class is used by {@link SxcDocumentDeserializerImpl} - * SxcDocumentDeserializerImpl} to decode the Pocket Excel format. - * - */ -final class PocketExcelDecoder extends SpreadsheetDecoder { - - private Workbook wb; - private Worksheet ws; - private CellValue cell; - private int maxRows = 0; - private int maxCols = 0; - private int wsIndex; - private Iterator<BIFFRecord> cellValue; - private Format fmt = null; - - /** - * Constructor creates a Pocket Excel WorkBook. - */ - PocketExcelDecoder() { - fmt = new Format(); - } - - - /** - * This method takes a <code>ConvertData</code> as input and - * converts it into a PocketWord WorkSheet. The WorkSheet is then - * added to the WorkBook. - * - * @param cd An <code>ConvertData</code> containing a - * Pocket Excel WorkSheet. - * - * @throws IOException If any I/O error occurs. - */ - public void addDeviceContent(ConvertData cd) throws IOException { - - Iterator<Object> e = cd.getDocumentEnumeration(); - wb = (Workbook) e.next(); - } - - - /** - * This method returns the number of spreadsheets - * stored in the WorkBook. - * - * @return The number of sheets in the WorkBook. - */ - public int getNumberOfSheets() { - - ArrayList<Object> v = wb.getWorksheetNames(); - Debug.log(Debug.TRACE,"Total Number of Sheets : " + v.size()); - return (v.size()); - } - - /** - * This method returns the number of spreadsheets - * stored in the WorkBook. - * - * @return The number of sheets in the WorkBook. - */ - public Iterator<NameDefinition> getNameDefinitions() { - - Iterator<DefinedName> e = wb.getDefinedNames(); - ArrayList<NameDefinition> nameDefinitionVector = new ArrayList<NameDefinition>(); - while(e.hasNext()) { - DefinedName dn = e.next(); - NameDefinition nameDefinitionEntry = dn.getNameDefinition(); - nameDefinitionVector.add(nameDefinitionEntry); - } - Debug.log(Debug.TRACE,"Getting " + nameDefinitionVector.size() + " DefinedName records"); - return (nameDefinitionVector.iterator()); - } - - /** - * This method returns an enumeration of Settings object(s), - * one for each worksheet - * - * @return An enumerattion of <code>Settings</code> - */ - public BookSettings getSettings() { - - return (wb.getSettings()); - } - /** - * This method returns the number of spreadsheets - * stored in the WorkBook. - * - * @return The number of sheets in the WorkBook. - */ - public Iterator<ColumnRowInfo> getColumnRowInfos() { - - ArrayList<ColumnRowInfo> colRowVector = new ArrayList<ColumnRowInfo>(); - - // Collect Columns from worksheet and add them to the vector - for(Iterator<ColInfo> e = ws.getColInfos();e.hasNext();) { - ColInfo ci = e.next(); - int repeated = ci.getLast() - ci.getFirst() + 1; - ColumnRowInfo colInfo = new ColumnRowInfo( ci.getColWidth(), - repeated, - ColumnRowInfo.COLUMN); - colRowVector.add(colInfo); - } - - // Collect Rows from worksheet and add them to the vector - for(Iterator<Row> e = ws.getRows();e.hasNext();) { - Row rw = e.next(); - // We will use the repeat field for number (unlike columns rows - // cannot be repeated, we have unique record for each row in pxl - int repeated = rw.getRowNumber(); - ColumnRowInfo rowInfo = new ColumnRowInfo( rw.getRowHeight(), - repeated, - ColumnRowInfo.ROW); - colRowVector.add(rowInfo); - } - Debug.log(Debug.TRACE,"Getting " + colRowVector.size() + " ColRowInfo records"); - return (colRowVector.iterator()); - } - - /** - * This method gets the requested WorkSheet from the - * WorkBook and sets it as the selected WorkSheet. All - * other "get" methods will now get data from this WorkSheet. - * - * @param sheetIndex The index number of the sheet to open. - * - * @throws IOException If any I/O error occurs. - */ - public void setWorksheet(int sheetIndex) throws IOException { - Debug.log(Debug.TRACE,"Setting to worksheet : " + sheetIndex); - ws = wb.getWorksheet(sheetIndex); - cellValue = ws.getCellEnumerator(); - wsIndex = sheetIndex; - while(goToNextCell()) { - maxRows = Math.max(maxRows, cell.getRow()); - maxCols = Math.max(maxCols, cell.getCol()); - } - cellValue = ws.getCellEnumerator(); - Debug.log(Debug.TRACE,"Max Cols : " + maxCols + " MaxRows : " + maxRows); - } - - - /** - * This method returns the name of the current spreadsheet. - * - * @return The name of the current WorkSheet. - */ - public String getSheetName() { - - String wsName = wb.getSheetName(wsIndex); - Debug.log(Debug.TRACE,"The name of the current Worksheet is : " + wsName); - return wsName; - } - - - /** - * This method gets the next cell from the WorkSheet - * and sets it as the selected cell. All other "get" - * methods will now get data from this cell. - * - * @return True if we were able to go to another cell - * in the sheet, false if there were no cells - * left. - * - * @throws IOException If any I/O error occurs. - */ - public boolean goToNextCell() throws IOException { - - boolean success = false; - - try { - cell = (CellValue) cellValue.next(); - Debug.log(Debug.TRACE,"Current Cell : " + cell.getString()); - readCellFormat(); - success = true; - } catch (NoSuchElementException e) { - Debug.log(Debug.TRACE,"Could't find current cell"); - } - - return success; - } - - - /** - * This method returns the row number of the current cell. - * - * @return The row number of the current cell. Returns - * -1 if no cell is currently selected. - */ - public int getRowNumber() { - - int row = -1; - - if (cell != null) { - row = cell.getRow(); - Debug.log(Debug.TRACE,"cell row is " + row); - } - return (row); - } - - /** - * This method returns the number of rows in the current sheet. - * - * @return The number of rows in the current sheet. - */ - public int getNumberOfRows() { - return maxRows; - } - - /** - * This method returns the number of columns in the current sheet. - * - * @return The number of columns in the current sheet. - */ - public int getNumberOfColumns() { - return maxCols; - } - - - /** - * This method returns the col number of the current cell. - * - * @return The col number of the current cell. Returns - * -1 if no cell is currently selected. - */ - public int getColNumber() { - - int col = -1; - - if (cell != null) { - col = cell.getCol(); - Debug.log(Debug.TRACE,"cell col is " + col); - } - return (col); - } - - /** - * This method returns the contents of the current cell. - * - * @return The contents of the current cell. Returns - * null if no cell is currently selected. - */ - public String getCellContents() { - - String contents = new String(""); - - if (cell != null) { - try { - contents = cell.getString(); - if (contents.startsWith("=")) { - contents = parseFormula(contents); - } - } - catch (IOException e) { - System.err.println("Could Not retrieve Cell contents"); - System.err.println("Setting contents of cell(" + cell.getRow() - + "," + cell.getCol() + ") to an empty string"); - System.err.println("Error msg: " + e.getMessage()); - } - } - - return contents; - } - - /** - * <p>This method takes a formula and parses it into - * StarOffice XML formula format.</p> - * - * <p>Many spreadsheets use ',' as a separator. - * StarOffice XML format uses ';' as a separator instead.</p> - * - * <p>Many spreadsheets use '!' as a separator when refencing - * a cell in a different sheet.</p> - * - * <blockquote> - * Example: =sheet1!A1 - * </blockquote> - * - * <p>StarOffice XML format uses '.' as a separator instead.</p> - * - * <blockquote> - * Example: =sheet1.A1 - * </blockquote> - * - * @param formula A formula string. - * - * @return A StarOffice XML format formula string. - */ - protected String parseFormula(String formula) { - - formula = formula.replace(',', ';'); - formula = formula.replace('!', '.'); - - return formula; - } - - /** - * This method returns the contents of the current cell. - * - * @return The contents of the current cell. Returns - * null if no cell is currently selected. - */ - public String getCellValue() { - - String contents = new String(""); - - if (cell != null) { - try { - contents = ((Formula)cell).getValue(); - } - catch (IOException e) { - System.err.println("Could Not retrieve Cell value"); - System.err.println("Setting value of cell(" + cell.getRow() - + "," + cell.getCol() + ") to an empty string"); - System.err.println("Error msg: " + e.getMessage()); - } - } - return contents; - } - - /** - * <p>This method returns the type of the data in the current cell. - * Currently the only type supported is String.</p> - * - * @return The type of the data in the current cell. - */ - public String getCellDataType() { - - String type = OfficeConstants.CELLTYPE_STRING; - - if(cell instanceof FloatNumber) - type = OfficeConstants.CELLTYPE_FLOAT; - if(cell instanceof Formula) - type = OfficeConstants.CELLTYPE_FLOAT; - - return type; - } - - - /** - * Return the Format object describing the active cell formatting. - * - * @return The Format object describing the active cell formatting. - */ - public Format getCellFormat() { - return new Format(fmt); - } - - - /** - * Create the format data for the new cell. - */ - private void readCellFormat() throws IOException { - - fmt.clearFormatting(); - - Debug.log(Debug.TRACE," ixfe for Current Cell " + cell.getIxfe()); - ExtendedFormat xf = wb.getExtendedFormat(cell.getIxfe()); - Debug.log(Debug.TRACE," ixfnt for Current Cell " + xf.getFontIndex()); - FontDescription fd = wb.getFontDescription(xf.getFontIndex()); - - fmt.setAttribute(Format.ITALIC, fd.isItalic()); - fmt.setAttribute(Format.BOLD, fd.isBold()); - fmt.setAttribute(Format.UNDERLINE, fd.isUnderline()); - fmt.setForeground(fd.getForeground()); - - fmt.setBackground(xf.getBackground()); - fmt.setAlign(xf.getAlign()); - fmt.setVertAlign(xf.getVertAlign()); - fmt.setAttribute(Format.WORD_WRAP, xf.isWordWrap()); - - fmt.setAttribute(Format.TOP_BORDER, xf.isBorder(ExtendedFormat.TOP_BORDER)); - fmt.setAttribute(Format.BOTTOM_BORDER, xf.isBorder(ExtendedFormat.BOTTOM_BORDER)); - fmt.setAttribute(Format.RIGHT_BORDER, xf.isBorder(ExtendedFormat.RIGHT_BORDER)); - fmt.setAttribute(Format.LEFT_BORDER, xf.isBorder(ExtendedFormat.LEFT_BORDER)); - - fmt.setFontName(fd.getFont()); - fmt.setFontSize(fd.getFontSize()); - - fmt.setCategory(getCellDataType()); - - } -} - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java deleted file mode 100644 index 925e8f95787d..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/PocketExcelEncoder.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel; - -import java.io.IOException; -import java.util.ArrayList; - -import org.openoffice.xmerge.util.Debug; - -import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; -import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetEncoder; -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.sxc.BookSettings; -import org.openoffice.xmerge.converter.xml.sxc.NameDefinition; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; - -/** - * This class is used by {@link SxcDocumentSerializerImpl} to encode the Pocket Excel format. - * - */ -final class PocketExcelEncoder extends SpreadsheetEncoder { - - private Workbook wb; - - /** - * Constructor creates a Pocket Excel WorkBook. - * - * @param name The name of the WorkBook. - * - * @throws IOException If any I/O error occurs. - */ - PocketExcelEncoder(String name) throws IOException { - wb = new Workbook(name); - } - - - /** - * This method creates a WorkSheet belonging to the - * WorkBook. - * - * @param sheetName The name of the WorkSheet. - * - * @throws IOException If any I/O error occurs. - */ - public void createWorksheet(String sheetName) throws IOException { - - wb.addWorksheet(sheetName); - } - - - /** - * This method gets the number of sheets in the WorkBook. - * - * @return The number of sheets in the WorkBook. - */ - public int getNumberOfSheets() { - - ArrayList<Object> v = wb.getWorksheetNames(); - return (v.size()); - } - - - /** - * This method returns the Workbook created. - * - * @return Returns a <code>Workbook</code> - * - * @throws IOException If any I/O error occurs. - */ - public Workbook getWorkbook() throws IOException { - - return wb; - } - - /** - * This method converts a String containing a formula in infix notation - * to a String in Reverse Polish Notation (RPN) - * - * @return a parsed pexcel formula in RPN - */ - protected String parseFormula(String formula) { - - Debug.log(Debug.TRACE,"Strip Formula (Before) : " + formula); - - StringBuffer inFormula = new StringBuffer(formula); - StringBuffer outFormula = new StringBuffer(); - - boolean inBrace = false; - boolean firstCharAfterBrace = false; - boolean firstCharAfterColon = false; - - int len = inFormula.length(); - - for (int in = 0; in < len; in++) { - switch (inFormula.charAt(in)) { - case '[': - // We are now inside a StarOffice cell reference. - // We also need to strip out the '[' - Debug.log(Debug.TRACE,"brace Found"); - inBrace = true; - - // If the next character is a '.', we want to strip it out - firstCharAfterBrace = true; - break; - - case ']': - // We are exiting a StarOffice cell reference - // We are stripping out the ']' - inBrace = false; - break; - case '.': - if (inBrace == true && (firstCharAfterBrace == true || - firstCharAfterColon == true) ) { - - Debug.log(Debug.TRACE,"dot Found and in brace"); - // Since we are in a StarOffice cell reference, - // and we are the first character, we need to - // strip out the '.' - firstCharAfterBrace = false; - firstCharAfterColon = false; - - } else if(firstCharAfterColon == true) { - firstCharAfterColon = false; - } else { - outFormula.append(inFormula.charAt(in)); - } - break; - - case ':': - // We have a cell range reference. - // May need to strip out the leading '.' - firstCharAfterColon = true; - outFormula.append(inFormula.charAt(in)); - break; - - case ';': - // StarOffice XML format uses ';' as a separator. MiniCalc (and - // many spreadsheets) use ',' as a separator instead. - outFormula.append(','); - break; - - default: - // We hit valid data, lets add it to the formula string - outFormula.append(inFormula.charAt(in)); - - // Need to make sure that firstCharAfterBrace is not true. - firstCharAfterBrace = false; - break; - } - } - - Debug.log(Debug.TRACE,"Strip Formula (After) : " + outFormula); - return outFormula.toString(); - } - - /** - * Add a cell to the current WorkSheet. - * - * @param row The row number of the cell. - * @param column The column number of the cell. - * @param fmt The <code>Format</code> object describing - * the appearance of this cell. - * @param cellContents The text or formula of the cell's contents. - * - * @throws IOException If any I/O error occurs. - */ - public void addCell(int row, int column, Format fmt, String cellContents) throws IOException { - - if (cellContents.startsWith("=")) { - cellContents = parseFormula(cellContents); - Debug.log(Debug.TRACE,"Parsing Formula " + cellContents); - } - wb.addCell(row, column, fmt, cellContents); - } - - - /** - * Set the width of the columns in the WorkBook. - * - * @param columnRows An <code>ArrayList</code> of ColumnRowInfo - */ - public void setColumnRows(ArrayList<ColumnRowInfo> columnRows) throws IOException { - - wb.addColInfo(columnRows); - } - - public void setNameDefinition(NameDefinition nd) throws IOException { - - String parsedName = nd.getDefinition(); - nd.setDefinition(parseFormula(parsedName)); - - wb.addNameDefinition(nd); - } - - public void addSettings(BookSettings s) throws IOException { - - wb.addSettings(s); - } - - - /** - * Set a cell's formatting options via a separately create - * <code>Format</code> object. - * - * @param row The row number of the cell to be changed. - * @param column The column number of the cell to be changed. - * @param fmt Object containing formatting settings for - * this cell. - */ - public void setCellFormat(int row, int column, Format fmt) { - Debug.log(Debug.TRACE,"bold : " + fmt.getAttribute(Format.BOLD) + - ",Italic : " + fmt.getAttribute(Format.ITALIC) + - ",Underline : " + fmt.getAttribute(Format.UNDERLINE)); - } - - - /** - * Get the names of the sheets in the WorkBook. - * - * @param sheet The required sheet. - */ - public String getSheetName(int sheet) { - ArrayList<Object> v = wb.getWorksheetNames(); - String wsName = (String) (v.get(sheet)); - - return wsName; - } - - -} - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java deleted file mode 100644 index 289edb44ec33..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentDeserializerImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.converter.xml.sxc.SpreadsheetDecoder; -import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentDeserializer; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.util.Debug; - - -/** - * <p>Pocket Excel implementation of <code>DocumentDeserializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxc.pexcel.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>This converts a set of files in Pocket Excel PXL format to a StarOffice DOM.</p> - * - */ -public final class SxcDocumentDeserializerImpl extends SxcDocumentDeserializer { - - /** - * Creates new <code>SxcDocumentDeserializerImpl</code>. - * - * @param cd <code>ConvertData</code> Input data to convert. - */ - public SxcDocumentDeserializerImpl(ConvertData cd) { - super(cd); - } - - - /** - * This method will be implemented by concrete subclasses and will - * return an application-specific decoder. - * - * @param workbook The WorkBook name. - * @param worksheetNames An array of WorkSheet names. - * @param password The password. - * - * @return An application-specific <code>SpreadsheetDecoder</code>. - */ - public SpreadsheetDecoder createDecoder(String workbook, - String[] worksheetNames, String password) throws IOException { - return new PocketExcelDecoder(); - } - - - /** - * This method will return the name of the WorkBook from the - * <code>ConvertData</code>. Allows for situations where the - * WorkBook name differs from the PDB name. - * - * Implemented in the Deserializer as the Decoder's constructor - * requires a name. - * - * @param cd The <code>ConvertData</code>. - * - * @return The name of the WorkBook. - */ - protected String getWorkbookName(ConvertData cd) - throws IOException { - - Iterator<Object> e = cd.getDocumentEnumeration(); - Workbook wb = (Workbook) e.next(); - - String workbookName = wb.getName(); - return workbookName; - } - - - /** - * This method will return an array of WorkSheet names from the - * <code>ConvertData</code>. - * - * @param cd The <code>ConvertData</code>. - * - * @return The name of the WorkSheet. - */ - protected String[] getWorksheetNames(ConvertData cd) - throws IOException { - - Iterator<Object> e = cd.getDocumentEnumeration(); - Workbook wb = (Workbook) e.next(); - ArrayList<Object> v = wb.getWorksheetNames(); - e = v.iterator(); - String worksheetNames[] = new String[v.size()]; - int i = 0; - while(e.hasNext()) { - worksheetNames[i] = (String) e.next(); - Debug.log(Debug.TRACE,"Worksheet Name : " + worksheetNames[i]); - i++; - } - return worksheetNames; - } -} - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java deleted file mode 100644 index 525c163fb51b..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/SxcDocumentSerializerImpl.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel; - -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; - -import java.io.IOException; - -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.converter.xml.sxc.SxcDocumentSerializer; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; - -/** - * <p>Pocket Excel implementation of <code>SxcDocumentDeserializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxc.pexcel.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>This converts StarOffice XML format to a set of files in - * Pocket Excel PXL format.</p> - * - */ -public final class SxcDocumentSerializerImpl extends SxcDocumentSerializer { - - - /** - * Constructor. - * - * @param document The <code>Document</code> to convert. - */ - public SxcDocumentSerializerImpl(Document document) { - super(document); - } - - - public ConvertData serialize() throws ConvertException, IOException { - - // Get the server side document name. This value should not - // contain a path or the file extension. - String docName = sxcDoc.getName(); - - // TODO - get real values for password when implemented in XML - // Passwords are not currently stored in StarCalc XML format. - String password = null; - - encoder = new PocketExcelEncoder(docName); - - // get dom document - org.w3c.dom.Document domDoc = sxcDoc.getContentDOM(); - - // load the styles - loadStyles(sxcDoc); - // Traverse to the office:body element. - // There should only be one. - NodeList list = domDoc.getElementsByTagName(TAG_OFFICE_BODY); - int len = list.getLength(); - - if (len > 0) { - Node node = list.item(0); - traverseBody(node); - } - - // get settings for this document - org.w3c.dom.Document settingsDoc = sxcDoc.getSettingsDOM(); - if(settingsDoc!=null) { - NodeList settingsList = settingsDoc.getElementsByTagName(TAG_OFFICE_SETTINGS); - int slen = settingsList.getLength(); - - if (slen > 0) { - Node settingsNode = settingsList.item(0); - traverseSettings(settingsNode); - } - } - - // Get the number of sheets in the workbook - // This will equal the number of PDBs we need - ConvertData cd = new ConvertData(); - Workbook wb = ((PocketExcelEncoder) encoder).getWorkbook(); - cd.addDocument(wb); - - return cd; - } - - - /** - * A cell reference in a StarOffice formula looks like - * [.C2] (for cell C2). MiniCalc is expecting cell references - * to look like C2. This method strips out the braces and - * the period. - * - * @param formula A StarOffice formula <code>String</code>. - * - * @return A MiniCalc formula <code>String</code>. - */ - protected String parseFormula(String formula) { - - return null; - } -} - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/package.html b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/package.html deleted file mode 100644 index cfa5a9f29ac6..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/package.html +++ /dev/null @@ -1,32 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<html> -<head> -<title>org.openoffice.xmerge.converter.xml.sxc.pexcel package</title> -</head> - -<body bgcolor="white"> - -<p>Provides the tools for doing the conversion of StarWriter XML to -and from Pocket Excel format.</p> - -<p>It follows the org.openoffice.xmerge framework for the conversion process.</p> - -</body> -</html> diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java deleted file mode 100644 index a6212a96ee65..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BIFFRecord.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - - public interface BIFFRecord { - - /** - * Get the type of the record. In the BIFF file format each record has a type - * designated with a byte value. See @link PocketExcelBiffConstants - * for a list of the BIFF constants and what they mean. - * - * @return byte The BIFF record value. - */ - public short getBiffType(); - - /** - * Read from the input stream <b>NB</b>The input stream is assumed to be in - * Little Endian format. The Biff identifier is expected to be in the stream. - * - * @param input The InputStream to read from. - * @return The number of bytes that were read in. - */ - public int read(InputStream input) throws IOException; - - /** - * Writes the record, including the BIFF record byte to the outputstream - * @param output The output stream to write to in LittleEndian format. - */ - public void write(OutputStream output) throws IOException; - -} - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java deleted file mode 100644 index 28c79c3069a4..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BeginningOfFile.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * This class describes the beginning of file. It is the - * the Biff record that marks the beginning of a a worbook - * or the beginning of worksheets in the workbook - * - */ -public class BeginningOfFile implements BIFFRecord { - - private byte[] version = new byte[2]; - private byte[] subStream = new byte[2]; - - /** - * Constructor that initializes the member values. - * - * @param global True for a workbook, false for a worksheet - */ - public BeginningOfFile(boolean global) { - setVersion((short) 271); - if(global) - setSubStreamWBGlobal(); - else - setSubStreamWorkSheet(); - } - - public BeginningOfFile(InputStream is) throws IOException { - read(is); - } - - private void setVersion(short version) { - this.version = EndianConverter.writeShort(version); - } - - int getVersion() { - return EndianConverter.readShort(version); - } - - private void setSubStreamWBGlobal() { - subStream = EndianConverter.writeShort((short) 0x05); - } - - private void setSubStreamWorkSheet() { - subStream = EndianConverter.writeShort((short) 0x10); - } - - int getSubStreamType() { - return EndianConverter.readShort(subStream); - } - - public int read(InputStream input) throws IOException { - int numBytesRead = input.read(version); - numBytesRead += input.read(subStream); - Debug.log(Debug.TRACE,"\tVersion : "+ EndianConverter.readShort(version) + - " Stream : " + EndianConverter.readShort(subStream)); - - return numBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(version); - output.write(subStream); - - Debug.log(Debug.TRACE, "Writing BeginningOfFile record"); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>BeginningOfFile</code> - */ - public short getBiffType() { - return PocketExcelConstants.BOF_RECORD; - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java deleted file mode 100644 index 2d30e8db092c..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BlankCell.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record that describes a blank cell - */ -public class BlankCell extends CellValue { - - /** - * Constructs a BlankCell <code>InputStream</code> - * - * @param is InputStream containing a BlankCell. - */ - public BlankCell(InputStream is) throws IOException { - read(is); - } - - /** - * Constructs a <code>BlankCell</code> using specified attributes - * - * @param row row number - * @param column column number - * @param ixfe font index - */ - public BlankCell(int row, int column, int ixfe) throws IOException { - - setRow(row); - setCol(column); - setIxfe(ixfe); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>BlankCell</code> - */ - public short getBiffType() { - return PocketExcelConstants.BLANK_CELL; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(rw); - output.write(col); - output.write(ixfe); - - Debug.log(Debug.TRACE, "Writing BlankCell record"); - - } - - /** - * Reads a BlankCell <code>InputStream</code> - * - * @param input InputStream containing a BlankCell. - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rw); - numOfBytesRead++; - col += input.read(); - numOfBytesRead += input.read(ixfe); - - Debug.log(Debug.TRACE, "\tRow : "+ EndianConverter.readShort(rw) + - " Column : " + col + - " ixfe : " + EndianConverter.readShort(ixfe)); - - return numOfBytesRead; - } - - /** - * Gets the <code>String</code> representing the cells contents - * - * @return the <code>String</code> representing the cells contents - */ - public String getString() throws IOException { - - return (new String("")); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java deleted file mode 100644 index 6602238fddcb..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoolErrCell.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record that describes a Boolean or Error value - */ -public class BoolErrCell extends CellValue { - - private byte bBoolErr; - private byte fError; - - /** - * Constructs a BoolErrCell from arguments - * - * @param row row number - * @param column column number - * @param ixfe font index - * @param bBoolErr Boolean value or error value - * @param fError Boolean error flag - */ - public BoolErrCell(int row, int column, int ixfe, int bBoolErr, int fError) throws IOException { - - setIxfe(ixfe); - this.bBoolErr = (byte)bBoolErr; - this.fError = (byte)fError; - setRow(row); - setCol(column); - } - - /** - * Constructs a BoolErrCell from the <code>InputStream</code> - * - * @param is InputStream containing a BoolErrCell - */ - public BoolErrCell(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>BoolErrCEll</code> - */ - public short getBiffType() { - return PocketExcelConstants.BOOLERR_CELL; - } - - /** - * Writes a <code>BoolErrCell</code> to the specified <code>Outputstream</code> - * - * @param output the <code>OutputStream</code> to write to - */ - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - - super.write(output); - - output.write(bBoolErr); - output.write(fError); - - Debug.log(Debug.TRACE,"Writing BoolErrCell record"); - } - - /** - * Reads a BoolErrCell from the <code>InputStream</code> - * - * @param input InputStream containing a BoolErrCell - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = super.read(input); - - bBoolErr = (byte) input.read(); - fError = (byte) input.read(); - numOfBytesRead += 2; - - Debug.log(Debug.TRACE, " bBoolErr : " + bBoolErr + - " fError : " + fError); - return numOfBytesRead; - } - - /** - * Gets the <code>String</code> representing the cells contents - * - * @return the <code>String</code> representing the cells contents - */ - public String getString() throws IOException { - return ("Error Cell"); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java deleted file mode 100644 index 51ac357973f0..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/BoundSheet.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.io.OutputStream; -import java.io.InputStream; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BoundSheet Record which describes the name of a worksheet - */ -public class BoundSheet implements BIFFRecord { - - private byte reserved; - private byte cch; - private byte[] sheetName; - - /** - * Constructs a pocket Excel Document assigns it the document name passed in - * - * @param name name of the worksheet represented - */ - public BoundSheet(String name) throws IOException { - setSheetName(name); - reserved = 0; - } - - /** - * Constructs a pocket Excel Document from the - * <code>InputStream</code> and assigns it the document name passed in - * - * @param is InputStream containing a Pocket Excel Data file. - */ - public BoundSheet(InputStream is) throws IOException { - read(is); - } - - /** - * Sets the worksheet name. The sheetname length must be doubled as the - * String is stored in unicode format. - * - * @param sheetName worksheet name - */ - void setSheetName(String sheetName) throws IOException { - this.cch = (byte) sheetName.length(); - this.sheetName = new byte[cch*2]; - this.sheetName = sheetName.getBytes("UTF-16LE"); - } - - public String getSheetName() { - String name; - - try { - name = new String(sheetName, "UTF-16LE"); - } catch (UnsupportedEncodingException e){ - name = "unknown"; - } - return name; - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>BoundSheet</code> - */ - public short getBiffType() { - return PocketExcelConstants.BOUND_SHEET; - } - - /** - * Write this particular <code>BIFFRecord</code> to the <code>OutputStream</code> - * - * @param output the <code>OutputStream</code> - */ - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(reserved); - output.write(cch); - output.write(sheetName); - - Debug.log(Debug.TRACE,"Writing BoundSheet record"); - } - - /** - * Reads a BoundSheet from the <code>InputStream</code> The byte array - * must be twice the size of the String as it uses unicode. - * - * @param input InputStream containing the record data - */ - public int read(InputStream input) throws IOException { - - reserved = (byte) input.read(); - cch = (byte) input.read(); - int numOfBytesRead = 2; - int strLen = cch*2; - sheetName = new byte[strLen]; - numOfBytesRead += input.read(sheetName, 0, strLen); - - Debug.log(Debug.TRACE,"\tReserved : "+ reserved + - " cch : " + cch + - " sheetName : " + new String(sheetName,"UTF-16LE")); - - return numOfBytesRead; - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java deleted file mode 100644 index d7ac2b71db23..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CellValue.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; - -public abstract class CellValue implements BIFFRecord { - - protected byte[] rw = new byte[2]; - protected byte col; - protected byte[] ixfe = new byte[2]; - - /** - * Get the row number of this cell - * - * @return the row number of this cell - */ - public int getRow() { - return EndianConverter.readShort(rw) + 1; - } - - /** - * Set the row number of this cell - * - * @param row sets the row number for this cell - */ - public void setRow(int row) { - this.rw = EndianConverter.writeShort((short) (row - 1)); - } - /** - * Get the Index to the <code>ExtendedFormat</code> - * - * @return the index number of this cell's <code>ExtendedFormat</code> - */ - public int getIxfe() { - return EndianConverter.readShort(ixfe); - } - - /** - * Sets the Index to the <code>ExtendedFormat</code> - * - * @param ixfe sets the index number for this cell's <code>ExtendedFormat</code> - */ - public void setIxfe(int ixfe) { - this.ixfe = EndianConverter.writeShort((short) (ixfe)); - } - - /** - * Get the column number of this cell - * - * @return the column number of this cell - */ - public int getCol() { - return col + 1; // The cols start at 1 - } - - /** - * Set the column number of this cell - * - * @param col sets the column number for this cell - */ - public void setCol(int col) { - this.col = (byte) (col - 1); // The cols start at 1 - } - - /** - * Writes basic cell value attributes to the specified <code>Outputstream</code> - * - * @param output the <code>OutputStream</code> to write to - */ - public void write(OutputStream output) throws IOException { - - output.write(rw); - output.write(col); - output.write(ixfe); - } - - /** - * Reads a <code>LabelCell</code> from the specified <code>Inputstream</code> - * - * @param input the <code>InputStream</code> to read from - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rw); - col += input.read(); - numOfBytesRead++; - numOfBytesRead += input.read(ixfe); - - Debug.log(Debug.TRACE, "\tRow : "+ EndianConverter.readShort(rw) + - " Column : " + col + - " ixfe : " + EndianConverter.readShort(ixfe)); - - return numOfBytesRead; - } - - /** - * Returns the contents of the cell as a String - * - * @return the contents of the cell - */ - abstract public String getString() throws IOException; - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java deleted file mode 100644 index 4ac59484e545..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/CodePage.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents the codepage for the document. There is a number of unknown - * fields which are hardcoded at construction - */ -public class CodePage implements BIFFRecord { - - private byte[] codepage = new byte[2]; - private byte[] unknown1 = new byte[2]; - private byte[] unknown2 = new byte[2]; - private byte unknown3; - - /** - * Constructs a pocket Excel Codepage - */ - public CodePage() { - codepage = new byte[] {(byte)0xE4, (byte)0x04}; - unknown1 = new byte[] {(byte)0x8C, (byte)0x01}; - unknown2 = new byte[] {(byte)0x00, (byte)0x01}; - unknown3 = 0x00; - } - - /** - * Constructs a pocket Excel Codepage from the<code>InputStream</code> - * - * @param is InputStream containing a Pocket Excel Data file. - */ - public CodePage(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>BoundSheet</code> - */ - public short getBiffType() { - return PocketExcelConstants.CODEPAGE; - } - - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(codepage); - numOfBytesRead += input.read(unknown1); - numOfBytesRead += input.read(unknown2); - unknown3 = (byte) input.read(); - numOfBytesRead++; - - Debug.log(Debug.TRACE,"\tcodepage : "+ EndianConverter.readShort(codepage) + - " unknown1 : " + EndianConverter.readShort(unknown1) + - " unknown2 : " + EndianConverter.readShort(unknown2) + - " unknown3 : " + unknown3); - - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(codepage); - output.write(unknown1); - output.write(unknown2); - output.write(unknown3); - - Debug.log(Debug.TRACE,"Writing CodePage record"); - - - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java deleted file mode 100644 index f687de7e13fc..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ColInfo.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * ColInfo describes the formatting for a column - * - */ -public class ColInfo implements BIFFRecord { - - private byte[] colFirst = new byte[2]; // first column this formatting applies to - private byte[] colLast = new byte[2]; // last column this formatting applies to - private byte[] colDX = new byte[2]; // column width - private byte[] ixfe = new byte[2]; // index for formatting - private byte grbit; // options flags - private float scale = (float) 2.5; // 1.798; - - /** - * Constructs a pocket Excel Document from the - * <code>InputStream</code> and assigns it the document name passed in - * - * @param colFirst the first column this formatting applies to - * @param colLast last column this formatting applies to - * @param colDX column width - * @param ixfe index for formatting - */ - public ColInfo(int colFirst, int colLast, int colDX, int ixfe) { - this.colFirst = EndianConverter.writeShort((short)colFirst); - this.colLast = EndianConverter.writeShort((short)colLast); - colDX *= scale; - this.colDX = EndianConverter.writeShort((short)colDX); - this.ixfe = EndianConverter.writeShort((short)ixfe); - this.grbit = 0x00; - } - - /** - * Construct a ColInfo from the InputStream - * - * @param is the <code>Inputstream</code> to read from - */ - public ColInfo(InputStream is) throws IOException { - read(is); - } - - /** - * Reads ColInfo record from the InputStream - * - * @param input the InputStream to read from - * @return the number of bytes read - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(colFirst); - numOfBytesRead += input.read(colLast); - numOfBytesRead += input.read(colDX); - short scaledDX = (short) (EndianConverter.readShort(colDX) / scale); - colDX = EndianConverter.writeShort(scaledDX); - numOfBytesRead += input.read(ixfe); - grbit = (byte) input.read(); - numOfBytesRead ++; - - Debug.log(Debug.TRACE,"\tcolFirst : "+ EndianConverter.readShort(colFirst) + - " colLast : " + EndianConverter.readShort(colLast) + - " colDX : " + EndianConverter.readShort(colDX) + - " ixfe : " + EndianConverter.readShort(ixfe) + - " grbit : " + grbit); - - return numOfBytesRead; - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>ColInfo</code> - */ - public short getBiffType() { - return PocketExcelConstants.COLINFO; - } - /** - * Get the width of this column - * - * @return the width of this column - */ - public short getColWidth() { - return EndianConverter.readShort(colDX); - } - - /** - * Get the first column that this formatting applies to. - * - * @return The first column. - */ - public short getFirst() { - return EndianConverter.readShort(colFirst); - } - - /** - * Get the last column that this formatting applies to. - * - * @return The last column. - */ - public short getLast() { - return EndianConverter.readShort(colLast); - } - - /** - * Writes a ColInfo to the specified <code>Outputstream</code> - * - * @param output the <code>OutputStream</code> to write to - */ - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(colFirst); - output.write(colLast); - output.write(colDX); - output.write(ixfe); - output.write(grbit); - - Debug.log(Debug.TRACE,"Writing ColInfo record"); - - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java deleted file mode 100644 index 891c39e83632..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefColWidth.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF record defining the default column width - */ -public class DefColWidth implements BIFFRecord { - - private byte[] grbit = new byte[2]; - private byte[] coldx = new byte[2]; - private byte[] ixfe = new byte[2]; - - /** - * Default constructor. Sets width to 9. - */ - public DefColWidth() { - grbit = new byte[] {0x00, 0x00}; - coldx = new byte[] {0x00, 0x09}; - ixfe = new byte[] {0x00, 0x00}; - } - - /** - * Constructs a pocket Excel Document from the - * <code>InputStream</code> and assigns it the document name passed in - * - * @param is InputStream containing a Pocket Excel Data file. - */ - public DefColWidth(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>DefColWidth</code> - */ - public short getBiffType() { - return PocketExcelConstants.DEF_COL_WIDTH; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(grbit); - output.write(coldx); - output.write(ixfe); - - Debug.log(Debug.TRACE, "Writing DefColWidth record"); - } - - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(grbit); - numOfBytesRead += input.read(coldx); - numOfBytesRead += input.read(ixfe); - - Debug.log(Debug.TRACE,"\tgrbit : "+ EndianConverter.readShort(grbit) + - " coldx : " + EndianConverter.readShort(coldx) + - " ixfe : " + EndianConverter.readShort(ixfe)); - return 0; - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java deleted file mode 100644 index 906cbb25a205..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefRowHeight.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF record defiuning the default row height - */ -public class DefRowHeight implements BIFFRecord { - - private byte[] unknown1 = new byte[2]; - private byte[] unknown2 = new byte[2]; - - /** - * Default constructor. Sets something unknown to 255. - */ - public DefRowHeight() { - unknown1 = new byte[] {(byte)0x00, (byte)0x00}; - unknown2 = new byte[] {(byte)0xFF, (byte)0x00}; - } - - /** - * Constructs a DefRowHeight from the <code>InputStream</code> - * - * @param is InputStream containing a Pocket Excel Data file. - */ - public DefRowHeight(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>DefRowHeight</code> - */ - public short getBiffType() { - return PocketExcelConstants.DEFAULT_ROW_HEIGHT; - } - - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(unknown1); - numOfBytesRead += input.read(unknown2); - - Debug.log(Debug.TRACE,"\tunknown1 : "+ EndianConverter.readShort(unknown1) + - " unknown2 : " + EndianConverter.readShort(unknown2)); - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(unknown1); - output.write(unknown2); - - Debug.log(Debug.TRACE,"Writing DefRowHeight record"); - - - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java deleted file mode 100644 index 5378ae2e5ec0..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula.FormulaHelper; -import org.openoffice.xmerge.converter.xml.sxc.NameDefinition; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record representing a defined name in the workbook - */ -public class DefinedName implements BIFFRecord { - - private byte[] grbit = new byte[2]; - private byte cch; - private byte[] cce = new byte[2]; - private byte[] ixals = new byte[2]; - private byte[] rgch; - private byte[] rgce; - private FormulaHelper fh = new FormulaHelper(); - private String definition = new String(""); - private Workbook wb; - - /** - * Constructs a Defined Name from an existing <code>NameDefinition</code> - * - * @param nd The name definition. - * @param wb The workbook we are defined in. - */ - public DefinedName(NameDefinition nd, Workbook wb) throws IOException { - - fh.setWorkbook(wb); - this.wb = wb; - String name = nd.getName(); - - // we have to insert an = to stop the formulaParser throwing an exception - definition = "=" + nd.getDefinition(); - - cch = (byte)name.length(); - rgch = new byte[cch*2]; - rgch = name.getBytes("UTF-16LE"); - grbit = EndianConverter.writeShort((short)0); - ixals[0] = (byte)0xFF;ixals[1] = (byte)0xFF; - } - - /** - * Constructs a Defined Name from the <code>InputStream</code> - * - * @param is InputStream containing the record data - * @param wb The workbook we are defined in. - */ - public DefinedName(InputStream is, Workbook wb) throws IOException { - - read(is); - fh.setWorkbook(wb); - this.wb = wb; - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>DefinedName</code> - */ - public short getBiffType() { - return PocketExcelConstants.DEFINED_NAME; - } - - /** - * Reads a Defined Name from the <code>InputStream</code> The byte array - * must be twice the size of the String as it uses unicode. - * - * @param input InputStream containing the record data - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(grbit); - cch = (byte) input.read(); - numOfBytesRead++; - numOfBytesRead += input.read(cce); - numOfBytesRead += input.read(ixals); - - rgch = new byte[cch*2]; - input.read(rgch, 0, cch*2); - - rgce = new byte[EndianConverter.readShort(cce)]; - input.read(rgce, 0, EndianConverter.readShort(cce)); - - Debug.log(Debug.TRACE, "\tgrbit : "+ EndianConverter.readShort(grbit) + - " cch : " + cch + - " cce : " + EndianConverter.readShort(cce) + - " ixals : " + EndianConverter.readShort(ixals) + - "\n\trgch : " + rgch + - " rgce : " + rgce); - - return numOfBytesRead; - } - - /** - * Write this particular <code>BIFFRecord</code> to the <code>OutputStream</code> - * - * @param output the <code>OutputStream</code> - */ - public void write(OutputStream output) throws IOException { - - try { - Debug.log(Debug.TRACE,"Writing out " + definition); - rgce = fh.convertCalcToPXL(definition); - cce = EndianConverter.writeShort((short) rgce.length); - } catch(Exception e) { - Debug.log(Debug.TRACE,"Error in Parsing Name Definition"); - cce = EndianConverter.writeShort((short) 0); - } - - output.write(getBiffType()); - output.write(grbit); - output.write(cch); - output.write(cce); - output.write(ixals); - output.write(rgch); - if(rgce.length!=0) - output.write(rgce); - - Debug.log(Debug.TRACE,"Writing DefinedName record"); - } - - /** - * Returns definition name. This is public because the - * <code>TokenDecoder</code> has to substitue the Name token with this - * String when writing out to sxc - * - * @return the <code>String</code> containing the name - */ - public String getName() { - String name; - - try { - name = new String(rgch, "UTF-16LE"); - } catch (UnsupportedEncodingException e){ - name = "unknown"; - } - return name; - } - - /** - * Returns a definition table which can be used by the pocket excel - * decoder to build a complete definitions table for writing to the sxc - * document - */ - public NameDefinition getNameDefinition() { - - String baseCellAddress; - getDefinition(); // This must be called first so we know the type - - baseCellAddress = "$" + wb.getSheetName(0) + ".A1"; - - NameDefinition nd = new NameDefinition(getName(),definition, baseCellAddress, isRangeType(), isExpressionType()); - return nd; - } - - /** - * Returns the definition - * - * @return the <code>String</code> containing the definition - */ - private String getDefinition() { - // pexcel sometimes creates Name definition with no defintion, bug?? - if(EndianConverter.readShort(cce)!=0) { - definition = fh.convertPXLToCalc(rgce); - definition = definition.substring(1); // remove the '=' - definition = definition.replace(',', ';'); - } - return definition; - } - - /** - * Returns the defintion - * - * @return the <code>String</code> containing the definition - */ - private boolean isRangeType() { - - return fh.isRangeType(); - } - /** - * Returns the defintion - * - * @return the <code>String</code> containing the definition - */ - private boolean isExpressionType() { - - return fh.isExpressionType(); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java deleted file mode 100644 index 101056678306..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Eof.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record used to mark the end of a section of file - */ -public class Eof implements BIFFRecord { - - /** - * Constructor - */ - public Eof() { - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>BeginningOfFile</code> - */ - public short getBiffType() { - return PocketExcelConstants.EOF_MARKER; - } - - public int read(InputStream input) throws IOException { - return 0; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - - Debug.log(Debug.TRACE,"Writing Eof record"); - - - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java deleted file mode 100644 index 5fbdb6d3edcc..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/ExtendedFormat.java +++ /dev/null @@ -1,375 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.awt.Color; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.util.ColourConverter; -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record descibing extended formatting information - * - */ -public class ExtendedFormat implements BIFFRecord, -org.openoffice.xmerge.converter.xml.OfficeConstants { - - private byte[] ixfnt = new byte[2]; // Index to Font Record - private byte[] ixnf = new byte[2]; - private byte[] fattributes = new byte[4]; - private byte[] fBaseAttr = new byte[2]; // base attribute flags - private byte[] fTextAttr = new byte[2]; // text attribute flags - private byte[] icvFore = new byte[2]; // Background colour of the cell - private byte[] icvFill = new byte[2]; - private byte bRight; // Right border Style - private byte bTop; // Top border style - private byte bLeft; // Left border style - private byte bBottom; // Bottom border style - private byte backstyle; - private byte borderstyle; - - public static final int TOP_BORDER = 0x01; - public static final int LEFT_BORDER = 0x02; - public static final int BOTTOM_BORDER = 0x04; - public static final int RIGHT_BORDER = 0x08; - - // Horizontal Alignment Styles - public static final int NORMAL_ALIGN = 0x00; - public static final int LEFT_ALIGN = 0x01; - public static final int CENTER_ALIGN = 0x02; - public static final int RIGHT_ALIGN = 0x03; - - // Vertical Alignment Styles - public static final int TOP_ALIGN = 0x10; - public static final int MIDDLE_ALIGN = 0x20; - public static final int BOTTOM_ALIGN = 0x30; - - public static final int WORD_WRAP = 0x08; - - /** - * Constructs an <code>ExtendedFormat</code> from the - * <code>InputStream</code> - * - * @param is <code>InputStream</code> to read from - */ - public ExtendedFormat(InputStream is) throws IOException { - read(is); - } - - /** - * Constructs a pocket Excel Document using default values and sets the - * font index using the specified attribute - * - * @param ixfnt index of the font this format should use - */ - public ExtendedFormat(int ixfnt, Format fmt) { - - this.ixfnt = EndianConverter.writeShort((short)ixfnt); - String category = fmt.getCategory(); - if(category.equalsIgnoreCase(CELLTYPE_CURRENCY)) { - this.ixnf = EndianConverter.writeShort((short) 0); - } else if(category.equalsIgnoreCase(CELLTYPE_DATE)) { - this.ixnf = EndianConverter.writeShort((short) 0x12); - } else if(category.equalsIgnoreCase(CELLTYPE_TIME)) { - this.ixnf = EndianConverter.writeShort((short) 0x1E); - } else { - this.ixnf = EndianConverter.writeShort((short) 0); - } - this.fattributes = new byte[] {(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF}; - this.fBaseAttr = new byte[] {(byte)0x02,(byte)0x00}; - - this.fTextAttr = new byte[] {(byte)0x00, (byte)0x00}; - - int align = fmt.getAlign(); - - // Horizontal alignment - if(align==Format.CENTER_ALIGN) { - fTextAttr[0] |= CENTER_ALIGN; - } else if(align==Format.LEFT_ALIGN) { - fTextAttr[0] |= LEFT_ALIGN; - } else if(align==Format.RIGHT_ALIGN) { - fTextAttr[0] |= RIGHT_ALIGN; - } else { - fTextAttr[0] |= NORMAL_ALIGN; - } - - int vertAlign = fmt.getVertAlign(); - - // Vertical alignment - if(vertAlign==Format.TOP_ALIGN) { - fTextAttr[0] |= TOP_ALIGN; - } else if(vertAlign==Format.BOTTOM_ALIGN) { - fTextAttr[0] |= BOTTOM_ALIGN; - } else if(vertAlign==Format.MIDDLE_ALIGN) { - fTextAttr[0] |= MIDDLE_ALIGN; - } else { - fTextAttr[0] |= BOTTOM_ALIGN; - } - - if(fmt.getAttribute(Format.WORD_WRAP)) { - fTextAttr[0] |= WORD_WRAP; - } - - if(fmt.getAttribute(Format.LEFT_BORDER)) { - fTextAttr[1] |= LEFT_BORDER; - } - if(fmt.getAttribute(Format.RIGHT_BORDER)) { - fTextAttr[1] |= RIGHT_BORDER; - } - if(fmt.getAttribute(Format.TOP_BORDER)) { - fTextAttr[1] |= TOP_BORDER; - } - if(fmt.getAttribute(Format.BOTTOM_BORDER)) { - fTextAttr[1] |= BOTTOM_BORDER; - } - - Color background = fmt.getBackground(); - if( background != null ) { - ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); - icvFill = EndianConverter.writeShort(cc.convertFromRGB(background)); - } else { - icvFill = new byte[] {(byte)0xFF,(byte)0x00}; - } - - icvFore = new byte[] {(byte)0xFF,(byte)0x00}; - - bRight = (byte) 0xFF; - bTop = (byte) 0xFF; - bLeft = (byte) 0xFF; - bBottom = (byte) 0xFF; - backstyle = (byte) 0x00; - borderstyle = (byte) 0x00; - - } - - /** - * Get the font index this format uses - * - * @return the font index - */ - public int getFontIndex() { - return EndianConverter.readShort(ixfnt); - } - - /** - * Get the font index this format uses - * - * @return the font index - */ - public int getFormatIndex() { - return EndianConverter.readShort(ixnf); - } - - /** - * Get the font index this format uses - * - * @return the font index - */ - public int getTextAttr() { - return EndianConverter.readShort(fTextAttr); - } - - /** - * Get the background color this format uses - * - * @return the background color - */ - public Color getBackground() { - short rgb = EndianConverter.readShort(icvFill); - Color c = null; - if(rgb!=0xFF) { - ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); - c = cc.convertToRGB(rgb); - } - return c; - } - - /** - * Get the Vertical alignment for this Format - * - * @return the alignment - */ - public int getVertAlign() { - - int mask = MIDDLE_ALIGN | BOTTOM_ALIGN | TOP_ALIGN; - int masked = fTextAttr[0] & mask; - - if(masked == MIDDLE_ALIGN) - return Format.MIDDLE_ALIGN; - - if(masked == BOTTOM_ALIGN) - return Format.BOTTOM_ALIGN; - - if(masked == TOP_ALIGN) - return Format.TOP_ALIGN; - - return Format.BOTTOM_ALIGN; - } - - /** - * Get the alignment for this Format - * - * @return the alignment - */ - public int getAlign() { - - int mask = LEFT_ALIGN | CENTER_ALIGN | RIGHT_ALIGN; - int masked = fTextAttr[0] & mask; - - if(masked == MIDDLE_ALIGN) - return Format.LEFT_ALIGN; - - if(masked == CENTER_ALIGN) - return Format.CENTER_ALIGN; - - if(masked == RIGHT_ALIGN) - return Format.RIGHT_ALIGN; - - return Format.LEFT_ALIGN; - } - - /** - * Is the word wrap set - * - * @return true if it is selected - */ - public boolean isWordWrap() { - return (!((fTextAttr[0] & WORD_WRAP) == 0)); - } - /** - * Get the border style - * - * @param side the side to test - * @return true if it is selected - */ - public boolean isBorder(int side) { - return (!((fTextAttr[1] & side) == 0)); - } - - /** - * Compare two ExtendedFormat to see if the font index is the same - * - * @param rhs The ExtendedFormat to be used in the comaprison - * @return True if the two are the same otherwise false - */ - public boolean compareTo(ExtendedFormat rhs) { - - if(EndianConverter.readShort(icvFill) != - EndianConverter.readShort(rhs.icvFill)) - return false; - - if(this.getTextAttr() != rhs.getTextAttr()) - return false; - - if(this.getVertAlign() != rhs.getVertAlign()) - return false; - - if(this.getAlign() != rhs.getAlign()) - return false; - - if (this.getFontIndex() != rhs.getFontIndex()) - return false; - - if (this.getFormatIndex() != rhs.getFormatIndex()) - return false; - - return true; - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>ExtendedFormat</code> - */ - public short getBiffType() { - return PocketExcelConstants.EXTENDED_FORMAT; - } - - /** - * Reads the extended format from the <code>Inputstream</code> - * - * @param input the <code>Inputstream</code>to read - * @return toal number of bytes read - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(ixfnt); - numOfBytesRead += input.read(ixnf); - numOfBytesRead += input.read(fattributes); - numOfBytesRead += input.read(fBaseAttr); - numOfBytesRead += input.read(fTextAttr); - numOfBytesRead += input.read(icvFore); - numOfBytesRead += input.read(icvFill); - bRight = (byte) input.read(); - bTop = (byte) input.read(); - bLeft = (byte) input.read(); - bBottom = (byte) input.read(); - backstyle = (byte) input.read(); - borderstyle = (byte) input.read(); - numOfBytesRead += 6; - - Debug.log(Debug.TRACE,"\tixfnt : "+ EndianConverter.readShort(ixfnt) + - " ixnf : " + EndianConverter.readShort(ixnf) + - " fattributes : " + EndianConverter.readInt(fattributes) + - " fBaseAttr : " + EndianConverter.readShort(fBaseAttr) + - "\n\tfTextAttr : " + EndianConverter.readShort(fTextAttr) + - " icvFore : " + EndianConverter.readShort(icvFore) + - " icvFill : " + EndianConverter.readShort(icvFill) + - " bRight : " + bRight + - "\n\tbTop : " + bTop + - " bLeft : " + bLeft + - " bBottom : " + bBottom + - " backstyle : " + backstyle + - " borderstyle : " + borderstyle); - return numOfBytesRead; - } - - /** - * Writes the ExtendedFormat to the <code>Outputstream<code> - * - * @param output the <code>Outputstream</code>to write to - */ - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(ixfnt); - output.write(ixnf); - output.write(fattributes); - output.write(fBaseAttr); - output.write(fTextAttr); - output.write(icvFore); - output.write(icvFill); - output.write(bRight); - output.write(bTop); - output.write(bLeft); - output.write(bBottom); - output.write(backstyle); - output.write(borderstyle); - - Debug.log(Debug.TRACE,"Writing ExtendedFormat record"); - - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java deleted file mode 100644 index 89663e0bdeb0..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FloatNumber.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record describing a floating point - */ -public class FloatNumber extends CellValue { - - protected byte[] num = new byte[8]; - - /** - * Constructs a FloatNumber by reading from an InputStream. - * - * @param is InputStream containing a Pocket Excel Data file. - */ - public FloatNumber(InputStream is) throws IOException { - read(is); - } - - /** - * Constructs a <code>FloatNumber</code> using specified attributes - * - * @param row row number - * @param column column number - * @param cellContents contents of the cell - * @param ixfe font index - */ - public FloatNumber(int row, int column, String cellContents, int ixfe) throws IOException { - - setIxfe(ixfe); - setRow(row); - setCol(column); - double cellLong = Double.parseDouble(cellContents); - num = EndianConverter.writeDouble(cellLong); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>FloatNumber</code> - */ - public short getBiffType() { - return PocketExcelConstants.NUMBER_CELL; - } - - /** - * Reads a<code>FloatNumber</code> from the specified <code>InputStream</code> - * - * @param input the <code>InputStram</code> to read from - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = super.read(input); - - numOfBytesRead += input.read(num); - - Debug.log(Debug.TRACE," num : " + getString()); - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - - super.write(output); - - output.write(num); - - Debug.log(Debug.TRACE,"Writing FloatNumber record"); - } - - /** - * Gets the numerical value the cell represents - * - * @return the <code>String</code> representing a double value - */ - public String getString() throws IOException { - - double value = EndianConverter.readDouble(num); - Double myDo = new Double(value); - return myDo.toString(); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java deleted file mode 100644 index 4e7ff4464fed..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/FontDescription.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.awt.Color; - -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.util.ColourConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record descibing a font used - */ -public class FontDescription implements BIFFRecord { - - private byte[] dwHeight = new byte[2]; - private byte[] grbit = new byte[2]; - private byte[] icvFore = new byte[2]; - private byte[] bls = new byte[2]; - private byte[] Reserved2 = new byte[2]; - private byte uls; - private byte bFamily; - private byte bCharSet; - private byte Reserved3; - private byte cch; - private byte[] rgch; - - public static final int UNDERLINE = 0x01; - public static final int ITALIC = 0x02; - - /** - * Constructs a FontDescription from a Format. - * - * @param fmt The <code>Format</code> to use as source. - */ - public FontDescription(Format fmt) throws IOException { - - Debug.log(Debug.TRACE,"Building FontDescriptor based on Format : " + fmt); - - this.dwHeight = EndianConverter.writeShort((short) (fmt.getFontSize()*20)); - - grbit = new byte[] {(byte)0x00, (byte)0x00}; - bls = EndianConverter.writeShort((short) 400); - uls = 0; - - if (fmt.getAttribute(Format.ITALIC)) - grbit[0] |= ITALIC; - - if (fmt.getAttribute(Format.BOLD)) - bls = EndianConverter.writeShort((short) 700); - - if (fmt.getAttribute(Format.UNDERLINE)) - uls |= UNDERLINE; - - bFamily = 0; - bCharSet = 0; - - String fontName = fmt.getFontName(); - if( !fontName.equals("Tahoma") && - !fontName.equals("Courier New")) { - // We will set our default font to be Tahoma - fontName = new String("Tahoma"); - } - - cch = (byte) fontName.length(); - rgch = fontName.getBytes("UTF-16LE"); - - Color foreground = fmt.getForeground(); - if( foreground != null ) { - ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); - icvFore = EndianConverter.writeShort(cc.convertFromRGB(foreground)); - } else { - icvFore = new byte[] {(byte)0xFF,(byte)0x00}; - } - - Reserved2 = EndianConverter.writeShort((short) 0); - Reserved3 = 0; - - } - - /** - * Tests if this font descriptor defines italic - * - * @return true if italic otherwise false - */ - public boolean isItalic() { - - return (EndianConverter.readShort(grbit) == 2); - } - - /** - * Tests if this font descriptor defines underline - * - * @return true if underline otherwise false - */ - public boolean isUnderline() { - - return (uls == 1); - } - - /** - * Tests if this font descriptor defines bold - * - * @return true if bold otherwise false - */ - public boolean isBold() { - - return (EndianConverter.readShort(bls) == 700); - } - - /** - * Get the background color this format uses - * - * @return the background color - */ - public Color getForeground() { - short rgb = EndianConverter.readShort(icvFore); - Color c = null; - if(rgb!=0xFF) { - ColourConverter cc = new ColourConverter(PocketExcelConstants.cLookup); - c = cc.convertToRGB(rgb); - } - return c; - } - - /** - * Compares current font descriptor against one passed in - * - * @return true if attrbitues are the same - */ - public boolean compareTo(FontDescription rhs) { - - if(EndianConverter.readShort(icvFore) != - EndianConverter.readShort(rhs.icvFore)) - return false; - - if (EndianConverter.readShort(dwHeight) != - EndianConverter.readShort(dwHeight)) - return false; - - if (this.getFont() != rhs.getFont()) - return false; - - if (this.isBold() != rhs.isBold()) - return false; - - if (this.isUnderline() != rhs.isUnderline()) - return false; - - if (this.isItalic() != rhs.isItalic()) - return false; - - return true; - } - - /** - * Constructs a Font Description from the <code>InputStream</code> - * - * @param is InputStream containing a <code>FontDescription</code> - */ - public FontDescription(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>FontDescription</code> - */ - public short getBiffType() { - return PocketExcelConstants.FONT_DESCRIPTION; - } - - /** - * Get the Font size - * - */ - public int getFontSize() { - return EndianConverter.readShort(dwHeight)/20; - } - - /** - * Get the font name - * - */ - public String getFont() { - - String name; - - try { - name = new String(rgch, "UTF-16LE"); - } catch (UnsupportedEncodingException e){ - name = "Tahoma"; - } - return name; - } - - /** - * Constructs a Font Description from the <code>InputStream</code> - * - * @param input InputStream containing a <code>FontDescription</code> - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(dwHeight); - numOfBytesRead += input.read(grbit); - numOfBytesRead += input.read(icvFore); - numOfBytesRead += input.read(bls); - numOfBytesRead += input.read(Reserved2); - uls = (byte) input.read(); - bFamily = (byte) input.read(); - bCharSet = (byte) input.read(); - Reserved3 = (byte) input.read(); - cch = (byte) input.read(); - numOfBytesRead += 5; - - rgch = new byte[cch*2]; - input.read(rgch, 0, cch*2); - - Debug.log(Debug.TRACE,"\tdwHeight : "+ EndianConverter.readShort(dwHeight) + - " grbit : " + EndianConverter.readShort(grbit) + - " bls : " + EndianConverter.readShort(bls) + - " uls : " + uls + - "\n\tFamily : " + bFamily + - " bCharSet : " + bCharSet + - " cch : " + cch + - " rgch : " + new String(rgch,"UTF-16LE")); - - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(dwHeight); - output.write(grbit); - output.write(icvFore); - output.write(bls); - output.write(Reserved2); - output.write(uls); - output.write(bFamily); - output.write(bCharSet); - output.write(Reserved3); - output.write(cch); - output.write(rgch); - - Debug.log(Debug.TRACE,"Writing FontDescription record"); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java deleted file mode 100644 index 18fb06030b9c..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Formula.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula.FormulaHelper; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record describing a formula - */ -public class Formula extends CellValue implements OfficeConstants { - - private byte[] num = new byte[8]; - private byte grbit; - private byte[] cce = new byte[2]; - private byte[] rgce; - private FormulaHelper fh = new FormulaHelper(); - - /** - * Constructs a <code>Formula</code> using specified attributes - * - * @param row row number - * @param column column number - * @param cellContents contents of the cell - * @param ixfe font index - * @param fmt cell format description. - * @param wb the workbook we are defined in. - */ - public Formula(int row, int column, String cellContents, int ixfe, Format fmt, Workbook wb) - throws Exception { - - fh.setWorkbook(wb); - - setRow(row); - setCol(column); - setIxfe(ixfe); - setFormula(cellContents); - - String category = fmt.getCategory(); - String value = fmt.getValue(); - - if(category.equalsIgnoreCase(CELLTYPE_BOOLEAN)) { - num[0]=(byte)0x01; - num[1]=(byte)0x00; - if(value.equalsIgnoreCase("true")) { - num[2]=(byte)0x01; - } else { - num[2]=(byte)0x00; - } - num[3]=(byte)0x00;num[4]=(byte)0x00;num[5]=(byte)0x00; - num[6]=(byte)0xFF;num[7]=(byte)0xFF; - } else if(category.equalsIgnoreCase(CELLTYPE_DATE)) { - Debug.log(Debug.TRACE,"Date Formula"); - num = EndianConverter.writeDouble(toExcelSerialDate(fmt.getValue())); - } else if(category.equalsIgnoreCase(CELLTYPE_TIME)) { - Debug.log(Debug.TRACE,"Time Formula"); - num = EndianConverter.writeDouble(toExcelSerialTime(fmt.getValue())); - } else if(category.equalsIgnoreCase(CELLTYPE_PERCENT)) { - Debug.log(Debug.TRACE,"Percent Formula"); - double percent = Double.parseDouble(fmt.getValue()); - num = EndianConverter.writeDouble(percent); - } else if(category.equalsIgnoreCase(CELLTYPE_CURRENCY)) { - Debug.log(Debug.TRACE,"Currency Formula"); - } else if(category.equalsIgnoreCase(CELLTYPE_STRING)) { - Debug.log(Debug.TRACE,"String Formula"); - num[0]=(byte)0x00; - num[1]=(byte)0x00; - num[2]=(byte)0x00; - num[3]=(byte)0x00; - num[4]=(byte)0x00; - num[5]=(byte)0x00; - num[6]=(byte)0xFF; - num[7]=(byte)0xFF; - } else { - Debug.log(Debug.TRACE,"Float Formula"); - double cellLong = Double.parseDouble(fmt.getValue()); - num = EndianConverter.writeDouble(cellLong); - } - } - - /** - * Translates a <code>String</code> written in infix which represents a - * formula into a byte[] what can be written to pocket excel file. - * - * @param inFormula formula string - */ - public void setFormula(String inFormula) throws Exception { - - rgce = fh.convertCalcToPXL(inFormula); - cce = EndianConverter.writeShort((short) rgce.length); - } - - /** - * Constructs a pocket Excel formula from the - * <code>InputStream</code> - * - * @param is InputStream containing a Pocket Excel Data file. - * @param wb The workbook we are defined in. - */ - public Formula(InputStream is, Workbook wb) throws IOException { - read(is); - fh.setWorkbook(wb); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>Formula</code> - */ - public short getBiffType() { - return PocketExcelConstants.FORMULA_CELL; - } - - /** - * Reads the formula data members from the stream. Byte arrays for Strings - * are doubled as they are stored as unicode - * - * @param input the input stream to read from. - * @return total number of bytes read - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = super.read(input); - - numOfBytesRead += input.read(num); - grbit = (byte) input.read(); - numOfBytesRead ++; - numOfBytesRead += input.read(cce); - - int strLen = EndianConverter.readShort(cce); - rgce = new byte[strLen]; - input.read(rgce, 0, strLen); - - Debug.log(Debug.TRACE, " num : " + num + - "\n\tgrbit : " + grbit + - " cce : " + EndianConverter.readShort(cce) + - " rgce : " + new String(rgce,"UTF-16LE") + - "\n" + numOfBytesRead + " Bytes Read"); - - return numOfBytesRead; - } - - /** - * Writes the Formula record to the <code>OutputStream</code> - * - * @param output The <code>OutputStream</code> being written to - */ - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - - super.write(output); - - output.write(num); - output.write(grbit); - output.write(cce); - output.write(rgce); - - Debug.log(Debug.TRACE,"Writing Formula record"); - } - - /** - * Gets the <code>String</code> representing the cell value - * - * @return the <code>String</code> representing the cell value - */ - public String getValue() throws IOException { - - double value = EndianConverter.readDouble(num); - Double myDo = new Double(value); - return myDo.toString(); - } - - /** - * Gets the <code>String</code> representing the cells contents - * - * @return the <code>String</code> representing the cells contents - */ - public String getString() throws IOException { - - return fh.convertPXLToCalc(rgce); - } - - /** - * Excel dates are the number of days since 1/1/1900. This method converts - * to this date. - * - * @param s String representing a date in the form YYYY-MM-DD - * @return The excel serial date - */ - public long toExcelSerialDate(String s) throws IOException { - - int year = Integer.parseInt(s.substring(0,4)); - int month = Integer.parseInt(s.substring(5,7)); - int day = Integer.parseInt(s.substring(8,10)); - - long serialDate = (1461 * (year + 4800 + (month - 14) / 12)) / 4 + - (367 * (month - 2 - 12 * ((month - 14) / 12))) / 12 - - (3 * ((year + 4900 + (month - 14) / 12)) / 100) / 4 + - day - 2415019 - 32075; - - return serialDate; - } - - /** - * Excel times are a fraction of a 24 hour day expressed in seconds. This method converts - * to this time. - * - * @param s String representing a time in the form ??HH?MM?SS? - * @return The excel serial time - */ - public double toExcelSerialTime(String s) throws IOException { - - int hours = Integer.parseInt(s.substring(2,4)); - int mins = Integer.parseInt(s.substring(5,7)); - int secs = Integer.parseInt(s.substring(8,10)); - - int timeSecs = (hours*3600) + (mins*60) + (secs); - - double d = (double) timeSecs / (24 * 3600); - - return d; - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java deleted file mode 100644 index 7c88383e9c48..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/LabelCell.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Reperesent a BIFF Record descibing a cell containing a string - */ -public class LabelCell extends CellValue { - - private byte[] cch = new byte[2]; - private byte[] rgch; - - /** - * Constructs a <code>LabelCell</code> using specified attributes - * - * @param row row number - * @param column column number - * @param cellContents contents of the cell - * @param ixfe font index - */ - public LabelCell(int row, int column, String cellContents, int ixfe) - throws IOException { - - setLabel(cellContents); - setRow(row); - setCol(column); - setIxfe(ixfe); - } - - /** - * Reads a LabelCell from the <code>InputStream</code> - * - * @param is the <code>Inputstream</code> to read from - */ - public LabelCell(InputStream is) throws IOException { - read(is); - } - - /** - * Writes a <code>LabelCell</code> to the specified <code>Outputstream</code> - * - * @param output The <code>OutputStream</code> to write to - */ - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - - super.write(output); - - output.write(cch); - output.write(rgch); - - Debug.log(Debug.TRACE,"Writing Label record"); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>LabelCell</code> - */ - public short getBiffType() { - return PocketExcelConstants.LABEL_CELL; - } - - /** - * Reads a<code>LabelCell</code> from the specified <code>InputStream</code> - * - * @param input the <code>InputStram</code> to read from - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = super.read(input); - - numOfBytesRead += input.read(cch); - - int strLen = EndianConverter.readShort(cch)*2; - rgch = new byte[strLen]; - input.read(rgch, 0, strLen); - - Debug.log(Debug.TRACE, " cch : " + EndianConverter.readShort(cch) + - " rgch : " + new String(rgch, "UTF-16LE")); - - return numOfBytesRead; - } - - /** - * Gets the <code>String</code> representing the cells contents - * - * @return the <code>String</code> representing the cells contents - */ - public String getString() throws IOException { - return (new String(rgch,"UTF-16LE")); - } - - /** - * Sets the <code>String</code> representing the cells contents - */ - private void setLabel(String cellContents) throws IOException { - rgch = cellContents.getBytes("UTF-16LE"); - cch = EndianConverter.writeShort((short)cellContents.length()); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java deleted file mode 100644 index 9e5cb81b3e56..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/NumberFormat.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - - -/** - * Represents a BIFF Record describing a number format - */ -public class NumberFormat implements BIFFRecord { - - private byte cce; - private byte[] rgch; - - /** - * Constructs a NumberFormat Record from the <code>InputStream</code> - * - * @param is InputStream containing the record data - */ - public NumberFormat(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>NumberFormat</code> - */ - public short getBiffType() { - return PocketExcelConstants.NUMBER_FORMAT; - } - - /** - * Reads the NumberFormat from the <code>InputStream</code> Byte array - * containg strings are doubled in length becuse they use unicode - * - * @return the total number of bytes read - */ - public int read(InputStream input) throws IOException { - - cce = (byte) input.read(); - int numOfBytesRead = 1; - - rgch = new byte[cce*2]; - numOfBytesRead += input.read(rgch, 0, cce*2); - - Debug.log(Debug.TRACE, "\tcce : "+ cce + - " rgch : " + new String(rgch,"UTF-16LE")); - - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(cce); - output.write(rgch); - - Debug.log(Debug.TRACE,"Writing NumberFormat record"); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java deleted file mode 100644 index 8d445442877c..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Pane.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.awt.Point; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; -import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; - -/** - * Represents a BIFF Record that describes the number and position of unfrozen - * panes. - */ -public class Pane implements BIFFRecord { - - private byte[] x = new byte[2]; - private byte[] y = new byte[2]; - private byte[] rwTop = new byte[2]; - private byte[] colLeft = new byte[2]; - private byte pnnAcct; - - /** - * Default Constructor - */ - public Pane() { - pnnAcct = (byte) 0x02; // Default setting - } - - /** - * Constructs a Pane Record from the <code>InputStream</code> - * - * @param is InputStream containing a Pane record - */ - public Pane(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>Pane</code> - */ - public short getBiffType() { - return PocketExcelConstants.PANE_INFO; - } - - /** - * Gets the split point for this pane, in the case of splits this will be - * in twips. - * - * @return the split point - */ - public Point getSplitPoint() { - - int xTwips = EndianConverter.readShort(x)/11; - int yTwips = EndianConverter.readShort(y)/15; - return (new Point(xTwips, yTwips)); - } - - /** - * Gets the freeze point for this pane, in the case of freezes this will - * be a zero-based index to either the column or row. - * - * @return the freeze point - */ - public Point getFreezePoint() { - - return (new Point(EndianConverter.readShort(x), - EndianConverter.readShort(y))); - } - - /** - * Sets the split point for this pane, coordinates are in column row units - * if the split type is freeze or twips if split type is split. - * - * @param splitType contains the X and Y split types (freeze or split) - * @param p the split point - */ - public void setSplitPoint(Point splitType, Point p) { - - if(splitType.getX()==SheetSettings.SPLIT - || splitType.getY()==SheetSettings.SPLIT) { - int yTwips = (int) p.getY(); - short yPxl = (short) (yTwips * 15); - y = EndianConverter.writeShort(yPxl); - int xTwips = (int) p.getX(); - short xPxl = (short) (xTwips * 11); - x = EndianConverter.writeShort(xPxl); - } else { - y = EndianConverter.writeShort((short) p.getY()); - x = EndianConverter.writeShort((short) p.getX()); - } - - } - - /** - * Set the pane number - * 0 - bottom right, 1 - top right - * 2 - bottom left, 3 - top left - * - * @param paneNumber the pane number - */ - public void setPaneNumber(int paneNumber) { - pnnAcct = (byte) paneNumber; - } - - /** - * Get the pane number of the active pane - * 0 - bottom right, 1 - top right - * 2 - bottom left, 3 - top left - * - * @return the hex code for <code>Pane</code> - */ - public int getPaneNumber() { - return pnnAcct; - } - - /** - * Set the top row visible in the lower pane - * - * @param top 0-based inex of the top row - */ - public void setTop(int top) { - rwTop = EndianConverter.writeShort((short)top); - } - - /** - * Set leftmost column visible in the right pane - * - * @param left 0-based index of the leftmost column - */ - public void setLeft(int left) { - colLeft = EndianConverter.writeShort((short)left); - } - - /** - * Get the top row visible in the lower pane - * - * @return the hex code for <code>Pane</code> - */ - public int getTop() { - return EndianConverter.readShort(rwTop); - } - - /** - * Get leftmost column visible in the right pane - * - * @return 0-based index of the column - */ - public int getLeft() { - return EndianConverter.readShort(colLeft); - } - - - /** - * Reads a <code>Pane</code> record from the <code>InputStream</code> - * - * @param input <code>InputStream</code> to read from - * @return the total number of bytes read - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(x); - numOfBytesRead += input.read(y); - numOfBytesRead += input.read(rwTop); - numOfBytesRead += input.read(colLeft); - pnnAcct = (byte) input.read(); - numOfBytesRead++; - - Debug.log(Debug.TRACE, "\tx : "+ EndianConverter.readShort(x) + - " y : " + EndianConverter.readShort(y) + - " rwTop : " + EndianConverter.readShort(rwTop) + - " colLeft : " + EndianConverter.readShort(colLeft) + - " pnnAcct : " + pnnAcct); - - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(x); - output.write(y); - output.write(rwTop); - output.write(colLeft); - output.write(pnnAcct); - - Debug.log(Debug.TRACE,"Writing Pane record"); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java deleted file mode 100644 index 194272bbccb8..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Row.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents s BIFF Record that describes the format of a column - */ -public class Row implements BIFFRecord { - - private byte[] rw = new byte[2]; - private byte[] miyRw = new byte[2]; - private byte[] grbit = new byte[2]; - private byte[] ixfe = new byte[2]; - private float scale = 1; - - /** - * Constructs a pocket Excel Document from the - * <code>InputStream</code> and assigns it the document name passed in - * - * @param rw Zero based row number - * @param miyRw row height - */ - public Row(int rw, int miyRw, boolean userDefined) { - this.rw = EndianConverter.writeShort((short) rw); - miyRw *= scale; - this.miyRw = EndianConverter.writeShort((short) miyRw); - if(userDefined) { - grbit = EndianConverter.writeShort((short) 2); - } else { - grbit = EndianConverter.writeShort((short) 0); - } - ixfe = EndianConverter.writeShort((short) 0); - } - - /** - * Constructs a Row fro man <code>InputStream</code> - * - * @param is InputStream containing a Pane Record - */ - public Row(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>Row</code> - */ - public short getBiffType() { - return PocketExcelConstants.ROW_DESCRIPTION; - } - - /** - * Get the height of this row - * - * @return the height of this row - */ - public short getRowHeight() { - return EndianConverter.readShort(miyRw); - } - - /** - * Get the row number - * - * @return the row this style applies to - */ - public short getRowNumber() { - return EndianConverter.readShort(rw); - } - - /** - * Reads a Row from an <code>InputStream</code> - * - * @param input InputStream containing a Row Record - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rw); - numOfBytesRead += input.read(miyRw); - short scaledHeight = (short) (EndianConverter.readShort(miyRw) / scale); - miyRw = EndianConverter.writeShort(scaledHeight); - numOfBytesRead += input.read(grbit); - numOfBytesRead += input.read(ixfe); - - Debug.log(Debug.TRACE,"\trw : "+ EndianConverter.readShort(rw) + - " miyRw : " + EndianConverter.readShort(miyRw) + - " grbit : " + EndianConverter.readShort(grbit) + - " ixfe : " + EndianConverter.readShort(ixfe)); - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(rw); - output.write(miyRw); - output.write(grbit); - output.write(ixfe); - - Debug.log(Debug.TRACE,"Writing Row record"); - - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java deleted file mode 100644 index 2d3ecb4efca5..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Selection.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.awt.Point; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record that describes the selected area of a worksheet - */ -public class Selection implements BIFFRecord { - - private byte[] rwTop = new byte[2]; - private byte colLeft; - private byte[] rwBottom = new byte[2]; - private byte colRight; - private byte[] rwActive = new byte[2]; - private byte colActive; - - /** - * Default Constructor - */ - public Selection() { - this.rwTop = EndianConverter.writeShort((short) 0); - this.colLeft = 0; - this.rwBottom = EndianConverter.writeShort((short) 0); - this.colRight = 0; - this.rwActive = EndianConverter.writeShort((short) 0); - this.colActive = 0; - - } - - /** - * Constructs a Selection Record from the <code>InputStream</code> - * - * @param is InputStream containing a Pocket Excel Data file. - */ - public Selection(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>Selection</code> - */ - public short getBiffType() { - return PocketExcelConstants.CURRENT_SELECTION; - } - - /** - * Get the active cell for this particular <code>BIFFRecord</code> - * - * @return the cell position - */ - public Point getActiveCell() { - Point p = new Point(colActive, EndianConverter.readShort(rwActive)); - return p; - } - - /** - * Set the active cell position for this particular <code>BIFFRecord</code> - * - * @param p The active cell position - */ - public void setActiveCell(Point p) { - - colActive = (byte) p.getX(); - rwActive = EndianConverter.writeShort((short) p.getY()); - } - - /** - * Reads a Selection Record from the <code>InputStream</code> - * - * @param input InputStream containing a Pocket Excel Data file. - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rwTop); - colLeft += (byte) input.read(); - numOfBytesRead += input.read(rwBottom); - colRight += (byte) input.read(); - numOfBytesRead += input.read(rwActive); - colActive += (byte) input.read(); - numOfBytesRead += 3; - - Debug.log(Debug.TRACE,"\trwTop : "+ EndianConverter.readShort(rwTop) + - " colLeft : " + colLeft + - " rwBottom : " + EndianConverter.readShort(rwBottom) + - " colRight : "+ colRight + - " rwActive : " + EndianConverter.readShort(rwActive) + - " colActive : " + colActive); - - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(rwTop); - output.write(colLeft); - output.write(rwBottom); - output.write(colRight); - output.write(rwActive); - output.write(colActive); - - Debug.log(Debug.TRACE,"Writing Selection record"); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java deleted file mode 100644 index f44d6c867c14..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/StringValue.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF Record that describes the value of a formula that - * evaluates to a string - */ -public class StringValue implements BIFFRecord { - - private byte[] cch = new byte[2]; - private byte[] rgch; - - /** - * Constructs a StringValue Record from a string - * - * @param str String containing value - */ - public StringValue(String str) throws IOException { - cch = EndianConverter.writeShort((short) str.length()); - rgch = new byte[str.length()]; - rgch = str.getBytes("UTF-16LE"); - } - - /** - * Constructs a StringValue Record from an <code>InputStream</code> - * - * @param is InputStream containing a StringValue Record - */ - public StringValue(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>StringValue</code> - */ - public short getBiffType() { - return PocketExcelConstants.FORMULA_STRING; - } - - /** - * Reads a StringVlaue Record from an <code>InputStream</code> - * - * @param input InputStream containing a StringValue Record - */ - public int read(InputStream input) throws IOException { - - cch[0] = (byte) input.read(); - cch[1] = (byte) input.read(); - int numOfBytesRead = 1; - - int strlen = EndianConverter.readShort(cch)*2; - rgch = new byte[strlen]; - numOfBytesRead += input.read(rgch, 0, strlen); - - Debug.log(Debug.TRACE,"\tcch : "+ cch + - " rgch : " + rgch); - - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(cch); - output.write(rgch); - - Debug.log(Debug.TRACE,"Writing StringValue record"); - } - - /** - * Gets the <code>String</code> representing the cells contents - * - * @return the <code>String</code> representing the cells contents - */ - public String getString() throws IOException { - String name; - - try { - name = new String(rgch, "UTF-16LE"); - } catch (UnsupportedEncodingException e){ - name = "unknown"; - } - return name; - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java deleted file mode 100644 index a8a2cd5502c2..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/UnsupportedFormulaException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.lang.Exception; - -/** - * At the moment any functions within a formula will result in this exception - * being thrown. - */ -public class UnsupportedFormulaException extends Exception { - - public UnsupportedFormulaException(String message){ - super(message); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java deleted file mode 100644 index 26c2a1eb8dbb..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window1.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; - -/** - * Represents a BIFF REcord that describes workbook window attributes - */ -public class Window1 implements BIFFRecord { - - private byte[] grbit = new byte[2]; - private byte[] itabCur = new byte[2]; // index of selected worksheet - - /** - * Constructor - */ - public Window1() { - grbit = EndianConverter.writeShort((short) 0); - itabCur = EndianConverter.writeShort((short) 0); - } - - /** - * Constructs a Window1 Record from an <code>InputStream</code> - * - * @param is InputStream containing a Window1 Record - */ - public Window1(InputStream is) throws IOException{ - read(is); - } - - /** - * Set the number of the active sheet - * - * @param activeSheet number of the active sheet - */ - public void setActiveSheet(int activeSheet) { - itabCur = EndianConverter.writeShort((short) activeSheet); - } - - /** - * Get the number of the active sheet - * - * @return number of the active sheet - */ - public int getActiveSheet() { - return EndianConverter.readShort(itabCur); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>Window1</code> - */ - public short getBiffType() { - return PocketExcelConstants.WINDOW_INFO; - } - - /** - * Reads a Window1 Record from an <code>InputStream</code> - * - * @param input InputStream containing a Window1 Record - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(grbit); - numOfBytesRead += input.read(itabCur); - - Debug.log(Debug.TRACE,"\tgrbit : "+ EndianConverter.readShort(grbit) + - " itabCur : " + EndianConverter.readShort(itabCur)); - - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(grbit); - output.write(itabCur); - - Debug.log(Debug.TRACE,"Writing Window1 record"); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java deleted file mode 100644 index e9730e0aecb3..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Window2.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.OutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.awt.Point; - -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; -import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; - -/** - * Represents a BIFF Record that describes worksheet window attributes - */ -public class Window2 implements BIFFRecord { - - private final static int FROZEN = 0x08; - private final static int NOSPLIT = 0x01; - - private byte[] rwTop = new byte[2]; - private byte colLeft; - private byte[] grbit = new byte[2]; - - /** - * Constructor - */ - public Window2() { - this.rwTop = EndianConverter.writeShort((short) 0); - this.colLeft = 0; - this.grbit = EndianConverter.writeShort((short) 0); - } - - /** - * Constructs a Window2 Record from an <code>InputStream</code> - * - * @param is InputStream containing a Window2 Record - */ - public Window2(InputStream is) throws IOException { - read(is); - } - - /** - * Get the hex code for this particular <code>BIFFRecord</code> - * - * @return the hex code for <code>Window2</code> - */ - public short getBiffType() { - return PocketExcelConstants.SHEET_WINDOW_INFO; - } - - /** - * Sets the split type for this pane, the split type is the same for both - * x and y so we only test against one. - * - * @param splitType the split type based on types defined in - * <code>sheetSettings</code> - */ - public void setSplitType(Point splitType) { - if(splitType.getX()==SheetSettings.SPLIT) { - grbit[0] &= ~FROZEN; - grbit[1] &= ~NOSPLIT; - } else { - grbit[0] |= FROZEN; - grbit[1] |= NOSPLIT; - } - } - - /** - * This method tests if this object describes a freeze - * - * @return true if freeze otherwise false - */ - public boolean isFrozen() { - if((grbit[0] & FROZEN) != FROZEN) - return false; - - if((grbit[1] & NOSPLIT) != NOSPLIT) - return false; - - return true; - } - - /** - * This method tests if this object describes a split - * - * @return true if split otherwise false - */ - public boolean isSplit() { - if((grbit[0] & FROZEN) == FROZEN) - return false; - - if((grbit[1] & NOSPLIT) == NOSPLIT) - return false; - - return true; - } - - /** - * Reads a Window2 Record from an <code>InputStream</code> - * - * @param input InputStream containing a Window2 Record - */ - public int read(InputStream input) throws IOException { - - int numOfBytesRead = input.read(rwTop); - colLeft = (byte) input.read(); - numOfBytesRead++; - numOfBytesRead += input.read(grbit); - - Debug.log(Debug.TRACE,"\trwTop : "+ EndianConverter.readShort(rwTop) + - " colLeft : " + colLeft + - " grbit : " + EndianConverter.readShort(grbit)); - return numOfBytesRead; - } - - public void write(OutputStream output) throws IOException { - - output.write(getBiffType()); - output.write(rwTop); - output.write(colLeft); - output.write(grbit); - - Debug.log(Debug.TRACE,"Writing Window2 record"); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java deleted file mode 100644 index 95a804acc3e2..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java +++ /dev/null @@ -1,532 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxc.BookSettings; -import org.openoffice.xmerge.converter.xml.sxc.ColumnRowInfo; -import org.openoffice.xmerge.converter.xml.sxc.Format; -import org.openoffice.xmerge.converter.xml.sxc.NameDefinition; -import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; -import org.openoffice.xmerge.util.Debug; - -/** - * This class is used by <code> PxlDocument</code> to maintain pexcel - * workbooks. - * - */ -public class Workbook implements org.openoffice.xmerge.Document, -OfficeConstants { - - private ArrayList<FontDescription> fonts = new ArrayList<FontDescription>(); - private ArrayList<ExtendedFormat> extendedFormats = new ArrayList<ExtendedFormat>(); - private ArrayList<Worksheet> worksheets = new ArrayList<Worksheet>(); - private ArrayList<BoundSheet> boundsheets = new ArrayList<BoundSheet>(); - private ArrayList<DefinedName> definedNames = new ArrayList<DefinedName>(); - private static final CodePage cp; - private static final Window1 win1; - private static final BeginningOfFile bof; - private static final Eof eof; - private String fileName; - - static { - cp = new CodePage(); - win1 = new Window1(); - bof = new BeginningOfFile(true); - eof = new Eof(); - } - - /** - * Constructs a pocket Excel Workbook with the name of the file passed in - * as an argument. Also fills out a basic header block containing the - * minimum number of objects that can be created at this time. - * - * @param name Name of the Pocket Excel Data file. (excluding the file - * extension) - */ - public Workbook(String name) throws IOException { - fileName = name + PocketExcelConstants.FILE_EXTENSION; - Format defaultFormat = new Format(); - FontDescription fd = new FontDescription(defaultFormat); - fonts.add(fd); - ExtendedFormat xf = new ExtendedFormat(0, defaultFormat); - extendedFormats.add(xf); - } - - /** - * Constructs a pocket Excel Workbook from the - * <code>InputStream</code> and assigns it the document name passed in - * - * @param name Name of the Pocket Excel Data file. (including the file - * extension) - * @param is InputStream containing a Pocket Excel Data file. - */ - public Workbook(String name, InputStream is) throws IOException { - read(is); - fileName = name; - } - - /** - * Writes the current workbook to the <code>Outputstream</code> - * - * @param os The destination outputstream - */ - public void write(OutputStream os) throws IOException { - bof.write(os); - cp.write(os); - for(Iterator<DefinedName> e = definedNames.iterator();e.hasNext();) { - DefinedName dn = e.next(); - dn.write(os); - } - win1.write(os); - for(Iterator<FontDescription> e = fonts.iterator();e.hasNext();) { - FontDescription fd = e.next(); - fd.write(os); - } - for(Iterator<ExtendedFormat> e = extendedFormats.iterator();e.hasNext();) { - ExtendedFormat xf = e.next(); - xf.write(os); - } - for(Iterator<BoundSheet> e = boundsheets.iterator();e.hasNext();) { - BoundSheet bs = e.next(); - bs.write(os); - } - eof.write(os); - - for(Iterator<Worksheet> e = worksheets.iterator();e.hasNext();) { - Worksheet ws = e.next(); - ws.write(os); - } - } - - /** - * Reads a workbook from the <code>InputStream</code> and contructs a - * workbook object from it - * - * @param is InputStream containing a Pocket Excel Data file. - */ - public void read(InputStream is) throws IOException { - - boolean done = false; - - int b = 0; - while (!done) - { - b = is.read(); - if (b == -1) - { - Debug.log(Debug.TRACE,"End of file reached"); - break; - } - - switch (b) - { - case PocketExcelConstants.DEFINED_NAME: - Debug.log(Debug.TRACE,"NAME: Defined Name (18h)"); - DefinedName dn = new DefinedName(is, this); - definedNames.add(dn); - break; - - case PocketExcelConstants.BOF_RECORD: - Debug.log(Debug.TRACE,"BOF Record"); - bof.read(is); - break; - - case PocketExcelConstants.EOF_MARKER: - Debug.log(Debug.TRACE,"EOF Marker"); - eof.read(is); - Worksheet ws = new Worksheet(this); - while(ws.read(is)) { - worksheets.add(ws); - ws = new Worksheet(this); - } - break; - - case PocketExcelConstants.FONT_DESCRIPTION: - Debug.log(Debug.TRACE,"FONT: Font Description (31h)"); - FontDescription fd = new FontDescription(is); - fonts.add(fd); - break; - - case PocketExcelConstants.WINDOW_INFO: - Debug.log(Debug.TRACE,"WINDOW1: Window Information (3Dh) [PXL 2.0]"); - win1.read(is); - break; - - case PocketExcelConstants.CODEPAGE: - Debug.log(Debug.TRACE,"CODEPAGE : Codepage and unknown fields (42h)"); - cp.read(is); - break; - - case PocketExcelConstants.BOUND_SHEET: - Debug.log(Debug.TRACE,"BOUNDSHEET: Sheet Information (85h)"); - BoundSheet bs = new BoundSheet(is); - boundsheets.add(bs); - break; - - case PocketExcelConstants.EXTENDED_FORMAT: - Debug.log(Debug.TRACE,"XF: Extended Format (E0h) [PXL 2.0]"); - ExtendedFormat xf = new ExtendedFormat(is); - extendedFormats.add(xf); - break; - - default: - b = is.read(); - break; - } - - } - is.close(); - } - - /** - * Adds a font recrod to the workbook - * - * @param f the font record to add - */ - public int addFont(FontDescription f) { - - boolean alreadyExists = false; - int i = 0; - - for(Iterator<FontDescription> e = fonts.iterator();e.hasNext();) { - FontDescription fd = e.next(); - if(fd.compareTo(f)) { - alreadyExists = true; - break; - } else { - i++; - } - } - - if(!alreadyExists) - fonts.add(f); - - return i; - } - - /** - * Adds a ExtendedFormat record to the workbook - * - * @param fmt the font record to add - */ - public int addExtendedFormat(Format fmt) throws IOException { - - FontDescription fd = new FontDescription(fmt); - int ixfnt = addFont(fd); - ExtendedFormat xf = new ExtendedFormat(ixfnt, fmt); - - boolean alreadyExists = false; - int i = 0; - - for(Iterator<ExtendedFormat> e = extendedFormats.iterator();e.hasNext();) { - ExtendedFormat currentXF = e.next(); - if(xf.compareTo(currentXF)) { - alreadyExists = true; - break; - } else if(!alreadyExists) { - i++; - } - } - - if(!alreadyExists) - extendedFormats.add(xf); - - return i; - } - - /** - * Gets a worksheet at a particular index from mthe current workbook. - * - * @param index the index of the worksheet to retrieve - */ - public Worksheet getWorksheet(int index) { - - return worksheets.get(index); - } - - /** - * Returns a FontDescription indictated by the - * index parameter passed in to the method - * - * @param ixfnt index to the FontDescriptions, this is a 0 based index - * @return FontDescription indexed by ixfe - */ - public FontDescription getFontDescription(int ixfnt) { - - return fonts.get(ixfnt); - } - - /** - * Returns a ExtendedFormat indictated by the - * index parameter passed in to the method - * - * @param ixfe index to the FontDescriptions, this is a 0 based index - * @return FontDescription indexed by ixfe - */ - public ExtendedFormat getExtendedFormat(int ixfe) { - - return extendedFormats.get(ixfe); - } - - /** - * Returns an enumeration of DefinedNames for this workbook - * - * @return Enumeration for the DefinedNames - */ - public Iterator<DefinedName> getDefinedNames() { - - return definedNames.iterator(); - } - - /** - * Returns an enumeration of <code>Settings</code> for this workbook - * - * @return Enumeration of <code>Settings</code> - */ - public BookSettings getSettings() { - - ArrayList<SheetSettings> settingsVector = new ArrayList<SheetSettings>(); - int index = 0; - for(Iterator<Worksheet> e = worksheets.iterator();e.hasNext();) { - Worksheet ws = e.next(); - SheetSettings s = ws.getSettings(); - s.setSheetName(getSheetName(index++)); - settingsVector.add(s); - } - BookSettings bs = new BookSettings(settingsVector); - String activeSheetName = getSheetName(win1.getActiveSheet()); - bs.setActiveSheet(activeSheetName); - return bs; - } - - /** - * Returns a <code>Vector</code> containing all the worksheet Names - * - * @return a <code>Vector</code> containing all the worksheet Names - */ - public ArrayList<Object> getWorksheetNames() { - - ArrayList<Object> wsNames = new ArrayList<Object>(); - - for(int i = 0;i < boundsheets.size();i++) { - wsNames.add(getSheetName(i)); - } - - return wsNames; - } - - /** - * Returns the name of the worksheet at the specified index - * - * @return a <code>String</code> containing the name of the worksheet - */ - public String getSheetName(int index) { - BoundSheet bs = boundsheets.get(index); - - return bs.getSheetName(); - } - - /** - * Adds a <code>Worksheet</code> to the workbook. - * - * @param name the name of the <code>Worksheet</code> to be added - */ - public void addWorksheet(String name) throws IOException { - - BoundSheet bs = new BoundSheet(name); - boundsheets.add(bs); - - Worksheet ws = new Worksheet(); - worksheets.add(ws); - } - - /** - * Adds a cell to the current worksheet. - * - * @param row Row index for the new cell. - * @param col Column index for the new cell. - * @param fmt Format description for the new cell. - * @param cellContents Contents for the new cell. - */ - public void addCell(int row,int col, Format fmt, String cellContents) - throws IOException { - - Worksheet currentWS = worksheets.get(worksheets.size()-1); - int ixfe = addExtendedFormat(fmt); - - String category = fmt.getCategory(); - - // Now the formatting is out of the way add the cell - Debug.log(Debug.TRACE,"Cell Format: " + fmt); - Debug.log(Debug.TRACE,"Row : " + row); - Debug.log(Debug.TRACE,"Col : " + col); - if(cellContents.startsWith("=")) { - try { - Formula f = new Formula(row, col, cellContents, ixfe, fmt, this); - currentWS.addCell(f); - if(category.equalsIgnoreCase(CELLTYPE_STRING)) { - StringValue sv = new StringValue(fmt.getValue()); - currentWS.addCell(sv); - } - } catch(Exception e) { - Debug.log(Debug.TRACE, "Parsing Exception thrown : " + e.getMessage()); - BoolErrCell errorCell = new BoolErrCell(row, col, ixfe, 0x2A, 1); - currentWS.addCell(errorCell); - } - } else if(category.equalsIgnoreCase(OfficeConstants.CELLTYPE_FLOAT)) { - try { - FloatNumber num = new FloatNumber(row, col, cellContents, ixfe); - currentWS.addCell(num); - } catch(Exception e) { - Debug.log(Debug.TRACE,"Error could not parse Float " + cellContents); - LabelCell lc = new LabelCell(row, col, cellContents, ixfe); - currentWS.addCell(lc); - } - } else { - if(cellContents.length()==0) { - Debug.log(Debug.TRACE, "Blank Cell"); - BlankCell b = new BlankCell(row, col, ixfe); - currentWS.addCell(b); - } else { - Debug.log(Debug.TRACE, "Label Cell : " + cellContents); - LabelCell lc = new LabelCell(row, col, cellContents, ixfe); - currentWS.addCell(lc); // three because we assume the last three - // Records in any worksheet is the selection, - // window2 and eof Records - } - } - } - - /** - * Will create a number of ColInfo records based on the column widths - * passed in. - * - * @param columnRows <code>Vector</code> of <code>ColumnRowInfo</code> - */ - public void addColInfo(ArrayList<ColumnRowInfo> columnRows) throws IOException { - - Worksheet currentWS = worksheets.get(worksheets.size()-1); - - int nCols = 0; - int nRows = 0; - - Debug.log(Debug.TRACE,"Workbook: addColInfo()"); - for(Iterator<ColumnRowInfo> e = columnRows.iterator();e.hasNext();) { - ColumnRowInfo cri =e.next(); - int ixfe = 0; - int size = cri.getSize(); - int repeated = cri.getRepeated(); - if(cri.isColumn()) { - Debug.log(Debug.TRACE,"Workbook: adding ColInfo width = " + size); - ColInfo newColInfo = new ColInfo( nCols, - nCols+repeated-1, - size, ixfe); - currentWS.addCol(newColInfo); - nCols += repeated; - } else if(cri.isRow()) { - - Debug.log(Debug.TRACE,"Workbook: adding Row Height = " + size); - if(!cri.isDefaultSize()) { - for(int i=0;i<repeated;i++) { - Row newRow = new Row(nRows++, size, cri.isUserDefined()); - currentWS.addRow(newRow); - } - } else { - // If it is the Default Row we don't need to add it - nRows += repeated; - } - - } - } - } - - /** - * Add a name definition to the workbook. - * - * @param nameDefinition The name definition to add. - */ - public void addNameDefinition(NameDefinition nameDefinition) throws IOException { - - DefinedName dn = new DefinedName(nameDefinition, this); - definedNames.add(dn); - } - - /** - * Adds the <code>BookSettings</code> for this workbook. - * - * @param book the <code>BookSettings</code> to add - */ - public void addSettings(BookSettings book) throws IOException { - - int index = 0; - ArrayList<SheetSettings> sheetSettings = book.getSheetSettings(); - String activeSheetName = book.getActiveSheet(); - - for(Iterator<Worksheet> e = worksheets.iterator();e.hasNext();) { - Worksheet ws = e.next(); - String name = getSheetName(index++); - if(activeSheetName.equals(name)) { - win1.setActiveSheet(index-1); - } - for(Iterator<SheetSettings> eSettings = sheetSettings.iterator();eSettings.hasNext();) { - SheetSettings s = eSettings.next(); - if(name.equals(s.getSheetName())) { - ws.addSettings(s); - } - } - } - } - - /** - * Return the filename of the pxl document without the file extension - * - * @return filename without the file extension - */ - public String getName() { - - // We have to strip off the file extension - int end = fileName.lastIndexOf("."); - String name; - if( end >= 0) // check in case the filename is already stripped - name = fileName.substring(0, end); - else - name = fileName; - - return name; - } - - /** - * Returns the filename of the pxl document with the file extension - * - * @return filename with the file extension - */ - public String getFileName() { - - return fileName; - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java deleted file mode 100644 index 5f101b28dda2..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records; - -import java.awt.Point; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.converter.xml.sxc.SheetSettings; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.PocketExcelConstants; -import org.openoffice.xmerge.util.Debug; - -/** - * This class is used by <code>PxlDocument</code> to maintain pexcel - * worksheets. - */ -public class Worksheet { - - private Workbook wb; - private ArrayList<Row> rows = new ArrayList<Row>(); - private ArrayList<ColInfo> colInfo = new ArrayList<ColInfo>(); - private ArrayList<BIFFRecord> cells = new ArrayList<BIFFRecord>(); - private DefColWidth dcw = new DefColWidth(); - private DefRowHeight drh = new DefRowHeight(); - private Window2 win2 = new Window2(); - private Selection sel = new Selection(); - private Pane p = new Pane(); - private BeginningOfFile bof; - private Eof eof; - - /** - * Creates a worksheet in a given workbook. - * - * @param wb The destination workbook. - */ - public Worksheet(Workbook wb) { - this.wb = wb; - } - - /** - * Default Contructor. Creates a worksheet not attached to any workbook. - */ - public Worksheet() { - } - - /** - * Writes the current workbook to the <code>Outputstream</code> - * - * @param os The destination outputstream - */ - public void write(OutputStream os) throws IOException { - - bof = new BeginningOfFile(false); - bof.write(os); - dcw.write(os); - for(Iterator<ColInfo> e = colInfo.iterator();e.hasNext();) { - ColInfo ci = e.next(); - ci.write(os); - } - drh.write(os); - for(Iterator<Row> e = rows.iterator();e.hasNext();) { - Row rw = e.next(); - rw.write(os); - } - for(Iterator<BIFFRecord> e = cells.iterator();e.hasNext();) { - BIFFRecord cv = e.next(); - cv.write(os); - } - win2.write(os); - p.write(os); - sel.write(os); - eof = new Eof(); - eof.write(os); - } - - /** - * Reads a worksheet from the <code>InputStream</code> and contructs a - * workbook object from it - * - * @param is InputStream containing a Pocket Excel Data file. - * @return True if we read anything. False if not. - */ - public boolean read(InputStream is) throws IOException { - - int b = is.read(); - - if (b==-1) - return false; - - while(b!=-1) { - switch (b) - { - case PocketExcelConstants.BLANK_CELL: - Debug.log(Debug.TRACE,"Blank Cell (01h)"); - BlankCell bc = new BlankCell(is); - cells.add(bc); - break; - - case PocketExcelConstants.NUMBER_CELL: - Debug.log(Debug.TRACE,"NUMBER: Cell Value, Floating-Point Number (03h)"); - FloatNumber fn = new FloatNumber(is); - cells.add(fn); - break; - - case PocketExcelConstants.LABEL_CELL: - Debug.log(Debug.TRACE,"LABEL: Cell Value, String Constant (04h)"); - LabelCell lc = new LabelCell(is); - cells.add(lc); - break; - - case PocketExcelConstants.BOOLERR_CELL: - Debug.log(Debug.TRACE,"BOOLERR: Cell Value, Boolean or Error (05h)"); - new BoolErrCell(is); - break; - - case PocketExcelConstants.FORMULA_CELL: - Debug.log(Debug.TRACE,"FORMULA: Cell Formula (06h)"); - Formula f = new Formula(is, wb); - cells.add(f); - break; - - case PocketExcelConstants.FORMULA_STRING: - Debug.log(Debug.TRACE,"String Value of a Formula (07h)"); - new StringValue(is); - break; - - case PocketExcelConstants.ROW_DESCRIPTION: - Debug.log(Debug.TRACE,"ROW: Describes a Row (08h)"); - Row rw = new Row(is); - rows.add(rw); - break; - - case PocketExcelConstants.BOF_RECORD: - Debug.log(Debug.TRACE,"BOF Record"); - bof = new BeginningOfFile(is); - break; - - case PocketExcelConstants.EOF_MARKER: - Debug.log(Debug.TRACE,"EOF Marker"); - eof = new Eof(); - return true; - - case PocketExcelConstants.CURRENT_SELECTION: - Debug.log(Debug.TRACE,"SELECTION: Current Selection (1Dh)"); - sel = new Selection(is); - break; - - case PocketExcelConstants.NUMBER_FORMAT: - Debug.log(Debug.TRACE,"FORMAT: Number Format (1Eh)"); - new NumberFormat(is); - break; - - case PocketExcelConstants.DEFAULT_ROW_HEIGHT: - Debug.log(Debug.TRACE,"DEFAULTROWHEIGHT: Default Row Height (25h)"); - drh = new DefRowHeight(is); - break; - - case PocketExcelConstants.SHEET_WINDOW_INFO: - Debug.log(Debug.TRACE,"WINDOW2: Sheet Window Information (3Eh) [PXL 2.0]"); - win2 = new Window2(is); - break; - - case PocketExcelConstants.PANE_INFO: - Debug.log(Debug.TRACE,"PANE: Number of Panes and their Position (41h) [PXL 2.0]"); - p = new Pane(is); - break; - - case PocketExcelConstants.DEF_COL_WIDTH: - Debug.log(Debug.TRACE,"DEFCOLWIDTH: Default Column Width (55h) [PXL 2.0]"); - dcw = new DefColWidth(is); - break; - - case PocketExcelConstants.COLINFO: - Debug.log(Debug.TRACE,"COLINFO: Column Formatting Information (7Dh) [PXL 2.0]"); - ColInfo ci = new ColInfo(is); - colInfo.add(ci); - break; - - default: - break; - } - b = is.read(); - - } - Debug.log(Debug.TRACE,"Leaving Worksheet:"); - - return true; - } - - /** - * Returns an enumerator which will be used to access individual cells - * - * @return an enumerator to the worksheet cells - */ - public Iterator<BIFFRecord> getCellEnumerator() throws IOException { - return (cells.iterator()); - } - - /** - * Adds a cell to this worksheet based on a <code>BIFFRecord</code>. - * Current valdid celltypes are <code>FloatNumber</code>, - * <code>LabelCell</code> or <code>Formula</code> - * - * @param br The <code>BIFFRecord</code> to read from. - */ - public void addCell(BIFFRecord br) { - cells.add(br); - } - - /** - * Adds a row to the worksheet. - * - * @param r The row to add. - */ - public void addRow(Row r) { - rows.add(r); - } - - /** - * Adds a ColInfo record to the worksheet. This may effec more than one column. - * - * @param c ColInfo structure defining widths, format etc. - */ - public void addCol(ColInfo c) { - colInfo.add(c); - } - - /** - * Add various settings to this worksheet. - * - * @param s SheetSettings object defining pane number, splits etc. - */ - public void addSettings(SheetSettings s) { - - sel.setActiveCell(s.getCursor()); - p.setLeft(s.getLeft()); - p.setTop(s.getTop()); - p.setPaneNumber(s.getPaneNumber()); - Point split = s.getSplit(); - if(split.getX()!=0 || split.getY()!=0) { - p.setSplitPoint(s.getSplitType(), split); - win2.setSplitType(s.getSplitType()); - } - } - - /** - * Returns an <code>Enumeration</code> to the ColInfo's for this worksheet - * - * @return an <code>Enumeration</code> to the ColInfo's - */ - public Iterator<ColInfo> getColInfos() { - - return (colInfo.iterator()); - } - - /** - * Returns a <code>SheetSettings</code> object containing a collection of data - * contained in <code>Pane</code>, <code>Window2</code> and - * <code>Selection</code> - * - * @return an <code>SheetSettings</code> - */ - public SheetSettings getSettings() { - - SheetSettings s = new SheetSettings(); - s.setCursor(sel.getActiveCell()); - if(win2.isFrozen()) { - s.setFreeze(p.getFreezePoint()); - } else if(win2.isSplit()) { - s.setSplit(p.getSplitPoint()); - } - s.setPaneNumber(p.getPaneNumber()); - s.setTopLeft(p.getTop(), p.getLeft()); - return s; - } - /** - * Returns an <code>Enumeration</code> to the Rows for this worksheet - * - * @return an <code>Enumeration</code> to the Rows - */ - public Iterator<Row> getRows() { - - return (rows.iterator()); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java deleted file mode 100644 index 506fd2777cf3..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaCompiler.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.util.ArrayList; -import java.util.ListIterator; -import java.util.Stack; - -import org.openoffice.xmerge.util.Debug; - -/** - * FormulaCompiler converts Calc formula string into PocketXL bytes - * and PocketXL formula bytes into Calc Formula strings - * - * For converting from infix to Reverse Polish (or Postfix) notation the string is - * converted into a vector of Tokens and then re-ordered based on a modified version - * of the standard Infix to RPN conversion algorithms. - * <pre> - * Infix2Rpn(tokens) - * while have more tokens - * if token is operand - * push to stack - * else if token is function, argument separater, or open bracket - * push token - * extract tokens to matching close bracket into param - * Infix2Rpn(param) - * else if token is close bracket - * pop from stack into result until close bracket or function - * else - * while stack.top.priority >= token.priority - * add stack.pop to result - * push token onto stack - * </pre> - * For converting from RPN to Infix the following algorithm is applied: - * <pre> - * while have more tokens - * if token is operand - * push token to stack - * else if token is function or operator - * pop from stack number of args required by token - * apply token to params to make expr - * push expr to stack - * return stack.pop - * </pre> - */ -public class FormulaCompiler { - /** - * Constructs a FormulaCompiler object - */ - public FormulaCompiler() { - } - - private boolean isPercent(Token pt) { - return pt.getTokenID() == TokenConstants.TPERCENT; - } - - private boolean isOpenBrace(Token pt) { - return pt.getTokenID() == TokenConstants.TPAREN; - } - - private boolean isCloseBrace(Token pt) { - return pt.getValue().compareTo(")") == 0; - } - - private boolean isParamDelimiter(Token pt) { - return pt.getTokenID() == TokenConstants.TARGSEP; - } - - /** - * Re-order into Infix format - * @param tokens The tokens in RPN form - * @return The vector of tokens re-ordered in Infix notation - */ - public ArrayList<Token> RPN2Infix(ArrayList<Token> tokens) { - ListIterator<Token> iter = tokens.listIterator(); - Stack<ArrayList<Token>> evalStack = new Stack<ArrayList<Token>>(); - Stack<ArrayList<Token>> args = new Stack<ArrayList<Token>>(); - - while (iter.hasNext()) { - Token pt = iter.next(); - if (pt.isOperand()) { - ArrayList<Token> expr = new ArrayList<Token>(5); - expr.add(pt); - evalStack.push(expr); - } else if (pt.isOperator() || pt.isFunction()) { - args.clear(); - for (int i=0; i< pt.getNumArgs(); i++) { - args.push(evalStack.pop()); - } - evalStack.push(makeExpression(pt, args)); - } - } - return evalStack.elementAt(0); - } - - /** - * Convert the infix expression to RPN. Note that open brackets are saved onto the stack to preserve the users bracketing. - * <p>Also note that the open bracket following functions is not pushed onto the stack - it is always implied when - * writing out results - * - * @param tokens The vector of tokens in Infix form - * - * @return A vector of tokens for the expression in Reverse Polish Notation order - */ - public ArrayList<Token> infix2RPN(ArrayList<Token> tokens) { - ArrayList<Token> rpnExpr = new ArrayList<Token>(15); - Stack<Token> evalStack = new Stack<Token>(); - ListIterator<Token> iter = tokens.listIterator(); - while (iter.hasNext()) { - Token pt = iter.next(); - - if (pt.isOperand()) { //Operands are output immediately - rpnExpr.add(pt); - } else if (pt.isFunction() || isParamDelimiter(pt) || isOpenBrace(pt)) { //Extract parameters after afunction or comma - evalStack.push(pt); - if (pt.isFunction()) { - iter.next(); - } - ArrayList<Token> param = extractParameter(iter); - Debug.log(Debug.TRACE, "Extracted parameter " + param); - rpnExpr.addAll(infix2RPN(param)); - } else if (isCloseBrace(pt)) { //Pop off stack till you meet a function or an open bracket - Token tmpTok = null; - boolean bPop = true; - while (bPop) { - if (evalStack.isEmpty()) { - bPop = false; - } else { - tmpTok = evalStack.pop(); - if (!isParamDelimiter(tmpTok)) { //Don't output commas - rpnExpr.add(tmpTok); - } - if (tmpTok.isFunction() || isOpenBrace(tmpTok)) { - bPop = false; - } - } - } - } else { - if (!evalStack.isEmpty()) { - while (!evalStack.isEmpty() && - (evalStack.peek().getTokenPriority() >=pt.getTokenPriority())) { - Token topTok = evalStack.peek(); - if (topTok.isFunction() || isOpenBrace(topTok)) { - break; - } - rpnExpr.add(evalStack.pop()); - } - } - evalStack.push(pt); - } - } - - while (!evalStack.isEmpty()) { - Token topTok = evalStack.peek(); - if (!(isOpenBrace(topTok) || isParamDelimiter(topTok))) { //Don't output brackets and commas - rpnExpr.add(evalStack.pop()); - } - else - { - evalStack.pop(); - } - } - return rpnExpr; - } - - /** - * Extract a parameter or bracketed sub-expression - * @param iter an iterator into the list - * @return A complete sub-expression - */ - protected ArrayList<Token> extractParameter(ListIterator<Token> iter) { - ArrayList<Token> param = new ArrayList<Token>(5); - int subExprCount = 0; - - while (iter.hasNext()) { - Token pt = iter.next(); - Debug.log(Debug.TRACE, "Token is " + pt + " and subExprCount is " + subExprCount); - if (isOpenBrace(pt)) { - subExprCount++; - param.add(pt); - } else if (isCloseBrace(pt)) { - if (subExprCount == 0) { - iter.previous(); - return param; - } else { - subExprCount--; - param.add(pt); - } - } else if (isParamDelimiter(pt) && (subExprCount == 0)) { - iter.previous(); - return param; - } else { - param.add(pt); - } - } - return param; - } - - /** - * Given the operator and it's operators - * @param pt The operator token - * @param args The arguments for this operator - * @return A correctly ordered expression - */ - protected ArrayList<Token> makeExpression(Token pt, Stack<ArrayList<Token>> args) { - ArrayList<Token> tmp = new ArrayList<Token>(5); - TokenFactory tf = new TokenFactory(); - if (pt.isOperator()) { - if (pt.getNumArgs()==2) { //Binary operator - tmp.addAll(args.pop()); - tmp.add(pt); - tmp.addAll(args.pop()); - } else if (pt.getNumArgs() == 1) { - if(isPercent(pt)) { - tmp.addAll(args.elementAt(0)); - tmp.add(pt); - } else { - tmp.add(pt); - tmp.addAll(args.elementAt(0)); - } - if (isOpenBrace(pt)) { - tmp.add(tf.getOperatorToken(")",1)); - } - } - } else if (pt.isFunction()) { - tmp.add(pt); - tmp.add(tf.getOperatorToken("(",1)); - if (!args.isEmpty()) { - ArrayList<Token> v = args.pop(); - tmp.addAll(v); - } - while (!args.isEmpty()) { - tmp.add(tf.getOperatorToken(",",1)); - ArrayList<Token> v = args.pop(); - tmp.addAll(v); - - } - tmp.add(tf.getOperatorToken(")",1)); - } - - return tmp; - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java deleted file mode 100644 index f2ba34e8dbd7..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaHelper.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; - -/** - * This Helper class provides a simplified interface to conversion between PocketXL formula representation - * and Calc formula representation.<p> - * The class is used by {@link org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Formula} - */ -public class FormulaHelper { - - private static FormulaParser parser; - private static FormulaCompiler compiler; - private static TokenEncoder encoder; - private static TokenDecoder decoder; - private boolean rangeType = false; - private boolean expressionType = false; - - static { - parser = new FormulaParser(); - compiler = new FormulaCompiler(); - encoder = new TokenEncoder(); - decoder = new TokenDecoder(); - } - - /** - * Sets the workbook cache so that global data such as - * <code>DefinedNames</code>, <code>Boundsheets</code> can be read - * - * @param wb Workbook object containing all the global data - */ - public void setWorkbook(Workbook wb) { - encoder.setWorkbook(wb); - decoder.setWorkbook(wb); - } - - /** - * Converts a string representation of a calc formula into an array of PocketXL bytes - * @param formula The Formula String (e.g. 1+SUM(A1,B1)) - * - * @throws UnsupportedFunctionException Thrown if a function in the formula is nto supported by Pocket Excel - * @throws FormulaParsingException Thrown when the formula is not well formed - * - */ - public byte[] convertCalcToPXL(String formula) throws UnsupportedFunctionException, FormulaParsingException { - - ArrayList<Token> parseTokens = parser.parse(formula); - ArrayList<Token> rpnTokens = compiler.infix2RPN(parseTokens); - - ByteArrayOutputStream bytes = null; - try { - bytes = new ByteArrayOutputStream(); - for (Iterator<Token> e = rpnTokens.iterator(); e.hasNext();) { - Token t = e.next(); - bytes.write(encoder.getByte(t)); - } - } catch (IOException e) { - } - - return bytes.toByteArray(); - } - - /** - * Converts a PocketXL byte array into a Calc function string - * @param formula A byte array that contains the PocketXL bytes for a formula - * - */ - public String convertPXLToCalc(byte[] formula) { - - ArrayList<Token> parseTokens = decoder.getTokenVector(formula); - ArrayList<Token> infixTokens = compiler.RPN2Infix(parseTokens); - - StringBuffer buff = new StringBuffer(); - for (Iterator<Token> e = infixTokens.iterator();e.hasNext();) { - Token t = e.next(); - buff.append(t.toString()); - // If we are parsing a Name definition we need to know if it is of - // type range or expression - if(!t.isOperand()) { - expressionType = true; - } - } - if(!expressionType) { - rangeType = true; - } - return "=" + buff.toString(); - } - - /** - * Returns a boolean indicating whether or not the byte[] parsed is of - * type range. This means it contains only a cell reference and no - * operators. This is necessry because the syntax for range and expression - * types differs. This is only of interest when dealing with - * <code>DefinedNames</code> and not <code>Formula</code> - * - * @return a boolean true if of type range otherwise false - * - */ - public boolean isRangeType() { - - return rangeType; - } - - /** - * Returns a boolean indicating whether or not the byte[] parsed is of - * type expression. This means it contains operators. This is necessry - * because the syntax for range and expression types differs. This is - * only of interest when dealing with <code>DefinedNames</code> and not - * <code>Formula</code> - * - * @return a boolean true if of type expression otherwise false - * - */ - public boolean isExpressionType() { - - return expressionType; - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java deleted file mode 100644 index acb605c43bc3..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParser.java +++ /dev/null @@ -1,516 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - - -import java.util.ArrayList; - -import org.openoffice.xmerge.util.Debug; - -/** - * This is the Formula Parser based on an article written by Jack Crenshaw. It is a - * top down parser with some basic error handling. It handles - * +,-,*,/,>,<,>=,<=,=,<>, unary + and - as well as functions. - * The BNF notation for this parser is - * <pre> - * <expression> ::= <unary op> <term> [<addop>|<logop> <term>] - * <term> ::= <factor> [<mulop> <factor>] - * <factor> ::= <number>[%] | <CellRef> | <QuoteString> | <expression> - * </pre> - */ -public class FormulaParser { - - private char look; - private String formulaStr; - private int index = 1; - private TokenFactory tokenFactory; - private ArrayList<Token> tokenVector; - - /** - * Default constructor - */ - public FormulaParser() { - - Debug.log(Debug.TRACE,"Creating a Formula Parser"); - tokenFactory = new TokenFactory(); - tokenVector = new ArrayList<Token>(); - } - - /** - * Parse method for parsing from a String to a byte[] - * - * @param formula A <code>String</code> representation of a formula - * starting with the '=' character - * @return A <code>Vector</code> containing the parsed <code>Token</code>s - */ - public ArrayList<Token> parse(String formula) throws FormulaParsingException { - - index = 1; - look = ' '; - tokenVector.clear(); - if(formula.startsWith("=")) { - formulaStr = formula; - Debug.log(Debug.TRACE,"Creating a Formula Parser for " + formulaStr); - getChar(); - expression(); - } else { - throw new FormulaParsingException("No equals found!" + makeErrorString()); - } - return tokenVector; - } - - /** - * Identify + and - operators - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isAddOp(char c) { - return (c == '-') || (c == '+'); - } - - /** - * Determine if the current character is a multiop - * - * @return A boolean returning the result of the comparison - */ - private boolean isMultiOp() { - return look=='*' || look =='/' || look == '^' || look == '&'; - } - - /** - * Identify <, >, <=, >=, =, <> using the index to find the current character(s) - * - * @return A boolean returning the result of the comparison - */ - private boolean isLogicalOp() { - if (!isLogicalOpChar(look)) { - return false; - } else if ((index+1) >= formulaStr.length()) {//logical operators in their own right : if at end then return true - return true; - } else if (!isLogicalOpChar(formulaStr.charAt(index))) { // we have >, < or = on their own - return true; - } else if ((look == '<') && ((formulaStr.charAt(index) == '>') || formulaStr.charAt(index) == '=')) { // <>, or <= - return true; - } else if ((look == '>') && (formulaStr.charAt(index) == '=')) { // >= - return true; - } - - return false; - } - - /** - * Identify characters that MAY be logical operator characters - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isLogicalOpChar(char c) { - return (c == '>') || (c == '<') || (c == '='); - } - - /** - * Identify special Cell Reference charaters - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isCellRefSpecialChar(char c) { - return (c == ':') || (c == '$') || (c == '.'); - } - - /** - * Identify letters - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isAlpha(char c) { - return(Character.isLetter(c)); - } - - /** - * Identify numbers - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isDigit(char c) { - return(Character.isDigit(c)); - } - - /** - * Identify numbers - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isPercent(char c) { - return (c == '%'); - } - - /** - * Identify valid Characters for cell references - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isCellRefChar(char c) { - return(isAlpha(c) || isDigit(c) || isCellRefSpecialChar(c)); - } - - /** - * Test if current character is a match and move to next character - * - * @param c The character which is to be matched - */ - private void match(char c) throws FormulaParsingException { - - if(look==c) { - Debug.log(Debug.TRACE,"Operator Found : " + look); - getChar(); - skipWhite(); - } - else - throw new FormulaParsingException("Unexpected character '" + c + "'" + makeErrorString()); - } - - /** - * Test if current character is a match and move to next character - * - * @param symbol The <code>String</code> to be matched. - */ - private void match(String symbol) throws FormulaParsingException { - - int numChars = symbol.length(); - boolean bContinue = true; - for (int i=0;i<numChars && bContinue; i++) { - if (look == symbol.charAt(i)) { - bContinue = getChar(); - skipWhite(); - } else { - throw new FormulaParsingException("Unexpected character '" + symbol + "'" + makeErrorString()); - } - } - } - - /** - * Skip over whitespaces (ie. spaces and tabs) - */ - private void skipWhite() throws FormulaParsingException { - - boolean success = true; - - while(Character.isWhitespace(look) && success) { - success = getChar(); - } - } - - /** - * This is a factor for multiplication and division operators - */ - private void factor() throws FormulaParsingException { - if(isAddOp(look)) { // handle unary addop - Character ch = new Character(look); - match(look); - tokenVector.add(tokenFactory.getOperatorToken(ch.toString(), 1)); - } - if(look=='(') { - match('('); - tokenVector.add(tokenFactory.getOperatorToken("(", 1)); - expression(); - match(')'); - tokenVector.add(tokenFactory.getOperatorToken(")", 1)); - } else if(isDigit(look)){ - getNum(); - } else { - ident(); - } - } - - /** - * Pulls the next character from the <code>String</code> - * - * @return boolean false if the end if the statement - * is reached otherwise true - */ - private boolean getChar() throws FormulaParsingException { - - boolean success = true; - - if(index<formulaStr.length()) { - look = formulaStr.charAt(index); - index++; - if(look==',') - success = false; - } else { - success = false; - } - return success; - } - - /** - * Parses the number of arguments in a function - * - * @return The number of arguments - */ - private int arguments() throws FormulaParsingException { - int numArgs; - - skipWhite(); - if(look==')') - numArgs = 0; - else - numArgs = 1; - - while(look!=')') { - expression(); - if(look==',') { - numArgs++; - match(','); - tokenVector.add(tokenFactory.getOperatorToken(",", 1)); - } - } - return numArgs; - } - - /** - * Test to see if we have come across a cell reference or a Name - * Definition. - */ - private boolean isCellRef(String s) { - char c; - boolean result = false; - - for(int i = 0;i<s.length();i++) { - c = s.charAt(i); - if(isCellRefSpecialChar(c)) { - result = true; - break; - } - } - - // if it is a simple cell reference then there will not be a cell - // reference 'special char' so we should also look for a digit - if(!result) { - if(isDigit(s.charAt(1)) || isDigit(s.charAt(2))) { - result = true; - } - } - return result; - } - - /** - * Test to see if we have come across a cell reference or a function and - * add the resulting toek nto the tokenVector. - */ - private void ident() throws FormulaParsingException { - - String cell = getTokenString(); - if(look=='(') { - Debug.log(Debug.TRACE,"Found Function : " + cell); - - int index = tokenVector.size(); - match('('); - tokenVector.add(tokenFactory.getOperatorToken("(", 1)); - int numArgs = arguments(); - match(')'); - tokenVector.add(tokenFactory.getOperatorToken(")", 1)); - tokenVector.add(index, tokenFactory.getFunctionToken(cell, numArgs)); - } else { - - if(cell.indexOf('.')!=-1) { - String cellRef = cell.substring(cell.indexOf('.') + 1, cell.length()); - if(cellRef.indexOf(':')!=-1) { - tokenVector.add(tokenFactory.getOperandToken(cell, "3D_CELL_AREA_REFERENCE")); - } else { - tokenVector.add(tokenFactory.getOperandToken(cell, "3D_CELL_REFERENCE")); - } - } else if(cell.indexOf(':')!=-1) { - tokenVector.add(tokenFactory.getOperandToken(cell, "CELL_AREA_REFERENCE")); - } else if(isCellRef(cell)) { - tokenVector.add(tokenFactory.getOperandToken(cell, "CELL_REFERENCE")); - } else { - tokenVector.add(tokenFactory.getOperandToken(cell, "NAME")); - } - } - } - - /** - * Will keep pulling valid logical operators from the formula and return - * the resultant <code>String</code>. - * - * @return a <code>String<code> representing a logical operator - */ - private String getLogicalOperator() throws FormulaParsingException { - String op = new String(); - boolean status; - - do { - op += look; - status = getChar(); - } while(isLogicalOpChar(look) && status); - skipWhite(); - return op; - } - - /** - * Keeps pulling characters from the statement until we get an - * operator and returns the resulting string. - * - * @return A <code>String</code>representing the next token - */ - private String getTokenString() throws FormulaParsingException { - - if(!isAlpha(look) && look!='$') - throw new FormulaParsingException("Expected Cell Reference" + makeErrorString()); - else { - String cell = new String(); - boolean status; - do { - cell += look; - status = getChar(); - } while(isCellRefChar(look) && status); - skipWhite(); - return cell; - } - } - - /** - * Keeps pulling numbers from the statement and add the resulting integer - * token to the tokenVector. - */ - private void getNum() throws FormulaParsingException { - - Debug.log(Debug.TRACE,"getNum : "); - if(!isDigit(look)) - throw new FormulaParsingException("Expected Integer" + makeErrorString()); - else { - String num = new String(); - boolean status; - - do { - num += look; - status = getChar(); - } while((isDigit(look) || ((look == '.') && isDigit(formulaStr.charAt(index)))) && status); - skipWhite(); - tokenVector.add(tokenFactory.getOperandToken(num, "INTEGER")); - if(isPercent(look)) { - match(look); - tokenVector.add(tokenFactory.getOperatorToken("%", 1)); - Debug.log(Debug.TRACE,"Added Percent token to Vector: "); - } - Debug.log(Debug.TRACE,"Number parsed : " + num); - } - } - - - /** - * Term will parse multiplication/division expressions - */ - private void term() throws FormulaParsingException { - factor(); - while(isMultiOp()) { - multiOp(Character.toString(look)); - } - } - - /** - * Expression is the entry point for the parser. It is the code - * that parses addition/subtraction expressions. - */ - private void expression() throws FormulaParsingException { - - if (look == '"') { //Extract a quoted string... - StringBuffer buff = new StringBuffer(); - boolean success = true; - success = getChar(); - while (look != '"' && success) { - buff.append(look); - success = getChar(); - } - - if (look != '"') { //We've reached the end of the string without getting a closing quote - throw new FormulaParsingException("Expected closing quote." + makeErrorString()); - } else { - tokenVector.add(tokenFactory.getOperandToken(buff.toString(), "STRING")); - getChar(); //Move on to the next character - } - } else { - term(); - } - while(isAddOp(look) || isLogicalOp()) { - if (isAddOp(look)) { - addOp(Character.toString(look)); - } else if (isLogicalOp()) { - logicalOp(); - } - } - } - - /** - * Test to see if the next token (represented as a <code>String</code>) is - * the same as the String passed in. Move the index along to the end of - * that String and add that <code>Token</code> to the tokenVector. Then - * call <code>term</code> to parse the right hand side of the operator. - * - * @param op A <code>String</code> representing the operator - */ - private void addOp(String op) throws FormulaParsingException { - match(op); - tokenVector.add(tokenFactory.getOperatorToken(op, 2)); - term(); - } - - /** - * Test to see if the next token (represented as a <code>String</code>) is - * the same as the String passed in. Move the index along to the end of - * that String and add that <code>Token</code> to the tokenVector. Then - * call <code>factor</code> to parse the right hand side of the operator. - * - * @param op A <code>String</code> representing the operator - */ - private void multiOp(String op) throws FormulaParsingException { - match(op); - tokenVector.add(tokenFactory.getOperatorToken(op, 2)); - factor(); - } - - /** - * Pull a logical operator starting at the current index, add a token for - * that operator to the tokenVector and call <code>term<code> to parse the - * right hand side of the operator - */ - private void logicalOp() throws FormulaParsingException { - String op = getLogicalOperator(); - tokenVector.add(tokenFactory.getOperatorToken(op, 2)); - term(); - } - - private String makeErrorString() { - StringBuffer buff = new StringBuffer(); - for (int i=0; i<index-1; i++) { - buff.append(' '); - } - - buff.append('^'); - return "\n\t" + formulaStr + "\n\t" + buff.toString(); - } - } - diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java deleted file mode 100644 index baf8c02da78b..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FormulaParsingException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -/* - * If the formula failed to be parsed properly this exception will be thrown - * - * Martin Maher - */ - -public class FormulaParsingException extends Exception { - - public FormulaParsingException(String message) { - super(message); - } - } diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java deleted file mode 100644 index a0cba9e566c8..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/FunctionLookup.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.util.HashMap; - -public class FunctionLookup extends SymbolLookup { - - private HashMap<String, Integer> stringToArgs = null; - - /** - * The default constructor - invokes {@link #initialize() initialize()} - */ - public FunctionLookup() { - initialize(); - } - - /** - * Initialize the lookup table for functions - */ - public void initialize() { - if ((stringToID != null) || (idToString != null) || (stringToArgs !=null)) { - return; - } - stringToID = new HashMap<String, Integer>(); - idToString = new HashMap<Integer, String>(); - stringToArgs = new HashMap<String, Integer>(); - - // Functions with Variable number of Arguments - // Math and Trig - addEntry("SUM", TokenConstants.TSUM, -1); - addEntry("MIN", TokenConstants.TMIN, -1); - addEntry("PRODUCT", TokenConstants.TPRODUCT, -1); - addEntry("LOG", TokenConstants.TLOG, -1); - addEntry("SUMIF", TokenConstants.TSUMIF, -1); - addEntry("TRUNC", TokenConstants.TRUNC, -1); - // Financial - addEntry("DDB", TokenConstants.TDDB, -1); - addEntry("FV", TokenConstants.TFV, -1); - addEntry("IRR", TokenConstants.TIRR, -1); - addEntry("NPER", TokenConstants.TNPER, -1); - addEntry("NPV", TokenConstants.TNPV, -1); - addEntry("PMT", TokenConstants.TPMT, -1); - addEntry("PV", TokenConstants.TPV, -1); - addEntry("RATE", TokenConstants.TRATE, -1); - // Statistical - addEntry("AVERAGE", TokenConstants.TAVERAGE, -1); - addEntry("COUNT", TokenConstants.TCOUNT, -1); - addEntry("COUNTA", TokenConstants.TCOUNTA, -1); - addEntry("MAX", TokenConstants.TMAX, -1 ); - addEntry("MIN", TokenConstants.TMIN, -1); - addEntry("STDEV", TokenConstants.TSTDEV, -1 ); - addEntry("STDEVP", TokenConstants.TSTDEVP, -1 ); - addEntry("VAR", TokenConstants.TVAR, -1); - addEntry("VARP", TokenConstants.TVARP, -1); - // Lookup - addEntry("CHOOSE", TokenConstants.TCHOOSE, -1); - addEntry("HLOOKUP", TokenConstants.THLOOKUP, -1); - addEntry("INDEX", TokenConstants.TINDEX, -1); - addEntry("MATCH", TokenConstants.TMATCH, -1) ; - addEntry("VLOOKUP", TokenConstants.TVLOOKUP, -1); - // Text - addEntry("RIGHT", TokenConstants.TRIGHT, -1); - addEntry("SUBSTITUTE", TokenConstants.TSUBSTITUTE, -1); - addEntry("FIND", TokenConstants.TFIND, -1); - addEntry("LEFT", TokenConstants.TLEFT, -1); - // Logical - addEntry("AND", TokenConstants.TAND, -1 ); - addEntry("IF", TokenConstants.TIF, -1) ; - addEntry("OR", TokenConstants.TOR, -1); - - // Functions with Fixed number of Arguments - // Math and Trig - addEntry("ABS", TokenConstants.TABS, 1); - addEntry("ACOS", TokenConstants.TACOS, 1); - addEntry("ASIN", TokenConstants.TASIN, 1); - addEntry("ATAN", TokenConstants.TATAN, 1); - addEntry("ATAN2", TokenConstants.TATAN2, 1); - addEntry("COS", TokenConstants.TCOS, 1); - addEntry("COUNTIF", TokenConstants.TCOUNTIF, 1); - addEntry("DEGREES", TokenConstants.TDEGREES, 1); - addEntry("EXP", TokenConstants.TEXP, 1); - addEntry("FACT", TokenConstants.TFACT, 1); - addEntry("INT", TokenConstants.TINTE, 1); - addEntry("LN", TokenConstants.TLN, 1); - addEntry("LOG10", TokenConstants.TLOG10, 1); - addEntry("MOD", TokenConstants.TMOD, 1); - addEntry("PI", TokenConstants.TPI, 0); - addEntry("POWER", TokenConstants.TPOWERF, 2); - addEntry("RADIANS", TokenConstants.TRADIANS, 1); - addEntry("RAND", TokenConstants.TRAND, 1); - addEntry("ROUND", TokenConstants.TROUND, 1); - addEntry("SQRT", TokenConstants.TSQRT, 1); - addEntry("TAN", TokenConstants.TTAN, 1); - addEntry("SIN", TokenConstants.TSIN, 1); - // Financial - addEntry("SLN", TokenConstants.TSLN, 3); - addEntry("SYD", TokenConstants.TSYD, 4); - // Date and Time - addEntry("DATE", TokenConstants.TDATE, 3); - addEntry("DATEVALUE", TokenConstants.TDATEVALUE, 1); - addEntry("DAY", TokenConstants.TDAY, 1); - addEntry("HOUR", TokenConstants.THOUR, 1); - addEntry("MINUTE", TokenConstants.TMINUTE, 1 ); - addEntry("MONTH", TokenConstants.TMONTH, 1); - addEntry("NOW", TokenConstants.TNOW, 0); - addEntry("SECOND", TokenConstants.TSECOND, 1); - addEntry("TIME", TokenConstants.TTIME, 3); - addEntry("TIMEVALUE", TokenConstants.TTIMEVALUE, 1); - addEntry("YEAR", TokenConstants.TYEAR, 1); - // Statistical - addEntry("COUNTBLANK", TokenConstants.TCOUNTBLANK, 1); - // lookup - addEntry("COLUMNS", TokenConstants.TCOLUMNS, 1); - addEntry("ROWS", TokenConstants.TROWS, 1); - // Database - addEntry("DAVERAGE", TokenConstants.TDAVAERAGE, 3); - addEntry("DCOUNT", TokenConstants.TDCOUNT, 3); - addEntry("DCOUNTA", TokenConstants.TDCOUNTA, 2); - addEntry("DGET", TokenConstants.TDGET, 3); - addEntry("DMAX", TokenConstants.TDMAX, 3); - addEntry("DMIN", TokenConstants.TDMIN, 3); - addEntry("DPRODUCT", TokenConstants.TDPRODUCT, 3); - addEntry("DSTDEV", TokenConstants.TDSTDEV, 3); - addEntry("DSTDEVP", TokenConstants.TDSTDEVP, 3) ; - addEntry("DSUM", TokenConstants.TDSUM, 3); - addEntry("DVAR", TokenConstants.TDVAR, 3); - addEntry("DVARP", TokenConstants.TDVARP, 3); - // Text - addEntry("EXACT", TokenConstants.TEXACT, 2); - addEntry("LEN", TokenConstants.TLEN, 1); - addEntry("LOWER", TokenConstants.TLOWER, 1); - addEntry("MID", TokenConstants.TMID, 3); // ?????? - addEntry("PROPER", TokenConstants.TPROPER, 1); - addEntry("REPLACE", TokenConstants.TREPLACE, 4); - addEntry("REPT", TokenConstants.TREPT, 2); - addEntry("T", TokenConstants.TT, 1); - addEntry("TRIM", TokenConstants.TRIM, 1); - addEntry("UPPER", TokenConstants.TUPPER, 1); - addEntry("VALUE", TokenConstants.TVALUE, 1); - // Logical - addEntry("FALSE", TokenConstants.TFALSE, 0); - addEntry("NOT", TokenConstants.TNOT, 1); - addEntry("TRUE", TokenConstants.TTRUE, 0); - // Informational - addEntry("ERRORTYPE", TokenConstants.TERRORTYPE, 1); - addEntry("ISBLANK", TokenConstants.TISBLANK, 1); - addEntry("ISERR", TokenConstants.TISERR, 1); - addEntry("ISERROR", TokenConstants.TISERROR, 1); - addEntry("ISLOGICAL", TokenConstants.TISLOGICAL, 1); - addEntry("ISNA", TokenConstants.TISNA, 1); - addEntry("ISNONTEXT", TokenConstants.TISNONTEXT, 1); - addEntry("ISNUMBER", TokenConstants.TISNUMBER, 1); - addEntry("ISTEXT", TokenConstants.TISTEXT, 1); - addEntry("N", TokenConstants.TN, 1); - addEntry("NA", TokenConstants.TNA, 0); - - } - - /** - * Associate a function with an identifier and specifiy the number of arguments for that function - * @param symbol The function string that will act as the key in the lookup table - * @param id The identifier for the function - * @param args The number of arguments this function requires - */ - public void addEntry(String symbol, int id, int args) { - addEntry(symbol, id); - stringToArgs.put(symbol, new Integer(args)); - } - - /** - * Retrieve the number of arguments for this function - * @param symbol The function name - * @return The number of arguments required by this function - */ - public int getArgCountFromString(String symbol) { - return stringToArgs.get(symbol).intValue(); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java deleted file mode 100644 index bc4176e8db1a..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperandLookup.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; -import java.util.HashMap; - -/** - * A lookup table containing information about operands - */ -public class OperandLookup extends SymbolLookup { - - /** - * The default constructor - invokes {@link #initialize() initialize()} - */ - public OperandLookup() { - initialize(); - } - - /** - * Initialize the lookup table for operands - */ - public void initialize() { - if ((stringToID != null) || (idToString != null)) { - return; - } - stringToID = new HashMap<String, Integer>(); - idToString = new HashMap<Integer, String>(); - addEntry("CELL_REFERENCE", TokenConstants.TREF); - addEntry("CELL_AREA_REFERENCE", TokenConstants.TAREA); - addEntry("INTEGER", TokenConstants.TNUM); - addEntry("NUMBER", TokenConstants.TNUM); - addEntry("STRING", TokenConstants.TSTRING); - addEntry("NAME", TokenConstants.TNAME); - addEntry("3D_CELL_REFERENCE", TokenConstants.TREF3D); - addEntry("3D_CELL_AREA_REFERENCE", TokenConstants.TAREA3D); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java deleted file mode 100644 index 73d1a850a33a..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/OperatorLookup.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.util.HashMap; - -/** - * A lookup table containing information about operators - */ -public class OperatorLookup extends SymbolLookup { - - /** - * The default constructor - invokes {@link #initialize() initialize()} - */ - public OperatorLookup() { - initialize(); - } - - /** - * Initialize the lookup table for operators - */ - public void initialize() { - if ((stringToID != null) || (idToString != null)) { - return; - } - stringToID = new HashMap<String, Integer>(); - idToString = new HashMap<Integer, String>(); - addEntry("UNARY_PLUS", TokenConstants.TUPLUS); - addEntry("UNARY_MINUS", TokenConstants.TUMINUS); - addEntry("%", TokenConstants.TPERCENT); - addEntry("+", TokenConstants.TADD); - addEntry("-", TokenConstants.TSUB); - addEntry("*", TokenConstants.TMUL); - addEntry("/", TokenConstants.TDIV); - addEntry(",", TokenConstants.TARGSEP); - addEntry("^", TokenConstants.TPOWER); - addEntry("&", TokenConstants.TCONCAT); - addEntry("(", TokenConstants.TPAREN); - addEntry(")", TokenConstants.TCLOSEPAREN); - addEntry("<", TokenConstants.TLESS); - addEntry(">", TokenConstants.TGREATER); - addEntry(">=", TokenConstants.TGTEQUALS); - addEntry("<=", TokenConstants.TLESSEQUALS); - addEntry("=", TokenConstants.TEQUALS); - addEntry("<>", TokenConstants.TNEQUALS); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java deleted file mode 100644 index 6e12dac248df..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/ParseToken.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -public interface ParseToken -{ - public boolean isOperand(); - public boolean isOperator(); - public int getTokenType(); - - //GENERIC TOKENS (MOSTLY UNUSED - public static final int TOKEN_OPERATOR = 1; - public static final int TOKEN_OPERAND = 2; - public static final int TOKEN_FUNCTION_FIXED = 3; - public static final int TOKEN_FUNCTION_VARIABLE = 4; - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java deleted file mode 100644 index 35407090e86d..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/PrecedenceTable.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.util.HashMap; - -/** - * This class defines the precedence applied to each operator when performing a conversion - */ -public class PrecedenceTable { - public static final int DEFAULT_PRECEDENCE = 0; - public static final int EQNEQ_PRECEDENCE = 1; // =, <> - public static final int GTLTEQ_PRECEDENCE = 1; // >=, <= - public static final int GTLT_PRECEDENCE = 2; // >, < - public static final int ADDOP_PRECEDENCE = 4; // +, - - public static final int MULTOP_PRECEDENCE = 5; // *, / - public static final int FACTOR_PRECEDENCE = 6; // ^ - public static final int CONCAT_PRECEDENCE = 6; // & - public static final int UNARY_PRECEDENCE = 7; // !, Unary +, Unary - - public static final int PAREN_PRECEDENCE = 8; // (, ) - public static final int FUNCTION_PRECEDENCE = 8; - public static final int COMMA_PRECEDENCE = 8; - - private static HashMap<String,Integer> map; - static { - map = new HashMap<String,Integer>(); - - map.put("%", new Integer(UNARY_PRECEDENCE)); - map.put("+", new Integer(ADDOP_PRECEDENCE)); - map.put("-", new Integer(ADDOP_PRECEDENCE)); - map.put("*", new Integer(MULTOP_PRECEDENCE)); - map.put("/", new Integer(MULTOP_PRECEDENCE)); - map.put("(", new Integer(PAREN_PRECEDENCE)); - map.put(")", new Integer(PAREN_PRECEDENCE)); - map.put(",", new Integer(COMMA_PRECEDENCE)); - map.put(">", new Integer(GTLT_PRECEDENCE)); - map.put("<", new Integer(GTLT_PRECEDENCE)); - map.put("=", new Integer(EQNEQ_PRECEDENCE)); - map.put("&", new Integer(CONCAT_PRECEDENCE)); - map.put("^", new Integer(FACTOR_PRECEDENCE)); - map.put(">=", new Integer(GTLTEQ_PRECEDENCE)); - map.put("<=", new Integer(GTLTEQ_PRECEDENCE)); - map.put("<>", new Integer(EQNEQ_PRECEDENCE)); - map.put("FUNCTION", new Integer(FUNCTION_PRECEDENCE)); - } - - /** - * Retrieve the precedence value for a given operator. - * @param op Look up the precedence for this operator - * @return an integer representing the integer value of the operator - */ - public static int getPrecedence(String op) { - Object obj = map.get(op); - if (obj == null) { - return DEFAULT_PRECEDENCE; - } - return ((Integer)obj).intValue(); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java deleted file mode 100644 index 251a6e2869da..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.util.HashMap; - -/** - * This interface defines the attributes of a lookup table for this plugin. - * Symbols will generally be either operators (_, -, *, etc) or funtion names. - */ -public abstract class SymbolLookup { - - protected HashMap<String, Integer> stringToID = null; - protected HashMap<Integer, String> idToString = null; - - /** - * Perform lookup table specific initialization. This would typically entail loading values into - * the lookup table. It is best to optimize this process so that data is loaded statically and shared - * across all instances of the lookup table. - */ - abstract public void initialize(); - - /** - * Associate a symbol with a numeric value in the lookup table - * @param symbol The symbol that will act as the key in the lookup table - * @param id The ID number to be associated with a given symbol - */ - public void addEntry(String symbol, int id) { - Integer iObj = new Integer(id); - stringToID.put(symbol, iObj); - idToString.put(iObj, symbol); - } - - /** - * Retrieve the symbol associated with a given identifier - * @param id The identfier for which we need to retieve the symbol string - * @return The string associated with this identifier in the lookup table. - */ - public String getStringFromID(int id) { - return idToString.get(new Integer(id)); - } - - /** - * Retrieve the identifier associated with a given symbol - * @param symbol The symbol for which we need to retieve the identifier - * @throws UnsupportedFunctionException Thown when the symbol is not found in the lookup table - * @return The identifier associated with this string in the lookup table. - */ - public int getIDFromString(String symbol) throws UnsupportedFunctionException { - Integer i = stringToID.get(symbol); - if (i == null) - throw new UnsupportedFunctionException("Token '" + symbol + "' not supported by Pocket Excel"); - - return stringToID.get(symbol).intValue(); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java deleted file mode 100644 index 4526d1efb093..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/Token.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - - -/** - * A Token is the basic building block of any formula. - * A Token can be of four types (Operator, Operand, Function with fixed - * arguments and function with a variable number of arguments. Each type can - * have numerous id's. Thetypes are define in <code>ParseToken</code> and the - * id's are defined in <code>TokenConstants</code>. The other member variables - * are priority which is returned from the <code>PrecedenceTable</code>, the - * value which is the String equivalent of the token (eg. "+", "$A$12", "SUM") - * and the number of arguments which is only valid for operators and functions. - * Tokens should never be created directly and instead are created by the - * <code>TokenFactory</code> - */ -public class Token implements ParseToken { - - private String value; - private int type; // operator, operand, function fixed, function variable - private int id; // cell reference, SUM, integer - private int priority; - private int numArgs=-1; - - public Token(String op, int type, int id, int args) { - this.value = op; - this.type = type; - this.id = id; - this.numArgs = args; - if(type==ParseToken.TOKEN_FUNCTION_VARIABLE) { - priority = PrecedenceTable.getPrecedence("FUNCTION"); - } else if(type==ParseToken.TOKEN_OPERATOR) { - priority = PrecedenceTable.getPrecedence(op); - } else { - priority = PrecedenceTable.getPrecedence("DEFAULT"); - } - } - - /** - * Checks if the current token is an operator - * - * @return A <code>boolean</code> result of the comaparison - */ - public boolean isOperator() { - return type == ParseToken.TOKEN_OPERATOR; - } - - /** - * Checks if the current token is an operand - * - * @return A <code>boolean</code> result of the comaparison - */ - public boolean isOperand() { - return type == ParseToken.TOKEN_OPERAND; - } - - /** - * Checks if the current token is a function - * - * @return A <code>boolean</code> result of the comaparison - */ - public boolean isFunction() { - return (type==ParseToken.TOKEN_FUNCTION_FIXED) || (type==ParseToken.TOKEN_FUNCTION_VARIABLE); - } - - /** - * Returns the token type. This can be one of four values (TOKEN_OPERATOR, - * TOKEN_OPERAND, TOKEN_FUNCTION_FIXED, TOKEN_FUNCTION_VARIABLE) defined in - * <code>ParseToken</code> - * - * @return A <code>boolean</code> result of the comparison - */ - public int getTokenType() { - - return type; - } - - /** - * Returns the ID of this token. This ID is equivalent to the pexcel hex - * value and is defined in <code>ParseToken</code> - * - * @return Returns the id of this token - */ - public int getTokenID() { - - return id; - } - - /** - * Returns the <code>String</code> equivalent of this token - * - * @return The <code>String</code> representing this Token - */ - public String getValue() { - return value; - } - - /** - * Returns the number of arguments if this token represents an operator or - * function. Otherwise returns -1. - * - * @return The number of arguments - */ - public int getNumArgs() { - return numArgs; - } - - /** - * Checks if the current token is an operator - * - * @return A <code>boolean</code> result of the comparison - */ - public int getTokenPriority() { - return priority; - } - - /** - * Returns the <code>String</code> equivalent of this token - * - * @return The <code>String</code> representing this Token - */ - public String toString() { - return getValue(); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java deleted file mode 100644 index fea9b5d7b46b..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenConstants.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -public interface TokenConstants { - - // Unary Operator Tokens - public static final int TUPLUS = 0x12; - public static final int TUMINUS = 0x13; - public static final int TPERCENT = 0x14; - public static final int TPAREN = 0x15; - // Binary Operator Tokens - public static final int TADD = 0x03; - public static final int TSUB = 0x04; - public static final int TMUL = 0x05; - public static final int TDIV = 0x06; - public static final int TPOWER = 0x07; - public static final int TCONCAT = 0x08; - - //Logical operators - public static final int TLESS = 0x09; - public static final int TLESSEQUALS = 0x0A; - public static final int TEQUALS = 0x0B; - public static final int TGTEQUALS = 0x0C; - public static final int TGREATER = 0x0D; - public static final int TNEQUALS = 0x0E; - - // Function Operator Tokens - public static final int TFUNC = 0x41; - public static final int TFUNCVAR = 0x42; - - // Constant Operand Tokens - public static final int TSTRING = 0x17; - public static final int TINT = 0x1E; - public static final int TNUM = 0x1F; - // Operand Tokens - public static final int TREF = 0x44; - public static final int TAREA = 0x25; - public static final int TNAME = 0x23; - public static final int TREF3D = 0x3A; - public static final int TAREA3D = 0x3B; - - // - public static final int TARGSEP = 0x1001; - public static final int TCLOSEPAREN = 0x1002; - - // Variable argument Functions - // Math and Trig - public static final int TSUM = 0x04; - public static final int TPRODUCT = 0xB7; - public static final int TSUMIF = 0x0159; - public static final int TLOG = 0x6D; - public static final int TRUNC = 0xC5; - // Financial - public static final int TDDB = 0x90; - public static final int TFV = 0x39; - public static final int TIRR = 0x3E; - public static final int TNPER = 0x3A; - public static final int TNPV = 0x0B; - public static final int TPMT = 0x3B; - public static final int TPV = 0x38; - public static final int TRATE = 0x3C; - // Statistical - public static final int TAVERAGE = 0x05; - public static final int TCOUNT = 0x00; - public static final int TCOUNTA = 0xA9; - public static final int TMAX = 0x07; - public static final int TMIN = 0x06; - public static final int TSTDEV = 0x0C; - public static final int TSTDEVP = 0xC1; - public static final int TVAR = 0x2E; - public static final int TVARP = 0xC2; - // Lookup - public static final int TCHOOSE = 0x64; - public static final int THLOOKUP = 0x65; - public static final int TINDEX = 0x1D; - public static final int TMATCH = 0x40; - public static final int TVLOOKUP = 0x66; - // Text - public static final int TRIGHT = 0x74; - public static final int TSUBSTITUTE = 0x78; - public static final int TFIND = 0x7c; - public static final int TLEFT = 0x73; - // Logical - public static final int TAND = 0x24; // 42 - public static final int TIF = 0x01; // 42 - public static final int TOR = 0x25; // 42 - - // Fixed argument Functions - // Math and Trig - public static final int TABS = 0x18; - public static final int TACOS = 0x63; - public static final int TASIN = 0x62; - public static final int TATAN = 0x12; - public static final int TATAN2 = 0x61; - public static final int TCOS = 0x10; - public static final int TSIN = 0x0F; - - public static final int TCOUNTIF = 0x015A; - public static final int TDEGREES = 0x0157; - public static final int TEXP = 0x15; - public static final int TFACT = 0xB8; - public static final int TINTE = 0x19; - public static final int TLN = 0x16; - - public static final int TLOG10 = 0x17; - public static final int TMOD = 0x27; - public static final int TPI = 0x13; - - public static final int TPOWERF = 0x0151; - public static final int TRADIANS = 0x0156; - public static final int TRAND = 0x3F; - public static final int TROUND = 0x1B; - public static final int TSQRT = 0x14; - public static final int TTAN = 0x11; - - public static final int TSLN = 0x8E; - public static final int TSYD = 0x8F; - - // Date and Time - public static final int TDATE = 0x41; - public static final int TDATEVALUE = 0x8C; - public static final int TDAY = 0x43; - public static final int THOUR = 0x47; - public static final int TMINUTE = 0x48; - public static final int TMONTH = 0x44; - public static final int TNOW = 0x4A; - public static final int TSECOND = 0x49; - public static final int TTIME = 0x42; - public static final int TTIMEVALUE = 0x8D; - public static final int TYEAR = 0x45; - // Statistical - public static final int TCOUNTBLANK = 0x015B ; - // lookup - public static final int TCOLUMNS = 0x4D; - public static final int TROWS = 0x4C; - // Database - public static final int TDAVAERAGE = 0x2A; - public static final int TDCOUNT = 0x28; - public static final int TDCOUNTA = 0xC7; - public static final int TDGET = 0xEB; - public static final int TDMAX = 0x2C; - public static final int TDMIN = 0x2B; - public static final int TDPRODUCT = 0xBD; - public static final int TDSTDEV = 0x2D; - public static final int TDSTDEVP = 0xC3; - public static final int TDSUM = 0x29; - public static final int TDVAR = 0x2F; - public static final int TDVARP = 0xC4; - // Text - public static final int TEXACT = 0x75; - public static final int TLEN = 0x20; - public static final int TLOWER = 0x70; - public static final int TMID = 0x1F; // ?????? - public static final int TPROPER = 0x72; - public static final int TREPLACE = 0x77; - public static final int TREPT = 0x1E; - public static final int TT = 0x82; - public static final int TRIM = 0x76; - public static final int TUPPER = 0x71; - public static final int TVALUE = 0x21; - // Logical - public static final int TFALSE = 0x23; - public static final int TNOT = 0x26; - public static final int TTRUE = 0x22; - // Informational - public static final int TERRORTYPE = 0x05; - public static final int TISBLANK = 0x81; - public static final int TISERR = 0x7E; - public static final int TISERROR = 0x03; - public static final int TISLOGICAL = 0xC6; - public static final int TISNA = 0x02; - public static final int TISNONTEXT = 0xBE; - public static final int TISNUMBER = 0x80; - public static final int TISTEXT = 0x7F; - public static final int TN = 0x83; - public static final int TNA = 0x0A; -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java deleted file mode 100644 index 36a1cdde38e0..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenDecoder.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; - -/** - * The TokenDecoder decodes a byte[] to an equivalent <code>String</code>. The only - * public method apart from the default constructor is the getTokenVector method. - * This method takes an entire formula as a pexcel byte[] and decodes it into - * a series of <code>Token</code>s. It adds these to a <code>Vector</code> which - * is returned once all the tokens have been decoded. The Decoder supports - * the following tokens.<br><br> - * - * Operands Floating point's, Cell references (absolute and relative), - * cell ranges<br> - * Operators +,-,*,/,<,>.<=,>=,<><br> - * Functions All pexcel fixed and variable argument functions - * - */ -public class TokenDecoder { - - private TokenFactory tf; - private FunctionLookup fl; - private OperatorLookup operatorLookup; - private Workbook wb; - - /** - * Default Constructor initializes the <code>TokenFactory</code> for generating - * <code>Token</code> and the <code>SymbolLookup</code> for generating - * Strings from hex values. - */ - public TokenDecoder() { - tf = new TokenFactory(); - fl = new FunctionLookup(); - operatorLookup = new OperatorLookup(); - } - - /** - * Sets global workbook data needed for defined names - */ - public void setWorkbook(Workbook wb) { - - Debug.log(Debug.TRACE, "TokenDecoder : setWorkbook"); - this.wb = wb; - } - - /** - * Returns a <code>Vector</code> of <code>Token</code> decoded from a - * byte[]. The byte[] is first converted to a - * <code>ByteArrayInputStream</code> as this is the easiest way of reading - * bytes. - * - * @param formula A Pocket Excel Formula byte[] - * @return A <code>Vector</code> of deoded <code>Token</code> - */ - public ArrayList<Token> getTokenVector(byte[] formula) { - - ArrayList<Token> v = new ArrayList<Token>(); - - ByteArrayInputStream bis = new ByteArrayInputStream(formula); - int b = 0 ; - - while ((b = bis.read())!=-1) - { - - - switch (b) { - - case TokenConstants.TAREA3D: - Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: "); - v.add(read3DCellAreaRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded 3D Area Cell Reference: " + last(v)); - break; - case TokenConstants.TREF3D: - Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: "); - v.add(read3DCellRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded 3D Cell Reference: " + last(v)); - break; - case TokenConstants.TREF : - v.add(readCellRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded Cell Reference: " + last(v)); - break; - case TokenConstants.TAREA : - v.add(readCellAreaRefToken(bis)); - Debug.log(Debug.TRACE, "Decoded Cell Area Reference: " + last(v)); - break; - case TokenConstants.TNUM : - v.add(readNumToken(bis)); - Debug.log(Debug.TRACE, "Decoded number : " + last(v)); - break; - case TokenConstants.TFUNCVAR : - v.add(readFunctionVarToken(bis)); - Debug.log(Debug.TRACE, "Decoded variable argument function: " + last(v)); - break; - case TokenConstants.TFUNC : - v.add(readFunctionToken(bis)); - Debug.log(Debug.TRACE, "Decoded function: " + last(v)); - break; - case TokenConstants.TSTRING : - v.add(readStringToken(bis)); - Debug.log(Debug.TRACE, "Decoded string: " + last(v)); - break; - case TokenConstants.TNAME : - v.add(readNameToken(bis)); - Debug.log(Debug.TRACE, "Decoded defined name: " + last(v)); - break; - case TokenConstants.TUPLUS: - case TokenConstants.TUMINUS: - case TokenConstants.TPERCENT: - v.add(readOperatorToken(b, 1)); - Debug.log(Debug.TRACE, "Decoded Unary operator : " + last(v)); - break; - case TokenConstants.TADD : - case TokenConstants.TSUB : - case TokenConstants.TMUL : - case TokenConstants.TDIV : - case TokenConstants.TLESS : - case TokenConstants.TLESSEQUALS : - case TokenConstants.TEQUALS : - case TokenConstants.TGTEQUALS : - case TokenConstants.TGREATER : - case TokenConstants.TNEQUALS : - v.add(readOperatorToken(b, 2)); - Debug.log(Debug.TRACE, "Decoded Binary operator : " + last(v)); - break; - - default : - Debug.log(Debug.TRACE, "Unrecognized byte : " + b); - } - } - return v; - } - - private static Object last(ArrayList<Token> list) - { - return list.get(list.size() - 1); - } - - /** - * Converts a zero based integer to a char (eg. a=0, b=1). - * It assumes the integer is less than 26. - * - * @param i A 0 based index - * @return The equivalent character - */ - private char int2Char(int i) { - return (char) ('A' + i); - } - - /** - * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded String <code>Token</code> - */ - private Token readStringToken(ByteArrayInputStream bis) { - - int len = bis.read()*2; - int options = bis.read(); - Debug.log(Debug.TRACE,"String length is " + len + " and Options Flag is " + options); - byte [] stringBytes = new byte[len]; - int numRead =0; - if ((numRead = bis.read(stringBytes, 0, len)) != len) { - Debug.log(Debug.TRACE,"Expected " + len + " bytes. Could only read " + numRead + " bytes."); - //throw new IOException("Expected " + len + " bytes. Could only read " + numRead + " bytes."); - } - StringBuffer outputString = new StringBuffer(); - outputString.append('"'); - try { - Debug.log(Debug.TRACE,"Using LE encoding"); - outputString.append(new String(stringBytes, "UTF-16LE")); - } catch (IOException eIO) { - outputString.append(new String(stringBytes)); //fall back to default encoding - } - outputString.append('"'); - - return (tf.getOperandToken(outputString.toString(), "STRING")); - } - - /** - * Reads a Defined Name token from the <code>ByteArrayInputStream</code> - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded Name <code>Token</code> - */ - private Token readNameToken(ByteArrayInputStream bis) { - byte buffer[] = new byte[2]; - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int nameIndex = EndianConverter.readShort(buffer); - bis.skip(12); // the next 12 bytes are unused - Iterator<DefinedName> e = wb.getDefinedNames(); - int i = 1; - while(i<nameIndex) { - e.next(); - i++; - } - Debug.log(Debug.TRACE,"Name index is " + nameIndex); - DefinedName dn = e.next(); - Debug.log(Debug.TRACE,"DefinedName is " + dn.getName()); - return (tf.getOperandToken(dn.getName(), "NAME")); - } - - /** - * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded Cell Reference <code>Token</code> - */ - private Token readCellRefToken(ByteArrayInputStream bis) { - - byte buffer[] = new byte[2]; - String outputString = new String(); - - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int formulaRow = EndianConverter.readShort(buffer); - int relativeFlags = (formulaRow & 0xC000)>>14; - formulaRow &= 0x3FFF; - int formulaCol = (byte) bis.read(); - - outputString = int2CellStr(formulaRow, formulaCol, relativeFlags); - - return (tf.getOperandToken(outputString,"CELL_REFERENCE")); - } - - /** - * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded Cell Reference <code>Token</code> - */ - private Token read3DCellRefToken(ByteArrayInputStream bis) { - - byte buffer[] = new byte[2]; - String outputString = new String(); - - bis.skip(10); - - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int Sheet1 = EndianConverter.readShort(buffer); - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int Sheet2 = EndianConverter.readShort(buffer); - - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int formulaRow = EndianConverter.readShort(buffer); - int relativeFlags = (formulaRow & 0xC000)>>14; - formulaRow &= 0x3FFF; - int formulaCol = (byte) bis.read(); - String cellRef = "." + int2CellStr(formulaRow, formulaCol, relativeFlags); - if(Sheet1 == Sheet2) { - outputString = "$" + wb.getSheetName(Sheet1) + cellRef; - } else { - outputString = "$" + wb.getSheetName(Sheet1) + cellRef + ":$" + wb.getSheetName(Sheet2) + cellRef; - } - - return (tf.getOperandToken(outputString,"3D_CELL_REFERENCE")); - } - - /** - * Reads a Cell Reference token from the <code>ByteArrayInputStream</code> - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded Cell Reference <code>Token</code> - */ - private Token read3DCellAreaRefToken(ByteArrayInputStream bis) { - - byte buffer[] = new byte[2]; - String outputString = new String(); - - bis.skip(10); - - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int Sheet1 = EndianConverter.readShort(buffer); - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int Sheet2 = EndianConverter.readShort(buffer); - - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int formulaRow1 = EndianConverter.readShort(buffer); - int relativeFlags1 = (formulaRow1 & 0xC000)>>14; - formulaRow1 &= 0x3FFF; - - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int formulaRow2 = EndianConverter.readShort(buffer); - int relativeFlags2 = (formulaRow2 & 0xC000)>>14; - formulaRow2 &= 0x3FFF; - - int formulaCol1 = (byte) bis.read(); - int formulaCol2 = (byte) bis.read(); - - String cellRef1 = "." + int2CellStr(formulaRow1, formulaCol1, relativeFlags1); - String cellRef2 = int2CellStr(formulaRow2, formulaCol2, relativeFlags2); - - if(Sheet1 == Sheet2) { - outputString = "$" + wb.getSheetName(Sheet1) + cellRef1 + ":" + cellRef2; - } else { - outputString = "$" + wb.getSheetName(Sheet1) + cellRef1 + ":$" + wb.getSheetName(Sheet2) + "." + cellRef2; - } - - return (tf.getOperandToken(outputString,"3D_CELL_AREA_REFERENCE")); - } - - /** - * Converts a row and col 0 based index to a spreadsheet cell reference. - * It also has a relativeFlags which indicates whether or not the - * Cell Reference is relative or absolute (Absolute is denoted with '$') - * - * 00 = absolute row, absolute col - * 01 = absolute row, relative col - * 10 = relative row, absolute col - * 11 = relative row, relative col - * - * @param row The cell reference 0 based index to the row - * @param col The cell reference 0 based index to the row - * @param relativeFlags Flags indicating addressing of row and column - * @return A <code>String</code> representing a cell reference - */ - private String int2CellStr(int row, int col, int relativeFlags) { - String outputString = ""; - int firstChar = (col + 1) / 26; - - if((relativeFlags & 1) == 0) { - outputString += "$"; - } - - if(firstChar>0) { - int secondChar = (col + 1) % 26; - outputString += Character.toString(int2Char(firstChar - 1)) + Character.toString(int2Char(secondChar - 1)); - } else { - outputString += Character.toString(int2Char(col)); - } - if((relativeFlags & 2) == 0) { - outputString += "$"; - } - outputString += Integer.toString(row+1); - return outputString; - } - - /** - * Reads a Cell Area Reference (cell range) <code>Token</code> from - * the <code>ByteArrayInputStream</code> - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The equivalent Cell Area Reference (cell range) - * <code>Token</code> - */ - private Token readCellAreaRefToken(ByteArrayInputStream bis) { - byte buffer[] = new byte[2]; - int formulaRow1, formulaRow2; - int formulaCol1, formulaCol2; - - String outputString = new String(); - - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - formulaRow1 = EndianConverter.readShort(buffer); - int relativeFlags1 = (formulaRow1 & 0xC000)>>14; - formulaRow1 &= 0x3FFF; - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - formulaRow2 = EndianConverter.readShort(buffer); - int relativeFlags2 = (formulaRow2 & 0xC000)>>14; - formulaRow2 &= 0x3FFF; - - formulaCol1 = (byte) bis.read(); - formulaCol2 = (byte) bis.read(); - - outputString = int2CellStr(formulaRow1, formulaCol1, relativeFlags1); - outputString += (":" + int2CellStr(formulaRow2, formulaCol2, relativeFlags2)); - - return (tf.getOperandToken(outputString,"CELL_AREA_REFERENCE")); - } - - - /** - * Reads a Number (floating point) token from the <code>ByteArrayInputStream</code> - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded Integer <code>Token</code> - */ - private Token readNumToken(ByteArrayInputStream bis) { - - byte numBuffer[] = new byte[8]; - - for(int j=0;j<8;j++) { - numBuffer[j]=(byte) bis.read(); - } - - return (tf.getOperandToken(Double.toString(EndianConverter.readDouble(numBuffer)),"NUMBER")); - } - - /** - * Read an Operator token from the <code>ByteArrayInputStream</code> - * - * @param b A Pocket Excel number representing an operator. - * @param args The number of arguments this operator takes. - * @return The decoded Operator <code>Token</code> - */ - private Token readOperatorToken(int b, int args) { - - Token t; - - if(b==TokenConstants.TUPLUS) { - t = tf.getOperatorToken("+", args); - } else if(b==TokenConstants.TUMINUS) { - t = tf.getOperatorToken("-", args); - } else { - t = tf.getOperatorToken(operatorLookup.getStringFromID(b), args); - } - return t; - } - - /** - * Read a Function token from the <code>ByteArrayInputStream</code> - * This function can have any number of arguments and this number is read - * in with the record - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded variable argument Function <code>Token</code> - */ - private Token readFunctionVarToken(ByteArrayInputStream bis) { - - int numArgs = 0; - numArgs = bis.read(); - byte buffer[] = new byte[2]; - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int functionID = EndianConverter.readShort(buffer); - return (tf.getFunctionToken(fl.getStringFromID(functionID),numArgs)); - } - - /** - * Read a Function token from the <code>ByteArrayInputStream</code> - * This function has a fixed number of arguments which it will get - * from <code>FunctionLookup</code>. - * - * @param bis The <code>ByteArrayInputStream</code> from which we read the - * bytes. - * @return The decoded fixed argument Function <code>Token</code> - */ - private Token readFunctionToken(ByteArrayInputStream bis) { - - byte buffer[] = new byte[2]; - buffer[0] = (byte) bis.read(); - buffer[1] = (byte) bis.read(); - int functionID = EndianConverter.readShort(buffer); - String functionName = fl.getStringFromID(functionID); - return (tf.getFunctionToken(functionName,fl.getArgCountFromString(functionName))); - } - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java deleted file mode 100644 index 7c25d6f5f9e9..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenEncoder.java +++ /dev/null @@ -1,536 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.DefinedName; -import org.openoffice.xmerge.converter.xml.sxc.pexcel.records.Workbook; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.EndianConverter; - -/** - * The TokenEncoder encodes a Token to an equivalent pexcel byte[]. The only - * public method apart from the default constructor is the getByte method. - * This method picks an encoder based onthe Token's type or id field and uses - * that encoder to return a byte[] which it returns. This Encoder supports - * Operands Floating point's, Cell references (absolute and relative), - * cell ranges - * Operators +,-,*,/,<,>.<=,>=,<> - * Functions All pexcel fixed and variable argument functions - * - */ -public class TokenEncoder { - - private String parseString; - private int index; - private Workbook wb; - - /** - * Default Constructor - */ - public TokenEncoder() { - parseString = new String(); - } - - /** - * Sets global workbook data needed for defined names - */ - public void setWorkbook(Workbook wb) { - - this.wb = wb; - } - - - /** - * Return the byte[] equivalent of a <code>Token</code>. The various - * encoders return <code>Vector</code> of <code>Byte</code> instead - * of byte[] because the number of bytes returned varies with each - * <code>Token</code> encoded. After the encoding is finished the Vector - * in converted to a byte[]. - * - * @param t The <code>Token</code> to be encoded - * @return An equivalent Pocket Excel byte[] - */ - public byte[] getByte(Token t) throws IOException { - - ArrayList<Byte> tmpByteArray = null; // we use this cause we don't know till after - // the encoding takes place how big the byte [] will be - //index=0; // This class is declared static in - // FormulaHelper so better make sure our index is 0 - if(t.getTokenType()==ParseToken.TOKEN_OPERATOR) { - tmpByteArray = operatorEncoder(t); - } else if (t.getTokenType()==ParseToken.TOKEN_FUNCTION_VARIABLE || t.getTokenType()==ParseToken.TOKEN_FUNCTION_FIXED){ - tmpByteArray = functionEncoder(t); - } else { // Operands and functions - switch(t.getTokenID()) { - case TokenConstants.TNAME : - tmpByteArray = nameDefinitionEncoder(t); - break; - case TokenConstants.TREF3D : - tmpByteArray = threeDCellRefEncoder(t); - break; - case TokenConstants.TAREA3D: - tmpByteArray = threeDAreaRefEncoder(t); - break; - case TokenConstants.TREF : - tmpByteArray = cellRefEncoder(t); - break; - case TokenConstants.TAREA : - tmpByteArray = areaRefEncoder(t); - break; - case TokenConstants.TNUM : - tmpByteArray = numEncoder(t); - break; - case TokenConstants.TSTRING : - tmpByteArray = stringEncoder(t); - break; - default : - Debug.log(Debug.ERROR, "Encoder found unrecognized Token"); - } - } - - byte cellRefArray[] = new byte[tmpByteArray.size()]; - int i = 0; - String s = new String(); - for(Iterator<Byte> e = tmpByteArray.iterator();e.hasNext();) { - Byte tmpByte = e.next(); - s = s + tmpByte + " "; - cellRefArray[i] = tmpByte.byteValue(); - i++; - } - Debug.log(Debug.TRACE, "Encoding Token " + t.getValue() + " as [" + s + "]"); - return cellRefArray; - } - - /** - * An Operator Encoder. - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> operatorEncoder(Token t) { - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - tmpByteArray.add(new Byte((byte)t.getTokenID())); - return tmpByteArray; - } - - - /** - * A String Encoder. - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> stringEncoder(Token t) throws IOException{ - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - tmpByteArray.add(new Byte((byte)t.getTokenID())); - tmpByteArray.add(new Byte((byte)(t.getValue().length()))); - tmpByteArray.add(new Byte((byte)0x01)); - byte [] stringBytes = t.getValue().getBytes("UTF-16LE"); - for (int i=0; i<stringBytes.length; i++) { - tmpByteArray.add(new Byte(stringBytes[i])); - } - return tmpByteArray; - } - - - /** - * An Integer Encoder. - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> numEncoder(Token t) { - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - - double cellLong = Double.parseDouble(t.getValue()); - tmpByteArray.add(new Byte((byte)t.getTokenID())); - byte[] tempByte = EndianConverter.writeDouble(cellLong); - for(int byteIter=0;byteIter<tempByte.length;byteIter++) { - tmpByteArray.add(new Byte(tempByte[byteIter])); - } - return tmpByteArray; - } - - /** - * Converts a char to an int. It is zero based - * so a=0, b=1 etc. - * - * @param ch the character to be converted - * @return -1 if not a character otherwise a 0 based index - */ - private int char2int(char ch) { - if(!Character.isLetter(ch)) - return -1; - - ch = Character.toUpperCase(ch); - return ch-'A'; - } - - /** - * Identify letters - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isAlpha(char c) { - return(Character.isLetter(c)); - } - - /** - * Identify numbers - * - * @param c The character which is to be identified - * @return A boolean returning the result of the comparison - */ - private boolean isDigit(char c) { - return(Character.isDigit(c)); - } - - /** - * Parses a column reference and returns it's integer equivalent. (eg. - * A=0, D=3, BA=27) - * - * @return an 0 based index to a column - */ - private int column() { - char ch = parseString.charAt(index); - String columnStr = new String(); - int col = 0; - - while(isAlpha(ch)) { - columnStr += ch; - index++; - ch = parseString.charAt(index); - } - - if(columnStr.length()==1) { - col = char2int(columnStr.charAt(0)); - } else if (columnStr.length()==2) { - col = char2int(columnStr.charAt(0)) + 1; - col = (col*26) + char2int(columnStr.charAt(1)); - } else { - Debug.log(Debug.ERROR, "Invalid Column Reference " + columnStr ); - } - - - return col; - } - - /** - * Parses a column reference and returns it's integer equivalent. (eg. - * A=0, D=3, BA=27) - * - * @return an 0 based index to a column - */ - private int row() { - char ch = parseString.charAt(index); - String rowStr = new String(); - boolean status = true; - - do { - rowStr += ch; - index++; - if(index>=parseString.length()) { - status = false; - } else { - ch = parseString.charAt(index); - } - } while(isDigit(ch) && status); - return Integer.parseInt(rowStr)-1; // Pexcel uses a 0 based index - } - - /** - * A Cell Reference Encoder (It supports absolute and relative addressing) - * - * @param cellCoordinates <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private byte[] encodeCellCoordinates(String cellCoordinates) { - int col = 0, row = 0; - int addressing = 0xC000; - - index = 0; - parseString = cellCoordinates; - Debug.log(Debug.TRACE,"Encoding cell coordinates " + cellCoordinates); - if(cellCoordinates.charAt(index)=='$') { - addressing &= 0x8000; - index++; - } - col = column(); - if(cellCoordinates.charAt(index)=='$') { - addressing &= 0x4000; - index++; - } - row = row(); // Pexcel uses a 0 based index - row |= addressing; - byte tokenBytes[] = new byte[3]; - tokenBytes[0] = (byte)row; - tokenBytes[1] = (byte)(row>>8); - tokenBytes[2] = (byte)col; - return tokenBytes; - } - - /** - * A name definition Encoder - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> nameDefinitionEncoder(Token t) { - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - - String nameString = t.getValue(); - Debug.log(Debug.TRACE,"NameDefinitionEncoder : " + nameString); - tmpByteArray.add(new Byte((byte)t.getTokenID())); - Iterator<DefinedName> e = wb.getDefinedNames(); - DefinedName dn; - String name; - int definedNameIndex = 0; - do { - dn = e.next(); - name = dn.getName(); - Debug.log(Debug.TRACE,"Name pulled from DefinedName : " + name); - definedNameIndex++; - } while(!nameString.equalsIgnoreCase(name) && e.hasNext()); - - tmpByteArray.add(new Byte((byte)definedNameIndex)); - tmpByteArray.add(new Byte((byte)0x00)); - - for(int i = 0;i < 12;i++) { - tmpByteArray.add(new Byte((byte)0x00)); - } - - return tmpByteArray; - } - /** - * A Cell Reference Encoder. It supports absolute and relative addressing - * but not sheetnames. - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> cellRefEncoder(Token t) { - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - - tmpByteArray.add(new Byte((byte)t.getTokenID())); - byte cellRefBytes[] = encodeCellCoordinates(t.getValue()); - for(int i = 0;i < cellRefBytes.length;i++) { - tmpByteArray.add(new Byte(cellRefBytes[i])); - } - return tmpByteArray; - } - - /** - * This function will find the sheetname index for a given String - * - * @param s <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private short findSheetIndex(String s) { - - short sheetIndex = 0; - String savedName; - String sheetName; - if (s.startsWith("$")) { - sheetName = s.substring(1,s.length()); // Remove $ - } else { - sheetName = s.substring(0,s.length()); - } - Debug.log(Debug.TRACE,"Searching for Worksheet : " + sheetName); - ArrayList<Object> names = wb.getWorksheetNames(); - Iterator<Object> e = names.iterator(); - do { - savedName = (String) e.next(); - sheetIndex++; - } while(!savedName.equalsIgnoreCase(sheetName) && e.hasNext()); - - Debug.log(Debug.TRACE,"Setting sheetindex to " + sheetIndex); - return (short)(sheetIndex-1); - } - - /** - * A 3D Cell reference encoder - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> threeDCellRefEncoder(Token t) { - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - parseString = t.getValue(); - Debug.log(Debug.TRACE,"Encoding 3D Cell reference " + t); - tmpByteArray.add(new Byte((byte)t.getTokenID())); - tmpByteArray.add(new Byte((byte)0xFF)); - tmpByteArray.add(new Byte((byte)0xFF)); - for(int i = 0;i < 8;i++) { - tmpByteArray.add(new Byte((byte)0x00)); - } - - String sheetRef = parseString.substring(0, parseString.indexOf('.') + 1); - if (sheetRef.indexOf(':')!=-1) { - sheetRef = parseString.substring(0, parseString.indexOf(':')); - short sheetNum1 = findSheetIndex(sheetRef); - sheetRef = parseString.substring(parseString.indexOf(':') + 1, parseString.length()); - short sheetNum2 = findSheetIndex(sheetRef); - tmpByteArray.add(new Byte((byte)sheetNum1)); - tmpByteArray.add(new Byte((byte)0x00)); - tmpByteArray.add(new Byte((byte)sheetNum2)); - tmpByteArray.add(new Byte((byte)0x00)); - } else { - sheetRef = parseString.substring(0, parseString.indexOf('.')); - short sheetNum = findSheetIndex(sheetRef); - tmpByteArray.add(new Byte((byte)sheetNum)); - tmpByteArray.add(new Byte((byte)0x00)); - tmpByteArray.add(new Byte((byte)sheetNum)); - tmpByteArray.add(new Byte((byte)0x00)); - } - String s = parseString.substring(parseString.indexOf('.') + 1, parseString.length()); - Debug.log(Debug.TRACE,"Parsing : " + s); - byte cellRefBytes[] = encodeCellCoordinates(s); - for(int i = 0;i < cellRefBytes.length;i++) { - tmpByteArray.add(new Byte(cellRefBytes[i])); - } - return tmpByteArray; - } - /** - * A 3D Area Reference Encoder. - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> threeDAreaRefEncoder(Token t) { - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - parseString = t.getValue(); - Debug.log(Debug.TRACE,"Encoding 3D Area reference " + t); - tmpByteArray.add(new Byte((byte)t.getTokenID())); - tmpByteArray.add(new Byte((byte)0xFF)); - tmpByteArray.add(new Byte((byte)0xFF)); - for(int i = 0;i < 8;i++) { - tmpByteArray.add(new Byte((byte)0x00)); - } - - String param1= parseString.substring(0, parseString.indexOf(':')); - String cellRef1 = param1.substring(parseString.indexOf('.') + 1, param1.length()); - String sheetRef1 = param1.substring(0, param1.indexOf('.')); - short sheetNum1 = findSheetIndex(sheetRef1); - - String param2 = parseString.substring(parseString.indexOf(':') + 1, parseString.length()); - Debug.log(Debug.TRACE,"param2: " + param2); - String cellRef2 = param2.substring(param2.indexOf('.') + 1, param2.length()); - Debug.log(Debug.TRACE,"cellRef2: " + cellRef2); - - if(param2.indexOf('.')==-1) { - tmpByteArray.add(new Byte((byte)sheetNum1)); - tmpByteArray.add(new Byte((byte)0x00)); - tmpByteArray.add(new Byte((byte)sheetNum1)); - tmpByteArray.add(new Byte((byte)0x00)); - } else { - String sheetRef2 = param2.substring(0, param2.indexOf('.')); - short sheetNum2 = findSheetIndex(sheetRef2); - tmpByteArray.add(new Byte((byte)sheetNum1)); - tmpByteArray.add(new Byte((byte)0x00)); - tmpByteArray.add(new Byte((byte)sheetNum2)); - tmpByteArray.add(new Byte((byte)0x00)); - } - - byte cellRefBytes1[] = encodeCellCoordinates(cellRef1); - byte cellRefBytes2[] = encodeCellCoordinates(cellRef2); - - tmpByteArray.add(new Byte(cellRefBytes1[0])); - tmpByteArray.add(new Byte(cellRefBytes1[1])); - - tmpByteArray.add(new Byte(cellRefBytes2[0])); - tmpByteArray.add(new Byte(cellRefBytes2[1])); - - tmpByteArray.add(new Byte(cellRefBytes1[2])); - tmpByteArray.add(new Byte(cellRefBytes2[2])); - - return tmpByteArray; - } - - /** - * A Cell Range Encoder. - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> areaRefEncoder(Token t) { - - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - - tmpByteArray.add(new Byte((byte)t.getTokenID())); - String param = t.getValue(); - String cellRef1 = new String(); - String cellRef2 = new String(); - - if(param.indexOf(':')==-1) { - Debug.log(Debug.ERROR, "Invalid Cell Range, could not find :"); - } else { - cellRef1 = param.substring(0, param.indexOf(':')); - cellRef2 = param.substring(param.indexOf(':') + 1, param.length()); - } - byte cellRefBytes1[] = encodeCellCoordinates(cellRef1); - byte cellRefBytes2[] = encodeCellCoordinates(cellRef2); - - tmpByteArray.add(new Byte(cellRefBytes1[0])); - tmpByteArray.add(new Byte(cellRefBytes1[1])); - - tmpByteArray.add(new Byte(cellRefBytes2[0])); - tmpByteArray.add(new Byte(cellRefBytes2[1])); - - tmpByteArray.add(new Byte(cellRefBytes1[2])); - tmpByteArray.add(new Byte(cellRefBytes2[2])); - - return tmpByteArray; - } - - /** - * A Function Encoder. - * - * @param t <code>Token</code> to be encoded - * @return A <code>Vector</code> of pexcel <code>Byte</code> - */ - private ArrayList<Byte> functionEncoder(Token t) { - ArrayList<Byte> tmpByteArray = new ArrayList<Byte>(); - - int id = t.getTokenID(); - if(t.getTokenType()==ParseToken.TOKEN_FUNCTION_VARIABLE) { - tmpByteArray.add(new Byte((byte)TokenConstants.TFUNCVAR)); - tmpByteArray.add(new Byte((byte)t.getNumArgs())); - } else { - tmpByteArray.add(new Byte((byte)TokenConstants.TFUNC)); - } - - tmpByteArray.add(new Byte((byte)id)); - tmpByteArray.add(new Byte((byte)(id>>8))); - return tmpByteArray; - } - - -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java deleted file mode 100644 index 24f4ced211f6..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/TokenFactory.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -import org.openoffice.xmerge.util.Debug; - -/** - * This is the Factory class responsible for creating a <code>Token</code>. - * It has three methods for returning three different types of Tokens - * (Operator, Operand and Function). - * This utility class is used by either the <code>FormulaParser</code> or the - * <code>FormulaDecoder</code>. - */ -public class TokenFactory { - - private OperatorLookup operatorLookup; - private OperandLookup operandLookup; - private FunctionLookup fl; - - /** - * Default Constructor - */ - public TokenFactory() { - operatorLookup = new OperatorLookup(); - operandLookup = new OperandLookup(); - fl = new FunctionLookup(); - } - - /** - * The Factory method for creating function Tokens - * - * @return The created <code>Token</code> - */ - public Token getFunctionToken(String s, int args) { - Token t = null; - // We will have to fix this later to include fixed function tokens - // Also will need to handle errors where functions names are incorrect??? - Debug.log(Debug.TRACE,"TokenFactory creating function Token : " + s); - try { - t = new Token(s, ParseToken.TOKEN_FUNCTION_VARIABLE, fl.getIDFromString(s), args); - } catch (UnsupportedFunctionException eFn) { - - Debug.log(Debug.ERROR, eFn.getMessage()); - } - return t; - } - - /** - * The Factory method for creating operator Tokens - * - * @return The created <code>Token</code> - */ - public Token getOperatorToken(String s, int args) { - - Token t = null; - - Debug.log(Debug.TRACE,"TokenFactory creating operator Token : " + s); - try { - if(args==1) { - if(s.equals("+")) { - t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString("UNARY_PLUS"), args); - } else if (s.equals("-")) { - t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString("UNARY_MINUS"), args); - } else { - t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString(s), args); - } - } else { - t = new Token(s, ParseToken.TOKEN_OPERATOR, operatorLookup.getIDFromString(s), args); - } - } catch (UnsupportedFunctionException eFn) { - Debug.log(Debug.ERROR, eFn.getMessage()); - } - return t; - } - - /** - * The Factory method for creating Operand Tokens - * - * @return The created <code>Token</code> - */ - public Token getOperandToken(String s, String type) { - Token t = null; - - Debug.log(Debug.TRACE,"TokenFactory creating operand (" + type + ") Token : " + s); - try { - t = new Token(s, ParseToken.TOKEN_OPERAND, operandLookup.getIDFromString(type), 0); - } catch (UnsupportedFunctionException eFn) { - Debug.log(Debug.ERROR, eFn.getMessage()); - } - - return t; - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java deleted file mode 100644 index 606dd12a1afd..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/UnsupportedFunctionException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula; - -/* - * Exception thrown when a function specified in a calc formula has no equivalent in Pocket Excel - * - */ - -public class UnsupportedFunctionException extends Exception { - UnsupportedFunctionException(String message) { - super(message); - } -} diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/package.html b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/package.html deleted file mode 100644 index 9592a999c060..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/package.html +++ /dev/null @@ -1,30 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <title>org.openoffice.xmerge.converter.xml.sxc.pexcel.records.formula package</title> - -</head> - <body bgcolor="white"> - -<p> This package contains the classes necessary for converting pexcel formula -to and from StarCalc Formula.</p> - -</body> -</html> diff --git a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/package.html b/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/package.html deleted file mode 100644 index 2bb4908e1723..000000000000 --- a/xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/package.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<html> -<head> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - <title>org.openoffice.xmerge.converter.xml.sxc.pexcel.records package</title> - -</head> - <body bgcolor="white"> - -<p> This package contains the objects that represent BIFF Records for the -pocket excel format. Each one implements the BIFF Record abstract class which -contains three basic functions (read, write and getBiffType). BIFF Records -which are not used do not contain setter's or getter's for their member -variables as some records have a large number of variables. It should be up -to the implementer which attributes get set and which get set to default -values.</p> - -</body> -</html> diff --git a/xmerge/source/pocketword/converter.xml b/xmerge/source/pocketword/converter.xml deleted file mode 100644 index 7f8e3defd9e6..000000000000 --- a/xmerge/source/pocketword/converter.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> - -<converters> - <converter type="staroffice/sxw" version="1.1"> - <converter-display-name> - Pocket Word - </converter-display-name> - <converter-description> - OpenOffice Writer XML to/from Pocket Word conversion. - </converter-description> - <converter-vendor> - OpenOffice.org - </converter-vendor> - <converter-class-impl> - org.openoffice.xmerge.converter.xml.sxw.pocketword.PluginFactoryImpl - </converter-class-impl> - <converter-target type="application/x-pocket-word"/> - </converter> -</converters> - diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl.java deleted file mode 100644 index 38d9a5829860..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ConverterCapabilitiesImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.OfficeConstants; - -/** - * <p>PocketWord implementation of <code>ConverterCapabilities</code> for - * the {@link - * org.openoffice.xmerge.converter.xml.sxw.pocketword.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>Used with StarWriter XML to/from PocketWord conversions. The - * <code>ConverterCapibilies</code> specify which "Office" - * <code>Document</code> tags and attributes are supported on the - * "Device" <code>Document</code> format.</p> - */ -public final class ConverterCapabilitiesImpl - implements ConverterCapabilities { - - public boolean canConvertTag(String tag) { - - if (OfficeConstants.TAG_OFFICE_DOCUMENT.equals(tag)) - return true; - else if (OfficeConstants.TAG_OFFICE_DOCUMENT_CONTENT.equals(tag)) - return true; - else if (OfficeConstants.TAG_OFFICE_BODY.equals(tag)) - return true; - else if (OfficeConstants.TAG_PARAGRAPH.equals(tag)) - return true; - else if (OfficeConstants.TAG_HEADING.equals(tag)) - return true; - else if (OfficeConstants.TAG_ORDERED_LIST.equals(tag)) - return true; - else if (OfficeConstants.TAG_UNORDERED_LIST.equals(tag)) - return true; - else if (OfficeConstants.TAG_LIST_ITEM.equals(tag)) - return true; - else if (OfficeConstants.TAG_LIST_HEADER.equals(tag)) - return true; - else if (OfficeConstants.TAG_SPAN.equals(tag)) - return true; - else if (OfficeConstants.TAG_HYPERLINK.equals(tag)) - return true; - else if (OfficeConstants.TAG_LINE_BREAK.equals(tag)) - return true; - else if (OfficeConstants.TAG_SPACE.equals(tag)) - return true; - else if (OfficeConstants.TAG_TAB_STOP.equals(tag)) - return true; - - return false; - } - - public boolean canConvertAttribute(String tag, - String attribute) { - - if (OfficeConstants.TAG_SPACE.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_SPACE_COUNT.equals(attribute)) - return true; - } - - return false; - } -} - diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java deleted file mode 100644 index d7cd645c99fa..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; - -import org.openoffice.xmerge.util.EndianConverter; - - -/** - * This class to represent the data structure stored by a Pocket Word file that - * describes that file. - * - * The data structure is of variable length, beginning at the end of the - * font declarations and ending 10 bytes before the first instance of 0xFF 0xFF - * marking a paragraph block. - * - * The variable length component arises from an 8 byte structure describing each - * paragraph in the document. These paragraph descriptors appear at the end - * of the Document Descriptor. - * - * @version 1.1 - */ -class DocumentDescriptor { - private short numParagraphs = 0; - private short length = 0; - private short numLines = 0; - - private ArrayList<ParagraphDescriptor> paragraphDesc = null; - - DocumentDescriptor() { - paragraphDesc = new ArrayList<ParagraphDescriptor>(0); - } - - - - /** - * Updates the <code>DocumentDescriptor</code> to include details of another - * paragraph in the document. - * - * @param len The number of characters in the paragraph. - * @param lines The number of lines on screen that the paragraph uses. - */ - public void addParagraph(short len, short lines) { - ParagraphDescriptor pd = new ParagraphDescriptor(len, lines); - - paragraphDesc.add(pd); - numParagraphs++; - numLines += lines; - length += pd.length; - } - - - /** - * Retrieve the <code>DocumentDescriptor's</code> data. Due to the variable - * length nature of the descriptor, certain fields can only be - * calculated/written after the addition of all paragraphs. - * - * @return Byte array containing the Pocket Word representation of this - * <code>DocumentDescriptor</code>. - */ - public byte[] getDescriptor () { - ByteArrayOutputStream descStream = new ByteArrayOutputStream(); - - writeHeader(descStream); - - /* - * This value seems to increment by 0x02 for each paragraph. - * For a single paragraph doc, the value is 0x08, 0x0A for two, - * 0x0C for three ... - */ - try { - descStream.write(EndianConverter.writeShort((short)(6 + - (numParagraphs * 2)))); - - descStream.write(EndianConverter.writeShort(numParagraphs)); - descStream.write(EndianConverter.writeShort((short)0)); - descStream.write(EndianConverter.writeShort(numParagraphs)); - - descStream.write(EndianConverter.writeShort((short)0)); - descStream.write(EndianConverter.writeShort(length)); - descStream.write(EndianConverter.writeShort((short)0)); - - descStream.write(EndianConverter.writeShort(numLines)); - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 } ); - - for (int i = 0; i < paragraphDesc.size(); i++) { - ParagraphDescriptor pd = paragraphDesc.get(i); - - descStream.write(pd.getDescriptor()); - } - - // Byte sequence marking the end of this DocumentDescriptor - descStream.write(EndianConverter.writeShort((short)0)); - descStream.write(EndianConverter.writeShort((short)0x41)); - } - catch (IOException ioe) { - // Should never happen as this is a memory based stream. - } - - return descStream.toByteArray(); - } - - - /* - * This method loads the intial fixed portion of the descriptor and the - * mid-section. The mid-section is variable but Pocket Word doesn't seem - * to mind default values. - */ - private void writeHeader(OutputStream descStream) { - - try { - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x06, 0x00, - 0x15, 0x00, 0x10, 0x00, - 0x01, 0x00, (byte)0xD0, 0x2F, - 0x00, 0x00, (byte)0xE0, 0x3D, - 0x00, 0x00, (byte)0xF0, 0x00, - 0x00, 0x00, (byte)0xA0, 0x05, - 0x00, 0x00, (byte)0xA0, 0x05, - 0x00, 0x00, (byte)0xA0, 0x05, - 0x00, 0x00, (byte)0xA0, 0x05, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x04, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x08, 0x00, - 0x07, 0x00, 0x10, 0x00, - 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x1F, 0x04, 0x00, 0x00 } ); - - /* - * The next four bytes are variable, but a pattern hasn't yet been - * established. Pocket Word seems to accept this constant value. - * - * The bytes are repeated after another 12 byte sequence which does - * not seem to change from one file to the next. - */ - descStream.write(new byte[] { (byte)0xE2, 0x02, 0x00, 0x00 } ); - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x3D, 0x04, 0x00, 0x00 } ); - descStream.write(new byte[] { (byte)0xE2, 0x02, 0x00, 0x00 } ); - - descStream.write(new byte[] { 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x08, 0x00 } ); - } - catch (IOException ioe) { - /* Shouldn't happen with a ByteArrayOutputStream */ - } - } - - - /** - * <code>ParagraphDescriptor</code> represents the data structure used to - * describe individual paragraphs within a <code>DocumentDescriptor.</code> - * - * It is used solely by the <code>DocumentDescriptor<code> class. - */ - private class ParagraphDescriptor { - private short filler = 0; - private short lines = 0; - private short length = 0; - private short unknown = 0x23; - - public ParagraphDescriptor(short len, short numLines) { - lines = numLines; - length = (short)(len + 1); - } - - public byte[] getDescriptor() { - ByteArrayOutputStream desc = new ByteArrayOutputStream(); - - try { - desc.write(EndianConverter.writeShort(filler)); - desc.write(EndianConverter.writeShort(lines)); - desc.write(EndianConverter.writeShort(length)); - desc.write(EndianConverter.writeShort(unknown)); - } - catch (IOException ioe) { - /* Should never happen */ - } - - return desc.toByteArray(); - } - } -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java deleted file mode 100644 index 7fdb983a1050..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDeserializerImpl.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.StyleCatalog; -import org.openoffice.xmerge.converter.xml.TextStyle; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.util.OfficeUtil; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - - -/** - * <p>Pocket Word implementation of <code>DocumentDeserializer</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.pocketword.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>This converts a Pocket Word file to an OpenOffice Writer XML DOM.</p> - * - * @version 1.1 - */ -public final class DocumentDeserializerImpl - implements DocumentDeserializer, OfficeConstants { - - private PocketWordDocument pswDoc = null; - private SxwDocument sxwDoc = null; - private String docName; - - private StyleCatalog styleCat = null; - - - /** - * Initialises a new <code>DocumentDeserializerImpl</code> using the - * supplied <code>ConvertData</code>.</p> - * - * <p>The <code>Document</code> objects in the <code>ConvertData</code> - * should be {@link - * org.openoffice.xmerge.converter.xml.sxw.pocketword.PocketWordDocument - * PocketWordDocument} objects.</p> - * - * @param cd ConvertData containing a <code>PocketWordDocument</code> - * for conversion. - */ - public DocumentDeserializerImpl(ConvertData cd) { - Iterator<Object> e = cd.getDocumentEnumeration(); - - // A Pocket Word file is composed of one binary file - while (e.hasNext()) { - pswDoc = (PocketWordDocument)e.next(); - } - - docName = pswDoc.getName(); - } - - - /** - * <p>Convert the data passed into the <code>DocumentDeserializer</code> - * constructor into the OpenOffice Writer <code>Document</code> - * format.</p> - * - * <p>This method may or may not be thread-safe. It is expected - * that the user code does not call this method in more than one - * thread. And for most cases, this method is only done once.</p> - * - * @return The resulting <code>Document</code> object from conversion. - * - * @throws ConvertException If any Convert error occurs. - * @throws IOException If any I/O error occurs. - */ - public Document deserialize() throws IOException, ConvertException { - Iterator<Paragraph> pe = pswDoc.getParagraphEnumeration(); - - sxwDoc = new SxwDocument (docName); - sxwDoc.initContentDOM(); - - // Default to an initial 5 entries in the catalog. - styleCat = new StyleCatalog(5); - - try { - buildDocument(pe); - } - catch (Exception e) { - e.printStackTrace(); - throw new ConvertException("Error building OpenOffice Writer DOM: " - + e.toString()); - - } - - return sxwDoc; - } - - - /** - * This method actually takes care of the conversion. - * - * @param data An Enumeration of all Paragraphs in the Pocket Word doc. - * - * @throws IOException If any I/O errors occur. - */ - private void buildDocument(Iterator<Paragraph> data) throws IOException { - - org.w3c.dom.Document doc = sxwDoc.getContentDOM(); - - /* - * There should be only one each of office:body and - * office:automatic-styles in each document. - */ - Node bodyNode = doc.getElementsByTagName(TAG_OFFICE_BODY).item(0); - - // Not every document has an automatic style tag - Node autoStylesNode = doc.getElementsByTagName( - TAG_OFFICE_AUTOMATIC_STYLES).item(0); - if (autoStylesNode == null) { - autoStylesNode = doc.createElement(TAG_OFFICE_AUTOMATIC_STYLES); - doc.insertBefore(autoStylesNode, bodyNode); - } - - - // Needed for naming new styles - int paraStyles = 1; - int textStyles = 1; - - // Pocket Word has no concept of a list. - Element listNode = null; - - - // Down to business ... - while (data.hasNext()) { - Paragraph p = data.next(); - Element paraNode = doc.createElement(TAG_PARAGRAPH); - - // Set paragraph style information here - ParaStyle pStyle = p.makeStyle(); - if (pStyle == null) { - paraNode.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, - PocketWordConstants.DEFAULT_STYLE); - } - else { - // Create paragraph style - pStyle.setName(new String("PS" + paraStyles++)); - paraNode.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, pStyle.getName()); - styleCat.add(pStyle); - } - - - /* - * For each of the paragraphs, process each segment. - * There will always be at least one. - */ - Iterator<ParagraphTextSegment> paraData = p.getSegmentsEnumerator(); - ArrayList<Element> textSpans = new ArrayList<Element>(0); - - do { - ParagraphTextSegment pts = paraData.next(); - Element span = doc.createElement(OfficeConstants.TAG_SPAN); - - TextStyle ts = pts.getStyle(); - - if (ts != null) { - ts.setName(new String("TS" + textStyles++)); - span.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, ts.getName()); - styleCat.add(ts); - } - else { - span.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, - PocketWordConstants.DEFAULT_STYLE); - } - - // If this isn't a blank paragraph - if (pts.getText() != null && !pts.getText().equals("")) { - Node[] children = OfficeUtil.parseText(pts.getText(), doc); - - for (int j = 0; j < children.length; j++) { - span.appendChild(children[j]); - } - } - - textSpans.add(span); - - } while (paraData.hasNext()); - - - /* - * Special case for the first span. If it has no style, then - * it shouldn't be a span, so just add its children with style - * set as standard. - */ - Element firstSpan = textSpans.get(0); - String styleName = firstSpan.getAttribute(ATTRIBUTE_TEXT_STYLE_NAME); - if (styleName.equals(PocketWordConstants.DEFAULT_STYLE)) { - NodeList nl = firstSpan.getChildNodes(); - int len = nl.getLength(); - - for (int i = 0; i < len; i++) { - /* - * Always take item 0 as the DOM tree event model will - * cause the NodeList to shrink as each Node is reparented. - * - * By taking the first item from the list, we essentially - * traverse the list in order. - */ - paraNode.appendChild(nl.item(0)); - } - } - else { - paraNode.appendChild(firstSpan); - } - - // The rest are spans, so just add them - for (int i = 1; i < textSpans.size(); i++) { - paraNode.appendChild(textSpans.get(i)); - } - - - /* - * Pocket Word doesn't support lists, but it does have bulleted - * paragraphs that are essentially the same thing. - * - * Unlike OpenOffice Writer, a blank paragraph can be bulleted - * as well. This will be handled by inserting a blank paragraph - * into the unordered list, but OpenOffice Writer will not display - * an item at that point in the list. - */ - if (p.isBulleted()) { - if (listNode == null) { - listNode = doc.createElement(TAG_UNORDERED_LIST); - } - Element listItem = doc.createElement(TAG_LIST_ITEM); - listItem.appendChild(paraNode); - listNode.appendChild(listItem); - } - else { - if (listNode != null) { - bodyNode.appendChild(listNode); - listNode = null; - } - bodyNode.appendChild(paraNode); - } - } // End processing paragraphs - - - // Now write the style catalog to the document - NodeList nl = styleCat.writeNode(doc, "dummy").getChildNodes(); - int nlLen = nl.getLength(); // nl.item reduces the length - for (int i = 0; i < nlLen; i++) { - autoStylesNode.appendChild(nl.item(0)); - } - } -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl.java deleted file mode 100644 index b268836a9a24..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentMergerImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import org.w3c.dom.Document; - -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.MergeException; -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.merger.DiffAlgorithm; -import org.openoffice.xmerge.merger.Difference; -import org.openoffice.xmerge.merger.NodeMergeAlgorithm; -import org.openoffice.xmerge.merger.Iterator; -import org.openoffice.xmerge.merger.diff.ParaNodeIterator; -import org.openoffice.xmerge.merger.diff.IteratorLCSAlgorithm; -import org.openoffice.xmerge.merger.merge.DocumentMerge; -import org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge; -import org.openoffice.xmerge.util.Debug; - - -/** - * PocketWord implementation of <code>DocumentMerger</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.pocketword.PluginFactoryImpl - * PluginFactoryImpl}.</p> - */ -public class DocumentMergerImpl implements DocumentMerger { - - private ConverterCapabilities cc_; - private org.openoffice.xmerge.Document orig = null; - - public DocumentMergerImpl(org.openoffice.xmerge.Document doc, ConverterCapabilities cc) { - cc_ = cc; - this.orig = doc; - } - - public void merge(org.openoffice.xmerge.Document modifiedDoc) throws MergeException { - - SxwDocument wdoc1 = (SxwDocument) orig; - SxwDocument wdoc2 = (SxwDocument) modifiedDoc; - - Document doc1 = wdoc1.getContentDOM(); - Document doc2 = wdoc2.getContentDOM(); - - Iterator i1 = new ParaNodeIterator(cc_, doc1.getDocumentElement()); - Iterator i2 = new ParaNodeIterator(cc_, doc2.getDocumentElement()); - - DiffAlgorithm diffAlgo = new IteratorLCSAlgorithm(); - - // find out the paragrah level diffs - Difference[] diffTable = diffAlgo.computeDiffs(i1, i2); - - if (Debug.isFlagSet(Debug.INFO)) { - Debug.log(Debug.INFO, "Diff Result: "); - - for (int i = 0; i < diffTable.length; i++) { - Debug.log(Debug.INFO, diffTable[i].debug()); - } - } - - // merge the paragraphs - NodeMergeAlgorithm charMerge = new CharacterBaseParagraphMerge(); - DocumentMerge docMerge = new DocumentMerge(cc_, charMerge); - - docMerge.applyDifference(i1, i2, diffTable); - } -} - - diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java deleted file mode 100644 index ba67a1dbbd97..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentSerializerImpl.java +++ /dev/null @@ -1,413 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.NamedNodeMap; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.DocumentSerializer; - -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; - -import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.TextStyle; -import org.openoffice.xmerge.converter.xml.StyleCatalog; - -import java.io.IOException; - -/** - * <p>Pocket Word implementation of <code>DocumentDeserializer</code> - * for use by {@link - * org.openoffice.xmerge.converter.xml.sxw.pocketword.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>This converts an OpenOffice Writer XML files to a Pocket Word file<.</p> - * - * @version 1.1 - */ -public final class DocumentSerializerImpl - implements DocumentSerializer, OfficeConstants { - - private PocketWordDocument pswDoc; - private SxwDocument sxwDoc; - - private StyleCatalog styleCat = null; - - private boolean inList = false; - - /** - * <p>Initialises a new <code>DocumentSerializerImpl</code> using the.<br> - * supplied <code>Document</code></p> - * - * <p>The supplied document should be an {@link - * org.openoffice.xmerge.converter.xml.sxw.SxwDocument SxwDocument} - * object.</p> - * - * @param doc The <code>Document</code> to convert. - */ - public DocumentSerializerImpl(Document doc) { - sxwDoc = (SxwDocument)doc; - pswDoc = new PocketWordDocument(sxwDoc.getName()); - } - - /** - * <p>Convert the data passed into the <code>DocumentSerializerImpl</code> - * constructor into Pocket Word format.</p> - * - * <p>This method may or may not be thread-safe. It is expected - * that the user code does not call this method in more than one - * thread. And for most cases, this method is only done once.</p> - * - * @return <code>ConvertData</code> object to pass back the - * converted data. - * - * @throws ConvertException If any conversion error occurs. - * @throws IOException If any I/O error occurs. - */ - public ConvertData serialize() throws IOException, ConvertException { - ConvertData cd = new ConvertData(); - - org.w3c.dom.Document doc = sxwDoc.getContentDOM(); - - // Load any style info before traversing the document content tree - loadStyles(); - - NodeList list = doc.getElementsByTagName(TAG_OFFICE_BODY); - - int len = list.getLength(); - if (len > 0) { - Node node = list.item(0); - traverseBody(node); - } - - cd.addDocument(pswDoc); - - return cd; - } - - /* - * Handles the loading of defined styles from the style.xml file as well - * as automatic styles from the content.xml file. - * - * Any change to a defined style, such as a short bold section, falls into - * the latter category. - */ - private void loadStyles() { - org.w3c.dom.Document contentDom = sxwDoc.getContentDOM(); - org.w3c.dom.Document styleDom = sxwDoc.getStyleDOM(); - - styleCat = new StyleCatalog(25); - - NodeList nl = null; - String families[] = new String[] { PocketWordConstants.TEXT_STYLE_FAMILY, - PocketWordConstants.PARAGRAPH_STYLE_FAMILY, - PocketWordConstants.PARAGRAPH_STYLE_FAMILY }; - Class<?> classes[] = new Class[] { TextStyle.class, - ParaStyle.class, - TextStyle.class }; - - String[] styleTypes = new String[] { TAG_OFFICE_STYLES, - TAG_OFFICE_AUTOMATIC_STYLES, - TAG_OFFICE_MASTER_STYLES }; - - /* - * Documents converted from PSW -> SXW will not have a style.xml when - * being converted back to PSW. This would occur if a document was - * not modified within Writer between conversions. - * - * Any Writer modifications and saves create the style.xml and other - * portions of a complete Writer SXW file. - */ - if (styleDom != null) { - // Process the Style XML tree - for (int i = 0; i < styleTypes.length; i++ ) { - nl = styleDom.getElementsByTagName(styleTypes[i]); - if (nl.getLength() != 0) { - styleCat.add(nl.item(0), families, classes, null, false); - } - } - } - - /* - * Process the content XML for any other style info. - * Should only be automatic types here. - */ - for (int i = 0; i < styleTypes.length; i++ ) { - nl = contentDom.getElementsByTagName(styleTypes[i]); - if (nl.getLength() != 0) { - styleCat.add(nl.item(0), families, classes, null, false); - } - } - } - - /* - * Process the office:body tag. - */ - private void traverseBody(Node node) throws IOException, ConvertException { - - if (node.hasChildNodes()) { - NodeList nList = node.getChildNodes(); - int len = nList.getLength(); - - for (int i = 0; i < len; i++) { - Node child = nList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH) - || nodeName.equals(TAG_HEADING)) { - traverseParagraph(child); - } - - if (nodeName.equals(TAG_UNORDERED_LIST) || - nodeName.equals(TAG_ORDERED_LIST)) { - traverseList(child); - } - } - } - } - } - - /* - * Process a text:p tag - */ - private void traverseParagraph(Node node) throws IOException, ConvertException { - String styleName = getAttribute(node, ATTRIBUTE_TEXT_STYLE_NAME); - - ParaStyle pstyle = (ParaStyle)styleCat.lookup(styleName, - PocketWordConstants.PARAGRAPH_STYLE_FAMILY, null, - ParaStyle.class); - if (pstyle != null) { - pstyle = (ParaStyle)pstyle.getResolved(); - } - - TextStyle tstyle = (TextStyle)styleCat.lookup(styleName, - PocketWordConstants.PARAGRAPH_STYLE_FAMILY, null, - TextStyle.class); - if (pstyle != null) { - tstyle = (TextStyle)tstyle.getResolved(); - } - - try { - pswDoc.addParagraph(pstyle, inList); - } - catch (Exception e) { - throw new ConvertException( - "Error adding paragraph to PocketWordDocument.\n" - + e.toString()); - } - - traverseParagraphContents(node, tstyle); - } - - /* - * Process the contents of a paragraph. This method handles situations - * where the paragraph contains multiple children, each representing a - * differently formatted piece of text. - */ - private void traverseParagraphContents (Node node, TextStyle defTextStyle) - throws IOException, ConvertException { - // First up, get the style of this little bit - String styleName = getAttribute(node, ATTRIBUTE_TEXT_STYLE_NAME); - TextStyle tStyle = (TextStyle)styleCat.lookup(styleName, - PocketWordConstants.TEXT_STYLE_FAMILY, null, - TextStyle.class); - - if (tStyle == null) { - tStyle = defTextStyle; - } - - if (node.hasChildNodes()) { - NodeList nList = node.getChildNodes(); - int len = nList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nList.item(i); - short nodeType = child.getNodeType(); - - switch (nodeType) { - case Node.TEXT_NODE: - String s = child.getNodeValue(); - if (s.length() > 0) { - try { - pswDoc.addParagraphData(s, tStyle); - } - catch (Exception e) { - throw new ConvertException( - "Error adding data to paragraph in " + - "PocketWordDocument.\n" + e.toString()); - - } - } - break; - - case Node.ELEMENT_NODE: - if (child.getNodeName().equals(TAG_SPACE)) { - StringBuffer sb = new StringBuffer(""); - int count = 1; - - NamedNodeMap map = child.getAttributes(); - - if (map.getLength() > 0) { - Node attr = map.getNamedItem(ATTRIBUTE_SPACE_COUNT); - count = Integer.parseInt(attr.getNodeValue().trim()); - } - - for ( ; count > 0; count--) { - sb.append(" "); - } - - /* - * May want to look at style info for spaces. Could - * be important when calculating font metrics. - */ - try { - pswDoc.addParagraphData(sb.toString(), tStyle); - } - catch (Exception e) { - throw new ConvertException( - "Error adding data to paragraph in " + - "PocketWordDocument.\n" + e.toString()); - - } - } - else if (child.getNodeName().equals(TAG_TAB_STOP)) { - try { - pswDoc.addParagraphData("\t", tStyle); - } - catch (Exception e) { - throw new ConvertException( - "Error adding data to paragraph in " + - "PocketWordDocument.\n" + e.toString()); - - } - } - else if (child.getNodeName().equals(TAG_LINE_BREAK)) { - /* - * Pocket Word does not support soft line breaks. - * They are just new paragraphs. - */ - } - else if (child.getNodeName().equals(TAG_SPAN)) { - /* - * This is where the interesting ones, i.e. format - * changes occur. - */ - traverseParagraphContents (child, defTextStyle); - } - else if (child.getNodeName().equals(TAG_HYPERLINK)) { - traverseParagraphContents (child, defTextStyle); - } - else { - // Should maybe have a default in here. - } - break; - default: - // Do nothing - } - } - } - else { - /* - * If the node has no children, then it is a blank paragraph, but - * they still require an entry in the Paragraph class to make sense. - */ - pswDoc.addParagraphData("", tStyle); - } - } - - /* - * Process a text:ordered-list or text:unordered-list tag. Pocket Word has - * no concept of a list so there is no need to differentiate between the - * two. - * - * Each item on the list contains a text:p node. - */ - private void traverseList (Node node) throws IOException, ConvertException { - inList = true; - - if (node.hasChildNodes()) { - NodeList nList = node.getChildNodes(); - int len = nList.getLength(); - - for (int i = 0; i < len; i++) { - Node child = nList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_LIST_ITEM)) { - traverseListItem(child); - } - } - } - } - - inList = false; - } - - /* - * Process a text:list-item node. They usually contain have a single - * text:p child but can also have sections or other lists. - * - * For this case, only paragraphs are supported. - */ - private void traverseListItem (Node node) throws IOException, ConvertException { - if (node.hasChildNodes()) { - NodeList nList = node.getChildNodes(); - int len = nList.getLength(); - - for (int i = 0; i < len; i++) { - Node child = nList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH)) { - traverseParagraph(child); - } - } - } - } - - } - - /* - * Utility method to retrieve a Node attribute. - */ - private String getAttribute (Node node, String attribute) { - NamedNodeMap attrNodes = node.getAttributes(); - - if (attrNodes != null) { - Node attr = attrNodes.getNamedItem(attribute); - if (attr != null) { - return attr.getNodeValue(); - } - } - - return null; - } -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java deleted file mode 100644 index 2871a2670a14..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/Paragraph.java +++ /dev/null @@ -1,843 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import java.awt.Color; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.TextStyle; -import org.openoffice.xmerge.util.ColourConverter; -import org.openoffice.xmerge.util.EndianConverter; - - -/** - * Represents a paragraph data structure within a Pocket Word document. - * - * @version 1.1 - */ -class Paragraph implements PocketWordConstants { - /* - * The data elements of a Paragraph. - * - * As the 'unknown' values are not calculated they are declared static. - * They are not declared final because they do have a calcuable value. - */ - private static short unknown1 = 0x23; - private short dataWords = 0; - private short textLength = 0; - private short lengthWithFormatting = 0; - private short lines = 0; - - private static final short marker = (short)0xFFFF; - private static int unknown2 = 0x22; // May be two short values - - private short specialIndentation = 0; - private short leftIndentation = 0; - private short rightIndentation = 0; - - private byte bullets = 0; - private byte alignment = 0; - - private static int unknown3 = 0; - - // Will always have at least these formatting settings in each paragraph - private short defaultFont = 2; // Courier New for the time being - private short defaultSize = 10; - - - /* - * Remaining elements assist in calculating correct values for the paragraph - * representation. - */ - - private ArrayList<ParagraphTextSegment> textSegments = null; - - private ArrayList<LineDescriptor> lineDescriptors = null; - - private ParaStyle pStyle = null; - - private boolean isLastParagraph = false; - - - /* - * Private class constructor used by all constructors. Ensures the proper - * initialisation of the Vector storing the paragraph's text. - */ - private Paragraph () { - textSegments = new ArrayList<ParagraphTextSegment>(); - } - - - /** - * <p>Constructor for use when converting from SXW format to Pocket Word - * format.</p> - * - * @param style Paragraph style object describing the formatting style - * of this paragraph. - */ - public Paragraph (ParaStyle style) { - this(); - - lineDescriptors = new ArrayList<LineDescriptor>(); - pStyle = style; - } - - - /** - * <p>Constructor for use when converting from Pocket Word format to SXW - * format.</p> - * - * @param data Byte array containing byte data describing this paragraph - * from the Pocket Word file. - */ - public Paragraph (byte[] data) { - this(); - - /* - * Read in all fixed data from the array - * - * unknown1 appears at data[0] and data[1] - */ - dataWords = EndianConverter.readShort(new byte[] { data[2], data[3] } ); - textLength = EndianConverter.readShort(new byte[] { data[4], data [5] } ); - lengthWithFormatting = EndianConverter.readShort( - new byte[] { data[6], data[7] } ); - lines = EndianConverter.readShort(new byte[] { data[8], data [9] } ); - - /* - * The marker appears at data[10] and data[11]. - * - * The value of unknown2 is at data[12], data[13], data[14] and data[15]. - */ - - specialIndentation = EndianConverter.readShort(new byte[] { data[16], data[17] } ); - leftIndentation = EndianConverter.readShort(new byte[] { data[18], data [19] } ); - rightIndentation = EndianConverter.readShort(new byte[] { data[20], data [21] } ); - - bullets = data[22]; - alignment = data[23]; - - // The value of unknown3 is at data[24], data[25], data[26] and data[27]. - - /* - * The actual paragraph data is in the remainder of the byte sequence. - * - * Only the actual text seqence with the embedded formatting tags is - * relevant to the conversion from Pocket Word to SXW format. - */ - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - bos.write(data, 28, lengthWithFormatting); - parseText(bos.toByteArray()); - } - - - /* - * Processes the text portion of the raw paragraph data from the Pocket Word - * file. This data also includes formatting settings for the text in the - * paragraph. - * - * Formatting changes appear like XML/HTML tags. Formatted blocks are - * preceded by a sequence of bytes switching on a formatting change and - * followed by a sequence switching off that formatting change. - */ - private void parseText (byte[] data) { - - int totalLength = data.length; - - StringBuffer sb = new StringBuffer(""); - - // Setup text style information - int mask = TextStyle.BOLD | TextStyle.ITALIC | TextStyle.UNDERLINE - | TextStyle.STRIKETHRU; - - - String fontName = null; - int fontSize = 0; - Color textColour = null; - Color backColour = null; - int modifiers = 0; - - TextStyle ts = null; - - int attrsSet = 0; // If this is 0, we have no extra style - boolean inSequence = false; - boolean sawText = false; - - // Start from the very beginning - for (int i = 0; i < totalLength; i++) { - // Will encounter at least two codes first - if ((byte)(data[i] & 0xF0) == FORMATTING_TAG) { - if (sawText) { - // Style change so dump previous segment and style info - addTextSegment(sb.toString(), ts); - sb = new StringBuffer(""); - sawText = false; - } - - switch (data[i]) { - case FONT_TAG: - int index = EndianConverter.readShort( - new byte[] { data[i + 1], data[i + 2] } ); - - /* - * Standard font. - * - * Should really be one, but as the only supported font - * currently is Courier New, want to leave it at Courier - * New for round trip conversions. - * - * Also need to account for the fact that Tahoma is the - * correct standard font. - */ - if (fontName == null || fontName.equals("2")) { - if (index != 2 && index != 1) { - fontName = String.valueOf(index); - attrsSet++; - } - } - else { - // Font is set, but not the default - if (index == 2 || index == 1) { - fontName = "2"; - attrsSet--; - } - else { - fontName = String.valueOf(index); - } - } - i += 2; - break; - - - case FONT_SIZE_TAG: - int size = EndianConverter.readShort( - new byte[] { data[i + 1], data[i + 2] } ); - - if (size == 0) { - // Flags the end of the last paragraph - isLastParagraph = true; - i += 2; - break; - } - - // Standard size - if (fontSize == 0 || fontSize == 10) { - if (size != 10) { - fontSize = size; - attrsSet++; - } - } - else { - // Font size is set, but not to standard - if (size == 10) { - fontSize = 10; - attrsSet--; - } - else { - fontSize = size; - } - } - i += 2; - break; - - - case COLOUR_TAG: - if (data[i + 1] != 0) { - ColourConverter cc = new ColourConverter(); - textColour = cc.convertToRGB( - EndianConverter.readShort(new byte[] { data[i + 1], - data[i + 2] } )); - attrsSet++; - } - else { - textColour = null; - attrsSet--; - } - i += 2; - break; - - - case FONT_WEIGHT_TAG: - if (data[i + 1] == FONT_WEIGHT_BOLD - || data[i + 1] == FONT_WEIGHT_THICK) { - modifiers |= TextStyle.BOLD; - attrsSet++; - } - else { - // Its a bit field so subtracting should work okay. - modifiers ^= TextStyle.BOLD; - attrsSet--; - } - i += 2; - break; - - - case ITALIC_TAG: - if (data[i + 1] == (byte)0x01) { - modifiers |= TextStyle.ITALIC; - attrsSet++; - } - else { - modifiers ^= TextStyle.ITALIC; - attrsSet--; - } - i++; - break; - - - case UNDERLINE_TAG: - if (data[i + 1] == (byte)0x01) { - modifiers |= TextStyle.UNDERLINE; - attrsSet++; - } - else { - modifiers ^= TextStyle.UNDERLINE; - attrsSet--; - } - i++; - break; - - - case STRIKETHROUGH_TAG: - if (data[i + 1] == (byte)0x01) { - modifiers |= TextStyle.STRIKETHRU; - attrsSet++; - } - else { - modifiers ^= TextStyle.STRIKETHRU; - attrsSet--; - } - i++; - break; - - case HIGHLIGHT_TAG: - /* - * Highlighting is treated by OpenOffice as a - * background colour. - */ - if (data[i + 1] == (byte)0x01) { - backColour = Color.yellow; - attrsSet++; - } - else { - backColour = null; - attrsSet--; - } - i++; - break; - } - - inSequence = true; - continue; - } - - if (inSequence) { - // Style information has been changed. Create new style here - - inSequence = false; - if (attrsSet > 0) { - ts = new TextStyle(null, TEXT_STYLE_FAMILY, DEFAULT_STYLE, - mask, modifiers, fontSize, fontName, null); - ts.setColors(textColour, backColour); - } - else { - ts = null; - } - } - - /* - * C4 xx seems to indicate a control code. C4 00 indicates the end - * of a paragraph; C4 04 indicates a tab space. Only these two - * have been seen so far. - */ - if (data[i] == (byte)0xC4) { - /* - * Redundant nodes are sometimes added to the last paragraph - * because a new sequence is being processed when the flag is - * set. - * - * To avoid this, do nothing with the last paragraph unless no - * text has been added for it already. In that case, add the - * empty text segment being process to ensure that all - * paragraphs have at least one text segment. - */ - if (data[i + 1] == (byte)0x00) { - if (isLastParagraph && textSegments.size() > 0) { - return; - } - addTextSegment(sb.toString(), ts); - return; - } - sb.append("\t"); - sawText = true; - i++; - continue; - } - - sb.append((char)data[i]); - sawText = true; - } - } - - - /** - * <p>Adds details of a new text block to the <code>Paragraph</code> object. - * </p> - * - * @param text The text of the new block. - * @param style Text style object describing the formatting attached - * to this block of text. - */ - public void addTextSegment(String text, TextStyle style) { - textLength += text.length(); - textSegments.add(new ParagraphTextSegment(text, style)); - } - - - /** - * <p>This method alters the state of the <code>Paragraph</code> object to - * indicate whether or not it is the final paragraph in the document.</p> - * - * <p>It is used during conversion from SXW format to Pocket Word format. - * In Pocket Word files, the last paragraph finishes with a different byte - * sequence to other paragraphs.</p> - * - * @param isLast true if the Paragraph is the last in the document, - * false otherwise. - */ - public void setLastParagraph(boolean isLast) { - isLastParagraph = isLast; - } - - - /** - * <p>Complementary method to {@link #setLastParagraph(boolean) - * setLastParagraph}. Returns the terminal status of this - * <code>Paragraph</code> within the Pocket Word document.</p> - * - * @return true if the Paragraph is the last in the document; false otherwise. - */ - public boolean getLastParagraph () { - return isLastParagraph; - } - - - /** - * <p>This method returns the Pocket Word representation of this - * <code>Paragraph</code> in Little Endian byte order.</p> - * - * <p>Used when converting from SXW format to Pocket Word format.</p> - * - * @return <code>byte</code> array containing the formatted representation - * of this Paragraph. - */ - public byte[] getParagraphData() { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - postProcessText(); - - /* - * Need information about the paragraph segments in two places - * so calculate them first. - * - * The stream contains the text wrapped in any formatting sequences that - * are necessary. - */ - ByteArrayOutputStream segs = new ByteArrayOutputStream(); - - try { - for (int i = 0; i < textSegments.size(); i++) { - ParagraphTextSegment pts = textSegments.get(i); - segs.write(pts.getData()); - } - } - catch (IOException ioe) { - // Should never happen in a memory based stream - } - - /* - * Number of data words for this paragraph descriptor: - * - * 26 is the number of bytes prior to the start of the segment. - * 3 comes from the C4 00 00 termintating sequence. - */ - dataWords = (short)(26 + segs.size() + 3 + 4); - if (isLastParagraph) { - dataWords += 6; - } - if (dataWords % 4 != 0) { - dataWords += (4 - (dataWords % 4)); - } - dataWords /= 4; - - /* - * The 8 bytes are made up of E6 ?0 00 and E5 ?0 00 at the start of the - * text along with the C4 00 that terminates it. - * - * In the event that the paragraph is the last one E6 00 00 is also - * present at the end of the text. Also, as we currently use a font - * other than the first in the index (Tahoma) E5 01 00 is also present. - * - * Make sure this is accurate when font specifications change - */ - lengthWithFormatting = (short)(segs.size() + (isLastParagraph ? 14 : 8)); - - try { - bos.write(EndianConverter.writeShort(unknown1)); - bos.write(EndianConverter.writeShort(dataWords)); - bos.write(EndianConverter.writeShort((short)(textLength + 1))); - bos.write(EndianConverter.writeShort(lengthWithFormatting)); - bos.write(EndianConverter.writeShort(lines)); - - bos.write(EndianConverter.writeShort(marker)); - bos.write(EndianConverter.writeInt(unknown2)); - - bos.write(EndianConverter.writeShort(specialIndentation)); - bos.write(EndianConverter.writeShort(leftIndentation)); - bos.write(EndianConverter.writeShort(rightIndentation)); - - bos.write(bullets); - - if (pStyle != null && pStyle.isAttributeSet(ParaStyle.TEXT_ALIGN)) { - switch (pStyle.getAttribute(ParaStyle.TEXT_ALIGN)) { - - case ParaStyle.ALIGN_RIGHT: - bos.write(0x01); - break; - - case ParaStyle.ALIGN_CENTER: - bos.write(0x02); - break; - - default: - bos.write(0x00); // Left align in all other circumstances - break; - } - } - else { - bos.write(0x00); - } - - bos.write(EndianConverter.writeInt(unknown3)); - - - /* - * Write out font and size. - * - * If font support is added then this should change as the information - * will have to be calculated from a Font table. - */ - bos.write(FONT_TAG); - bos.write(EndianConverter.writeShort(defaultFont)); - bos.write(FONT_SIZE_TAG); - bos.write(EndianConverter.writeShort(defaultSize)); - - // Write out the text segments - bos.write(segs.toByteArray()); - - /* - * If this is the last paragraph in the document then we need to make - * sure that the paragraph text is terminated correctly with an E6 00 00 - * before the C4 00 00. - */ - if (isLastParagraph) { - if (defaultFont != 1) { - // Must always go back to the first font. - bos.write(FONT_TAG); - bos.write(EndianConverter.writeShort((short)0x01)); - } - bos.write(FONT_SIZE_TAG); - bos.write(EndianConverter.writeShort((short)0x00)); - } - - bos.write(new byte[] { (byte)0xC4, 0x00, 0x00 } ); - - int padding = 0; - if (bos.size() % 4 != 0) { - padding = 4 - (bos.size() % 4); - } - for (int i = 0; i < padding; i++) { - bos.write(0x00); - } - - // Third byte should match first byte after 0xFF 0xFF - bos.write(new byte[] { 0x42, 0x00, 0x22, 0x00} ); - - /* - * Meaning of last two bytes seems to be the number of words describing - * lines. This is calculated at 10 bytes per descriptor. - * - * May have two extra padding bytes that need to be accounted for too - * The division below may lose 2 bytes (integer result). - */ - int wordsRemaining = (lineDescriptors.size() * 10) / 4; - if ((lineDescriptors.size() * 10) % 4 != 0) { - wordsRemaining++; - } - bos.write(EndianConverter.writeShort((short)wordsRemaining)); - - - // Now write out the line descriptors - for (int i = 0; i < lineDescriptors.size(); i++) { - LineDescriptor ld = lineDescriptors.get(i); - - bos.write(ld.getDescriptorInfo()); - } - - - if (!isLastParagraph) { - /* - * There may be a need to pad this. Will be writing at - * either start of 4 byte block or 2 bytes into it. - */ - if (bos.size() % 4 != 2) { - bos.write(EndianConverter.writeShort((short)0)); - } - bos.write(EndianConverter.writeShort((short)0x41)); - } - } - catch (IOException ioe) { - // Should never occur for a memory based stream - } - - return bos.toByteArray(); - } - - - /* - * This method handles the calculation of correct values for line lengths - * in each individual descriptor and the number of lines in the document. - * - * TODO: Update to take account of different font metrics. - */ - private void postProcessText() { - /* - * The post-processing ... - * - * For each line, we need to add a line descriptor and increment - * the number of lines in the paragraph data structure. - * - * To do this, make sure that no sequence goes over the given screen - * width unless the last char is a whitespace character. - */ - - // In courier, can have no more than 29 chars per line - - int chunkStart = 0; - StringBuffer sb = new StringBuffer(""); - - // Line Descriptor info should be eliminated each time - lineDescriptors = new ArrayList<LineDescriptor>(); - lines = 0; - - for (int i = 0; i < textSegments.size(); i++) { - ParagraphTextSegment pts = textSegments.get(i); - sb.append(pts.getText()); - } - - if (sb.length() == 0) { - lines = 1; - lineDescriptors.add(new LineDescriptor((short)1, (short)0)); - return; - } - - while (chunkStart < sb.length()) { - String text = ""; - - try { - text = sb.substring(chunkStart, chunkStart + 30); - } - catch (StringIndexOutOfBoundsException sioobe) { - // We have less than one line left so just add it - text = sb.substring(chunkStart); - lineDescriptors.add(new LineDescriptor((short)(text.length() + 1), (short)(text.length() * 36))); - chunkStart += text.length(); - lines++; - continue; - } - - int lastWhitespace = -1; - - for (int i = 29; i >= 0; i--) { - if (Character.isWhitespace(text.charAt(i))) { - lastWhitespace = i; - break; - } - } - - if (lastWhitespace != -1) { - // The line can be split - lineDescriptors.add(new LineDescriptor((short)(lastWhitespace + 1), (short)(lastWhitespace * 36))); - chunkStart += lastWhitespace + 1; - lines++; - } - else { - // The line is completely occupied by a single word - lineDescriptors.add(new LineDescriptor((short)29, (short)(29 * 36))); - chunkStart += 29; - lines++; - } - } - } - - - /** - * <p>Returns the number of lines in the <code>Paragraph</code>.</p> - * - * @return The number of lines in the document. - */ - public short getLines() { - postProcessText(); - - return lines; - } - - - /** - * <p>Toggles the flag indicating that the <code>Paragraph</code> is a - * bulleted paragraph.</p> - * - * @param isBulleted true to enable bulleting for this paragraph, false - * otherwise. - */ - public void setBullets(boolean isBulleted) { - if (isBulleted) { - bullets = (byte)0xFF; - } - else { - bullets = 0; - } - } - - /** - * <p>Returns the bulleting status of the <code>Paragraph</code>.</p> - * - * @return true if the paragraph is bulleted, false otherwise. - */ - public boolean isBulleted() { - if (bullets != 0) { - return true; - } - return false; - } - - - /** - * <p>Returns the number of text characters in the <code>Paragraph</code>, - * excluding formatting.</p> - * - * @return The length of the paragraph. - */ - public int getTextLength () { - return textLength; - } - - - /** - * <p>Returns an <code>Enumeration</code> over the individual text segments - * of the <code>Paragraph</code>.</p> - * - * @return An <code>Enumeration</code> of the text segments. - */ - public Iterator<ParagraphTextSegment> getSegmentsEnumerator () { - return textSegments.iterator(); - } - - - /** - * <p>Returns a paragraph style object that describes any of the paragraph - * level formatting used by this <code>Paragraph</code>.</p> - * - * @return Paragraph style object describing the <code>Paragraph</code>. - */ - public ParaStyle makeStyle() { - int attrs[] = new int[] { ParaStyle.MARGIN_LEFT, ParaStyle.MARGIN_RIGHT, - ParaStyle.TEXT_ALIGN }; - String values[] = new String[attrs.length]; - - /* - * Not interested in left or right indents just yet. Don't know - * how to calculate them. - */ - - switch (alignment) { - case 2: - values[2] = "center"; - break; - - case 1: - values[2] = "right"; - break; - - case 0: - default: - values[2] = "left"; - return null; // Not interested if its the default. - } - - return new ParaStyle(null, PARAGRAPH_STYLE_FAMILY, null, attrs, - values, null); - } - - - /* - * Class describing the data structures which appear following the text - * of a Paragraph. For each line on screen that the Paragraph uses, a - * LineDescriptor details how many characters are on the line and how much - * screen space they occupy. - * - * The screen space and character breaks are calculated during post-processing - * of the paragraph. See postProcessText(). - * - * The unit of measurement used for screen space is currently unknown. - */ - private class LineDescriptor { - private short characters = 0; - private int filler = 0; - private short screen_space = 0; - private short marker = 0; - - private LineDescriptor(short chars, short space) { - characters = chars; - screen_space = space; - marker = (short)0x040C; // Not a constant. Depends on font used. - } - - - private byte[] getDescriptorInfo(){ - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - try { - bos.write(EndianConverter.writeShort(characters)); - bos.write(EndianConverter.writeInt(filler)); - bos.write(EndianConverter.writeShort(screen_space)); - bos.write(EndianConverter.writeShort(marker)); - } - catch (IOException ioe) { - // Should never happen in a memory based stream. - } - - return bos.toByteArray(); - } - } -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment.java deleted file mode 100644 index 999a24f8bc40..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/ParagraphTextSegment.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import org.openoffice.xmerge.converter.xml.TextStyle; - -import org.openoffice.xmerge.util.EndianConverter; - -import org.openoffice.xmerge.util.ColourConverter; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -/** - * This class represents a portion of text with a particular formatting style. - * The style may differ from the default style of the paragraph of which it - * is part. - * - * @version 1.1 - */ -class ParagraphTextSegment implements PocketWordConstants { - - private String pText; - private TextStyle pStyle; - - - /** - * <p>Initialise a new <code>ParagraphTextSegment</p>. - * <p>Both parameters may be <code>null</code>.</p> - * - * @param data The text of this segment. - * @param style The style describing this segment. - */ - public ParagraphTextSegment (String data, TextStyle style) { - pText = data; - pStyle = style; - } - - /** - * <p>Sets the text for this segment.</p> - * - * @param data The text of this segment. - */ - public void setText (String data) { - pText = data; - } - - /** - * <p>Gets the text for this segment.</p> - * - * @return The text of this segment. - */ - public String getText () { - return pText; - } - - - /** - * <p>Sets the style for this segment.</p> - * - * @param style The style describing this segment. - */ - public void setStyle (TextStyle style) { - pStyle = style; - } - - - /** - * <p>Gets the style for this segment.</p> - * - * @return The style describing this segment. - */ - public TextStyle getStyle () { - return pStyle; - } - - - /** - * <p>Returns the string data for this text segment wrapped with the - * appropriate byte codes for the formatting settings used.</p> - * - * @return <code>byte</code> array containing formatted text in Pocket Word - * format. - */ - public byte[] getData () { - ByteArrayOutputStream data = new ByteArrayOutputStream(); - - boolean colourSet = false; - boolean boldSet = false; - boolean italicSet = false; - boolean underlineSet = false; - boolean strikeSet = false; - boolean highlightSet = false; - - // TODO: Font changes need to be worked out here - - try { - if (pStyle != null) { - if (pStyle.getFontColor() != null) { - ColourConverter cc = new ColourConverter(); - short colourCode = cc.convertFromRGB(pStyle.getFontColor()); - if (colourCode != 0) { // not black - data.write(COLOUR_TAG); - data.write(EndianConverter.writeShort(colourCode)); - colourSet = true; - } - } - if (pStyle.isSet(TextStyle.BOLD) && pStyle.getAttribute(TextStyle.BOLD)) { - data.write(new byte[] { FONT_WEIGHT_TAG, FONT_WEIGHT_BOLD, 0x00 } ); - boldSet = true; - } - if (pStyle.isSet(TextStyle.ITALIC) && pStyle.getAttribute(TextStyle.ITALIC)) { - data.write(new byte[] { ITALIC_TAG, 0x01 } ); - italicSet = true; - } - if (pStyle.isSet(TextStyle.UNDERLINE) && pStyle.getAttribute(TextStyle.UNDERLINE)) { - data.write(new byte[] { UNDERLINE_TAG, 0x01 } ); - underlineSet = true; - } - if (pStyle.isSet(TextStyle.STRIKETHRU) && pStyle.getAttribute(TextStyle.STRIKETHRU)) { - data.write(new byte[] { STRIKETHROUGH_TAG, 0x01 } ); - strikeSet = true; - } - if (pStyle.getBackgroundColor() != null) { - data.write(new byte[] { HIGHLIGHT_TAG, 0x01 } ); - highlightSet = true; - } - } - - - // Now write out the data - if (!pText.equals("\t")) { - data.write(pText.getBytes()); - } - else { - /* - * Tabs are a special case. They are represented by Pocket Word - * as the LE sequence 0xC4 0x04. - */ - data.write(new byte[] { (byte)0xC4, 0x04 } ); - } - - - // Now close out any of the settings changes - if (colourSet) { - /* - * Colours may change without changing back to black, but - * without knowing what the previous colour was, the only - * way to ensure correct conversion is to restore to black and - * let the next segment change the colour again. - */ - data.write(new byte[] { COLOUR_TAG, 0x00, 0x00 } ); - } - if (boldSet) { - data.write(new byte[] { FONT_WEIGHT_TAG, FONT_WEIGHT_NORMAL, 0x00 } ); - } - if (italicSet) { - data.write(new byte[] { ITALIC_TAG, 0x00 } ); - } - if (underlineSet) { - data.write(new byte[] { UNDERLINE_TAG, 0x00 } ); - } - if (strikeSet) { - data.write(new byte[] { STRIKETHROUGH_TAG, 0x00 } ); - } - if (highlightSet) { - data.write(new byte[] { HIGHLIGHT_TAG, 0x00 } ); - } - } - catch (IOException ioe) { - // Should never occur in a memory based stream - } - - return data.toByteArray(); - } -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl.java deleted file mode 100644 index 24c7b915c98c..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PluginFactoryImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - - -import java.io.InputStream; -import java.io.IOException; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.DocumentDeserializerFactory; -import org.openoffice.xmerge.DocumentSerializerFactory; -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.DocumentMergerFactory; -import org.openoffice.xmerge.ConverterCapabilities; - -import org.openoffice.xmerge.util.registry.ConverterInfo; - -import org.openoffice.xmerge.converter.xml.sxw.SxwPluginFactory; - - -/** - * Factory class used to create converters to/from the Pocket Word format. - * - * @version 1.1 - */ -public final class PluginFactoryImpl extends SxwPluginFactory - implements DocumentDeserializerFactory, DocumentSerializerFactory, - DocumentMergerFactory{ - - /** - * <p>Constructor that caches the <code>ConvertInfo</code> that - * corresponds to the registry information for this plug-in.</p> - * - * @param ci <code>ConvertInfo</code> object. - */ - public PluginFactoryImpl (ConverterInfo ci) { - super(ci); - } - - /** ConverterCapabilities object for this type of conversion. */ - private final static ConverterCapabilities converterCap = - new ConverterCapabilitiesImpl(); - - - /** - * <p>The <code>DocumentSerializer</code> is used to convert - * from the OpenOffice Writer <code>Document</code> format - * to the Pocket Word <code>Document</code> format.</p> - * - * <p>The <code>ConvertData</code> object is passed along to the - * created <code>DocumentSerializer</code> via its constructor. - * The <code>ConvertData</code> is read and converted when the - * the <code>DocumentSerializer</code> object's - * <code>serialize</code> method is called.</p> - * - * @param doc <code>Document</code> object that the created - * <code>DocumentSerializer</code> object uses - * as input. - * - * @return A <code>DocumentSerializer</code> object. - */ - public DocumentSerializer createDocumentSerializer(Document doc) { - return new DocumentSerializerImpl(doc); - } - - - /** - * The <code>DocumentDeserializer</code> is used to convert - * from the Pocket Word <code>Document</code> format to - * the OpenOffice Writer <code>Document</code> format.</p> - * - * The <code>ConvertData</code> object is passed along to the - * created <code>DocumentDeserializer</code> via its constructor. - * The <code>ConvertData</code> is read and converted when the - * the <code>DocumentDeserializer</code> object's - * <code>deserialize</code> method is called. - * </p> - * - * @param cd <code>ConvertData</code> object that the created - * <code>DocumentDeserializer</code> object uses as - * input. - * - * @return A <code>DocumentDeserializer</code> object. - */ - public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { - return new DocumentDeserializerImpl(cd); - } - - - /** - * <p>Create a <code>Document</code> object that corresponds to - * the Pocket Word data passed in via the <code>InputStream</code> - * object. - * - * <p>This method will read from the given <code>InputStream</code> - * object. The returned <code>Document</code> object will contain - * the necessary data for the other objects created by the - * <code>PluginFactoryImpl</code> to process, like the - * <code>DocumentSerializerImpl</code> object and a - * <code>DocumentMerger</code> object.</p> - * - * @param name The <code>Document</code> name. - * @param is <code>InputStream</code> object corresponding - * to the <code>Document</code>. - * - * @return A <code>Document</code> object representing the - * Pocket Word format. - * - * @throws IOException If any I/O error occurs. - */ - - public Document createDeviceDocument(String name, InputStream is) - throws IOException { - PocketWordDocument pwd = new PocketWordDocument(name); - pwd.read(is); - return pwd; - } - - /** - * Returns an instance of <code>DocumentMergerImpl</code>, - * which is an implementation of the <code>DocumentMerger</code> - * interface. - * - * @param doc <code>Document</code> to merge. - * - * @return A DocumentMergerImpl object. - */ - public DocumentMerger createDocumentMerger(Document doc) { - ConverterCapabilities cc = converterCap; - DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc); - return merger; - - } - -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants.java deleted file mode 100644 index feb982784b66..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordConstants.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - - -/** - * Interface defining constants for Pocket Word attributes. - * - * @version 1.1 - */ -public interface PocketWordConstants { - /** File extension for Pocket Word files. */ - public static final String FILE_EXTENSION = ".psw"; - - /** Name of the default style. */ - public static final String DEFAULT_STYLE = "Standard"; - - /** Family name for Paragraph styles. */ - public static final String PARAGRAPH_STYLE_FAMILY = "paragraph"; - - /** Family name for Text styles. */ - public static final String TEXT_STYLE_FAMILY = "text"; - - - /** - * Generic Pocket Word formatting code. - * - * Formatting codes are 0xEz, where z indicates the specific format code. - */ - public static final byte FORMATTING_TAG = (byte)0xE0; - - /** Font specification tag. The two bytes following inidicate which font. */ - public static final byte FONT_TAG = (byte)0xE5; - - /** Font size tag. The two bytes following specify font size in points. */ - public static final byte FONT_SIZE_TAG = (byte)0xE6; - - /** Colour tag. Two bytes following index a 4-bit colour table. */ - public static final byte COLOUR_TAG = (byte)0xE7; - - /** Font weight tag. Two bytes following indicate weighting of font. */ - public static final byte FONT_WEIGHT_TAG = (byte)0xE8; - - /** Normal font weight value. */ - public static final byte FONT_WEIGHT_NORMAL = (byte)0x04; - - /** Fine font weight value. */ - public static final byte FONT_WEIGHT_FINE = (byte)0x01; - - /** Bold font weight value. */ - public static final byte FONT_WEIGHT_BOLD = (byte)0x07; - - /** Thick font weight value. */ - public static final byte FONT_WEIGHT_THICK = (byte)0x09; - - /** Italic tag. Single byte following indicates whether italic is on. */ - public static final byte ITALIC_TAG = (byte)0xE9; - - /** Underline tag. Single byte following indicates whether underline is on. */ - public static final byte UNDERLINE_TAG = (byte)0xEA; - - /** Strikethrough tag. Single byte following indicates whether strikethrough is on. */ - public static final byte STRIKETHROUGH_TAG = (byte)0XEB; - - /** Highlighting tag. Single byte following indicates whether highlighting is on. */ - public static final byte HIGHLIGHT_TAG = (byte)0xEC; - -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java deleted file mode 100644 index 8e79a8c43868..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/PocketWordDocument.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.pocketword; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.TextStyle; - - -/** - * <p>Class representing a Pocket Word Document.</p> - * - * <p><code>PocketWordDocument</code> is used to create new Pocket Word documents - * and to read existing data to allow for conversion to OpenOffice Writer - * format.</p> - * - * @version 1.1 - */ -public class PocketWordDocument implements Document, PocketWordConstants { - private String docName; - - private byte[] preamble; - private ArrayList<Object> fonts; - private DocumentDescriptor descriptor; - private ArrayList<Paragraph> paragraphs; - - private Paragraph currentPara; - - /* - * The trailer currently appears to be constant, but if its found to - * have a variable component, then this initialisation should be moved - * to an initTrailer() method. - * - * Padding is sometimes needed before the trailer to ensure the file - * ends on a 4-byte boundary, but this is handled in write(). - */ - private static final byte[] trailer = new byte[] { (byte)0x82, 0x00, - 0x09, 0x00, - 0x03, 0x00, - (byte)0x82, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00, - 0x00, 0x00 }; - - - /** - * <p>Constructs a new Pocket Word Document.</p> - * - * <p>This new document does notcontain any information. Document data must - * either be added using appropriate methods, or an existing file can be - * {@link #read(InputStream) read} from an <code>InputStream</code>.</p> - * - * @param name The name of the <code>PocketWordDocument</code>. - */ - public PocketWordDocument(String name) { - - docName = trimDocumentName(name); - - preamble = new byte[52]; - fonts = new ArrayList<Object>(); - descriptor = new DocumentDescriptor(); - paragraphs = new ArrayList<Paragraph>(); - } - - - /** - * <p>This method reads <code>byte</code> data from the InputStream and - * extracts font and paragraph data from the file.</p> - * - * @param docData InputStream containing a Pocket Word data file. - * - * @throws IOException In case of any I/O errors. - */ - public void read(InputStream docData) throws IOException { - - if (docData == null) { - throw new IOException ("No input stream to convert"); - } - - // The preamble may become important for font declarations. - int readValue = docData.read(preamble); - // #i33702# check for an empty InputStream. - if(readValue == -1) { - System.err.println("Error:invalid input stream"); - return; - } - - byte[] font = new byte[80]; - do { - docData.read(font); - - String name = new String(font, 0, 64, "UTF-16LE"); - fonts.add(name.trim()); - - } while (!(font[76] == 5 && font[77] == 0 - && font[78] == 1 && font[79] == 0)); - - /* - * TODO: The document descriptor data that follows the fonts ends with - * a variable section containing data for each of the paragraphs. - * It may be possible to use this information to calculate staring - * positions for each paragraph rather than iterating through the - * entire byte stream. - */ - - int value; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - while ((value = docData.read()) != -1) { - bos.write(value); - } - - - byte[] contentData = bos.toByteArray(); - int start = 0, end = 0; - boolean sawMarker = false; - - for (int i = 0; i < contentData.length; i += 4) { - if (contentData[i + 2] == (byte)0xFF - && contentData[i + 3] == (byte)0xFF && !sawMarker) { - start = i - 8; - sawMarker = true; - continue; - } - - if (contentData[i + 2] == (byte)0xFF - && contentData[i + 3] == (byte)0xFF && sawMarker) { - end = i - 8; - ByteArrayOutputStream paragraph = new ByteArrayOutputStream(); - paragraph.write(contentData, start, end - start); - paragraphs.add(new Paragraph(paragraph.toByteArray())); - - // Reset the markers - sawMarker = false; - i -= 4; // Skip back - } - - } - - /* - * Special case, the last paragraph - * If we got here, and the marker is set then we saw the start of the - * last paragraph, but no following paragraph - */ - ByteArrayOutputStream paragraph = new ByteArrayOutputStream(); - if (contentData[contentData.length - 19] == 0) { - paragraph.write(contentData, start, contentData.length - start - 20); - } - else { - paragraph.write(contentData, start, contentData.length - start - 18); - } - paragraphs.add(new Paragraph(paragraph.toByteArray())); - } - - - /* - * Utility method to make sure the document name is stripped of any file - * extensions before use. - */ - private String trimDocumentName(String name) { - String temp = name.toLowerCase(); - - if (temp.endsWith(FILE_EXTENSION)) { - // strip the extension - int nlen = name.length(); - int endIndex = nlen - FILE_EXTENSION.length(); - name = name.substring(0,endIndex); - } - - return name; - } - - - /** - * <p>Method to provide access to all of the <code>Paragraph</code> objects - * in the <code>Document</code>.</p> - * - * @return <code>Enumeration</code> over the paragraphs in the document. - */ - public Iterator<Paragraph> getParagraphEnumeration() { - return paragraphs.iterator(); - } - - - /** - * <p>Returns the <code>Document</code> name with no file extension.</p> - * - * @return The <code>Document</code> name with no file extension. - */ - public String getName() { - return docName; - } - - - /** - * <p>Returns the <code>Document</code> name with file extension.</p> - * - * @return The <code>Document</code> name with file extension. - */ - public String getFileName() { - return new String(docName + FILE_EXTENSION); - } - - - /** - * <p>Writes out the <code>Document</code> content to the specified - * <code>OutputStream</code>.</p> - * - * <p>This method may not be thread-safe. - * Implementations may or may not synchronize this - * method. User code (i.e. caller) must make sure that - * calls to this method are thread-safe.</p> - * - * @param os <code>OutputStream</code> to write out the - * <code>Document</code> content. - * - * @throws IOException If any I/O error occurs. - */ - public void write(OutputStream os) throws IOException { - DataOutputStream dos = new DataOutputStream(os); - - initPreamble(); - dos.write(preamble); - - loadFonts(); - for (int i = 0; i < fonts.size(); i++ ) { - ByteArrayOutputStream fontData = (ByteArrayOutputStream)fonts.get(i); - dos.write(fontData.toByteArray()); - } - - - for (int i = 0; i < paragraphs.size(); i++) { - Paragraph para = paragraphs.get(i); - descriptor.addParagraph((short)para.getTextLength(), para.getLines()); - } - dos.write(descriptor.getDescriptor()); - - for (int i = 0; i < paragraphs.size(); i++ ) { - Paragraph para = paragraphs.get(i); - - // Last paragraph has some extra data - if (i + 1 == paragraphs.size()) { - para.setLastParagraph(true); - } - dos.write(para.getParagraphData()); - } - - - /* - * Before we write out the trailer, we need to make sure that it will - * lead to the file ending on a 4 byte boundary. - */ - if (dos.size() % 4 == 0) { - dos.write((byte)0x00); - dos.write((byte)0x00); - } - - dos.write(trailer); - - dos.flush(); - dos.close(); - } - - - /** - * <p>This method adds a new paragraph element to the document. No string - * data is added to the paragraph.</p> - * - * <p><b>N.B.</b> The newly added paragraph becomes the current paragraph and - * is used as the target for all subsequent calls to addParagraphData().</p> - * - * @param style Paragraph Style object describing the formatting for - * the new paragraph. Can be null. - * @param listElement true if this paragraph is to be bulleted; - * false otherwise. - */ - public void addParagraph(ParaStyle style, boolean listElement) { - /* For the moment, only support basic text entry in a single paragraph */ - Paragraph para = new Paragraph(style); - - paragraphs.add(para); - - currentPara = para; - - if (listElement) { - para.setBullets(true); - } - } - - - /** - * <p>This method adds text to the current paragraph.</p> - * - * <p>If no paragraphs exist within the document, it creates one.</p> - * - * @param data The string data for this segment. - * @param style Text Style object describing the formatting of this - * segment. Can be null. - */ - public void addParagraphData(String data, TextStyle style) { - if (currentPara == null) { - addParagraph(null, false); - } - currentPara.addTextSegment(data, style); - } - - - /* - * Preamble is the portion before font specification which never - * seems to change from one file, or one saved version, to the next. - * - * Bytes 18h and 19h seem to contain the number of fonts and should - * be modified when all of the fonts have been specified. - * These bytes are the first two on the fourth line below. - */ - private void initPreamble() { - preamble = new byte[] { 0x7B, 0x5C, 0x70, 0x77, 0x69, 0x15, 0x00, 0x00, - 0x01, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x2C, 0x00, 0x01, 0x00, 0x0A, 0x00, // Bytes 3-4 Font?? - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Bytes 1-2 # Fonts - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }; - } - - - /* - * This method writes the minimum font data that is used by the converter. - * Currently, all documents convert to 10 point Courier New. Tahoma is - * always mentioned in Pocket Word files, however, even if it is not used. - * - * TODO: Rewrite to allow for multiple fonts once font support issues - * have been resolved. - */ - private void loadFonts() { - ByteArrayOutputStream fontData = new ByteArrayOutputStream(); - - try { - fontData.write(new String("Tahoma").getBytes("UTF-16LE")); - fontData.write(new byte[52]); // Rest of font name? - fontData.write(new byte[] { 0x02, 0x00, 0x01, 0x00 } ); - fontData.write(new byte[] { 0x00, 0x00, 0x01, 0x00 } ); - fontData.write(new byte[] { 0x00, 0x00, 0x00, 0x00 } ); - fontData.write(new byte[] { 0x00, 0x00, 0x00, 0x00 } ); - - fonts.add(fontData); - - fontData = new ByteArrayOutputStream(); - - fontData.write(new String("Courier New").getBytes("UTF-16LE")); - fontData.write(new byte[42]); - fontData.write(new byte[] { 0x14, 0x00, 0x04, 0x00 } ); - fontData.write(new byte[] { 0x01, 0x00, 0x00, 0x00 } ); - fontData.write(new byte[] { 0x00, 0x00, 0x15, 0x00 } ); - - // Next part indicates that this is the last font - fontData.write(new byte[] { 0x05, 0x00, 0x01, 0x00 } ); - - fonts.add(fontData); - } - catch (IOException ioe) { - // Shouldn't happen as this is a memory based stream - } - } -} diff --git a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/package.html b/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/package.html deleted file mode 100644 index 675657d29df5..000000000000 --- a/xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/package.html +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<html> -<head> -<title>org.openoffice.xmerge.converter.xml.sxw.pocketword package</title> -</head> - -<body bgcolor="white"> - -<p>Plugin for the conversion of documents between StarWriter XML and - Pocket Word format.</p> -<p>This plugin suports conversion of most features supported by Pocket Word.</p> -<ul> - <li>Bold, Italic, Underline</li> - <li>Strikethrough</li> - <li>Highlight</li> - <li>Colours</li> - <li>Lists</li> - <li>Alignments</li> -</ul> - -<p>Additionally, work on fonts is currently underway.</p> - -<p>This plugin is based on the Windows CE 3.0 version of Pocket Word.<br> - Testing was carried out using Pocket PC 2000 and Pocket PC 2002 devices.</p> - -<p>It follows the org.openoffice.xmerge framework -for the conversion process.</p> - -</body> -</html> diff --git a/xmerge/source/regutil/makefile.mk b/xmerge/source/regutil/makefile.mk deleted file mode 100644 index e520c2fb499d..000000000000 --- a/xmerge/source/regutil/makefile.mk +++ /dev/null @@ -1,39 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -PRJ = ..$/.. -PRJNAME = xmerge -TARGET = regutil -ENABLE_EXCEPTIONS=TRUE -LIBTARGET=NO - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - -.IF "$(OS)" == "WNT" - -OBJFILES=$(OBJ)$/regutil.obj -APP1TARGETDEPN=makefile.mk -APP1OBJS=$(OBJFILES) -APP1TARGET=$(TARGET) -APP1STDLIBS= Advapi32.lib - -.ENDIF - -# --- Targets ------------------------------------------------------ -.INCLUDE : target.mk diff --git a/xmerge/source/regutil/regutil.cpp b/xmerge/source/regutil/regutil.cpp deleted file mode 100644 index 2fb07466d023..000000000000 --- a/xmerge/source/regutil/regutil.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -/* - * Simple Application which calls the DllRegisterServer or DllUnregisterServer functions - * of the XMerge ActiveSync plugin. - */ - - -#include <stdio.h> -#include <string.h> -#include <windows.h> - - -typedef HRESULT (STDAPICALLTYPE *DLLREGISTERSERVER)(void); -typedef HRESULT (STDAPICALLTYPE *DLLUNREGISTERSERVER)(void); - -int main(int argc, char* argv[]) -{ - BOOL bUninstall = FALSE; - int nPathIndex = 1; - - if (argc < 2 || argc > 3) - { - printf("\nUsage: regutil [/u] <Full Path of XMergeSync.dll>\n\n"); - return -1; - } - - - if (argc == 3) - { - if (strcmp("/u", argv[1])) - { - printf("\nUnrecognised option: %s\n", argv[1]); - return -1; - } - - bUninstall = TRUE; - nPathIndex = 2; - } - - - // Dynamically load the library - HMODULE hmXMDll = LoadLibrary(argv[nPathIndex]); - - if (hmXMDll == NULL) - { - printf("\nUnable to load the library %s\n", argv[nPathIndex]); - return -1; - } - - - // Get an offset to the either the DllRegisterServer or DllUnregisterServer functions - if (!bUninstall) - { - printf("\nRegistering %s ... ", argv[nPathIndex]); - - DLLREGISTERSERVER DllRegisterServer = (DLLREGISTERSERVER)GetProcAddress(hmXMDll, "DllRegisterServer"); - - if (DllRegisterServer == NULL) - { - printf("failed.\n\nDllRegisterServer is not present in library.\n"); - return -1; - } - - // Now call the procedure ... - HRESULT regResult = DllRegisterServer() ; - - if (regResult != S_OK) - { - printf("failed.\n"); - return -1; - } - } - else - { - printf("\nUnregistering %s ... ", argv[nPathIndex]); - - DLLUNREGISTERSERVER DllUnregisterServer = (DLLUNREGISTERSERVER)GetProcAddress(hmXMDll, "DllUnregisterServer"); - - if (DllUnregisterServer == NULL) - { - printf("failed.\n\nDllUnregisterServer is not present in library.\n"); - return -1; - } - - // Now call the procedure ... - HRESULT regResult = DllUnregisterServer() ; - - if (regResult != S_OK) - { - printf("failed.\n"); - return -1; - } - - } - - printf("done.\n"); - - - // Clean up - FreeLibrary(hmXMDll); - - return 0; -} -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmerge/source/regutil/regutil.dsp b/xmerge/source/regutil/regutil.dsp deleted file mode 100644 index 2c3689c047a5..000000000000 --- a/xmerge/source/regutil/regutil.dsp +++ /dev/null @@ -1,96 +0,0 @@ -# Microsoft Developer Studio Project File - Name="regutil" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=regutil - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "regutil.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "regutil.mak" CFG="regutil - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "regutil - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "regutil - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "regutil - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x1809 /d "NDEBUG"
-# ADD RSC /l 0x1809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "regutil - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "regutil___Win32_Debug"
-# PROP BASE Intermediate_Dir "regutil___Win32_Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "regutil___Win32_Debug"
-# PROP Intermediate_Dir "regutil___Win32_Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE RSC /l 0x1809 /d "_DEBUG"
-# ADD RSC /l 0x1809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "regutil - Win32 Release"
-# Name "regutil - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/xmerge/source/regutil/regutil.dsw b/xmerge/source/regutil/regutil.dsw deleted file mode 100644 index 4ad03e67bffc..000000000000 --- a/xmerge/source/regutil/regutil.dsw +++ /dev/null @@ -1,17 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
diff --git a/xmerge/source/wordsmith/build.xml b/xmerge/source/wordsmith/build.xml deleted file mode 100644 index b9718ffd1562..000000000000 --- a/xmerge/source/wordsmith/build.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<project name="wordsmith" default="all" basedir="."> - - <property file="../inc/antbuild.properties"/> - - <path id="classpath"> - <pathelement location="${build.dir}/xmerge.jar"/> - </path> - - - <target name="init" > - <mkdir dir="${target.dir}"/> - </target> - - <!-- compile java sources in ${package} --> - <target name="compile" depends="init"> - <javac srcdir="${src.dir}" - destdir="${target.dir}" - debug="${debug}" - deprecation="${deprecation}" - optimize="${optimize}"> - <classpath refid="classpath"/> - </javac> - </target> - - <!-- package to jar --> - <target name="jar" depends="compile"> - <jar destfile="${target.jar}"> - <fileset dir="${target.dir}" - includes="**/*.class" /> - <metainf dir="${basedir}"> - <filename name="converter.xml"/> - </metainf> - </jar> - </target> - - <!-- clean up --> - <target name="clean"> - <delete dir="${class.dir}"/> - <delete file="${target.jar}"/> - </target> - - <target name="all" depends="jar"> - </target> - -</project> - diff --git a/xmerge/source/wordsmith/converter.xml b/xmerge/source/wordsmith/converter.xml deleted file mode 100644 index f169dfaa2e08..000000000000 --- a/xmerge/source/wordsmith/converter.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . ---> -<converters> - <converter type="staroffice/sxw" version="1.0"> - <converter-display-name> - WordSmith - </converter-display-name> - <converter-description> - StarWriter XML to/from WordSmith conversion - </converter-description> - <converter-vendor>OpenOffice.org</converter-vendor> - <converter-class-impl> - org.openoffice.xmerge.converter.xml.sxw.wordsmith.PluginFactoryImpl - </converter-class-impl> - <converter-target type="application/x-wordsmith" /> - </converter> -</converters> - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/ConverterCapabilitiesImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/ConverterCapabilitiesImpl.java deleted file mode 100644 index 65e8769610f1..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/ConverterCapabilitiesImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.OfficeConstants; - -/** - * <p>WordSmith implementation of <code>ConverterCapabilities</code> for - * the {@link - * org.openoffice.xmerge.converter.xml.sxw.wordsmith.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>Used with StarWriter XML to/from WordSmith conversions. - * The <code>ConverterCapibilies</code> specify which "Office" - * <code>Document</code> tags and attributes are supported on the - * "Device" <code>Document</code> format.</p> - */ -public final class ConverterCapabilitiesImpl - implements ConverterCapabilities { - - public boolean canConvertTag(String tag) { - - if (OfficeConstants.TAG_OFFICE_DOCUMENT.equals(tag)) - return true; - else if (OfficeConstants.TAG_OFFICE_DOCUMENT_CONTENT.equals(tag)) - return true; - else if (OfficeConstants.TAG_OFFICE_BODY.equals(tag)) - return true; - else if (OfficeConstants.TAG_PARAGRAPH.equals(tag)) - return true; - else if (OfficeConstants.TAG_HEADING.equals(tag)) - return true; - else if (OfficeConstants.TAG_ORDERED_LIST.equals(tag)) - return true; - else if (OfficeConstants.TAG_UNORDERED_LIST.equals(tag)) - return true; - else if (OfficeConstants.TAG_LIST_ITEM.equals(tag)) - return true; - else if (OfficeConstants.TAG_LIST_HEADER.equals(tag)) - return true; - else if (OfficeConstants.TAG_SPAN.equals(tag)) - return true; - else if (OfficeConstants.TAG_HYPERLINK.equals(tag)) - return true; - else if (OfficeConstants.TAG_LINE_BREAK.equals(tag)) - return true; - else if (OfficeConstants.TAG_SPACE.equals(tag)) - return true; - else if (OfficeConstants.TAG_TAB_STOP.equals(tag)) - return true; - - return false; - } - - public boolean canConvertAttribute(String tag, - String attribute) { - - if (OfficeConstants.TAG_SPACE.equals(tag)) { - - if (OfficeConstants.ATTRIBUTE_SPACE_COUNT.equals(attribute)) - return true; - } - - return false; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DOCConstants.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DOCConstants.java deleted file mode 100644 index 78bbc7a06458..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DOCConstants.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -/** - * Constants used for encoding and decoding the WordSmith format. - * - */ -interface DOCConstants { - - /** Constant for uncompressed version. */ - public static final short UNCOMPRESSED = 1; - - /** Constant for compressed version. */ - public static final short COMPRESSED = 2; - - /** Constant used for spare fields. */ - public static final int SPARE = 0; - - /** WordSmith record size. */ - public static final short TEXT_RECORD_SIZE = 4096; - - /** Constant for encoding scheme. */ - public static final String ENCODING = "8859_1"; - - /** Constant for TAB character. */ - public final static char TAB_CHAR = '\t'; - - /** Constant for EOL character. */ - public final static char EOL_CHAR = '\n'; - - /** Constant for SPACE character. */ - public final static char SPACE_CHAR = ' '; -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java deleted file mode 100644 index 559abefa70b5..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentDeserializerImpl.java +++ /dev/null @@ -1,545 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; - -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.Style; -import org.openoffice.xmerge.converter.xml.StyleCatalog; -import org.openoffice.xmerge.converter.xml.TextStyle; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.XmlUtil; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -/** - * <p>WordSmith implementation of - * org.openoffice.xmerge.DocumentDeserializer - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.wordsmith.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * The <code>deserialize</code> method uses a - * <code>DocDecoder</code> to read the WordSmith format into a - * <code>String</code> object, then it calls <code>buildDocument</code> - * to create a <code>SxwDocument</code> object from it. - * - */ -public final class DocumentDeserializerImpl -implements DOCConstants, OfficeConstants, DocumentDeserializer { - - /** A Decoder object for decoding WordSmith format. */ - private WSDecoder decoder = null; - - WseFontTable fontTable = null; - WseColorTable colorTable = null; - StyleCatalog styleCat = null; - StyleCatalog oldStyleCat = null; - - /** A <code>ConvertData</code> object assigned to this object. */ - private ConvertData cd = null; - - - /** - * Constructor that assigns the given <code>ConvertData</code> - * to the object. - * - * @param cd A <code>ConvertData</code> object to read data for - * the conversion process by the deserialize method. - */ - public DocumentDeserializerImpl(ConvertData cd) { - this.cd = cd; - } - - - /** - * Convert the given <code>ConvertData</code> into a - * <code>SxwDocument</code> object. - * - * @return Resulting <code>Document</code> object. - * - * @throws ConvertException If any conversion error occurs. - * @throws IOException If any I/O error occurs. - */ - public Document deserialize() throws ConvertException, - IOException { - return deserialize(null, cd); - } - - - public Document deserialize(Document origDoc, ConvertData cd) - throws IOException { - - Document doc = null; - PalmDocument palmDoc = null; - Iterator<Object> e = cd.getDocumentEnumeration(); - - while(e.hasNext()) { - palmDoc = (PalmDocument) e.next(); - PalmDB pdb = palmDoc.getPdb(); - Record[] recs = pdb.getRecords(); - decoder = new WSDecoder(); - Wse[] b = decoder.parseDocument(recs); - String docName = palmDoc.getName(); - doc = buildDocument(docName, b, origDoc); - } - return doc; - } - - - /** - * Temporary method to read existing <code>StyleCatalog</code> - * as a starting point. - * - * @param parentDoc The parent <code>Document</code>. - */ - private void readStyleCatalog(Document parentDoc) { - try { - java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); - parentDoc.write(bos); - SxwDocument sxwDoc = new SxwDocument("old"); - sxwDoc.read(new ByteArrayInputStream(bos.toByteArray())); - org.w3c.dom.Document domDoc = sxwDoc.getContentDOM(); - - String families[] = new String[3]; - families[0] = "text"; - families[1] = "paragraph"; - families[2] = "paragraph"; - Class<?> classes[] = new Class<?>[3]; - classes[0] = TextStyle.class; - classes[1] = ParaStyle.class; - classes[2] = TextStyle.class; - - NodeList nl = domDoc.getElementsByTagName(TAG_OFFICE_STYLES); - oldStyleCat.add(nl.item(0), families, classes, null, false); - nl = domDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES); - oldStyleCat.add(nl.item(0), families, classes, null, false); - nl = domDoc.getElementsByTagName(TAG_OFFICE_MASTER_STYLES); - oldStyleCat.add(nl.item(0), families, classes, null, false); - - } catch (Exception e) { - Debug.log(Debug.ERROR, "", e); - } - - } - - - /** - * Given an array of paragraph <code>Style</code> objects, see if - * there is exactly one which matches the text formatting - * <code>Style</code> of <code>tStyle</code>. - * - * @param paraStyles An array of paragraph <code>Style</code> - * objects. - * @param tStyle Text <code>Style</code> to match. - * - * @return The paragraph <code>Style</code> that matches. - */ - private ParaStyle matchParaByText(Style paraStyles[], TextStyle tStyle) { - int matchIndex = -1; - int matchCount = 0; - Style txtMatches[] = oldStyleCat.getMatching(tStyle); - if (txtMatches.length >= 1) { - for (int j = 0; j < txtMatches.length; j++) { - TextStyle t = (TextStyle)txtMatches[j]; - - if (!t.getFamily().equals("paragraph")) - continue; - - for (int k = 0; k < paraStyles.length; k++) { - if (t.getName().equals(paraStyles[k].getName())) { - matchCount++; - matchIndex = k; - } - } - } - } - if (matchCount == 1) - return (ParaStyle)paraStyles[matchIndex]; - else return null; - } - - - /** - * Take a <code>String</code> of text and turn it into a sequence - * of <code>Node</code> objects. - * - * @param text <code>String</code> of text. - * @param parentDoc Parent <code>Document</code>. - * - * @return Array of <code>Node</code> objects. - */ - private Node[] parseText(String text, org.w3c.dom.Document parentDoc) { - ArrayList<Node> nodeVec = new ArrayList<Node>(); - - // Break up the text from the WordSmith text run into Open - // Office text runs. There may be more runs in OO because - // runs of 2 or more spaces map to nodes. - while ((text.indexOf(" ") != -1) || (text.indexOf("\t") != 1)) { - - // Find the indices of tabs and multiple spaces, and - // figure out which of them occurs first in the string. - int spaceIndex = text.indexOf(" "); - int tabIndex = text.indexOf("\t"); - if ((spaceIndex == -1) && (tabIndex == -1)) - break; // DJP This should not be necessary. What is wrong - // with the while() stmt up above? - int closerIndex; // Index of the first of these - if (spaceIndex == -1) - closerIndex = tabIndex; - else if (tabIndex == -1) - closerIndex = spaceIndex; - else - closerIndex = (spaceIndex > tabIndex) ? tabIndex : spaceIndex; - - // If there is any text prior to the first occurrence of a - // tab or spaces, create a text node from it, then chop it - // off the string we're working with. - if (closerIndex > 0) { - String beginningText = text.substring(0, closerIndex); - Text textNode = parentDoc.createTextNode(beginningText); - nodeVec.add(textNode); - log("<TEXT>"); - log(beginningText); - log("</TEXT>"); - } - text = text.substring(closerIndex); - - // Handle either tab character or space sequence by creating - // an element for it, and then chopping out the text that - // represented it in "text". - if (closerIndex == tabIndex) { - Element tabNode = parentDoc.createElement(TAG_TAB_STOP); - nodeVec.add(tabNode); - text = text.substring(1); // tab is always a single character - log("<TAB/>"); - } else { - // Compute length of space sequence. - int nrSpaces = 2; - while ((nrSpaces < text.length()) - && text.substring(nrSpaces, nrSpaces + 1).equals(" ")) - nrSpaces++; - - Element spaceNode = parentDoc.createElement(TAG_SPACE); - spaceNode.setAttribute(ATTRIBUTE_SPACE_COUNT, new Integer(nrSpaces).toString()); - nodeVec.add(spaceNode); - text = text.substring(nrSpaces); - log("<SPACE count=\"" + nrSpaces + "\" />"); - } - } - - // No more tabs or space sequences. If there's any remaining - // text create a text node for it. - if (text.length() > 0) { - Text textNode = parentDoc.createTextNode(text); - nodeVec.add(textNode); - log("<TEXT>"); - log(text); - log("</TEXT>"); - } - - // Now create and populate an array to return the nodes in. - Node nodes[] = new Node[nodeVec.size()]; - for (int i = 0; i < nodeVec.size(); i++) - nodes[i] = nodeVec.get(i); - return nodes; - } - - - /** - * Parses the text content of a WordSmith format and builds a - * <code>SXWDocument</code>. - * - * @param docName <code>Document</code> name - * @param data Text content of WordSmith format - * - * @return Resulting <code>SXWDocument</code> object. - * - * @throws IOException If any I/O error occurs. - */ - private SxwDocument buildDocument(String docName, Wse[] data, Document origDoc) - throws IOException { - - // create minimum office xml document. - SxwDocument sxwDoc = new SxwDocument(docName); - sxwDoc.initContentDOM(); - - org.w3c.dom.Document doc = sxwDoc.getContentDOM(); - - // Grab hold of the office:body tag, - // Assume there should be one. - // This is where top level paragraphs will append to. - NodeList list = doc.getElementsByTagName(TAG_OFFICE_BODY); - Node bodyNode = list.item(0); - - styleCat = new StyleCatalog(50); - oldStyleCat = new StyleCatalog(50); - if (origDoc != null) - readStyleCatalog(origDoc); - - Element currPara = null; - ParaStyle currParaStyle = null; - int newTextStyleNr = 0; - int newParaStyleNr = 0; - - // Now write out the document body by running through - // the list of WordSmith elements and processing each one - // in turn. - for (int i = 0; i < data.length; i++) { - - if (data[i].getClass() == WsePara.class) { - - currPara = doc.createElement(TAG_PARAGRAPH); - log("</PARA>"); - log("<PARA>"); - - WsePara p = (WsePara)data[i]; - - // Save info about the first text run, if there is one. - WseTextRun firstTextRun = null; - - if ((data.length >= i + 2) - && (data[i+1].getClass() == WseTextRun.class)) - firstTextRun = (WseTextRun)data[i+1]; - - Style matches[] = oldStyleCat.getMatching(p.makeStyle()); - - // See if we can find a unique match in the catalog - // of existing styles from the original document. - ParaStyle pStyle = null; - if (matches.length == 1) { - pStyle = (ParaStyle)matches[0]; - log("using an existing style"); - } else if ((matches.length > 1) && (firstTextRun != null)) { - pStyle = matchParaByText(matches, firstTextRun.makeStyle()); - log("resolved a para by looking @ text"); - } - - // If nothing found so far, try looking in the catalog - // of newly-created styles. - // DJP FIXME: if we need to add two para styles with the - // same para formatting info but different default text - // styles, this won't work! - if (pStyle == null) { - log("had " + matches.length + " matches in old catalog"); - matches = styleCat.getMatching(p.makeStyle()); - if (matches.length == 0) { - pStyle = p.makeStyle(); - String newName = new String("PPP" + ++newParaStyleNr); - pStyle.setName(newName); - styleCat.add(pStyle); - // DJP: write in the text format info here - log("created a new style"); - } else if (matches.length == 1) { - pStyle = (ParaStyle)matches[0]; - log("re-using a new style"); - } else if (firstTextRun != null) { - pStyle = matchParaByText(matches, firstTextRun.makeStyle()); - if (pStyle != null) { - log("resolved a (new) para by looking @ text"); - } else - log("Hey this shouldn't happen! - nr of matches is " - + matches.length); - } - } - - if (pStyle == null) - log("Unable to figure out a para style"); - - // Figured out a style to use. Specify the style in this - // paragraph's attributes. - currPara.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, pStyle.getName()); - - bodyNode.appendChild(currPara); - currParaStyle = pStyle; - } else if (data[i].getClass() == WseTextRun.class) { - WseTextRun tr = (WseTextRun)data[i]; - TextStyle trStyle = null; - Node trNodes[] = parseText(tr.getText(), doc); - - // First see if the formatting of this text run matches - // the default text formatting for this paragraph. If - // it does, then just make the text node(s) children of - // the current paragraph. - Style[] cps = new Style[1]; - cps[0] = currParaStyle; - if (matchParaByText(cps, tr.makeStyle()) != null) { - for (int ii = 0; ii < trNodes.length; ii++) { - currPara.appendChild(trNodes[ii]); - } - continue; - } - - // Check for existing, matching styles in the old style - // catalog. If exactly one is found, use it. Otherwise, - // check the new style catalog, and either use the style - // found or add this new one to it. - Style matches[] = oldStyleCat.getMatching(tr.makeStyle()); - if (matches.length == 1) - trStyle = (TextStyle)matches[0]; - else { - matches = styleCat.getMatching(tr.makeStyle()); - if (matches.length == 0) { - trStyle = tr.makeStyle(); - String newName = new String("TTT" + ++newTextStyleNr); - trStyle.setName(newName); - styleCat.add(trStyle); - } else if (matches.length == 1) - trStyle = (TextStyle)matches[0]; - else - log("multiple text style matches from new catalog"); - } - - // Create a text span node, set the style attribute, make the - // text node(s) its children, and append it to current paragraph's - // list of children. - Element textSpanNode = doc.createElement(TAG_SPAN); - textSpanNode.setAttribute(ATTRIBUTE_TEXT_STYLE_NAME, trStyle.getName()); - for (int ii = 0; ii < trNodes.length; ii++) { - textSpanNode.appendChild(trNodes[ii]); - } - currPara.appendChild(textSpanNode); - log("</SPAN>"); - } - - else if (data[i].getClass() == WseFontTable.class) { - fontTable = (WseFontTable)data[i]; - } - - else if (data[i].getClass() == WseColorTable.class) { - colorTable = (WseColorTable)data[i]; - } - } - - - //NodeList r = doc.getElementsByTagName(TAG_OFFICE_DOCUMENT); - NodeList r = doc.getElementsByTagName(TAG_OFFICE_DOCUMENT_CONTENT); - Node rootNode = r.item(0); - - // read the original document - org.w3c.dom.NodeList nl; - if (origDoc != null) { - java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); - origDoc.write(bos); - SxwDocument origSxwDoc = new SxwDocument("old"); - origSxwDoc.read(new ByteArrayInputStream(bos.toByteArray())); - org.w3c.dom.Document origDomDoc = origSxwDoc.getContentDOM(); - - org.w3c.dom.DocumentFragment df; - org.w3c.dom.Node newNode; - - // copy font declarations from original document to the new document - nl = origDomDoc.getElementsByTagName(TAG_OFFICE_FONT_DECLS); - df = doc.createDocumentFragment(); - newNode = XmlUtil.deepClone(df, nl.item(0)); - rootNode.insertBefore(newNode, bodyNode); - - // copy style catalog from original document to the new document - nl = origDomDoc.getElementsByTagName(TAG_OFFICE_STYLES); - df = doc.createDocumentFragment(); - newNode = XmlUtil.deepClone(df, nl.item(0)); - rootNode.insertBefore(newNode, bodyNode); - - nl = origDomDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES); - df = doc.createDocumentFragment(); - newNode = XmlUtil.deepClone(df, nl.item(0)); - rootNode.insertBefore(newNode, bodyNode); - - nl = origDomDoc.getElementsByTagName(TAG_OFFICE_MASTER_STYLES); - df = doc.createDocumentFragment(); - newNode = XmlUtil.deepClone(df, nl.item(0)); - rootNode.insertBefore(newNode, bodyNode); - } - - // Original document not specified. We need to add font declarations. - // DJP: this might just be for debugging. Merger will probably put - // the "real" ones in. - // DJP: if really doing it this way, do it right: gather font names - // from style catalog(s). - else { - org.w3c.dom.Node declNode; - - log("<FONT-DECLS/>"); - - declNode = doc.createElement(TAG_OFFICE_FONT_DECLS); - rootNode.insertBefore(declNode, bodyNode); - org.w3c.dom.Element fontNode; - - fontNode = doc.createElement(TAG_STYLE_FONT_DECL); - fontNode.setAttribute(ATTRIBUTE_STYLE_NAME, "Arial"); - fontNode.setAttribute(ATTRIBUTE_FO_FONT_FAMILY, "Arial"); - fontNode.setAttribute(ATTRIBUTE_STYLE_FONT_PITCH, "variable"); - declNode.appendChild(fontNode); - - fontNode = doc.createElement(TAG_STYLE_FONT_DECL); - fontNode.setAttribute(ATTRIBUTE_STYLE_NAME, "Arioso"); - fontNode.setAttribute(ATTRIBUTE_FO_FONT_FAMILY, "Arioso"); - fontNode.setAttribute(ATTRIBUTE_STYLE_FONT_PITCH, "variable"); - declNode.appendChild(fontNode); - } - - - // Now add any new styles we have created in this document. - nl = doc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES); - Node autoStylesNode = nl.item(0); - if (autoStylesNode == null) { - autoStylesNode = doc.createElement(TAG_OFFICE_AUTOMATIC_STYLES); - log("<OFFICE-AUTOMATIC-STYLES/>"); - rootNode.insertBefore(autoStylesNode, bodyNode); - } - - Node newStyleCatNode = styleCat.writeNode(doc, "dummy"); - nl = newStyleCatNode.getChildNodes(); - int nNodes = nl.getLength(); - for (int i = 0; i < nNodes; i++) { - autoStylesNode.appendChild(nl.item(0)); - } - - oldStyleCat.dumpCSV(true); - styleCat.dumpCSV(true); - return sxwDoc; - } - - - /** - * Sends message to the log object. - * - * @param str Debug message. - */ - private void log(String str) { - - Debug.log(Debug.TRACE, str); - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentMergerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentMergerImpl.java deleted file mode 100644 index 30a5fbfd1914..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentMergerImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import org.w3c.dom.Document; -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.MergeException; -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.merger.DiffAlgorithm; -import org.openoffice.xmerge.merger.Difference; -import org.openoffice.xmerge.merger.NodeMergeAlgorithm; -import org.openoffice.xmerge.merger.Iterator; -import org.openoffice.xmerge.merger.diff.ParaNodeIterator; -import org.openoffice.xmerge.merger.diff.IteratorLCSAlgorithm; -import org.openoffice.xmerge.merger.merge.DocumentMerge; -import org.openoffice.xmerge.merger.merge.CharacterBaseParagraphMerge; -import org.openoffice.xmerge.util.Debug; - - -/** - * Wordsmith implementation of <code>DocumentMerger</code> - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.wordsmith.PluginFactoryImpl - * PluginFactoryImpl}.</p> - */ -public class DocumentMergerImpl implements DocumentMerger { - - private ConverterCapabilities cc_; - private org.openoffice.xmerge.Document orig = null; - - public DocumentMergerImpl(org.openoffice.xmerge.Document doc, ConverterCapabilities cc) { - cc_ = cc; - this.orig = doc; - } - - public void merge(org.openoffice.xmerge.Document modifiedDoc) throws MergeException { - - SxwDocument wdoc1 = (SxwDocument) orig; - SxwDocument wdoc2 = (SxwDocument) modifiedDoc; - - Document doc1 = wdoc1.getContentDOM(); - Document doc2 = wdoc2.getContentDOM(); - - Iterator i1 = new ParaNodeIterator(cc_, doc1.getDocumentElement()); - Iterator i2 = new ParaNodeIterator(cc_, doc2.getDocumentElement()); - - DiffAlgorithm diffAlgo = new IteratorLCSAlgorithm(); - - // find out the paragrah level diffs - Difference[] diffTable = diffAlgo.computeDiffs(i1, i2); - - if (Debug.isFlagSet(Debug.INFO)) { - Debug.log(Debug.INFO, "Diff Result: "); - - for (int i = 0; i < diffTable.length; i++) { - Debug.log(Debug.INFO, diffTable[i].debug()); - } - } - - // merge the paragraphs - NodeMergeAlgorithm charMerge = new CharacterBaseParagraphMerge(); - DocumentMerge docMerge = new DocumentMerge(cc_, charMerge); - - docMerge.applyDifference(i1, i2, diffTable); - } -} - - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java deleted file mode 100644 index ca99f8562be3..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/DocumentSerializerImpl.java +++ /dev/null @@ -1,517 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import org.w3c.dom.NodeList; -import org.w3c.dom.Node; -import org.w3c.dom.NamedNodeMap; -import java.io.IOException; - -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.ConvertException; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.converter.xml.OfficeConstants; -import org.openoffice.xmerge.converter.xml.sxw.SxwDocument; -import org.openoffice.xmerge.converter.palm.PalmDB; -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.converter.palm.PdbUtil; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.util.*; -import org.openoffice.xmerge.converter.xml.*; - -/** - * <p>WordSmith implementation of - * org.openoffice.xmerge.DocumentSerializer - * for the {@link - * org.openoffice.xmerge.converter.xml.sxw.wordsmith.PluginFactoryImpl - * PluginFactoryImpl}.</p> - * - * <p>The <code>serialize</code> method traverses the DOM - * document from the given <code>Document</code> object. It uses a - * <code>DocEncoder</code> object for the actual conversion of - * contents to the WordSmith format.</p> - * - */ - -// DJP: take out "implements OfficeConstants" -public final class DocumentSerializerImpl -implements OfficeConstants, DocumentSerializer { - - /** A WSEncoder object for encoding to WordSmith. */ - private WSEncoder encoder = null; - - /** The <code>StyleCatalog</code>. */ - private StyleCatalog styleCat = null; - - private WseFontTable fontTable = new WseFontTable(); - private WseColorTable colorTable = new WseColorTable(); - - /** - * The <code>SxwDocument</code> object that this converter - * processes. - */ - private SxwDocument sxwDoc = null; - - /** - * Constructor. - * - * @param doc The <code>Document</code> to convert. - */ - public DocumentSerializerImpl(Document doc) { - sxwDoc = (SxwDocument) doc; - } - - - /** - * <p>Method to convert a <code>Document</code> into a - * <code>PalmDocument</code>.</p> - * - * <p>This method is not thread safe for performance reasons. - * This method should not be called from within two threads. - * It would be best to call this method only once per object - * instance.</p> - * - * <p>Note that the doc parameter needs to be an XML - * <code>Document</code>, else this method will throw a - * <code>ClassCastException</code>. I think this is a hack, - * but this is the only way to not modify most of the existing - * code right now.</p> - * - * @throws ConvertException If any conversion error occurs. - * @throws IOException If any I/O error occurs. - */ - public ConvertData serialize() - throws IOException { - - - // get the server document name - String docName = sxwDoc.getName(); - - // get DOM document - org.w3c.dom.Document domDoc = sxwDoc.getContentDOM(); - - // Create WordSmith encoder object. Add WordSmith header, - // empty font table to it. - encoder = new WSEncoder(); - encoder.addElement(fontTable); - encoder.addElement(colorTable); - - // Read the styles into the style catalog - String families[] = new String[3]; - families[0] = "text"; - families[1] = "paragraph"; - families[2] = "paragraph"; - Class<?> classes[] = new Class[3]; - classes[0] = TextStyle.class; - classes[1] = ParaStyle.class; - classes[2] = TextStyle.class; - styleCat = new StyleCatalog(25); - - // Parse the input document - // DJP todo: eliminate multiple calls to add() when it can - // recurse properly. - NodeList nl = domDoc.getElementsByTagName(TAG_OFFICE_STYLES); - styleCat.add(nl.item(0), families, classes, null, false); - nl = domDoc.getElementsByTagName(TAG_OFFICE_AUTOMATIC_STYLES); - styleCat.add(nl.item(0), families, classes, null, false); - nl = domDoc.getElementsByTagName(TAG_OFFICE_MASTER_STYLES); - styleCat.add(nl.item(0), families, classes, null, false); - - // Traverse to the office:body element. - // There should only be one. - NodeList list = domDoc.getElementsByTagName(TAG_OFFICE_BODY); - int len = list.getLength(); - if (len > 0) { - Node node = list.item(0); - traverseBody(node); - } - - // create a PalmDB object and ConvertData object. - // - Record records[] = encoder.getRecords(); - - ConvertData cd = new ConvertData(); - PalmDocument palmDoc = new PalmDocument(docName, - PdbUtil.intID("WrdS"), PdbUtil.intID("BDOC"), 0, - PalmDB.PDB_HEADER_ATTR_BACKUP, records); - cd.addDocument(palmDoc); - return cd; - } - - - /** - * This method traverses <i>office:body</i> element. - * - * @param node <i>office:body</i> <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseBody(Node node) throws IOException { - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH) || - nodeName.equals(TAG_HEADING)) { - - traverseParagraph(child); - - } else if (nodeName.equals(TAG_UNORDERED_LIST)) { - - traverseList(child); - - } else if (nodeName.equals(TAG_ORDERED_LIST)) { - - traverseList(child); - - } else { - - Debug.log(Debug.INFO, "<OTHERS " /* + XmlDebug.nodeInfo(child) */ + " />"); - } - } - } - } - - } - - - /** - * This method traverses the <i>text:p</i> and <i>text:h</i> - * element <code>Node</code> objects. - * - * @param node A <i>text:p</i> or <i>text:h</i> <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseParagraph(Node node) throws IOException { - - String styleName = findAttribute(node, "text:style-name"); - ParaStyle pstyle = (ParaStyle)styleCat.lookup(styleName, "paragraph", - null, ParaStyle.class); - - // If the style does not exist in the style catalog for some reason, - // make up a default style and use it. We'll have to add this default - // style to the style catalog the first time it is used. - if (pstyle == null) { - styleName = "CONVERTER-DEFAULT"; - pstyle = (ParaStyle)styleCat.lookup(styleName, "paragraph", null, - ParaStyle.class); - if (pstyle == null) { - pstyle = new ParaStyle(styleName, "paragraph", null, - (String [])null, null, styleCat); - styleCat.add(pstyle); - styleCat.add(new TextStyle(styleName, "paragraph", null, - 0, 0, 12, "Times-Roman", styleCat)); - } - } - - pstyle = (ParaStyle)pstyle.getResolved(); - encoder.addElement(new WsePara(pstyle, styleCat)); - TextStyle defParaTextStyle = (TextStyle) - styleCat.lookup(styleName, "paragraph", null, TextStyle.class); - - traverseParaContents(node, defParaTextStyle); - } - - - /** - * This method traverses a paragraph content. Note that this - * method may recurse to call itself. - * - * @param node A paragraph or content <code>Node</code> - */ - private void traverseParaContents(Node node, TextStyle defTextStyle) { - - String styleName = findAttribute(node, "text:style-name"); - TextStyle style = (TextStyle) - styleCat.lookup(styleName, "text", null, TextStyle.class); - - if (node.hasChildNodes()) { - NodeList nodeList = node.getChildNodes(); - int nChildren = nodeList.getLength(); - - for (int i = 0; i < nChildren; i++) { - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.TEXT_NODE) { - - // this is for grabbing text nodes. - String s = child.getNodeValue(); - - if (s.length() > 0) { - if (style != null) - encoder.addElement(new WseTextRun(s, style, styleCat, - fontTable, colorTable)); - else - encoder.addElement(new WseTextRun(s, defTextStyle, - styleCat, fontTable, colorTable)); - } - - } else if (child.getNodeType() == Node.ELEMENT_NODE) { - - String childNodeName = child.getNodeName(); - - if (childNodeName.equals(TAG_SPACE)) { - - // this is for text:s tags. - NamedNodeMap map = child.getAttributes(); - Node attr = map.getNamedItem(ATTRIBUTE_SPACE_COUNT); - StringBuffer space = new StringBuffer(" "); - int count = 1; - - if (attr != null) { - try { - String countStr = attr.getNodeValue(); - count = Integer.parseInt(countStr.trim()); - } catch (NumberFormatException e) { - Debug.log(Debug.ERROR, "Problem parsing space tag", e); - } - } - - for (int j = 1; j < count; j++) - space.append(" "); - - encoder.addElement(new WseTextRun(space.toString(), - defTextStyle, - styleCat, fontTable, colorTable)); - Debug.log(Debug.INFO, "<SPACE count=\"" + count + "\" />"); - - } else if (childNodeName.equals(TAG_TAB_STOP)) { - - // this is for text:tab-stop - encoder.addElement(new WseTextRun("\t", defTextStyle, styleCat, - fontTable, colorTable)); - - Debug.log(Debug.INFO, "<TAB/>"); - - } else if (childNodeName.equals(TAG_LINE_BREAK)) { - - // this is for text:line-break - encoder.addElement(new WseTextRun("\n", defTextStyle, - styleCat, fontTable, colorTable)); - - Debug.log(Debug.INFO, "<LINE-BREAK/>"); - - } else if (childNodeName.equals(TAG_SPAN)) { - - // this is for text:span - Debug.log(Debug.INFO, "<SPAN>"); - traverseParaContents(child, defTextStyle); - Debug.log(Debug.INFO, "</SPAN>"); - - } else if (childNodeName.equals(TAG_HYPERLINK)) { - - // this is for text:a - Debug.log(Debug.INFO, "<HYPERLINK>"); - traverseParaContents(child, defTextStyle); - Debug.log(Debug.INFO, "<HYPERLINK/>"); - - } else if (childNodeName.equals(TAG_BOOKMARK) || - childNodeName.equals(TAG_BOOKMARK_START)) { - - Debug.log(Debug.INFO, "<BOOKMARK/>"); - - } else { - - Debug.log(Debug.INFO, "<OTHERS " /* + XmlDebug.nodeInfo(child) */ + " />"); - } - - } - - } - } - } - - - /** - * This method traverses list tags <i>text:unordered-list</i> and - * <i>text:ordered-list</i>. A list can only contain one optional - * <i>text:list-header</i> and one or more <i>text:list-item</i> - * elements. - * - * @param node A list <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseList(Node node) throws IOException { - - Debug.log(Debug.TRACE, "<LIST>"); - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_LIST_ITEM)) { - - traverseListItem(child); - - } else if (nodeName.equals(TAG_LIST_HEADER)) { - - traverseListHeader(child); - - } else { - - Debug.log(Debug.ERROR, "<INVALID-XML-BUG " + " />"); - } - } - } - } - - Debug.log(Debug.TRACE, "</LIST>"); - } - - - /** - * This method traverses a <i>text:list-header</i> element. - * It contains one or more <i>text:p</i> elements. - * - * @param node A list header <code>Node</code>. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseListHeader(Node node) throws IOException { - - Debug.log(Debug.TRACE, "<LIST-HEADER>"); - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH)) { - - traverseParagraph(child); - - } else { - - Debug.log(Debug.TRACE, "<INVALID-XML-BUG " + " />"); - } - } - } - } - - Debug.log(Debug.TRACE, "</LIST-HEADER>"); - } - - - /** - * This method will traverse a <i>text:list-item</i>. - * A list item may contain one or more of <i>text:p</i>, - * <i>text:h</i>, <i>text:section</i>, - * <i>text:ordered-list</i> and <i>text:unordered-list</i>. - * - * This method currently only implements grabbing <i>text:p</i>, - * <i>text:h</i>, <i>text:unordered-list</i> and - * <i>text:ordered-list</i>. - * - * @param node <code>Node</code> to traverse. - * - * @throws IOException If any I/O error occurs. - */ - private void traverseListItem(Node node) throws IOException { - - Debug.log(Debug.TRACE, "<LIST-ITEM>"); - - if (node.hasChildNodes()) { - - NodeList nodeList = node.getChildNodes(); - int len = nodeList.getLength(); - - for (int i = 0; i < len; i++) { - - Node child = nodeList.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - - String nodeName = child.getNodeName(); - - if (nodeName.equals(TAG_PARAGRAPH)) { - - traverseParagraph(child); - - } else if (nodeName.equals(TAG_UNORDERED_LIST)) { - - traverseList(child); - - } else if (nodeName.equals(TAG_ORDERED_LIST)) { - - traverseList(child); - - } else { - - Debug.log(Debug.ERROR, "<INVALID-XML-BUG " + " />"); - } - } - } - } - - Debug.log(Debug.TRACE, "</LIST-ITEM>"); - } - - - /** - * Look up a <code>Node</code> object's named attribute and return - * its value - * - * @param node The <code>Node</code>. - * @param name The attribute name. - * - * @return The value of the named attribute - */ - private String findAttribute(Node node, String name) { - NamedNodeMap attrNodes = node.getAttributes(); - if (attrNodes != null) { - int len = attrNodes.getLength(); - for (int i = 0; i < len; i++) { - Node attr = attrNodes.item(i); - if (attr.getNodeName().equals(name)) - return attr.getNodeValue(); - } - } - return null; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/PluginFactoryImpl.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/PluginFactoryImpl.java deleted file mode 100644 index f4eb5dcb11a7..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/PluginFactoryImpl.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import org.openoffice.xmerge.Document; -import org.openoffice.xmerge.ConvertData; -import org.openoffice.xmerge.DocumentMerger; -import org.openoffice.xmerge.DocumentMergerFactory; -import org.openoffice.xmerge.DocumentSerializer; -import org.openoffice.xmerge.DocumentSerializerFactory; -import org.openoffice.xmerge.DocumentDeserializer; -import org.openoffice.xmerge.DocumentDeserializerFactory; -import org.openoffice.xmerge.ConverterCapabilities; -import org.openoffice.xmerge.converter.xml.sxw.SxwPluginFactory; -import org.openoffice.xmerge.converter.palm.PalmDocument; -import org.openoffice.xmerge.util.registry.ConverterInfo; - -import java.io.InputStream; -import java.io.IOException; - - -/** - * <p>WordSmith implementation of a <code>PluginFactory</code> that - * encapsulates conversion of StarWriter XML format to and from - * WordSmith format.</p> - * - * The superclass produces a particular - * {@link org.openoffice.xmerge.Document Document} - * object, i.e. - * {@link org.openoffice.xmerge.converter.xml.sxw.SxwDocument - * SxwDocument} that the converters in this class works with. Thus, - * this class only implements the methods that produces the converters, - * i.e. {@link - * org.openoffice.xmerge.DocumentSerializer - * DocumentSerializer} and {@link - * org.openoffice.xmerge.DocumentDeserializer - * DocumentDeserializer}; - * as well as the {@link - * org.openoffice.xmerge.ConverterCapabilities - * ConverterCapabilities} object that is specific to this format - * conversion. That superclass also produces a {@link - * org.openoffice.xmerge.DocumentMerger DocumentMerger} - * object, i.e. {@link - * org.openoffice.xmerge.converter.xml.sxw.wordsmith.DocumentMergerImpl - * DocumentMergerImpl} which this class derives the functionality.</p> - * - */ -public final class PluginFactoryImpl extends SxwPluginFactory - implements DocumentDeserializerFactory, DocumentSerializerFactory, - DocumentMergerFactory { - - public PluginFactoryImpl(ConverterInfo ci) { - super(ci); - } - - /** ConverterCapabilities object for this type of conversion. */ - private final static ConverterCapabilities converterCap = - new ConverterCapabilitiesImpl(); - - - /** - * Returns an instance of <code>DocumentSerializerImpl</code>, which is - * an implementation of <code>DocumentSerializer</code> interface. - * - * @param doc <code>Document</code> object to be converted/serialized. - * - * @return A <code>DocumentSerializerImpl</code> object. - */ - public DocumentSerializer createDocumentSerializer(Document doc) { - - return new DocumentSerializerImpl(doc); - } - - - /** - * Returns an instance of <code>DocumentDeserializerImpl</code>, - * which is an implementation of <code>DocumentDeserializer</code> - * interface. - * - * @param cd <code>ConvertData</code> object for reading data - * which will be converted back to a - * <code>Document</code> object. - * - * @return A <code>DocumentDeserializerImpl</code> object. - */ - public DocumentDeserializer createDocumentDeserializer(ConvertData cd) { - - return new DocumentDeserializerImpl(cd); - } - - /** - * Returns an instance of <code>DocumentMergerImpl</code>, - * which is an implementation of the <code>DocumentMerger</code> - * interface. - * - * @param doc <code>Document</code> to merge. - * - * @return A DocumentMergerImpl object. - */ - public DocumentMerger createDocumentMerger(Document doc) { - - ConverterCapabilities cc = converterCap; - DocumentMergerImpl merger = new DocumentMergerImpl(doc, cc); - return merger; - } - - /** - * Returns an instance of the DeviceDocument - * which is an implementation of the <code>DocumentMerger</code> - * interface. - * - * @return A Device Document object - */ - public Document createDeviceDocument(String name, InputStream is) - throws IOException { - - PalmDocument palmDoc = new PalmDocument(is); - return palmDoc; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java deleted file mode 100644 index cb12e2df5cac..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSDecoder.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; - -import org.openoffice.xmerge.converter.palm.Record; -import org.openoffice.xmerge.util.Debug; -import org.openoffice.xmerge.util.Resources; - -/** - * This class is used by {@link - * org.openoffice.xmerge.converter.xml.sxw.wordsmith.DocumentDeserializerImpl - * DocumentDeserializerImpl} to decode a WordSmith format. It currently - * decodes the text content into a single <code>String</code> object. - * - */ -final class WSDecoder implements DOCConstants { - - /** For decoding purposes. */ - private final static int COUNT_BITS = 3; - - /** Resources object for I18N. */ - private Resources res = null; - - /** - * Default constructor creates a header and - * a text buffer for holding all the text in - * the DOC db. - */ - WSDecoder() { - res = Resources.getInstance(); - } - - /** - * Decode the text records into a single <code>byte</code> array. - * - * @param recs <code>Record</code> array holding WordSmith - * contents. - * - * @throws IOException If any I/O error occurs. - */ - byte[] parseRecords(Record[] recs) throws IOException { - - // read the header record - HeaderInfo header = readHeader(recs[0].getBytes()); - dumpHeader(header); - byte[][] byteArrays = new byte[recs.length - 1][]; - for (int i = 0; i < recs.length - 1; i++) byteArrays[i] = null; - - switch (header.version & ~4) { // DJP: "4" indicates OOB data is present. - // Add a constant to handle this, might also need code to handle it. - - case COMPRESSED: - case 3: // DJP: determined this empirically. Are Herbie's constants wrong? - for (int i = 1; i < recs.length; i++) { - byteArrays[i-1] = decompress(recs[i].getBytes(), - header.textRecordSize); - Debug.log(Debug.INFO, "processing " + byteArrays[i-1].length + " bytes"); - } - - break; - - case UNCOMPRESSED: - for (int i = 1; i < recs.length; i++) { - byteArrays[i-1] = recs[i].getBytes(); - Debug.log(Debug.INFO, "processing " + byteArrays[i-1].length + " bytes"); - } - - break; - - default: - throw new IOException(res.getString("UNKNOWN_DOC_VERSION")); - - } - - // Concatenate byteArrays[][] into a single byte array. - int length = 0; - for (int i = 0; i < recs.length - 1; i++) - length += byteArrays[i].length; - byte bigArray[] = new byte[length]; - int offset = 0; - for (int i = 0; i < recs.length - 1; i++) { - System.arraycopy(byteArrays[i], 0, bigArray, offset, - byteArrays[i].length); - offset += byteArrays[i].length; - } - return bigArray; - } - - - /** - * Decode the text records into a <code>Wse</code> array. - * - * @param recs <code>Record</code> array holding DOC - * contents. - * - * @throws IOException If any I/O error occurs. - */ - Wse[] parseDocument(Record[] recs) throws IOException { - - java.util.ArrayList<Wse> v = new java.util.ArrayList<Wse>(20); - WseFontTable fontTable = null; - WseColorTable colorTable = null; - - // rawData is the document data to be parsed. - byte rawData[] = parseRecords(recs); - - // beginning of document has some header information, including - // optional font and color tables. - // DJP: maybe should add a new WSelement (docHeader) to hold - // header info. - // DJP: finish code here to parse header - if (rawData[0] != 2) throw new IOException(); - int nParagraphs = util.intFrom4bytes(rawData, 2); - int nAtoms = util.intFrom4bytes(rawData, 6); - int nChars = util.intFrom4bytes(rawData, 10); - int miscSize = util.intFrom4bytes(rawData, 14); - int curIndex = 18; - - while (curIndex < rawData.length) { - if (WsePara.isValid(rawData, curIndex)) { - v.add(new WsePara(rawData, curIndex)); - curIndex = WsePara.computeNewIndex(curIndex); - } else if (WseTextRun.isValid(rawData, curIndex)) { - v.add(new WseTextRun(rawData, curIndex, fontTable, colorTable)); - curIndex = WseTextRun.computeNewIndex(rawData, curIndex); - } else if (WseFontTable.isValid(rawData, curIndex)) { - fontTable = new WseFontTable(rawData, curIndex); - v.add(fontTable); - curIndex = WseFontTable.computeNewIndex(rawData, curIndex); - } else if (WseColorTable.isValid(rawData, curIndex)) { - colorTable = new WseColorTable(rawData, curIndex); - v.add(colorTable); - curIndex = WseColorTable.computeNewIndex(rawData, curIndex); - } else { - Debug.log(Debug.ERROR, "Unknown code " + rawData[curIndex]); - throw new IOException(); - } - } - - return v.toArray(new Wse[2]); - } - - - /** - * <p>Decompress the <code>byte</code> array.</p> - * - * <p>The resulting uncompressed <code>byte</code> array - * should be within <code>textRecordSize</code> length, - * definitely within twice the size it claims, else treat - * it as a problem with the encoding of that PDB and - * throw <code>IOException</code>.</p> - * - * @param cBytes Compressed <code>byte</code> array - * @param textRecordSize Size of uncompressed <code>byte</code> - * array - * - * @throws IOException If <code>textRecordSize</codeL < - * <code>cBytes.length</code>. - */ - private byte[] decompress(byte[] cBytes, int textRecordSize) - throws IOException { - - // create byte array for storing uncompressed bytes - // it should be within textRecordSize range, definitely - // within twice of textRecordSize! if not, then - // an ArrayIndexOutOfBoundsException will get thrown, - // and it should be converted into an IOException, and - // treat it as a conversion error. - byte[] uBytes = new byte[textRecordSize*2]; - - int up = 0; - int cp = 0; - - try { - - while (cp < cBytes.length) { - - int c = cBytes[cp++] & 0xff; - - // codes 1...8 mean copy that many bytes - if (c > 0 && c < 9) { - - while (c-- > 0) - uBytes[up++] = cBytes[cp++]; - } - - // codes 0, 9...0x7F represent themselves - else if (c < 0x80) { - uBytes[up++] = (byte) c; - } - - // codes 0xC0...0xFF represent "space + ascii char" - else if (c >= 0xC0) { - uBytes[up++] = (byte) ' '; - uBytes[up++] = (byte) (c ^ 0x80); - } - - // codes 0x80...0xBf represent sequences - else { - c <<= 8; - c += cBytes[cp++] & 0xff; - int m = (c & 0x3fff) >> COUNT_BITS; - int n = c & ((1 << COUNT_BITS) - 1); - n += COUNT_BITS; - while (n-- > 0) { - uBytes[up] = uBytes[up - m]; - up++; - } - } - } - - } catch (ArrayIndexOutOfBoundsException e) { - - throw new IOException( - res.getString("DOC_TEXT_RECORD_SIZE_EXCEEDED")); - } - - // note that ubytes may be larger that the amount of - // uncompressed bytes, so trim it to another byte array - // with the exact size. - byte[] textBytes = new byte[up]; - System.arraycopy(uBytes, 0, textBytes, 0, up); - - return textBytes; - } - - - /** - * Read the header <code>byte</code> array. - * - * @param bytes <code>byte</code> array containing header - * record data. - * - * @return <code>HeaderInfo</code> object. - * - * @throws IOException If any I/O error occurs. - */ - private HeaderInfo readHeader(byte[] bytes) throws IOException { - - HeaderInfo header = new HeaderInfo(); - - ByteArrayInputStream bis = new ByteArrayInputStream(bytes); - DataInputStream dis = new DataInputStream(bis); - - // Normally the first 2 bytes comprised of the version - // which should either be COMPRESSED or UNCOMPRESSED - // SmartDoc/Quickword would add a 0x01 to the first - // byte, thus their version would be 0x0101 for UNCOMPRESSED - // instead of 0x0001 and 0x0102 for UNCOMPRESSED instead of - // 0x0002. - - dis.readByte(); - header.version = dis.readByte(); - - // read extra 2 unused bytes - dis.readShort(); - - // Read the text length, this should be unsigned 4 bytes. - // We could store the read value into a long, but then - // our current buffer limit is the max positive of an int. - // That is a large enough limit, thus we shall stay with - // storing the value in an int. If it exceeds, then - // an IOException should be thrown. - header.textLen = dis.readInt(); - if (header.textLen < 0) { - throw new IOException(res.getString("DOC_TEXT_LENGTH_EXCEEDED")); - } - - // read the number of records - unsigned 2 bytes - dis.readShort(); - - // read the record size - unsigned 2 bytes - header.textRecordSize = dis.readShort() & 0x0000ffff; - - // read extra 4 unused bytes - dis.readInt(); - - return header; - } - - - /** - * Prints out header info into log. - * Used for debugging purposes only. - * - * @param header <code>HeaderInfo</code> structure. - */ - private void dumpHeader(HeaderInfo header) { - /* - log("<DOC_INFO "); - log("version=\"" + header.version + "\" "); - log("text-length=\"" + header.textLen + "\" "); - log("number-of-records=\"" + header.textRecordCount + "\" "); - log("record-size=\"" + header.textRecordSize + "\" />\n"); - */ - } - - - /** - * Inner class to store DOC header information. - */ - private class HeaderInfo { - - /** length of text section */ - int textLen = 0; - - /** - * size of a text record. This is normally the same as - * TEXT_RECORD_SIZE, but some applications may modify this. - */ - int textRecordSize = 0; - - /** compression type */ - int version = 0; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java deleted file mode 100644 index af9980d87183..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WSEncoder.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.ArrayList; - -import org.openoffice.xmerge.converter.palm.Record; - -/** - * This class is used by {@link - * org.openoffice.xmerge.converter.xml.sxw.wordsmith.DocumentDeserializerImpl - * DocumentDeserializerImpl} to encode the WordSmith format. - * - */ - -// DJP: replace 4096 w/ a defined constant - -final class WSEncoder { - - /* DJP: These should probably go somewhere else! */ - /** Constant for uncompressed version. */ - public static final short UNCOMPRESSED = 1; - - /** Constant for compressed version. */ - public static final short COMPRESSED = 2; - - /** Constant used for spare fields. */ - public static final int SPARE = 0; - - /* WordSmith Header information. */ - private short version; - private int textLen; - private short maxRecSize; - - - /* WordSmith document elements. */ - WseHeader header = null; - WseFontTable ft = null; - WseColorTable ct = null; - private ArrayList<Wse> elements; // paragraphs & text runs - - /* Totals for the WordSmith document. */ - int nrParagraphs = 0; - int nrAtoms = 0; - int nrChars = 0; - - - /** - * Default constructor creates a header and - * a text buffer for holding all the text in - * the WordSmith database. - */ - WSEncoder() { - version = 1; - textLen = 0; - maxRecSize = 4096; - elements = new ArrayList<Wse>(); - } - - - /** - * This method adds a new element to the WordSmith document. - * - * @param elem WordSmith document element to add - */ - void addElement(Wse elem) { - if (elem.getClass() == WseHeader.class) - header = (WseHeader)elem; - else if (elem.getClass() == WseFontTable.class) - ft = (WseFontTable)elem; - else if (elem.getClass() == WseColorTable.class) - ct = (WseColorTable)elem; - else - elements.add(elem); - } - - - /** - * This method encodes the information given to - * an array of palm Records in the WordSmith database format. - * - * @return <code>Record</code> array holding WordSmith contents. - * - * @throws IOException If any I/O error occurs. - */ - Record[] getRecords() throws IOException { - - ArrayList<Record> allRecs = new ArrayList<Record>(); - int nElements = elements.size(); - - // Count up the number of paragraphs, atoms, and characters. - int currElement = 0; - while (currElement < nElements) { - Wse e = elements.get(currElement++); - if (e.getClass() == WsePara.class) - nrParagraphs++; - if (e.getClass() == WseTextRun.class) { - nrAtoms++; - nrChars += ((WseTextRun)e).getText().length(); - } - } - - byte[] currRec = new byte[4096]; - int currRecLen = 0; - - // This code assumes that the WordSmith header, font table, - // and color table total less than 4096 bytes. - header = new WseHeader(nrParagraphs, nrAtoms, nrChars, ft, ct); - System.arraycopy(header.getBytes(), 0, - currRec, currRecLen, header.getByteCount()); - currRecLen += header.getByteCount(); - - if (ft != null) { - System.arraycopy(ft.getBytes(), 0, currRec, currRecLen, - ft.getByteCount()); - currRecLen += ft.getByteCount(); - } - if (ct != null) { - System.arraycopy(ct.getBytes(), 0, currRec, currRecLen, - ct.getByteCount()); - currRecLen += ct.getByteCount(); - } - - currElement = 0; - while (currElement < nElements) { - Wse e = elements.get(currElement++); - int length = e.getByteCount(); - if ((length + currRecLen) <= 4096) { - System.arraycopy(e.getBytes(), 0, currRec, currRecLen, length); - currRecLen += length; - } else { - // Copy in enough to get to full size, then create a - // new Record and add it to the Vector. - int firstPartLen = 4096 - currRecLen; - System.arraycopy(e.getBytes(), 0, currRec, currRecLen, - firstPartLen); - Record r = new Record(currRec); - allRecs.add(r); - - // Put the remainder at the beginning of the next record - currRecLen = 0; - System.arraycopy(e.getBytes(), firstPartLen, currRec, - currRecLen, length - firstPartLen); - currRecLen += length - firstPartLen; - } - } - - // Processed all the elements. Write out any remaining partial record. - if (currRecLen > 0) { - byte[] partial = new byte[currRecLen]; - System.arraycopy(currRec, 0, partial, 0, currRecLen); - Record rr = new Record(partial); - allRecs.add(rr); - } - - - // Record 0 is the WordSmith header. Do it last since it - // contains totals for the entire document. It goes - // before everything else. - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - DataOutputStream dos = new DataOutputStream(bos); - dos.writeShort(version); - dos.writeShort(0); - dos.writeInt(textLen); - dos.writeShort(allRecs.size()); - dos.writeShort(maxRecSize); - dos.writeInt(0); - allRecs.add(0, new Record(bos.toByteArray())); - - // Convert Vector of Records to an array and return it. - int nRecs = allRecs.size(); - Record recs[] = new Record[nRecs]; - for (int i = 0; i < nRecs; i++) - recs[i] = allRecs.get(i); - return recs; - } - -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/Wse.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/Wse.java deleted file mode 100644 index 9e80feab7e1e..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/Wse.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - - - -/** - * This is the superclass for all elements in a WordSmith document. - * Elements can be paragraphs, text runs, font tables, or color tables. - * - */ -abstract class Wse { - - /** - * Return the total number of bytes needed to represent this - * object. - * - * @return The total number of bytes needed to represent this - * object. - */ - abstract int getByteCount(); - - - /** - * Return an <code>byte</code> array representing this element. - * - * @return An <code>bytes</code> array representing this element. - */ - abstract byte[] getBytes(); -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java deleted file mode 100644 index 5651ee9dbf97..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseColorTable.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import java.awt.Color; - -/** - * This class represents a color table in a WordSmith document. - * - */ -class WseColorTable extends Wse { - - private Color fgColors[]; - private Color bgColors[]; - - /** - * Constructor to use when going from DOM to WordSmith - */ - public WseColorTable() { - fgColors = new Color[16]; - bgColors = new Color[16]; - - // Always need these two! - fgColors[0] = Color.black; - bgColors[0] = Color.white; - - } - - /** - * Constructor to use when going from WordSmith to DOM. - * - * @param dataArray <code>byte</code> array. - * @param i The index. - */ - public WseColorTable(byte dataArray[], int i) { - fgColors = new Color[16]; - bgColors = new Color[16]; - - i += 2; // Skip leading "64" and table length field. - for (int k = 0; k < 16; k++) { - fgColors[k] = new Color(dataArray[i+1] & 0xFF, - dataArray[i+2] & 0xFF, - dataArray[i+3] & 0xFF); - i += 4; - } - for (int k = 0; k < 16; k++) { - bgColors[k] = new Color(dataArray[i+1] & 0xFF, - dataArray[i+2] & 0xFF, - dataArray[i+3] & 0xFF); - i += 4; - } - - } - - - /** - * Compute the index of the first <code>byte</code> following the - * paragraph descriptor, assuming that - * <code>dataArray[startIndex]</code> is the beginning of a valid - * paragraph descriptor. - * - * @param dataArray <code>byte</code array. - * @param startIndex The start index. - * - * @return The index of the first <code>byte</code> following the - * paragraph description. - */ - static int computeNewIndex(byte dataArray[], int startIndex) { - int tableLen = dataArray[startIndex + 1]; - tableLen &= 0xFF; // eliminate problems with sign-extension - return startIndex + tableLen + 2; - } - - - /** - * Return true if <code>dataArray[startIndex]</code> is the start - * of a valid paragraph descriptor. - * - * @param dataArray <code>byte</code> array. - * @param startIndex Start index. - * - * @return true if <code>dataArray[startIndex]</code> is the start - * of a valid paragraph descriptor, false otherwise. - */ - static boolean isValid(byte dataArray[], int startIndex) { - try { - if (dataArray[startIndex] != 64) - return false; - int len = dataArray[startIndex + 1]; - len &= 0xFF; // eliminate problems with sign-extension - int temp = dataArray[startIndex + len + 2]; // probe end of table - } catch (ArrayIndexOutOfBoundsException e) { - return false; - } - return true; - } - - - /** - * Return the number of bytes needed to represent this color table. - * - * @return The byte count. - */ - int getByteCount() { - return (32 * 4) + 1 + 1; - } - - - /** - * Return a <code>byte</code> array representing this color table. - * - * @return <code>bytes</code> array representing this color table. - */ - byte[] getBytes() { - byte[] b = new byte[(32 * 4) + 1 + 1]; - b[0] = 0x40; - b[1] = (byte)128; - int i = 2; - // int indVal = 0xd8; - int indVal = 0; - - for (int j = 0; j < 16; j++) { - b[i++] = (byte)indVal++; - if (fgColors[j] != null) { - b[i++] = (byte)fgColors[j].getRed(); - b[i++] = (byte)fgColors[j].getGreen(); - b[i++] = (byte)fgColors[j].getBlue(); - } else { - b[i++] = (byte)0; - b[i++] = (byte)0; - b[i++] = (byte)0; - } - } - - for (int j = 0; j < 16; j++) { - b[i++] = (byte)indVal++; - if (bgColors[j] != null) { - b[i++] = (byte)bgColors[j].getRed(); - b[i++] = (byte)bgColors[j].getGreen(); - b[i++] = (byte)bgColors[j].getBlue(); - } else { - b[i++] = (byte)0xFF; - b[i++] = (byte)0xFF; - b[i++] = (byte)0xFF; - } - } - - return b; - } - - - /** - * Return the index of the specified foreground or background - * <code>Color</code>. (If the color is not already in the table, - * it will be added.) - * - * Note that the implementation of this may include a "margin of - * error" to prevent the color table from being filled up too - * quickly. - * - * @param c The <code>Color</code>. - * @param foreground true if foreground color, false if background - * color - * - * @return The index of the specified foreground or background - * <code>Color</code>. - * - * DJP: how to handle table overflow? - */ - int findColor(Color c, boolean foreground) { - - Color colorArray[] = foreground ? fgColors : bgColors; - - for (int i = 0; i < 16; i++) { - if (colorArray[i] != null) { - if (colorArray[i].equals(c)) - return i; - } - else - break; // hit a null entry - no more colors in table! - } - - // Color was not found in the table. Add it. - for (int i = 0; i < 16; i++) { - if (colorArray[i] == null) { - colorArray[i] = c; - return i; - } - } - return 0; // Default - we should never get here though. - } - - - /** - * Given an index, return the <code>Color</code> from the table. - * - * @param index The index - * @param foreground true if foreground color, false if background - * color - * - * @return The <code>Color</code> at the specified index. - */ - Color getColor(int index, boolean foreground) { - - Color colorArray[] = foreground ? fgColors : bgColors; - return colorArray[index]; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java deleted file mode 100644 index 391dbcd8a7bc..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseFontTable.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - - -/** - * <p>This class represents a font table in a WordSmith document. - * A font table is represented as follows:</p> - * - * <p><blockquote> - * binary "3"<br> - * two-byte length of the table of strings which follows<br> - * string table (null-terminated strings) representing font names - * </blockquote></p> - * - */ -class WseFontTable extends Wse { - - java.util.ArrayList<String> fontNames = new java.util.ArrayList<String>(10); - - - /** - * Constructor for use when going from DOM to WordSmith. - */ - public WseFontTable() { - } - - - /** - * Constructor for use when going from WordSmith to DOM. - * - * @param dataArray <code>byte</code> array. - * @param i The index. - */ - public WseFontTable(byte dataArray[], int i) { - i++; - int tableLen = ((dataArray[i] << 8) | (dataArray[i+1] & 0xFF)); - i += 2; - while (tableLen > 0) { - int j = 0; - while (dataArray[i + j] != 0) j++; - fontNames.add(new String(dataArray, i, j)); - tableLen -= (j + 1); - i += (j + 1); - } - } - - - /** - * Add a new font to the table. - * - * @param newFontName The new font name. - */ - public void add(String newFontName) { - if (newFontName != null) - fontNames.add(newFontName); - } - - - /** - * Return a font name from the table, or null if invalid index. - * - * @param index The font name index. - * - * @return The font name. - */ - public String getFontName(int index) { - try { - return fontNames.get(index); - } catch (ArrayIndexOutOfBoundsException e) { - return null; - } - } - - /** - * Return the index of a font name in the table, or -1 if not found. - * - * @param fontName The font name. - * - * @return The index of the font name, or -1 if not found. - */ - public int getFontIndex(String fontName) { - int len = fontNames.size(); - for (int i = 0; i < len; i++) { - String name = fontNames.get(i); - if (name.equals(fontName)) - return i; - } - return -1; - } - - - /** - * Compute the index of the first <code>byte</code> following the - * paragraph descriptor, assuming that - * <code>dataArray[startIndex]</code> is the beginning of a valid - * paragraph descriptor. - * - * @param dataArray <code>byte</code> array. - * @param startIndex The start index. - * - * @return The index of the first <code>byte</code> following the - * paragraph description. - */ - static int computeNewIndex(byte dataArray[], int startIndex) { - startIndex++; // Skip the leading "3" - int tableLen = ((dataArray[startIndex] << 8) | (dataArray[startIndex+1] & 0xFF)); - tableLen &= 0xFFFF; // eliminate problems with sign-extension - return startIndex + tableLen + 2; - } - - - /** - * Return true if <code>dataArray[startIndex]</code> is the start of a - * valid paragraph descriptor. - * - * @param dataArray <code>byte</code> string. - * @param startIndex Start index. - * - * @return true if <code>dataArray[startIndex]</code> is the start - * of a valid paragraph descriptor, false otherwise. - */ - static boolean isValid(byte dataArray[], int startIndex) { - try { - if (dataArray[startIndex] != 3) - return false; - int len = ((dataArray[startIndex+1] << 8) - | (dataArray[startIndex+2] & 0xFF)); - len &= 0xFFFF; // eliminate problems with sign-extension - - if (dataArray[startIndex + len + 2] != 0) - return false; - } catch (ArrayIndexOutOfBoundsException e) { - return false; - } - return true; - } - - - /** - * Return the number of bytes needed to represent this font table. - * - * @return The number of bytes needed to represent this font table. - */ - int getByteCount() { - - int length = 3; // leading "3" plus 2 bytes for length. - int nFonts = fontNames.size(); - for (int i = 0; i < nFonts; i++) { - String name = fontNames.get(i); - length += name.length() + 1; // extra byte is for trailing "0" - } - return length; - } - - /** - * Return a <code>byte</code> array representing this font table. - * - * @return An <code>byte</code> array representing this font table. - */ - byte[] getBytes() { - - int length = getByteCount(); - int nFonts = fontNames.size(); - byte b[] = new byte[length]; - b[0] = 3; - length -= 3; - b[1] = (byte)(length >> 8); - b[2] = (byte)(length & 0xFF); - int indx = 3; - for (int i = 0; i < nFonts; i++) { - String name = fontNames.get(i); - byte bname[] = name.getBytes(); - System.arraycopy(bname, 0, b, indx, bname.length); - indx += bname.length; - b[indx++] = 0; - } - return b; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseHeader.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseHeader.java deleted file mode 100644 index eb62be7437e3..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseHeader.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import java.io.IOException; -import java.io.DataOutputStream; -import java.io.ByteArrayOutputStream; - -/** - * This class represents a WordSmith document header. - * - */ -class WseHeader extends Wse { - - private int nParagraphs = 0; - private int nAtoms = 0; - private int nChars = 0; - private int miscSize = 0; - - /** - * Constructor for use when going from DOM to WordSmith. - * - * @param nPara The number of paragraphs. - * @param nAtoms The number of atoms. - * @param nChars The number of characters. - * @param ft The font table. - * @param ct The color table. - */ - public WseHeader(int nPara, int nAtoms, int nChars, WseFontTable ft, - WseColorTable ct) { - nParagraphs = nPara; - this.nAtoms = nAtoms; - this.nChars = nChars; - if (ft != null) miscSize += ft.getByteCount(); - if (ct != null) miscSize += ct.getByteCount(); - } - - - /** - * Constructor for use when going from WordSmith to DOM. - * - * @param dataArray <code>byte</code> array. - * @param i Index. - */ - public WseHeader(byte dataArray[], int i) { - // DJP: write this! - } - - /** - * Return true if <code>dataArray[startIndex]</code> is the start - * of a document header. - * - * @param dataArray <code>byte</code> array. - * @param startIndex The index. - * - * @return true if <code>dataArray[startIndex]</code> is the start - * of a document header, false otherwise. - */ - static boolean isValid(byte dataArray[], int startIndex) { - return ((dataArray[startIndex] == 2) - && (dataArray[startIndex + 1] == 4)); - } - - - /** - * Compute and return the index of the first <code>byte</code> - * following this element. It is assumed that the element - * starting at <code>dataArray[startIndex]</code> is valid. - * - * @param startIndex The start index. - * - * @return The first <code>byte</code> following this element. - */ - static int computeNewIndex(int startIndex) { - return startIndex + 18; - } - - - /** - * Return the total number of bytes needed to represent this. - * - * @return The total number of bytes needed to represent this. - */ - int getByteCount() { - return 18; - } - - - /** - * Return a <code>byte</code> array representing this element. - * - * @return A <code>byte</code> array representing this element. - */ - byte[] getBytes() { - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - DataOutputStream os = new DataOutputStream(bs); - - try { - os.write(2); // binary doc indicator - os.write(4); // binary header indicator - - os.writeInt(nParagraphs); - os.writeInt(nAtoms); - os.writeInt(nChars); - os.writeInt(miscSize); - - } catch (IOException e) { - e.printStackTrace(); - } - - return bs.toByteArray(); - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WsePara.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WsePara.java deleted file mode 100644 index fc4807a7f51c..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WsePara.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import org.openoffice.xmerge.converter.xml.ParaStyle; -import org.openoffice.xmerge.converter.xml.StyleCatalog; - - -/** - * This class represents a paragraph in a WordSmith document. - * (A paragraph is "5" followed by 12 bytes of attributes.) - * - */ -class WsePara extends Wse { - - private byte spaceBefore = 0; - private byte spaceAfter = 0; - private byte leftIndent = 0; - private byte firstIndent = 0; - private byte rightIndent = 0; - private byte misc = 0; - private byte style = 0; - private byte lineSpace = 0; - private byte outline = 0; - private byte reserved = 0; - - private static final byte LS_EXACTLY = (byte)0xC0; - private static final byte LS_ATLEAST = (byte)0x80; - private static final byte LS_MULTIPLE = (byte)0x40; - private static final byte LS_VALUEMASK = (byte)0x3F; - - private static final byte ALIGN_RIGHT = (byte)2; - private static final byte ALIGN_LEFT = (byte)0; - private static final byte ALIGN_CENTER = (byte)1; - private static final byte ALIGN_JUST = (byte)3; - - private StyleCatalog sc = null; - - - /** - * Constructor for use when going from DOM to WordSmith. - * - * @param p The paragraph style. - * @param sc The <code>StyleCatalog</code>. - */ - public WsePara(ParaStyle p, StyleCatalog sc) { - this.sc = sc; - ParaStyle ps = (ParaStyle)p.getResolved(); - - if (ps.isAttributeSet(ParaStyle.MARGIN_LEFT)) { - double temp = ps.getAttribute(ParaStyle.MARGIN_LEFT) * 1.6 / 100; - leftIndent = (byte) temp; - if ((temp - leftIndent) > 0.5) leftIndent++; - } - - if (ps.isAttributeSet(ParaStyle.MARGIN_RIGHT)) { - double temp = ps.getAttribute(ParaStyle.MARGIN_RIGHT) * 1.6 / 100; - rightIndent = (byte) temp; - if ((temp - rightIndent) > 0.5) rightIndent++; - } - - if (ps.isAttributeSet(ParaStyle.TEXT_INDENT)) { - double temp = ps.getAttribute(ParaStyle.TEXT_INDENT) * 1.6 / 100; - firstIndent = (byte) temp; - if ((temp - firstIndent) > 0.5) firstIndent++; - } - - if (ps.isAttributeSet(ParaStyle.MARGIN_TOP)) { - double temp = ps.getAttribute(ParaStyle.MARGIN_TOP) * 1.6 / 100; - spaceBefore = (byte) temp; - if ((temp - spaceBefore) > 0.5) spaceBefore++; - } - - if (ps.isAttributeSet(ParaStyle.MARGIN_BOTTOM)) { - double temp = ps.getAttribute(ParaStyle.MARGIN_BOTTOM) * 1.6 / 100; - spaceAfter = (byte) temp; - if ((temp - spaceAfter) > 0.5) spaceAfter++; - } - - if (ps.isAttributeSet(ParaStyle.LINE_HEIGHT)) { - int lh = ps.getAttribute(ParaStyle.LINE_HEIGHT); - if ((lh & ~ParaStyle.LH_VALUEMASK) == 0) - lineSpace = (byte)(LS_MULTIPLE | (lh * 2)); - else if ((lh & ParaStyle.LH_PCT) != 0) { - lh = (lh & ParaStyle.LH_VALUEMASK) / 100; - lineSpace = (byte)(LS_MULTIPLE | (lh * 2)); - } - // DJP: handle other cases.... - } - - if (ps.isAttributeSet(ParaStyle.TEXT_ALIGN)) { - - int val = ps.getAttribute(ParaStyle.TEXT_ALIGN); - - switch (val) { - case ParaStyle.ALIGN_RIGHT: - misc = ALIGN_RIGHT; - break; - case ParaStyle.ALIGN_LEFT: - misc = ALIGN_LEFT; - break; - case ParaStyle.ALIGN_CENTER: - misc = ALIGN_CENTER; - break; - case ParaStyle.ALIGN_JUST: - misc = ALIGN_JUST; - break; - } - } - - } - - - /** - * Constructor for use when going from WordSmith to DOM. - * Assumes <code>dataArray[startIndex]</code> is the first - * <code>byte</code> of a valid WordSmith paragraph descriptor. - * - * @param dataArray <code>byte</code> array. - * @param startIndex The start index. - */ - public WsePara(byte dataArray[], int startIndex) { - spaceBefore = dataArray[startIndex + 1]; - spaceAfter = dataArray[startIndex + 2]; - leftIndent = dataArray[startIndex + 3]; - firstIndent = dataArray[startIndex + 4]; - rightIndent = dataArray[startIndex + 5]; - misc = dataArray[startIndex + 6]; - style = dataArray[startIndex + 7]; - lineSpace = dataArray[startIndex + 8]; - outline = dataArray[startIndex + 9]; - } - - - /** - * Compute the index of the first <code>byte</code> following the - * paragraph descriptor, assuming that - * <code>dataArray[startIndex]</code> is the beginning of a valid - * paragraph descriptor. - * - * @param startIndex The start index. - * - * @return The index of the first <code>byte</code> following the - * paragraph description. - */ - static int computeNewIndex(int startIndex) { - return startIndex + 13; - } - - - /** - * Return true if <code>dataArray[startIndex]</code> is the start - * of a valid paragraph descriptor. - * - * @param dataArray <code>byte</code> array. - * @param startIndex The start index. - * - * @return true if <code>dataArray[startIndex]</code> is the start - * of a valid paragraph descriptor, false otherwise. - */ - static boolean isValid(byte dataArray[], int startIndex) { - return (dataArray[startIndex] == 5); - } - - /** - * Return the number of bytes needed to represent this paragraph. - * - * @return The number of bytes needed to represent this paragraph. - */ - int getByteCount() { - return 13; - } - - /** - * Return an <code>byte</code> array representing this paragraph. - * - * @return An <code>byte</code> array representing this paragraph. - */ - byte[] getBytes() { - byte b[] = new byte[13]; - - b[0] = 5; - b[1] = spaceBefore; - b[2] = spaceAfter; - b[3] = leftIndent; - b[4] = firstIndent; - b[5] = rightIndent; - b[6] = misc; - b[7] = style; - b[8] = lineSpace; - b[9] = outline; - b[10] = reserved; - b[11] = 0; - b[12] = 0; - - return b; - } - - /** - * Return a <code>ParaStyle</code> that reflects the formatting of - * this run. - * - * @return A <code>ParaStyle</code> that reflects the formatting - * of this run. - */ - ParaStyle makeStyle() { - /* Csaba: Commented out the LINE_HEIGHT syle, because there was no - incoming data for that style. It was resulting a zero line - height in the xml document, ie. the doc looked empty. - */ - int attrs[] = { ParaStyle.MARGIN_LEFT, ParaStyle.MARGIN_RIGHT, - ParaStyle.TEXT_INDENT, //ParaStyle.LINE_HEIGHT, - ParaStyle.MARGIN_TOP, ParaStyle.MARGIN_BOTTOM, - ParaStyle.TEXT_ALIGN }; - String values[] = new String[attrs.length]; - double temp; - - temp = leftIndent / 1.6; - values[0] = (new Double(temp)).toString() + "mm"; - - temp = rightIndent / 1.6; - values[1] = (new Double(temp)).toString() + "mm"; - - temp = firstIndent / 1.6; - values[2] = (new Double(temp)).toString() + "mm"; - - temp = spaceBefore / 1.6; - values[3] = (new Double(temp)).toString() + "mm"; - - temp = spaceAfter / 1.6; - values[4] = (new Double(temp)).toString() + "mm"; - - switch (misc) { - case ALIGN_RIGHT: values[5] = "right"; break; - case ALIGN_LEFT: values[5] = "left"; break; - case ALIGN_CENTER:values[5] = "center"; break; - case ALIGN_JUST: values[5] = "justified"; break; - } - ParaStyle x = new ParaStyle(null, "paragraph", null, attrs, - values, sc); - - return x; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java deleted file mode 100644 index 0556427ae57a..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/WseTextRun.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import org.openoffice.xmerge.converter.xml.TextStyle; -import org.openoffice.xmerge.converter.xml.StyleCatalog; -import java.awt.Color; - -/** - * <p>This class represents a text run (aka text atom) in a WordSmith - * document.</p> - * - * <p>WordSmith represents a text run as follows:</p> - * - * <p><ul><li> - * 1 byte Value of "1", indicating beginning of a text atom - * </li><li> - * 2 bytes Length of text (does not include attributes, this length field, - * etc) - * </li><li> - * 1 byte Font index - Index in the font table of font to be used - * </li><li> - * 1 byte Font size (DJP: get details of representation) - * </li><li> - * 1 byte Color index - Index in the color table of font color to be used - * </li><li> - * 1 byte Modifiers - bit flags for bold, italic, etc - * </li><li> - * n bytes Text - the actual text - * </li></ul></p> - * - */ -class WseTextRun extends Wse { - - /** Font specifier. This is an index into the font table. */ - private byte fontIndex = 0; - private String fontName = null; - - /** Size of the font. */ - private byte fontSize = 0; - - /** - * Color of the font. This is an index into the color table. - * High nibble is background color index, low nibble is font color - * index. - */ - private byte colorIndex = 0; - - /** - * Reference to color table for color lookups. - */ - private WseColorTable ct; - - /** - * The modifiers for the text run. (Mostly) Bitwise flags. The "_TOKEN" - * values are not yet implemented in this converter. They may not even - * be implemented in WordSmith yet. - */ - private byte modifiers = 0; - final public static int BOLD = 0x01; - final public static int ITALIC = 0x02; - final public static int UNDERLINE = 0x04; - final public static int STRIKETHRU = 0x08; - final public static int SUPERSCRIPT = 0x10; - final public static int SUBSCRIPT = 0x20; - final public static int LINK = 0x40; - final public static int CUSTOM_TOKEN = 0x80; - final public static int IMAGE_TOKEN = 0x80; - final public static int BOOKMARK_TOKEN = 0x81; - final public static int ANNOTATION_TOKEN = 0x82; - final public static int LINK_TOKEN = 0x83; - - /** The actual text. */ - private String text; - - StyleCatalog sc; - - - /** - * Constructor for use when going from DOM to WordSmith. - * - * @param txt The text. - * @param t The text style. - * @param sc The <code>StyleCatalog</code>. - * @param ft The font table. - * @param ct The color Table. - */ - public WseTextRun(String txt, TextStyle t, StyleCatalog sc, - WseFontTable ft, WseColorTable ct) { - - this.sc = sc; - this.ct = ct; - - TextStyle ts = (TextStyle)t.getResolved(); - - if (ts.isSet(TextStyle.BOLD) && ts.getAttribute(TextStyle.BOLD)) - modifiers |= BOLD; - if (ts.isSet(TextStyle.ITALIC) && ts.getAttribute(TextStyle.ITALIC)) - modifiers |= ITALIC; - if (ts.isSet(TextStyle.UNDERLINE) && ts.getAttribute(TextStyle.UNDERLINE)) - modifiers |= UNDERLINE; - if (ts.isSet(TextStyle.STRIKETHRU) && ts.getAttribute(TextStyle.STRIKETHRU)) - modifiers |= STRIKETHRU; - if (ts.isSet(TextStyle.SUPERSCRIPT) && ts.getAttribute(TextStyle.SUPERSCRIPT)) - modifiers |= SUPERSCRIPT; - if (ts.isSet(TextStyle.SUBSCRIPT) && ts.getAttribute(TextStyle.SUBSCRIPT)) - modifiers |= SUBSCRIPT; - - fontSize = (byte)(ts.getFontSize() * 2); - fontName = ts.getFontName(); - fontIndex = (byte)ft.getFontIndex(fontName); - if (fontIndex == -1) { - ft.add(fontName); - fontIndex = (byte)ft.getFontIndex(fontName); - } - - // Figure out the color index. - Color c = t.getFontColor(); - if (c == null) - c = Color.black; - colorIndex = (byte)ct.findColor(c, true); - c = t.getBackgroundColor(); - if (c == null) - c = Color.white; - colorIndex |= (byte)(ct.findColor(c, false) << 4); - - text = txt; - } - - - /** - * Standard constructor for use when going from WordSmith to DOM. - * - * @param dataArray <code>byte</code> array. - * @param startIndex The start index. - * @param ft The font table. - * @param ct The color table. - */ - public WseTextRun(byte dataArray[], int startIndex, WseFontTable ft, - WseColorTable ct) { - - this.ct = ct; - - startIndex++; // Skip the leading "1" - - int textLen = ((dataArray[startIndex] << 8) - | (dataArray[startIndex+1] & 0xFF)); - startIndex += 2; - - fontIndex = dataArray[startIndex++]; - if (ft != null) - fontName = ft.getFontName(fontIndex); - - fontSize = dataArray[startIndex++]; - - colorIndex = dataArray[startIndex++]; - modifiers = dataArray[startIndex++]; - - text = new String(dataArray, startIndex, textLen); - startIndex += textLen; // skip the text - } - - - /** - * Given a <code>byte</code> sequence, assumed to be a text run, - * compute the index of the first byte past the text run. - * - * @param dataArray <code>byte</code> array. - * @param startIndex The start index - * - * @return The index of the first <code>byte</code> past the - * text run. - */ - public static int computeNewIndex(byte dataArray[], int startIndex) { - - startIndex++; // Skip the leading "1" - - int textLen = ((dataArray[startIndex] << 8) - | (dataArray[startIndex+1] & 0xFF)); - startIndex += 2; - - startIndex += 4; // skip attributes - // text = new String(dataArray, startIndex, textLen); - startIndex += textLen; // skip the text - return startIndex; - } - - - /** - * Return true if the sequence starting at - * <code>dataArray[startIndex]</code> is a valid text run. - * - * @param dataArray <code>byte</code> array. - * @param startIndex The start index. - * - * @return true if the sequence starting at - * <code>dataArray[startIndex]</code> is a valid - * text run, false otherwise. - */ - public static boolean isValid(byte dataArray[], int startIndex) { - return (dataArray[startIndex] == 1); - } - - /** - * Return the number of bytes needed to represent this text run. - * - * @return The number of bytes needed to represent this text run. - */ - int getByteCount() { - return text.length() + 7; - } - - - /** - * Return an <code>byte</code> array representing this text run. - * - * @return An <code>byte</code> array representing this text run. - */ - byte[] getBytes() { - short textLen = (short)text.length(); - byte b[] = new byte[textLen + 7]; - b[0] = 1; - b[1] = (byte)(textLen >> 8); - b[2] = (byte)(textLen & 0xFF); - b[3] = fontIndex; - b[4] = fontSize; - b[5] = colorIndex; - b[6] = modifiers; - byte[] txtBytes = text.getBytes(); - System.arraycopy(txtBytes, 0, b, 7, textLen); - return b; - } - - - /** - * Return the text of this run. - * - * @return The text of this run. - */ - public String getText() { - return text; - } - - - /** - * Return a <code>TextStyle</code> that reflects the formatting - * of this run. - * - * @return A <code>TextStyle</code> that reflects the formatting - * of this run. - */ - public TextStyle makeStyle() { - int mod = 0; - if ((modifiers & BOLD) != 0) mod |= TextStyle.BOLD; - if ((modifiers & ITALIC) != 0) mod |= TextStyle.ITALIC; - if ((modifiers & UNDERLINE) != 0) mod |= TextStyle.UNDERLINE; - if ((modifiers & STRIKETHRU) != 0) - mod |= TextStyle.STRIKETHRU; - if ((modifiers & SUPERSCRIPT) != 0) mod |= TextStyle.SUPERSCRIPT; - if ((modifiers & SUBSCRIPT) != 0) mod |= TextStyle.SUBSCRIPT; - - int mask = TextStyle.BOLD | TextStyle.ITALIC - | TextStyle.UNDERLINE - | TextStyle.STRIKETHRU | TextStyle.SUPERSCRIPT - | TextStyle.SUBSCRIPT; - - TextStyle x = new TextStyle(null, "text", null, mask, - mod, (fontSize/2), fontName, sc); - - // If color table is available, set the colors. - if (ct != null) { - Color fc = ct.getColor(colorIndex & 0xF, true); - Color bc = ct.getColor(colorIndex >> 4, false); - x.setColors(fc, bc); - } - - return x; - } - - - /** - * Display debug information. - */ - public void dump() { - System.out.print("TEXT RUN: fontIndex = " + fontIndex - + " fontsize = " + fontSize - + " colorIndex = " + colorIndex - + " "); - if ((modifiers & BOLD) != 0) System.out.print("BOLD,"); - if ((modifiers & ITALIC) != 0) System.out.print("ITALIC,"); - if ((modifiers & UNDERLINE) != 0) System.out.print("UNDERLINE,"); - if ((modifiers & STRIKETHRU) != 0) System.out.print("STRIKETHRU,"); - if ((modifiers & SUPERSCRIPT) != 0) System.out.print("SUPERSCRIPT,"); - if ((modifiers & SUBSCRIPT) != 0) System.out.print("SUBSCRIPT,"); - System.out.println("\n" + text); - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java deleted file mode 100644 index 18cb61b67b57..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/textRecord.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -import java.io.IOException; -import java.io.DataOutputStream; -import java.io.ByteArrayOutputStream; - -/** - * This class represents a single text record in a WordSmith document. - * A record is composed of one or more "WordSmith elements", which - * include: WordSmith header, font table, color table, paragraphs, - * and text runs. - * - */ - -class textRecord { - - java.util.ArrayList<Wse> elements; - - - /** - * Default constructor - */ - textRecord() { - elements = new java.util.ArrayList<Wse>(10); - } - - - /** - * Add an element - * - * @param elem The element to add - */ - void addElement(Wse elem) { - elements.add(elem); - } - - - /** - * Return the number of bytes needed to represent the current - * contents of this text record. - * - * @return The number of bytes needed to represent the current - * contents of this text record. - */ - int getByteCount() { - int totalBytes = 0; - int nElements = elements.size(); - for (int i = 0; i < nElements; i++) { - Wse e = elements.get(i); - totalBytes += e.getByteCount(); - } - return totalBytes; - } - - - /** - * Return the contents of this record as a <code>byte</code> array. - * - * @return the contents of this record as a <code>byte</code> array. - */ - byte[] getBytes() { - DataOutputStream os = null; // Used for storing the data - ByteArrayOutputStream bs = null; // Used for storing the data - - try { - bs = new ByteArrayOutputStream(); - os = new DataOutputStream(bs); - int nElements = elements.size(); - for (int i = 0; i < nElements; i++) { - Wse e = elements.get(i); - os.write(e.getBytes()); - } - - } catch (IOException e) { - e.printStackTrace(); - } - - if (bs != null) - return bs.toByteArray(); - else - return null; - } -} - diff --git a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/util.java b/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/util.java deleted file mode 100644 index 96110be4543f..000000000000 --- a/xmerge/source/wordsmith/java/org/openoffice/xmerge/converter/xml/sxw/wordsmith/util.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package org.openoffice.xmerge.converter.xml.sxw.wordsmith; - -/** - * WordSmith utility class. - * - */ -class util { - - /** - * Convert 2 bytes to an integer. - * - * @param data <code>byte</code> data to convert. - * @param index Index to convert. - * - * @return Converted integer. - */ - static int intFrom2bytes(byte[] data, int index) { - return (((data[index] & 0xFF) << 8) - | (data[index+1] & 0xFF)); - - } - - - /** - * Convert 4 bytes to an integer. - * - * @param data <code>byte</code> data to convert. - * @param index Index to convert. - * - * @return Converted integer. - */ - static int intFrom4bytes(byte[] data, int index) { - return (((data[index] & 0xFF) << 24) - | ((data[index + 1] & 0xFF) << 16) - | ((data[index + 2] & 0xFF) << 8) - | (data[index+3] & 0xFF)); - - } -} - diff --git a/xmerge/source/wordsmith/makefile.mk b/xmerge/source/wordsmith/makefile.mk deleted file mode 100644 index b5690a1f35d6..000000000000 --- a/xmerge/source/wordsmith/makefile.mk +++ /dev/null @@ -1,24 +0,0 @@ -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -TARGET=wordsmith -PRJ=../.. -PRJNAME=xmerge - -.INCLUDE : ant.mk -ALLTAR: ANTBUILD |