[Libreoffice-commits] core.git: filter/Configuration_filter.mk l10ntools/Jar_FCFGMerge.mk l10ntools/Module_l10ntools.mk l10ntools/Package_inc.mk l10ntools/source Repository.mk
Matúš Kukan
matus.kukan at gmail.com
Mon Mar 11 08:00:12 PDT 2013
Repository.mk | 1
filter/Configuration_filter.mk | 7
l10ntools/Jar_FCFGMerge.mk | 48
l10ntools/Module_l10ntools.mk | 6
l10ntools/Package_inc.mk | 2
l10ntools/source/filter/merge/FCFGMerge.cfg | 112
l10ntools/source/filter/merge/FCFGMerge.java | 114
l10ntools/source/filter/merge/Manifest.mf | 1
l10ntools/source/filter/merge/Merger.java | 345 -
l10ntools/source/filter/utils/AnalyzeStartupLog.java | 316 -
l10ntools/source/filter/utils/Cache.java | 2428 ----------
l10ntools/source/filter/utils/ConfigHelper.java | 291 -
l10ntools/source/filter/utils/FileHelper.java | 754 ---
l10ntools/source/filter/utils/Logger.java | 156
l10ntools/source/filter/utils/MalformedCommandLineException.java | 38
l10ntools/source/filter/utils/XMLHelper.java | 812 ---
16 files changed, 1 insertion(+), 5430 deletions(-)
New commits:
commit 17b2ace79b86bd772d9eb48b9c4ad69c0713695c
Author: Matúš Kukan <matus.kukan at gmail.com>
Date: Sat Mar 9 12:34:34 2013 +0100
filter: use python version of FCFGMerge
Change-Id: I23124b919359c1217529724338b8d4906e051306
diff --git a/Repository.mk b/Repository.mk
index 1514afd..a7b1706 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -746,7 +746,6 @@ $(eval $(call gb_Helper_register_jars,URE, \
$(eval $(call gb_Helper_register_jars,OOO, \
ConnectivityTools \
- FCFGMerge \
HelloWorld \
Highlight \
MemoryUsage \
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index c37d4ad..6f36649 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -21,16 +21,11 @@
# most of the rules here use some weird merge program, and this is sort of
# semi-integrated with the stuff from Configuration.mk; not exactly pretty...
-ifeq ($(SOLAR_JAVA),)
filter_MERGE_TARGET := $(call gb_ExternalExecutable_get_dependencies,python) \
$(SRCDIR)/filter/source/config/tools/merge/pyAltFCFGMerge
filter_MERGE := $(call gb_ExternalExecutable_get_command,python) \
$(SRCDIR)/filter/source/config/tools/merge/pyAltFCFGMerge
-else # SOLAR_JAVA
-filter_MERGE_TARGET := $(OUTDIR_FOR_BUILD)/bin/FCFGMerge.jar
-filter_MERGE := $(JAVAINTERPRETER) $(JAVAIFLAGS) -jar $(filter_MERGE_TARGET)
-endif
-filter_MERGE_CONFIG_TARGET := $(OUTDIR_FOR_BUILD)/inc/l10ntools/FCFGMerge.cfg
+filter_MERGE_CONFIG_TARGET := $(SRCDIR)/filter/source/config/tools/merge/FCFGMerge.cfg
### filter configuration rules: generic stuff #######################
diff --git a/l10ntools/Jar_FCFGMerge.mk b/l10ntools/Jar_FCFGMerge.mk
deleted file mode 100644
index 7719f5f..0000000
--- a/l10ntools/Jar_FCFGMerge.mk
+++ /dev/null
@@ -1,48 +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 David Ostrovsky <d.ostrovsky at gmx.de> (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_Jar_Jar,FCFGMerge))
-
-$(eval $(call gb_Jar_set_packageroot,FCFGMerge,com))
-
-$(eval $(call gb_Jar_set_manifest,FCFGMerge,$(SRCDIR)/l10ntools/source/filter/merge/Manifest.mf))
-
-$(eval $(call gb_Jar_add_sourcefiles,FCFGMerge,\
- l10ntools/source/filter/merge/FCFGMerge \
- l10ntools/source/filter/merge/Merger \
- l10ntools/source/filter/utils/AnalyzeStartupLog \
- l10ntools/source/filter/utils/Cache \
- l10ntools/source/filter/utils/ConfigHelper \
- l10ntools/source/filter/utils/FileHelper \
- l10ntools/source/filter/utils/Logger \
- l10ntools/source/filter/utils/MalformedCommandLineException \
- l10ntools/source/filter/utils/XMLHelper \
-))
-
-$(eval $(call gb_Jar_add_packagefile,FCFGMerge,\
- com/sun/star/filter/config/tools/merge/FCFGMerge.cfg,\
- $(SRCDIR)/l10ntools/source/filter/merge/FCFGMerge.cfg \
-))
diff --git a/l10ntools/Module_l10ntools.mk b/l10ntools/Module_l10ntools.mk
index 1d174a3..2982fd6d 100644
--- a/l10ntools/Module_l10ntools.mk
+++ b/l10ntools/Module_l10ntools.mk
@@ -43,10 +43,4 @@ $(eval $(call gb_Module_add_targets,l10ntools,\
Package_ulfconv \
))
-ifneq ($(SOLAR_JAVA),)
-$(eval $(call gb_Module_add_targets,l10ntools,\
- Jar_FCFGMerge \
-))
-endif
-
# vim:set noet sw=4 ts=4:
diff --git a/l10ntools/Package_inc.mk b/l10ntools/Package_inc.mk
index c990c15..dc7b32e 100644
--- a/l10ntools/Package_inc.mk
+++ b/l10ntools/Package_inc.mk
@@ -29,7 +29,5 @@ $(eval $(call gb_Package_Package,l10ntools_inc,$(SRCDIR)/l10ntools))
$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/export.hxx,inc/export.hxx))
$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/directory.hxx,inc/l10ntools/directory.hxx))
$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/file.hxx,inc/l10ntools/file.hxx))
-$(eval $(call gb_Package_add_file,l10ntools_inc,inc/l10ntools/FCFGMerge.cfg,source/filter/merge/FCFGMerge.cfg))
-
# vim: set noet sw=4 ts=4:
diff --git a/l10ntools/source/filter/merge/FCFGMerge.cfg b/l10ntools/source/filter/merge/FCFGMerge.cfg
deleted file mode 100644
index 4516a77..0000000
--- a/l10ntools/source/filter/merge/FCFGMerge.cfg
+++ /dev/null
@@ -1,112 +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 .
-#
-
-#************************************************
-# Specify the verbose mode of this tool.
-# 1 = show errors only
-# 2 = show errors/warnings (default)
-# 3 = show errors/warnings and some generic infos
-# 4 = show anything (including detailed infos)
-#
-# [OPTIONAL]
-#************************************************
-
-loglevel = 2
-
-#************************************************
-# This extension is used for all XML files. It doesnt
-# matter if its used for reading fragments or writing
-# XML packages.
-# Must be given without any additional signes like "."
-# or "*."!
-#
-# [REQUIRED]
-#************************************************
-
-extension_xcu=xcu
-
-#************************************************
-# This extension is used for all Package files. It doesnt
-# matter if its used for reading such files or writing
-# it.
-# Must be given without any additional signes like "."
-# or "*."!
-#
-# [REQUIRED]
-#************************************************
-
-extension_pkg=pkg
-
-#************************************************
-# These values are used to generate a correct XML
-# header.
-# Note: The property "xmlpackage" must be specified
-# via command line. There exists more then one
-# possible value.
-#
-# [REQUIRED]
-#************************************************
-
-xmlversion = 1.0
-xmlencoding = UTF-8
-xmlpath = org.openoffice.TypeDetection
-#xmlpackage =
-
-#************************************************
-# These values are used to name the configuration
-# sets inside the generated XCM file for different
-# item groups like e.g. types, filters etcpp.
-#
-# [REQUIRED]
-#************************************************
-
-setname_types = Types
-setname_filters = Filters
-setname_frameloaders = FrameLoaders
-setname_contenthandlers = ContentHandlers
-
-subdir_types = types
-subdir_filters = filters
-subdir_frameloaders = frameloaders
-subdir_contenthandlers = contenthandlers
-
-#************************************************
-# This delimiter is used to split every
-# item list of the package configuration files
-# (which are temp. created by the make proccess)
-# into its tokens.
-#
-# [REQUIRED]
-#************************************************
-delimiter=,
-
-#************************************************
-# Enable/disable removing of leading/trailing withespaces
-# during splitting stringlists.
-#
-# [REQUIRED]
-#************************************************
-trim=true
-
-#************************************************
-# Enable/disable removing of leading/trailing "-signs
-# during splitting stringlists.
-#
-# [REQUIRED]
-#************************************************
-decode=false
diff --git a/l10ntools/source/filter/merge/FCFGMerge.java b/l10ntools/source/filter/merge/FCFGMerge.java
deleted file mode 100644
index ce3d510..0000000
--- a/l10ntools/source/filter/merge/FCFGMerge.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 com.sun.star.filter.config.tools.merge;
-
-import java.lang.*;
-import java.util.*;
-import java.io.*;
-import com.sun.star.filter.config.tools.utils.*;
-
-/**
- * Its a simple command line tool, which can merge different XML fragments
- * together. Such fragments must exist as files on disk, will be moved into
- * one file together on disk.
- *
- *
- */
-public class FCFGMerge
-{
- private static final java.lang.String CFGFILE = "com/sun/star/filter/config/tools/merge/FCFGMerge.cfg";
- private static final java.lang.String PROP_LOGLEVEL = "loglevel";
-
- //___________________________________________
- // main
-
- public static void main(java.lang.String[] sCmdLine)
- {
- // create log object in default mode "WARNINGS"
- // If a command line parameter indicates another
- // level - change it!
- Logger aLog = new Logger();
-
- try
- {
- // merge config file and overwrite properties
- // via command line
- ConfigHelper aCfg = null;
- aCfg = new ConfigHelper(CFGFILE, sCmdLine);
-
- // update log level
- int nLogLevel = aCfg.getInt(PROP_LOGLEVEL, Logger.LEVEL_WARNINGS);
- aLog = new Logger(nLogLevel);
-
- // help requested?
- if (aCfg.isHelp())
- {
- FCFGMerge.printCopyright();
- FCFGMerge.printHelp();
- System.exit(-1);
- }
-
- // create new merge object and start operation
- Merger aMerger = new Merger(aCfg, aLog);
- aMerger.merge();
- }
- catch(java.lang.Throwable ex)
- {
- aLog.setException(ex);
- System.exit(-1);
- }
-
- System.exit(0);
- }
-
- //___________________________________________
-
- /** prints out a copyright message on stdout.
- */
- private static void printCopyright()
- {
- java.lang.StringBuffer sOut = new java.lang.StringBuffer(256);
- sOut.append("FCFGMerge (LibreOffice)\n\n");
- sOut.append("Copyright (C) 2003 Sun Microsystems, Inc.\n");
- sOut.append("Copyright (C) 2012 The Document Foundation\n");
- sOut.append("License LGPLv3: GNU LGPL version 3 <http://www.gnu.org/licenses/lgpl.html>.\n");
- sOut.append("This is free software: you are free to change and redistribute it.\n");
- sOut.append("There is NO WARRANTY, to the extent permitted by law.\n");
- System.out.println(sOut.toString());
- }
-
- //___________________________________________
-
- /** prints out a help message on stdout.
- */
- private static void printHelp()
- {
- java.lang.StringBuffer sOut = new java.lang.StringBuffer(256);
- sOut.append("____________________________________________________________\n");
- sOut.append("usage: FCFGMerge cfg=<file name>\n" );
- sOut.append("parameters:\n" );
- sOut.append("\tcfg=<file name>\n" );
- sOut.append("\t\tmust point to a system file, which contains\n" );
- sOut.append("\t\tall neccessary configuration data for the merge process.\n");
- sOut.append("\n\tFurther cou can specify every parameter allowed in the\n" );
- sOut.append("\n\tconfig file as command line parameter too, to overwrite\n" );
- sOut.append("\n\tthe value from the file.\n" );
- System.out.println(sOut.toString());
- }
-}
diff --git a/l10ntools/source/filter/merge/Manifest.mf b/l10ntools/source/filter/merge/Manifest.mf
deleted file mode 100644
index 1337eaf..0000000
--- a/l10ntools/source/filter/merge/Manifest.mf
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.sun.star.filter.config.tools.merge.FCFGMerge
diff --git a/l10ntools/source/filter/merge/Merger.java b/l10ntools/source/filter/merge/Merger.java
deleted file mode 100644
index e0eff4d..0000000
--- a/l10ntools/source/filter/merge/Merger.java
+++ /dev/null
@@ -1,345 +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 com.sun.star.filter.config.tools.merge;
-
-import java.lang.*;
-import java.util.*;
-import java.io.*;
-import com.sun.star.filter.config.tools.utils.*;
-
-/** can merge different xml fragments together.
- *
- *
- */
-public class Merger
-{
- private static final java.lang.String PROP_XMLVERSION = "xmlversion" ; // <= global cfg file
- private static final java.lang.String PROP_XMLENCODING = "xmlencoding" ; // <= global cfg file
- private static final java.lang.String PROP_XMLPATH = "xmlpath" ; // <= global cfg file
- private static final java.lang.String PROP_XMLPACKAGE = "xmlpackage" ; // <= global cfg file
-
- private static final java.lang.String PROP_SETNAME_TYPES = "setname_types" ; // <= global cfg file
- private static final java.lang.String PROP_SETNAME_FILTERS = "setname_filters" ; // <= global cfg file
- private static final java.lang.String PROP_SETNAME_LOADERS = "setname_frameloaders" ; // <= global cfg file
- private static final java.lang.String PROP_SETNAME_HANDLERS = "setname_contenthandlers" ; // <= global cfg file
-
- private static final java.lang.String PROP_SUBDIR_TYPES = "subdir_types" ; // <= global cfg file
- private static final java.lang.String PROP_SUBDIR_FILTERS = "subdir_filters" ; // <= global cfg file
- private static final java.lang.String PROP_SUBDIR_LOADERS = "subdir_frameloaders" ; // <= global cfg file
- private static final java.lang.String PROP_SUBDIR_HANDLERS = "subdir_contenthandlers" ; // <= global cfg file
-
- private static final java.lang.String PROP_EXTENSION_XCU = "extension_xcu" ; // <= global cfg file
- private static final java.lang.String PROP_EXTENSION_PKG = "extension_pkg" ; // <= global cfg file
-
- private static final java.lang.String PROP_DELIMITER = "delimiter" ; // <= global cfg file
- private static final java.lang.String PROP_TRIM = "trim" ; // <= global cfg file
- private static final java.lang.String PROP_DECODE = "decode" ; // <= global cfg file
-
- private static final java.lang.String PROP_FRAGMENTSDIR = "fragmentsdir" ; // <= cmdline
- private static final java.lang.String PROP_TEMPDIR = "tempdir" ; // <= cmdline
- private static final java.lang.String PROP_OUTDIR = "outdir" ; // <= cmdline
- private static final java.lang.String PROP_PKG = "pkg" ; // <= cmdline
- private static final java.lang.String PROP_DEBUG = "debug" ; // <= cmdline
-
- private static final java.lang.String PROP_TCFG = "tcfg" ; // <= cmdline
- private static final java.lang.String PROP_FCFG = "fcfg" ; // <= cmdline
- private static final java.lang.String PROP_LCFG = "lcfg" ; // <= cmdline
- private static final java.lang.String PROP_CCFG = "ccfg" ; // <= cmdline
- private static final java.lang.String PROP_LANGUAGEPACK = "languagepack" ; // <= cmdline
-
- private static final java.lang.String PROP_ITEMS = "items" ; // <= pkg cfg files!
-
- //___________________________________________
- // member
-
- //-------------------------------------------
- /** TODO */
- private ConfigHelper m_aCfg;
-
- //-------------------------------------------
- /** TODO */
- private Logger m_aLog;
-
- //-------------------------------------------
- /** TODO */
- private java.io.File m_aFragmentsDir;
-
- //-------------------------------------------
- /** TODO */
- private java.io.File m_aTempDir;
-
- //-------------------------------------------
- /** TODO */
- private java.io.File m_aOutDir;
-
- //-------------------------------------------
- /** TODO */
- private java.util.Vector m_lTypes;
- private java.util.Vector m_lFilters;
- private java.util.Vector m_lLoaders;
- private java.util.Vector m_lHandlers;
-
- //___________________________________________
- // interface
-
- //-------------------------------------------
- /** initialize a new instance of this class and
- * try to get all needed resources from the config module.
- *
- * @param aCfg
- * provides access to all values of the global
- * config file and to the command line.
- *
- * @param aLog
- * can be used to print out log informations.
- */
- public Merger(ConfigHelper aCfg,
- Logger aLog)
- throws java.lang.Exception
- {
- m_aCfg = aCfg;
- m_aLog = aLog;
-
- m_aFragmentsDir = new java.io.File(m_aCfg.getString(PROP_FRAGMENTSDIR));
- m_aTempDir = new java.io.File(m_aCfg.getString(PROP_TEMPDIR ));
-// m_aOutDir = new java.io.File(m_aCfg.getString(PROP_OUTDIR ));
-
- java.lang.String sDelimiter = m_aCfg.getString(PROP_DELIMITER);
- boolean bTrim = m_aCfg.getBoolean(PROP_TRIM);
- boolean bDecode = m_aCfg.getBoolean(PROP_DECODE);
-
- try
- {
- ConfigHelper aFcfg = new ConfigHelper(m_aCfg.getString(PROP_TCFG), null);
- m_lTypes = aFcfg.getStringList(PROP_ITEMS, sDelimiter, bTrim, bDecode);
- }
- catch(java.util.NoSuchElementException ex1)
- {
- m_lTypes = new java.util.Vector();
- //m_aLog.setWarning("Fragment list of types is missing. Parameter \"items\" seems to be invalid.");
- }
-
- try
- {
- ConfigHelper aFcfg = new ConfigHelper(m_aCfg.getString(PROP_FCFG), null);
- m_lFilters = aFcfg.getStringList(PROP_ITEMS, sDelimiter, bTrim, bDecode);
- }
- catch(java.util.NoSuchElementException ex1)
- {
- m_lFilters = new java.util.Vector();
- //m_aLog.setWarning("Fragment list of filters is missing. Parameter \"items\" seems to be invalid.");
- }
-
- try
- {
- ConfigHelper aFcfg = new ConfigHelper(m_aCfg.getString(PROP_LCFG), null);
- m_lLoaders = aFcfg.getStringList(PROP_ITEMS, sDelimiter, bTrim, bDecode);
- }
- catch(java.util.NoSuchElementException ex1)
- {
- m_lLoaders = new java.util.Vector();
- //m_aLog.setWarning("Fragment list of frame loader objects is missing. Parameter \"items\" seems to be invalid.");
- }
-
- try
- {
- ConfigHelper aFcfg = new ConfigHelper(m_aCfg.getString(PROP_CCFG), null);
- m_lHandlers = aFcfg.getStringList(PROP_ITEMS, sDelimiter, bTrim, bDecode);
- }
- catch(java.util.NoSuchElementException ex1)
- {
- m_lHandlers = new java.util.Vector();
- //m_aLog.setWarning("Fragment list of content handler objects is missing. Parameter \"items\" seems to be invalid.");
- }
- }
-
- //-------------------------------------------
- /** TODO */
- public synchronized void merge()
- throws java.lang.Exception
- {
- java.lang.StringBuffer sBuffer = new java.lang.StringBuffer(1000000);
- java.lang.String sPackage = m_aCfg.getString(PROP_PKG);
-
- m_aLog.setGlobalInfo("create package \""+sPackage+"\" ...");
- m_aLog.setDetailedInfo("generate package header ... ");
-
- sBuffer.append(
- XMLHelper.generateHeader(
- m_aCfg.getString (PROP_XMLVERSION ),
- m_aCfg.getString (PROP_XMLENCODING ),
- m_aCfg.getString (PROP_XMLPATH ),
- m_aCfg.getString (PROP_XMLPACKAGE ),
- m_aCfg.getBoolean(PROP_LANGUAGEPACK, false)));
-
- // counts all transferred fragments
- // Can be used later to decide, if a generated package file
- // contains "nothing"!
- int nItemCount = 0;
-
- for (int i=0; i<4; ++i)
- {
- java.lang.String sSetName = null;
- java.lang.String sSubDir = null;
- java.util.Vector lFragments = null;
-
- try
- {
- switch(i)
- {
- case 0: // types
- {
- m_aLog.setDetailedInfo("generate set for types ... ");
- sSetName = m_aCfg.getString(PROP_SETNAME_TYPES);
- sSubDir = m_aCfg.getString(PROP_SUBDIR_TYPES );
- lFragments = m_lTypes;
- }
- break;
-
- case 1: // filters
- {
- m_aLog.setDetailedInfo("generate set for filter ... ");
- sSetName = m_aCfg.getString(PROP_SETNAME_FILTERS);
- sSubDir = m_aCfg.getString(PROP_SUBDIR_FILTERS );
- lFragments = m_lFilters;
- }
- break;
-
- case 2: // loaders
- {
- m_aLog.setDetailedInfo("generate set for frame loader ... ");
- sSetName = m_aCfg.getString(PROP_SETNAME_LOADERS);
- sSubDir = m_aCfg.getString(PROP_SUBDIR_LOADERS );
- lFragments = m_lLoaders;
- }
- break;
-
- case 3: // handlers
- {
- m_aLog.setDetailedInfo("generate set for content handler ... ");
- sSetName = m_aCfg.getString(PROP_SETNAME_HANDLERS);
- sSubDir = m_aCfg.getString(PROP_SUBDIR_HANDLERS );
- lFragments = m_lHandlers;
- }
- break;
- }
-
- nItemCount += lFragments.size();
-
- getFragments(
- new java.io.File(m_aFragmentsDir, sSubDir),
- sSetName,
- lFragments,
- 1,
- sBuffer);
- }
- catch(java.util.NoSuchElementException exIgnore)
- { continue; }
- }
-
- m_aLog.setDetailedInfo("generate package footer ... ");
- sBuffer.append(XMLHelper.generateFooter());
-
- // Attention!
- // If the package seem to be empty, it make no sense to generate a corresponding
- // xml file. We should suppress writing of this file on disk completely ...
- if (nItemCount < 1)
- {
- m_aLog.setWarning("Package is empty and will not result into a xml file on disk!? Please check configuration file.");
- return;
- }
- m_aLog.setGlobalInfo("package contains "+nItemCount+" items");
-
- java.io.File aPackage = new File(sPackage);
- m_aLog.setGlobalInfo("write temp package \""+aPackage.getPath()); // TODO encoding must be readed from the configuration
- FileHelper.writeEncodedBufferToFile(aPackage, "UTF-8", false, sBuffer); // check for success is done inside this method!
- }
-
- //-------------------------------------------
- /** TODO */
- private void getFragments(java.io.File aDir ,
- java.lang.String sSetName ,
- java.util.Vector lFragments ,
- int nPrettyTabs,
- java.lang.StringBuffer sBuffer )
- throws java.lang.Exception
- {
- if (lFragments.size()<1)
- {
-// m_aLog.setWarning("List of fragments is empty!? Will be ignored ...");
- return;
- }
-
- java.util.Enumeration pFragments = lFragments.elements();
- java.lang.String sExtXcu = m_aCfg.getString(PROP_EXTENSION_XCU);
-
- for (int tabs=0; tabs<nPrettyTabs; ++tabs)
- sBuffer.append("\t");
- sBuffer.append("<node oor:name=\""+sSetName+"\">\n");
- ++nPrettyTabs;
-
- // special mode for generating language packs.
- // In such case we must live with some missing fragment files.
- // Reason behind; Not all filters are realy localized.
- // But we dont use a different fragment list. We try to locate
- // any fragment file in its language-pack version ...
- boolean bHandleLanguagePacks = m_aCfg.getBoolean(PROP_LANGUAGEPACK, false);
- boolean bDebug = m_aCfg.getBoolean(PROP_DEBUG , false);
- java.lang.String sEncoding = "UTF-8";
- if (bDebug)
- sEncoding = "UTF-8Special";
-
- while(pFragments.hasMoreElements())
- {
- java.lang.String sFragment = (java.lang.String)pFragments.nextElement();
- java.io.File aFragment = new java.io.File(aDir, sFragment+"."+sExtXcu);
-
- // handle simple files only and check for existence!
- if (!aFragment.exists())
- {
- if (bHandleLanguagePacks)
- {
- m_aLog.setWarning("language fragment \""+aFragment.getPath()+"\" does not exist. Will be ignored.");
- continue;
- }
- else
- throw new java.io.IOException("fragment \""+aFragment.getPath()+"\" does not exists.");
- }
-
- if (!aFragment.isFile())
- {
- m_aLog.setWarning("fragment \""+aFragment.getPath()+"\" seem to be not a valid file.");
- continue;
- }
-
- // copy file content of original fragment
- // Note: A FileNotFoundException will be thrown automaticly by the
- // used reader objects. Let it break this method too. Our calli is interested
- // on such errors :-)
- m_aLog.setDetailedInfo("merge fragment \""+aFragment.getPath()+"\" ...");
- FileHelper.readEncodedBufferFromFile(aFragment, sEncoding, sBuffer);
-
- sBuffer.append("\n");
- }
-
- --nPrettyTabs;
- for (int tabs=0; tabs<nPrettyTabs; ++tabs)
- sBuffer.append("\t");
- sBuffer.append("</node>\n");
- }
-}
diff --git a/l10ntools/source/filter/utils/AnalyzeStartupLog.java b/l10ntools/source/filter/utils/AnalyzeStartupLog.java
deleted file mode 100644
index 45f736b..0000000
--- a/l10ntools/source/filter/utils/AnalyzeStartupLog.java
+++ /dev/null
@@ -1,316 +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 com.sun.star.filter.config.tools.utils;
-
-//_______________________________________________
-// imports
-import java.util.*;
-import java.lang.*;
-
-//_______________________________________________
-// implementation
-public class AnalyzeStartupLog
-{
- private class OperationTime
- {
- /** name the measured operation. */
- public java.lang.String sOperation;
-
- /** contains the time value, when this operation was started. */
- public long nStartTime;
-
- /** contains the time value, when this operation was finished. */
- public long nEndTime;
-
- /** text inside log file, which identifies the start time value. */
- public java.lang.String sStartMsg;
-
- /** text inside log file, which identifies the end time value. */
- public java.lang.String sEndMsg;
- }
-
- //_________________________________
- // main
-
- public static void main(java.lang.String[] lCmdLine)
- {
- int nExit = 0;
- try
- {
- // analyze command line
- ConfigHelper aCmdLine = new ConfigHelper("", lCmdLine);
- java.lang.String sLogDir = aCmdLine.getString("logdir" );
- java.lang.String sDataFile = aCmdLine.getString("datafile");
-
- if (sLogDir == null || sDataFile == null)
- {
- System.err.println("AnalyzeStartupLog lodir=<dir> datafile=<file>");
- System.err.println("E.g.: AnalyzeStartupLog lodir=c:\\temp\\logs datafile=c:\\temp\\data.csv");
- System.exit(--nExit);
- }
-
- // get list of all log files
- boolean bRecursive = true;
- java.util.Vector lLogs = FileHelper.getSystemFilesFromDir(new java.io.File(sLogDir), bRecursive);
- if (lLogs == null || lLogs.isEmpty())
- {
- System.err.println("log dir is empty");
- System.exit(--nExit);
- }
-
- // analyze it
- java.lang.StringBuffer sOut = new java.lang.StringBuffer(1000);
- sOut.append("log;t_cfg_start;t_cfg_end;t_fwk_start;t_fwk_end;t_sfx_start;t_sfx_end;t_types_start;t_types_end;t_filters_start;t_filters_end;");
- sOut.append("t_filters_swriter_start;t_filters_swriter_end;t_filters_sweb_start;t_filters_sweb_end;t_filters_sglobal_start;t_filters_sglobal_end;t_filters_scalc_start;t_filters_scalc_end;t_filters_sdraw_start;t_filters_sdraw_end;t_filters_simpress_start;t_filters_simpress_end;t_filters_schart_start;t_filters_schart_end;t_filters_smath_start;t_filters_smath_end;");
- sOut.append("t_others_start;t_others_end;d_cfg;d_fwk;d_sfx;d_types;d_filters;d_others;d_complete\n");
-
- java.util.Enumeration aIt = lLogs.elements();
- while (aIt.hasMoreElements())
- {
- java.io.File aLog = (java.io.File)aIt.nextElement();
- java.io.FileReader aReader = new java.io.FileReader(aLog);
- java.io.BufferedReader aBuffer = new java.io.BufferedReader(aReader);
-
- long t_cfg_start = 0;
- long t_cfg_end = 0;
-
- long t_fwk_start = 0;
- long t_fwk_end = 0;
-
- long t_sfx_start = 0;
- long t_sfx_end = 0;
-
- long t_types_start = 0;
- long t_types_end = 0;
-
- long t_filters_start = 0;
- long t_filters_end = 0;
-
- long t_filters_swriter_start = 0;
- long t_filters_swriter_end = 0;
-
- long t_filters_sweb_start = 0;
- long t_filters_sweb_end = 0;
-
- long t_filters_sglobal_start = 0;
- long t_filters_sglobal_end = 0;
-
- long t_filters_scalc_start = 0;
- long t_filters_scalc_end = 0;
-
- long t_filters_sdraw_start = 0;
- long t_filters_sdraw_end = 0;
-
- long t_filters_simpress_start = 0;
- long t_filters_simpress_end = 0;
-
- long t_filters_schart_start = 0;
- long t_filters_schart_end = 0;
-
- long t_filters_smath_start = 0;
- long t_filters_smath_end = 0;
-
- long t_others_start = 0;
- long t_others_end = 0;
-
- while (true)
- {
- java.lang.String sLine = aBuffer.readLine();
- if (sLine == null)
- break;
-
- if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : { creation ConfigItem [file=standard, version=6, mode=3]"))
- t_cfg_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : } creation ConfigItem"))
- t_cfg_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : { reading TypeDetection.xml"))
- t_fwk_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("| framework (as96863) ::FilterCache::FilterCache : } reading TypeDetection.xml"))
- t_fwk_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadTypes"))
- t_types_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadTypes"))
- t_types_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadFilters"))
- t_filters_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadFilters"))
- t_filters_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [swriter]"))
- t_filters_swriter_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [swriter]"))
- t_filters_swriter_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [sweb]"))
- t_filters_sweb_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [sweb]"))
- t_filters_sweb_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [sglobal]"))
- t_filters_sglobal_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [sglobal]"))
- t_filters_sglobal_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [scalc]"))
- t_filters_scalc_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [scalc]"))
- t_filters_scalc_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [sdraw]"))
- t_filters_sdraw_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [sdraw]"))
- t_filters_sdraw_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [simpress]"))
- t_filters_simpress_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [simpress]"))
- t_filters_simpress_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [schart]"))
- t_filters_schart_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [schart]"))
- t_filters_schart_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ reading FilterGroup [smath]"))
- t_filters_smath_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} reading FilterGroup [smath]"))
- t_filters_smath_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("{ framework (as96863) ::FilterCFGAccess::impl_loadDetectors"))
- t_others_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} framework (as96863) ::FilterCFGAccess::impl_loadContentHandlers"))
- t_others_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} framework (as96863) ::FilterCache::FilterCache"))
- t_sfx_start = new java.lang.Long(sLine.substring(0, 6)).longValue();
- else
- if (sLine.endsWith("} desktop (lo119109) OfficeWrapper::OfficeWrapper"))
- t_sfx_end = new java.lang.Long(sLine.substring(0, 6)).longValue();
- }
-
- sOut.append(aLog.getName() );
- sOut.append(";" );
- sOut.append(t_cfg_start );
- sOut.append(";" );
- sOut.append(t_cfg_end );
- sOut.append(";" );
- sOut.append(t_fwk_start );
- sOut.append(";" );
- sOut.append(t_fwk_end );
- sOut.append(";" );
- sOut.append(t_sfx_start );
- sOut.append(";" );
- sOut.append(t_sfx_end );
- sOut.append(";" );
- sOut.append(t_types_start );
- sOut.append(";" );
- sOut.append(t_types_end );
- sOut.append(";" );
- sOut.append(t_filters_start );
- sOut.append(";" );
- sOut.append(t_filters_end );
- sOut.append(";" );
-
- sOut.append(t_filters_swriter_start );
- sOut.append(";" );
- sOut.append(t_filters_swriter_end );
- sOut.append(";" );
- sOut.append(t_filters_sweb_start );
- sOut.append(";" );
- sOut.append(t_filters_sweb_end );
- sOut.append(";" );
- sOut.append(t_filters_sglobal_start );
- sOut.append(";" );
- sOut.append(t_filters_sglobal_end );
- sOut.append(";" );
- sOut.append(t_filters_scalc_start );
- sOut.append(";" );
- sOut.append(t_filters_scalc_end );
- sOut.append(";" );
- sOut.append(t_filters_sdraw_start );
- sOut.append(";" );
- sOut.append(t_filters_sdraw_end );
- sOut.append(";" );
- sOut.append(t_filters_simpress_start );
- sOut.append(";" );
- sOut.append(t_filters_simpress_end );
- sOut.append(";" );
- sOut.append(t_filters_schart_start );
- sOut.append(";" );
- sOut.append(t_filters_schart_end );
- sOut.append(";" );
- sOut.append(t_filters_smath_start );
- sOut.append(";" );
- sOut.append(t_filters_smath_end );
- sOut.append(";" );
-
- sOut.append(t_others_start );
- sOut.append(";" );
- sOut.append(t_others_end );
- sOut.append(";" );
- sOut.append(t_cfg_end -t_cfg_start );
- sOut.append(";" );
- sOut.append(t_fwk_end -t_fwk_start );
- sOut.append(";" );
- sOut.append(t_sfx_end -t_sfx_start );
- sOut.append(";" );
- sOut.append(t_types_end -t_types_start );
- sOut.append(";" );
- sOut.append(t_filters_end-t_filters_start);
- sOut.append(";" );
- sOut.append(t_others_end -t_others_start );
- sOut.append(";" );
- sOut.append(t_others_end -t_cfg_start );
- sOut.append("\n" );
-
- aBuffer.close();
- }
-
- java.io.FileWriter aCSV = new java.io.FileWriter(sDataFile);
- java.lang.String sData = sOut.toString();
- aCSV.write(sData, 0, sData.length());
- aCSV.flush();
- aCSV.close();
- }
- catch(java.lang.Throwable exAny)
- {
- System.err.println(exAny.getMessage());
- exAny.printStackTrace();
- System.exit(--nExit);
- }
-
- System.exit(0);
- }
-}
diff --git a/l10ntools/source/filter/utils/Cache.java b/l10ntools/source/filter/utils/Cache.java
deleted file mode 100644
index 5ecea57..0000000
--- a/l10ntools/source/filter/utils/Cache.java
+++ /dev/null
@@ -1,2428 +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 com.sun.star.filter.config.tools.utils;
-
-//_______________________________________________
-
-import java.lang.*;
-import java.util.*;
-import java.io.*;
-
-//_______________________________________________
-
-/**
- * It implements a container for all possible entries which are part of the type
- * and filter mechanism of an office - means all items of the configuration file
- * "TypeDetection". How these entries will be readed or written can be switch
- * in different modes. That would make it possible to edit an xml directly or
- * to contact a running office instance.
- *
- *
- */
-public class Cache
-{
-
-
- /** identifies a file type item of this cache. */
- public static final int E_TYPE = 0;
-
- /** identifies a filter item of this cache. */
- public static final int E_FILTER = 1;
-
- /** identifies a detect service item of this cache. */
- public static final int E_DETECTSERVICE = 2;
-
- /** identifies a frame loader item of this cache. */
- public static final int E_FRAMELOADER = 3;
-
- /** identifies a content handler item of this cache. */
- public static final int E_CONTENTHANDLER = 4;
-
- /** indicates an unsupported xml format => error! */
- public static final int FORMAT_UNSUPPORTED = -1;
-
- /** identify the configuration format of an office 6.0.
- * The own formated data string is used. */
- public static final int FORMAT_60 = 0;
-
- /** identify the configuration format of an office 6.y.
- * Properties are realy xml tags again. */
- public static final int FORMAT_6Y = 1;
-
- /** identify the configuration format which is used inside
- * this tooling project. */
- public static final int FORMAT_INTERNAL = 2;
-
- /** right value for a command line parameter to define a 6.0 version. */
- public static final java.lang.String CMDVAL_FORMAT_60 = "6.0";
-
- /** right value for a command line parameter to define a 6.Y version. */
- public static final java.lang.String CMDVAL_FORMAT_6Y = "6.Y";
-
- /** right value for a command line parameter to define an internal xml version! */
- public static final java.lang.String CMDVAL_FORMAT_INTERNAL = "internal";
-
- // general
- public static final java.lang.String PROPNAME_DATA = "Data";
- public static final java.lang.String PROPNAME_NAME = "Name";
- public static final java.lang.String PROPNAME_UINAME = "UIName";
- public static final java.lang.String PROPNAME_UINAMES = "UINames";
-
- // type 6.0 ...
- public static final java.lang.String PROPNAME_MEDIATYPE = "MediaType";
- public static final java.lang.String PROPNAME_PREFERRED = "Preferred";
- public static final java.lang.String PROPNAME_CLIPBOARDFORMAT = "ClipboardFormat";
- public static final java.lang.String PROPNAME_DOCUMENTICONID = "DocumentIconID";
- public static final java.lang.String PROPNAME_URLPATTERN = "URLPattern";
- public static final java.lang.String PROPNAME_EXTENSIONS = "Extensions";
- // ... +6.y
- public static final java.lang.String PROPNAME_UIORDER = "UIOrder";
- public static final java.lang.String PROPNAME_PREFERREDFILTER = "PreferredFilter";
- public static final java.lang.String PROPNAME_DETECTSERVICE = "DetectService";
- public static final java.lang.String PROPNAME_FRAMELOADER = "FrameLoader";
- public static final java.lang.String PROPNAME_CONTENTHANDLER = "ContentHandler";
-
- // filter
- public static final java.lang.String PROPNAME_DOCUMENTSERVICE = "DocumentService";
- public static final java.lang.String PROPNAME_FILEFORMATVERSION = "FileFormatVersion";
- public static final java.lang.String PROPNAME_FILTERSERVICE = "FilterService";
- public static final java.lang.String PROPNAME_FLAGS = "Flags";
- public static final java.lang.String PROPNAME_ORDER = "Order"; // -6.y
- public static final java.lang.String PROPNAME_TEMPLATENAME = "TemplateName";
- public static final java.lang.String PROPNAME_TYPE = "Type";
- public static final java.lang.String PROPNAME_UICOMPONENT = "UIComponent";
- public static final java.lang.String PROPNAME_USERDATA = "UserData";
-
- // frame loader / detect services / content handler
- public static final java.lang.String PROPNAME_TYPES = "Types";
-
- //___________________________________________
- // private const
-
- private static final java.lang.String FILTERSERVICE_NATIVEWARPPER = "com.sun.star.filter.NativeFilterWrapper";
- private static final java.lang.String GENERIC_DETECTSERVICE = "com.sun.star.comp.office.FrameLoader";
-
- /** its the name of the cfg set, which contains all types. */
- private static final java.lang.String CFGNODE_TYPES = "Types";
-
- /** its the name of the cfg set, which contains all filters. */
- private static final java.lang.String CFGNODE_FILTERS = "Filters";
-
- /** its the name of the cfg set, which contains all detect services. */
- private static final java.lang.String CFGNODE_DETECTSERVICES = "DetectServices";
-
- /** its the name of the cfg set, which contains all frame loaders. */
- private static final java.lang.String CFGNODE_FRAMELOADERS = "FrameLoaders";
-
- /** its the name of the cfg set, which contains all content handlers. */
- private static final java.lang.String CFGNODE_CONTENTHANDLERS = "ContentHandlers";
-
- // names for filter flags
- private static final java.lang.String FLAGNAME_3RDPARTYFILTER = "3RDPARTYFILTER";
- private static final java.lang.String FLAGNAME_ALIEN = "ALIEN";
- private static final java.lang.String FLAGNAME_ASYNCHRON = "ASYNCHRON";
- private static final java.lang.String FLAGNAME_BROWSERPREFERRED = "BROWSERPREFERRED";
- private static final java.lang.String FLAGNAME_CONSULTSERVICE = "CONSULTSERVICE";
- private static final java.lang.String FLAGNAME_DEFAULT = "DEFAULT";
- private static final java.lang.String FLAGNAME_EXPORT = "EXPORT";
- private static final java.lang.String FLAGNAME_IMPORT = "IMPORT";
- private static final java.lang.String FLAGNAME_INTERNAL = "INTERNAL";
- private static final java.lang.String FLAGNAME_NOTINCHOOSER = "NOTINCHOOSER";
- private static final java.lang.String FLAGNAME_NOTINFILEDIALOG = "NOTINFILEDIALOG";
- private static final java.lang.String FLAGNAME_NOTINSTALLED = "NOTINSTALLED";
- private static final java.lang.String FLAGNAME_OWN = "OWN";
- private static final java.lang.String FLAGNAME_PACKED = "PACKED";
- private static final java.lang.String FLAGNAME_PREFERRED = "PREFERRED";
- private static final java.lang.String FLAGNAME_READONLY = "READONLY";
- private static final java.lang.String FLAGNAME_TEMPLATE = "TEMPLATE";
- private static final java.lang.String FLAGNAME_TEMPLATEPATH = "TEMPLATEPATH";
- private static final java.lang.String FLAGNAME_USESOPTIONS = "USESOPTIONS";
-
- private static final java.lang.String FLAGNAME_COMBINED = "COMBINED";
- private static final java.lang.String FLAGNAME_SUPPORTSSELECTION= "SUPPORTSSELECTION";
-
- // values for filter flags
- private static final int FLAGVAL_3RDPARTYFILTER = 0x00080000; // 524288
- private static final int FLAGVAL_ALIEN = 0x00000040; // 64
- private static final int FLAGVAL_ALL = 0xffffffff; // 4294967295
- private static final int FLAGVAL_ASYNCHRON = 0x00004000; // 16384
- private static final int FLAGVAL_BROWSERPREFERRED = 0x00400000; // 4194304
- private static final int FLAGVAL_CONSULTSERVICE = 0x00040000; // 262144
- private static final int FLAGVAL_DEFAULT = 0x00000100; // 256
- private static final int FLAGVAL_EXPORT = 0x00000002; // 2
- private static final int FLAGVAL_IMPORT = 0x00000001; // 1
- private static final int FLAGVAL_INTERNAL = 0x00000008; // 8
- private static final int FLAGVAL_NOTINCHOOSER = 0x00002000; // 8192
- private static final int FLAGVAL_NOTINFILEDIALOG = 0x00001000; // 4096
- private static final int FLAGVAL_NOTINSTALLED = 0x00020000; // 131072
- private static final int FLAGVAL_OWN = 0x00000020; // 32
- private static final int FLAGVAL_PACKED = 0x00100000; // 1048576
- private static final int FLAGVAL_PREFERRED = 0x10000000; // 268435456
- private static final int FLAGVAL_READONLY = 0x00010000; // 65536
- private static final int FLAGVAL_TEMPLATE = 0x00000004; // 4
- private static final int FLAGVAL_TEMPLATEPATH = 0x00000010; // 16
- private static final int FLAGVAL_USESOPTIONS = 0x00000080; // 128
-
- private static final int FLAGVAL_COMBINED = 0x00800000; // ...
- private static final int FLAGVAL_SUPPORTSSELECTION = 0x00000400; // 1024
-
- //___________________________________________
- // member
-
- /** list of all located types.
- * Format: [string,HashMap]
- */
- private java.util.HashMap m_lTypes;
-
- /** list of all located filters.
- * Format: [string,HashMap]
- */
- private java.util.HashMap m_lFilters;
-
- /** list of all located detect services.
- * Format: [string,HashMap]
- */
- private java.util.HashMap m_lDetectServices;
-
- /** list of all located frame loader.
- * Format: [string,HashMap]
- */
- private java.util.HashMap m_lFrameLoaders;
-
- /** list of all located content handler.
- * Format: [string,HashMap]
- */
- private java.util.HashMap m_lContentHandlers;
-
- /** contains all analyzed relations between
- * filters and types. The key is an internal
- * type name (can be used as reference into the
- * list m_lTypes) and the value is a Vector of all
- * internal filter names, which are registered for
- * this type.
- * Format: [string, Vector]
- */
- private java.util.HashMap m_lFilterToTypeRegistrations;
-
- private int m_nDoubleRegisteredFilters;
- private int m_nTypesForFilters;
- private int m_nTypesForDetectServices;
- private int m_nTypesForFrameLoaders;
- private int m_nTypesForContentHandlers;
-
- /** can be used to log different informations. */
- private Logger m_aDebug;
-
- //___________________________________________
- // interface
-
- /** standard ctor.
- *
- * Initialize an empty cache instance. You have to use
- * on of the fromXXX() methods to fill it from different
- * sources with content.
- */
- public Cache(Logger aDebug)
- {
- reset();
- m_aDebug = aDebug;
- }
-
- //___________________________________________
-
- /** free memory and set default values on all members.
- */
- public synchronized void reset()
- {
- m_lTypes = new java.util.HashMap();
- m_lFilters = new java.util.HashMap();
- m_lFrameLoaders = new java.util.HashMap();
- m_lDetectServices = new java.util.HashMap();
- m_lContentHandlers = new java.util.HashMap();
- m_lFilterToTypeRegistrations = new java.util.HashMap();
- m_aDebug = new Logger();
- m_nDoubleRegisteredFilters = 0;
- m_nTypesForFilters = 0;
- m_nTypesForDetectServices = 0;
- m_nTypesForFrameLoaders = 0;
- m_nTypesForContentHandlers = 0;
- }
-
- //___________________________________________
-
- /** converts a string representation of an xml format
- * to its int value, which must be used at some interface
- * methods of this cache.
- *
- * If the given string does not match to any well known format,
- * the return value will be FORMAT_UNSUPPORTED. The calli have to
- * check that. Otherwhise a called interface method at this cache
- * instance will be rejected by an exception!
- *
- * @param sFormat
- * the string representation
- * Must be one of our public const values from type CMDVAL_FORMAT_xxx.
- *
- * @return [int]
- * the int representation.
- * Will be one of our public const values from type FORMAT_xxx.
- */
- public static int mapFormatString2Format(java.lang.String sFormat)
- {
- int nFormat = FORMAT_UNSUPPORTED;
- if (sFormat.equalsIgnoreCase(CMDVAL_FORMAT_60))
- nFormat = FORMAT_60;
- else
- if (sFormat.equalsIgnoreCase(CMDVAL_FORMAT_6Y))
- nFormat = FORMAT_6Y;
- else
- if (sFormat.equalsIgnoreCase(CMDVAL_FORMAT_INTERNAL))
- nFormat = FORMAT_INTERNAL;
- return nFormat;
- }
-
- //___________________________________________
-
- /** return some statistic values.
- *
- * Such values can be: - count of container items,
- * - ...
- *
- * @return [java.lang.String]
- * a formated string, which contains al statistic data.
- */
- public synchronized java.lang.String getStatistics()
- {
- java.lang.StringBuffer sBuffer = new java.lang.StringBuffer(256);
-
- sBuffer.append("types = "+m_lTypes.size() +"\n");
- sBuffer.append("filters = "+m_lFilters.size() +"\n");
- sBuffer.append("detect services = "+m_lDetectServices.size() +"\n");
- sBuffer.append("frame loaders = "+m_lFrameLoaders.size() +"\n");
- sBuffer.append("content handler = "+m_lContentHandlers.size() +"\n");
- sBuffer.append("double registered filters = "+m_nDoubleRegisteredFilters+"\n");
- sBuffer.append("types used by filters = "+m_nTypesForFilters +"\n");
- sBuffer.append("types used by detect services = "+m_nTypesForDetectServices +"\n");
- sBuffer.append("types used by frame loaders = "+m_nTypesForFrameLoaders +"\n");
- sBuffer.append("types used by content handlers = "+m_nTypesForContentHandlers+"\n");
-
- return sBuffer.toString();
- }
-
- //___________________________________________
-
- /** reset this cache and fill it with new values using the given XML file.
- *
- * @param aXML
- * must be a system file of a suitable XML file, which
- * include all neccessary type/filter items.
- *
- * @param nFormat
- * identifies the format of the specified xml file,
- * which must be interpreted.
- */
- public synchronized void fromXML(java.io.File aXML ,
- int nFormat)
- throws java.lang.Exception
- {
- // clear this cache
- reset();
-
- // parse it
- javax.xml.parsers.DocumentBuilderFactory aFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
- /* Attention:
- * This call is important. It force right handling of entities during parsing and(!)
- * writing. It let all possible signs for entities or it's quoted representations
- * untouched. So this class don't change the original signs of the original file.
- * Means:
- * <ul>
- * <li>(') => (')</li>
- * <li>(") => (")</li>
- * <li>(>) => (>)</li>
- * <li>(<) => (<)</li>
- * <li>(>) => (>)</li>
- * <li>(&) => (&)</li>
- * <li>...</li>
- * </ul>
- */
-
- System.out.println("TODO: must be adapted to java 1.3 :-(");
- System.exit(-1);
-//TODO_JAVA aFactory.setExpandEntityReferences(false);
-
- javax.xml.parsers.DocumentBuilder aBuilder = aFactory.newDocumentBuilder();
- org.w3c.dom.Document aDOM = aBuilder.parse(aXML);
- org.w3c.dom.Element aRoot = aDOM.getDocumentElement();
-
- // step over all sets
- java.util.Vector lSetNodes = XMLHelper.extractChildNodesByTagName(aRoot, XMLHelper.XMLTAG_NODE);
- java.util.Enumeration it1 = lSetNodes.elements();
- while (it1.hasMoreElements())
- {
- // try to find out, which set should be read
- org.w3c.dom.Node aSetNode = (org.w3c.dom.Node)it1.nextElement();
- java.lang.String sSetName = XMLHelper.extractNodeAttribByName(aSetNode, XMLHelper.XMLATTRIB_OOR_NAME);
- if (sSetName == null)
- throw new java.io.IOException("unsupported format: could not extract set name on node ...\n"+aSetNode);
-
- // map some generic interfaces to the right members!
- int eType = -1 ;
- java.util.HashMap rMap = null;
-
- if (sSetName.equals(CFGNODE_TYPES))
- {
- eType = E_TYPE;
- rMap = m_lTypes;
- }
- else
- if (sSetName.equals(CFGNODE_FILTERS))
- {
- eType = E_FILTER;
- rMap = m_lFilters;
- }
- else
- if (sSetName.equals(CFGNODE_FRAMELOADERS))
- {
- eType = E_FRAMELOADER;
- rMap = m_lFrameLoaders;
- }
- else
- if (sSetName.equals(CFGNODE_DETECTSERVICES))
- {
- eType = E_DETECTSERVICE;
- rMap = m_lDetectServices;
- }
- else
- if (sSetName.equals(CFGNODE_CONTENTHANDLERS))
- {
- eType = E_CONTENTHANDLER;
- rMap = m_lContentHandlers;
- }
- else
- throw new java.io.IOException("unsupported format: unknown set name [\""+sSetName+"\"] detected on node ...\n"+aSetNode);
-
- // load all set entries
- java.util.Vector lChildNodes = XMLHelper.extractChildNodesByTagName(aSetNode, XMLHelper.XMLTAG_NODE);
- java.util.Enumeration it2 = lChildNodes.elements();
- while (it2.hasMoreElements())
- {
- org.w3c.dom.Node aChildNode = (org.w3c.dom.Node)it2.nextElement();
- java.lang.String sChildName = XMLHelper.extractNodeAttribByName(aChildNode, XMLHelper.XMLATTRIB_OOR_NAME);
- if (sChildName == null)
- throw new java.io.IOException("unsupported format: could not extract child node name on node ...\n"+aChildNode);
- java.util.HashMap aPropSet = null;
-
- // Note: Our internal format is different from the source format!
- java.util.HashMap aTempSet = XMLHelper.convertNodeToPropSet(aChildNode);
- switch(eType)
- {
- case E_TYPE :
- {
- aPropSet = Cache.convertTypePropsToInternal(aTempSet, nFormat);
- m_aDebug.setDetailedInfo("type [\""+sChildName+"\"] converted to internal format");
- }
- break;
-
- case E_FILTER :
- {
- aPropSet = Cache.convertFilterPropsToInternal(aTempSet, nFormat);
- m_aDebug.setDetailedInfo("filter [\""+sChildName+"\"] converted to internal format");
- }
- break;
-
- case E_DETECTSERVICE :
- {
- aPropSet = Cache.convertDetectServicePropsToInternal(aTempSet, nFormat);
- m_aDebug.setDetailedInfo("detect service [\""+sChildName+"\"] converted to internal format");
- }
- break;
-
- case E_FRAMELOADER :
- {
- aPropSet = Cache.convertFrameLoaderPropsToInternal(aTempSet, nFormat);
- m_aDebug.setDetailedInfo("frame loader [\""+sChildName+"\"] converted to internal format");
- }
- break;
-
- case E_CONTENTHANDLER :
- {
- aPropSet = Cache.convertContentHandlerPropsToInternal(aTempSet, nFormat);
- m_aDebug.setDetailedInfo("content handler [\""+sChildName+"\"] converted to internal format");
- }
- break;
- }
- m_aDebug.setDetailedInfo("props = "+aTempSet);
- rMap.put(sChildName, aPropSet);
- }
- }
- }
-
- //___________________________________________
-
- /** create some hml views of the current content of this cache.
- *
- * The given directory is used to create different html files
- * there. Every of them show another aspect of this cache.
- * E.g.: - all type/filter properties
- * - relation ships between types/filters/loaders etc.
- *
- * @param aDirectory
- * points to a system directory, which
- * can be used completely(!) to generate
- * the results there.
- *
- * @param nFormat
- * specify in which context the cache items should be
- * interpreted.
- */
- public synchronized void toHTML(java.io.File aDirectory,
- int nFormat ,
- java.lang.String sEncoding )
- throws java.lang.Exception
- {
- if (nFormat != FORMAT_6Y)
- throw new java.lang.Exception("HTML views are supported for the new 6.y format only yet.");
-
- java.lang.StringBuffer sRelationView = new java.lang.StringBuffer(1000);
- sRelationView.append("<html><header><title>Relation View</title></header><body>");
- sRelationView.append("<table border=1>");
- sRelationView.append("<tr><td><b>type</b></td><td><b>detect service</b></td><td><b>preferred filter</b></td><td><b>frame loader</b></td><td><b>content handler</b></td></tr>");
-
- java.util.Iterator aIt = m_lTypes.keySet().iterator();
- while (aIt.hasNext())
- {
- java.lang.String sType = (java.lang.String)aIt.next();
- java.util.HashMap aType = (java.util.HashMap)m_lTypes.get(sType);
-
- sRelationView.append("<tr>");
- sRelationView.append("<td>"+sType+"</td>");
-
- java.lang.String sVal = (java.lang.String)aType.get(PROPNAME_DETECTSERVICE);
- if (sVal == null || sVal.length()<1)
- sRelationView.append("<td> - </td>");
- else
- sRelationView.append("<td>"+sVal+"</td>");
-
- sVal = (java.lang.String)aType.get(PROPNAME_PREFERREDFILTER);
- if (sVal == null || sVal.length()<1)
- sRelationView.append("<td> - </td>");
- else
- sRelationView.append("<td>"+sVal+"</td>");
-
- sVal = (java.lang.String)aType.get(PROPNAME_FRAMELOADER);
- if (sVal == null || sVal.length()<1)
- sRelationView.append("<td> - </td>");
- else
- sRelationView.append("<td>"+sVal+"</td>");
-
- sVal = (java.lang.String)aType.get(PROPNAME_CONTENTHANDLER);
- if (sVal == null || sVal.length()<1)
- sRelationView.append("<td> - </td>");
- else
- sRelationView.append("<td>"+sVal+"</td>");
-
- sRelationView.append("</tr>");
- }
-
- sRelationView.append("</table>");
- sRelationView.append("</body>");
-
- FileHelper.writeEncodedBufferToFile(new java.io.File(aDirectory, "relation_view.html"), sEncoding, false, sRelationView);
-
- java.util.HashMap lFilters2TypeRegistration = new java.util.HashMap();
- aIt = m_lFilters.keySet().iterator();
- while (aIt.hasNext())
- {
- java.lang.String sFilter = (java.lang.String)aIt.next();
- java.util.HashMap aFilter = (java.util.HashMap)m_lFilters.get(sFilter);
- java.lang.String sType = (java.lang.String)aFilter.get(PROPNAME_TYPE);
-
- java.util.Vector lFilters = (java.util.Vector)lFilters2TypeRegistration.get(sType);
- if (lFilters == null)
- lFilters = new java.util.Vector();
- lFilters.add(sFilter);
- lFilters2TypeRegistration.put(sType, lFilters);
- }
-
- java.lang.StringBuffer sType2FiltersView = new java.lang.StringBuffer(1000);
- sType2FiltersView.append("<html><header><title>Type2Filters View</title></header><body>");
- sType2FiltersView.append("<table border=1>");
- sType2FiltersView.append("<tr><td><b>type</b></td><td><b>filters</b></td></tr>");
-
- aIt = lFilters2TypeRegistration.keySet().iterator();
- while (aIt.hasNext())
- {
- java.lang.String sType = (java.lang.String)aIt.next();
- java.util.Vector lFilters = (java.util.Vector)lFilters2TypeRegistration.get(sType);
-
- sType2FiltersView.append("<tr><td>"+sType+"</td><td>");
- java.util.Enumeration aEn = lFilters.elements();
- while(aEn.hasMoreElements())
- sType2FiltersView.append(aEn.nextElement()+"<br>");
- sType2FiltersView.append("</td></tr>");
- }
-
- sType2FiltersView.append("</table>");
- sType2FiltersView.append("</body>");
-
- FileHelper.writeEncodedBufferToFile(new java.io.File(aDirectory, "type2filters_view.html"), sEncoding, false, sType2FiltersView);
- }
-
- //___________________________________________
-
- /** converts all items of this cache to its xml representation
- * and write it to the given file.
- *
- * @param aXML
- * the target file for output.
- *
- * @param nFormat
- * the requested xml format.
- * see const values FORMAT_xxx too.
- *
- * @param sEncoding
- * specify the file encoding for the generated xml file.
- *
- * @throws [java.lang.Exception]
- * if something fail during convertion.
- */
- public synchronized void toXML(java.io.File aXML ,
- int nFormat ,
- java.lang.String sEncoding)
- throws java.lang.Exception
- {
- java.lang.StringBuffer sXML = new java.lang.StringBuffer(500000);
-
- for (int i=0; i<5; ++i)
- {
- // define right sub container
- java.lang.String sSetName = null;
- java.util.HashMap rMap = null;
- int eType = -1;
-
- switch(i)
- {
- case 0 :
- {
- sSetName = CFGNODE_TYPES;
- rMap = m_lTypes;
- eType = E_TYPE;
- }
- break;
-
- case 1 :
- {
- sSetName = CFGNODE_FILTERS;
- rMap = m_lFilters;
- eType = E_FILTER;
- }
- break;
-
- case 2 :
- {
- sSetName = CFGNODE_DETECTSERVICES;
- rMap = m_lDetectServices;
- eType = E_DETECTSERVICE;
- }
- break;
-
- case 3 :
- {
- sSetName = CFGNODE_FRAMELOADERS;
- rMap = m_lFrameLoaders;
- eType = E_FRAMELOADER;
- }
- break;
-
- case 4 :
- {
- sSetName = CFGNODE_CONTENTHANDLERS;
- rMap = m_lContentHandlers;
- eType = E_CONTENTHANDLER;
- }
- break;
- }
-
- // generate set
- sXML.append("<node oor:name=\""+sSetName+"\" oor:op=\"replace\">\n");
- java.util.Iterator it = rMap.keySet().iterator();
- while(it.hasNext())
- {
- java.lang.String sItem = (java.lang.String)it.next();
- sXML.append("<node oor:name=\""+sItem+"\" oor:op=\"replace\">\n");
- sXML.append(getItemAsXML(eType, sItem, nFormat));
- sXML.append("</node>\n");
- }
- sXML.append("</node>\n");
- }
-
- java.io.FileOutputStream aStream = new java.io.FileOutputStream(aXML.getAbsolutePath(), false);
- java.io.OutputStreamWriter aWriter = new java.io.OutputStreamWriter(aStream, sEncoding);
- java.lang.String sOut = sXML.toString();
- aWriter.write(sOut, 0, sOut.length());
- aWriter.flush();
- aWriter.close();
- }
-
- //___________________________________________
-
- /** converts a type property set from internal format
- * to an external one.
- *
- * @param aMap
- * points to the item, which should be converted.
- *
- * @param nFormat
- * specify the requested output format.
- *
- * @return [java.util.HashMap]
- * contains the properties in the requested format.
- *
- * @throws [java.lang.Exception
- * if something fail during convertion.
- */
- private static java.util.HashMap convertTypePropsToExternal(java.util.HashMap aMap ,
- int nFormat)
- throws java.lang.Exception
- {
- java.util.HashMap aResultMap = new java.util.HashMap();
- // copy Name property ... if it exists!
- if (aMap.containsKey(PROPNAME_NAME))
- aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME));
- switch(nFormat)
- {
- //-----------------------------------
- case FORMAT_60 :
- {
- // copy UIName property unchanged
- aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME));
-
- // ignore properties "UIOrder", "PreferredFilter", "DetectService"
- // They are not supported for 6.0 types.
-
- // pack all other properties to one "Data" string value
- java.lang.StringBuffer sData = new java.lang.StringBuffer(256);
-
- sData.append(aMap.get(PROPNAME_PREFERRED));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_MEDIATYPE));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_CLIPBOARDFORMAT));
- sData.append(",");
-
- java.util.Vector lList = (java.util.Vector)aMap.get(PROPNAME_URLPATTERN);
- int c = lList.size();
- int i = 0;
- for (i=0; i<c; ++i)
- {
- sData.append(lList.elementAt(i));
- if (i<(c-1))
- sData.append(";");
- }
-
- lList = (java.util.Vector)aMap.get(PROPNAME_EXTENSIONS);
- c = lList.size();
- for (i=0; i<c; ++i)
- {
- sData.append(lList.elementAt(i));
- if (i<(c-1))
- sData.append(";");
- }
-
- sData.append(",");
- sData.append(aMap.get(PROPNAME_DOCUMENTICONID));
- sData.append(",");
-
- aResultMap.put(PROPNAME_DATA, sData.toString());
- }
- break;
-
- //-----------------------------------
- case FORMAT_6Y :
- {
- // copy all supported properties directly
- aResultMap.put(PROPNAME_PREFERRED , aMap.get(PROPNAME_PREFERRED ));
- aResultMap.put(PROPNAME_MEDIATYPE , aMap.get(PROPNAME_MEDIATYPE ));
- aResultMap.put(PROPNAME_URLPATTERN , aMap.get(PROPNAME_URLPATTERN ));
- aResultMap.put(PROPNAME_EXTENSIONS , aMap.get(PROPNAME_EXTENSIONS ));
- aResultMap.put(PROPNAME_UINAME , aMap.get(PROPNAME_UINAME ));
- aResultMap.put(PROPNAME_PREFERREDFILTER, aMap.get(PROPNAME_PREFERREDFILTER));
- aResultMap.put(PROPNAME_DETECTSERVICE , aMap.get(PROPNAME_DETECTSERVICE ));
- aResultMap.put(PROPNAME_CLIPBOARDFORMAT, aMap.get(PROPNAME_CLIPBOARDFORMAT));
- aResultMap.put(PROPNAME_UIORDER , aMap.get(PROPNAME_UIORDER ));
- /* REMOVED!
- aResultMap.put(PROPNAME_DOCUMENTICONID , aMap.get(PROPNAME_DOCUMENTICONID ));
- */
- }
- break;
-
- //-----------------------------------
- default :
- throw new java.lang.Exception("unknown format");
- }
-
- return aResultMap;
- }
-
- //___________________________________________
-
- /** converts a filter property set from internal format
- * to an external one.
- *
- * @param aMap
- * points to the item, which should be converted.
- *
- * @param nFormat
- * specify the requested output format.
- *
- * @return [java.util.HashMap]
- * contains the properties in the requested format.
- *
- * @throws [java.lang.Exception
- * if something fail during convertion.
- */
- private static java.util.HashMap convertFilterPropsToExternal(java.util.HashMap aMap ,
- int nFormat)
- throws java.lang.Exception
- {
- java.util.HashMap aResultMap = new java.util.HashMap();
- // copy Name property ... if it exists!
- if (aMap.containsKey(PROPNAME_NAME))
- aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME));
- switch(nFormat)
- {
- //-----------------------------------
- case FORMAT_60 :
- {
- // copy UIName property unchanged!
- aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME));
-
- // but pack all other properties
- java.lang.StringBuffer sData = new java.lang.StringBuffer(256);
-
- sData.append(aMap.get(PROPNAME_ORDER));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_TYPE));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_DOCUMENTSERVICE));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_FILTERSERVICE));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_FLAGS));
- sData.append(",");
- java.util.Vector lList = (java.util.Vector)aMap.get(PROPNAME_USERDATA);
- int c = lList.size();
- int i = 0;
- for (i=0; i<c; ++i)
- {
- sData.append(lList.elementAt(i));
- if (i<(c-1))
- sData.append(";");
- }
- sData.append(",");
- sData.append(aMap.get(PROPNAME_FILEFORMATVERSION));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_TEMPLATENAME));
- sData.append(",");
- sData.append(aMap.get(PROPNAME_UICOMPONENT));
- sData.append(",");
-
- aResultMap.put(PROPNAME_DATA, sData.toString());
- }
- break;
-
- //-----------------------------------
- case FORMAT_6Y :
- {
- // supress "Order" property.
- // Will be moved to type entries in 6.y version!
-
- // supress "UIName" property.
- // Only type entries will be localized in 6.y version!
- /* TODO make it configurable :-) */
- aResultMap.put(PROPNAME_UINAME , aMap.get(PROPNAME_UINAME ));
-
- // copy all supported properties directly
- aResultMap.put(PROPNAME_TYPE , aMap.get(PROPNAME_TYPE ));
- aResultMap.put(PROPNAME_DOCUMENTSERVICE , aMap.get(PROPNAME_DOCUMENTSERVICE ));
- aResultMap.put(PROPNAME_FILTERSERVICE , aMap.get(PROPNAME_FILTERSERVICE ));
- aResultMap.put(PROPNAME_USERDATA , aMap.get(PROPNAME_USERDATA ));
- aResultMap.put(PROPNAME_FILEFORMATVERSION, aMap.get(PROPNAME_FILEFORMATVERSION));
- aResultMap.put(PROPNAME_TEMPLATENAME , aMap.get(PROPNAME_TEMPLATENAME ));
- aResultMap.put(PROPNAME_UICOMPONENT , aMap.get(PROPNAME_UICOMPONENT ));
-
- // "Flags" will be converted from internal format [int] to
- // the 6.y format [string-list]!
- java.lang.Integer nFlags = (java.lang.Integer)aMap.get(PROPNAME_FLAGS);
- java.util.Vector lFlags = Cache.convertFilterFlagValues2Names(nFlags);
- aResultMap.put(PROPNAME_FLAGS, lFlags);
- }
- break;
-
- //-----------------------------------
- default :
- throw new java.lang.Exception("unknown format");
- }
-
- return aResultMap;
- }
-
- //___________________________________________
-
- /** converts a detect service property set from internal format
- * to an external one.
- *
- * @param aMap
- * points to the item, which should be converted.
- *
- * @param nFormat
- * specify the requested output format.
- *
- * @return [java.util.HashMap]
- * contains the properties in the requested format.
- *
- * @throws [java.lang.Exception
- * if something fail during convertion.
- */
- private static java.util.HashMap convertDetectServicePropsToExternal(java.util.HashMap aMap ,
- int nFormat)
- throws java.lang.Exception
- {
- java.util.HashMap aResultMap = null;
-
- switch(nFormat)
- {
- //-----------------------------------
- case FORMAT_60 :
- {
- // no changes!
- aResultMap = aMap;
- }
- break;
-
- //-----------------------------------
- case FORMAT_6Y :
- {
- // remove localized name
- aResultMap = aMap;
- aResultMap.remove(PROPNAME_UINAME);
- }
- break;
-
- //-----------------------------------
- default :
- throw new java.lang.Exception("unknown format");
- }
-
- return aResultMap;
- }
-
- private static java.util.HashMap convertFrameLoaderPropsToExternal(java.util.HashMap aMap ,
- int nFormat)
- throws java.lang.Exception
- {
- java.util.HashMap aResultMap = null;
-
- switch(nFormat)
- {
- //-----------------------------------
- case FORMAT_60 :
- {
- // no changes!
- aResultMap = aMap;
- }
- break;
-
- //-----------------------------------
- case FORMAT_6Y :
- {
- // remove localized name
- aResultMap = aMap;
- aResultMap.remove(PROPNAME_UINAME);
- }
- break;
-
- //-----------------------------------
- default :
- throw new java.lang.Exception("unknown format");
- }
-
- return aResultMap;
- }
-
- private static java.util.HashMap convertContentHandlerPropsToExternal(java.util.HashMap aMap ,
- int nFormat)
- throws java.lang.Exception
- {
- java.util.HashMap aResultMap = null;
-
- switch(nFormat)
- {
- //-----------------------------------
- case FORMAT_60 :
- {
- // no changes!
- aResultMap = aMap;
- }
- break;
-
- //-----------------------------------
- case FORMAT_6Y :
- {
- // remove localized name
- aResultMap = aMap;
- aResultMap.remove(PROPNAME_UINAME);
- }
- break;
-
- //-----------------------------------
- default :
- throw new java.lang.Exception("unknown format");
- }
-
- return aResultMap;
- }
-
- //___________________________________________
-
- /** converts a type property set (using an external format) to
- * our internal cache format.
- *
- * Especialy the data format string will be expanded
- * to its real properties.
- *
- * Schema:
- * aMap["UIName"] => aExpandedMap["UIName"]
- * aMap["Data" ] => aExpandedMap["Preferred" ], aExpandedMap["MediaType"] etc. ...
- *
- * @param aMap
- * points to the item, which should be converted.
-
- * @param nFormat
- * specify the external format.
- *
- * @return [java.util.HashMap]
- * The new map in internal format.
- */
- private static java.util.HashMap convertTypePropsToInternal(java.util.HashMap aMap ,
- int nFormat)
- throws java.lang.Exception
- {
- java.util.HashMap aResultMap = new java.util.HashMap();
- // copy Name property ... if it exists!
- if (aMap.containsKey(PROPNAME_NAME))
- aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME));
- switch(nFormat)
- {
- //-----------------------------------
- case FORMAT_60 :
- {
- // copy UIName property unchanged!
- aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME));
-
- // generate new property "UIOrder"
- // Its the moved property "Order" of filters for versions >= 6.y!
- aResultMap.put(PROPNAME_UIORDER, new java.lang.Integer(0));
-
- // generate new property "PreferredFilter"
- // Its a the moved filter flag "Preferred" for versions >= 6.y!
- aResultMap.put(PROPNAME_PREFERREDFILTER, new java.lang.String());
-
- // generate new property "DetectService"
- // Every type know its detector diretcly from now. No search
- // will be necessary any longer.
- aResultMap.put(PROPNAME_DETECTSERVICE, new java.lang.String());
-
- // analyze the Data property of the original map
- // and copy its results (means all expanded properties)
- // to the result map.
- java.lang.String sDataVal = (java.lang.String)aMap.get(PROPNAME_DATA);
- java.util.Vector lTokens = Cache.splitTokenString(sDataVal, ",");
-
- int t = 0;
- java.util.Enumeration it = lTokens.elements();
- while (it.hasMoreElements())
- {
- java.lang.String sToken = (java.lang.String)it.nextElement();
- switch(t)
- {
- case 0 :
- aResultMap.put(PROPNAME_PREFERRED, new java.lang.Boolean(sToken));
- break;
- case 1 :
- aResultMap.put(PROPNAME_MEDIATYPE, sToken);
- break;
- case 2 :
- {
- /*HACK ersetze %20 mit " " ...*/
- int ni = sToken.indexOf("%20");
- if (ni!=-1)
- {
- java.lang.String sPatch = sToken.substring(0,ni) + " " + sToken.substring(ni+3);
- sToken = sPatch;
- }
- aResultMap.put(PROPNAME_CLIPBOARDFORMAT, sToken);
- }
- break;
- case 3 :
- aResultMap.put(PROPNAME_URLPATTERN, Cache.splitTokenString(sToken, ";"));
- break;
- case 4 :
- aResultMap.put(PROPNAME_EXTENSIONS, Cache.splitTokenString(sToken, ";"));
- break;
- case 5 :
- aResultMap.put(PROPNAME_DOCUMENTICONID, new java.lang.Integer(sToken));
- break;
- default :
- throw new java.lang.Exception("unsupported format for data value of a type \""+aMap.get(PROPNAME_NAME)+"\" detected.");
- }
- ++t;
- }
- }
- break;
-
- //-----------------------------------
- case FORMAT_6Y :
- {
- // copy all supported properties directly
- aResultMap.put(PROPNAME_PREFERRED , aMap.get(PROPNAME_PREFERRED ));
- aResultMap.put(PROPNAME_MEDIATYPE , aMap.get(PROPNAME_MEDIATYPE ));
- aResultMap.put(PROPNAME_CLIPBOARDFORMAT, aMap.get(PROPNAME_CLIPBOARDFORMAT));
- aResultMap.put(PROPNAME_URLPATTERN , aMap.get(PROPNAME_URLPATTERN ));
- aResultMap.put(PROPNAME_EXTENSIONS , aMap.get(PROPNAME_EXTENSIONS ));
- aResultMap.put(PROPNAME_DOCUMENTICONID , aMap.get(PROPNAME_DOCUMENTICONID ));
- aResultMap.put(PROPNAME_UINAME , aMap.get(PROPNAME_UINAME ));
- aResultMap.put(PROPNAME_UIORDER , aMap.get(PROPNAME_UIORDER ));
- aResultMap.put(PROPNAME_PREFERREDFILTER, aMap.get(PROPNAME_PREFERREDFILTER));
- aResultMap.put(PROPNAME_DETECTSERVICE , aMap.get(PROPNAME_DETECTSERVICE ));
- }
- break;
-
- //-----------------------------------
- default :
- throw new java.lang.Exception("unknown format");
- }
-
- return aResultMap;
- }
-
- //___________________________________________
-
- /** converts a filter property set (using an external format) to
- * our internal cache format.
- *
- * Especialy the data format string will be expanded
- * to its real properties.
- *
- * Schema:
- * aMap["UIName"] => aExpandedMap["UIName"]
- * aMap["Data" ] => aExpandedMap["Order" ], aExpandedMap["Flags"] etc. ...
- *
- * @param aMap
- * points to the item, which should be converted.
- *
- * @param nFormat
- * specify the external format.
- *
- * @return [java.util.HashMap]
- * The new map in internal format.
- */
- private static java.util.HashMap convertFilterPropsToInternal(java.util.HashMap aMap ,
- int nFormat)
- throws java.lang.Exception
- {
- java.util.HashMap aResultMap = new java.util.HashMap();
- // copy Name property ... if it exists!
- if (aMap.containsKey(PROPNAME_NAME))
- aResultMap.put(PROPNAME_NAME, aMap.get(PROPNAME_NAME));
- switch(nFormat)
- {
- //-----------------------------------
- case FORMAT_60 :
- {
- // copy UIName property
- aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME));
-
- // analyze the Data property of the original map
- // and copy its results (means all expanded properties)
- // to the result map.
- java.lang.String sDataVal = (java.lang.String)aMap.get(PROPNAME_DATA);
- java.util.Vector lTokens = Cache.splitTokenString(sDataVal, ",");
-
- int t = 0;
- java.util.Enumeration it = lTokens.elements();
- while (it.hasMoreElements())
- {
- java.lang.String sToken = (java.lang.String)it.nextElement();
- switch(t)
- {
- case 0 :
- aResultMap.put(PROPNAME_ORDER, new java.lang.Integer(sToken));
- break;
- case 1 :
- aResultMap.put(PROPNAME_TYPE, sToken);
- break;
- case 2 :
- aResultMap.put(PROPNAME_DOCUMENTSERVICE, sToken);
- break;
- case 3 :
- aResultMap.put(PROPNAME_FILTERSERVICE, sToken);
- break;
- case 4 :
- aResultMap.put(PROPNAME_FLAGS, new java.lang.Integer(sToken));
- break;
- case 5 :
- aResultMap.put(PROPNAME_USERDATA, Cache.splitTokenString(sToken, ";"));
- break;
- case 6 :
- aResultMap.put(PROPNAME_FILEFORMATVERSION, new java.lang.Integer(sToken));
- break;
- case 7 :
- aResultMap.put(PROPNAME_TEMPLATENAME, sToken);
- break;
- case 8 :
- aResultMap.put(PROPNAME_UICOMPONENT, sToken);
- break;
- default :
- throw new java.lang.Exception("unsupported format for data value of a filter detected.");
- }
- ++t;
- }
-
- // its an optional property :-)
- if (!aResultMap.containsKey(PROPNAME_TEMPLATENAME))
- aResultMap.put(PROPNAME_TEMPLATENAME, new java.lang.String(""));
-
- // its an optional property :-)
- if (!aResultMap.containsKey(PROPNAME_UICOMPONENT))
- aResultMap.put(PROPNAME_UICOMPONENT, new java.lang.String(""));
- }
- break;
-
- //-----------------------------------
- case FORMAT_6Y :
- {
- // "Order" does not exist for 6.y versions! Use default.
- aResultMap.put(PROPNAME_ORDER, new java.lang.Integer(0));
-
- // "UIName" property does not exist for 6.y versions! use default.
- /* TODO make it configurable :-) */
- aResultMap.put(PROPNAME_UINAME, aMap.get(PROPNAME_UINAME));
- //aResultMap.put(PROPNAME_UINAME, new java.util.HashMap());
-
- // "Flags" must be converted from names to its values
- java.util.Vector lFlags = (java.util.Vector)aMap.get(PROPNAME_FLAGS);
- java.lang.Integer nFlags = Cache.convertFilterFlagNames2Values(lFlags);
- aResultMap.put(PROPNAME_FLAGS, nFlags);
-
- // copy all direct supported properties
- aResultMap.put(PROPNAME_TYPE , aMap.get(PROPNAME_TYPE ));
- aResultMap.put(PROPNAME_DOCUMENTSERVICE , aMap.get(PROPNAME_DOCUMENTSERVICE ));
- aResultMap.put(PROPNAME_FILTERSERVICE , aMap.get(PROPNAME_ORDER ));
- aResultMap.put(PROPNAME_USERDATA , aMap.get(PROPNAME_USERDATA ));
- aResultMap.put(PROPNAME_FILEFORMATVERSION, aMap.get(PROPNAME_FILEFORMATVERSION));
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list