summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorRelease Engineers <releng@openoffice.org>2008-12-01 13:46:00 +0000
committerRelease Engineers <releng@openoffice.org>2008-12-01 13:46:00 +0000
commitb984adad34332b2bd33ffa15f7a0e458773cd39b (patch)
tree3561bde44a3f6482c7fb8ccf430c9e1e1e6105b5 /framework
parent9d49dd00b8023f12aced72413645d81ef94da02b (diff)
CWS-TOOLING: integrate CWS accelerators01svn
2008-11-26 10:12:06 +0100 as r264354 : #i96383# use new snapshot of accelerator configuration retrieved from latest master 2008-11-21 12:45:17 +0100 as r264125 : handle missing module configurations right (create them on demand) 2008-11-21 11:37:37 +0100 as r264117 : #i96383# add missing shortcuts for writer 2008-11-03 10:46:17 +0100 as r263280 : fix warning regarding unreachable code 2008-10-23 11:07:04 +0200 as r262616 : #i87737# move shortcut configuration to XCU/S based configuration
Diffstat (limited to 'framework')
-rw-r--r--framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java689
-rw-r--r--framework/qa/complex/accelerators/helper/KeyMapping.java171
-rw-r--r--framework/qa/complex/accelerators/helper/makefile.mk50
-rw-r--r--framework/qa/complex/accelerators/makefile.mk90
-rw-r--r--framework/source/accelerators/acceleratorconfiguration.cxx2293
-rw-r--r--framework/source/accelerators/documentacceleratorconfiguration.cxx76
-rw-r--r--framework/source/accelerators/globalacceleratorconfiguration.cxx63
-rw-r--r--framework/source/accelerators/moduleacceleratorconfiguration.cxx54
-rw-r--r--framework/source/inc/accelerators/acceleratorconfiguration.hxx421
-rw-r--r--framework/source/inc/accelerators/documentacceleratorconfiguration.hxx17
-rw-r--r--framework/source/inc/accelerators/globalacceleratorconfiguration.hxx16
-rw-r--r--framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx7
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx4
13 files changed, 3101 insertions, 850 deletions
diff --git a/framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java b/framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java
new file mode 100644
index 0000000000..39936de4cd
--- /dev/null
+++ b/framework/qa/complex/accelerators/AcceleratorsConfigurationTest.java
@@ -0,0 +1,689 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: AcceleratorsConfigurationTest.java,v $
+ * $Revision: 1.1.2.4 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+package complex.accelerators;
+
+// imports
+import com.sun.star.awt.*;
+import com.sun.star.beans.*;
+import com.sun.star.container.*;
+import com.sun.star.embed.*;
+import com.sun.star.lang.*;
+import com.sun.star.ui.*;
+import com.sun.star.uno.*;
+import com.sun.star.util.*;
+
+import complexlib.ComplexTestCase;
+
+import java.lang.*;
+import java.util.*;
+
+import helper.*;
+
+//-----------------------------------------------
+/** @short todo document me
+ */
+public class AcceleratorsConfigurationTest extends ComplexTestCase
+{
+ /** points to the global uno service manager. */
+ private XMultiServiceFactory m_xSmgr = null;
+
+ /** the accelerator configuration for testing. */
+ private XAcceleratorConfiguration m_xGlobalAccelCfg = null;
+ private XAcceleratorConfiguration m_xModuleAccelCfg = null;
+ private XAcceleratorConfiguration m_xDocumentAccelCfg = null;
+
+ /** XCS/XCU based accelerator configuration. */
+ private XNameAccess m_xConfig = null;
+ private XNameAccess m_xPrimaryKeys = null;
+ private XNameAccess m_xSecondaryKeys = null;
+
+ //-------------------------------------------
+ // test environment
+
+ //-----------------------------------------------
+ /** @short todo document me
+ */
+ public String[] getTestMethodNames()
+ {
+ return new String[]
+ {
+ "checkGlobalAccelCfg",
+ "checkModuleAccelCfg",
+ "checkDocumentAccelCfg"
+ };
+ }
+
+ //-----------------------------------------------
+ /** @short Create the environment for following tests.
+ */
+ public void before()
+ throws java.lang.Exception
+ {
+ // get uno service manager from global test environment
+ m_xSmgr = (XMultiServiceFactory)param.getMSF();
+
+ m_xGlobalAccelCfg = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ m_xSmgr.createInstance("com.sun.star.ui.GlobalAcceleratorConfiguration"));
+ m_xModuleAccelCfg = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ m_xSmgr.createInstance("com.sun.star.ui.ModuleAcceleratorConfiguration"));
+ m_xDocumentAccelCfg = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ m_xSmgr.createInstance("com.sun.star.ui.DocumentAcceleratorConfiguration"));
+
+ String sConfigPath = "org.openoffice.Office.Accelerators";
+ boolean bReadOnly = false;
+ XNameAccess m_xConfig = openConfig(m_xSmgr, sConfigPath, bReadOnly);
+ if (m_xConfig != null)
+ {
+ m_xPrimaryKeys = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xConfig.getByName("PrimaryKeys"));
+ m_xSecondaryKeys = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xConfig.getByName("SecondaryKeys"));
+ }
+ }
+
+ //-------------------------------------------
+ /** @short close the environment.
+ */
+ public void after()
+ throws java.lang.Exception
+ {
+ m_xConfig = null;
+ m_xGlobalAccelCfg = null;
+ m_xModuleAccelCfg = null;
+ m_xDocumentAccelCfg = null;
+ m_xSmgr = null;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ public void checkGlobalAccelCfg()
+ throws java.lang.Exception
+ {
+ log.println("\n---- check Global accelerator configuration: ----");
+
+ String[] sKeys;
+ XNameAccess xPrimaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class,m_xPrimaryKeys.getByName("Global"));
+ XNameAccess xSecondaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xSecondaryKeys.getByName("Global"));
+
+ sKeys = new String[] { "A_MOD1" };
+ impl_checkGetKeyCommands(m_xGlobalAccelCfg, xPrimaryAccess, sKeys);
+
+ sKeys = new String[] { "PASTE", "X_SHIFT" };
+ String[] sCommands = new String[] { ".uno:test", ".uno:test" };
+ impl_checkSetKeyCommands(m_xGlobalAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys, sCommands);
+
+ sKeys = new String[] { "C_MOD1", "CUT" };
+ impl_checkRemoveKeyCommands(m_xGlobalAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys);
+
+ String[] sCommandList = new String[] { ".uno:Paste", ".uno:CloseWin" };
+ impl_checkGetPreferredKeyEventsForCommandList(m_xGlobalAccelCfg, xPrimaryAccess, sCommandList);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ public void checkModuleAccelCfg()
+ throws java.lang.Exception
+ {
+ String[] sModules = new String[]
+ {
+ "com.sun.star.frame.StartModule",
+ "com.sun.star.drawing.DrawingDocument",
+ "com.sun.star.presentation.PresentationDocument",
+ "com.sun.star.sheet.SpreadsheetDocument",
+ "com.sun.star.text.TextDocument",
+ // add other modules here
+ };
+
+ for (int i=0; i<sModules.length; ++i)
+ {
+ log.println("\n---- check accelerator configuration depending module: " + sModules[i] + " ----");
+
+ PropertyValue[] aProp = new PropertyValue[2];
+ aProp[0] = new PropertyValue();
+ aProp[0].Name = "ModuleIdentifier";
+ aProp[0].Value = sModules[i];
+ aProp[1] = new PropertyValue();
+ aProp[1].Name = "Locale";
+ aProp[1].Value = "en-US";
+
+ XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(XInitialization.class, m_xModuleAccelCfg);
+ xInit.initialize(aProp); // to fill cache
+
+ XNameAccess xPrimaryModules = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xPrimaryKeys.getByName("Modules"));
+ XNameAccess xSecondaryModules = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, m_xSecondaryKeys.getByName("Modules"));
+
+ String[] sKeys;
+ XNameAccess xPrimaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xPrimaryModules.getByName(sModules[i]));
+ XNameAccess xSecondaryAccess = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xSecondaryModules.getByName(sModules[i]));
+
+ //--------------------------------------------
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ sKeys = new String[] { "A_SHIFT_MOD1_MOD2" };
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ sKeys = new String[] { "B_MOD1" };
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ sKeys = new String[] { "F11_MOD1" };
+ else
+ sKeys = new String[] { "A_MOD1" };
+ impl_checkGetKeyCommands(m_xModuleAccelCfg, xPrimaryAccess, sKeys);
+
+ //--------------------------------------------
+ String[] sCommands;
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ {
+ sKeys = new String[] { "A_SHIFT_MOD1_MOD2" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ {
+ sKeys = new String[] { "B_MOD1" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ {
+ sKeys = new String[] { "F11_MOD1" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ else
+ {
+ sKeys = new String[] { "PASTE" };
+ sCommands = new String[] { ".uno:test" };
+ }
+ impl_checkSetKeyCommands(m_xModuleAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys, sCommands);
+
+ //--------------------------------------------
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ sKeys = new String[] { "A_SHIFT_MOD1_MOD2" };
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ sKeys = new String[] { "F5_SHIFT_MOD1" };
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ sKeys = new String[] { "BACKSPACE_MOD2" };
+ else
+ sKeys = new String[] { "C_MOD1" };
+ impl_checkRemoveKeyCommands(m_xModuleAccelCfg, xPrimaryAccess, xSecondaryAccess, sKeys);
+
+ //--------------------------------------------
+ String[] sCommandList;
+ if (sModules[i].equals("com.sun.star.presentation.PresentationDocument"))
+ sCommandList = new String[] { ".uno:Presentation" };
+ else if (sModules[i].equals("com.sun.star.sheet.SpreadsheetDocument"))
+ sCommandList = new String[] { ".uno:InsertCell" };
+ else if (sModules[i].equals("com.sun.star.text.TextDocument"))
+ sCommandList = new String[] { ".uno:SelectionModeBlock" };
+ else
+ sCommandList = new String[] { ".uno:Cut" };
+ impl_checkGetPreferredKeyEventsForCommandList(m_xModuleAccelCfg, xPrimaryAccess, sCommandList);
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ public void checkDocumentAccelCfg()
+ throws java.lang.Exception
+ {
+ log.println("\n---- check Document accelerator configuration: ----");
+
+ String sDocCfgName;
+
+ sDocCfgName = "file:///c:/test.cfg";
+ SaveDocumentAcceleratorConfiguration(sDocCfgName);
+
+ sDocCfgName = "file:///c:/test.cfg";
+ LoadDocumentAcceleratorConfiguration(sDocCfgName);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkGetKeyCommands(XAcceleratorConfiguration xAccelCfg, XNameAccess xAccess, String[] sKeys)
+ throws java.lang.Exception
+ {
+ log.println("check getKeyCommands...");
+
+ for (int i=0; i<sKeys.length; ++i)
+ {
+ if (xAccess.hasByName(sKeys[i]) && getCommandFromConfiguration(xAccess, sKeys[i]).length()>0)
+ {
+ log.println("** get command by " + sKeys[i] + " **");
+
+ String sCmdFromCache = new String(); // get a value using XAcceleratorConfiguration API
+ String sCmdFromConfiguration = new String(); // get a value using configuration API
+
+ // GET shortcuts/commands using XAcceleratorConfiguration API
+ sCmdFromCache = xAccelCfg.getCommandByKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ log.println(sKeys[i] + "-->" + sCmdFromCache + ", by XAcceleratorConfiguration API");
+
+ // GET shortcuts/commands using configuration API
+ sCmdFromConfiguration = getCommandFromConfiguration(xAccess, sKeys[i]);
+ log.println(sKeys[i] + "-->" + sCmdFromConfiguration + ", by configuration API");
+
+ assure("values are different by XAcceleratorConfiguration API and configuration API!", sCmdFromCache.equals(sCmdFromConfiguration));
+
+ String sLocale = "es";
+ setOfficeLocale(sLocale);
+ sCmdFromConfiguration = getCommandFromConfiguration(xAccess, sKeys[i]);
+ log.println(sKeys[i] + "-->" + sCmdFromConfiguration + ", by configuration API" + " for locale:"+ getOfficeLocale());
+
+ sLocale = "en-US";
+ setOfficeLocale(sLocale); //reset to default locale
+ }
+ else
+ {
+ log.println(sKeys[i] + " doesn't exist!");
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkSetKeyCommands(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, XNameAccess xSecondaryAccess, String[] sKeys, String[] sCommands)
+ throws java.lang.Exception
+ {
+ log.println("check setKeyCommands...");
+
+ for (int i=0; i<sKeys.length; ++i)
+ {
+ if (!xPrimaryAccess.hasByName(sKeys[i]) && !xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.setKeyEvent(convertShortcut2AWTKey(sKeys[i]), sCommands[i]);
+ xAccelCfg.store();
+ if (xPrimaryAccess.hasByName(sKeys[i]))
+ log.println("add " + sKeys[i] + " successfully!");
+ else
+ log.println("add " + sKeys[i] + " failed!");
+ }
+ else if (xPrimaryAccess.hasByName(sKeys[i]))
+ {
+ String sOriginalCommand = getCommandFromConfiguration(xPrimaryAccess, sKeys[i]);
+ if (!sCommands[i].equals(sOriginalCommand))
+ {
+ xAccelCfg.setKeyEvent(convertShortcut2AWTKey(sKeys[i]), sCommands[i]);
+ xAccelCfg.store();
+
+ String sChangedCommand = getCommandFromConfiguration(xPrimaryAccess, sKeys[i]);
+ if (sCommands[i].equals(sChangedCommand))
+ log.println("change " + sKeys[i] + " successfully!");
+ else
+ log.println("change " + sKeys[i] + " failed!");
+ }
+ else
+ log.println(sKeys[i] + " already exist!");
+ }
+ else if (xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ String sOriginalCommand = getCommandFromConfiguration(xSecondaryAccess, sKeys[i]);
+ if (!sCommands[i].equals(sOriginalCommand))
+ {
+ xAccelCfg.setKeyEvent(convertShortcut2AWTKey(sKeys[i]), sCommands[i]);
+ xAccelCfg.store();
+
+ String sChangedCommand = getCommandFromConfiguration(xPrimaryAccess, sKeys[i]);
+ if (sCommands[i].equals(sChangedCommand))
+ log.println("change " + sKeys[i] + " successfully!");
+ else
+ log.println("change " + sKeys[i] + " failed!");
+ }
+ else
+ log.println(sKeys[i] + " already exist!");
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkRemoveKeyCommands(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, XNameAccess xSecondaryAccess, String[] sKeys)
+ throws java.lang.Exception
+ {
+ log.println("check removeKeyCommands...");
+
+ for (int i=0; i<sKeys.length; i++)
+ {
+ if (!xPrimaryAccess.hasByName(sKeys[i]) && !xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ log.println(sKeys[i] + " doesn't exist!");
+ }
+ else if (xPrimaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.removeKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ xAccelCfg.store();
+ if (!xPrimaryAccess.hasByName(sKeys[i]))
+ log.println("Remove " + sKeys[i] + " successfully!");
+ else
+ log.println("Remove " + sKeys[i] + " failed!");
+ }
+ else if (xSecondaryAccess.hasByName(sKeys[i]))
+ {
+ xAccelCfg.removeKeyEvent(convertShortcut2AWTKey(sKeys[i]));
+ xAccelCfg.store();
+ if (!xSecondaryAccess.hasByName(sKeys[i]))
+ log.println("Remove " + sKeys[i] + " successfully!");
+ else
+ log.println("Remove " + sKeys[i] + " failed!");
+ }
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void impl_checkGetPreferredKeyEventsForCommandList(XAcceleratorConfiguration xAccelCfg, XNameAccess xPrimaryAccess, String[] sCommandList)
+ throws java.lang.Exception
+ {
+ log.println("check getPreferredKeyEventsForCommandList...");
+
+ Object[] oKeyEvents = xAccelCfg.getPreferredKeyEventsForCommandList(sCommandList);
+ for (int i = 0; i < oKeyEvents.length; i++)
+ {
+ log.println("get preferred key for command "+ sCommandList[i] + ":");
+
+ KeyEvent aKeyEvent = (KeyEvent)AnyConverter.toObject(KeyEvent.class, oKeyEvents[i]);
+ String sKeyEvent = convertAWTKey2Shortcut(aKeyEvent);
+ log.println(sKeyEvent);
+
+ String sCmdFromConfiguration = getCommandFromConfiguration(xPrimaryAccess, sKeyEvent);
+ log.println(sCmdFromConfiguration);
+ if (sCommandList[i].equals(sCmdFromConfiguration))
+ log.println("get preferred key correctly!");
+ else
+ log.println("get preferred key failed!");
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private String getCommandFromConfiguration(XNameAccess xAccess, String sKey)
+ throws java.lang.Exception
+ {
+ String sCommand = new String();
+
+ if (xAccess.hasByName(sKey))
+ {
+ XNameAccess xKey = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xAccess.getByName(sKey));
+ XNameAccess xCommand = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xKey.getByName("Command"));
+
+ String sLocale = getOfficeLocale();
+ if (xCommand.hasByName(sLocale))
+ sCommand = (String)UnoRuntime.queryInterface(String.class, xCommand.getByName(sLocale));
+ }
+
+ return sCommand;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void insertKeyToConfiguration(XNameAccess xAccess, String sKey, String sCommand)
+ throws java.lang.Exception
+ {
+ XNameContainer xContainer = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, xAccess);
+ if (!xContainer.hasByName(sKey))
+ {
+ XSingleServiceFactory xFac = (XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class, xContainer);
+ XInterface xInst = (XInterface)UnoRuntime.queryInterface(XInterface.class, xFac.createInstance());
+ xContainer.insertByName(sKey, xInst);
+ }
+
+ XNameAccess xKey = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xContainer.getByName(sKey));
+ XNameContainer xCommand = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, xKey.getByName("Command"));
+ String sLocale = getOfficeLocale();
+ if (xCommand.hasByName(sLocale))
+ xCommand.insertByName(sLocale, sCommand);
+ else
+ xCommand.replaceByName(sLocale, sCommand);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void removeKeyFromConfiguration(XNameAccess xAccess, String sKey)
+ throws java.lang.Exception
+ {
+ XNameContainer xContainer = (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, xAccess);
+ if (xContainer.hasByName(sKey))
+ xContainer.removeByName(sKey);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void LoadDocumentAcceleratorConfiguration(String sDocCfgName)
+ throws java.lang.Exception
+ {
+ XSingleServiceFactory xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory.class,
+ m_xSmgr.createInstance("com.sun.star.embed.StorageFactory"));
+
+ Object aArgs[] = new Object[2];
+ aArgs[0] = sDocCfgName;
+ aArgs[1] = new Integer(com.sun.star.embed.ElementModes.READ);
+ XStorage xRootStorage = (XStorage)UnoRuntime.queryInterface(
+ XStorage.class,
+ xStorageFactory.createInstanceWithArguments(aArgs));
+
+ XStorage xUIConfig = xRootStorage.openStorageElement("Configurations2", com.sun.star.embed.ElementModes.READ);
+
+ PropertyValue aProp = new PropertyValue();
+ aProp.Name = "DocumentRoot";
+ aProp.Value = xUIConfig;
+ Object[] lArgs = new Object[1];
+ lArgs[0] = aProp;
+
+ XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(XInitialization.class, m_xDocumentAccelCfg);
+ xInit.initialize(lArgs);
+
+ String test = m_xDocumentAccelCfg.getCommandByKeyEvent(convertShortcut2AWTKey("F2"));
+ log.println(test);
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void SaveDocumentAcceleratorConfiguration(String sDocCfgName)
+ throws java.lang.Exception
+ {
+ XSingleServiceFactory xStorageFactory = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory.class,
+ m_xSmgr.createInstance("com.sun.star.embed.StorageFactory"));
+
+ Object aArgs[] = new Object[2];
+ aArgs[0] = sDocCfgName;
+ aArgs[1] = new Integer(com.sun.star.embed.ElementModes.WRITE);
+ XStorage xRootStorage = (XStorage)UnoRuntime.queryInterface(
+ XStorage.class,
+ xStorageFactory.createInstanceWithArguments(aArgs));
+
+ XStorage xUIConfig = xRootStorage.openStorageElement("Configurations2", com.sun.star.embed.ElementModes.WRITE);
+
+ XUIConfigurationManager xCfgMgr = (XUIConfigurationManager)UnoRuntime.queryInterface(
+ XUIConfigurationManager.class,
+ m_xSmgr.createInstance("com.sun.star.ui.UIConfigurationManager"));
+
+ XUIConfigurationStorage xUICfgStore = (XUIConfigurationStorage)UnoRuntime.queryInterface(
+ XUIConfigurationStorage.class,
+ xCfgMgr);
+ xUICfgStore.setStorage(xUIConfig);
+
+ XPropertySet xUIConfigProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xUIConfig);
+ xUIConfigProps.setPropertyValue("MediaType", "application/vnd.sun.xml.ui.configuration");
+
+ if (xCfgMgr != null)
+ {
+ XAcceleratorConfiguration xTargetAccMgr = (XAcceleratorConfiguration)UnoRuntime.queryInterface(
+ XAcceleratorConfiguration.class,
+ xCfgMgr.getShortCutManager());
+ XUIConfigurationPersistence xCommit1 = (XUIConfigurationPersistence)UnoRuntime.queryInterface(
+ XUIConfigurationPersistence.class, xTargetAccMgr);
+ XUIConfigurationPersistence xCommit2 = (XUIConfigurationPersistence)UnoRuntime.queryInterface(
+ XUIConfigurationPersistence.class, xCfgMgr);
+ xCommit1.store();
+ xCommit2.store();
+
+ XTransactedObject xCommit3 = (XTransactedObject)UnoRuntime.queryInterface(
+ XTransactedObject.class, xRootStorage);
+ xCommit3.commit();
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private com.sun.star.awt.KeyEvent convertShortcut2AWTKey(String sShortcut)
+ throws java.lang.Exception
+ {
+ com.sun.star.awt.KeyEvent aKeyEvent = new com.sun.star.awt.KeyEvent();
+ KeyMapping aKeyMapping = new KeyMapping();
+ String[] sShortcutSplits = sShortcut.split("_");
+
+ aKeyEvent.KeyCode = aKeyMapping.mapIdentifier2Code(sShortcutSplits[0]);
+ for (int i = 1; i < sShortcutSplits.length; i++)
+ {
+ if (sShortcutSplits[i].equals("SHIFT"))
+ aKeyEvent.Modifiers |= com.sun.star.awt.KeyModifier.SHIFT;
+ else if (sShortcutSplits[i].equals("MOD1"))
+ aKeyEvent.Modifiers |= com.sun.star.awt.KeyModifier.MOD1;
+ else if (sShortcutSplits[i].equals("MOD2"))
+ aKeyEvent.Modifiers |= com.sun.star.awt.KeyModifier.MOD2;
+ }
+
+ return aKeyEvent;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private String convertAWTKey2Shortcut(com.sun.star.awt.KeyEvent aKeyEvent)
+ throws java.lang.Exception
+ {
+ String sShortcut;
+
+ KeyMapping aKeyMapping = new KeyMapping();
+ sShortcut = aKeyMapping.mapCode2Identifier(aKeyEvent.KeyCode);
+
+ if ((aKeyEvent.Modifiers & com.sun.star.awt.KeyModifier.SHIFT) == com.sun.star.awt.KeyModifier.SHIFT)
+ sShortcut += "_SHIFT";
+ if ((aKeyEvent.Modifiers & com.sun.star.awt.KeyModifier.MOD1) == com.sun.star.awt.KeyModifier.MOD1)
+ sShortcut += "_MOD1";
+ if ((aKeyEvent.Modifiers & com.sun.star.awt.KeyModifier.MOD2) == com.sun.star.awt.KeyModifier.MOD2)
+ sShortcut += "_MOD2";
+
+ return sShortcut;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private String getOfficeLocale()
+ throws java.lang.Exception
+ {
+ String sLocale = new String();
+
+ String sConfigPath = "org.openoffice.Setup";
+ boolean bReadOnly = true;
+ XNameAccess xRootConfig = openConfig(m_xSmgr, sConfigPath, bReadOnly);
+
+ if (xRootConfig != null)
+ {
+ XNameAccess xLocale = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xRootConfig.getByName("L10N"));
+ XPropertySet xSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xLocale);
+ sLocale = (String)xSet.getPropertyValue("ooLocale");
+ }
+
+ return sLocale;
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private void setOfficeLocale(String sLocale)
+ throws java.lang.Exception
+ {
+ String sConfigPath = "org.openoffice.Setup";
+ boolean bReadOnly = false;
+ XNameAccess xRootConfig = openConfig(m_xSmgr, sConfigPath, bReadOnly);
+
+ if (xRootConfig != null)
+ {
+ XNameAccess xLocale = (XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, xRootConfig.getByName("L10N"));
+ XPropertySet xSet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xLocale);
+ xSet.setPropertyValue("ooLocale", sLocale);
+ XChangesBatch xBatch = (XChangesBatch)UnoRuntime.queryInterface(XChangesBatch.class, xRootConfig);
+ xBatch.commitChanges();
+ }
+ }
+
+ //-------------------------------------------
+ /** @todo document me.
+ */
+ private XNameAccess openConfig(XMultiServiceFactory xSMGR,
+ String sConfigPath ,
+ boolean bReadOnly )
+ throws java.lang.Exception
+ {
+ XMultiServiceFactory xConfigRoot = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ xSMGR.createInstance("com.sun.star.configuration.ConfigurationProvider"));
+
+ PropertyValue[] lParams = new PropertyValue[2];
+ lParams[0] = new PropertyValue();
+ lParams[0].Name = "nodepath";
+ lParams[0].Value = sConfigPath;
+
+ lParams[1] = new PropertyValue();
+ lParams[1].Name = "locale";
+ lParams[1].Value = "*";
+
+ Object aConfig;
+ if (bReadOnly)
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationAccess",
+ lParams);
+ else
+ aConfig = xConfigRoot.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ lParams);
+
+ XNameAccess xConfig = (XNameAccess)UnoRuntime.queryInterface(
+ XNameAccess.class,
+ aConfig);
+
+ if (xConfig == null)
+ throw new com.sun.star.uno.Exception("Could not open configuration \"" + sConfigPath + "\"");
+
+ return xConfig;
+ }
+}
diff --git a/framework/qa/complex/accelerators/helper/KeyMapping.java b/framework/qa/complex/accelerators/helper/KeyMapping.java
new file mode 100644
index 0000000000..fd22e05912
--- /dev/null
+++ b/framework/qa/complex/accelerators/helper/KeyMapping.java
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: KeyMapping.java,v $
+ * $Revision: 1.1.2.1 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+package complex.accelerators;
+
+import java.util.HashMap;
+
+class KeyIdentifierInfo
+{
+ protected String sIdentifier;
+ protected Short nCode;
+
+ KeyIdentifierInfo(String sID, Short nC)
+ {
+ sIdentifier = sID;
+ nCode = nC;
+ }
+}
+
+class IdentifierHashMap extends HashMap
+{
+ public void put(String sIdentifier, Short nCode)
+ {
+ super.put(sIdentifier, nCode);
+ }
+ public Short get(String sIdentifier)
+ {
+ return (Short)super.get(sIdentifier);
+ }
+}
+
+class CodeHashMap extends HashMap
+{
+ public void put(Short nCode, String sIdentifier)
+ {
+ super.put(nCode, sIdentifier);
+ }
+ public String get(Short nCode)
+ {
+ return (String)super.get(nCode);
+ }
+}
+
+public class KeyMapping
+{
+ private IdentifierHashMap aIdentifierHashMap;
+ private CodeHashMap aCodeHashMap;
+
+ KeyMapping()
+ {
+ KeyIdentifierInfo[] aInfoMap = {
+ new KeyIdentifierInfo("0", new Short(com.sun.star.awt.Key.NUM0)),
+ new KeyIdentifierInfo("1", new Short(com.sun.star.awt.Key.NUM1)),
+ new KeyIdentifierInfo("2", new Short(com.sun.star.awt.Key.NUM2)),
+ new KeyIdentifierInfo("3", new Short(com.sun.star.awt.Key.NUM3)),
+ new KeyIdentifierInfo("4", new Short(com.sun.star.awt.Key.NUM4)),
+ new KeyIdentifierInfo("5", new Short(com.sun.star.awt.Key.NUM5)),
+ new KeyIdentifierInfo("6", new Short(com.sun.star.awt.Key.NUM6)),
+ new KeyIdentifierInfo("7", new Short(com.sun.star.awt.Key.NUM7)),
+ new KeyIdentifierInfo("8", new Short(com.sun.star.awt.Key.NUM8)),
+ new KeyIdentifierInfo("9", new Short(com.sun.star.awt.Key.NUM9)),
+ new KeyIdentifierInfo("A", new Short(com.sun.star.awt.Key.A)),
+ new KeyIdentifierInfo("B", new Short(com.sun.star.awt.Key.B)),
+ new KeyIdentifierInfo("C", new Short(com.sun.star.awt.Key.C)),
+ new KeyIdentifierInfo("D", new Short(com.sun.star.awt.Key.D)),
+ new KeyIdentifierInfo("E", new Short(com.sun.star.awt.Key.E)),
+ new KeyIdentifierInfo("F", new Short(com.sun.star.awt.Key.F)),
+ new KeyIdentifierInfo("G", new Short(com.sun.star.awt.Key.G)),
+ new KeyIdentifierInfo("H", new Short(com.sun.star.awt.Key.H)),
+ new KeyIdentifierInfo("I", new Short(com.sun.star.awt.Key.I)),
+ new KeyIdentifierInfo("J", new Short(com.sun.star.awt.Key.J)),
+ new KeyIdentifierInfo("K", new Short(com.sun.star.awt.Key.K)),
+ new KeyIdentifierInfo("L", new Short(com.sun.star.awt.Key.L)),
+ new KeyIdentifierInfo("M", new Short(com.sun.star.awt.Key.M)),
+ new KeyIdentifierInfo("N", new Short(com.sun.star.awt.Key.N)),
+ new KeyIdentifierInfo("O", new Short(com.sun.star.awt.Key.O)),
+ new KeyIdentifierInfo("P", new Short(com.sun.star.awt.Key.P)),
+ new KeyIdentifierInfo("Q", new Short(com.sun.star.awt.Key.Q)),
+ new KeyIdentifierInfo("R", new Short(com.sun.star.awt.Key.R)),
+ new KeyIdentifierInfo("S", new Short(com.sun.star.awt.Key.S)),
+ new KeyIdentifierInfo("T", new Short(com.sun.star.awt.Key.T)),
+ new KeyIdentifierInfo("U", new Short(com.sun.star.awt.Key.U)),
+ new KeyIdentifierInfo("V", new Short(com.sun.star.awt.Key.V)),
+ new KeyIdentifierInfo("W", new Short(com.sun.star.awt.Key.W)),
+ new KeyIdentifierInfo("X", new Short(com.sun.star.awt.Key.X)),
+ new KeyIdentifierInfo("Y", new Short(com.sun.star.awt.Key.Y)),
+ new KeyIdentifierInfo("Z", new Short(com.sun.star.awt.Key.Z)),
+ new KeyIdentifierInfo("F1", new Short(com.sun.star.awt.Key.F1)),
+ new KeyIdentifierInfo("F2", new Short(com.sun.star.awt.Key.F2)),
+ new KeyIdentifierInfo("F3", new Short(com.sun.star.awt.Key.F3)),
+ new KeyIdentifierInfo("F4", new Short(com.sun.star.awt.Key.F4)),
+ new KeyIdentifierInfo("F5", new Short(com.sun.star.awt.Key.F5)),
+ new KeyIdentifierInfo("F6", new Short(com.sun.star.awt.Key.F6)),
+ new KeyIdentifierInfo("F7", new Short(com.sun.star.awt.Key.F7)),
+ new KeyIdentifierInfo("F8", new Short(com.sun.star.awt.Key.F8)),
+ new KeyIdentifierInfo("F9", new Short(com.sun.star.awt.Key.F9)),
+ new KeyIdentifierInfo("F10", new Short(com.sun.star.awt.Key.F10)),
+ new KeyIdentifierInfo("F11", new Short(com.sun.star.awt.Key.F11)),
+ new KeyIdentifierInfo("F12", new Short(com.sun.star.awt.Key.F12)),
+ new KeyIdentifierInfo("DOWN", new Short(com.sun.star.awt.Key.DOWN)),
+ new KeyIdentifierInfo("UP", new Short(com.sun.star.awt.Key.UP)),
+ new KeyIdentifierInfo("LEFT", new Short(com.sun.star.awt.Key.LEFT)),
+ new KeyIdentifierInfo("RIGHT", new Short(com.sun.star.awt.Key.RIGHT)),
+ new KeyIdentifierInfo("HOME", new Short(com.sun.star.awt.Key.HOME)),
+ new KeyIdentifierInfo("END", new Short(com.sun.star.awt.Key.END)),
+ new KeyIdentifierInfo("PAGEUP", new Short(com.sun.star.awt.Key.PAGEUP)),
+ new KeyIdentifierInfo("PAGEDOWN", new Short(com.sun.star.awt.Key.PAGEDOWN)),
+ new KeyIdentifierInfo("RETURN", new Short(com.sun.star.awt.Key.RETURN)),
+ new KeyIdentifierInfo("ESCAPE", new Short(com.sun.star.awt.Key.ESCAPE)),
+ new KeyIdentifierInfo("TAB", new Short(com.sun.star.awt.Key.TAB)),
+ new KeyIdentifierInfo("BACKSPACE", new Short(com.sun.star.awt.Key.BACKSPACE)),
+ new KeyIdentifierInfo("SPACE", new Short(com.sun.star.awt.Key.SPACE)),
+ new KeyIdentifierInfo("INSERT", new Short(com.sun.star.awt.Key.INSERT)),
+ new KeyIdentifierInfo("DELETE", new Short(com.sun.star.awt.Key.DELETE)),
+ new KeyIdentifierInfo("ADD", new Short(com.sun.star.awt.Key.ADD)),
+ new KeyIdentifierInfo("SUBTRACT", new Short(com.sun.star.awt.Key.SUBTRACT)),
+ new KeyIdentifierInfo("MULTIPLY", new Short(com.sun.star.awt.Key.MULTIPLY)),
+ new KeyIdentifierInfo("DIVIDE", new Short(com.sun.star.awt.Key.DIVIDE)),
+ new KeyIdentifierInfo("CUT", new Short(com.sun.star.awt.Key.CUT)),
+ new KeyIdentifierInfo("COPY", new Short(com.sun.star.awt.Key.COPY)),
+ new KeyIdentifierInfo("PASTE", new Short(com.sun.star.awt.Key.PASTE)),
+ new KeyIdentifierInfo("UNDO", new Short(com.sun.star.awt.Key.UNDO)),
+ new KeyIdentifierInfo("REPEAT", new Short(com.sun.star.awt.Key.REPEAT))
+ };
+
+ aIdentifierHashMap = new IdentifierHashMap();
+ aCodeHashMap = new CodeHashMap();
+ for (int i = 0; i<aInfoMap.length; i++)
+ {
+ aIdentifierHashMap.put(aInfoMap[i].sIdentifier, aInfoMap[i].nCode);
+ aCodeHashMap.put(aInfoMap[i].nCode, aInfoMap[i].sIdentifier);
+ }
+ }
+
+ public short mapIdentifier2Code(String sIdentifier)
+ {
+ return (aIdentifierHashMap.get(sIdentifier)).shortValue();
+ }
+
+ public String mapCode2Identifier(short nCode)
+ {
+ return (String)aCodeHashMap.get(new Short(nCode));
+ }
+}
diff --git a/framework/qa/complex/accelerators/helper/makefile.mk b/framework/qa/complex/accelerators/helper/makefile.mk
new file mode 100644
index 0000000000..836b5abc88
--- /dev/null
+++ b/framework/qa/complex/accelerators/helper/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.2.1 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..
+TARGET = AcceleratorsConfigurationTest
+PRJNAME = framework
+PACKAGE = complex$/accelerators$/helper
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+ Generator.jar OOoRunner.jar
+JAVAFILES = KeyMapping.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+MAXLINELENGTH = 100000
+
+.INCLUDE : target.mk
diff --git a/framework/qa/complex/accelerators/makefile.mk b/framework/qa/complex/accelerators/makefile.mk
new file mode 100644
index 0000000000..0b84754a2b
--- /dev/null
+++ b/framework/qa/complex/accelerators/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.2.2 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = AcceleratorsConfigurationTest
+PRJNAME = $(TARGET)
+PACKAGE = complex$/accelerators
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar jut.jar java_uno.jar \
+ OOoRunner.jar
+
+JAVAFILES = AcceleratorsConfigurationTest.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+SUBDIRS=helper
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+#.IF "$(depend)" == ""
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLTAR
+#.ELSE
+#$(CLASSDIR)$/$(PACKAGE)$/$(JAVAFILES:b).props : ALLDEP
+#.ENDIF
+
+.INCLUDE : target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index 95f0719562..9c2eaadd40 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -1,629 +1,1664 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: acceleratorconfiguration.cxx,v $
- * $Revision: 1.8 $
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_framework.hxx"
-#include <accelerators/acceleratorconfiguration.hxx>
-
-//_______________________________________________
-// own includes
-#include <pattern/configuration.hxx>
-#include <accelerators/presethandler.hxx>
-
-#ifndef __FRAMEWORK_XML_SAXNAMESPACEFILTER_HXX_
-#include <xml/saxnamespacefilter.hxx>
-#endif
-
-#ifndef __FRAMEWORK_XML_ACCELERATORCONFIGURATIONREADER_HXX_
-#include <xml/acceleratorconfigurationreader.hxx>
-#endif
-
-#ifndef __FRAMEWORK_XML_ACCELERATORCONFIGURATIONWRITER_HXX_
-#include <xml/acceleratorconfigurationwriter.hxx>
-#endif
-#include <threadhelp/readguard.hxx>
-#include <threadhelp/writeguard.hxx>
-
-#ifndef __FRAMEWORK_ACCELERATORCONST_H_
-#include <acceleratorconst.h>
-#endif
-#include <services.h>
-
-//_______________________________________________
-// interface includes
-#include <com/sun/star/xml/sax/XParser.hpp>
-#include <com/sun/star/xml/sax/InputSource.hpp>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/embed/ElementModes.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
-#include <com/sun/star/io/XTruncate.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-
-//_______________________________________________
-// other includes
-#include <vcl/svapp.hxx>
-
-//_______________________________________________
-// const
-
-namespace framework
-{
-
-#ifdef fpc
- #error "Who exports this define? I use it as namespace alias ..."
-#else
- namespace fpc = ::framework::pattern::configuration;
-#endif
-
-//-----------------------------------------------
-// XInterface, XTypeProvider
-DEFINE_XINTERFACE_6(AcceleratorConfiguration ,
- OWeakObject ,
- DIRECT_INTERFACE(css::lang::XTypeProvider ),
- DIRECT_INTERFACE(css::ui::XAcceleratorConfiguration ),
- DIRECT_INTERFACE(css::form::XReset ),
- DIRECT_INTERFACE(css::ui::XUIConfigurationPersistence),
- DIRECT_INTERFACE(css::ui::XUIConfigurationStorage ),
- DIRECT_INTERFACE(css::ui::XUIConfiguration ))
-
-DEFINE_XTYPEPROVIDER_6(AcceleratorConfiguration ,
- css::lang::XTypeProvider ,
- css::ui::XAcceleratorConfiguration ,
- css::form::XReset ,
- css::ui::XUIConfigurationPersistence,
- css::ui::XUIConfigurationStorage ,
- css::ui::XUIConfiguration )
-
-//-----------------------------------------------
-AcceleratorConfiguration::AcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
- : ThreadHelpBase (&Application::GetSolarMutex())
- , m_xSMGR (xSMGR )
- , m_aPresetHandler(xSMGR )
- , m_pWriteCache (0 )
-{
-}
-
-//-----------------------------------------------
-AcceleratorConfiguration::~AcceleratorConfiguration()
-{
- LOG_ASSERT(!m_pWriteCache, "AcceleratorConfiguration::~AcceleratorConfiguration()\nChanges not flushed. Ignore it ...")
-}
-
-//-----------------------------------------------
-css::uno::Sequence< css::awt::KeyEvent > SAL_CALL AcceleratorConfiguration::getAllKeyEvents()
- throw(css::uno::RuntimeException)
-{
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
-
- AcceleratorCache& rCache = impl_getCFG();
- AcceleratorCache::TKeyList lKeys = rCache.getAllKeys();
- return lKeys.getAsConstList();
-
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-::rtl::OUString SAL_CALL AcceleratorConfiguration::getCommandByKeyEvent(const css::awt::KeyEvent& aKeyEvent)
- throw(css::container::NoSuchElementException,
- css::uno::RuntimeException )
-{
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
-
- AcceleratorCache& rCache = impl_getCFG();
- if (!rCache.hasKey(aKeyEvent))
- throw css::container::NoSuchElementException(
- ::rtl::OUString(),
- static_cast< ::cppu::OWeakObject* >(this));
- return rCache.getCommandByKey(aKeyEvent);
-
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::setKeyEvent(const css::awt::KeyEvent& aKeyEvent,
- const ::rtl::OUString& sCommand )
- throw(css::lang::IllegalArgumentException,
- css::uno::RuntimeException )
-{
- if (
- (aKeyEvent.KeyCode == 0) &&
- (aKeyEvent.KeyChar == 0) &&
- (aKeyEvent.KeyFunc == 0) &&
- (aKeyEvent.Modifiers == 0)
- )
- throw css::lang::IllegalArgumentException(
- ::rtl::OUString::createFromAscii("Such key event seams not to be supported by any operating system."),
- static_cast< ::cppu::OWeakObject* >(this),
- 0);
-
- if (!sCommand.getLength())
- throw css::lang::IllegalArgumentException(
- ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
- static_cast< ::cppu::OWeakObject* >(this),
- 1);
-
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
-
- AcceleratorCache& rCache = impl_getCFG(sal_True); // TRUE => force getting of a writeable cache!
- rCache.setKeyCommandPair(aKeyEvent, sCommand);
-
- aWriteLock.unlock();
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::removeKeyEvent(const css::awt::KeyEvent& aKeyEvent)
- throw(css::container::NoSuchElementException,
- css::uno::RuntimeException )
-{
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
-
- AcceleratorCache& rCache = impl_getCFG(sal_True); // true => force using of a writeable cache
- if (!rCache.hasKey(aKeyEvent))
- throw css::container::NoSuchElementException(
- ::rtl::OUString(),
- static_cast< ::cppu::OWeakObject* >(this));
- rCache.removeKey(aKeyEvent);
-
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-css::uno::Sequence< css::awt::KeyEvent > SAL_CALL AcceleratorConfiguration::getKeyEventsByCommand(const ::rtl::OUString& sCommand)
- throw(css::lang::IllegalArgumentException ,
- css::container::NoSuchElementException,
- css::uno::RuntimeException )
-{
- if (!sCommand.getLength())
- throw css::lang::IllegalArgumentException(
- ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
- static_cast< ::cppu::OWeakObject* >(this),
- 1);
-
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
-
- AcceleratorCache& rCache = impl_getCFG();
- if (!rCache.hasCommand(sCommand))
- throw css::container::NoSuchElementException(
- ::rtl::OUString(),
- static_cast< ::cppu::OWeakObject* >(this));
-
- AcceleratorCache::TKeyList lKeys = rCache.getKeysByCommand(sCommand);
- return lKeys.getAsConstList();
-
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-css::uno::Sequence< css::uno::Any > SAL_CALL AcceleratorConfiguration::getPreferredKeyEventsForCommandList(const css::uno::Sequence< ::rtl::OUString >& lCommandList)
- throw(css::lang::IllegalArgumentException ,
- css::uno::RuntimeException )
-{
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
-
- sal_Int32 i = 0;
- sal_Int32 c = lCommandList.getLength();
- css::uno::Sequence< css::uno::Any > lPreferredOnes (c); // dont pack list!
- AcceleratorCache& rCache = impl_getCFG();
-
- for (i=0; i<c; ++i)
- {
- const ::rtl::OUString& rCommand = lCommandList[i];
- if (!rCommand.getLength())
- throw css::lang::IllegalArgumentException(
- ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
- static_cast< ::cppu::OWeakObject* >(this),
- (sal_Int16)i);
-
- if (!rCache.hasCommand(rCommand))
- continue;
-
- AcceleratorCache::TKeyList lKeys = rCache.getKeysByCommand(rCommand);
- if (lKeys.size()<1)
- continue;
-
- css::uno::Any& rAny = lPreferredOnes[i];
- rAny <<= *(lKeys.begin());
- }
-
- aReadLock.unlock();
- // <- SAFE ----------------------------------
-
- return lPreferredOnes;
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::removeCommandFromAllKeyEvents(const ::rtl::OUString& sCommand)
- throw(css::lang::IllegalArgumentException ,
- css::container::NoSuchElementException,
- css::uno::RuntimeException )
-{
- if (!sCommand.getLength())
- throw css::lang::IllegalArgumentException(
- ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
- static_cast< ::cppu::OWeakObject* >(this),
- 0);
-
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
-
- AcceleratorCache& rCache = impl_getCFG(sal_True); // TRUE => force getting of a writeable cache!
- if (!rCache.hasCommand(sCommand))
- throw css::container::NoSuchElementException(
- ::rtl::OUString::createFromAscii("Command does not exists inside this container."),
- static_cast< ::cppu::OWeakObject* >(this));
- rCache.removeCommand(sCommand);
-
- aWriteLock.unlock();
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::reload()
- throw(css::uno::Exception ,
- css::uno::RuntimeException)
-{
- css::uno::Reference< css::io::XStream > xStreamNoLang;
-
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
- css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // TRUE => open or create!
- try
- {
- xStreamNoLang = m_aPresetHandler.openPreset(PresetHandler::PRESET_DEFAULT(), sal_True);
- }
- catch(const css::io::IOException&) {} // does not have to exist
- aReadLock.unlock();
- // <- SAFE ----------------------------------
-
- css::uno::Reference< css::io::XInputStream > xIn;
- if (xStream.is())
- xIn = xStream->getInputStream();
- if (!xIn.is())
- throw css::io::IOException(
- ::rtl::OUString::createFromAscii("Could not open accelerator configuration for reading."),
- static_cast< ::cppu::OWeakObject* >(this));
-
- // impl_ts_load() does not clear the cache
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
- m_aReadCache = AcceleratorCache();
- aWriteLock.unlock();
- // <- SAFE ----------------------------------
-
- impl_ts_load(xIn);
-
- // Load also the general language independent default accelerators
- // (ignoring the already defined accelerators)
- if (xStreamNoLang.is())
- {
- xIn = xStreamNoLang->getInputStream();
- if (xIn.is())
- impl_ts_load(xIn);
- }
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::store()
- throw(css::uno::Exception ,
- css::uno::RuntimeException)
-{
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
- css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // TRUE => open or create!
- aReadLock.unlock();
- // <- SAFE ----------------------------------
-
- css::uno::Reference< css::io::XOutputStream > xOut;
- if (xStream.is())
- xOut = xStream->getOutputStream();
-
- if (!xOut.is())
- throw css::io::IOException(
- ::rtl::OUString::createFromAscii("Could not open accelerator configuration for saving."),
- static_cast< ::cppu::OWeakObject* >(this));
-
- impl_ts_save(xOut);
-
- xOut.clear();
- xStream.clear();
-
- m_aPresetHandler.commitUserChanges();
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::storeToStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
- throw(css::uno::Exception ,
- css::uno::RuntimeException)
-{
- css::uno::Reference< css::io::XStream > xStream = StorageHolder::openSubStreamWithFallback(
- xStorage,
- PresetHandler::TARGET_CURRENT(),
- css::embed::ElementModes::READWRITE,
- sal_False); // False => no fallback from read/write to readonly!
- css::uno::Reference< css::io::XOutputStream > xOut;
- if (xStream.is())
- xOut = xStream->getOutputStream();
-
- if (!xOut.is())
- throw css::io::IOException(
- ::rtl::OUString::createFromAscii("Could not open accelerator configuration for saving."),
- static_cast< ::cppu::OWeakObject* >(this));
-
- impl_ts_save(xOut);
-
- // TODO inform listener about success, so it can flush the root and sub storage of this stream!
-}
-
-//-----------------------------------------------
-::sal_Bool SAL_CALL AcceleratorConfiguration::isModified()
- throw(css::uno::RuntimeException)
-{
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
- return (m_pWriteCache != 0);
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-::sal_Bool SAL_CALL AcceleratorConfiguration::isReadOnly()
- throw(css::uno::RuntimeException)
-{
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
- css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // TRUE => open or create!
- aReadLock.unlock();
- // <- SAFE ----------------------------------
-
- css::uno::Reference< css::io::XOutputStream > xOut;
- if (xStream.is())
- xOut = xStream->getOutputStream();
- return !(xOut.is());
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::setStorage(const css::uno::Reference< css::embed::XStorage >& /*xStorage*/)
- throw(css::uno::RuntimeException)
-{
- LOG_WARNING("AcceleratorConfiguration::setStorage()", "TODO implement this HACK .-)")
-}
-
-//-----------------------------------------------
-::sal_Bool SAL_CALL AcceleratorConfiguration::hasStorage()
- throw(css::uno::RuntimeException)
-{
- LOG_WARNING("AcceleratorConfiguration::hasStorage()", "TODO implement this HACK .-)")
- return sal_False;
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& /*xListener*/)
- throw(css::uno::RuntimeException)
-{
- LOG_WARNING("AcceleratorConfiguration::addConfigurationListener()", "TODO implement me")
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& /*xListener*/)
- throw(css::uno::RuntimeException)
-{
- LOG_WARNING("AcceleratorConfiguration::removeConfigurationListener()", "TODO implement me")
-}
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::reset()
- throw(css::uno::RuntimeException)
-{
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
- m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
- aWriteLock.unlock();
- // <- SAFE ----------------------------------
-
- reload();
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::addResetListener(const css::uno::Reference< css::form::XResetListener >& /*xListener*/)
- throw(css::uno::RuntimeException)
-{
- LOG_WARNING("AcceleratorConfiguration::addResetListener()", "TODO implement me")
-}
-
-//-----------------------------------------------
-void SAL_CALL AcceleratorConfiguration::removeResetListener(const css::uno::Reference< css::form::XResetListener >& /*xListener*/)
- throw(css::uno::RuntimeException)
-{
- LOG_WARNING("AcceleratorConfiguration::removeResetListener()", "TODO implement me")
-}
-
-//-----------------------------------------------
-// IStorageListener
-void AcceleratorConfiguration::changesOccured(const ::rtl::OUString& /*sPath*/)
-{
- reload();
-}
-
-//-----------------------------------------------
-void AcceleratorConfiguration::impl_ts_load(const css::uno::Reference< css::io::XInputStream >& xStream)
-{
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
-
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
- if (m_pWriteCache)
- {
- // be aware of reentrance problems - use temp variable for calling delete ... :-)
- AcceleratorCache* pTemp = m_pWriteCache;
- m_pWriteCache = 0;
- delete pTemp;
- }
-
- aWriteLock.unlock();
- // <- SAFE ----------------------------------
-
- css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY);
- if (xSeek.is())
- xSeek->seek(0);
-
- // add accelerators to the cache (the cache is not cleared)
- // SAFE -> ----------------------------------
- aWriteLock.lock();
-
- // create the parser queue
- // Note: Use special filter object between parser and reader
- // to get filtered xml with right namespaces ...
- // Use further a temp cache for reading!
- AcceleratorConfigurationReader* pReader = new AcceleratorConfigurationReader(m_aReadCache);
- css::uno::Reference< css::xml::sax::XDocumentHandler > xReader (static_cast< ::cppu::OWeakObject* >(pReader), css::uno::UNO_QUERY_THROW);
- SaxNamespaceFilter* pFilter = new SaxNamespaceFilter(xReader);
- css::uno::Reference< css::xml::sax::XDocumentHandler > xFilter (static_cast< ::cppu::OWeakObject* >(pFilter), css::uno::UNO_QUERY_THROW);
-
- // connect parser, filter and stream
- css::uno::Reference< css::xml::sax::XParser > xParser(xSMGR->createInstance(SERVICENAME_SAXPARSER), css::uno::UNO_QUERY_THROW);
- xParser->setDocumentHandler(xFilter);
-
- css::xml::sax::InputSource aSource;
- aSource.aInputStream = xStream;
-
- // TODO think about error handling
- xParser->parseStream(aSource);
-
- aWriteLock.unlock();
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-void AcceleratorConfiguration::impl_ts_save(const css::uno::Reference< css::io::XOutputStream >& xStream)
-{
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
-
- AcceleratorCache aCache;
- sal_Bool bChanged = (m_pWriteCache != 0);
- if (bChanged)
- aCache.takeOver(*m_pWriteCache);
- else
- aCache.takeOver(m_aReadCache);
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
-
- aReadLock.unlock();
- // <- SAFE ----------------------------------
-
- css::uno::Reference< css::io::XTruncate > xClearable(xStream, css::uno::UNO_QUERY_THROW);
- xClearable->truncate();
-
- // TODO can be removed if seek(0) is done by truncate() automaticly!
- css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY);
- if (xSeek.is())
- xSeek->seek(0);
-
- // combine writer/cache/stream etcpp.
- css::uno::Reference< css::xml::sax::XDocumentHandler > xWriter (xSMGR->createInstance(SERVICENAME_SAXWRITER), css::uno::UNO_QUERY_THROW);
- css::uno::Reference< css::io::XActiveDataSource> xDataSource(xWriter , css::uno::UNO_QUERY_THROW);
- xDataSource->setOutputStream(xStream);
-
- // write into the stream
- AcceleratorConfigurationWriter aWriter(aCache, xWriter);
- aWriter.flush();
-
- // take over all changes into the original container
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
-
- // take over all changes into the readonly cache ...
- // and forget the copy-on-write copied cache
- if (bChanged)
- {
- m_aReadCache.takeOver(*m_pWriteCache);
- // live with reentrance .-)
- AcceleratorCache* pTemp = m_pWriteCache;
- m_pWriteCache = 0;
- delete pTemp;
- }
-
- aWriteLock.unlock();
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-AcceleratorCache& AcceleratorConfiguration::impl_getCFG(sal_Bool bWriteAccessRequested)
-{
- // SAFE -> ----------------------------------
- WriteGuard aWriteLock(m_aLock);
-
- // create copy of our readonly-cache, if write access is forced ... but
- // not still possible!
- if (
- (bWriteAccessRequested) &&
- (!m_pWriteCache )
- )
- {
- m_pWriteCache = new AcceleratorCache(m_aReadCache);
- }
-
- // in case, we have a writeable cache, we use it for reading too!
- // Otherwhise the API user cant find its own changes ...
- if (m_pWriteCache)
- return *m_pWriteCache;
- else
- return m_aReadCache;
- // <- SAFE ----------------------------------
-}
-
-//-----------------------------------------------
-::comphelper::Locale AcceleratorConfiguration::impl_ts_getLocale() const
-{
- static ::rtl::OUString LOCALE_PACKAGE = ::rtl::OUString::createFromAscii("/org.openoffice.Setup");
- static ::rtl::OUString LOCALE_PATH = ::rtl::OUString::createFromAscii("L10N" );
- static ::rtl::OUString LOCALE_KEY = ::rtl::OUString::createFromAscii("ooLocale" );
-
- // SAFE -> ----------------------------------
- ReadGuard aReadLock(m_aLock);
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
- aReadLock.unlock();
- // <- SAFE ----------------------------------
-
- css::uno::Reference< css::uno::XInterface > xCFG = fpc::ConfigurationHelper::openConfig(xSMGR, LOCALE_PACKAGE, LOCALE_PATH, fpc::ConfigurationHelper::E_READONLY);
- css::uno::Reference< css::beans::XPropertySet > xProp (xCFG, css::uno::UNO_QUERY_THROW);
- ::rtl::OUString sISOLocale;
- xProp->getPropertyValue(LOCALE_KEY) >>= sISOLocale;
-
- if (!sISOLocale.getLength())
- return ::comphelper::Locale::EN_US();
- return ::comphelper::Locale(sISOLocale);
-}
-
-} // namespace framework
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: acceleratorconfiguration.cxx,v $
+ * $Revision: 1.7.204.12 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_framework.hxx"
+#include <accelerators/acceleratorconfiguration.hxx>
+
+//_______________________________________________
+// own includes
+#include <pattern/configuration.hxx>
+#include <accelerators/presethandler.hxx>
+
+#include <xml/saxnamespacefilter.hxx>
+#include <xml/acceleratorconfigurationreader.hxx>
+#include <xml/acceleratorconfigurationwriter.hxx>
+
+#include <threadhelp/readguard.hxx>
+#include <threadhelp/writeguard.hxx>
+
+#include <acceleratorconst.h>
+#include <services.h>
+
+//_______________________________________________
+// interface includes
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+//_______________________________________________
+// other includes
+#include <vcl/svapp.hxx>
+
+#ifndef __FRAMEWORK_ACCELERATORS_KEYMAPPING_HXX_
+#include <accelerators/keymapping.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMED_HPP_
+#include <com/sun/star/container/XNamed.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
+#include <com/sun/star/container/XNameContainer.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_AWT_KEYEVENT_HPP_
+#include <com/sun/star/awt/KeyEvent.hpp>
+#endif
+
+#ifndef __COM_SUN_STAR_AWT_KEYMODIFIER_HPP_
+#include <com/sun/star/awt/KeyModifier.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_UTIL_XCHANGESNOTIFIER_HPP_
+#include <com/sun/star/util/XChangesNotifier.hpp>
+#endif
+
+#ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_
+#include <comphelper/configurationhelper.hxx>
+#endif
+
+#ifndef UNOTOOLS_CONFIGPATHES_HXX_INCLUDED
+#include <unotools/configpathes.hxx>
+#endif
+
+#ifndef _RTL_LOGFILE_HXX_
+#include <rtl/logfile.hxx>
+#endif
+
+#include <svtools/acceleratorexecute.hxx>
+
+//_______________________________________________
+// const
+
+namespace framework
+{
+
+#ifdef fpc
+ #error "Who exports this define? I use it as namespace alias ..."
+#else
+ namespace fpc = ::framework::pattern::configuration;
+#endif
+
+//-----------------------------------------------
+// XInterface, XTypeProvider
+DEFINE_XINTERFACE_6(XMLBasedAcceleratorConfiguration ,
+ OWeakObject ,
+ DIRECT_INTERFACE(css::lang::XTypeProvider ),
+ DIRECT_INTERFACE(css::ui::XAcceleratorConfiguration ),
+ DIRECT_INTERFACE(css::form::XReset ),
+ DIRECT_INTERFACE(css::ui::XUIConfigurationPersistence),
+ DIRECT_INTERFACE(css::ui::XUIConfigurationStorage ),
+ DIRECT_INTERFACE(css::ui::XUIConfiguration ))
+
+DEFINE_XTYPEPROVIDER_6(XMLBasedAcceleratorConfiguration ,
+ css::lang::XTypeProvider ,
+ css::ui::XAcceleratorConfiguration ,
+ css::form::XReset ,
+ css::ui::XUIConfigurationPersistence,
+ css::ui::XUIConfigurationStorage ,
+ css::ui::XUIConfiguration )
+
+//-----------------------------------------------
+XMLBasedAcceleratorConfiguration::XMLBasedAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
+ : ThreadHelpBase (&Application::GetSolarMutex())
+ , m_xSMGR (xSMGR )
+ , m_aPresetHandler(xSMGR )
+ , m_pWriteCache (0 )
+{
+}
+
+//-----------------------------------------------
+XMLBasedAcceleratorConfiguration::~XMLBasedAcceleratorConfiguration()
+{
+ LOG_ASSERT(!m_pWriteCache, "XMLBasedAcceleratorConfiguration::~XMLBasedAcceleratorConfiguration()\nChanges not flushed. Ignore it ...")
+}
+
+//-----------------------------------------------
+css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XMLBasedAcceleratorConfiguration::getAllKeyEvents()
+ throw(css::uno::RuntimeException)
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ AcceleratorCache& rCache = impl_getCFG();
+ AcceleratorCache::TKeyList lKeys = rCache.getAllKeys();
+ return lKeys.getAsConstList();
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+::rtl::OUString SAL_CALL XMLBasedAcceleratorConfiguration::getCommandByKeyEvent(const css::awt::KeyEvent& aKeyEvent)
+ throw(css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ AcceleratorCache& rCache = impl_getCFG();
+ if (!rCache.hasKey(aKeyEvent))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString(),
+ static_cast< ::cppu::OWeakObject* >(this));
+ return rCache.getCommandByKey(aKeyEvent);
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::setKeyEvent(const css::awt::KeyEvent& aKeyEvent,
+ const ::rtl::OUString& sCommand )
+ throw(css::lang::IllegalArgumentException,
+ css::uno::RuntimeException )
+{
+ if (
+ (aKeyEvent.KeyCode == 0) &&
+ (aKeyEvent.KeyChar == 0) &&
+ (aKeyEvent.KeyFunc == 0) &&
+ (aKeyEvent.Modifiers == 0)
+ )
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Such key event seams not to be supported by any operating system."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 0);
+
+ if (!sCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 1);
+
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ AcceleratorCache& rCache = impl_getCFG(sal_True); // TRUE => force getting of a writeable cache!
+ rCache.setKeyCommandPair(aKeyEvent, sCommand);
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::removeKeyEvent(const css::awt::KeyEvent& aKeyEvent)
+throw(css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ AcceleratorCache& rCache = impl_getCFG(sal_True); // true => force using of a writeable cache
+ if (!rCache.hasKey(aKeyEvent))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString(),
+ static_cast< ::cppu::OWeakObject* >(this));
+ rCache.removeKey(aKeyEvent);
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XMLBasedAcceleratorConfiguration::getKeyEventsByCommand(const ::rtl::OUString& sCommand)
+ throw(css::lang::IllegalArgumentException ,
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ if (!sCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 1);
+
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ AcceleratorCache& rCache = impl_getCFG();
+ if (!rCache.hasCommand(sCommand))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString(),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ AcceleratorCache::TKeyList lKeys = rCache.getKeysByCommand(sCommand);
+ return lKeys.getAsConstList();
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+css::uno::Sequence< css::uno::Any > SAL_CALL XMLBasedAcceleratorConfiguration::getPreferredKeyEventsForCommandList(const css::uno::Sequence< ::rtl::OUString >& lCommandList)
+ throw(css::lang::IllegalArgumentException ,
+ css::uno::RuntimeException )
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ sal_Int32 i = 0;
+ sal_Int32 c = lCommandList.getLength();
+ css::uno::Sequence< css::uno::Any > lPreferredOnes (c); // dont pack list!
+ AcceleratorCache& rCache = impl_getCFG();
+
+ for (i=0; i<c; ++i)
+ {
+ const ::rtl::OUString& rCommand = lCommandList[i];
+ if (!rCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ (sal_Int16)i);
+
+ if (!rCache.hasCommand(rCommand))
+ continue;
+
+ AcceleratorCache::TKeyList lKeys = rCache.getKeysByCommand(rCommand);
+ if (lKeys.size()<1)
+ continue;
+
+ css::uno::Any& rAny = lPreferredOnes[i];
+ rAny <<= *(lKeys.begin());
+ }
+
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ return lPreferredOnes;
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::removeCommandFromAllKeyEvents(const ::rtl::OUString& sCommand)
+ throw(css::lang::IllegalArgumentException ,
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ if (!sCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 0);
+
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ AcceleratorCache& rCache = impl_getCFG(sal_True); // TRUE => force getting of a writeable cache!
+ if (!rCache.hasCommand(sCommand))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString::createFromAscii("Command does not exists inside this container."),
+ static_cast< ::cppu::OWeakObject* >(this));
+ rCache.removeCommand(sCommand);
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::reload()
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException)
+{
+ css::uno::Reference< css::io::XStream > xStreamNoLang;
+
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+ css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // TRUE => open or create!
+ try
+ {
+ xStreamNoLang = m_aPresetHandler.openPreset(PresetHandler::PRESET_DEFAULT(), sal_True);
+ }
+ catch(const css::io::IOException&) {} // does not have to exist
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::io::XInputStream > xIn;
+ if (xStream.is())
+ xIn = xStream->getInputStream();
+ if (!xIn.is())
+ throw css::io::IOException(
+ ::rtl::OUString::createFromAscii("Could not open accelerator configuration for reading."),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ // impl_ts_load() does not clear the cache
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+ m_aReadCache = AcceleratorCache();
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+
+ impl_ts_load(xIn);
+
+ // Load also the general language independent default accelerators
+ // (ignoring the already defined accelerators)
+ if (xStreamNoLang.is())
+ {
+ xIn = xStreamNoLang->getInputStream();
+ if (xIn.is())
+ impl_ts_load(xIn);
+ }
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::store()
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException)
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+ css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // TRUE => open or create!
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::io::XOutputStream > xOut;
+ if (xStream.is())
+ xOut = xStream->getOutputStream();
+
+ if (!xOut.is())
+ throw css::io::IOException(
+ ::rtl::OUString::createFromAscii("Could not open accelerator configuration for saving."),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ impl_ts_save(xOut);
+
+ xOut.clear();
+ xStream.clear();
+
+ m_aPresetHandler.commitUserChanges();
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::storeToStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException)
+{
+ css::uno::Reference< css::io::XStream > xStream = StorageHolder::openSubStreamWithFallback(
+ xStorage,
+ PresetHandler::TARGET_CURRENT(),
+ css::embed::ElementModes::READWRITE,
+ sal_False); // False => no fallback from read/write to readonly!
+ css::uno::Reference< css::io::XOutputStream > xOut;
+ if (xStream.is())
+ xOut = xStream->getOutputStream();
+
+ if (!xOut.is())
+ throw css::io::IOException(
+ ::rtl::OUString::createFromAscii("Could not open accelerator configuration for saving."),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ impl_ts_save(xOut);
+
+ // TODO inform listener about success, so it can flush the root and sub storage of this stream!
+}
+
+//-----------------------------------------------
+::sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::isModified()
+ throw(css::uno::RuntimeException)
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+ return (m_pWriteCache != 0);
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+::sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::isReadOnly()
+ throw(css::uno::RuntimeException)
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+ css::uno::Reference< css::io::XStream > xStream = m_aPresetHandler.openTarget(PresetHandler::TARGET_CURRENT(), sal_True); // TRUE => open or create!
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::io::XOutputStream > xOut;
+ if (xStream.is())
+ xOut = xStream->getOutputStream();
+ return !(xOut.is());
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::setStorage(const css::uno::Reference< css::embed::XStorage >& /*xStorage*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XMLBasedAcceleratorConfiguration::setStorage()", "TODO implement this HACK .-)")
+}
+
+//-----------------------------------------------
+::sal_Bool SAL_CALL XMLBasedAcceleratorConfiguration::hasStorage()
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XMLBasedAcceleratorConfiguration::hasStorage()", "TODO implement this HACK .-)")
+ return sal_False;
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XMLBasedAcceleratorConfiguration::addConfigurationListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XMLBasedAcceleratorConfiguration::removeConfigurationListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::reset()
+throw(css::uno::RuntimeException)
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+ m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+
+ reload();
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::addResetListener(const css::uno::Reference< css::form::XResetListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XMLBasedAcceleratorConfiguration::addResetListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+void SAL_CALL XMLBasedAcceleratorConfiguration::removeResetListener(const css::uno::Reference< css::form::XResetListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XMLBasedAcceleratorConfiguration::removeResetListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+// IStorageListener
+void XMLBasedAcceleratorConfiguration::changesOccured(const ::rtl::OUString& /*sPath*/)
+{
+ reload();
+}
+
+//-----------------------------------------------
+void XMLBasedAcceleratorConfiguration::impl_ts_load(const css::uno::Reference< css::io::XInputStream >& xStream)
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
+ if (m_pWriteCache)
+ {
+ // be aware of reentrance problems - use temp variable for calling delete ... :-)
+ AcceleratorCache* pTemp = m_pWriteCache;
+ m_pWriteCache = 0;
+ delete pTemp;
+ }
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY);
+ if (xSeek.is())
+ xSeek->seek(0);
+
+ // add accelerators to the cache (the cache is not cleared)
+ // SAFE -> ----------------------------------
+ aWriteLock.lock();
+
+ // create the parser queue
+ // Note: Use special filter object between parser and reader
+ // to get filtered xml with right namespaces ...
+ // Use further a temp cache for reading!
+ AcceleratorConfigurationReader* pReader = new AcceleratorConfigurationReader(m_aReadCache);
+ css::uno::Reference< css::xml::sax::XDocumentHandler > xReader (static_cast< ::cppu::OWeakObject* >(pReader), css::uno::UNO_QUERY_THROW);
+ SaxNamespaceFilter* pFilter = new SaxNamespaceFilter(xReader);
+ css::uno::Reference< css::xml::sax::XDocumentHandler > xFilter (static_cast< ::cppu::OWeakObject* >(pFilter), css::uno::UNO_QUERY_THROW);
+
+ // connect parser, filter and stream
+ css::uno::Reference< css::xml::sax::XParser > xParser(xSMGR->createInstance(SERVICENAME_SAXPARSER), css::uno::UNO_QUERY_THROW);
+ xParser->setDocumentHandler(xFilter);
+
+ css::xml::sax::InputSource aSource;
+ aSource.aInputStream = xStream;
+
+ // TODO think about error handling
+ xParser->parseStream(aSource);
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+void XMLBasedAcceleratorConfiguration::impl_ts_save(const css::uno::Reference< css::io::XOutputStream >& xStream)
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ AcceleratorCache aCache;
+ sal_Bool bChanged = (m_pWriteCache != 0);
+ if (bChanged)
+ aCache.takeOver(*m_pWriteCache);
+ else
+ aCache.takeOver(m_aReadCache);
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
+
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::io::XTruncate > xClearable(xStream, css::uno::UNO_QUERY_THROW);
+ xClearable->truncate();
+
+ // TODO can be removed if seek(0) is done by truncate() automaticly!
+ css::uno::Reference< css::io::XSeekable > xSeek(xStream, css::uno::UNO_QUERY);
+ if (xSeek.is())
+ xSeek->seek(0);
+
+ // combine writer/cache/stream etcpp.
+ css::uno::Reference< css::xml::sax::XDocumentHandler > xWriter (xSMGR->createInstance(SERVICENAME_SAXWRITER), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::io::XActiveDataSource> xDataSource(xWriter , css::uno::UNO_QUERY_THROW);
+ xDataSource->setOutputStream(xStream);
+
+ // write into the stream
+ AcceleratorConfigurationWriter aWriter(aCache, xWriter);
+ aWriter.flush();
+
+ // take over all changes into the original container
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ // take over all changes into the readonly cache ...
+ // and forget the copy-on-write copied cache
+ if (bChanged)
+ {
+ m_aReadCache.takeOver(*m_pWriteCache);
+ // live with reentrance .-)
+ AcceleratorCache* pTemp = m_pWriteCache;
+ m_pWriteCache = 0;
+ delete pTemp;
+ }
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteAccessRequested)
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ //create copy of our readonly-cache, if write access is forced ... but
+ //not still possible!
+ if (
+ (bWriteAccessRequested) &&
+ (!m_pWriteCache )
+ )
+ {
+ m_pWriteCache = new AcceleratorCache(m_aReadCache);
+ }
+
+ // in case, we have a writeable cache, we use it for reading too!
+ // Otherwhise the API user cant find its own changes ...
+ if (m_pWriteCache)
+ return *m_pWriteCache;
+ else
+ return m_aReadCache;
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+::comphelper::Locale XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
+{
+ static ::rtl::OUString LOCALE_PACKAGE = ::rtl::OUString::createFromAscii("/org.openoffice.Setup");
+ static ::rtl::OUString LOCALE_PATH = ::rtl::OUString::createFromAscii("L10N" );
+ static ::rtl::OUString LOCALE_KEY = ::rtl::OUString::createFromAscii("ooLocale" );
+
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::uno::XInterface > xCFG = fpc::ConfigurationHelper::openConfig(xSMGR, LOCALE_PACKAGE, LOCALE_PATH, fpc::ConfigurationHelper::E_READONLY);
+ css::uno::Reference< css::beans::XPropertySet > xProp (xCFG, css::uno::UNO_QUERY_THROW);
+ ::rtl::OUString sISOLocale;
+ xProp->getPropertyValue(LOCALE_KEY) >>= sISOLocale;
+
+ if (!sISOLocale.getLength())
+ return ::comphelper::Locale::EN_US();
+ return ::comphelper::Locale(sISOLocale);
+}
+
+/*******************************************************************************
+*
+* XCU based accelerator configuration
+*
+*******************************************************************************/
+
+//-----------------------------------------------
+// XInterface, XTypeProvider
+DEFINE_XINTERFACE_7(XCUBasedAcceleratorConfiguration ,
+ OWeakObject ,
+ DIRECT_INTERFACE(css::lang::XTypeProvider ),
+ DIRECT_INTERFACE(css::ui::XAcceleratorConfiguration ),
+ DIRECT_INTERFACE(css::util::XChangesListener ),
+ DIRECT_INTERFACE(css::form::XReset ),
+ DIRECT_INTERFACE(css::ui::XUIConfigurationPersistence),
+ DIRECT_INTERFACE(css::ui::XUIConfigurationStorage ),
+ DIRECT_INTERFACE(css::ui::XUIConfiguration ))
+
+ DEFINE_XTYPEPROVIDER_7(XCUBasedAcceleratorConfiguration ,
+ css::lang::XTypeProvider ,
+ css::ui::XAcceleratorConfiguration ,
+ css::util::XChangesListener ,
+ css::form::XReset ,
+ css::ui::XUIConfigurationPersistence,
+ css::ui::XUIConfigurationStorage ,
+ css::ui::XUIConfiguration )
+
+//-----------------------------------------------
+XCUBasedAcceleratorConfiguration::XCUBasedAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
+ : ThreadHelpBase (&Application::GetSolarMutex())
+ , m_xSMGR (xSMGR )
+ , m_pPrimaryWriteCache(0 )
+ , m_pSecondaryWriteCache(0 )
+{
+ m_xCfg = css::uno::Reference< css::container::XNameAccess > (
+ ::comphelper::ConfigurationHelper::openConfig( m_xSMGR, CFG_ENTRY_ACCELERATORS, ::comphelper::ConfigurationHelper::E_ALL_LOCALES ),
+ css::uno::UNO_QUERY );
+}
+
+//-----------------------------------------------
+XCUBasedAcceleratorConfiguration::~XCUBasedAcceleratorConfiguration()
+{
+}
+
+//-----------------------------------------------
+css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XCUBasedAcceleratorConfiguration::getAllKeyEvents()
+ throw(css::uno::RuntimeException)
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ AcceleratorCache::TKeyList lKeys = impl_getCFG(sal_True).getAllKeys(); //get keys from PrimaryKeys set
+
+ AcceleratorCache::TKeyList lSecondaryKeys = impl_getCFG(sal_False).getAllKeys(); //get keys from SecondaryKeys set
+ AcceleratorCache::TKeyList::const_iterator pIt;
+ for ( pIt = lSecondaryKeys.begin(); pIt != lSecondaryKeys.end(); ++pIt )
+ lKeys.push_back(*pIt);
+
+ return lKeys.getAsConstList();
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+::rtl::OUString SAL_CALL XCUBasedAcceleratorConfiguration::getCommandByKeyEvent(const css::awt::KeyEvent& aKeyEvent)
+ throw(css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ AcceleratorCache& rPrimaryCache = impl_getCFG(sal_True );
+ AcceleratorCache& rSecondaryCache = impl_getCFG(sal_False);
+
+ if (!rPrimaryCache.hasKey(aKeyEvent) && !rSecondaryCache.hasKey(aKeyEvent))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString(),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ if (rPrimaryCache.hasKey(aKeyEvent))
+ return rPrimaryCache.getCommandByKey(aKeyEvent);
+ else
+ return rSecondaryCache.getCommandByKey(aKeyEvent);
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::setKeyEvent(const css::awt::KeyEvent& aKeyEvent,
+ const ::rtl::OUString& sCommand )
+ throw(css::lang::IllegalArgumentException,
+ css::uno::RuntimeException )
+{
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog1, " start XCUBasedAcceleratorConfiguration::setKeyEvent" );
+
+ if (
+ (aKeyEvent.KeyCode == 0) &&
+ (aKeyEvent.KeyChar == 0) &&
+ (aKeyEvent.KeyFunc == 0) &&
+ (aKeyEvent.Modifiers == 0)
+ )
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Such key event seams not to be supported by any operating system."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 0);
+
+ if (!sCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 1);
+
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ AcceleratorCache& rPrimaryCache = impl_getCFG(sal_True, sal_True ); // TRUE => force getting of a writeable cache!
+ AcceleratorCache& rSecondaryCache = impl_getCFG(sal_False, sal_True); // TRUE => force getting of a writeable cache!
+
+ if ( rPrimaryCache.hasKey(aKeyEvent) )
+ {
+ ::rtl::OUString sOriginalCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
+ if ( sCommand != sOriginalCommand )
+ {
+ if (rSecondaryCache.hasCommand(sOriginalCommand))
+ {
+ AcceleratorCache::TKeyList lSecondaryKeys = rSecondaryCache.getKeysByCommand(sOriginalCommand);
+ rSecondaryCache.removeKey(lSecondaryKeys[0]);
+ rPrimaryCache.setKeyCommandPair(lSecondaryKeys[0], sOriginalCommand);
+ }
+
+ if (rPrimaryCache.hasCommand(sCommand))
+ {
+ AcceleratorCache::TKeyList lPrimaryKeys = rPrimaryCache.getKeysByCommand(sCommand);
+ rPrimaryCache.removeKey(lPrimaryKeys[0]);
+ rSecondaryCache.setKeyCommandPair(lPrimaryKeys[0], sCommand);
+ }
+
+ rPrimaryCache.setKeyCommandPair(aKeyEvent, sCommand);
+ }
+ }
+
+ else if ( rSecondaryCache.hasKey(aKeyEvent) )
+ {
+ ::rtl::OUString sOriginalCommand = rSecondaryCache.getCommandByKey(aKeyEvent);
+ if (sCommand != sOriginalCommand)
+ {
+ if (rPrimaryCache.hasCommand(sCommand))
+ {
+ AcceleratorCache::TKeyList lPrimaryKeys = rPrimaryCache.getKeysByCommand(sCommand);
+ rPrimaryCache.removeKey(lPrimaryKeys[0]);
+ rSecondaryCache.setKeyCommandPair(lPrimaryKeys[0], sCommand);
+ }
+
+ rSecondaryCache.removeKey(aKeyEvent);
+ rPrimaryCache.setKeyCommandPair(aKeyEvent, sCommand);
+ }
+ }
+
+ else
+ {
+ if (rPrimaryCache.hasCommand(sCommand))
+ {
+ AcceleratorCache::TKeyList lPrimaryKeys = rPrimaryCache.getKeysByCommand(sCommand);
+ rPrimaryCache.removeKey(lPrimaryKeys[0]);
+ rSecondaryCache.setKeyCommandPair(lPrimaryKeys[0], sCommand);
+ }
+
+ rPrimaryCache.setKeyCommandPair(aKeyEvent, sCommand);
+ }
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, " end XCUBasedAcceleratorConfiguration::setKeyEvent" );
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::removeKeyEvent(const css::awt::KeyEvent& aKeyEvent)
+ throw(css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ AcceleratorCache& rPrimaryCache = impl_getCFG(sal_True, sal_True );
+ AcceleratorCache& rSecondaryCache = impl_getCFG(sal_False, sal_True);
+
+ if (!rPrimaryCache.hasKey(aKeyEvent) && !rSecondaryCache.hasKey(aKeyEvent))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString(),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ if (rPrimaryCache.hasKey(aKeyEvent))
+ {
+ ::rtl::OUString sDelCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
+ if (sDelCommand.getLength() > 0)
+ {
+ ::rtl::OUString sOriginalCommand = rPrimaryCache.getCommandByKey(aKeyEvent);
+ if (rSecondaryCache.hasCommand(sOriginalCommand))
+ {
+ AcceleratorCache::TKeyList lSecondaryKeys = rSecondaryCache.getKeysByCommand(sOriginalCommand);
+ rSecondaryCache.removeKey(lSecondaryKeys[0]);
+ rPrimaryCache.setKeyCommandPair(lSecondaryKeys[0], sOriginalCommand);
+ }
+
+ rPrimaryCache.removeKey(aKeyEvent);
+ }
+
+ }
+ else
+ {
+ ::rtl::OUString sDelCommand = rSecondaryCache.getCommandByKey(aKeyEvent);
+ if (sDelCommand.getLength() > 0)
+ rSecondaryCache.removeKey(aKeyEvent);
+ }
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+css::uno::Sequence< css::awt::KeyEvent > SAL_CALL XCUBasedAcceleratorConfiguration::getKeyEventsByCommand(const ::rtl::OUString& sCommand)
+ throw(css::lang::IllegalArgumentException ,
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ if (!sCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 1);
+
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ AcceleratorCache& rPrimaryCache = impl_getCFG(sal_True );
+ AcceleratorCache& rSecondaryCache = impl_getCFG(sal_False);
+
+ if (!rPrimaryCache.hasCommand(sCommand) && !rSecondaryCache.hasCommand(sCommand))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString(),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ AcceleratorCache::TKeyList lKeys = rPrimaryCache.getKeysByCommand(sCommand);
+
+ AcceleratorCache::TKeyList lSecondaryKeys = rSecondaryCache.getKeysByCommand(sCommand);
+ AcceleratorCache::TKeyList::const_iterator pIt;
+ for (pIt = lSecondaryKeys.begin(); pIt != lSecondaryKeys.end(); ++pIt)
+ lKeys.push_back(*pIt);
+
+ return lKeys.getAsConstList();
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+AcceleratorCache::TKeyList::const_iterator lcl_getPreferredKey(const AcceleratorCache::TKeyList& lKeys)
+{
+ AcceleratorCache::TKeyList::const_iterator pIt;
+ for ( pIt = lKeys.begin ();
+ pIt != lKeys.end ();
+ ++pIt )
+ {
+ const css::awt::KeyEvent& rAWTKey = *pIt;
+ const KeyCode aVCLKey = ::svt::AcceleratorExecute::st_AWTKey2VCLKey(rAWTKey);
+ const String sName = aVCLKey.GetName();
+
+ if (sName.Len () > 0)
+ return pIt;
+ }
+
+ return lKeys.end ();
+}
+
+//-----------------------------------------------
+css::uno::Sequence< css::uno::Any > SAL_CALL XCUBasedAcceleratorConfiguration::getPreferredKeyEventsForCommandList(const css::uno::Sequence< ::rtl::OUString >& lCommandList)
+ throw(css::lang::IllegalArgumentException ,
+ css::uno::RuntimeException )
+{
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ sal_Int32 i = 0;
+ sal_Int32 c = lCommandList.getLength();
+ css::uno::Sequence< css::uno::Any > lPreferredOnes (c); // dont pack list!
+ AcceleratorCache& rCache = impl_getCFG(sal_True);
+
+ for (i=0; i<c; ++i)
+ {
+ const ::rtl::OUString& rCommand = lCommandList[i];
+ if (!rCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ (sal_Int16)i);
+
+ if (!rCache.hasCommand(rCommand))
+ continue;
+
+ AcceleratorCache::TKeyList lKeys = rCache.getKeysByCommand(rCommand);
+ if (lKeys.size()<1)
+ continue;
+
+ AcceleratorCache::TKeyList::const_iterator pPreferredKey = lcl_getPreferredKey(lKeys);
+ if (pPreferredKey != lKeys.end ())
+ {
+ css::uno::Any& rAny = lPreferredOnes[i];
+ rAny <<= *(pPreferredKey);
+ }
+ }
+
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ return lPreferredOnes;
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::removeCommandFromAllKeyEvents(const ::rtl::OUString& sCommand)
+ throw(css::lang::IllegalArgumentException ,
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException )
+{
+ if (!sCommand.getLength())
+ throw css::lang::IllegalArgumentException(
+ ::rtl::OUString::createFromAscii("Empty command strings are not allowed here."),
+ static_cast< ::cppu::OWeakObject* >(this),
+ 0);
+
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ AcceleratorCache& rPrimaryCache = impl_getCFG(sal_True, sal_True );
+ AcceleratorCache& rSecondaryCache = impl_getCFG(sal_False, sal_True);
+
+ if (!rPrimaryCache.hasCommand(sCommand) && !rSecondaryCache.hasCommand(sCommand))
+ throw css::container::NoSuchElementException(
+ ::rtl::OUString::createFromAscii("Command does not exists inside this container."),
+ static_cast< ::cppu::OWeakObject* >(this));
+
+ if (rPrimaryCache.hasCommand(sCommand))
+ rPrimaryCache.removeCommand(sCommand);
+ if (rSecondaryCache.hasCommand(sCommand))
+ rSecondaryCache.removeCommand(sCommand);
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::reload()
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException)
+{
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog1, " start XCUBasedAcceleratorConfiguration::reload()" );
+
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ sal_Bool bPreferred;
+ css::uno::Reference< css::container::XNameAccess > xAccess;
+
+ bPreferred = sal_True;
+ m_aPrimaryReadCache = AcceleratorCache();
+ if (m_pPrimaryWriteCache)
+ {
+ // be aware of reentrance problems - use temp variable for calling delete ... :-)
+ AcceleratorCache* pTemp = m_pPrimaryWriteCache;
+ m_pPrimaryWriteCache = 0;
+ delete pTemp;
+ }
+ m_xCfg->getByName(CFG_ENTRY_PRIMARY) >>= xAccess;
+ impl_ts_load(bPreferred, xAccess); // load the preferred keys
+
+ bPreferred = sal_False;
+ m_aSecondaryReadCache = AcceleratorCache();
+ if (m_pSecondaryWriteCache)
+ {
+ // be aware of reentrance problems - use temp variable for calling delete ... :-)
+ AcceleratorCache* pTemp = m_pSecondaryWriteCache;
+ m_pSecondaryWriteCache = 0;
+ delete pTemp;
+ }
+ m_xCfg->getByName(CFG_ENTRY_SECONDARY) >>= xAccess;
+ impl_ts_load(bPreferred, xAccess); // load the secondary keys
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, " end XCUBasedAcceleratorConfiguration::reload()" );
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::store()
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException)
+{
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog1, " start XCUBasedAcceleratorConfiguration::store()" );
+
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+
+ sal_Bool bPreferred;
+ css::uno::Reference< css::container::XNameAccess > xAccess;
+
+ bPreferred = sal_True;
+ m_xCfg->getByName(CFG_ENTRY_PRIMARY) >>= xAccess;
+ impl_ts_save(bPreferred, xAccess);
+
+ bPreferred = sal_False;
+ m_xCfg->getByName(CFG_ENTRY_SECONDARY) >>= xAccess;
+ impl_ts_save(bPreferred, xAccess);
+
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, " end XCUBasedAcceleratorConfiguration::store()" );
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::storeToStorage(const css::uno::Reference< css::embed::XStorage >& /*xStorage*/)
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException)
+{
+ // todo implement me
+ // use m_aCache + old AcceleratorXMLWriter to store data directly on storage given as parameter ...
+}
+
+//-----------------------------------------------
+::sal_Bool SAL_CALL XCUBasedAcceleratorConfiguration::isModified()
+ throw(css::uno::RuntimeException)
+{
+ return sal_False;
+}
+
+//-----------------------------------------------
+::sal_Bool SAL_CALL XCUBasedAcceleratorConfiguration::isReadOnly()
+ throw(css::uno::RuntimeException)
+{
+ return sal_False;
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::setStorage(const css::uno::Reference< css::embed::XStorage >& /*xStorage*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XCUBasedAcceleratorConfiguration::setStorage()", "TODO implement this HACK .-)")
+}
+
+//-----------------------------------------------
+::sal_Bool SAL_CALL XCUBasedAcceleratorConfiguration::hasStorage()
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XCUBasedAcceleratorConfiguration::hasStorage()", "TODO implement this HACK .-)")
+ return sal_False;
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XCUBasedAcceleratorConfiguration::addConfigurationListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XCUBasedAcceleratorConfiguration::removeConfigurationListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::reset()
+ throw(css::uno::RuntimeException)
+{
+ css::uno::Reference< css::container::XNamed > xNamed(m_xCfg, css::uno::UNO_QUERY);
+ ::rtl::OUString sConfig = xNamed->getName();
+ if ( sConfig.equalsAscii("Global") )
+ {
+ m_xCfg = css::uno::Reference< css::container::XNameAccess > (
+ ::comphelper::ConfigurationHelper::openConfig( m_xSMGR, CFG_ENTRY_GLOBAL, ::comphelper::ConfigurationHelper::E_ALL_LOCALES ),
+ css::uno::UNO_QUERY );
+ XCUBasedAcceleratorConfiguration::reload();
+ }
+ else if ( sConfig.equalsAscii("Modules") )
+ {
+ m_xCfg = css::uno::Reference< css::container::XNameAccess > (
+ ::comphelper::ConfigurationHelper::openConfig( m_xSMGR, CFG_ENTRY_MODULES, ::comphelper::ConfigurationHelper::E_ALL_LOCALES ),
+ css::uno::UNO_QUERY );
+ XCUBasedAcceleratorConfiguration::reload();
+ }
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::addResetListener(const css::uno::Reference< css::form::XResetListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XCUBasedAcceleratorConfiguration::addResetListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::removeResetListener(const css::uno::Reference< css::form::XResetListener >& /*xListener*/)
+ throw(css::uno::RuntimeException)
+{
+ LOG_WARNING("XCUBasedAcceleratorConfiguration::removeResetListener()", "TODO implement me")
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::changesOccurred(const css::util::ChangesEvent& aEvent)
+ throw(css::uno::RuntimeException)
+{
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog1, " start XCUBasedAcceleratorConfiguration::changesOccurred()" );
+
+ css::uno::Reference< css::container::XHierarchicalNameAccess > xHAccess;
+ aEvent.Base >>= xHAccess;
+ if (! xHAccess.is ())
+ return;
+
+ const sal_Int32 c = aEvent.Changes.getLength();
+ sal_Int32 i = 0;
+
+ for (i=0; i<c; ++i)
+ {
+ const css::util::ElementChange& aChange = aEvent.Changes[i];
+
+ // Only path of form "PrimaryKeys/Modules/Module['<module_name>']/Key['<command_url>']/Command[<locale>]" will
+ // be interesting for use. Sometimes short path values are given also by the broadcaster ... but they must be ignored :-)
+ // So we try to split the path into 3 parts (module isnt important here, because we already know it ... because
+ // these instance is bound to a specific module configuration ... or it''s the global configuration where no module is given at all.
+
+ ::rtl::OUString sOrgPath ;
+ ::rtl::OUString sPath ;
+ ::rtl::OUString sKey;
+
+ aChange.Accessor >>= sOrgPath;
+ sPath = sOrgPath;
+ ::rtl::OUString sPrimarySecondary = ::utl::extractFirstFromConfigurationPath(sPath);
+ sPath = ::utl::dropPrefixFromConfigurationPath(sPath, sPrimarySecondary);
+
+ ::rtl::OUString sGlobalModules = ::utl::extractFirstFromConfigurationPath(sPath);
+ sPath = ::utl::dropPrefixFromConfigurationPath(sPath, sGlobalModules);
+
+ if ( sGlobalModules.equals(CFG_ENTRY_GLOBAL) )
+ {
+ ::rtl::OUString sModule;
+ sKey = ::utl::extractFirstFromConfigurationPath(sPath);
+ reloadChanged(sPrimarySecondary, sGlobalModules, sModule, sKey);
+ }
+ else if ( sGlobalModules.equals(CFG_ENTRY_MODULES) )
+ {
+ ::rtl::OUString sModule = ::utl::extractFirstFromConfigurationPath(sPath);
+ ::rtl::OUString sDropModule = ::rtl::OUString::createFromAscii("Module['") + sModule + ::rtl::OUString::createFromAscii("']");
+ sPath = ::utl::dropPrefixFromConfigurationPath(sPath, sDropModule);
+ sKey = ::utl::extractFirstFromConfigurationPath(sPath);
+ reloadChanged(sPrimarySecondary, sGlobalModules, sModule, sKey);
+ }
+ }
+
+ RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, " end XCUBasedAcceleratorConfiguration::changesOccurred()" );
+}
+
+//-----------------------------------------------
+void SAL_CALL XCUBasedAcceleratorConfiguration::disposing(const css::lang::EventObject& /*aSource*/)
+ throw(css::uno::RuntimeException)
+{
+}
+
+//-----------------------------------------------
+void XCUBasedAcceleratorConfiguration::impl_ts_load( sal_Bool bPreferred, const css::uno::Reference< css::container::XNameAccess >& xCfg )
+{
+ AcceleratorCache aReadCache = AcceleratorCache();
+ css::uno::Reference< css::container::XNameAccess > xAccess;
+ if (m_sGlobalOrModules.equalsAscii("Global"))
+ xCfg->getByName(CFG_ENTRY_GLOBAL) >>= xAccess;
+ else if (m_sGlobalOrModules.equalsAscii("Modules"))
+ {
+ css::uno::Reference< css::container::XNameAccess > xModules;
+ xCfg->getByName(CFG_ENTRY_MODULES) >>= xModules;
+ xModules->getByName(m_sModuleCFG) >>= xAccess;
+ }
+
+ css::uno::Reference< css::container::XNameAccess > xKey;
+ css::uno::Reference< css::container::XNameAccess > xCommand;
+ if (xAccess.is())
+ {
+ css::uno::Sequence< ::rtl::OUString > lKeys = xAccess->getElementNames();
+ sal_Int32 nKeys = lKeys.getLength();
+ for ( sal_Int32 i=0; i<nKeys; ++i )
+ {
+ ::rtl::OUString sKey = lKeys[i];
+ xAccess->getByName(sKey) >>= xKey;
+ xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
+
+ css::uno::Sequence< ::rtl::OUString > lLocales = xCommand->getElementNames();
+ sal_Int32 nLocales = lLocales.getLength();
+ ::std::vector< ::rtl::OUString > aLocales;
+ for ( sal_Int32 j=0; j<nLocales; ++j )
+ aLocales.push_back(lLocales[j]);
+
+ ::std::vector< ::rtl::OUString >::const_iterator pFound;
+ for ( pFound = aLocales.begin(); pFound != aLocales.end(); ++pFound )
+ {
+ if ( *pFound == impl_ts_getLocale().toISO() )
+ break;
+ }
+
+ if ( pFound == aLocales.end() )
+ {
+ ::rtl::OUString sDefaultLocale = ::rtl::OUString::createFromAscii("en-US");
+ for ( pFound = aLocales.begin(); pFound != aLocales.end(); ++pFound )
+ {
+ if ( *pFound == sDefaultLocale )
+ break;
+ }
+
+ if ( pFound == aLocales.end() )
+ continue;
+ }
+
+ ::rtl::OUString sLocale = *pFound;
+ ::rtl::OUString sCommand;
+ xCommand->getByName(sLocale) >>= sCommand;
+ if (sCommand.getLength()<1)
+ continue;
+
+ KeyMapping aKeyMapping;
+ css::awt::KeyEvent aKeyEvent;
+
+ sal_Int32 nIndex = 0;
+ ::rtl::OUString sKeyCommand = sKey.getToken(0, '_', nIndex);
+ ::rtl::OUString sPrefix = ::rtl::OUString::createFromAscii("KEY_");
+ aKeyEvent.KeyCode = aKeyMapping.mapIdentifierToCode(sPrefix + sKeyCommand);
+
+ css::uno::Sequence< ::rtl::OUString > sToken(4);
+ const sal_Int32 nToken = 4;
+ sal_Bool bValid = sal_True;
+ sal_Int32 k;
+ for (k=0; k<nToken; ++k)
+ {
+ if (nIndex < 0)
+ break;
+
+ sToken[k] = sKey.getToken(0, '_', nIndex);
+ ::rtl::OUString sTest = sToken[k];
+ if (sToken[k].getLength() < 1)
+ {
+ bValid = sal_False;
+ break;
+ }
+
+ if (sToken[k].equalsAscii("SHIFT"))
+ aKeyEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
+ else if (sToken[k].equalsAscii("MOD1"))
+ aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD1;
+ else if (sToken[k].equalsAscii("MOD2"))
+ aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD2;
+ else
+ {
+ bValid = sal_False;
+ break;
+ }
+ }
+
+ if ( !aReadCache.hasKey(aKeyEvent) && bValid && k<nToken)
+ aReadCache.setKeyCommandPair(aKeyEvent, sCommand);
+ }
+ }
+
+ if (bPreferred)
+ m_aPrimaryReadCache.takeOver(aReadCache);
+ else
+ m_aSecondaryReadCache.takeOver(aReadCache);
+}
+
+//-----------------------------------------------
+void XCUBasedAcceleratorConfiguration::impl_ts_save(sal_Bool bPreferred, const css::uno::Reference< css::container::XNameAccess >& /*xCfg*/)
+{
+ if (bPreferred)
+ {
+ AcceleratorCache::TKeyList::const_iterator pIt;
+ AcceleratorCache::TKeyList lPrimaryReadKeys = m_aPrimaryReadCache.getAllKeys();
+ AcceleratorCache::TKeyList lPrimaryWriteKeys = m_pPrimaryWriteCache->getAllKeys();
+
+ for ( pIt = lPrimaryReadKeys.begin(); pIt != lPrimaryReadKeys.end(); ++pIt )
+ {
+ if (!m_pPrimaryWriteCache->hasKey(*pIt))
+ removeKeyFromConfiguration(*pIt, sal_True);
+ }
+
+ for ( pIt = lPrimaryWriteKeys.begin(); pIt != lPrimaryWriteKeys.end(); ++pIt )
+ {
+ ::rtl::OUString sCommand = m_pPrimaryWriteCache->getCommandByKey(*pIt);
+ if (!m_aPrimaryReadCache.hasKey(*pIt))
+ {
+ insertKeyToConfiguration(*pIt, sCommand, sal_True);
+ }
+ else
+ {
+ ::rtl::OUString sReadCommand = m_aPrimaryReadCache.getCommandByKey(*pIt);
+ if (sReadCommand != sCommand)
+ insertKeyToConfiguration(*pIt, sCommand, sal_True);
+ }
+ }
+
+ // take over all changes into the original container
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ if (m_pPrimaryWriteCache)
+ {
+ m_aPrimaryReadCache.takeOver(*m_pPrimaryWriteCache);
+ AcceleratorCache* pTemp = m_pPrimaryWriteCache;
+ m_pPrimaryWriteCache = 0;
+ delete pTemp;
+ }
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+ }
+
+ else
+ {
+ AcceleratorCache::TKeyList::const_iterator pIt;
+ AcceleratorCache::TKeyList lSecondaryReadKeys = m_aSecondaryReadCache.getAllKeys();
+ AcceleratorCache::TKeyList lSecondaryWriteKeys = m_pSecondaryWriteCache->getAllKeys();
+
+ for ( pIt = lSecondaryReadKeys.begin(); pIt != lSecondaryReadKeys.end(); ++pIt)
+ {
+ if (!m_pSecondaryWriteCache->hasKey(*pIt))
+ removeKeyFromConfiguration(*pIt, sal_False);
+ }
+
+
+ for ( pIt = lSecondaryWriteKeys.begin(); pIt != lSecondaryWriteKeys.end(); ++pIt )
+ {
+ ::rtl::OUString sCommand = m_pSecondaryWriteCache->getCommandByKey(*pIt);
+ if (!m_aSecondaryReadCache.hasKey(*pIt))
+ {
+ insertKeyToConfiguration(*pIt, sCommand, sal_False);
+ }
+ else
+ {
+ ::rtl::OUString sReadCommand = m_aSecondaryReadCache.getCommandByKey(*pIt);
+ if (sReadCommand != sCommand)
+ insertKeyToConfiguration(*pIt, sCommand, sal_False);
+ }
+ }
+
+ // take over all changes into the original container
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ if (m_pSecondaryWriteCache)
+ {
+ m_aSecondaryReadCache.takeOver(*m_pSecondaryWriteCache);
+ AcceleratorCache* pTemp = m_pSecondaryWriteCache;
+ m_pSecondaryWriteCache = 0;
+ delete pTemp;
+ }
+
+ aWriteLock.unlock();
+ // <- SAFE ----------------------------------
+ }
+
+ ::comphelper::ConfigurationHelper::flush(m_xCfg);
+}
+
+//-----------------------------------------------
+void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt::KeyEvent& aKeyEvent, const ::rtl::OUString& sCommand, const sal_Bool bPreferred )
+{
+ css::uno::Reference< css::container::XNameAccess > xAccess;
+ css::uno::Reference< css::container::XNameContainer > xContainer;
+ css::uno::Reference< css::lang::XSingleServiceFactory > xFac;
+ css::uno::Reference< css::uno::XInterface > xInst;
+
+ if ( bPreferred )
+ m_xCfg->getByName(CFG_ENTRY_PRIMARY) >>= xAccess;
+ else
+ m_xCfg->getByName(CFG_ENTRY_SECONDARY) >>= xAccess;
+
+ if ( m_sGlobalOrModules.equals(CFG_ENTRY_GLOBAL) )
+ xAccess->getByName(CFG_ENTRY_GLOBAL) >>= xContainer;
+ else if ( m_sGlobalOrModules.equals(CFG_ENTRY_MODULES) )
+ {
+ css::uno::Reference< css::container::XNameContainer > xModules;
+ xAccess->getByName(CFG_ENTRY_MODULES) >>= xModules;
+ if ( !xModules->hasByName(m_sModuleCFG) )
+ {
+ xFac = css::uno::Reference< css::lang::XSingleServiceFactory >(xModules, css::uno::UNO_QUERY);
+ xInst = xFac->createInstance();
+ xModules->insertByName(m_sModuleCFG, css::uno::makeAny(xInst));
+ }
+ xModules->getByName(m_sModuleCFG) >>= xContainer;
+ }
+
+ KeyMapping aKeyMapping;
+ const sal_Int32 nBeginIndex = 4; // "KEY_" is the prefix of a identifier...
+ ::rtl::OUString sKey = (aKeyMapping.mapCodeToIdentifier(aKeyEvent.KeyCode)).copy(nBeginIndex);
+
+ if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT )
+ sKey += ::rtl::OUString::createFromAscii("_SHIFT");
+ if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 )
+ sKey += ::rtl::OUString::createFromAscii("_MOD1");
+ if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 )
+ sKey += ::rtl::OUString::createFromAscii("_MOD2");
+
+ css::uno::Reference< css::container::XNameAccess > xKey;
+ css::uno::Reference< css::container::XNameContainer > xCommand;
+ if ( !xContainer->hasByName(sKey) )
+ {
+ xFac = css::uno::Reference< css::lang::XSingleServiceFactory >(xContainer, css::uno::UNO_QUERY);
+ xInst = xFac->createInstance();
+ xContainer->insertByName(sKey, css::uno::makeAny(xInst));
+ }
+ xContainer->getByName(sKey) >>= xKey;
+
+ xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
+ ::rtl::OUString sLocale = impl_ts_getLocale().toISO();
+ if ( !xCommand->hasByName(sLocale) )
+ xCommand->insertByName(sLocale, css::uno::makeAny(sCommand));
+ else
+ xCommand->replaceByName(sLocale, css::uno::makeAny(sCommand));
+}
+
+//-----------------------------------------------
+void XCUBasedAcceleratorConfiguration::removeKeyFromConfiguration( const css::awt::KeyEvent& aKeyEvent, const sal_Bool bPreferred )
+{
+ css::uno::Reference< css::container::XNameAccess > xAccess;
+ css::uno::Reference< css::container::XNameContainer > xContainer;
+
+ if ( bPreferred )
+ m_xCfg->getByName(CFG_ENTRY_PRIMARY) >>= xAccess;
+ else
+ m_xCfg->getByName(CFG_ENTRY_SECONDARY) >>= xAccess;
+
+ if ( m_sGlobalOrModules.equals(CFG_ENTRY_GLOBAL) )
+ xAccess->getByName(CFG_ENTRY_GLOBAL) >>= xContainer;
+ else if ( m_sGlobalOrModules.equals(CFG_ENTRY_MODULES) )
+ {
+ css::uno::Reference< css::container::XNameAccess > xModules;
+ xAccess->getByName(CFG_ENTRY_MODULES) >>= xModules;
+ if ( !xModules->hasByName(m_sModuleCFG) )
+ return;
+ xModules->getByName(m_sModuleCFG) >>= xContainer;
+ }
+
+ KeyMapping aKeyMapping;
+ const sal_Int32 nBeginIndex = 4; // "KEY_" is the prefix of a identifier...
+ ::rtl::OUString sKey = (aKeyMapping.mapCodeToIdentifier(aKeyEvent.KeyCode)).copy(nBeginIndex);
+
+ if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::SHIFT) == css::awt::KeyModifier::SHIFT )
+ sKey += ::rtl::OUString::createFromAscii("_SHIFT");
+ if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::MOD1 ) == css::awt::KeyModifier::MOD1 )
+ sKey += ::rtl::OUString::createFromAscii("_MOD1");
+ if ( (aKeyEvent.Modifiers & css::awt::KeyModifier::MOD2 ) == css::awt::KeyModifier::MOD2 )
+ sKey += ::rtl::OUString::createFromAscii("_MOD2");
+
+ xContainer->removeByName(sKey);
+}
+
+//-----------------------------------------------
+void XCUBasedAcceleratorConfiguration::reloadChanged( const ::rtl::OUString& sPrimarySecondary, const ::rtl::OUString& sGlobalModules, const ::rtl::OUString& sModule, const ::rtl::OUString& sKey )
+{
+ css::uno::Reference< css::container::XNameAccess > xAccess;
+ css::uno::Reference< css::container::XNameContainer > xContainer;
+
+ m_xCfg->getByName(sPrimarySecondary) >>= xAccess;
+ if ( sGlobalModules.equals(CFG_ENTRY_GLOBAL) )
+ xAccess->getByName(CFG_ENTRY_GLOBAL) >>= xContainer;
+ else
+ {
+ css::uno::Reference< css::container::XNameAccess > xModules;
+ xAccess->getByName(CFG_ENTRY_MODULES) >>= xModules;
+ if ( !xModules->hasByName(sModule) )
+ return;
+ xModules->getByName(sModule) >>= xContainer;
+ }
+
+ KeyMapping aKeyMapping;
+ css::awt::KeyEvent aKeyEvent;
+ ::rtl::OUString sKeyIdentifier;
+
+ sal_Int32 nIndex = 0;
+ sKeyIdentifier = sKey.getToken(0, '_', nIndex);
+ aKeyEvent.KeyCode = aKeyMapping.mapIdentifierToCode(::rtl::OUString::createFromAscii("KEY_")+sKeyIdentifier);
+
+ css::uno::Sequence< ::rtl::OUString > sToken(3);
+ const sal_Int32 nToken = 3;
+ for (sal_Int32 i=0; i<nToken; ++i)
+ {
+ if ( nIndex < 0 )
+ break;
+
+ sToken[i] = sKey.getToken(0, '_', nIndex);
+ if (sToken[i].equalsAscii("SHIFT"))
+ aKeyEvent.Modifiers |= css::awt::KeyModifier::SHIFT;
+ else if (sToken[i].equalsAscii("MOD1"))
+ aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD1;
+ else if (sToken[i].equalsAscii("MOD2"))
+ aKeyEvent.Modifiers |= css::awt::KeyModifier::MOD2;
+ }
+
+ css::uno::Reference< css::container::XNameAccess > xKey;
+ css::uno::Reference< css::container::XNameAccess > xCommand;
+ ::rtl::OUString sCommand;
+
+ if (xContainer->hasByName(sKey))
+ {
+ ::rtl::OUString sLocale = impl_ts_getLocale().toISO();
+ xContainer->getByName(sKey) >>= xKey;
+ xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
+ xCommand->getByName(sLocale) >>= sCommand;
+ }
+
+ if (sPrimarySecondary.equals(CFG_ENTRY_PRIMARY))
+ {
+ if (sCommand.getLength() ==0)
+ m_aPrimaryReadCache.removeKey(aKeyEvent);
+ else
+ m_aPrimaryReadCache.setKeyCommandPair(aKeyEvent, sCommand);
+ }
+ else if (sPrimarySecondary.equals(CFG_ENTRY_SECONDARY))
+ {
+ if (sCommand.getLength() ==0)
+ m_aSecondaryReadCache.removeKey(aKeyEvent);
+ else
+ m_aSecondaryReadCache.setKeyCommandPair(aKeyEvent, sCommand);
+ }
+}
+
+//-----------------------------------------------
+AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bPreferred, sal_Bool bWriteAccessRequested)
+{
+ // SAFE -> ----------------------------------
+ WriteGuard aWriteLock(m_aLock);
+
+ if (bPreferred)
+ {
+ //create copy of our readonly-cache, if write access is forced ... but
+ //not still possible!
+ if (
+ (bWriteAccessRequested) &&
+ (!m_pPrimaryWriteCache )
+ )
+ {
+ m_pPrimaryWriteCache = new AcceleratorCache(m_aPrimaryReadCache);
+ }
+
+ // in case, we have a writeable cache, we use it for reading too!
+ // Otherwhise the API user cant find its own changes ...
+ if (m_pPrimaryWriteCache)
+ return *m_pPrimaryWriteCache;
+ else
+ return m_aPrimaryReadCache;
+ }
+
+ else
+ {
+ //create copy of our readonly-cache, if write access is forced ... but
+ //not still possible!
+ if (
+ (bWriteAccessRequested) &&
+ (!m_pSecondaryWriteCache )
+ )
+ {
+ m_pSecondaryWriteCache = new AcceleratorCache(m_aSecondaryReadCache);
+ }
+
+ // in case, we have a writeable cache, we use it for reading too!
+ // Otherwhise the API user cant find its own changes ...
+ if (m_pSecondaryWriteCache)
+ return *m_pSecondaryWriteCache;
+ else
+ return m_aSecondaryReadCache;
+ }
+
+ // <- SAFE ----------------------------------
+}
+
+//-----------------------------------------------
+::comphelper::Locale XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
+{
+ static ::rtl::OUString LOCALE_PACKAGE = ::rtl::OUString::createFromAscii("/org.openoffice.Setup");
+ static ::rtl::OUString LOCALE_PATH = ::rtl::OUString::createFromAscii("L10N" );
+ static ::rtl::OUString LOCALE_KEY = ::rtl::OUString::createFromAscii("ooLocale" );
+
+ // SAFE -> ----------------------------------
+ ReadGuard aReadLock(m_aLock);
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
+ aReadLock.unlock();
+ // <- SAFE ----------------------------------
+
+ css::uno::Reference< css::uno::XInterface > xCFG = fpc::ConfigurationHelper::openConfig(xSMGR, LOCALE_PACKAGE, LOCALE_PATH, fpc::ConfigurationHelper::E_READONLY);
+ css::uno::Reference< css::beans::XPropertySet > xProp (xCFG, css::uno::UNO_QUERY_THROW);
+ ::rtl::OUString sISOLocale;
+ xProp->getPropertyValue(LOCALE_KEY) >>= sISOLocale;
+
+ if (!sISOLocale.getLength())
+ return ::comphelper::Locale::EN_US();
+ return ::comphelper::Locale(sISOLocale);
+}
+
+} // namespace framework
diff --git a/framework/source/accelerators/documentacceleratorconfiguration.cxx b/framework/source/accelerators/documentacceleratorconfiguration.cxx
index 72b61e191b..540a0f481a 100644
--- a/framework/source/accelerators/documentacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/documentacceleratorconfiguration.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: documentacceleratorconfiguration.cxx,v $
- * $Revision: 1.10 $
+ * $Revision: 1.9.244.4 $
*
* This file is part of OpenOffice.org.
*
@@ -32,6 +32,18 @@
#include "precompiled_framework.hxx"
#include <accelerators/documentacceleratorconfiguration.hxx>
+#ifndef __FRAMEWORK_XML_ACCELERATORCONFIGURATIONREADER_HXX_
+#include <xml/acceleratorconfigurationreader.hxx>
+#endif
+
+#ifndef __FRAMEWORK_XML_ACCELERATORCONFIGURATIONWRITER_HXX_
+#include <xml/acceleratorconfigurationwriter.hxx>
+#endif
+
+#ifndef __FRAMEWORK_XML_SAXNAMESPACEFILTER_HXX_
+#include <xml/saxnamespacefilter.hxx>
+#endif
+
//_______________________________________________
// own includes
#include <threadhelp/readguard.hxx>
@@ -45,6 +57,30 @@
//_______________________________________________
// interface includes
+#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
+#include <com/sun/star/io/XSeekable.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_
+#include <com/sun/star/io/XTruncate.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_EMBED_ELEMENTMODES_HPP_
+#include <com/sun/star/embed/ElementModes.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_INPUTSOURCE_HPP_
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#endif
+
+#ifndef _COM_SUN_STAR_XML_SAX_XPARSER_HPP_
+#include <com/sun/star/xml/sax/XParser.hpp>
+#endif
+
//_______________________________________________
// other includes
@@ -61,13 +97,13 @@ namespace framework
//-----------------------------------------------
// XInterface, XTypeProvider, XServiceInfo
DEFINE_XINTERFACE_2(DocumentAcceleratorConfiguration ,
- AcceleratorConfiguration ,
+ XMLBasedAcceleratorConfiguration ,
DIRECT_INTERFACE(css::lang::XServiceInfo) ,
DIRECT_INTERFACE(css::lang::XInitialization))
// DIRECT_INTERFACE(css::ui::XUIConfigurationStorage))
DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(DocumentAcceleratorConfiguration ,
- AcceleratorConfiguration ,
+ XMLBasedAcceleratorConfiguration ,
css::lang::XServiceInfo ,
css::lang::XInitialization)
// css::ui::XUIConfigurationStorage)
@@ -89,7 +125,7 @@ DEFINE_INIT_SERVICE(DocumentAcceleratorConfiguration,
//-----------------------------------------------
DocumentAcceleratorConfiguration::DocumentAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
- : AcceleratorConfiguration(xSMGR)
+ : XMLBasedAcceleratorConfiguration(xSMGR)
{
}
@@ -123,21 +159,21 @@ void SAL_CALL DocumentAcceleratorConfiguration::setStorage(const css::uno::Refer
throw(css::uno::RuntimeException)
{
// Attention! xStorage must be accepted too, if it's NULL !
-
+
// SAFE -> ----------------------------------
WriteGuard aWriteLock(m_aLock);
sal_Bool bForgetOldStorages = m_xDocumentRoot.is();
m_xDocumentRoot = xStorage;
aWriteLock.unlock();
// <- SAFE ----------------------------------
-
+
if (bForgetOldStorages)
impl_ts_clearCache();
if (xStorage.is())
impl_ts_fillCache();
}
-
+
//-----------------------------------------------
sal_Bool SAL_CALL DocumentAcceleratorConfiguration::hasStorage()
throw(css::uno::RuntimeException)
@@ -147,7 +183,7 @@ sal_Bool SAL_CALL DocumentAcceleratorConfiguration::hasStorage()
return m_xDocumentRoot.is();
// <- SAFE ----------------------------------
}
-
+
//-----------------------------------------------
void DocumentAcceleratorConfiguration::impl_ts_fillCache()
{
@@ -156,12 +192,12 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache()
css::uno::Reference< css::embed::XStorage > xDocumentRoot = m_xDocumentRoot;
aReadLock.unlock();
// <- SAFE ----------------------------------
-
+
// Sometimes we must live without a document root.
// E.g. if the document is readonly ...
if (!xDocumentRoot.is())
return;
-
+
// get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-)
@@ -173,7 +209,7 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache()
{
// Note: The used preset class is threadsafe by itself ... and live if we live!
// We do not need any mutex here.
-
+
// open the folder, where the configuration exists
m_aPresetHandler.connectToResource(
PresetHandler::E_DOCUMENT,
@@ -181,21 +217,21 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache()
::rtl::OUString(),
xDocumentRoot,
aLocale);
-
- AcceleratorConfiguration::reload();
+
+ DocumentAcceleratorConfiguration::reload();
m_aPresetHandler.addStorageListener(this);
}
/*
-
- Sometimes the configuration seams to be corrupted ..
- So it would be nice if we dont crash the office then .-)
- #121559#
-
+
+ Sometimes the configuration seams to be corrupted ..
+ So it would be nice if we dont crash the office then .-)
+ #121559#
+
catch(const css::uno::RuntimeException& exRun)
- { throw exRun; }
+ { throw exRun; }
*/
catch(const css::uno::Exception&)
- {}
+ {}
}
//-----------------------------------------------
diff --git a/framework/source/accelerators/globalacceleratorconfiguration.cxx b/framework/source/accelerators/globalacceleratorconfiguration.cxx
index 1b79cbe211..acd8d1f03f 100644
--- a/framework/source/accelerators/globalacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/globalacceleratorconfiguration.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: globalacceleratorconfiguration.cxx,v $
- * $Revision: 1.6 $
+ * $Revision: 1.5.244.7 $
*
* This file is part of OpenOffice.org.
*
@@ -37,24 +37,22 @@
#include <threadhelp/readguard.hxx>
#include <threadhelp/writeguard.hxx>
-#ifndef __FRAMEWORK_ACCELERATORCONST_H_
#include <acceleratorconst.h>
-#endif
#include <services.h>
//_______________________________________________
// interface includes
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/util/XChangesNotifier.hpp>
//_______________________________________________
// other includes
#include <vcl/svapp.hxx>
-
-#ifndef _COMPHELPER_LOCALE_HXX
#include <comphelper/locale.hxx>
-#endif
+#include <comphelper/configurationhelper.hxx>
//_______________________________________________
// const
@@ -64,12 +62,14 @@ namespace framework
//-----------------------------------------------
// XInterface, XTypeProvider, XServiceInfo
-DEFINE_XINTERFACE_1(GlobalAcceleratorConfiguration ,
- AcceleratorConfiguration ,
- DIRECT_INTERFACE(css::lang::XServiceInfo))
-DEFINE_XTYPEPROVIDER_1_WITH_BASECLASS(GlobalAcceleratorConfiguration,
- AcceleratorConfiguration ,
- css::lang::XServiceInfo )
+DEFINE_XINTERFACE_2(GlobalAcceleratorConfiguration ,
+ XCUBasedAcceleratorConfiguration ,
+ DIRECT_INTERFACE(css::lang::XServiceInfo),
+ DIRECT_INTERFACE(css::lang::XInitialization))
+DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(GlobalAcceleratorConfiguration,
+ XCUBasedAcceleratorConfiguration ,
+ css::lang::XServiceInfo ,
+ css::lang::XInitialization)
DEFINE_XSERVICEINFO_MULTISERVICE(GlobalAcceleratorConfiguration ,
::cppu::OWeakObject ,
@@ -89,14 +89,19 @@ DEFINE_INIT_SERVICE(GlobalAcceleratorConfiguration,
//-----------------------------------------------
GlobalAcceleratorConfiguration::GlobalAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
- : AcceleratorConfiguration(xSMGR)
+ : XCUBasedAcceleratorConfiguration(xSMGR)
{
}
//-----------------------------------------------
GlobalAcceleratorConfiguration::~GlobalAcceleratorConfiguration()
{
- m_aPresetHandler.removeStorageListener(this);
+}
+
+void SAL_CALL GlobalAcceleratorConfiguration::initialize(const css::uno::Sequence< css::uno::Any >& /*lArguments*/)
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException)
+{
}
//-----------------------------------------------
@@ -105,30 +110,16 @@ void GlobalAcceleratorConfiguration::impl_ts_fillCache()
// get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-)
- ::comphelper::Locale aLocale = impl_ts_getLocale();
+ ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
// May be there exists no accelerator config? Handle it gracefully :-)
try
- {
- // Note: The used preset class is threadsafe by itself ... and live if we live!
- // We do not need any mutex here.
-
- // open the folder, where the configuration exists
- m_aPresetHandler.connectToResource(
- PresetHandler::E_GLOBAL,
- PresetHandler::RESOURCETYPE_ACCELERATOR(),
- ::rtl::OUString(),
- css::uno::Reference< css::embed::XStorage >(),
- aLocale);
-
- // check if the user already has a current configuration
- // if not - se the default preset as new current one.
- // means: copy "share/default.xml" => "user/current.xml"
- if (!m_aPresetHandler.existsTarget(PresetHandler::TARGET_CURRENT()))
- m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
-
- AcceleratorConfiguration::reload();
- m_aPresetHandler.addStorageListener(this);
+ {
+ m_sGlobalOrModules = CFG_ENTRY_GLOBAL;
+ XCUBasedAcceleratorConfiguration::reload();
+
+ css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
+ xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this));
}
catch(const css::uno::RuntimeException& exRun)
{ throw exRun; }
diff --git a/framework/source/accelerators/moduleacceleratorconfiguration.cxx b/framework/source/accelerators/moduleacceleratorconfiguration.cxx
index 4c1ed283e9..340ffa56d1 100644
--- a/framework/source/accelerators/moduleacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/moduleacceleratorconfiguration.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: moduleacceleratorconfiguration.cxx,v $
- * $Revision: 1.7 $
+ * $Revision: 1.6.244.6 $
*
* This file is part of OpenOffice.org.
*
@@ -56,6 +56,22 @@
#endif
#include <vcl/svapp.hxx>
+#ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_
+#include <comphelper/configurationhelper.hxx>
+#endif
+
+#ifndef _COM_SUN_STAR_UTIL_XCHANGESNOTIFIER_HPP_
+#include <com/sun/star/util/XChangesNotifier.hpp>
+#endif
+
+#ifndef _RTL_LOGFILE_HXX_
+#include <rtl/logfile.hxx>
+#endif
+
+#ifndef _RTL_LOGFILE_HXX_
+#include <rtl/logfile.h>
+#endif
+
//_______________________________________________
// const
@@ -65,12 +81,12 @@ namespace framework
//-----------------------------------------------
// XInterface, XTypeProvider, XServiceInfo
DEFINE_XINTERFACE_2(ModuleAcceleratorConfiguration ,
- AcceleratorConfiguration ,
+ XCUBasedAcceleratorConfiguration ,
DIRECT_INTERFACE(css::lang::XServiceInfo) ,
DIRECT_INTERFACE(css::lang::XInitialization))
DEFINE_XTYPEPROVIDER_2_WITH_BASECLASS(ModuleAcceleratorConfiguration,
- AcceleratorConfiguration ,
+ XCUBasedAcceleratorConfiguration ,
css::lang::XServiceInfo ,
css::lang::XInitialization )
@@ -91,14 +107,14 @@ DEFINE_INIT_SERVICE(ModuleAcceleratorConfiguration,
//-----------------------------------------------
ModuleAcceleratorConfiguration::ModuleAcceleratorConfiguration(const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR)
- : AcceleratorConfiguration(xSMGR)
+ : XCUBasedAcceleratorConfiguration(xSMGR)
{
}
//-----------------------------------------------
ModuleAcceleratorConfiguration::~ModuleAcceleratorConfiguration()
{
- m_aPresetHandler.removeStorageListener(this);
+ // m_aPresetHandler.removeStorageListener(this);
}
//-----------------------------------------------
@@ -111,6 +127,7 @@ void SAL_CALL ModuleAcceleratorConfiguration::initialize(const css::uno::Sequenc
::comphelper::SequenceAsHashMap lArgs(lArguments);
m_sModule = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("ModuleIdentifier"), ::rtl::OUString());
+ m_sLocale = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("Locale") , ::rtl::OUString::createFromAscii("x-default"));
if (!m_sModule.getLength())
throw css::uno::RuntimeException(
@@ -129,37 +146,24 @@ void ModuleAcceleratorConfiguration::impl_ts_fillCache()
// SAFE -> ----------------------------------
ReadGuard aReadLock(m_aLock);
::rtl::OUString sModule = m_sModule;
+ m_sModuleCFG = m_sModule;
aReadLock.unlock();
// <- SAFE ----------------------------------
// get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-)
- ::comphelper::Locale aLocale = impl_ts_getLocale();
+ ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
// May be the current app module does not have any
// accelerator config? Handle it gracefully :-)
try
{
- // Note: The used preset class is threadsafe by itself ... and live if we live!
- // We do not need any mutex here.
-
- // open the folder, where the configuration exists
- m_aPresetHandler.connectToResource(
- PresetHandler::E_MODULES,
- PresetHandler::RESOURCETYPE_ACCELERATOR(),
- sModule,
- css::uno::Reference< css::embed::XStorage >(),
- aLocale);
-
- // check if the user already has a current configuration
- // if not - se the default preset as new current one.
- // means: copy "share/default.xml" => "user/current.xml"
- if (!m_aPresetHandler.existsTarget(PresetHandler::TARGET_CURRENT()))
- m_aPresetHandler.copyPresetToTarget(PresetHandler::PRESET_DEFAULT(), PresetHandler::TARGET_CURRENT());
-
- AcceleratorConfiguration::reload();
- m_aPresetHandler.addStorageListener(this);
+ m_sGlobalOrModules = CFG_ENTRY_MODULES;
+ XCUBasedAcceleratorConfiguration::reload();
+
+ css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
+ xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this));
}
catch(const css::uno::RuntimeException& exRun)
{ throw exRun; }
diff --git a/framework/source/inc/accelerators/acceleratorconfiguration.hxx b/framework/source/inc/accelerators/acceleratorconfiguration.hxx
index 43aef0cc0b..5e4594dc94 100644
--- a/framework/source/inc/accelerators/acceleratorconfiguration.hxx
+++ b/framework/source/inc/accelerators/acceleratorconfiguration.hxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: acceleratorconfiguration.hxx,v $
- * $Revision: 1.6 $
+ * $Revision: 1.5.300.9 $
*
* This file is part of OpenOffice.org.
*
@@ -45,24 +45,26 @@
//__________________________________________
// interface includes
+
+#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
#include <com/sun/star/ui/XUIConfiguration.hpp>
#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
-#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONSTORAGE_HDL_
#include <com/sun/star/ui/XUIConfigurationStorage.hpp>
-#endif
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/util/XChangesListener.hpp>
// TODO use XPresetHandler interface instead if available
#include <com/sun/star/form/XReset.hpp>
//__________________________________________
// other includes
+#include <cppuhelper/propshlp.hxx>
#include <cppuhelper/weak.hxx>
#include <comphelper/locale.hxx>
@@ -71,6 +73,16 @@
namespace framework
{
+//-----------------------------------------------
+// Accelerators.xcu
+static const ::rtl::OUString CFG_ENTRY_ACCELERATORS = ::rtl::OUString::createFromAscii("org.openoffice.Office.Accelerators");
+static const ::rtl::OUString CFG_ENTRY_PRIMARY = ::rtl::OUString::createFromAscii("PrimaryKeys");
+static const ::rtl::OUString CFG_ENTRY_SECONDARY = ::rtl::OUString::createFromAscii("SecondaryKeys");
+
+static const ::rtl::OUString CFG_ENTRY_GLOBAL = ::rtl::OUString::createFromAscii("Global");
+static const ::rtl::OUString CFG_ENTRY_MODULES = ::rtl::OUString::createFromAscii("Modules");
+
+static const ::rtl::OUString CFG_PROP_COMMAND = ::rtl::OUString::createFromAscii("Command");
/** "global" type to make accelerator presets unique, so they can be used
in combination with the salhelper::SingletonRef mechanism! */
@@ -80,14 +92,14 @@ typedef PresetHandler AcceleratorPresets;
/**
implements a read/write access to the accelerator configuration.
*/
-class AcceleratorConfiguration : protected ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
- , public IStorageListener
- , public ::cppu::OWeakObject
- , public css::lang::XTypeProvider
- , public css::form::XReset // TODO use XPresetHandler instead if available
- , public css::ui::XAcceleratorConfiguration // => css::ui::XUIConfigurationPersistence
- // css::ui::XUIConfigurationStorage
- // css::ui::XUIConfiguration
+class XMLBasedAcceleratorConfiguration : protected ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
+ , public IStorageListener
+ , public ::cppu::OWeakObject
+ , public css::lang::XTypeProvider
+ , public css::form::XReset // TODO use XPresetHandler instead if available
+ , public css::ui::XAcceleratorConfiguration // => css::ui::XUIConfigurationPersistence
+ // css::ui::XUIConfigurationStorage
+ // css::ui::XUIConfiguration
{
//______________________________________
// member
@@ -96,38 +108,38 @@ class AcceleratorConfiguration : protected ThreadHelpBase
//---------------------------------------
/** the global uno service manager.
- Must be used to create own needed services. */
+ Must be used to create own needed services. */
css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
-
+
//---------------------------------------
/** used to:
- i ) copy configuration files from the share to the user layer
- ii ) provide access to these config files
- iii) cache all sub storages on the path from the top to the bottom(!)
- iv ) provide commit for changes. */
+ i ) copy configuration files from the share to the user layer
+ ii ) provide access to these config files
+ iii) cache all sub storages on the path from the top to the bottom(!)
+ iv ) provide commit for changes. */
PresetHandler m_aPresetHandler;
-
+
//---------------------------------------
/** contains the cached configuration data */
AcceleratorCache m_aReadCache;
-
+
//---------------------------------------
/** used to implement the copy on write pattern! */
AcceleratorCache* m_pWriteCache;
-
- //______________________________________
- // native interface!
+
+ //______________________________________
+ // native interface!
public:
- AcceleratorConfiguration( const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR );
- virtual ~AcceleratorConfiguration( );
-
- //______________________________________
- // uno interface!
+ XMLBasedAcceleratorConfiguration( const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR );
+ virtual ~XMLBasedAcceleratorConfiguration( );
+
+ //______________________________________
+ // uno interface!
public:
-
+
// XInterface, XTypeProvider
FWK_DECLARE_XINTERFACE
FWK_DECLARE_XTYPEPROVIDER
@@ -135,166 +147,327 @@ class AcceleratorConfiguration : protected ThreadHelpBase
// XAcceleratorConfiguration
virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getAllKeyEvents()
throw(css::uno::RuntimeException);
-
+
virtual ::rtl::OUString SAL_CALL getCommandByKeyEvent(const css::awt::KeyEvent& aKeyEvent)
throw(css::container::NoSuchElementException,
- css::uno::RuntimeException );
-
+ css::uno::RuntimeException );
+
virtual void SAL_CALL setKeyEvent(const css::awt::KeyEvent& aKeyEvent,
- const ::rtl::OUString& sCommand )
+ const ::rtl::OUString& sCommand )
throw(css::lang::IllegalArgumentException,
- css::uno::RuntimeException );
-
+ css::uno::RuntimeException );
+
virtual void SAL_CALL removeKeyEvent(const css::awt::KeyEvent& aKeyEvent)
throw(css::container::NoSuchElementException,
- css::uno::RuntimeException );
-
+ css::uno::RuntimeException );
+
virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getKeyEventsByCommand(const ::rtl::OUString& sCommand)
throw(css::lang::IllegalArgumentException ,
- css::container::NoSuchElementException,
- css::uno::RuntimeException );
-
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException );
+
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPreferredKeyEventsForCommandList(const css::uno::Sequence< ::rtl::OUString >& lCommandList)
throw(css::lang::IllegalArgumentException ,
- css::uno::RuntimeException );
-
+ css::uno::RuntimeException );
+
virtual void SAL_CALL removeCommandFromAllKeyEvents(const ::rtl::OUString& sCommand)
throw(css::lang::IllegalArgumentException ,
- css::container::NoSuchElementException,
- css::uno::RuntimeException );
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException );
// XUIConfigurationPersistence
virtual void SAL_CALL reload()
throw(css::uno::Exception ,
- css::uno::RuntimeException);
-
+ css::uno::RuntimeException);
+
virtual void SAL_CALL store()
throw(css::uno::Exception ,
- css::uno::RuntimeException);
-
+ css::uno::RuntimeException);
+
virtual void SAL_CALL storeToStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
throw(css::uno::Exception ,
- css::uno::RuntimeException);
-
+ css::uno::RuntimeException);
+
virtual ::sal_Bool SAL_CALL isModified()
throw(css::uno::RuntimeException);
-
+
virtual ::sal_Bool SAL_CALL isReadOnly()
throw(css::uno::RuntimeException);
-
+
// XUIConfigurationStorage
virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
throw(css::uno::RuntimeException);
-
+
virtual ::sal_Bool SAL_CALL hasStorage()
throw(css::uno::RuntimeException);
-
+
// XUIConfiguration
virtual void SAL_CALL addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
throw(css::uno::RuntimeException);
-
+
virtual void SAL_CALL removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
throw(css::uno::RuntimeException);
-
+
// XReset
// TODO use XPresetHandler instead if available
virtual void SAL_CALL reset()
throw(css::uno::RuntimeException);
-
+
virtual void SAL_CALL addResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
throw(css::uno::RuntimeException);
-
+
virtual void SAL_CALL removeResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
throw(css::uno::RuntimeException);
-
+
// IStorageListener
virtual void changesOccured(const ::rtl::OUString& sPath);
- //______________________________________
- // helper for derived classes
+ //______________________________________
+ // helper for derived classes
protected:
-
+
//---------------------------------------
/** @short return the current office locale.
-
- @descr We does not cache this value, because we are not listen
- for changes on the configuration layer ...
-
- @return ::comphelper::Locale
- The current office locale.
- */
+
+ @descr We does not cache this value, because we are not listen
+ for changes on the configuration layer ...
+
+ @return ::comphelper::Locale
+ The current office locale.
+ */
::comphelper::Locale impl_ts_getLocale() const;
-
- //______________________________________
- // helper
+
+ //______________________________________
+ // helper
private:
-
+
//---------------------------------------
/** @short load a configuration set, using the given stream.
-
- @param xStream
- provides the XML structure as stream.
- */
+
+ @param xStream
+ provides the XML structure as stream.
+ */
void impl_ts_load(const css::uno::Reference< css::io::XInputStream >& xStream);
-
+
//---------------------------------------
/** @short save a configuration set, using the given stream.
-
- @param xStream
- the XML structure can be written there.
- */
+
+ @param xStream
+ the XML structure can be written there.
+ */
void impl_ts_save(const css::uno::Reference< css::io::XOutputStream >& xStream);
-
+
//---------------------------------------
/** @short try to locate and open a sub storage.
-
- @descr It search at the root storage for the specified
- sub storage. If it exists - it will be opened.
- By default this method tries to open the storage
- for reading. But the calli can request a writeable
- storage.
-
- @param xRooStorage
- used to locate the sub storage.
-
- @param sSubStorage
- relativ path of the sub storage.
-
- @param bOutStream
- force open of the sub storage in
- write mode - instead of read mode, which
- is the default.
-
- @return [XInterface]
- will be a css::io::XInpoutStream or a css::io::XOutputStream.
- Depends from the parameter bWriteable!
- */
+
+ @descr It search at the root storage for the specified
+ sub storage. If it exists - it will be opened.
+ By default this method tries to open the storage
+ for reading. But the calli can request a writeable
+ storage.
+
+ @param xRooStorage
+ used to locate the sub storage.
+
+ @param sSubStorage
+ relativ path of the sub storage.
+
+ @param bOutStream
+ force open of the sub storage in
+ write mode - instead of read mode, which
+ is the default.
+
+ @return [XInterface]
+ will be a css::io::XInpoutStream or a css::io::XOutputStream.
+ Depends from the parameter bWriteable!
+ */
css::uno::Reference< css::uno::XInterface > impl_ts_openSubStorage(const css::uno::Reference< css::embed::XStorage >& xRootStorage,
- const ::rtl::OUString& sSubStorage ,
- sal_Bool bOutStream );
-
+ const ::rtl::OUString& sSubStorage ,
+ sal_Bool bOutStream );
+
//---------------------------------------
/** @short returns a reference to one of our internal cache members.
-
- @descr We implement the copy-on-write pattern. Doing so
- we know two caches internaly. The second one is used
- only, if the container was changed.
-
- This method here returns access to one of these
- caches - depending on the change state of this
- configuration service.
-
- @param bWriteAccessRequested
- if the outside code whish to change the container
- it must call this method with "TRUE". So the internal
- cache can be prepared for that (means copy-on-write ...).
-
- @return [AcceleratorCache]
- c++ reference(!) to one of our internal caches.
- */
+
+ @descr We implement the copy-on-write pattern. Doing so
+ we know two caches internaly. The second one is used
+ only, if the container was changed.
+
+ This method here returns access to one of these
+ caches - depending on the change state of this
+ configuration service.
+
+ @param bWriteAccessRequested
+ if the outside code whish to change the container
+ it must call this method with "TRUE". So the internal
+ cache can be prepared for that (means copy-on-write ...).
+
+ @return [AcceleratorCache]
+ c++ reference(!) to one of our internal caches.
+ */
AcceleratorCache& impl_getCFG(sal_Bool bWriteAccessRequested = sal_False);
+
+};
+
+class XCUBasedAcceleratorConfiguration : protected ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
+ , public ::cppu::OWeakObject
+ , public css::lang::XTypeProvider
+ , public css::util::XChangesListener
+ , public css::form::XReset // TODO use XPresetHandler instead if available
+ , public css::ui::XAcceleratorConfiguration // => css::ui::XUIConfigurationPersistence
+ // css::ui::XUIConfigurationStorage
+ // css::ui::XUIConfiguration
+{
+ //______________________________________
+ // member
+
+ protected:
+
+ //---------------------------------------
+ /** the global uno service manager.
+ Must be used to create own needed services. */
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
+
+ css::uno::Reference< css::container::XNameAccess > m_xCfg;
+ AcceleratorCache m_aPrimaryReadCache;
+ AcceleratorCache m_aSecondaryReadCache;
+ AcceleratorCache* m_pPrimaryWriteCache;
+ AcceleratorCache* m_pSecondaryWriteCache;
+
+ ::rtl::OUString m_sGlobalOrModules;
+ ::rtl::OUString m_sModuleCFG;
+
+ //______________________________________
+ // native interface!
+
+ public:
+
+ XCUBasedAcceleratorConfiguration( const css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR );
+ virtual ~XCUBasedAcceleratorConfiguration( );
+
+ //______________________________________
+ // uno interface!
+
+ public:
+
+ // XInterface, XTypeProvider
+ FWK_DECLARE_XINTERFACE
+ FWK_DECLARE_XTYPEPROVIDER
+
+ // XAcceleratorConfiguration
+ virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getAllKeyEvents()
+ throw(css::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getCommandByKeyEvent(const css::awt::KeyEvent& aKeyEvent)
+ throw(css::container::NoSuchElementException,
+ css::uno::RuntimeException );
+
+ virtual void SAL_CALL setKeyEvent(const css::awt::KeyEvent& aKeyEvent,
+ const ::rtl::OUString& sCommand )
+ throw(css::lang::IllegalArgumentException,
+ css::uno::RuntimeException );
+
+ virtual void SAL_CALL removeKeyEvent(const css::awt::KeyEvent& aKeyEvent)
+ throw(css::container::NoSuchElementException,
+ css::uno::RuntimeException );
+
+ virtual css::uno::Sequence< css::awt::KeyEvent > SAL_CALL getKeyEventsByCommand(const ::rtl::OUString& sCommand)
+ throw(css::lang::IllegalArgumentException ,
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException );
+
+ virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPreferredKeyEventsForCommandList(const css::uno::Sequence< ::rtl::OUString >& lCommandList)
+ throw(css::lang::IllegalArgumentException ,
+ css::uno::RuntimeException );
+
+ virtual void SAL_CALL removeCommandFromAllKeyEvents(const ::rtl::OUString& sCommand)
+ throw(css::lang::IllegalArgumentException ,
+ css::container::NoSuchElementException,
+ css::uno::RuntimeException );
+
+ // XUIConfigurationPersistence
+ virtual void SAL_CALL reload()
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL store()
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException);
+
+ virtual void SAL_CALL storeToStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
+ throw(css::uno::Exception ,
+ css::uno::RuntimeException);
+
+ virtual ::sal_Bool SAL_CALL isModified()
+ throw(css::uno::RuntimeException);
+
+ virtual ::sal_Bool SAL_CALL isReadOnly()
+ throw(css::uno::RuntimeException);
+
+ // XUIConfigurationStorage
+ virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
+ throw(css::uno::RuntimeException);
+
+ virtual ::sal_Bool SAL_CALL hasStorage()
+ throw(css::uno::RuntimeException);
+
+ // XUIConfiguration
+ virtual void SAL_CALL addConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL removeConfigurationListener(const css::uno::Reference< css::ui::XUIConfigurationListener >& xListener)
+ throw(css::uno::RuntimeException);
+
+ // XReset
+ // TODO use XPresetHandler instead if available
+ virtual void SAL_CALL reset()
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL addResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL removeResetListener(const css::uno::Reference< css::form::XResetListener >& xListener)
+ throw(css::uno::RuntimeException);
+
+ // css.util.XChangesListener
+ virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& aEvent)
+ throw(css::uno::RuntimeException);
+
+ // css.lang.XEventListener
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw(css::uno::RuntimeException);
+
+ //______________________________________
+ // helper for derived classes
+
+ protected:
+
+ //---------------------------------------
+ /** @short return the current office locale.
+
+ @descr We does not cache this value, because we are not listen
+ for changes on the configuration layer ...
+
+ @return ::comphelper::Locale
+ The current office locale.
+ */
+ ::comphelper::Locale impl_ts_getLocale() const;
+
+ //______________________________________
+ // helper
+
+ private:
+
+ void impl_ts_load(sal_Bool bPreferred, const css::uno::Reference< css::container::XNameAccess >& xCfg);
+ void impl_ts_save(sal_Bool bPreferred, const css::uno::Reference< css::container::XNameAccess >& xCfg);
+
+ void insertKeyToConfiguration(const css::awt::KeyEvent& aKeyEvent, const ::rtl::OUString& sCommand, const sal_Bool bPreferred);
+ void removeKeyFromConfiguration(const css::awt::KeyEvent& aKeyEvent, const sal_Bool bPreferred);
+
+ void reloadChanged(const ::rtl::OUString& sPrimarySecondary, const ::rtl::OUString& sGlobalModules, const ::rtl::OUString& sModule, const ::rtl::OUString& sKey);
+ AcceleratorCache& impl_getCFG(sal_Bool bPreferred, sal_Bool bWriteAccessRequested = sal_False);
+
};
} // namespace framework
diff --git a/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx b/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx
index 79368665c8..d95feb3c62 100644
--- a/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx
+++ b/framework/source/inc/accelerators/documentacceleratorconfiguration.hxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: documentacceleratorconfiguration.hxx,v $
- * $Revision: 1.8 $
+ * $Revision: 1.7.300.4 $
*
* This file is part of OpenOffice.org.
*
@@ -35,11 +35,10 @@
// own includes
#include <accelerators/acceleratorconfiguration.hxx>
+#include <accelerators/istoragelistener.hxx>
#include <accelerators/presethandler.hxx>
-#ifndef __FRAMEWORK_MACROS_XINTERFACE_HXX_
-#include <macros/interface.hxx>
-#endif
+#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
#include <macros/xserviceinfo.hxx>
@@ -62,7 +61,7 @@ namespace framework
implements a read/write access to a document
based accelerator configuration.
*/
-class DocumentAcceleratorConfiguration : public AcceleratorConfiguration
+class DocumentAcceleratorConfiguration : public XMLBasedAcceleratorConfiguration
, public css::lang::XServiceInfo
, public css::lang::XInitialization
// , public css::ui::XUIConfigurationStorage
@@ -75,7 +74,7 @@ class DocumentAcceleratorConfiguration : public AcceleratorConfiguration
//----------------------------------
/** points to the root storage of the outside document,
where we can read/save our configuration data. */
- css::uno::Reference< css::embed::XStorage > m_xDocumentRoot;
+ css::uno::Reference< css::embed::XStorage > m_xDocumentRoot;
//______________________________________
// interface
@@ -100,14 +99,14 @@ class DocumentAcceleratorConfiguration : public AcceleratorConfiguration
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
throw(css::uno::Exception ,
css::uno::RuntimeException);
-
+
// XUIConfigurationStorage
virtual void SAL_CALL setStorage(const css::uno::Reference< css::embed::XStorage >& xStorage)
throw(css::uno::RuntimeException);
-
+
virtual sal_Bool SAL_CALL hasStorage()
throw(css::uno::RuntimeException);
-
+
//______________________________________
// helper
diff --git a/framework/source/inc/accelerators/globalacceleratorconfiguration.hxx b/framework/source/inc/accelerators/globalacceleratorconfiguration.hxx
index dd074057cd..9c6517ac08 100644
--- a/framework/source/inc/accelerators/globalacceleratorconfiguration.hxx
+++ b/framework/source/inc/accelerators/globalacceleratorconfiguration.hxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: globalacceleratorconfiguration.hxx,v $
- * $Revision: 1.5 $
+ * $Revision: 1.4.300.4 $
*
* This file is part of OpenOffice.org.
*
@@ -46,6 +46,10 @@
//__________________________________________
// interface includes
+#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
+#include <com/sun/star/lang/XInitialization.hpp>
+#endif
+
//__________________________________________
// other includes
@@ -60,8 +64,9 @@ namespace framework
implements a read/write access to the global
accelerator configuration.
*/
-class GlobalAcceleratorConfiguration : public AcceleratorConfiguration
+class GlobalAcceleratorConfiguration : public XCUBasedAcceleratorConfiguration
, public css::lang::XServiceInfo
+ , public css::lang::XInitialization
{
//______________________________________
// interface
@@ -85,10 +90,17 @@ class GlobalAcceleratorConfiguration : public AcceleratorConfiguration
FWK_DECLARE_XTYPEPROVIDER
DECLARE_XSERVICEINFO
+ // XInitialization
+ virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments)
+ throw (css::uno::Exception ,
+ css::uno::RuntimeException);
+
//______________________________________
// helper
private:
+
+ ::rtl::OUString m_sLocale;
//----------------------------------
/** read all data into the cache. */
diff --git a/framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx b/framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx
index e7027a88ba..e57ef45ad1 100644
--- a/framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx
+++ b/framework/source/inc/accelerators/moduleacceleratorconfiguration.hxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: moduleacceleratorconfiguration.hxx,v $
- * $Revision: 1.5 $
+ * $Revision: 1.4.300.4 $
*
* This file is part of OpenOffice.org.
*
@@ -61,7 +61,7 @@ namespace framework
implements a read/write access to a module
dependend accelerator configuration.
*/
-class ModuleAcceleratorConfiguration : public AcceleratorConfiguration
+class ModuleAcceleratorConfiguration : public XCUBasedAcceleratorConfiguration
, public css::lang::XServiceInfo
, public css::lang::XInitialization
{
@@ -73,7 +73,8 @@ class ModuleAcceleratorConfiguration : public AcceleratorConfiguration
//----------------------------------
/** identify the application module, where this accelerator
configuration cache should work on. */
- ::rtl::OUString m_sModule;
+ ::rtl::OUString m_sModule;
+ ::rtl::OUString m_sLocale;
//______________________________________
// interface
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index cbbef42f1c..7d2bf4fd54 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: moduleuiconfigurationmanager.cxx,v $
- * $Revision: 1.20 $
+ * $Revision: 1.19.208.2 $
*
* This file is part of OpenOffice.org.
*
@@ -1379,7 +1379,7 @@ Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getShortCutManage
{
ResetableGuard aGuard( m_aLock );
Reference< XMultiServiceFactory > xSMGR = m_xServiceManager;
- ::rtl::OUString aModule = m_aModuleShortName;
+ ::rtl::OUString aModule = /*m_aModuleShortName*/m_aModuleIdentifier;
aGuard.unlock();
Reference< XInterface > xManager = xSMGR->createInstance(SERVICENAME_MODULEACCELERATORCONFIGURATION);