summaryrefslogtreecommitdiff
path: root/cui/source/customize
diff options
context:
space:
mode:
Diffstat (limited to 'cui/source/customize')
-rw-r--r--cui/source/customize/acccfg.cxx1699
-rw-r--r--cui/source/customize/acccfg.hrc75
-rw-r--r--cui/source/customize/acccfg.src357
-rw-r--r--cui/source/customize/cfg.cxx6053
-rw-r--r--cui/source/customize/cfg.hrc105
-rw-r--r--cui/source/customize/cfg.src872
-rw-r--r--cui/source/customize/cfgutil.cxx1798
-rw-r--r--cui/source/customize/eventdlg.cxx247
-rw-r--r--cui/source/customize/eventdlg.hrc43
-rw-r--r--cui/source/customize/eventdlg.hxx78
-rw-r--r--cui/source/customize/eventdlg.src111
-rw-r--r--cui/source/customize/macropg.cxx1054
-rw-r--r--cui/source/customize/macropg.hrc101
-rw-r--r--cui/source/customize/macropg.src485
-rw-r--r--cui/source/customize/macropg_impl.hxx73
-rw-r--r--cui/source/customize/makefile.mk63
-rw-r--r--cui/source/customize/selector.cxx1253
-rw-r--r--cui/source/customize/selector.hrc57
-rw-r--r--cui/source/customize/selector.src212
19 files changed, 14736 insertions, 0 deletions
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx
new file mode 100644
index 000000000000..a75a7cf1f24d
--- /dev/null
+++ b/cui/source/customize/acccfg.cxx
@@ -0,0 +1,1699 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cui.hxx"
+
+//-----------------------------------------------
+// include own files
+
+#include "acccfg.hxx"
+#include "cfgutil.hxx"
+#include <dialmgr.hxx>
+
+#include <sfx2/msg.hxx>
+#include <sfx2/macrconf.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/minfitem.hxx>
+#include <svl/stritem.hxx>
+
+#include "cuires.hrc"
+#include "acccfg.hrc"
+
+#include <svx/svxids.hrc> // SID_CHARMAP, SID_ATTR_SPECIALCHAR
+
+//-----------------------------------------------
+// include interface declarations
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+
+#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGERSUPLLIER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#endif
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+
+//-----------------------------------------------
+// include other projects
+#include <unotools/processfactory.hxx>
+#include <svtools/acceleratorexecute.hxx>
+#include <comphelper/processfactory.hxx>
+#include <svtools/svlbitm.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/help.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+
+//-----------------------------------------------
+// namespaces
+
+#ifdef css
+ #error "ambigous praeprozessor directive for css ..."
+#else
+ namespace css = ::com::sun::star;
+#endif
+
+using namespace com::sun::star;
+
+//-----------------------------------------------
+// definitions
+
+//-----------------------------------------------
+static ::rtl::OUString SERVICE_STORAGEFACTORY = ::rtl::OUString::createFromAscii("com.sun.star.embed.StorageFactory" );
+static ::rtl::OUString SERVICE_UICONFIGMGR = ::rtl::OUString::createFromAscii("com.sun.star.ui.UIConfigurationManager" );
+static ::rtl::OUString SERVICE_DESKTOP = ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop" );
+static ::rtl::OUString SERVICE_MODULEMANAGER = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager" );
+static ::rtl::OUString SERVICE_GLOBALACCCFG = ::rtl::OUString::createFromAscii("com.sun.star.ui.GlobalAcceleratorConfiguration" );
+static ::rtl::OUString SERVICE_MODULEUICONFIGSUPPLIER = ::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier");
+static ::rtl::OUString SERVICE_UICMDDESCRIPTION = ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription" );
+
+static ::rtl::OUString MODULEPROP_SHORTNAME = ::rtl::OUString::createFromAscii("ooSetupFactoryShortName" );
+static ::rtl::OUString MODULEPROP_UINAME = ::rtl::OUString::createFromAscii("ooSetupFactoryUIName" );
+static ::rtl::OUString CMDPROP_UINAME = ::rtl::OUString::createFromAscii("Name" );
+
+static ::rtl::OUString FOLDERNAME_UICONFIG = ::rtl::OUString::createFromAscii("Configurations2" );
+
+static ::rtl::OUString MEDIATYPE_PROPNAME = ::rtl::OUString::createFromAscii("MediaType" );
+static ::rtl::OUString MEDIATYPE_UICONFIG = ::rtl::OUString::createFromAscii("application/vnd.sun.xml.ui.configuration" );
+
+//-----------------------------------------------
+static USHORT __FAR_DATA KEYCODE_ARRAY[] =
+{
+ KEY_F1 ,
+ KEY_F2 ,
+ KEY_F3 ,
+ KEY_F4 ,
+ KEY_F5 ,
+ KEY_F6 ,
+ KEY_F7 ,
+ KEY_F8 ,
+ KEY_F9 ,
+ KEY_F10 ,
+ KEY_F11 ,
+ KEY_F12 ,
+
+ KEY_DOWN ,
+ KEY_UP ,
+ KEY_LEFT ,
+ KEY_RIGHT ,
+ KEY_HOME ,
+ KEY_END ,
+ KEY_PAGEUP ,
+ KEY_PAGEDOWN ,
+ KEY_RETURN ,
+ KEY_ESCAPE ,
+ KEY_BACKSPACE,
+ KEY_INSERT ,
+ KEY_DELETE ,
+
+ KEY_OPEN ,
+ KEY_CUT ,
+ KEY_COPY ,
+ KEY_PASTE ,
+ KEY_UNDO ,
+ KEY_REPEAT ,
+ KEY_FIND ,
+ KEY_PROPERTIES ,
+ KEY_FRONT ,
+ KEY_CONTEXTMENU ,
+ KEY_MENU ,
+ KEY_HELP ,
+
+ KEY_F1 | KEY_SHIFT,
+ KEY_F2 | KEY_SHIFT,
+ KEY_F3 | KEY_SHIFT,
+ KEY_F4 | KEY_SHIFT,
+ KEY_F5 | KEY_SHIFT,
+ KEY_F6 | KEY_SHIFT,
+ KEY_F7 | KEY_SHIFT,
+ KEY_F8 | KEY_SHIFT,
+ KEY_F9 | KEY_SHIFT,
+ KEY_F10 | KEY_SHIFT,
+ KEY_F11 | KEY_SHIFT,
+ KEY_F12 | KEY_SHIFT,
+
+ KEY_DOWN | KEY_SHIFT,
+ KEY_UP | KEY_SHIFT,
+ KEY_LEFT | KEY_SHIFT,
+ KEY_RIGHT | KEY_SHIFT,
+ KEY_HOME | KEY_SHIFT,
+ KEY_END | KEY_SHIFT,
+ KEY_PAGEUP | KEY_SHIFT,
+ KEY_PAGEDOWN | KEY_SHIFT,
+ KEY_RETURN | KEY_SHIFT,
+ KEY_SPACE | KEY_SHIFT,
+ KEY_ESCAPE | KEY_SHIFT,
+ KEY_BACKSPACE | KEY_SHIFT,
+ KEY_INSERT | KEY_SHIFT,
+ KEY_DELETE | KEY_SHIFT,
+
+ KEY_0 | KEY_MOD1 ,
+ KEY_1 | KEY_MOD1 ,
+ KEY_2 | KEY_MOD1 ,
+ KEY_3 | KEY_MOD1 ,
+ KEY_4 | KEY_MOD1 ,
+ KEY_5 | KEY_MOD1 ,
+ KEY_6 | KEY_MOD1 ,
+ KEY_7 | KEY_MOD1 ,
+ KEY_8 | KEY_MOD1 ,
+ KEY_9 | KEY_MOD1 ,
+ KEY_A | KEY_MOD1 ,
+ KEY_B | KEY_MOD1 ,
+ KEY_C | KEY_MOD1 ,
+ KEY_D | KEY_MOD1 ,
+ KEY_E | KEY_MOD1 ,
+ KEY_F | KEY_MOD1 ,
+ KEY_G | KEY_MOD1 ,
+ KEY_H | KEY_MOD1 ,
+ KEY_I | KEY_MOD1 ,
+ KEY_J | KEY_MOD1 ,
+ KEY_K | KEY_MOD1 ,
+ KEY_L | KEY_MOD1 ,
+ KEY_M | KEY_MOD1 ,
+ KEY_N | KEY_MOD1 ,
+ KEY_O | KEY_MOD1 ,
+ KEY_P | KEY_MOD1 ,
+ KEY_Q | KEY_MOD1 ,
+ KEY_R | KEY_MOD1 ,
+ KEY_S | KEY_MOD1 ,
+ KEY_T | KEY_MOD1 ,
+ KEY_U | KEY_MOD1 ,
+ KEY_V | KEY_MOD1 ,
+ KEY_W | KEY_MOD1 ,
+ KEY_X | KEY_MOD1 ,
+ KEY_Y | KEY_MOD1 ,
+ KEY_Z | KEY_MOD1 ,
+
+ KEY_F1 | KEY_MOD1 ,
+ KEY_F2 | KEY_MOD1 ,
+ KEY_F3 | KEY_MOD1 ,
+ KEY_F4 | KEY_MOD1 ,
+ KEY_F5 | KEY_MOD1 ,
+ KEY_F6 | KEY_MOD1 ,
+ KEY_F7 | KEY_MOD1 ,
+ KEY_F8 | KEY_MOD1 ,
+ KEY_F9 | KEY_MOD1 ,
+ KEY_F10 | KEY_MOD1 ,
+ KEY_F11 | KEY_MOD1 ,
+ KEY_F12 | KEY_MOD1 ,
+
+ KEY_DOWN | KEY_MOD1 ,
+ KEY_UP | KEY_MOD1 ,
+ KEY_LEFT | KEY_MOD1 ,
+ KEY_RIGHT | KEY_MOD1 ,
+ KEY_HOME | KEY_MOD1 ,
+ KEY_END | KEY_MOD1 ,
+ KEY_PAGEUP | KEY_MOD1 ,
+ KEY_PAGEDOWN | KEY_MOD1 ,
+ KEY_RETURN | KEY_MOD1 ,
+ KEY_SPACE | KEY_MOD1 ,
+ KEY_BACKSPACE | KEY_MOD1 ,
+ KEY_INSERT | KEY_MOD1 ,
+ KEY_DELETE | KEY_MOD1 ,
+
+ KEY_ADD | KEY_MOD1 ,
+ KEY_SUBTRACT | KEY_MOD1 ,
+ KEY_MULTIPLY | KEY_MOD1 ,
+ KEY_DIVIDE | KEY_MOD1 ,
+
+ KEY_0 | KEY_SHIFT | KEY_MOD1,
+ KEY_1 | KEY_SHIFT | KEY_MOD1,
+ KEY_2 | KEY_SHIFT | KEY_MOD1,
+ KEY_3 | KEY_SHIFT | KEY_MOD1,
+ KEY_4 | KEY_SHIFT | KEY_MOD1,
+ KEY_5 | KEY_SHIFT | KEY_MOD1,
+ KEY_6 | KEY_SHIFT | KEY_MOD1,
+ KEY_7 | KEY_SHIFT | KEY_MOD1,
+ KEY_8 | KEY_SHIFT | KEY_MOD1,
+ KEY_9 | KEY_SHIFT | KEY_MOD1,
+ KEY_A | KEY_SHIFT | KEY_MOD1,
+ KEY_B | KEY_SHIFT | KEY_MOD1,
+ KEY_C | KEY_SHIFT | KEY_MOD1,
+ KEY_D | KEY_SHIFT | KEY_MOD1,
+ KEY_E | KEY_SHIFT | KEY_MOD1,
+ KEY_F | KEY_SHIFT | KEY_MOD1,
+ KEY_G | KEY_SHIFT | KEY_MOD1,
+ KEY_H | KEY_SHIFT | KEY_MOD1,
+ KEY_I | KEY_SHIFT | KEY_MOD1,
+ KEY_J | KEY_SHIFT | KEY_MOD1,
+ KEY_K | KEY_SHIFT | KEY_MOD1,
+ KEY_L | KEY_SHIFT | KEY_MOD1,
+ KEY_M | KEY_SHIFT | KEY_MOD1,
+ KEY_N | KEY_SHIFT | KEY_MOD1,
+ KEY_O | KEY_SHIFT | KEY_MOD1,
+ KEY_P | KEY_SHIFT | KEY_MOD1,
+ KEY_Q | KEY_SHIFT | KEY_MOD1,
+ KEY_R | KEY_SHIFT | KEY_MOD1,
+ KEY_S | KEY_SHIFT | KEY_MOD1,
+ KEY_T | KEY_SHIFT | KEY_MOD1,
+ KEY_U | KEY_SHIFT | KEY_MOD1,
+ KEY_V | KEY_SHIFT | KEY_MOD1,
+ KEY_W | KEY_SHIFT | KEY_MOD1,
+ KEY_X | KEY_SHIFT | KEY_MOD1,
+ KEY_Y | KEY_SHIFT | KEY_MOD1,
+ KEY_Z | KEY_SHIFT | KEY_MOD1,
+
+ KEY_F1 | KEY_SHIFT | KEY_MOD1,
+ KEY_F2 | KEY_SHIFT | KEY_MOD1,
+ KEY_F3 | KEY_SHIFT | KEY_MOD1,
+ KEY_F4 | KEY_SHIFT | KEY_MOD1,
+ KEY_F5 | KEY_SHIFT | KEY_MOD1,
+ KEY_F6 | KEY_SHIFT | KEY_MOD1,
+ KEY_F7 | KEY_SHIFT | KEY_MOD1,
+ KEY_F8 | KEY_SHIFT | KEY_MOD1,
+ KEY_F9 | KEY_SHIFT | KEY_MOD1,
+ KEY_F10 | KEY_SHIFT | KEY_MOD1,
+ KEY_F11 | KEY_SHIFT | KEY_MOD1,
+ KEY_F12 | KEY_SHIFT | KEY_MOD1,
+
+ KEY_DOWN | KEY_SHIFT | KEY_MOD1,
+ KEY_UP | KEY_SHIFT | KEY_MOD1,
+ KEY_LEFT | KEY_SHIFT | KEY_MOD1,
+ KEY_RIGHT | KEY_SHIFT | KEY_MOD1,
+ KEY_HOME | KEY_SHIFT | KEY_MOD1,
+ KEY_END | KEY_SHIFT | KEY_MOD1,
+ KEY_PAGEUP | KEY_SHIFT | KEY_MOD1,
+ KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD1,
+ KEY_RETURN | KEY_SHIFT | KEY_MOD1,
+ KEY_SPACE | KEY_SHIFT | KEY_MOD1,
+ KEY_BACKSPACE | KEY_SHIFT | KEY_MOD1,
+ KEY_INSERT | KEY_SHIFT | KEY_MOD1,
+ KEY_DELETE | KEY_SHIFT | KEY_MOD1,
+
+ KEY_0 | KEY_MOD2 ,
+ KEY_1 | KEY_MOD2 ,
+ KEY_2 | KEY_MOD2 ,
+ KEY_3 | KEY_MOD2 ,
+ KEY_4 | KEY_MOD2 ,
+ KEY_5 | KEY_MOD2 ,
+ KEY_6 | KEY_MOD2 ,
+ KEY_7 | KEY_MOD2 ,
+ KEY_8 | KEY_MOD2 ,
+ KEY_9 | KEY_MOD2 ,
+ KEY_A | KEY_MOD2 ,
+ KEY_B | KEY_MOD2 ,
+ KEY_C | KEY_MOD2 ,
+ KEY_D | KEY_MOD2 ,
+ KEY_E | KEY_MOD2 ,
+ KEY_F | KEY_MOD2 ,
+ KEY_G | KEY_MOD2 ,
+ KEY_H | KEY_MOD2 ,
+ KEY_I | KEY_MOD2 ,
+ KEY_J | KEY_MOD2 ,
+ KEY_K | KEY_MOD2 ,
+ KEY_L | KEY_MOD2 ,
+ KEY_M | KEY_MOD2 ,
+ KEY_N | KEY_MOD2 ,
+ KEY_O | KEY_MOD2 ,
+ KEY_P | KEY_MOD2 ,
+ KEY_Q | KEY_MOD2 ,
+ KEY_R | KEY_MOD2 ,
+ KEY_S | KEY_MOD2 ,
+ KEY_T | KEY_MOD2 ,
+ KEY_U | KEY_MOD2 ,
+ KEY_V | KEY_MOD2 ,
+ KEY_W | KEY_MOD2 ,
+ KEY_X | KEY_MOD2 ,
+ KEY_Y | KEY_MOD2 ,
+ KEY_Z | KEY_MOD2 ,
+
+ KEY_F1 | KEY_MOD2 ,
+ KEY_F2 | KEY_MOD2 ,
+ KEY_F3 | KEY_MOD2 ,
+ KEY_F4 | KEY_MOD2 ,
+ KEY_F5 | KEY_MOD2 ,
+ KEY_F6 | KEY_MOD2 ,
+ KEY_F7 | KEY_MOD2 ,
+ KEY_F8 | KEY_MOD2 ,
+ KEY_F9 | KEY_MOD2 ,
+ KEY_F10 | KEY_MOD2 ,
+ KEY_F11 | KEY_MOD2 ,
+ KEY_F12 | KEY_MOD2 ,
+
+ KEY_DOWN | KEY_MOD2 ,
+ KEY_UP | KEY_MOD2 ,
+ KEY_LEFT | KEY_MOD2 ,
+ KEY_RIGHT | KEY_MOD2 ,
+ KEY_HOME | KEY_MOD2 ,
+ KEY_END | KEY_MOD2 ,
+ KEY_PAGEUP | KEY_MOD2 ,
+ KEY_PAGEDOWN | KEY_MOD2 ,
+ KEY_RETURN | KEY_MOD2 ,
+ KEY_SPACE | KEY_MOD2 ,
+ KEY_BACKSPACE | KEY_MOD2 ,
+ KEY_INSERT | KEY_MOD2 ,
+ KEY_DELETE | KEY_MOD2 ,
+
+ KEY_0 | KEY_SHIFT | KEY_MOD2,
+ KEY_1 | KEY_SHIFT | KEY_MOD2,
+ KEY_2 | KEY_SHIFT | KEY_MOD2,
+ KEY_3 | KEY_SHIFT | KEY_MOD2,
+ KEY_4 | KEY_SHIFT | KEY_MOD2,
+ KEY_5 | KEY_SHIFT | KEY_MOD2,
+ KEY_6 | KEY_SHIFT | KEY_MOD2,
+ KEY_7 | KEY_SHIFT | KEY_MOD2,
+ KEY_8 | KEY_SHIFT | KEY_MOD2,
+ KEY_9 | KEY_SHIFT | KEY_MOD2,
+ KEY_A | KEY_SHIFT | KEY_MOD2,
+ KEY_B | KEY_SHIFT | KEY_MOD2,
+ KEY_C | KEY_SHIFT | KEY_MOD2,
+ KEY_D | KEY_SHIFT | KEY_MOD2,
+ KEY_E | KEY_SHIFT | KEY_MOD2,
+ KEY_F | KEY_SHIFT | KEY_MOD2,
+ KEY_G | KEY_SHIFT | KEY_MOD2,
+ KEY_H | KEY_SHIFT | KEY_MOD2,
+ KEY_I | KEY_SHIFT | KEY_MOD2,
+ KEY_J | KEY_SHIFT | KEY_MOD2,
+ KEY_K | KEY_SHIFT | KEY_MOD2,
+ KEY_L | KEY_SHIFT | KEY_MOD2,
+ KEY_M | KEY_SHIFT | KEY_MOD2,
+ KEY_N | KEY_SHIFT | KEY_MOD2,
+ KEY_O | KEY_SHIFT | KEY_MOD2,
+ KEY_P | KEY_SHIFT | KEY_MOD2,
+ KEY_Q | KEY_SHIFT | KEY_MOD2,
+ KEY_R | KEY_SHIFT | KEY_MOD2,
+ KEY_S | KEY_SHIFT | KEY_MOD2,
+ KEY_T | KEY_SHIFT | KEY_MOD2,
+ KEY_U | KEY_SHIFT | KEY_MOD2,
+ KEY_V | KEY_SHIFT | KEY_MOD2,
+ KEY_W | KEY_SHIFT | KEY_MOD2,
+ KEY_X | KEY_SHIFT | KEY_MOD2,
+ KEY_Y | KEY_SHIFT | KEY_MOD2,
+ KEY_Z | KEY_SHIFT | KEY_MOD2,
+
+ KEY_F1 | KEY_SHIFT | KEY_MOD2,
+ KEY_F2 | KEY_SHIFT | KEY_MOD2,
+ KEY_F3 | KEY_SHIFT | KEY_MOD2,
+ KEY_F4 | KEY_SHIFT | KEY_MOD2,
+ KEY_F5 | KEY_SHIFT | KEY_MOD2,
+ KEY_F6 | KEY_SHIFT | KEY_MOD2,
+ KEY_F7 | KEY_SHIFT | KEY_MOD2,
+ KEY_F8 | KEY_SHIFT | KEY_MOD2,
+ KEY_F9 | KEY_SHIFT | KEY_MOD2,
+ KEY_F10 | KEY_SHIFT | KEY_MOD2,
+ KEY_F11 | KEY_SHIFT | KEY_MOD2,
+ KEY_F12 | KEY_SHIFT | KEY_MOD2,
+
+ KEY_DOWN | KEY_SHIFT | KEY_MOD2,
+ KEY_UP | KEY_SHIFT | KEY_MOD2,
+ KEY_LEFT | KEY_SHIFT | KEY_MOD2,
+ KEY_RIGHT | KEY_SHIFT | KEY_MOD2,
+ KEY_HOME | KEY_SHIFT | KEY_MOD2,
+ KEY_END | KEY_SHIFT | KEY_MOD2,
+ KEY_PAGEUP | KEY_SHIFT | KEY_MOD2,
+ KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD2,
+ KEY_RETURN | KEY_SHIFT | KEY_MOD2,
+ KEY_SPACE | KEY_SHIFT | KEY_MOD2,
+ KEY_BACKSPACE | KEY_SHIFT | KEY_MOD2,
+ KEY_INSERT | KEY_SHIFT | KEY_MOD2,
+ KEY_DELETE | KEY_SHIFT | KEY_MOD2,
+
+ KEY_0 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_1 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_2 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_3 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_4 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_5 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_6 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_7 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_8 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_9 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_A | KEY_MOD1 | KEY_MOD2 ,
+ KEY_B | KEY_MOD1 | KEY_MOD2 ,
+ KEY_C | KEY_MOD1 | KEY_MOD2 ,
+ KEY_D | KEY_MOD1 | KEY_MOD2 ,
+ KEY_E | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F | KEY_MOD1 | KEY_MOD2 ,
+ KEY_G | KEY_MOD1 | KEY_MOD2 ,
+ KEY_H | KEY_MOD1 | KEY_MOD2 ,
+ KEY_I | KEY_MOD1 | KEY_MOD2 ,
+ KEY_J | KEY_MOD1 | KEY_MOD2 ,
+ KEY_K | KEY_MOD1 | KEY_MOD2 ,
+ KEY_L | KEY_MOD1 | KEY_MOD2 ,
+ KEY_M | KEY_MOD1 | KEY_MOD2 ,
+ KEY_N | KEY_MOD1 | KEY_MOD2 ,
+ KEY_O | KEY_MOD1 | KEY_MOD2 ,
+ KEY_P | KEY_MOD1 | KEY_MOD2 ,
+ KEY_Q | KEY_MOD1 | KEY_MOD2 ,
+ KEY_R | KEY_MOD1 | KEY_MOD2 ,
+ KEY_S | KEY_MOD1 | KEY_MOD2 ,
+ KEY_T | KEY_MOD1 | KEY_MOD2 ,
+ KEY_U | KEY_MOD1 | KEY_MOD2 ,
+ KEY_V | KEY_MOD1 | KEY_MOD2 ,
+ KEY_W | KEY_MOD1 | KEY_MOD2 ,
+ KEY_X | KEY_MOD1 | KEY_MOD2 ,
+ KEY_Y | KEY_MOD1 | KEY_MOD2 ,
+ KEY_Z | KEY_MOD1 | KEY_MOD2 ,
+
+ KEY_F1 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F2 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F3 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F4 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F5 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F6 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F7 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F8 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F9 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F10 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F11 | KEY_MOD1 | KEY_MOD2 ,
+ KEY_F12 | KEY_MOD1 | KEY_MOD2 ,
+
+ KEY_DOWN | KEY_MOD1 | KEY_MOD2 ,
+ KEY_UP | KEY_MOD1 | KEY_MOD2 ,
+ KEY_LEFT | KEY_MOD1 | KEY_MOD2 ,
+ KEY_RIGHT | KEY_MOD1 | KEY_MOD2 ,
+ KEY_HOME | KEY_MOD1 | KEY_MOD2 ,
+ KEY_END | KEY_MOD1 | KEY_MOD2 ,
+ KEY_PAGEUP | KEY_MOD1 | KEY_MOD2 ,
+ KEY_PAGEDOWN | KEY_MOD1 | KEY_MOD2 ,
+ KEY_RETURN | KEY_MOD1 | KEY_MOD2 ,
+ KEY_SPACE | KEY_MOD1 | KEY_MOD2 ,
+ KEY_BACKSPACE | KEY_MOD1 | KEY_MOD2 ,
+ KEY_INSERT | KEY_MOD1 | KEY_MOD2 ,
+ KEY_DELETE | KEY_MOD1 | KEY_MOD2 ,
+
+ KEY_0 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_1 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_2 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_3 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_4 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_5 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_6 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_7 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_8 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_9 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_A | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_B | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_C | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_D | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_E | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_G | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_H | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_I | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_J | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_K | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_L | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_M | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_N | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_O | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_P | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_Q | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_R | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_S | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_T | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_U | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_V | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_W | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_X | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_Y | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_Z | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+
+ KEY_F1 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F2 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F3 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F4 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F5 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F6 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F7 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F8 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F9 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F10 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F11 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_F12 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+
+ KEY_DOWN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_UP | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_LEFT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_RIGHT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_HOME | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_END | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_PAGEUP | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_RETURN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_SPACE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_BACKSPACE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_INSERT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
+ KEY_DELETE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2
+};
+
+static USHORT KEYCODE_ARRAY_SIZE = (sizeof(KEYCODE_ARRAY) / sizeof(KEYCODE_ARRAY[0]));
+
+//-----------------------------------------------
+// seems to be needed to layout the list box, which shows all
+// assignable shortcuts
+static long AccCfgTabs[] =
+{
+ 2, // Number of Tabs
+ 0,
+ 120 // Function
+};
+
+//-----------------------------------------------
+class SfxAccCfgLBoxString_Impl : public SvLBoxString
+{
+ public:
+ SfxAccCfgLBoxString_Impl( SvLBoxEntry* pEntry,
+ USHORT nFlags,
+ const String& sText );
+
+ virtual ~SfxAccCfgLBoxString_Impl();
+
+ virtual void Paint(const Point& aPos ,
+ SvLBox& rDevice,
+ USHORT nFlags ,
+ SvLBoxEntry* pEntry );
+};
+
+//-----------------------------------------------
+SfxAccCfgLBoxString_Impl::SfxAccCfgLBoxString_Impl( SvLBoxEntry* pEntry,
+ USHORT nFlags,
+ const String& sText )
+ : SvLBoxString(pEntry, nFlags, sText)
+{
+}
+
+//-----------------------------------------------
+SfxAccCfgLBoxString_Impl::~SfxAccCfgLBoxString_Impl()
+{
+}
+
+//-----------------------------------------------
+void SfxAccCfgLBoxString_Impl::Paint(const Point& aPos ,
+ SvLBox& rDevice,
+ USHORT /*nFlags*/,
+ SvLBoxEntry* pEntry )
+{
+ /*/ ??? realy needed !!!
+ Font aOldFont(rDevice.GetFont());
+ Font aNewFont(aOldFont );
+ rDevice.SetFont( aFont );
+ */
+
+ if (!pEntry)
+ return;
+
+ TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
+ if (!pUserData)
+ return;
+
+ if (pUserData->m_bIsConfigurable)
+ rDevice.DrawText(aPos, GetText());
+ else
+ rDevice.DrawCtrlText(aPos, GetText(), 0, STRING_LEN, TEXT_DRAW_DISABLE);
+
+ //rDev.SetFont( aOldFont );
+}
+
+//-----------------------------------------------
+void SfxAccCfgTabListBox_Impl::InitEntry( SvLBoxEntry* pEntry ,
+ const XubString& sText ,
+ const Image& aImage1,
+ const Image& aImage2,
+ SvLBoxButtonKind eButtonKind)
+{
+ SvTabListBox::InitEntry(pEntry, sText, aImage1, aImage2, eButtonKind);
+}
+
+//-----------------------------------------------
+/** select the entry, which match the current key input ... excepting
+ keys, which are used for the dialog itself.
+ */
+void SfxAccCfgTabListBox_Impl::KeyInput(const KeyEvent& aKey)
+{
+ KeyCode aCode1 = aKey.GetKeyCode();
+ USHORT nCode1 = aCode1.GetCode();
+ USHORT nMod1 = aCode1.GetModifier();
+
+ // is it related to our list box ?
+ if (
+ (nCode1 != KEY_DOWN ) &&
+ (nCode1 != KEY_UP ) &&
+ (nCode1 != KEY_LEFT ) &&
+ (nCode1 != KEY_RIGHT ) &&
+ (nCode1 != KEY_PAGEUP ) &&
+ (nCode1 != KEY_PAGEDOWN)
+ )
+ {
+ SvLBoxEntry* pEntry = First();
+ while (pEntry)
+ {
+ TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
+ if (pUserData)
+ {
+ USHORT nCode2 = pUserData->m_aKey.GetCode();
+ USHORT nMod2 = pUserData->m_aKey.GetModifier();
+ if (
+ (nCode1 == nCode2) &&
+ (nMod1 == nMod2 )
+ )
+ {
+ Select (pEntry);
+ MakeVisible(pEntry);
+ return;
+ }
+ }
+ pEntry = Next(pEntry);
+ }
+ }
+
+ // no - handle it as normal dialog input
+ SvTabListBox::KeyInput(aKey);
+}
+
+//-----------------------------------------------
+SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( Window* pParent, const SfxItemSet& aSet )
+ : SfxTabPage (pParent, CUI_RES(RID_SVXPAGE_KEYBOARD), aSet)
+ , m_pMacroInfoItem ()
+ , m_pStringItem ()
+ , m_pFontItem ()
+ , m_pFileDlg (NULL)
+ , aEntriesBox (this , this, CUI_RES(BOX_ACC_ENTRIES ))
+ , aKeyboardGroup (this , CUI_RES(GRP_ACC_KEYBOARD ))
+ , aOfficeButton (this , CUI_RES(RB_OFFICE ))
+ , aModuleButton (this , CUI_RES(RB_MODULE ))
+ , aChangeButton (this , CUI_RES(BTN_ACC_CHANGE ))
+ , aRemoveButton (this , CUI_RES(BTN_ACC_REMOVE ))
+ , aGroupText (this , CUI_RES(TXT_ACC_GROUP ))
+ , pGroupLBox(new SfxConfigGroupListBox_Impl( this, CUI_RES(BOX_ACC_GROUP), SFX_SLOT_ACCELCONFIG ))
+ , aFunctionText (this , CUI_RES(TXT_ACC_FUNCTION ))
+ , pFunctionBox(new SfxConfigFunctionListBox_Impl( this, CUI_RES( BOX_ACC_FUNCTION )))
+ , aKeyText (this , CUI_RES(TXT_ACC_KEY ))
+ , aKeyBox (this , CUI_RES(BOX_ACC_KEY ))
+ , aFunctionsGroup (this , CUI_RES(GRP_ACC_FUNCTIONS ))
+ , aLoadButton (this , CUI_RES(BTN_LOAD ))
+ , aSaveButton (this , CUI_RES(BTN_SAVE ))
+ , aResetButton (this , CUI_RES(BTN_RESET ))
+ , aLoadAccelConfigStr ( CUI_RES( STR_LOADACCELCONFIG ) )
+ , aSaveAccelConfigStr ( CUI_RES( STR_SAVEACCELCONFIG ) )
+ , aFilterAllStr ( CUI_RES( STR_SFX_FILTERNAME_ALL ) )
+ , aFilterCfgStr ( CUI_RES( STR_FILTERNAME_CFG ) )
+ , m_bStylesInfoInitialized(sal_False)
+ , m_xGlobal ()
+ , m_xModule ()
+ , m_xAct ()
+{
+ FreeResource();
+
+// install handler functions
+ aChangeButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, ChangeHdl ));
+ aRemoveButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RemoveHdl ));
+ aEntriesBox.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
+ pGroupLBox->SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
+ pFunctionBox->SetSelectHdl( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
+ aKeyBox.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
+ aLoadButton.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage, Load ));
+ aSaveButton.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage, Save ));
+ aResetButton.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage, Default ));
+ aOfficeButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RadioHdl ));
+ aModuleButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RadioHdl ));
+
+ // initialize Entriesbox
+ aEntriesBox.SetWindowBits(WB_HSCROLL|WB_CLIPCHILDREN);
+ aEntriesBox.SetSelectionMode(SINGLE_SELECTION);
+ aEntriesBox.SetTabs(&AccCfgTabs[0], MAP_APPFONT);
+ aEntriesBox.Resize(); // OS: Hack for right selection
+ aEntriesBox.SetSpaceBetweenEntries(0);
+ aEntriesBox.SetDragDropMode(0);
+
+ // detect max keyname width
+ long nMaxWidth = 0;
+ for ( USHORT i = 0; i < KEYCODE_ARRAY_SIZE; ++i )
+ {
+ long nTmp = GetTextWidth( KeyCode( KEYCODE_ARRAY[i] ).GetName() );
+ if ( nTmp > nMaxWidth )
+ nMaxWidth = nTmp;
+ }
+ // recalc second tab
+ long nNewTab = PixelToLogic( Size( nMaxWidth, 0 ), MAP_APPFONT ).Width();
+ nNewTab = nNewTab + 5; // additional space
+ aEntriesBox.SetTab( 1, nNewTab );
+
+ // initialize GroupBox
+ pGroupLBox->SetFunctionListBox(pFunctionBox);
+
+ // initialize KeyBox
+ aKeyBox.SetWindowBits(WB_CLIPCHILDREN|WB_HSCROLL|WB_SORT);
+}
+
+//-----------------------------------------------
+SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
+{
+ // free memory - remove all dynamic user data
+ SvLBoxEntry* pEntry = aEntriesBox.First();
+ while (pEntry)
+ {
+ TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
+ if (pUserData)
+ delete pUserData;
+ pEntry = aEntriesBox.Next(pEntry);
+ }
+
+ pEntry = aKeyBox.First();
+ while (pEntry)
+ {
+ TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
+ if (pUserData)
+ delete pUserData;
+ pEntry = aKeyBox.Next(pEntry);
+ }
+
+ aEntriesBox.Clear();
+ aKeyBox.Clear();
+
+ delete m_pFileDlg;
+ delete pGroupLBox;
+ delete pFunctionBox;
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::InitAccCfg()
+{
+ // already initialized ?
+ if (m_xSMGR.is())
+ return; // yes -> do nothing
+
+ try
+ {
+ // no - initialize this instance
+ m_xSMGR = ::utl::getProcessServiceFactory();
+
+ m_xUICmdDescription = css::uno::Reference< css::container::XNameAccess >(m_xSMGR->createInstance(SERVICE_UICMDDESCRIPTION), css::uno::UNO_QUERY_THROW);
+
+ // get the current active frame, which should be our "parent"
+ // for this session
+ m_xFrame = GetFrame();
+ if ( !m_xFrame.is() )
+ {
+ css::uno::Reference< css::frame::XFramesSupplier > xDesktop(m_xSMGR->createInstance(SERVICE_DESKTOP), css::uno::UNO_QUERY_THROW);
+ m_xFrame = xDesktop->getActiveFrame();
+ }
+
+ // identify module
+ css::uno::Reference< css::frame::XModuleManager > xModuleManager (m_xSMGR->createInstance(SERVICE_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::container::XNameAccess > xModuleManagerCont(xModuleManager , css::uno::UNO_QUERY_THROW);
+ m_sModuleLongName = xModuleManager->identify(m_xFrame);
+ ::comphelper::SequenceAsHashMap lModuleProps(xModuleManagerCont->getByName(m_sModuleLongName));
+ m_sModuleShortName = lModuleProps.getUnpackedValueOrDefault(MODULEPROP_SHORTNAME, ::rtl::OUString());
+ m_sModuleUIName = lModuleProps.getUnpackedValueOrDefault(MODULEPROP_UINAME , ::rtl::OUString());
+
+ // get global accelerator configuration
+ m_xGlobal = css::uno::Reference< css::ui::XAcceleratorConfiguration >(m_xSMGR->createInstance(SERVICE_GLOBALACCCFG), css::uno::UNO_QUERY_THROW);
+
+ // get module accelerator configuration
+ css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier(m_xSMGR->createInstance(SERVICE_MODULEUICONFIGSUPPLIER), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::ui::XUIConfigurationManager > xUICfgManager = xModuleCfgSupplier->getUIConfigurationManager(m_sModuleLongName);
+ m_xModule = css::uno::Reference< css::ui::XAcceleratorConfiguration >(xUICfgManager->getShortCutManager(), css::uno::UNO_QUERY_THROW);
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ { m_xSMGR.clear(); }
+}
+
+//-----------------------------------------------
+/** Initialize text columns with own class to enable custom painting
+ This is needed as we have to paint disabled entries by ourself. No support for that in the
+ original SvTabListBox!
+ */
+void SfxAcceleratorConfigPage::CreateCustomItems( SvLBoxEntry* pEntry,
+ const String& sCol1 ,
+ const String& sCol2 )
+{
+ SfxAccCfgLBoxString_Impl* pStringItem = new SfxAccCfgLBoxString_Impl(pEntry, 0, sCol1);
+ pEntry->ReplaceItem(pStringItem, 1);
+
+ pStringItem = new SfxAccCfgLBoxString_Impl(pEntry, 0, sCol2);
+ pEntry->ReplaceItem(pStringItem, 2);
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xAccMgr)
+{
+ if (!xAccMgr.is())
+ return;
+
+ if (!m_bStylesInfoInitialized)
+ {
+ css::uno::Reference< css::frame::XController > xController;
+ css::uno::Reference< css::frame::XModel > xModel;
+ if (m_xFrame.is())
+ xController = m_xFrame->getController();
+ if (xController.is())
+ xModel = xController->getModel();
+
+ m_aStylesInfo.setModel(xModel);
+ pFunctionBox->SetStylesInfo(&m_aStylesInfo);
+ pGroupLBox->SetStylesInfo(&m_aStylesInfo);
+ m_bStylesInfoInitialized = sal_True;
+ }
+
+ // Insert all editable accelerators into list box. It is possible
+ // that some accelerators are not mapped on the current system/keyboard
+ // but we don't want to lose these mappings.
+ USHORT c1 = KEYCODE_ARRAY_SIZE;
+ USHORT i1 = 0;
+ USHORT nListPos = 0;
+ for (i1=0; i1<c1; ++i1)
+ {
+ KeyCode aKey = KEYCODE_ARRAY[i1];
+ String sKey = aKey.GetName();
+ if (!sKey.Len())
+ continue;
+ TAccInfo* pEntry = new TAccInfo(i1, nListPos, aKey);
+ SvLBoxEntry* pLBEntry = aEntriesBox.InsertEntryToColumn(sKey, 0L, LIST_APPEND, 0xFFFF);
+ pLBEntry->SetUserData(pEntry);
+ }
+
+ // Assign all commands to its shortcuts - reading the accelerator config.
+ css::uno::Sequence< css::awt::KeyEvent > lKeys = xAccMgr->getAllKeyEvents();
+ sal_Int32 c2 = lKeys.getLength();
+ sal_Int32 i2 = 0;
+ USHORT nCol = aEntriesBox.TabCount()-1;
+
+ for (i2=0; i2<c2; ++i2)
+ {
+ const css::awt::KeyEvent& aAWTKey = lKeys[i2];
+ ::rtl::OUString sCommand = xAccMgr->getCommandByKeyEvent(aAWTKey);
+ String sLabel = GetLabel4Command(sCommand);
+ KeyCode aKeyCode = ::svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey);
+ USHORT nPos = MapKeyCodeToPos(aKeyCode);
+
+ if (nPos == LISTBOX_ENTRY_NOTFOUND)
+ continue;
+
+ aEntriesBox.SetEntryText(sLabel, nPos, nCol);
+
+ SvLBoxEntry* pLBEntry = aEntriesBox.GetEntry(0, nPos);
+ TAccInfo* pEntry = (TAccInfo*)pLBEntry->GetUserData();
+
+ pEntry->m_bIsConfigurable = sal_True;
+ pEntry->m_sCommand = sCommand;
+ CreateCustomItems(pLBEntry, aEntriesBox.GetEntryText(pLBEntry, 0), sLabel);
+ }
+
+ // Map the VCL hardcoded key codes and mark them as not changeable
+ ULONG c3 = Application::GetReservedKeyCodeCount();
+ ULONG i3 = 0;
+ for (i3=0; i3<c3; ++i3)
+ {
+ const KeyCode* pKeyCode = Application::GetReservedKeyCode(i3);
+ USHORT nPos = MapKeyCodeToPos(*pKeyCode);
+
+ if (nPos == LISTBOX_ENTRY_NOTFOUND)
+ continue;
+
+ // Hardcoded function mapped so no ID possible and mark entry as not changeable
+ SvLBoxEntry* pLBEntry = aEntriesBox.GetEntry(0, nPos);
+ TAccInfo* pEntry = (TAccInfo*)pLBEntry->GetUserData();
+
+ pEntry->m_bIsConfigurable = sal_False;
+ CreateCustomItems(pLBEntry, aEntriesBox.GetEntryText(pLBEntry, 0), String());
+ }
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xAccMgr)
+{
+ if (!xAccMgr.is())
+ return;
+
+ // Go through the list from the bottom to the top ...
+ // because logical accelerator must be preferred instead of
+ // physical ones!
+ SvLBoxEntry* pEntry = aEntriesBox.First();
+ while (pEntry)
+ {
+ TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
+ ::rtl::OUString sCommand ;
+ css::awt::KeyEvent aAWTKey ;
+
+ if (pUserData)
+ {
+ sCommand = pUserData->m_sCommand;
+ aAWTKey = ::svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData->m_aKey);
+ }
+
+ try
+ {
+ if (sCommand.getLength())
+ xAccMgr->setKeyEvent(aAWTKey, sCommand);
+ else
+ xAccMgr->removeKeyEvent(aAWTKey);
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ {}
+
+ pEntry = aEntriesBox.Next(pEntry);
+ }
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::ResetConfig()
+{
+ aEntriesBox.Clear();
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, Load, Button*, EMPTYARG )
+{
+ // ask for filename, where we should load the new config data from
+ StartFileDialog( WB_OPEN | WB_STDMODAL | WB_3DLOOK, aLoadAccelConfigStr );
+ return 0;
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, Save, Button*, EMPTYARG )
+{
+ StartFileDialog( WB_SAVEAS | WB_STDMODAL | WB_3DLOOK, aLoadAccelConfigStr );
+ return 0;
+}
+
+//-----------------------------------------------
+IMPL_LINK(SfxAcceleratorConfigPage, Default, PushButton*, EMPTYARG)
+{
+ css::uno::Reference< css::form::XReset > xReset(m_xAct, css::uno::UNO_QUERY);
+ if (xReset.is())
+ xReset->reset();
+
+ aEntriesBox.SetUpdateMode(FALSE);
+ ResetConfig();
+ Init(m_xAct);
+ aEntriesBox.SetUpdateMode(TRUE);
+ aEntriesBox.Invalidate();
+ aEntriesBox.Select(aEntriesBox.GetEntry(0, 0));
+
+ return 0;
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, ChangeHdl, Button*, EMPTYARG )
+{
+ USHORT nPos = (USHORT) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
+ TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
+ String sNewCommand = pFunctionBox->GetCurCommand();
+ String sLabel = pFunctionBox->GetCurLabel();
+ if (!sLabel.Len())
+ sLabel = GetLabel4Command(sNewCommand);
+
+ pEntry->m_sCommand = sNewCommand;
+ USHORT nCol = aEntriesBox.TabCount() - 1;
+ aEntriesBox.SetEntryText(sLabel, nPos, nCol);
+
+ ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
+ return 0;
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, RemoveHdl, Button *, EMPTYARG )
+{
+ // get selected entry
+ USHORT nPos = (USHORT) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
+ TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
+
+ // remove function name from selected entry
+ USHORT nCol = aEntriesBox.TabCount() - 1;
+ aEntriesBox.SetEntryText( String(), nPos, nCol );
+ pEntry->m_sCommand = ::rtl::OUString();
+
+ ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
+ return 0;
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, SelectHdl, Control*, pListBox )
+{
+ // disable help
+ Help::ShowBalloon( this, Point(), String() );
+ if ( pListBox == &aEntriesBox )
+ {
+ USHORT nPos = (USHORT) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
+ TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
+ ::rtl::OUString sPossibleNewCommand = pFunctionBox->GetCurCommand();
+
+ aRemoveButton.Enable( FALSE );
+ aChangeButton.Enable( FALSE );
+
+ if (pEntry->m_bIsConfigurable)
+ {
+ if (pEntry->isConfigured())
+ aRemoveButton.Enable( TRUE );
+ aChangeButton.Enable( pEntry->m_sCommand != sPossibleNewCommand );
+ }
+ }
+ else if ( pListBox == pGroupLBox )
+ {
+ pGroupLBox->GroupSelected();
+ if ( !pFunctionBox->FirstSelected() )
+ aChangeButton.Enable( FALSE );
+ }
+ else if ( pListBox == pFunctionBox )
+ {
+ aRemoveButton.Enable( FALSE );
+ aChangeButton.Enable( FALSE );
+
+ // #i36994 First selected can return zero!
+ SvLBoxEntry* pLBEntry = aEntriesBox.FirstSelected();
+ if ( pLBEntry != 0 )
+ {
+ USHORT nPos = (USHORT) aEntriesBox.GetModel()->GetRelPos( pLBEntry );
+ TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
+ ::rtl::OUString sPossibleNewCommand = pFunctionBox->GetCurCommand();
+
+ if (pEntry->m_bIsConfigurable)
+ {
+ if (pEntry->isConfigured())
+ aRemoveButton.Enable( TRUE );
+ aChangeButton.Enable( pEntry->m_sCommand != sPossibleNewCommand );
+ }
+
+ // update key box
+ aKeyBox.Clear();
+ SvLBoxEntry* pIt = aEntriesBox.First();
+ while ( pIt )
+ {
+ TAccInfo* pUserData = (TAccInfo*)pIt->GetUserData();
+ if ( pUserData && pUserData->m_sCommand == sPossibleNewCommand )
+ {
+ TAccInfo* pU1 = new TAccInfo(-1, -1, pUserData->m_aKey);
+ SvLBoxEntry* pE1 = aKeyBox.InsertEntry( pUserData->m_aKey.GetName(), 0L, TRUE, LIST_APPEND );
+ pE1->SetUserData(pU1);
+ pE1->EnableChildsOnDemand( FALSE );
+ }
+ pIt = aEntriesBox.Next(pIt);
+ }
+ }
+ }
+ else
+ {
+ // goto selected "key" entry of the key box
+ SvLBoxEntry* pE2 = 0;
+ TAccInfo* pU2 = 0;
+ USHORT nP2 = LISTBOX_ENTRY_NOTFOUND;
+ SvLBoxEntry* pE3 = 0;
+
+ pE2 = aKeyBox.FirstSelected();
+ if (pE2)
+ pU2 = (TAccInfo*)pE2->GetUserData();
+ if (pU2)
+ nP2 = MapKeyCodeToPos(pU2->m_aKey);
+ if (nP2 != LISTBOX_ENTRY_NOTFOUND)
+ pE3 = aEntriesBox.GetEntry( 0, nP2 );
+ if (pE3)
+ {
+ aEntriesBox.Select( pE3 );
+ aEntriesBox.MakeVisible( pE3 );
+ }
+ }
+
+ return 0;
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, RadioHdl, RadioButton *, EMPTYARG )
+{
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xOld = m_xAct;
+
+ if (aOfficeButton.IsChecked())
+ m_xAct = m_xGlobal;
+ else if (aModuleButton.IsChecked())
+ m_xAct = m_xModule;
+
+ // nothing changed? => do nothing!
+ if ( m_xAct.is() && ( xOld == m_xAct ) )
+ return 0;
+
+ aEntriesBox.SetUpdateMode( FALSE );
+ ResetConfig();
+ Init(m_xAct);
+ aEntriesBox.SetUpdateMode( TRUE );
+ aEntriesBox.Invalidate();
+
+ pGroupLBox->Init(m_xSMGR, m_xFrame, m_sModuleLongName);
+
+ // pb: #133213# do not select NULL entries
+ SvLBoxEntry* pEntry = aEntriesBox.GetEntry( 0, 0 );
+ if ( pEntry )
+ aEntriesBox.Select( pEntry );
+ pEntry = pGroupLBox->GetEntry( 0, 0 );
+ if ( pEntry )
+ pGroupLBox->Select( pEntry );
+
+ ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
+ return 1L;
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, LoadHdl, sfx2::FileDialogHelper*, EMPTYARG )
+{
+ DBG_ASSERT( m_pFileDlg, "SfxInternetPage::DialogClosedHdl(): no file dialog" );
+
+ ::rtl::OUString sCfgName;
+ if ( ERRCODE_NONE == m_pFileDlg->GetError() )
+ sCfgName = m_pFileDlg->GetPath();
+
+ if ( !sCfgName.getLength() )
+ return 0;
+
+ GetTabDialog()->EnterWait();
+
+ css::uno::Reference< css::frame::XModel > xDoc ;
+ css::uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr ;
+ css::uno::Reference< css::embed::XStorage > xRootStorage; // we must hold the root storage alive, if xCfgMgr is used!
+
+ try
+ {
+ // first check if URL points to a document already loaded
+ xDoc = SearchForAlreadyLoadedDoc(sCfgName);
+ if (xDoc.is())
+ {
+ // Get ui config manager. There should always be one at the model.
+ css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xCfgSupplier(xDoc, css::uno::UNO_QUERY_THROW);
+ xCfgMgr = xCfgSupplier->getUIConfigurationManager();
+ }
+ else
+ {
+ // URL doesn't point to a loaded document, try to access it as a single storage
+ // dont forget to release the storage afterwards!
+ css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(m_xSMGR->createInstance(SERVICE_STORAGEFACTORY), css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence< css::uno::Any > lArgs(2);
+ lArgs[0] <<= sCfgName;
+ lArgs[1] <<= css::embed::ElementModes::READ;
+
+ xRootStorage = css::uno::Reference< css::embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::embed::XStorage > xUIConfig = xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, css::embed::ElementModes::READ);
+ if (xUIConfig.is())
+ {
+ xCfgMgr = css::uno::Reference< css::ui::XUIConfigurationManager >(m_xSMGR->createInstance(SERVICE_UICONFIGMGR), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::ui::XUIConfigurationStorage > xCfgMgrStore(xCfgMgr, css::uno::UNO_QUERY_THROW);
+ xCfgMgrStore->setStorage(xUIConfig);
+ }
+ }
+
+ if (xCfgMgr.is())
+ {
+ // open the configuration and update our UI
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xTempAccMgr(xCfgMgr->getShortCutManager(), css::uno::UNO_QUERY_THROW);
+
+ aEntriesBox.SetUpdateMode(FALSE);
+ ResetConfig();
+ Init(xTempAccMgr);
+ aEntriesBox.SetUpdateMode(TRUE);
+ aEntriesBox.Invalidate();
+ aEntriesBox.Select(aEntriesBox.GetEntry(0, 0));
+
+ }
+
+ // dont forget to close the new opened storage!
+ // We are the owner of it.
+ if (xRootStorage.is())
+ {
+ css::uno::Reference< css::lang::XComponent > xComponent;
+ xComponent = css::uno::Reference< css::lang::XComponent >(xCfgMgr, css::uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+ xComponent = css::uno::Reference< css::lang::XComponent >(xRootStorage, css::uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+ }
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ {}
+
+ GetTabDialog()->LeaveWait();
+
+ return 0;
+}
+
+//-----------------------------------------------
+IMPL_LINK( SfxAcceleratorConfigPage, SaveHdl, sfx2::FileDialogHelper*, EMPTYARG )
+{
+ DBG_ASSERT( m_pFileDlg, "SfxInternetPage::DialogClosedHdl(): no file dialog" );
+
+ ::rtl::OUString sCfgName;
+ if ( ERRCODE_NONE == m_pFileDlg->GetError() )
+ sCfgName = m_pFileDlg->GetPath();
+
+ if ( !sCfgName.getLength() )
+ return 0;
+
+ GetTabDialog()->EnterWait();
+
+ css::uno::Reference< css::frame::XModel > xDoc ;
+ css::uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr ;
+ css::uno::Reference< css::embed::XStorage > xRootStorage;
+
+ try
+ {
+ // first check if URL points to a document already loaded
+ xDoc = SearchForAlreadyLoadedDoc(sCfgName);
+ if (xDoc.is())
+ {
+ // get config manager, force creation if there was none before
+ css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xCfgSupplier(xDoc, css::uno::UNO_QUERY_THROW);
+ xCfgMgr = xCfgSupplier->getUIConfigurationManager();
+ }
+ else
+ {
+ // URL doesn't point to a loaded document, try to access it as a single storage
+ css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(m_xSMGR->createInstance(SERVICE_STORAGEFACTORY), css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence< css::uno::Any > lArgs(2);
+ lArgs[0] <<= sCfgName;
+ lArgs[1] <<= css::embed::ElementModes::WRITE;
+
+ xRootStorage = css::uno::Reference< css::embed::XStorage >(
+ xStorageFactory->createInstanceWithArguments(lArgs),
+ css::uno::UNO_QUERY_THROW);
+
+ css::uno::Reference< css::embed::XStorage > xUIConfig(
+ xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, css::embed::ElementModes::WRITE),
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::beans::XPropertySet > xUIConfigProps(
+ xUIConfig,
+ css::uno::UNO_QUERY_THROW);
+
+ // set the correct media type if the storage was new created
+ ::rtl::OUString sMediaType;
+ xUIConfigProps->getPropertyValue(MEDIATYPE_PROPNAME) >>= sMediaType;
+ if (!sMediaType.getLength())
+ xUIConfigProps->setPropertyValue(MEDIATYPE_PROPNAME, css::uno::makeAny(MEDIATYPE_UICONFIG));
+
+ xCfgMgr = css::uno::Reference< css::ui::XUIConfigurationManager >(m_xSMGR->createInstance(SERVICE_UICONFIGMGR), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::ui::XUIConfigurationStorage > xUICfgStore(xCfgMgr, css::uno::UNO_QUERY_THROW);
+ xUICfgStore->setStorage(xUIConfig);
+ }
+
+ if (xCfgMgr.is())
+ {
+ // get the target configuration access and update with all shortcuts
+ // which are set currently at the UI !
+ // Dont copy the m_xAct content to it ... because m_xAct will be updated
+ // from the UI on pressing the button "OK" only. And inbetween it's not up to date !
+ css::uno::Reference< css::ui::XAcceleratorConfiguration > xTargetAccMgr(xCfgMgr->getShortCutManager(), css::uno::UNO_QUERY_THROW);
+ Apply(xTargetAccMgr);
+
+ // commit (order is important!)
+ css::uno::Reference< css::ui::XUIConfigurationPersistence > xCommit1(xTargetAccMgr, css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::ui::XUIConfigurationPersistence > xCommit2(xCfgMgr , css::uno::UNO_QUERY_THROW);
+ xCommit1->store();
+ xCommit2->store();
+
+ if (xRootStorage.is())
+ {
+ // Commit root storage
+ css::uno::Reference< css::embed::XTransactedObject > xCommit3(xRootStorage, css::uno::UNO_QUERY_THROW);
+ xCommit3->commit();
+ }
+ }
+
+ if (xRootStorage.is())
+ {
+ css::uno::Reference< css::lang::XComponent > xComponent;
+ xComponent = css::uno::Reference< css::lang::XComponent >(xCfgMgr, css::uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+ xComponent = css::uno::Reference< css::lang::XComponent >(xRootStorage, css::uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose();
+ }
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ {}
+
+ GetTabDialog()->LeaveWait();
+
+ return 0;
+}
+
+::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL )
+{
+ ::rtl::OUString aLabel;
+ if ( aCmdURL.getLength() )
+ {
+ try
+ {
+ uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY );
+ if ( xNameAccess.is() )
+ {
+ uno::Reference< container::XNameAccess > xUICommandLabels;
+ const ::rtl::OUString aModule( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) );
+ uno::Any a = xNameAccess->getByName( aModule );
+ uno::Reference< container::XNameAccess > xUICommands;
+ a >>= xUICommandLabels;
+ rtl::OUString aStr;
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ a = xUICommandLabels->getByName( aCmdURL );
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if ( aPropSeq[i].Name.equalsAscii( "Name" ))
+ {
+ aPropSeq[i].Value >>= aStr;
+ break;
+ }
+ }
+ }
+ aLabel = aStr;
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+
+ return aLabel;
+}
+
+
+//-----------------------------------------------
+String SfxAcceleratorConfigPage::GetFunctionName(KeyFuncType eType) const
+{
+ ::rtl::OUStringBuffer sName(256);
+ sName.appendAscii("\"");
+ switch(eType)
+ {
+ case KEYFUNC_NEW :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:NewDoc") ) );
+ break;
+
+ case KEYFUNC_OPEN :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Open") ) );
+ break;
+
+ case KEYFUNC_SAVE :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Save") ) );
+ break;
+
+ case KEYFUNC_SAVEAS :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:SaveAs") ) );
+ break;
+
+ case KEYFUNC_PRINT :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Print") ) );
+ break;
+
+ case KEYFUNC_CLOSE :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Close") ) );
+ break;
+
+ case KEYFUNC_QUIT :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Quit") ) );
+ break;
+
+ case KEYFUNC_CUT :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Cut") ) );
+ break;
+
+ case KEYFUNC_COPY :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Copy") ) );
+ break;
+
+ case KEYFUNC_PASTE :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Paste") ) );
+ break;
+
+ case KEYFUNC_UNDO :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Undo") ) );
+ break;
+
+ case KEYFUNC_REDO :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Redo") ) );
+ break;
+
+ case KEYFUNC_DELETE :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Delete") ) );
+ break;
+
+ case KEYFUNC_REPEAT :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Repeat") ) );
+ break;
+
+ case KEYFUNC_FIND :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Search") ) );
+ break;
+
+ case KEYFUNC_FINDBACKWARD :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:SearchBackwards") ) );
+ break;
+
+ case KEYFUNC_PROPERTIES :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Options") ) );
+ break;
+
+ case KEYFUNC_FRONT :
+ sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:ToFront") ) );
+ break;
+
+ default:
+ break;
+ }
+ sName.appendAscii("\"");
+ return String(sName.makeStringAndClear());
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::StartFileDialog( WinBits nBits, const String& rTitle )
+{
+ bool bSave = ( ( nBits & WB_SAVEAS ) == WB_SAVEAS );
+ short nDialogType = bSave ? css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
+ : css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
+ if ( m_pFileDlg )
+ delete m_pFileDlg;
+ m_pFileDlg = new sfx2::FileDialogHelper( nDialogType, 0 );
+
+ m_pFileDlg->SetTitle( rTitle );
+// m_pFileDlg->SetDialogHelpId( bSave ? HID_CONFIG_SAVE : HID_CONFIG_LOAD );
+ m_pFileDlg->AddFilter( aFilterAllStr, DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ) );
+ m_pFileDlg->AddFilter( aFilterCfgStr, DEFINE_CONST_UNICODE( "*.cfg" ) );
+
+ Link aDlgClosedLink = bSave ? LINK( this, SfxAcceleratorConfigPage, SaveHdl )
+ : LINK( this, SfxAcceleratorConfigPage, LoadHdl );
+ m_pFileDlg->StartExecuteModal( aDlgClosedLink );
+}
+
+//-----------------------------------------------
+BOOL SfxAcceleratorConfigPage::FillItemSet( SfxItemSet& )
+{
+ Apply(m_xAct);
+ try
+ {
+ m_xAct->store();
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ { return FALSE; }
+
+ return TRUE;
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::Reset( const SfxItemSet& rSet )
+{
+ // open accelerator configs
+ // Note: It initialize some other members too, which are needed here ...
+ // e.g. m_sModuleUIName!
+ InitAccCfg();
+
+ // change te description of the radio button, which switch to the module
+ // dependend accelerator configuration
+ String sButtonText = aModuleButton.GetText();
+ sButtonText.SearchAndReplace(String::CreateFromAscii("$(MODULE)"), m_sModuleUIName);
+ aModuleButton.SetText(sButtonText);
+
+ if (m_xModule.is())
+ aModuleButton.Check();
+ else
+ {
+ aModuleButton.Hide();
+ aOfficeButton.Check();
+ }
+
+ RadioHdl(0);
+
+ const SfxPoolItem* pMacroItem=0;
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_MACROINFO, TRUE, &pMacroItem ) )
+ {
+ m_pMacroInfoItem = PTR_CAST( SfxMacroInfoItem, pMacroItem );
+ pGroupLBox->SelectMacro( m_pMacroInfoItem );
+ }
+ else
+ {
+ const SfxPoolItem* pStringItem=0;
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_CHARMAP, TRUE, &pStringItem ) )
+ m_pStringItem = PTR_CAST( SfxStringItem, pStringItem );
+
+ const SfxPoolItem* pFontItem=0;
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_SPECIALCHAR, TRUE, &pFontItem ) )
+ m_pFontItem = PTR_CAST( SfxStringItem, pFontItem );
+
+ if ( m_pStringItem )
+ pGroupLBox->AddAndSelect( m_pStringItem, m_pFontItem );
+ }
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::SelectMacro(const SfxMacroInfoItem *pItem)
+{
+ m_pMacroInfoItem = pItem;
+ pGroupLBox->SelectMacro( pItem );
+}
+
+//-----------------------------------------------
+void SfxAcceleratorConfigPage::CopySource2Target(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xSourceAccMgr,
+ const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xTargetAccMgr)
+{
+ const css::uno::Sequence< css::awt::KeyEvent > lKeys = xSourceAccMgr->getAllKeyEvents();
+ sal_Int32 c = lKeys.getLength();
+ sal_Int32 i = 0;
+ for (i=0; i<c; ++i)
+ {
+ const css::awt::KeyEvent& rKey = lKeys[i];
+ ::rtl::OUString sCommand = xSourceAccMgr->getCommandByKeyEvent(rKey);
+ xTargetAccMgr->setKeyEvent(rKey, sCommand);
+ }
+}
+
+//-----------------------------------------------
+KeyCode SfxAcceleratorConfigPage::MapPosToKeyCode(USHORT nPos) const
+{
+ TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
+ KeyCode aCode(KEYCODE_ARRAY[pEntry->m_nKeyPos] & 0xFFF ,
+ KEYCODE_ARRAY[pEntry->m_nKeyPos] & (KEY_SHIFT | KEY_MOD2));
+ return aCode;
+}
+
+//-----------------------------------------------
+USHORT SfxAcceleratorConfigPage::MapKeyCodeToPos(const KeyCode& aKey) const
+{
+ USHORT nCode1 = aKey.GetCode()+aKey.GetModifier();
+ SvLBoxEntry* pEntry = aEntriesBox.First();
+ USHORT i = 0;
+
+ while (pEntry)
+ {
+ TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
+ if (pUserData)
+ {
+ USHORT nCode2 = pUserData->m_aKey.GetCode()+pUserData->m_aKey.GetModifier();
+ if (nCode1 == nCode2)
+ return i;
+ }
+ pEntry = aEntriesBox.Next(pEntry);
+ ++i;
+ }
+
+ return LISTBOX_ENTRY_NOTFOUND;
+}
+
+//-----------------------------------------------
+String SfxAcceleratorConfigPage::GetLabel4Command(const String& sCommand)
+{
+ try
+ {
+ // check global command configuration first
+ css::uno::Reference< css::container::XNameAccess > xModuleConf;
+ m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
+ if (xModuleConf.is())
+ {
+ ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
+ String sLabel = String(lProps.getUnpackedValueOrDefault(CMDPROP_UINAME, ::rtl::OUString()));
+ if (sLabel.Len())
+ return sLabel;
+ }
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ {}
+
+ // may be it's a style URL .. they must be handled special
+ SfxStyleInfo_Impl aStyle;
+ aStyle.sCommand = sCommand;
+ if (m_aStylesInfo.parseStyleCommand(aStyle))
+ {
+ m_aStylesInfo.getLabel4Style(aStyle);
+ return aStyle.sLabel;
+ }
+ else
+ {
+ String aRet( String::CreateFromAscii("Symbols: ") );
+ xub_StrLen nPos = sCommand.SearchAscii(".uno:InsertSymbol?Symbols:string=");
+ if ( nPos == 0 )
+ {
+ aRet += String( sCommand, 34, sCommand.Len()-34 );
+ return aRet;
+ }
+ }
+
+ return sCommand;
+}
+
+SfxTabPage* SfxAcceleratorConfigPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
+{
+ return new SfxAcceleratorConfigPage( pParent, rAttrSet );
+}
+
+//-----------------------------------------------
+css::uno::Reference< css::frame::XModel > SfxAcceleratorConfigPage::SearchForAlreadyLoadedDoc(const String& /*sName*/)
+{
+ return css::uno::Reference< css::frame::XModel >();
+}
+
+SvxShortcutAssignDlg::SvxShortcutAssignDlg( Window* pParent, const uno::Reference< frame::XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
+ : SfxSingleTabDialog( pParent, rSet, 0 )
+{
+ SfxTabPage* pPage = SfxAcceleratorConfigPage::Create( this, rSet );
+ pPage->SetFrame( rxDocumentFrame );
+ SetTabPage( pPage );
+
+}
+
+SvxShortcutAssignDlg::~SvxShortcutAssignDlg()
+{
+}
+
+
+// .uno:InsertSymbol?Symbols:string=bla
diff --git a/cui/source/customize/acccfg.hrc b/cui/source/customize/acccfg.hrc
new file mode 100644
index 000000000000..be0771b83fc8
--- /dev/null
+++ b/cui/source/customize/acccfg.hrc
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define GRP_FUNCTIONS 22
+#define BTN_ACC_OK 1
+#define BTN_ACC_CANCEL 2
+#define BTN_ACC_CHANGE 3
+#define BTN_ACC_REMOVE 4
+#define BOX_ACC_ENTRIES 5
+#define TXT_ACC_DESCRIPTIONTEXT 6
+#define TXT_ACC_DESCRIPTIONINFO 7
+#define GRP_ACC_KEYBOARD 8
+#define TXT_ACC_GROUP 9
+#define BOX_ACC_GROUP 10
+#define TXT_ACC_FUNCTION 11
+#define BOX_ACC_FUNCTION 12
+#define TXT_ACC_KEY 13
+#define BOX_ACC_KEY 14
+#define GRP_ACC_FUNCTIONS 15
+#define BTN_RESET 20
+#define BTN_LOAD 40
+#define BTN_SAVE 41
+#define RB_OFFICE 44
+#define RB_MODULE 45
+#define STR_LOADACCELCONFIG 46
+#define STR_SAVEACCELCONFIG 47
+
+#define IMG_HARDDISK 48
+#define IMG_HARDDISK_HC 49
+#define STR_PRODMACROS 50
+#define STR_MYMACROS 51
+#define IMG_LIB 52
+#define IMG_LIB_HC 53
+#define IMG_MACRO 54
+#define IMG_MACRO_HC 55
+#define IMG_DOC 56
+#define IMG_DOC_HC 57
+#define STR_GROUP_STYLES 58
+#define STR_PDF_EXPORT_SEND 59
+#define STR_RECHECK_DOCUMENT 60
+#define IMG_INFO 61
+#define STR_BASICNAME 62
+#define BMP_COLLAPSED 63
+#define BMP_EXPANDED 64
+#define BMP_COLLAPSED_HC 65
+#define BMP_EXPANDED_HC 66
+#define STR_BASICMACROS 67
+#define STR_DLG_MACROS 68
+#define STR_HUMAN_APPNAME 69
+#define STR_FILTERNAME_CFG 70
+
diff --git a/cui/source/customize/acccfg.src b/cui/source/customize/acccfg.src
new file mode 100644
index 000000000000..74188426a787
--- /dev/null
+++ b/cui/source/customize/acccfg.src
@@ -0,0 +1,357 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include "helpid.hrc"
+#include "cuires.hrc"
+#include "acccfg.hrc"
+
+#define MASKCOLOR MaskColor = \
+ Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+#define PUSHBUTTON_TEXT_SAVE \
+ Text [ en-US ] = "~Save..." ; \
+
+#define PUSHBUTTON_TEXT_RESET \
+ Text [ en-US ] = "R~eset" ; \
+
+#define PUSHBUTTON_TEXT_LOAD \
+ Text [ en-US ] = "~Load..." ; \
+
+#define PUSHBUTTON_TEXT_REMOVE \
+ Text [ en-US ] = "~Delete" ; \
+
+#define PUSHBUTTON_TEXT_CHANGE \
+ Text [ en-US ] = "~Modify" ; \
+
+#define PUSHBUTTON_TEXT_NEW \
+ Text [ en-US ] = "~New" ; \
+
+#define FIXEDTEXT_TEXT_GROUP \
+ Text [ en-US ] = "~Category" ; \
+
+#define FIXEDTEXT_TEXT_FUNCTION \
+ Text [ en-US ] = "Function" ; \
+
+#define GROUPBOX_TEXT_FUNCTIONS \
+ Text [ en-US ] = "Functions" ; \
+
+ // TP_CONFIG_ACCEL -------------------------------------------------------
+TabPage RID_SVXPAGE_KEYBOARD
+{
+ HelpId = HID_CONFIG_ACCEL ;
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 273 , 258 ) ;
+ RadioButton RB_OFFICE
+ {
+ Pos = MAP_APPFONT ( 192 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text = "%PRODUCTNAME" ;
+ };
+ RadioButton RB_MODULE
+ {
+ Pos = MAP_APPFONT ( 192 , 19 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text = "$(MODULE)" ;
+ };
+ PushButton BTN_ACC_CHANGE
+ {
+ Pos = MAP_APPFONT ( 192 , 35 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ PUSHBUTTON_TEXT_CHANGE
+ };
+ PushButton BTN_ACC_REMOVE
+ {
+ Pos = MAP_APPFONT ( 192 , 52 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ Group = TRUE ;
+ PUSHBUTTON_TEXT_REMOVE
+ };
+ FixedLine GRP_ACC_KEYBOARD
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 180 , 8 ) ;
+ Group = TRUE ;
+ Text [ en-US ] = "Shortcut keys";
+ };
+ Control BOX_ACC_ENTRIES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 174 , 120 ) ;
+ TabStop = TRUE ;
+ Group = TRUE ;
+ HelpId = HID_ACCELCONFIG_LISTBOX ;
+ };
+ FixedLine GRP_ACC_FUNCTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 140 ) ;
+ Size = MAP_APPFONT ( 258 , 8 ) ;
+ Group = TRUE ;
+ GROUPBOX_TEXT_FUNCTIONS
+ };
+ FixedText TXT_ACC_GROUP
+ {
+ Pos = MAP_APPFONT ( 12 , 151 ) ;
+ Size = MAP_APPFONT ( 78 , 8 ) ;
+ Group = TRUE ;
+ Left = TRUE ;
+ FIXEDTEXT_TEXT_GROUP
+ };
+ Control BOX_ACC_GROUP
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 161 ) ;
+ Size = MAP_APPFONT ( 78 , 91 ) ;
+ TabStop = TRUE ;
+ HelpId = HID_CONFIGGROUP_ACC_LISTBOX ;
+ };
+ FixedText TXT_ACC_FUNCTION
+ {
+ Pos = MAP_APPFONT ( 93 , 151 ) ;
+ Size = MAP_APPFONT ( 88 , 8 ) ;
+ Left = TRUE ;
+ FIXEDTEXT_TEXT_FUNCTION
+ };
+ Control BOX_ACC_FUNCTION
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 161 ) ;
+ Size = MAP_APPFONT ( 88 , 91 ) ;
+ TabStop = TRUE ;
+ HelpId = HID_CONFIGFUNCTION_ACC_LISTBOX ;
+ };
+ FixedText TXT_ACC_KEY
+ {
+ Pos = MAP_APPFONT ( 184 , 151 ) ;
+ Size = MAP_APPFONT ( 80 , 8 ) ;
+ Text [ en-US ] = "~Keys" ;
+ Left = TRUE ;
+ };
+ Control BOX_ACC_KEY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 184 , 161 ) ;
+ Size = MAP_APPFONT ( 80 , 91 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_LOAD
+ {
+ Pos = MAP_APPFONT ( 192 , 86 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ Group = TRUE ;
+ PUSHBUTTON_TEXT_LOAD
+ };
+ PushButton BTN_SAVE
+ {
+ Pos = MAP_APPFONT ( 192 , 103 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ Group = TRUE ;
+ PUSHBUTTON_TEXT_SAVE
+ };
+ PushButton BTN_RESET
+ {
+ Pos = MAP_APPFONT ( 192 , 120 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ Group = TRUE ;
+ PUSHBUTTON_TEXT_RESET
+ };
+ String STR_LOADACCELCONFIG
+ {
+ Text [ en-US ] = "Load Keyboard Configuration" ;
+ };
+ String STR_SAVEACCELCONFIG
+ {
+ Text [ en-US ] = "Save Keyboard Configuration" ;
+ };
+ String STR_SFX_FILTERNAME_ALL
+ {
+ Text [ en-US ] = "All files (*.*)" ;
+ };
+ String STR_FILTERNAME_CFG
+ {
+ Text [ en-US ] = "Configuration" ;
+ };
+};
+
+Resource RID_SVXPAGE_CONFIGGROUPBOX
+{
+ String STR_MYMACROS
+ {
+ Text [ en-US ] = "My Macros";
+ };
+ String STR_PRODMACROS
+ {
+ Text [ en-US ] = "%PRODUCTNAME Macros";
+ };
+ String STR_BASICMACROS
+ {
+ Text [ en-US ] = "BASIC Macros" ;
+ };
+ String STR_DLG_MACROS
+ {
+ Text [ en-US ] = "%PRODUCTNAME Macros" ;
+ };
+ String STR_HUMAN_APPNAME
+ {
+ TEXT = "%PRODUCTNAME" ;
+ };
+ String STR_GROUP_STYLES
+ {
+ Text [ en-US ] = "Styles" ;
+ };
+ Image IMG_HARDDISK
+ {
+ ImageBitmap = Bitmap { File = "harddisk_16.bmp" ; };
+ MASKCOLOR
+ };
+ Image IMG_HARDDISK_HC
+ {
+ ImageBitmap = Bitmap { File = "harddisk_16_h.bmp" ; };
+ MASKCOLOR
+ };
+ Image IMG_LIB
+ {
+ ImageBitmap = Bitmap { File = "im30820.png"; };
+ MASKCOLOR
+ };
+ Image IMG_LIB_HC
+ {
+ ImageBitmap = Bitmap { File = "imh30820.png"; };
+ MASKCOLOR
+ };
+ Image IMG_MACRO
+ {
+ ImageBitmap = Bitmap { File = "im30821.png"; };
+ MASKCOLOR
+ };
+ Image IMG_MACRO_HC
+ {
+ ImageBitmap = Bitmap { File = "imh30821.png"; };
+ MASKCOLOR
+ };
+ Image IMG_DOC
+ {
+ ImageBitmap = Bitmap { File = "im30826.png"; };
+ MASKCOLOR
+ };
+ Image IMG_DOC_HC
+ {
+ ImageBitmap = Bitmap { File = "imh30826.png"; };
+ MASKCOLOR
+ };
+ String STR_BASICNAME
+ {
+ Text = "%PRODUCTNAME Basic" ;
+ };
+ Image BMP_COLLAPSED
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "plus.bmp" ;
+ };
+ // MaskColor = Color { Predefine = COL_GREEN ; };
+ };
+ Image BMP_EXPANDED
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "minus.bmp" ;
+ };
+ // MaskColor = Color { Predefine = COL_GREEN ; };
+ };
+ Image BMP_EXPANDED_HC
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "minus_h.bmp" ;
+ };
+ };
+ Image BMP_COLLAPSED_HC
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "plus_h.bmp" ;
+ };
+ };
+};
+
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
new file mode 100644
index 000000000000..d9f730e0224f
--- /dev/null
+++ b/cui/source/customize/cfg.cxx
@@ -0,0 +1,6053 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cui.hxx"
+
+#include <stdlib.h>
+#include <time.h>
+
+#ifndef _HELP_HXX //autogen
+#include <vcl/help.hxx>
+#endif
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#include <vcl/decoview.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/scrbar.hxx>
+
+//added for issue73355
+//#ifndef _SV_SVDATA_HXX
+//#include <vcl/svdata.hxx>
+//#endif
+//issue73355 ends
+
+#include <sfx2/app.hxx>
+#include <sfx2/sfxdlg.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/msgpool.hxx>
+#include <sfx2/mnumgr.hxx>
+#include <sfx2/macrconf.hxx>
+#include <sfx2/minfitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/miscopt.hxx>
+#include <tools/diagnose_ex.h>
+#include <toolkit/unohlp.hxx>
+
+#include <algorithm>
+//add
+#include <cuires.hrc>
+#include "cfg.hrc"
+#include "helpid.hrc"
+
+#include "acccfg.hxx"
+#include "cfg.hxx"
+#include "eventdlg.hxx"
+#include <dialmgr.hxx>
+
+#include <comphelper/documentinfo.hxx>
+#include <comphelper/processfactory.hxx>
+#ifndef _UNOTOOLS_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#include <com/sun/star/ui/ItemType.hpp>
+#include <com/sun/star/ui/ItemStyle.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/ui/XUIConfiguration.hpp>
+#include <com/sun/star/ui/XUIConfigurationListener.hpp>
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
+#include <com/sun/star/ui/XUIConfigurationStorage.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManager.hpp>
+#include <com/sun/star/ui/XUIElement.hpp>
+#ifndef _COM_SUN_STAR_UI_UIElementType_HPP_
+#include <com/sun/star/ui/UIElementType.hpp>
+#endif
+#include <com/sun/star/ui/ImageType.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XFrames.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+
+#include "dlgname.hxx"
+
+#define PRTSTR(x) rtl::OUStringToOString(x, RTL_TEXTENCODING_ASCII_US).pData->buffer
+
+#define ENTRY_HEIGHT 16
+
+static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
+static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
+static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer";
+static const char ITEM_DESCRIPTOR_LABEL[] = "Label";
+static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
+static const char ITEM_DESCRIPTOR_STYLE[] = "Style";
+static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible";
+static const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL";
+static const char ITEM_DESCRIPTOR_UINAME[] = "UIName";
+
+static const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
+static const char ITEM_TOOLBAR_URL[] = "private:resource/toolbar/";
+
+static const char CUSTOM_TOOLBAR_STR[] = "custom_toolbar_";
+static const char CUSTOM_MENU_STR[] = "vnd.openoffice.org:CustomMenu";
+
+static const char __FAR_DATA pSeparatorStr[] =
+ "----------------------------------";
+static const char __FAR_DATA pMenuSeparatorStr[] = " | ";
+
+#ifdef _MSC_VER
+#pragma warning (disable:4355)
+#endif
+
+using rtl::OUString;
+namespace css = com::sun::star;
+namespace uno = com::sun::star::uno;
+namespace frame = com::sun::star::frame;
+namespace lang = com::sun::star::lang;
+namespace container = com::sun::star::container;
+namespace beans = com::sun::star::beans;
+namespace graphic = com::sun::star::graphic;
+
+void printPropertySet(
+ const OUString& prefix,
+ const uno::Reference< beans::XPropertySet >& xPropSet )
+{
+ uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
+ xPropSet->getPropertySetInfo();
+
+ uno::Sequence< beans::Property > aPropDetails =
+ xPropSetInfo->getProperties();
+
+ OSL_TRACE("printPropertySet: %d properties", aPropDetails.getLength());
+
+ for ( sal_Int32 i = 0; i < aPropDetails.getLength(); i++ )
+ {
+ OUString tmp;
+ sal_Int32 ival;
+
+ uno::Any a = xPropSet->getPropertyValue( aPropDetails[i].Name );
+
+ if ( ( a >>= tmp ) /* && tmp.getLength() != 0 */ )
+ {
+ OSL_TRACE("%s: Got property: %s = %s",
+ PRTSTR(prefix), PRTSTR(aPropDetails[i].Name), PRTSTR(tmp));
+ }
+ else if ( ( a >>= ival ) )
+ {
+ OSL_TRACE("%s: Got property: %s = %d",
+ PRTSTR(prefix), PRTSTR(aPropDetails[i].Name), PRTSTR(tmp));
+ }
+ else
+ {
+ OSL_TRACE("%s: Got property: %s of type %s",
+ PRTSTR(prefix), PRTSTR(aPropDetails[i].Name), PRTSTR(a.getValueTypeName()));
+ }
+ }
+}
+
+void printProperties(
+ const OUString& prefix,
+ const uno::Sequence< beans::PropertyValue >& aProp )
+{
+ for ( sal_Int32 i = 0; i < aProp.getLength(); i++ )
+ {
+ OUString tmp;
+
+ aProp[i].Value >>= tmp;
+
+ OSL_TRACE("%s: Got property: %s = %s",
+ PRTSTR(prefix), PRTSTR(aProp[i].Name), PRTSTR(tmp));
+ }
+}
+
+void printEntries(SvxEntries* entries)
+{
+ SvxEntries::const_iterator iter = entries->begin();
+
+ for ( ; iter != entries->end(); iter++ )
+ {
+ SvxConfigEntry* entry = *iter;
+
+ OSL_TRACE("printEntries: %s", PRTSTR(entry->GetName()));
+ }
+}
+
+OUString
+stripHotKey( const OUString& str )
+{
+ sal_Int32 index = str.indexOf( '~' );
+ if ( index == -1 )
+ {
+ return str;
+ }
+ else
+ {
+ return str.replaceAt( index, 1, OUString() );
+ }
+}
+
+OUString replaceSaveInName(
+ const OUString& rMessage,
+ const OUString& rSaveInName )
+{
+ OUString name;
+ OUString placeholder = OUString::createFromAscii( "%SAVE IN SELECTION%" );
+
+ sal_Int32 pos = rMessage.indexOf( placeholder );
+
+ if ( pos != -1 )
+ {
+ name = rMessage.replaceAt(
+ pos, placeholder.getLength(), rSaveInName );
+ }
+ else
+ {
+ // don't change the message
+ }
+
+ return name;
+}
+
+OUString
+replaceSixteen( const OUString& str, sal_Int32 nReplacement )
+{
+ OUString result( str );
+ OUString sixteen = OUString::valueOf( (sal_Int32)16 );
+ OUString expected = OUString::valueOf( nReplacement );
+
+ sal_Int32 len = sixteen.getLength();
+ sal_Int32 index = result.indexOf( sixteen );
+
+ while ( index != -1 )
+ {
+ result = result.replaceAt( index, len, expected );
+ index = result.indexOf( sixteen, index );
+ }
+
+ return result;
+}
+
+OUString
+generateCustomName(
+ const OUString& prefix,
+ SvxEntries* entries,
+ sal_Int32 suffix = 1 )
+{
+ // find and replace the %n placeholder in the prefix string
+ OUString name;
+ OUString placeholder = OUString::createFromAscii( "%n" );
+
+ sal_Int32 pos = prefix.indexOf(
+ OUString::createFromAscii( "%n" ) );
+
+ if ( pos != -1 )
+ {
+ name = prefix.replaceAt(
+ pos, placeholder.getLength(), OUString::valueOf( suffix ) );
+ }
+ else
+ {
+ // no placeholder found so just append the suffix
+ name = prefix + OUString::valueOf( suffix );
+ }
+
+ // now check is there is an already existing entry with this name
+ SvxEntries::const_iterator iter = entries->begin();
+
+ SvxConfigEntry* pEntry;
+ while ( iter != entries->end() )
+ {
+ pEntry = *iter;
+
+ if ( name.equals( pEntry->GetName() ) )
+ {
+ break;
+ }
+ iter++;
+ }
+
+ if ( iter != entries->end() )
+ {
+ // name already exists so try the next number up
+ return generateCustomName( prefix, entries, ++suffix );
+ }
+
+ return name;
+}
+
+sal_uInt32 generateRandomValue()
+{
+ srand( unsigned( time( NULL ) ));
+ return sal_uInt32( rand() );
+}
+
+OUString
+generateCustomURL(
+ SvxEntries* entries )
+{
+ OUString url = OUString::createFromAscii( ITEM_TOOLBAR_URL );
+ url += OUString::createFromAscii( CUSTOM_TOOLBAR_STR );
+
+ // use a random number to minimize possible clash with existing custom toolbars
+ url += OUString::valueOf( sal_Int64( generateRandomValue() ), 16 );
+
+ // now check is there is an already existing entry with this url
+ SvxEntries::const_iterator iter = entries->begin();
+
+ SvxConfigEntry* pEntry;
+ while ( iter != entries->end() )
+ {
+ pEntry = *iter;
+
+ if ( url.equals( pEntry->GetCommand() ) )
+ {
+ break;
+ }
+ iter++;
+ }
+
+ if ( iter != entries->end() )
+ {
+ // url already exists so try the next number up
+ return generateCustomURL( entries );
+ }
+
+ return url;
+}
+
+OUString
+generateCustomMenuURL(
+ SvxEntries* entries,
+ sal_Int32 suffix = 1 )
+{
+ OUString url = OUString::createFromAscii( CUSTOM_MENU_STR );
+ url += OUString::valueOf( suffix );
+
+ // now check is there is an already existing entry with this url
+ SvxEntries::const_iterator iter = entries->begin();
+
+ SvxConfigEntry* pEntry;
+ while ( iter != entries->end() )
+ {
+ pEntry = *iter;
+
+ if ( url.equals( pEntry->GetCommand() ) )
+ {
+ break;
+ }
+ iter++;
+ }
+
+ if ( iter != entries->end() )
+ {
+ // url already exists so try the next number up
+ return generateCustomMenuURL( entries, ++suffix );
+ }
+
+ return url;
+}
+
+static sal_Int16 theImageType =
+ css::ui::ImageType::COLOR_NORMAL |
+ css::ui::ImageType::SIZE_DEFAULT;
+
+void InitImageType()
+{
+ theImageType =
+ css::ui::ImageType::COLOR_NORMAL |
+ css::ui::ImageType::SIZE_DEFAULT;
+
+ if ( SvtMiscOptions().AreCurrentSymbolsLarge() )
+ {
+ theImageType |= css::ui::ImageType::SIZE_LARGE;
+ }
+
+ Window* topwin = Application::GetActiveTopWindow();
+ if ( topwin != NULL &&
+ topwin->GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ theImageType |= css::ui::ImageType::COLOR_HIGHCONTRAST;
+ }
+}
+
+sal_Int16 GetImageType()
+{
+ return theImageType;
+}
+
+void RemoveEntry( SvxEntries* pEntries, SvxConfigEntry* pChildEntry )
+{
+ SvxEntries::iterator iter = pEntries->begin();
+
+ while ( iter != pEntries->end() )
+ {
+ if ( pChildEntry == *iter )
+ {
+ pEntries->erase( iter );
+ break;
+ }
+ iter++;
+ }
+}
+
+bool
+SvxConfigPage::CanConfig( const OUString& aModuleId )
+{
+ OSL_TRACE("SupportsDocumentConfig: %s", PRTSTR(aModuleId));
+
+ if ( aModuleId.equalsAscii( "com.sun.star.script.BasicIDE" )
+ || aModuleId.equalsAscii( "com.sun.star.frame.Bibliography" )
+ )
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+OUString GetModuleName( const OUString& aModuleId )
+{
+ if ( aModuleId.equalsAscii( "com.sun.star.text.TextDocument" ) ||
+ aModuleId.equalsAscii( "com.sun.star.text.GlobalDocument" ) )
+ return OUString::createFromAscii("Writer");
+ else if ( aModuleId.equalsAscii( "com.sun.star.text.WebDocument" ) )
+ return OUString::createFromAscii("Writer/Web");
+ else if ( aModuleId.equalsAscii( "com.sun.star.drawing.DrawingDocument" ) )
+ return OUString::createFromAscii("Draw");
+ else if ( aModuleId.equalsAscii( "com.sun.star.presentation.PresentationDocument" ) )
+ return OUString::createFromAscii("Impress");
+ else if ( aModuleId.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ return OUString::createFromAscii("Calc");
+ else if ( aModuleId.equalsAscii( "com.sun.star.script.BasicIDE" ) )
+ return OUString::createFromAscii("Basic");
+ else if ( aModuleId.equalsAscii( "com.sun.star.formula.FormulaProperties" ) )
+ return OUString::createFromAscii("Math");
+ else if ( aModuleId.equalsAscii( "com.sun.star.sdb.RelationDesign" ) )
+ return OUString::createFromAscii("Relation Design");
+ else if ( aModuleId.equalsAscii( "com.sun.star.sdb.QueryDesign" ) )
+ return OUString::createFromAscii("Query Design");
+ else if ( aModuleId.equalsAscii( "com.sun.star.sdb.TableDesign" ) )
+ return OUString::createFromAscii("Table Design");
+ else if ( aModuleId.equalsAscii( "com.sun.star.sdb.DataSourceBrowser" ) )
+ return OUString::createFromAscii("Data Source Browser" );
+ else if ( aModuleId.equalsAscii( "com.sun.star.sdb.DatabaseDocument" ) )
+ return OUString::createFromAscii("Database" );
+
+ return ::rtl::OUString();
+}
+
+OUString GetUIModuleName( const OUString& aModuleId, const uno::Reference< css::frame::XModuleManager >& rModuleManager )
+{
+ OUString aModuleUIName;
+
+ if ( rModuleManager.is() )
+ {
+ uno::Reference< css::container::XNameAccess > xNameAccess( rModuleManager, uno::UNO_QUERY );
+ if ( xNameAccess.is() )
+ {
+ try
+ {
+ uno::Any a = xNameAccess->getByName( aModuleId );
+ uno::Sequence< beans::PropertyValue > aSeq;
+
+ if ( a >>= aSeq )
+ {
+ OUString aUIName;
+ for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
+ {
+ if ( aSeq[i].Name.equalsAscii( "ooSetupFactoryUIName" ))
+ {
+ aSeq[i].Value >>= aModuleUIName;
+ break;
+ }
+ }
+ }
+ }
+ catch ( uno::RuntimeException& e )
+ {
+ throw e;
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ }
+
+ if ( aModuleUIName.getLength() == 0 )
+ aModuleUIName = GetModuleName( aModuleId );
+
+ return aModuleUIName;
+}
+
+bool GetMenuItemData(
+ const uno::Reference< container::XIndexAccess >& rItemContainer,
+ sal_Int32 nIndex,
+ OUString& rCommandURL,
+ OUString& rHelpURL,
+ OUString& rLabel,
+ sal_uInt16& rType,
+ uno::Reference< container::XIndexAccess >& rSubMenu )
+{
+ try
+ {
+ uno::Sequence< beans::PropertyValue > aProp;
+ if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
+ {
+ for ( sal_Int32 i = 0; i < aProp.getLength(); i++ )
+ {
+ if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
+ {
+ aProp[i].Value >>= rCommandURL;
+ }
+ else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
+ {
+ aProp[i].Value >>= rHelpURL;
+ }
+ else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_CONTAINER ))
+ {
+ aProp[i].Value >>= rSubMenu;
+ }
+ else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ))
+ {
+ aProp[i].Value >>= rLabel;
+ }
+ else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
+ {
+ aProp[i].Value >>= rType;
+ }
+ }
+
+ return TRUE;
+ }
+ }
+ catch ( ::com::sun::star::lang::IndexOutOfBoundsException& )
+ {
+ }
+
+ return FALSE;
+}
+
+bool GetToolbarItemData(
+ const uno::Reference< container::XIndexAccess >& rItemContainer,
+ sal_Int32 nIndex,
+ OUString& rCommandURL,
+ OUString& rHelpURL,
+ OUString& rLabel,
+ sal_uInt16& rType,
+ sal_Bool& rIsVisible,
+ sal_Int32& rStyle,
+ uno::Reference< container::XIndexAccess >& rSubMenu )
+{
+ try
+ {
+ uno::Sequence< beans::PropertyValue > aProp;
+ if ( rItemContainer->getByIndex( nIndex ) >>= aProp )
+ {
+ for ( sal_Int32 i = 0; i < aProp.getLength(); i++ )
+ {
+ if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
+ {
+ aProp[i].Value >>= rCommandURL;
+ }
+ if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
+ {
+ aProp[i].Value >>= rStyle;
+ }
+ else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
+ {
+ aProp[i].Value >>= rHelpURL;
+ }
+ else if (aProp[i].Name.equalsAscii(ITEM_DESCRIPTOR_CONTAINER))
+ {
+ aProp[i].Value >>= rSubMenu;
+ }
+ else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ))
+ {
+ aProp[i].Value >>= rLabel;
+ }
+ else if ( aProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
+ {
+ aProp[i].Value >>= rType;
+ }
+ else if (aProp[i].Name.equalsAscii(ITEM_DESCRIPTOR_ISVISIBLE))
+ {
+ aProp[i].Value >>= rIsVisible;
+ }
+ }
+
+ return sal_True;
+ }
+ }
+ catch ( ::com::sun::star::lang::IndexOutOfBoundsException& )
+ {
+ }
+
+ return sal_False;
+}
+
+uno::Sequence< beans::PropertyValue >
+ConvertSvxConfigEntry(
+ const uno::Reference< container::XNameAccess >& xCommandToLabelMap,
+ const SvxConfigEntry* pEntry )
+{
+ static const OUString aDescriptorCommandURL (
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ) );
+
+ static const OUString aDescriptorType(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ) );
+
+ static const OUString aDescriptorLabel(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL ) );
+
+ static const OUString aDescriptorHelpURL(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL ) );
+
+ static const OUString aDescriptorContainer(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ) );
+
+ uno::Sequence< beans::PropertyValue > aPropSeq( 4 );
+
+ aPropSeq[0].Name = aDescriptorCommandURL;
+ aPropSeq[0].Value <<= rtl::OUString( pEntry->GetCommand() );
+
+ aPropSeq[1].Name = aDescriptorType;
+ aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
+
+ // If the name has not been changed and the name is the same as
+ // in the default command to label map then the label can be stored
+ // as an empty string.
+ // It will be initialised again later using the command to label map.
+ aPropSeq[2].Name = aDescriptorLabel;
+ if ( pEntry->HasChangedName() == FALSE && pEntry->GetCommand().getLength() )
+ {
+ BOOL isDefaultName = FALSE;
+ try
+ {
+ uno::Any a( xCommandToLabelMap->getByName( pEntry->GetCommand() ) );
+ uno::Sequence< beans::PropertyValue > tmpPropSeq;
+ if ( a >>= tmpPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < tmpPropSeq.getLength(); i++ )
+ {
+ if ( tmpPropSeq[i].Name.equals( aDescriptorLabel ) )
+ {
+ OUString tmpLabel;
+ tmpPropSeq[i].Value >>= tmpLabel;
+
+ if ( tmpLabel.equals( pEntry->GetName() ) )
+ {
+ isDefaultName = TRUE;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // isDefaultName is left as FALSE
+ }
+
+ if ( isDefaultName )
+ {
+ aPropSeq[2].Value <<= rtl::OUString();
+ }
+ else
+ {
+ aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
+ }
+ }
+ else
+ {
+ aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
+ }
+
+ aPropSeq[3].Name = aDescriptorHelpURL;
+ aPropSeq[3].Value <<= rtl::OUString( pEntry->GetHelpURL() );
+
+ return aPropSeq;
+}
+
+uno::Sequence< beans::PropertyValue >
+ConvertToolbarEntry(
+ const uno::Reference< container::XNameAccess >& xCommandToLabelMap,
+ const SvxConfigEntry* pEntry )
+{
+ static const OUString aDescriptorCommandURL (
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ) );
+
+ static const OUString aDescriptorType(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ) );
+
+ static const OUString aDescriptorLabel(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL ) );
+
+ static const OUString aDescriptorHelpURL(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL ) );
+
+ static const OUString aDescriptorContainer(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ) );
+
+ static const OUString aIsVisible(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_ISVISIBLE ) );
+
+ uno::Sequence< beans::PropertyValue > aPropSeq( 5 );
+
+ aPropSeq[0].Name = aDescriptorCommandURL;
+ aPropSeq[0].Value <<= rtl::OUString( pEntry->GetCommand() );
+
+ aPropSeq[1].Name = aDescriptorType;
+ aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
+
+ // If the name has not been changed and the name is the same as
+ // in the default command to label map then the label can be stored
+ // as an empty string.
+ // It will be initialised again later using the command to label map.
+ aPropSeq[2].Name = aDescriptorLabel;
+ if ( pEntry->HasChangedName() == FALSE && pEntry->GetCommand().getLength() )
+ {
+ BOOL isDefaultName = FALSE;
+ try
+ {
+ uno::Any a( xCommandToLabelMap->getByName( pEntry->GetCommand() ) );
+ uno::Sequence< beans::PropertyValue > tmpPropSeq;
+ if ( a >>= tmpPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < tmpPropSeq.getLength(); i++ )
+ {
+ if ( tmpPropSeq[i].Name.equals( aDescriptorLabel ) )
+ {
+ OUString tmpLabel;
+ tmpPropSeq[i].Value >>= tmpLabel;
+
+ if ( tmpLabel.equals( pEntry->GetName() ) )
+ {
+ isDefaultName = TRUE;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // isDefaultName is left as FALSE
+ }
+
+ if ( isDefaultName )
+ {
+ aPropSeq[2].Value <<= rtl::OUString();
+ }
+ else
+ {
+ aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
+ }
+ }
+ else
+ {
+ aPropSeq[2].Value <<= rtl::OUString( pEntry->GetName() );
+ }
+
+ aPropSeq[3].Name = aDescriptorHelpURL;
+ aPropSeq[3].Value <<= rtl::OUString( pEntry->GetHelpURL() );
+
+ aPropSeq[4].Name = aIsVisible;
+ aPropSeq[4].Value <<= pEntry->IsVisible();
+
+ return aPropSeq;
+}
+
+SfxTabPage *CreateSvxMenuConfigPage( Window *pParent, const SfxItemSet& rSet )
+{
+ return new SvxMenuConfigPage( pParent, rSet );
+}
+
+SfxTabPage *CreateKeyboardConfigPage( Window *pParent, const SfxItemSet& rSet )
+{
+ return new SfxAcceleratorConfigPage( pParent, rSet );
+}
+
+SfxTabPage *CreateSvxToolbarConfigPage( Window *pParent, const SfxItemSet& rSet )
+{
+ return new SvxToolbarConfigPage( pParent, rSet );
+}
+
+SfxTabPage *CreateSvxEventConfigPage( Window *pParent, const SfxItemSet& rSet )
+{
+ return new SvxEventConfigPage( pParent, rSet, SvxEventConfigPage::EarlyInit() );
+}
+
+sal_Bool impl_showKeyConfigTabPage( const css::uno::Reference< css::frame::XFrame >& xFrame )
+{
+ static ::rtl::OUString SERVICENAME_MODULEMANAGER = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager");
+ static ::rtl::OUString SERVICENAME_DESKTOP = ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop" );
+ static ::rtl::OUString MODULEID_STARTMODULE = ::rtl::OUString::createFromAscii("com.sun.star.frame.StartModule" );
+
+ try
+ {
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
+ css::uno::Reference< css::frame::XFramesSupplier > xDesktop(xSMGR->createInstance(SERVICENAME_DESKTOP), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::frame::XModuleManager > xMM (xSMGR->createInstance(SERVICENAME_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
+
+ if (xMM.is() && xFrame.is())
+ {
+ ::rtl::OUString sModuleId = xMM->identify(xFrame);
+ if (
+ ( sModuleId.getLength() ) &&
+ (!sModuleId.equals(MODULEID_STARTMODULE))
+ )
+ return sal_True;
+ }
+ }
+ catch(const css::uno::Exception&)
+ {}
+
+ return sal_False;
+}
+
+/******************************************************************************
+ *
+ * SvxConfigDialog is the configuration dialog which is brought up from the
+ * Tools menu. It includes tabs for customizing menus, toolbars, events and
+ * key bindings.
+ *
+ *****************************************************************************/
+SvxConfigDialog::SvxConfigDialog(
+ Window * pParent, const SfxItemSet* pSet_ )
+ :
+ SfxTabDialog( pParent,
+ CUI_RES( RID_SVXDLG_CUSTOMIZE ), pSet_ )
+{
+ FreeResource();
+
+ InitImageType();
+
+ AddTabPage( RID_SVXPAGE_MENUS, CreateSvxMenuConfigPage, NULL );
+ AddTabPage( RID_SVXPAGE_KEYBOARD, CreateKeyboardConfigPage, NULL );
+ AddTabPage( RID_SVXPAGE_TOOLBARS, CreateSvxToolbarConfigPage, NULL );
+ AddTabPage( RID_SVXPAGE_EVENTS, CreateSvxEventConfigPage, NULL );
+
+ const SfxPoolItem* pItem =
+ pSet_->GetItem( pSet_->GetPool()->GetWhich( SID_CONFIG ) );
+
+ if ( pItem )
+ {
+ OUString text = ((const SfxStringItem*)pItem)->GetValue();
+
+ if (text.indexOf(OUString::createFromAscii(ITEM_TOOLBAR_URL)) == 0)
+ {
+ SetCurPageId( RID_SVXPAGE_TOOLBARS );
+ }
+ }
+}
+
+void SvxConfigDialog::SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame)
+{
+ m_xFrame = xFrame;
+
+ if (!impl_showKeyConfigTabPage( xFrame ))
+ RemoveTabPage( RID_SVXPAGE_KEYBOARD );
+}
+
+SvxConfigDialog::~SvxConfigDialog()
+{
+}
+
+short SvxConfigDialog::Ok()
+{
+ return SfxTabDialog::Ok();
+}
+
+void SvxConfigDialog::PageCreated( USHORT nId, SfxTabPage& rPage )
+{
+ (void)rPage;
+
+ switch ( nId )
+ {
+ case RID_SVXPAGE_MENUS:
+ case RID_SVXPAGE_TOOLBARS:
+ case RID_SVXPAGE_KEYBOARD:
+ {
+ rPage.SetFrame(m_xFrame);
+ }
+ break;
+ case RID_SVXPAGE_EVENTS:
+ {
+ dynamic_cast< SvxEventConfigPage& >( rPage ).LateInit( m_xFrame );
+ };
+ break;
+ default:
+ break;
+ }
+}
+
+void SvxConfigDialog::ActivateTabPage( USHORT nSlotId )
+{
+ (void)nSlotId;
+}
+
+/******************************************************************************
+ *
+ * The SaveInData class is used to hold data for entries in the Save In
+ * ListBox controls in the menu and toolbar tabs
+ *
+ ******************************************************************************/
+
+// Initialize static variable which holds default XImageManager
+uno::Reference< css::ui::XImageManager>* SaveInData::xDefaultImgMgr = NULL;
+
+SaveInData::SaveInData(
+ const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
+ const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
+ const OUString& aModuleId,
+ bool isDocConfig )
+ :
+ bModified( FALSE ),
+ bDocConfig( isDocConfig ),
+ bReadOnly( FALSE ),
+ m_xCfgMgr( xCfgMgr ),
+ m_xParentCfgMgr( xParentCfgMgr )
+{
+ uno::Reference< beans::XPropertySet > xProps(
+ ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+
+ xProps->getPropertyValue(
+ OUString::createFromAscii( "DefaultContext" ))
+ >>= m_xComponentContext;
+
+ m_aSeparatorSeq.realloc( 1 );
+ m_aSeparatorSeq[0].Name = OUString(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ) );
+ m_aSeparatorSeq[0].Value <<= css::ui::ItemType::SEPARATOR_LINE;
+
+ if ( bDocConfig )
+ {
+ uno::Reference< css::ui::XUIConfigurationPersistence >
+ xDocPersistence( GetConfigManager(), uno::UNO_QUERY );
+
+ bReadOnly = xDocPersistence->isReadOnly();
+ }
+
+ m_xServiceManager = uno::Reference< lang::XMultiServiceFactory >(
+ ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ m_xServiceManager->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.frame.UICommandDescription" ) ) ),
+ uno::UNO_QUERY );
+
+ if ( xNameAccess.is() )
+ xNameAccess->getByName( aModuleId ) >>= m_xCommandToLabelMap;
+
+ if ( !m_xImgMgr.is() )
+ {
+ m_xImgMgr = uno::Reference< css::ui::XImageManager >(
+ GetConfigManager()->getImageManager(), uno::UNO_QUERY );
+ }
+
+ if ( !IsDocConfig() )
+ {
+ // If this is not a document configuration then it is the settings
+ // for the module (writer, calc, impress etc.) Use this as the default
+ // XImageManager instance
+ xDefaultImgMgr = &m_xImgMgr;
+ }
+ else
+ {
+ // If this is a document configuration then use the module image manager
+ // as default.
+ if ( m_xParentCfgMgr.is() )
+ {
+ m_xParentImgMgr = uno::Reference< css::ui::XImageManager >(
+ m_xParentCfgMgr->getImageManager(), uno::UNO_QUERY );
+ xDefaultImgMgr = &m_xParentImgMgr;
+ }
+ }
+}
+
+uno::Reference< graphic::XGraphic > GetGraphic(
+ const uno::Reference< css::ui::XImageManager >& xImageManager,
+ const OUString& rCommandURL )
+{
+ uno::Reference< graphic::XGraphic > result;
+
+ if ( xImageManager.is() )
+ {
+ // TODO handle large and high contrast graphics
+ uno::Sequence< uno::Reference< graphic::XGraphic > > aGraphicSeq;
+
+ uno::Sequence< OUString > aImageCmdSeq( 1 );
+ aImageCmdSeq[0] = rCommandURL;
+
+ try
+ {
+ aGraphicSeq =
+ xImageManager->getImages( GetImageType(), aImageCmdSeq );
+
+ if ( aGraphicSeq.getLength() > 0 )
+ {
+ result = aGraphicSeq[0];
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ // will return empty XGraphic
+ }
+ }
+
+ return result;
+}
+
+Image SaveInData::GetImage( const OUString& rCommandURL )
+{
+ Image aImage;
+
+ uno::Reference< graphic::XGraphic > xGraphic =
+ GetGraphic( m_xImgMgr, rCommandURL );
+
+ if ( xGraphic.is() )
+ {
+ aImage = Image( xGraphic );
+ }
+ else if ( xDefaultImgMgr != NULL && (*xDefaultImgMgr).is() )
+ {
+ xGraphic = GetGraphic( (*xDefaultImgMgr), rCommandURL );
+
+ if ( xGraphic.is() )
+ {
+ aImage = Image( xGraphic );
+ }
+ }
+
+ return aImage;
+}
+
+bool SaveInData::PersistChanges(
+ const uno::Reference< uno::XInterface >& xManager )
+{
+ bool result = TRUE;
+
+ try
+ {
+ if ( xManager.is() && !IsReadOnly() )
+ {
+ uno::Reference< css::ui::XUIConfigurationPersistence >
+ xConfigPersistence( xManager, uno::UNO_QUERY );
+
+ if ( xConfigPersistence->isModified() )
+ {
+ xConfigPersistence->store();
+ }
+ }
+ }
+ catch ( com::sun::star::io::IOException& )
+ {
+ result = FALSE;
+ }
+
+ return result;
+}
+
+/******************************************************************************
+ *
+ * The MenuSaveInData class extends SaveInData and provides menu specific
+ * load and store functionality.
+ *
+ ******************************************************************************/
+
+// Initialize static variable which holds default Menu data
+MenuSaveInData* MenuSaveInData::pDefaultData = NULL;
+
+MenuSaveInData::MenuSaveInData(
+ const uno::Reference< css::ui::XUIConfigurationManager >& cfgmgr,
+ const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
+ const OUString& aModuleId,
+ bool isDocConfig )
+ :
+ SaveInData( cfgmgr, xParentCfgMgr, aModuleId, isDocConfig ),
+ m_aMenuResourceURL(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_MENUBAR_URL ) ),
+ m_aDescriptorContainer(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ) ),
+ pRootEntry( 0 )
+{
+ try
+ {
+ OUString url( RTL_CONSTASCII_USTRINGPARAM( ITEM_MENUBAR_URL ) );
+ m_xMenuSettings = GetConfigManager()->getSettings( url, sal_False );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // will use menu settings for the module
+ }
+
+ // If this is not a document configuration then it is the settings
+ // for the module (writer, calc, impress etc.). These settings should
+ // be set as the default to be used for SaveIn locations that do not
+ // have custom settings
+ if ( !IsDocConfig() )
+ {
+ SetDefaultData( this );
+ }
+}
+
+MenuSaveInData::~MenuSaveInData()
+{
+ if ( pRootEntry != NULL )
+ {
+ delete pRootEntry;
+ }
+}
+
+SvxEntries*
+MenuSaveInData::GetEntries()
+{
+ if ( pRootEntry == NULL )
+ {
+ pRootEntry = new SvxConfigEntry(
+ String::CreateFromAscii("MainMenus"), String(), TRUE );
+
+ if ( m_xMenuSettings.is() )
+ {
+ LoadSubMenus( m_xMenuSettings, String(), pRootEntry );
+ }
+ else if ( GetDefaultData() != NULL )
+ {
+ // If the doc has no config settings use module config settings
+ LoadSubMenus( GetDefaultData()->m_xMenuSettings, String(), pRootEntry );
+ }
+ }
+
+ return pRootEntry->GetEntries();
+}
+
+void
+MenuSaveInData::SetEntries( SvxEntries* pNewEntries )
+{
+ // delete old menu hierarchy first
+ if ( pRootEntry != NULL )
+ {
+ delete pRootEntry->GetEntries();
+ }
+
+ // now set new menu hierarchy
+ pRootEntry->SetEntries( pNewEntries );
+}
+
+bool MenuSaveInData::LoadSubMenus(
+ const uno::Reference< container::XIndexAccess >& xMenuSettings,
+ const OUString& rBaseTitle,
+ SvxConfigEntry* pParentData )
+{
+ SvxEntries* pEntries = pParentData->GetEntries();
+
+ for ( sal_Int32 nIndex = 0; nIndex < xMenuSettings->getCount(); nIndex++ )
+ {
+ uno::Reference< container::XIndexAccess > xSubMenu;
+ OUString aCommandURL;
+ OUString aHelpURL;
+ OUString aLabel;
+ bool bIsUserDefined = TRUE;
+
+ sal_uInt16 nType( css::ui::ItemType::DEFAULT );
+
+ bool bItem = GetMenuItemData( xMenuSettings, nIndex,
+ aCommandURL, aHelpURL, aLabel, nType, xSubMenu );
+
+ if ( bItem )
+ {
+ if ( nType == css::ui::ItemType::DEFAULT )
+ {
+ uno::Any a;
+ try
+ {
+ a = m_xCommandToLabelMap->getByName( aCommandURL );
+ bIsUserDefined = FALSE;
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ bIsUserDefined = TRUE;
+ }
+
+ // If custom label not set retrieve it from the command
+ // to info service
+ if ( aLabel.equals( OUString() ) )
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if ( aPropSeq[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ) )
+ {
+ aPropSeq[i].Value >>= aLabel;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( xSubMenu.is() )
+ {
+ // popup menu
+ SvxConfigEntry* pEntry = new SvxConfigEntry(
+ aLabel, aCommandURL, TRUE );
+
+ pEntry->SetUserDefined( bIsUserDefined );
+ pEntry->SetHelpURL( aHelpURL );
+
+ pEntries->push_back( pEntry );
+
+ OUString subMenuTitle( rBaseTitle );
+
+ if ( subMenuTitle.getLength() != 0 )
+ {
+ subMenuTitle +=
+ OUString::createFromAscii(pMenuSeparatorStr);
+ }
+ else
+ {
+ pEntry->SetMain( TRUE );
+ }
+
+ subMenuTitle += stripHotKey( aLabel );
+
+ LoadSubMenus( xSubMenu, subMenuTitle, pEntry );
+ }
+ else
+ {
+ SvxConfigEntry* pEntry = new SvxConfigEntry(
+ aLabel, aCommandURL, FALSE );
+ pEntry->SetUserDefined( bIsUserDefined );
+ pEntry->SetHelpURL( aHelpURL );
+ pEntries->push_back( pEntry );
+ }
+ }
+ else
+ {
+ SvxConfigEntry* pEntry = new SvxConfigEntry;
+ pEntry->SetUserDefined( bIsUserDefined );
+ pEntries->push_back( pEntry );
+ }
+ }
+ }
+ return true;
+}
+
+bool MenuSaveInData::Apply()
+{
+ bool result = FALSE;
+
+ if ( IsModified() )
+ {
+ // Apply new menu bar structure to our settings container
+ m_xMenuSettings = uno::Reference< container::XIndexAccess >(
+ GetConfigManager()->createSettings(), uno::UNO_QUERY );
+
+ uno::Reference< container::XIndexContainer > xIndexContainer (
+ m_xMenuSettings, uno::UNO_QUERY );
+
+ uno::Reference< lang::XSingleComponentFactory > xFactory (
+ m_xMenuSettings, uno::UNO_QUERY );
+
+ Apply( pRootEntry, xIndexContainer, xFactory, NULL );
+
+ try
+ {
+ if ( GetConfigManager()->hasSettings( m_aMenuResourceURL ) )
+ {
+ GetConfigManager()->replaceSettings(
+ m_aMenuResourceURL, m_xMenuSettings );
+ }
+ else
+ {
+ GetConfigManager()->insertSettings(
+ m_aMenuResourceURL, m_xMenuSettings );
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ OSL_TRACE("caught container::NoSuchElementException saving settings");
+ }
+ catch ( com::sun::star::io::IOException& )
+ {
+ OSL_TRACE("caught IOException saving settings");
+ }
+ catch ( com::sun::star::uno::Exception& )
+ {
+ OSL_TRACE("caught some other exception saving settings");
+ }
+
+ SetModified( FALSE );
+
+ result = PersistChanges( GetConfigManager() );
+ }
+
+ return result;
+}
+
+void MenuSaveInData::Apply(
+ SvxConfigEntry* pRootEntry_,
+ uno::Reference< container::XIndexContainer >& rMenuBar,
+ uno::Reference< lang::XSingleComponentFactory >& rFactory,
+ SvLBoxEntry *pParentEntry )
+{
+ (void)pRootEntry_;
+ (void)pParentEntry;
+
+ SvxEntries::const_iterator iter = GetEntries()->begin();
+ SvxEntries::const_iterator end = GetEntries()->end();
+
+ for ( ; iter != end; iter++ )
+ {
+ SvxConfigEntry* pEntryData = *iter;
+
+ uno::Sequence< beans::PropertyValue > aPropValueSeq =
+ ConvertSvxConfigEntry( m_xCommandToLabelMap, pEntryData );
+
+ uno::Reference< container::XIndexContainer > xSubMenuBar(
+ rFactory->createInstanceWithContext( m_xComponentContext ),
+ uno::UNO_QUERY );
+
+ sal_Int32 nIndex = aPropValueSeq.getLength();
+ aPropValueSeq.realloc( nIndex + 1 );
+ aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
+ aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ rMenuBar->insertByIndex(
+ rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
+ ApplyMenu( xSubMenuBar, rFactory, pEntryData );
+ }
+}
+
+void MenuSaveInData::ApplyMenu(
+ uno::Reference< container::XIndexContainer >& rMenuBar,
+ uno::Reference< lang::XSingleComponentFactory >& rFactory,
+ SvxConfigEntry* pMenuData )
+{
+ SvxEntries::const_iterator iter = pMenuData->GetEntries()->begin();
+ SvxEntries::const_iterator end = pMenuData->GetEntries()->end();
+
+ for ( ; iter != end; iter++ )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ if ( pEntry->IsPopup() )
+ {
+ uno::Sequence< beans::PropertyValue > aPropValueSeq =
+ ConvertSvxConfigEntry( m_xCommandToLabelMap, pEntry );
+
+ uno::Reference< container::XIndexContainer > xSubMenuBar(
+ rFactory->createInstanceWithContext( m_xComponentContext ),
+ uno::UNO_QUERY );
+
+ sal_Int32 nIndex = aPropValueSeq.getLength();
+ aPropValueSeq.realloc( nIndex + 1 );
+ aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
+ aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+
+ rMenuBar->insertByIndex(
+ rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
+
+ ApplyMenu( xSubMenuBar, rFactory, pEntry );
+ }
+ else if ( pEntry->IsSeparator() )
+ {
+ rMenuBar->insertByIndex(
+ rMenuBar->getCount(), uno::makeAny( m_aSeparatorSeq ));
+ }
+ else
+ {
+ uno::Sequence< beans::PropertyValue > aPropValueSeq =
+ ConvertSvxConfigEntry( m_xCommandToLabelMap, pEntry );
+ rMenuBar->insertByIndex(
+ rMenuBar->getCount(), uno::makeAny( aPropValueSeq ));
+ }
+ }
+}
+
+void
+MenuSaveInData::Reset()
+{
+ GetConfigManager()->reset();
+
+ delete pRootEntry;
+ pRootEntry = NULL;
+
+ try
+ {
+ m_xMenuSettings = GetConfigManager()->getSettings(
+ m_aMenuResourceURL, sal_False );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // will use default settings
+ }
+}
+
+class PopupPainter : public SvLBoxString
+{
+public:
+ PopupPainter( SvLBoxEntry* pEntry, const String& rStr )
+ : SvLBoxString( pEntry, 0, rStr )
+ { }
+
+ ~PopupPainter() { }
+
+ void Paint( const Point& rPos, SvLBox& rOutDev,
+ USHORT nViewDataEntryFlags, SvLBoxEntry* pEntry )
+ {
+ SvLBoxString::Paint( rPos, rOutDev, nViewDataEntryFlags, pEntry );
+
+ Color aOldFillColor = rOutDev.GetFillColor();
+
+ SvTreeListBox* pTreeBox = static_cast< SvTreeListBox* >( &rOutDev );
+ long nX = pTreeBox->GetSizePixel().Width();
+
+ ScrollBar* pVScroll = pTreeBox->GetVScroll();
+ if ( pVScroll->IsVisible() )
+ {
+ nX -= pVScroll->GetSizePixel().Width();
+ }
+
+ SvViewDataItem* pItem = rOutDev.GetViewDataItem( pEntry, this );
+ nX -= pItem->aSize.Height();
+
+ long nSize = pItem->aSize.Height() / 2;
+ long nHalfSize = nSize / 2;
+ long nY = rPos.Y() + nHalfSize;
+
+ if ( aOldFillColor == COL_WHITE )
+ {
+ rOutDev.SetFillColor( Color( COL_BLACK ) );
+ }
+ else
+ {
+ rOutDev.SetFillColor( Color( COL_WHITE ) );
+ }
+
+ long n = 0;
+ while ( n <= nHalfSize )
+ {
+ rOutDev.DrawRect( Rectangle( nX+n, nY+n, nX+n, nY+nSize-n ) );
+ n++;
+ }
+
+ rOutDev.SetFillColor( aOldFillColor );
+ }
+};
+
+/******************************************************************************
+ *
+ * SvxMenuEntriesListBox is the listbox in which the menu items for a
+ * particular menu are shown. We have a custom listbox because we need
+ * to add drag'n'drop support from the Macro Selector and within the
+ * listbox
+ *
+ *****************************************************************************/
+SvxMenuEntriesListBox::SvxMenuEntriesListBox(
+ Window* pParent, const ResId& rResId)
+ : SvTreeListBox( pParent, rResId )
+ , pPage( (SvxMenuConfigPage*) pParent )
+ , m_bIsInternalDrag( FALSE )
+{
+ SetWindowBits(
+ GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HIDESELECTION );
+
+ SetSpaceBetweenEntries( 3 );
+ SetEntryHeight( ENTRY_HEIGHT );
+
+ SetHighlightRange();
+ SetSelectionMode(SINGLE_SELECTION);
+
+ SetDragDropMode( SV_DRAGDROP_CTRL_MOVE |
+ SV_DRAGDROP_APP_COPY |
+ SV_DRAGDROP_ENABLE_TOP |
+ SV_DRAGDROP_APP_DROP);
+}
+
+SvxMenuEntriesListBox::~SvxMenuEntriesListBox()
+{
+ // do nothing
+}
+
+// drag and drop support
+DragDropMode SvxMenuEntriesListBox::NotifyStartDrag(
+ TransferDataContainer& aTransferDataContainer, SvLBoxEntry* pEntry )
+{
+ (void)aTransferDataContainer;
+ (void)pEntry;
+
+ m_bIsInternalDrag = TRUE;
+ return GetDragDropMode();
+}
+
+void SvxMenuEntriesListBox::DragFinished( sal_Int8 nDropAction )
+{
+ (void)nDropAction;
+ m_bIsInternalDrag = FALSE;
+}
+
+sal_Int8 SvxMenuEntriesListBox::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ if ( m_bIsInternalDrag )
+ {
+ // internal copy isn't allowed!
+ if ( rEvt.mnAction == DND_ACTION_COPY )
+ return DND_ACTION_NONE;
+ else
+ return SvTreeListBox::AcceptDrop( rEvt );
+ }
+
+ // Always do COPY instead of MOVE if D&D comes from outside!
+ AcceptDropEvent aNewAcceptDropEvent( rEvt );
+ aNewAcceptDropEvent.mnAction = DND_ACTION_COPY;
+ return SvTreeListBox::AcceptDrop( aNewAcceptDropEvent );
+}
+
+BOOL SvxMenuEntriesListBox::NotifyAcceptDrop( SvLBoxEntry* )
+{
+ return TRUE;
+}
+
+BOOL SvxMenuEntriesListBox::NotifyMoving(
+ SvLBoxEntry* pTarget, SvLBoxEntry* pSource,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos)
+{
+ // only try to do a move if we are dragging within the list box
+ if ( m_bIsInternalDrag )
+ {
+ if ( pPage->MoveEntryData( pSource, pTarget ) == TRUE )
+ {
+ SvTreeListBox::NotifyMoving(
+ pTarget, pSource, rpNewParent, rNewChildPos );
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+ else
+ {
+ return NotifyCopying( pTarget, pSource, rpNewParent, rNewChildPos );
+ }
+}
+
+BOOL SvxMenuEntriesListBox::NotifyCopying(
+ SvLBoxEntry* pTarget, SvLBoxEntry* pSource,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos)
+{
+ (void)pSource;
+ (void)rpNewParent;
+ (void)rNewChildPos;
+
+ if ( !m_bIsInternalDrag )
+ {
+ // if the target is NULL then add function to the start of the list
+ pPage->AddFunction( pTarget, pTarget == NULL );
+
+ // AddFunction already adds the listbox entry so return FALSE
+ // to stop another listbox entry being added
+ return FALSE;
+ }
+
+ // Copying is only allowed from external controls, not within the listbox
+ return FALSE;
+}
+
+void SvxMenuEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
+{
+ KeyCode keycode = rKeyEvent.GetKeyCode();
+
+ // support DELETE for removing the current entry
+ if ( keycode == KEY_DELETE )
+ {
+ pPage->DeleteSelectedContent();
+ }
+ // support CTRL+UP and CTRL+DOWN for moving selected entries
+ else if ( keycode.GetCode() == KEY_UP && keycode.IsMod1() )
+ {
+ pPage->MoveEntry( TRUE );
+ }
+ else if ( keycode.GetCode() == KEY_DOWN && keycode.IsMod1() )
+ {
+ pPage->MoveEntry( FALSE );
+ }
+ else
+ {
+ // pass on to superclass
+ SvTreeListBox::KeyInput( rKeyEvent );
+ }
+}
+
+// class SvxDescriptionEdit ----------------------------------------------
+
+SvxDescriptionEdit::SvxDescriptionEdit( Window* pParent, const ResId& _rId ) :
+
+ ExtMultiLineEdit( pParent, _rId )
+
+{
+ // calculate the available space for help text
+ m_aRealRect = Rectangle( Point(), GetSizePixel() );
+ if ( GetVScrollBar() )
+ m_aRealRect.Right() -= ( GetVScrollBar()->GetSizePixel().Width() + 4 );
+
+ SetLeftMargin(2);
+ SetBorderStyle( WINDOW_BORDER_MONO );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxDescriptionEdit::SetNewText( const String& _rText )
+{
+ String sTemp( _rText );
+ sal_Bool bShow = sal_False;
+ if ( sTemp.Len() > 0 )
+ {
+ // detect if a scrollbar is necessary
+ Rectangle aRect = GetTextRect( m_aRealRect, sTemp, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE );
+ bShow = ( aRect.Bottom() > m_aRealRect.Bottom() );
+ }
+
+ if ( GetVScrollBar() )
+ GetVScrollBar()->Show( bShow );
+
+ if ( bShow )
+ sTemp += '\n';
+
+ SetText( sTemp );
+}
+
+/******************************************************************************
+ *
+ * SvxConfigPage is the abstract base class on which the Menu and Toolbar
+ * configuration tabpages are based. It includes methods which are common to
+ * both tabpages to add, delete, move and rename items etc.
+ *
+ *****************************************************************************/
+SvxConfigPage::SvxConfigPage(
+ Window *pParent, const SfxItemSet& rSet )
+ :
+ SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_MENUS ), rSet ),
+ bInitialised( FALSE ),
+ pCurrentSaveInData( 0 ),
+ aTopLevelSeparator( this, CUI_RES( GRP_MENUS ) ),
+ aTopLevelLabel( this, CUI_RES( FT_MENUS ) ),
+ aTopLevelListBox( this, CUI_RES( LB_MENUS ) ),
+ aNewTopLevelButton( this, CUI_RES( BTN_NEW ) ),
+ aModifyTopLevelButton( this, CUI_RES( BTN_CHANGE ) ),
+ aContentsSeparator( this, CUI_RES( GRP_MENU_SEPARATOR ) ),
+ aContentsLabel( this, CUI_RES( GRP_MENU_ENTRIES ) ),
+ aContentsListBox( 0 ),
+ aAddCommandsButton( this, CUI_RES( BTN_ADD_COMMANDS ) ),
+ aModifyCommandButton( this, CUI_RES( BTN_CHANGE_ENTRY ) ),
+ aMoveUpButton( this, CUI_RES( BTN_UP ) ),
+ aMoveDownButton( this, CUI_RES( BTN_DOWN ) ),
+ aSaveInText( this, CUI_RES( TXT_SAVEIN ) ),
+ aSaveInListBox( this, CUI_RES( LB_SAVEIN ) ),
+ aDescriptionLabel( this, CUI_RES( FT_DESCRIPTION ) ),
+ aDescriptionField( this, CUI_RES( ED_DESCRIPTION ) ),
+ pSelectorDlg( 0 )
+{
+ aDescriptionField.SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
+ aDescriptionField.SetAutoScroll( TRUE );
+ aDescriptionField.EnableCursor( FALSE );
+}
+
+SvxConfigPage::~SvxConfigPage()
+{
+}
+
+void SvxConfigPage::Reset( const SfxItemSet& )
+{
+ // If we haven't initialised our XMultiServiceFactory reference
+ // then Reset is being called at the opening of the dialog.
+ //
+ // Load menu configuration data for the module of the currently
+ // selected document, for the currently selected document, and for
+ // all other open documents of the same module type
+ if ( !bInitialised )
+ {
+ USHORT nPos = 0;
+ uno::Reference < css::ui::XUIConfigurationManager > xCfgMgr;
+ uno::Reference < css::ui::XUIConfigurationManager > xDocCfgMgr;
+
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager(
+ ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+
+ m_xFrame = GetFrame();
+ OUString aModuleId = GetFrameWithDefaultAndIdentify( m_xFrame );
+
+ // replace %MODULENAME in the label with the correct module name
+ uno::Reference< css::frame::XModuleManager > xModuleManager(
+ xServiceManager->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.frame.ModuleManager" ) ) ),
+ uno::UNO_QUERY_THROW );
+ OUString aModuleName = GetUIModuleName( aModuleId, xModuleManager );
+
+ OUString title = aTopLevelSeparator.GetText();
+ OUString aSearchString = OUString::createFromAscii( "%MODULENAME" );
+ sal_Int32 index = title.indexOf( aSearchString );
+
+ if ( index != -1 )
+ {
+ title = title.replaceAt(
+ index, aSearchString.getLength(), aModuleName );
+ aTopLevelSeparator.SetText( title );
+ }
+
+ uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier >
+ xModuleCfgSupplier( xServiceManager->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ))),
+ uno::UNO_QUERY );
+
+ // Set up data for module specific menus
+ SaveInData* pModuleData = NULL;
+
+ try
+ {
+ xCfgMgr =
+ xModuleCfgSupplier->getUIConfigurationManager( aModuleId );
+
+ pModuleData = CreateSaveInData( xCfgMgr,
+ uno::Reference< css::ui::XUIConfigurationManager >(),
+ aModuleId,
+ FALSE );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ }
+
+ if ( pModuleData != NULL )
+ {
+ OUString label;
+ utl::ConfigManager::GetDirectConfigProperty(
+ utl::ConfigManager::PRODUCTNAME ) >>= label;
+ label += OUString::createFromAscii( " " );
+ label += aModuleName;
+
+ nPos = aSaveInListBox.InsertEntry( label );
+ aSaveInListBox.SetEntryData( nPos, pModuleData );
+ }
+
+ // try to retrieve the document based ui configuration manager
+ OUString aTitle;
+ uno::Reference< frame::XController > xController =
+ m_xFrame->getController();
+ if ( CanConfig( aModuleId ) && xController.is() )
+ {
+ uno::Reference< frame::XModel > xModel( xController->getModel() );
+ if ( xModel.is() )
+ {
+ uno::Reference< css::ui::XUIConfigurationManagerSupplier >
+ xCfgSupplier( xModel, uno::UNO_QUERY );
+
+ if ( xCfgSupplier.is() )
+ {
+ xDocCfgMgr = xCfgSupplier->getUIConfigurationManager();
+ }
+ aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
+ }
+ }
+
+ SaveInData* pDocData = NULL;
+ if ( xDocCfgMgr.is() )
+ {
+ pDocData = CreateSaveInData( xDocCfgMgr, xCfgMgr, aModuleId, TRUE );
+
+ if ( !pDocData->IsReadOnly() )
+ {
+ nPos = aSaveInListBox.InsertEntry( aTitle );
+ aSaveInListBox.SetEntryData( nPos, pDocData );
+ }
+ }
+
+ // if an item to select has been passed in (eg. the ResourceURL for a
+ // toolbar) then try to select the SaveInData entry that has that item
+ bool bURLToSelectFound = FALSE;
+ if ( m_aURLToSelect.getLength() != 0 )
+ {
+ if ( pDocData != NULL && pDocData->HasURL( m_aURLToSelect ) )
+ {
+ aSaveInListBox.SelectEntryPos( nPos, TRUE );
+ pCurrentSaveInData = pDocData;
+ bURLToSelectFound = TRUE;
+ }
+ else if ( pModuleData->HasURL( m_aURLToSelect ) )
+ {
+ aSaveInListBox.SelectEntryPos( 0, TRUE );
+ pCurrentSaveInData = pModuleData;
+ bURLToSelectFound = TRUE;
+ }
+ }
+
+ if ( bURLToSelectFound == FALSE )
+ {
+ // if the document has menu configuration settings select it
+ // it the SaveIn listbox, otherwise select the module data
+ if ( pDocData != NULL && pDocData->HasSettings() )
+ {
+ aSaveInListBox.SelectEntryPos( nPos, TRUE );
+ pCurrentSaveInData = pDocData;
+ }
+ else
+ {
+ aSaveInListBox.SelectEntryPos( 0, TRUE );
+ pCurrentSaveInData = pModuleData;
+ }
+ }
+
+#ifdef DBG_UTIL
+ DBG_ASSERT( pCurrentSaveInData, "SvxConfigPage::Reset(): no SaveInData" );
+#endif
+
+ if ( CanConfig( aModuleId ) )
+ {
+ // Load configuration for other open documents which have
+ // same module type
+ uno::Sequence< uno::Reference< frame::XFrame > > aFrameList;
+ try
+ {
+ uno::Reference< frame::XFramesSupplier > xFramesSupplier(
+ xServiceManager->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.frame.Desktop" ) ) ),
+ uno::UNO_QUERY_THROW );
+
+ uno::Reference< frame::XFrames > xFrames =
+ xFramesSupplier->getFrames();
+
+ aFrameList = xFrames->queryFrames(
+ frame::FrameSearchFlag::ALL & ~frame::FrameSearchFlag::SELF );
+
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ for ( sal_Int32 i = 0; i < aFrameList.getLength(); i++ )
+ {
+ SaveInData* pData = NULL;
+ uno::Reference < frame::XFrame > xf = aFrameList[i];
+
+ if ( xf.is() && xf != m_xFrame )
+ {
+ OUString aCheckId;
+ try{
+ aCheckId = xModuleManager->identify( xf );
+ } catch(const uno::Exception&)
+ { aCheckId = ::rtl::OUString(); }
+
+ if ( aModuleId.equals( aCheckId ) )
+ {
+ // try to get the document based ui configuration manager
+ OUString aTitle2;
+ uno::Reference< frame::XController > xController_ =
+ xf->getController();
+
+ if ( xController_.is() )
+ {
+ uno::Reference< frame::XModel > xModel(
+ xController_->getModel() );
+
+ if ( xModel.is() )
+ {
+ uno::Reference<
+ css::ui::XUIConfigurationManagerSupplier >
+ xCfgSupplier( xModel, uno::UNO_QUERY );
+
+ if ( xCfgSupplier.is() )
+ {
+ xDocCfgMgr =
+ xCfgSupplier->getUIConfigurationManager();
+ }
+ aTitle2 = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
+ }
+ }
+
+ if ( xDocCfgMgr.is() )
+ {
+ pData = CreateSaveInData( xDocCfgMgr, xCfgMgr, aModuleId, TRUE );
+
+ if ( pData && !pData->IsReadOnly() )
+ {
+ nPos = aSaveInListBox.InsertEntry( aTitle2 );
+ aSaveInListBox.SetEntryData( nPos, pData );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ aSaveInListBox.SetSelectHdl(
+ LINK( this, SvxConfigPage, SelectSaveInLocation ) );
+
+ bInitialised = TRUE;
+
+ Init();
+ }
+ else
+ {
+ if ( QueryReset() == RET_YES )
+ {
+ // Reset menu configuration for currently selected SaveInData
+ GetSaveInData()->Reset();
+
+ Init();
+ }
+ }
+}
+
+::rtl::OUString SvxConfigPage::GetFrameWithDefaultAndIdentify( uno::Reference< frame::XFrame >& _inout_rxFrame )
+{
+ ::rtl::OUString sModuleID;
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager(
+ ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< frame::XFramesSupplier > xFramesSupplier(
+ xServiceManager->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.frame.Desktop" ) ) ),
+ uno::UNO_QUERY_THROW );
+
+ if ( !_inout_rxFrame.is() )
+ _inout_rxFrame = xFramesSupplier->getActiveFrame();
+
+ if ( !_inout_rxFrame.is() )
+ {
+ uno::Reference< frame::XDesktop > xDesktop( xFramesSupplier, uno::UNO_QUERY_THROW );
+ _inout_rxFrame = xDesktop->getCurrentFrame();
+ }
+
+ if ( !_inout_rxFrame.is() && SfxViewFrame::Current() )
+ _inout_rxFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+
+ if ( !_inout_rxFrame.is() )
+ {
+ DBG_ERRORFILE( "SvxConfigPage::GetFrameWithDefaultAndIdentify(): no frame found!" );
+ return sModuleID;
+ }
+
+ uno::Reference< css::frame::XModuleManager > xModuleManager(
+ xServiceManager->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.frame.ModuleManager" ) ) ),
+ uno::UNO_QUERY_THROW );
+
+ try
+ {
+ sModuleID = xModuleManager->identify( _inout_rxFrame );
+ }
+ catch ( const frame::UnknownModuleException& )
+ {
+ }
+
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sModuleID;
+}
+
+BOOL SvxConfigPage::FillItemSet( SfxItemSet& )
+{
+ bool result = FALSE;
+
+ for ( USHORT i = 0 ; i < aSaveInListBox.GetEntryCount(); i++ )
+ {
+ SaveInData* pData =
+ (SaveInData*) aSaveInListBox.GetEntryData( i );
+
+ result = pData->Apply();
+ }
+ return result;
+}
+
+void SvxConfigPage::PositionContentsListBox()
+{
+ if ( aContentsListBox == NULL )
+ {
+ return;
+ }
+
+ Point p, newp;
+ Size s, news;
+ long x, y, width, height;
+
+ // x and width is same as aTopLevelListBox
+ x = aTopLevelListBox.GetPosPixel().X();
+ width = aTopLevelListBox.GetSizePixel().Width();
+
+ // y is same as aAddCommandsButton
+ y = aAddCommandsButton.GetPosPixel().Y();
+
+ // get gap between aAddCommandsButton and aContentsSeparator
+ p = aContentsSeparator.GetPosPixel();
+ s = aContentsSeparator.GetSizePixel();
+ long gap = y - ( p.Y() + s.Height() );
+
+ height = aSaveInListBox.GetPosPixel().Y() - y - gap;
+
+ aContentsListBox->SetPosPixel( Point( x, y ) );
+ aContentsListBox->SetSizePixel( Size( width, height ) );
+}
+
+IMPL_LINK( SvxConfigPage, SelectSaveInLocation, ListBox *, pBox )
+{
+ (void)pBox;
+
+ pCurrentSaveInData = (SaveInData*) aSaveInListBox.GetEntryData(
+ aSaveInListBox.GetSelectEntryPos());
+
+ Init();
+ return 1;
+}
+
+void SvxConfigPage::ReloadTopLevelListBox( SvxConfigEntry* pToSelect )
+{
+ USHORT nSelectionPos = aTopLevelListBox.GetSelectEntryPos();
+ aTopLevelListBox.Clear();
+
+ if ( GetSaveInData() && GetSaveInData()->GetEntries() )
+ {
+ SvxEntries::const_iterator iter = GetSaveInData()->GetEntries()->begin();
+ SvxEntries::const_iterator end = GetSaveInData()->GetEntries()->end();
+
+ for ( ; iter != end; iter++ )
+ {
+ SvxConfigEntry* pEntryData = *iter;
+ USHORT nPos = aTopLevelListBox.InsertEntry( stripHotKey( pEntryData->GetName() ) );
+ aTopLevelListBox.SetEntryData( nPos, pEntryData );
+
+ if ( pEntryData == pToSelect )
+ nSelectionPos = nPos;
+
+ AddSubMenusToUI( stripHotKey( pEntryData->GetName() ), pEntryData );
+ }
+ }
+#ifdef DBG_UTIL
+ else
+ {
+ DBG_ASSERT( GetSaveInData(), "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData" );
+ DBG_ASSERT( GetSaveInData()->GetEntries() ,
+ "SvxConfigPage::ReloadTopLevelListBox(): no SaveInData entries" );
+ }
+#endif
+
+ nSelectionPos = nSelectionPos < aTopLevelListBox.GetEntryCount() ?
+ nSelectionPos : aTopLevelListBox.GetEntryCount() - 1;
+
+ aTopLevelListBox.SelectEntryPos( nSelectionPos, TRUE );
+ aTopLevelListBox.GetSelectHdl().Call( this );
+}
+
+void SvxConfigPage::AddSubMenusToUI(
+ const String& rBaseTitle, SvxConfigEntry* pParentData )
+{
+ SvxEntries::const_iterator iter = pParentData->GetEntries()->begin();
+ SvxEntries::const_iterator end = pParentData->GetEntries()->end();
+
+ for ( ; iter != end; iter++ )
+ {
+ SvxConfigEntry* pEntryData = *iter;
+
+ if ( pEntryData->IsPopup() )
+ {
+ OUString subMenuTitle( rBaseTitle );
+ subMenuTitle += OUString::createFromAscii( pMenuSeparatorStr );
+ subMenuTitle += stripHotKey( pEntryData->GetName() );
+
+ USHORT nPos = aTopLevelListBox.InsertEntry( subMenuTitle );
+ aTopLevelListBox.SetEntryData( nPos, pEntryData );
+
+ AddSubMenusToUI( subMenuTitle, pEntryData );
+ }
+ }
+}
+
+SvxEntries* SvxConfigPage::FindParentForChild(
+ SvxEntries* pRootEntries, SvxConfigEntry* pChildData )
+{
+ SvxEntries::const_iterator iter = pRootEntries->begin();
+ SvxEntries::const_iterator end = pRootEntries->end();
+
+ for ( ; iter != end; iter++ )
+ {
+ SvxConfigEntry* pEntryData = *iter;
+
+ if ( pEntryData == pChildData )
+ {
+ return pRootEntries;
+ }
+ else if ( pEntryData->IsPopup() )
+ {
+ SvxEntries* result =
+ FindParentForChild( pEntryData->GetEntries(), pChildData );
+
+ if ( result != NULL )
+ {
+ return result;
+ }
+ }
+ }
+ return NULL;
+}
+
+SvLBoxEntry* SvxConfigPage::AddFunction(
+ SvLBoxEntry* pTarget, bool bFront, bool bAllowDuplicates )
+{
+ String aDisplayName = pSelectorDlg->GetSelectedDisplayName();
+ String aHelpText = pSelectorDlg->GetSelectedHelpText();
+ String aURL = pSelectorDlg->GetScriptURL();
+
+ if ( !aURL.Len() )
+ {
+ return NULL;
+ }
+
+ SvxConfigEntry* pNewEntryData =
+ new SvxConfigEntry( aDisplayName, aURL, FALSE );
+ pNewEntryData->SetUserDefined( TRUE );
+ pNewEntryData->SetHelpURL( aURL );
+
+ // check that this function is not already in the menu
+ SvxConfigEntry* pParent = GetTopLevelSelection();
+
+ SvxEntries::const_iterator iter = pParent->GetEntries()->begin();
+ SvxEntries::const_iterator end = pParent->GetEntries()->end();
+
+ if ( !bAllowDuplicates )
+ {
+ while ( iter != end )
+ {
+ SvxConfigEntry *pCurEntry = *iter;
+
+ if ( pCurEntry->GetCommand() == pNewEntryData->GetCommand() )
+ {
+ // asynchronous error message, because of MsgBoxes
+ PostUserEvent(
+ LINK( this, SvxConfigPage, AsyncInfoMsg ) );
+ return NULL;
+ }
+
+ iter++;
+ }
+ }
+
+ return InsertEntry( pNewEntryData, pTarget, bFront );
+}
+
+SvLBoxEntry* SvxConfigPage::InsertEntry(
+ SvxConfigEntry* pNewEntryData,
+ SvLBoxEntry* pTarget,
+ bool bFront )
+{
+ // Grab the entries list for the currently selected menu
+ SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
+
+ SvLBoxEntry* pNewEntry = NULL;
+ SvLBoxEntry* pCurEntry =
+ pTarget != NULL ? pTarget : aContentsListBox->GetCurEntry();
+
+ if ( bFront )
+ {
+ pEntries->insert( pEntries->begin(), pNewEntryData );
+ pNewEntry = InsertEntryIntoUI( pNewEntryData, 0 );
+ }
+ else if ( pCurEntry == NULL || pCurEntry == aContentsListBox->Last() )
+ {
+ pEntries->push_back( pNewEntryData );
+ pNewEntry = InsertEntryIntoUI( pNewEntryData );
+ }
+ else
+ {
+ SvxConfigEntry* pEntryData =
+ (SvxConfigEntry*) pCurEntry->GetUserData();
+
+ SvxEntries::iterator iter = pEntries->begin();
+ SvxEntries::const_iterator end = pEntries->end();
+
+ // Advance the iterator to the data for currently selected entry
+ USHORT nPos = 0;
+ while (*iter != pEntryData && ++iter != end)
+ {
+ nPos++;
+ }
+
+ // Now step past it to the entry after the currently selected one
+ iter++;
+ nPos++;
+
+ // Now add the new entry to the UI and to the parent's list
+ if ( iter != end )
+ {
+ pEntries->insert( iter, pNewEntryData );
+ pNewEntry = InsertEntryIntoUI( pNewEntryData, nPos );
+ }
+ }
+
+ if ( pNewEntry != NULL )
+ {
+ aContentsListBox->Select( pNewEntry );
+ aContentsListBox->MakeVisible( pNewEntry );
+
+ GetSaveInData()->SetModified( TRUE );
+ }
+
+ return pNewEntry;
+}
+
+SvLBoxEntry* SvxConfigPage::InsertEntryIntoUI(
+ SvxConfigEntry* pNewEntryData, ULONG nPos )
+{
+ SvLBoxEntry* pNewEntry = NULL;
+
+ if (pNewEntryData->IsSeparator())
+ {
+ pNewEntry = aContentsListBox->InsertEntry(
+ String::CreateFromAscii( pSeparatorStr ),
+ 0, FALSE, nPos, pNewEntryData );
+ }
+ else
+ {
+ OUString aName = stripHotKey( pNewEntryData->GetName() );
+
+ Image aImage = GetSaveInData()->GetImage(
+ pNewEntryData->GetCommand());
+
+ if ( !!aImage )
+ {
+ pNewEntry = aContentsListBox->InsertEntry(
+ aName, aImage, aImage, 0, FALSE, nPos, pNewEntryData );
+ }
+ else
+ {
+ pNewEntry = aContentsListBox->InsertEntry(
+ aName, 0, FALSE, nPos, pNewEntryData );
+ }
+
+ if ( pNewEntryData->IsPopup() ||
+ pNewEntryData->GetStyle() & css::ui::ItemStyle::DROP_DOWN )
+ {
+ // add new popup painter, it gets destructed by the entry
+ pNewEntry->ReplaceItem(
+ new PopupPainter( pNewEntry, aName ),
+ pNewEntry->ItemCount() - 1 );
+ }
+ }
+
+ return pNewEntry;
+}
+
+IMPL_LINK( SvxConfigPage, AsyncInfoMsg, String*, pMsg )
+{
+ (void)pMsg;
+
+ // Asynchronous msg because of D&D
+ InfoBox( this, CUI_RES(
+ IBX_MNUCFG_ALREADY_INCLUDED ) ).Execute();
+
+ return 0;
+}
+
+IMPL_LINK( SvxConfigPage, MoveHdl, Button *, pButton )
+{
+ MoveEntry( pButton == &aMoveUpButton );
+ return 0;
+}
+
+void SvxConfigPage::MoveEntry( bool bMoveUp )
+{
+ SvLBoxEntry *pSourceEntry = aContentsListBox->FirstSelected();
+ SvLBoxEntry *pTargetEntry = NULL;
+ SvLBoxEntry *pToSelect = NULL;
+
+ if ( !pSourceEntry )
+ {
+ return;
+ }
+
+ if ( bMoveUp )
+ {
+ // Move Up is just a Move Down with the source and target reversed
+ pTargetEntry = pSourceEntry;
+ pSourceEntry = aContentsListBox->PrevSibling( pTargetEntry );
+ pToSelect = pTargetEntry;
+ }
+ else
+ {
+ pTargetEntry = aContentsListBox->NextSibling( pSourceEntry );
+ pToSelect = pSourceEntry;
+ }
+
+ if ( MoveEntryData( pSourceEntry, pTargetEntry ) )
+ {
+ aContentsListBox->GetModel()->Move( pSourceEntry, pTargetEntry );
+ aContentsListBox->Select( pToSelect );
+ aContentsListBox->MakeVisible( pToSelect );
+
+ UpdateButtonStates();
+ }
+}
+
+bool SvxConfigPage::MoveEntryData(
+ SvLBoxEntry* pSourceEntry, SvLBoxEntry* pTargetEntry )
+{
+ //modified by shizhoubo for issue53677
+ if ( NULL == pSourceEntry || NULL == pTargetEntry )
+ {
+ return FALSE;
+ }
+
+ // Grab the entries list for the currently selected menu
+ SvxEntries* pEntries = GetTopLevelSelection()->GetEntries();
+
+ SvxConfigEntry* pSourceData =
+ (SvxConfigEntry*) pSourceEntry->GetUserData();
+
+ if ( pTargetEntry == NULL )
+ {
+ RemoveEntry( pEntries, pSourceData );
+ pEntries->insert(
+ pEntries->begin(), pSourceData );
+
+ GetSaveInData()->SetModified( TRUE );
+
+ return TRUE;
+ }
+ else
+ {
+ SvxConfigEntry* pTargetData =
+ (SvxConfigEntry*) pTargetEntry->GetUserData();
+
+ if ( pSourceData != NULL && pTargetData != NULL )
+ {
+ // remove the source entry from our list
+ RemoveEntry( pEntries, pSourceData );
+
+ SvxEntries::iterator iter = pEntries->begin();
+ SvxEntries::const_iterator end = pEntries->end();
+
+ // advance the iterator to the position of the target entry
+ while (*iter != pTargetData && ++iter != end) ;
+
+ // insert the source entry at the position after the target
+ pEntries->insert( ++iter, pSourceData );
+
+ GetSaveInData()->SetModified( TRUE );
+
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+SvxMenuConfigPage::SvxMenuConfigPage(
+ Window *pParent, const SfxItemSet& rSet )
+ :
+ SvxConfigPage( pParent, rSet )
+{
+ aContentsListBox = new SvxMenuEntriesListBox( this, CUI_RES( BOX_ENTRIES ) );
+ FreeResource();
+
+ PositionContentsListBox();
+ aContentsListBox->SetZOrder( &aAddCommandsButton, WINDOW_ZORDER_BEFOR );
+
+ aTopLevelListBox.SetSelectHdl(
+ LINK( this, SvxMenuConfigPage, SelectMenu ) );
+
+ aContentsListBox->SetSelectHdl(
+ LINK( this, SvxMenuConfigPage, SelectMenuEntry ) );
+
+ aMoveUpButton.SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
+ aMoveDownButton.SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
+
+ aNewTopLevelButton.SetClickHdl (
+ LINK( this, SvxMenuConfigPage, NewMenuHdl ) );
+
+ aAddCommandsButton.SetClickHdl (
+ LINK( this, SvxMenuConfigPage, AddCommandsHdl ) );
+
+ PopupMenu* pMenu = new PopupMenu( CUI_RES( MODIFY_MENU ) );
+ pMenu->SetMenuFlags(
+ pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
+
+ aModifyTopLevelButton.SetPopupMenu( pMenu );
+ aModifyTopLevelButton.SetSelectHdl(
+ LINK( this, SvxMenuConfigPage, MenuSelectHdl ) );
+
+ PopupMenu* pEntry = new PopupMenu( CUI_RES( MODIFY_ENTRY ) );
+ pEntry->SetMenuFlags(
+ pEntry->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
+
+ aModifyCommandButton.SetPopupMenu( pEntry );
+ aModifyCommandButton.SetSelectHdl(
+ LINK( this, SvxMenuConfigPage, EntrySelectHdl ) );
+}
+
+// Populates the Menu combo box
+void SvxMenuConfigPage::Init()
+{
+ // ensure that the UI is cleared before populating it
+ aTopLevelListBox.Clear();
+ aContentsListBox->Clear();
+
+ ReloadTopLevelListBox();
+
+ aTopLevelListBox.SelectEntryPos(0, TRUE);
+ aTopLevelListBox.GetSelectHdl().Call(this);
+}
+
+SvxMenuConfigPage::~SvxMenuConfigPage()
+{
+ for ( USHORT i = 0 ; i < aSaveInListBox.GetEntryCount(); i++ )
+ {
+ MenuSaveInData* pData =
+ (MenuSaveInData*) aSaveInListBox.GetEntryData( i );
+
+ delete pData;
+ }
+
+ if ( pSelectorDlg != NULL )
+ {
+ delete pSelectorDlg;
+ }
+
+ delete aContentsListBox;
+}
+
+IMPL_LINK( SvxMenuConfigPage, SelectMenuEntry, Control *, pBox )
+{
+ (void)pBox;
+
+ UpdateButtonStates();
+
+ return 1;
+}
+
+void SvxMenuConfigPage::UpdateButtonStates()
+{
+ PopupMenu* pPopup = aModifyCommandButton.GetPopupMenu();
+
+ // Disable Up and Down buttons depending on current selection
+ SvLBoxEntry* selection = aContentsListBox->GetCurEntry();
+
+ if ( aContentsListBox->GetEntryCount() == 0 || selection == NULL )
+ {
+ aMoveUpButton.Enable( FALSE );
+ aMoveDownButton.Enable( FALSE );
+
+ pPopup->EnableItem( ID_BEGIN_GROUP, TRUE );
+ pPopup->EnableItem( ID_RENAME, FALSE );
+ pPopup->EnableItem( ID_DELETE, FALSE );
+
+ aDescriptionField.Clear();
+
+ return;
+ }
+
+ SvLBoxEntry* first = aContentsListBox->First();
+ SvLBoxEntry* last = aContentsListBox->Last();
+
+ aMoveUpButton.Enable( selection != first );
+ aMoveDownButton.Enable( selection != last );
+
+ SvxConfigEntry* pEntryData =
+ (SvxConfigEntry*) selection->GetUserData();
+
+ if ( pEntryData->IsSeparator() )
+ {
+ pPopup->EnableItem( ID_DELETE, TRUE );
+ pPopup->EnableItem( ID_BEGIN_GROUP, FALSE );
+ pPopup->EnableItem( ID_RENAME, FALSE );
+
+ aDescriptionField.Clear();
+ }
+ else
+ {
+ pPopup->EnableItem( ID_BEGIN_GROUP, TRUE );
+ pPopup->EnableItem( ID_DELETE, TRUE );
+ pPopup->EnableItem( ID_RENAME, TRUE );
+
+ aDescriptionField.SetNewText( pEntryData->GetHelpText() );
+ }
+}
+
+void SvxMenuConfigPage::DeleteSelectedTopLevel()
+{
+ SvxConfigEntry* pMenuData = GetTopLevelSelection();
+
+ SvxEntries* pParentEntries =
+ FindParentForChild( GetSaveInData()->GetEntries(), pMenuData );
+
+ RemoveEntry( pParentEntries, pMenuData );
+ delete pMenuData;
+
+ ReloadTopLevelListBox();
+
+ GetSaveInData()->SetModified( TRUE );
+}
+
+bool SvxMenuConfigPage::DeleteSelectedContent()
+{
+ SvLBoxEntry *pActEntry = aContentsListBox->FirstSelected();
+
+ if ( pActEntry != NULL )
+ {
+ // get currently selected menu entry
+ SvxConfigEntry* pMenuEntry =
+ (SvxConfigEntry*) pActEntry->GetUserData();
+
+ // get currently selected menu
+ SvxConfigEntry* pMenu = GetTopLevelSelection();
+
+ // remove menu entry from the list for this menu
+ RemoveEntry( pMenu->GetEntries(), pMenuEntry );
+
+ // remove menu entry from UI
+ aContentsListBox->GetModel()->Remove( pActEntry );
+
+ // if this is a submenu entry, redraw the menus list box
+ if ( pMenuEntry->IsPopup() )
+ {
+ ReloadTopLevelListBox();
+ }
+
+ // delete data for menu entry
+ delete pMenuEntry;
+
+ GetSaveInData()->SetModified( TRUE );
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+short SvxMenuConfigPage::QueryReset()
+{
+ String msg =
+ String( CUI_RES( RID_SVXSTR_CONFIRM_MENU_RESET ) );
+
+ String saveInName = aSaveInListBox.GetEntry(
+ aSaveInListBox.GetSelectEntryPos() );
+
+ OUString label = replaceSaveInName( msg, saveInName );
+
+ QueryBox qbox( this, WB_YES_NO, label );
+
+ return qbox.Execute();
+}
+
+IMPL_LINK( SvxMenuConfigPage, SelectMenu, ListBox *, pBox )
+{
+ (void)pBox;
+
+ aContentsListBox->Clear();
+
+ SvxConfigEntry* pMenuData = GetTopLevelSelection();
+
+ PopupMenu* pPopup = aModifyTopLevelButton.GetPopupMenu();
+ pPopup->EnableItem( ID_DELETE, pMenuData->IsDeletable() );
+ pPopup->EnableItem( ID_RENAME, pMenuData->IsRenamable() );
+ pPopup->EnableItem( ID_MOVE, pMenuData->IsMovable() );
+
+ SvxEntries* pEntries = pMenuData->GetEntries();
+ SvxEntries::const_iterator iter = pEntries->begin();
+
+ for ( ; iter != pEntries->end(); iter++ )
+ {
+ SvxConfigEntry* pEntry = *iter;
+ InsertEntryIntoUI( pEntry );
+ }
+
+ UpdateButtonStates();
+
+ return 0;
+}
+
+IMPL_LINK( SvxMenuConfigPage, MenuSelectHdl, MenuButton *, pButton )
+{
+ switch( pButton->GetCurItemId() )
+ {
+ case ID_DELETE:
+ {
+ DeleteSelectedTopLevel();
+ break;
+ }
+ case ID_RENAME:
+ {
+ SvxConfigEntry* pMenuData = GetTopLevelSelection();
+
+ String aNewName( stripHotKey( pMenuData->GetName() ) );
+ String aDesc = CUI_RESSSTR( RID_SVXSTR_LABEL_NEW_NAME );
+
+ SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
+ pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_MENU );
+ pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_MENU ) );
+
+ bool ret = pNameDialog->Execute();
+
+ if ( ret == RET_OK ) {
+ pNameDialog->GetName( aNewName );
+ pMenuData->SetName( aNewName );
+
+ ReloadTopLevelListBox();
+
+ GetSaveInData()->SetModified( TRUE );
+ }
+
+ // #i68101# Moemory leak (!)
+ delete pNameDialog;
+
+ break;
+ }
+ case ID_MOVE:
+ {
+ SvxConfigEntry* pMenuData = GetTopLevelSelection();
+
+ SvxMainMenuOrganizerDialog* pDialog =
+ new SvxMainMenuOrganizerDialog( this,
+ GetSaveInData()->GetEntries(), pMenuData );
+
+ bool ret = pDialog->Execute();
+
+ if ( ret == RET_OK )
+ {
+ GetSaveInData()->SetEntries( pDialog->GetEntries() );
+
+ ReloadTopLevelListBox( pDialog->GetSelectedEntry() );
+
+ GetSaveInData()->SetModified( TRUE );
+ }
+
+ delete pDialog;
+
+ break;
+ }
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+IMPL_LINK( SvxMenuConfigPage, EntrySelectHdl, MenuButton *, pButton )
+{
+ switch( pButton->GetCurItemId() )
+ {
+ case ID_ADD_SUBMENU:
+ {
+ String aNewName;
+ String aDesc = CUI_RESSSTR( RID_SVXSTR_SUBMENU_NAME );
+
+ SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
+ pNameDialog->SetHelpId( HID_SVX_CONFIG_NAME_SUBMENU );
+ pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_ADD_SUBMENU ) );
+
+ bool ret = pNameDialog->Execute();
+
+ if ( ret == RET_OK ) {
+ pNameDialog->GetName(aNewName);
+
+ SvxConfigEntry* pNewEntryData =
+ new SvxConfigEntry( aNewName, aNewName, TRUE );
+ pNewEntryData->SetUserDefined( TRUE );
+
+ InsertEntry( pNewEntryData );
+
+ ReloadTopLevelListBox();
+
+ GetSaveInData()->SetModified( TRUE );
+ }
+
+ delete pNameDialog;
+
+ break;
+ }
+ case ID_BEGIN_GROUP:
+ {
+ SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
+ pNewEntryData->SetUserDefined( TRUE );
+ InsertEntry( pNewEntryData );
+
+ break;
+ }
+ case ID_DELETE:
+ {
+ DeleteSelectedContent();
+ break;
+ }
+ case ID_RENAME:
+ {
+ SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
+ SvxConfigEntry* pEntry =
+ (SvxConfigEntry*) pActEntry->GetUserData();
+
+ String aNewName( stripHotKey( pEntry->GetName() ) );
+ String aDesc = CUI_RESSSTR( RID_SVXSTR_LABEL_NEW_NAME );
+
+ SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
+ pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_MENU_ITEM );
+ pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_MENU ) );
+
+ bool ret = pNameDialog->Execute();
+
+ if ( ret == RET_OK ) {
+ pNameDialog->GetName(aNewName);
+
+ pEntry->SetName( aNewName );
+ aContentsListBox->SetEntryText( pActEntry, aNewName );
+
+ GetSaveInData()->SetModified( TRUE );
+ }
+
+ delete pNameDialog;
+
+ break;
+ }
+ default:
+ {
+ return FALSE;
+ }
+ }
+
+ if ( GetSaveInData()->IsModified() )
+ {
+ UpdateButtonStates();
+ }
+
+ return TRUE;
+}
+
+IMPL_LINK( SvxMenuConfigPage, AddFunctionHdl,
+ SvxScriptSelectorDialog *, pDialog )
+{
+ (void)pDialog;
+
+ AddFunction();
+
+ return 0;
+}
+
+IMPL_LINK( SvxMenuConfigPage, NewMenuHdl, Button *, pButton )
+{
+ (void)pButton;
+
+ SvxMainMenuOrganizerDialog* pDialog =
+ new SvxMainMenuOrganizerDialog( 0,
+ GetSaveInData()->GetEntries(), NULL, TRUE );
+
+ bool ret = pDialog->Execute();
+
+ if ( ret == RET_OK )
+ {
+ GetSaveInData()->SetEntries( pDialog->GetEntries() );
+ ReloadTopLevelListBox( pDialog->GetSelectedEntry() );
+ GetSaveInData()->SetModified( TRUE );
+ }
+
+ delete pDialog;
+
+ return 0;
+}
+
+IMPL_LINK( SvxMenuConfigPage, AddCommandsHdl, Button *, pButton )
+{
+ (void)pButton;
+
+ if ( pSelectorDlg == NULL )
+ {
+ // Create Script Selector which also shows builtin commands
+ pSelectorDlg = new SvxScriptSelectorDialog( this, TRUE, m_xFrame );
+
+ pSelectorDlg->SetAddHdl(
+ LINK( this, SvxMenuConfigPage, AddFunctionHdl ) );
+
+ pSelectorDlg->SetDialogDescription( String(
+ CUI_RES( RID_SVXSTR_MENU_ADDCOMMANDS_DESCRIPTION ) ) );
+ }
+
+ // Position the Script Selector over the Add button so it is
+ // beside the menu contents list and does not obscure it
+ pSelectorDlg->SetPosPixel( aAddCommandsButton.GetPosPixel() );
+
+ pSelectorDlg->SetImageProvider(
+ static_cast< ImageProvider* >( GetSaveInData() ) );
+
+ pSelectorDlg->Show();
+ return 1;
+}
+
+SaveInData* SvxMenuConfigPage::CreateSaveInData(
+ const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
+ const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
+ const OUString& aModuleId,
+ bool bDocConfig )
+{
+ return static_cast< SaveInData* >(
+ new MenuSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ));
+}
+
+SvxMainMenuOrganizerDialog::SvxMainMenuOrganizerDialog(
+ Window* pParent, SvxEntries* entries,
+ SvxConfigEntry* selection, bool bCreateMenu )
+ :
+ ModalDialog( pParent, CUI_RES( MD_MENU_ORGANISER ) ),
+ aMenuNameText( this, CUI_RES( TXT_MENU_NAME ) ),
+ aMenuNameEdit( this, CUI_RES( EDIT_MENU_NAME ) ),
+ aMenuListText( this, CUI_RES( TXT_MENU ) ),
+ aMenuListBox( this, CUI_RES( BOX_MAIN_MENUS ) ),
+ aMoveUpButton( this, CUI_RES( BTN_MENU_UP ) ),
+ aMoveDownButton( this, CUI_RES( BTN_MENU_DOWN ) ),
+ aOKButton( this, CUI_RES( BTN_MENU_ADD ) ),
+ aCloseButton( this, CUI_RES( BTN_MENU_CLOSE ) ),
+ aHelpButton( this, CUI_RES( BTN_MENU_HELP ) ),
+ bModified( FALSE )
+{
+ FreeResource();
+
+ // Copy the entries list passed in
+ if ( entries != NULL )
+ {
+ SvxConfigEntry* pEntry;
+ SvLBoxEntry* pLBEntry;
+
+ pEntries = new SvxEntries();
+ SvxEntries::const_iterator iter = entries->begin();
+
+ while ( iter != entries->end() )
+ {
+ pEntry = *iter;
+ pLBEntry =
+ aMenuListBox.InsertEntry( stripHotKey( pEntry->GetName() ) );
+ pLBEntry->SetUserData( pEntry );
+ pEntries->push_back( pEntry );
+
+ if ( pEntry == selection )
+ {
+ aMenuListBox.Select( pLBEntry );
+ }
+ iter++;
+ }
+ }
+
+ if ( bCreateMenu )
+ {
+ // Generate custom name for new menu
+ String prefix =
+ String( CUI_RES( RID_SVXSTR_NEW_MENU ) );
+
+ OUString newname = generateCustomName( prefix, entries );
+ OUString newurl = generateCustomMenuURL( pEntries );
+
+ SvxConfigEntry* pNewEntryData =
+ new SvxConfigEntry( newname, newurl, TRUE );
+ pNewEntryData->SetUserDefined( TRUE );
+ pNewEntryData->SetMain( TRUE );
+
+ pNewMenuEntry =
+ aMenuListBox.InsertEntry( stripHotKey( pNewEntryData->GetName() ) );
+ aMenuListBox.Select( pNewMenuEntry );
+
+ pNewMenuEntry->SetUserData( pNewEntryData );
+
+ pEntries->push_back( pNewEntryData );
+
+ aMenuNameEdit.SetText( newname );
+ aMenuNameEdit.SetModifyHdl(
+ LINK( this, SvxMainMenuOrganizerDialog, ModifyHdl ) );
+ }
+ else
+ {
+ Point p, newp;
+ Size s, news;
+
+ // get offset to bottom of name textfield from top of dialog
+ p = aMenuNameEdit.GetPosPixel();
+ s = aMenuNameEdit.GetSizePixel();
+ long offset = p.Y() + s.Height();
+
+ // reposition menu list and label
+ aMenuListText.SetPosPixel( aMenuNameText.GetPosPixel() );
+ aMenuListBox.SetPosPixel( aMenuNameEdit.GetPosPixel() );
+
+ // reposition up and down buttons
+ p = aMoveUpButton.GetPosPixel();
+ newp = Point( p.X(), p.Y() - offset );
+ aMoveUpButton.SetPosPixel( newp );
+
+ p = aMoveDownButton.GetPosPixel();
+ newp = Point( p.X(), p.Y() - offset );
+ aMoveDownButton.SetPosPixel( newp );
+
+ // change size of dialog
+ s = GetSizePixel();
+ news = Size( s.Width(), s.Height() - offset );
+ SetSizePixel( news );
+
+ // hide name label and textfield
+ aMenuNameText.Hide();
+ aMenuNameEdit.Hide();
+
+ // change the title
+ SetText( CUI_RES( RID_SVXSTR_MOVE_MENU ) );
+ }
+
+ aMenuListBox.SetSelectHdl(
+ LINK( this, SvxMainMenuOrganizerDialog, SelectHdl ) );
+
+ aMoveUpButton.SetClickHdl (
+ LINK( this, SvxMainMenuOrganizerDialog, MoveHdl) );
+ aMoveDownButton.SetClickHdl (
+ LINK( this, SvxMainMenuOrganizerDialog, MoveHdl) );
+}
+
+IMPL_LINK(SvxMainMenuOrganizerDialog, ModifyHdl, Edit*, pEdit)
+{
+ (void)pEdit;
+
+ // if the Edit control is empty do not change the name
+ if ( aMenuNameEdit.GetText().Equals( String() ) )
+ {
+ return 0;
+ }
+
+ SvxConfigEntry* pNewEntryData =
+ (SvxConfigEntry*) pNewMenuEntry->GetUserData();
+
+ pNewEntryData->SetName( aMenuNameEdit.GetText() );
+
+ aMenuListBox.SetEntryText( pNewMenuEntry, pNewEntryData->GetName() );
+
+ return 0;
+}
+
+SvxMainMenuOrganizerDialog::~SvxMainMenuOrganizerDialog()
+{
+}
+
+IMPL_LINK( SvxMainMenuOrganizerDialog, SelectHdl, Control*, pCtrl )
+{
+ (void)pCtrl;
+ UpdateButtonStates();
+ return 1;
+}
+
+void SvxMainMenuOrganizerDialog::UpdateButtonStates()
+{
+ // Disable Up and Down buttons depending on current selection
+ SvLBoxEntry* selection = aMenuListBox.GetCurEntry();
+ SvLBoxEntry* first = aMenuListBox.First();
+ SvLBoxEntry* last = aMenuListBox.Last();
+
+ aMoveUpButton.Enable( selection != first );
+ aMoveDownButton.Enable( selection != last );
+}
+
+IMPL_LINK( SvxMainMenuOrganizerDialog, MoveHdl, Button *, pButton )
+{
+ SvLBoxEntry *pSourceEntry = aMenuListBox.FirstSelected();
+ SvLBoxEntry *pTargetEntry = NULL;
+
+ if ( !pSourceEntry )
+ {
+ return 0;
+ }
+
+ if ( pButton == &aMoveDownButton )
+ {
+ pTargetEntry = aMenuListBox.NextSibling( pSourceEntry );
+ }
+ else if ( pButton == &aMoveUpButton )
+ {
+ // Move Up is just a Move Down with the source and target reversed
+ pTargetEntry = pSourceEntry;
+ pSourceEntry = aMenuListBox.PrevSibling( pTargetEntry );
+ }
+
+ if ( pSourceEntry != NULL && pTargetEntry != NULL )
+ {
+ SvxConfigEntry* pSourceData =
+ (SvxConfigEntry*) pSourceEntry->GetUserData();
+ SvxConfigEntry* pTargetData =
+ (SvxConfigEntry*) pTargetEntry->GetUserData();
+
+ SvxEntries::iterator iter1 = GetEntries()->begin();
+ SvxEntries::iterator iter2 = GetEntries()->begin();
+ SvxEntries::const_iterator end = GetEntries()->end();
+
+ // Advance the iterators to the positions of the source and target
+ while (*iter1 != pSourceData && ++iter1 != end) ;
+ while (*iter2 != pTargetData && ++iter2 != end) ;
+
+ // Now swap the entries in the menu list and in the UI
+ if ( iter1 != end && iter2 != end )
+ {
+ std::swap( *iter1, *iter2 );
+ aMenuListBox.GetModel()->Move( pSourceEntry, pTargetEntry );
+ aMenuListBox.MakeVisible( pSourceEntry );
+
+ bModified = TRUE;
+ }
+ }
+
+ if ( bModified )
+ {
+ UpdateButtonStates();
+ }
+
+ return 0;
+}
+
+SvxEntries* SvxMainMenuOrganizerDialog::GetEntries()
+{
+ return pEntries;
+}
+
+SvxConfigEntry* SvxMainMenuOrganizerDialog::GetSelectedEntry()
+{
+ return (SvxConfigEntry*)aMenuListBox.FirstSelected()->GetUserData();
+}
+
+SvxConfigEntry::SvxConfigEntry(
+ const uno::Sequence< beans::PropertyValue >& rProperties,
+ const uno::Reference< container::XNameAccess >& rCommandToLabelMap )
+ :
+ nId( 1 ),
+ bPopUp( FALSE ),
+ bStrEdited( FALSE ),
+ bIsUserDefined( FALSE ),
+ bIsMain( FALSE ),
+ bIsParentData( FALSE ),
+ bIsVisible( TRUE ),
+ nStyle( 0 ),
+ pEntries( 0 )
+{
+ sal_uInt16 nType( css::ui::ItemType::DEFAULT );
+ OUString aHelpURL_;
+
+ for ( sal_Int32 i = 0; i < rProperties.getLength(); i++ )
+ {
+ if ( rProperties[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
+ {
+ rProperties[i].Value >>= aCommand;
+ }
+ else if ( rProperties[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
+ {
+ rProperties[i].Value >>= aHelpURL_;
+ }
+ else if ( rProperties[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ))
+ {
+ rProperties[i].Value >>= aLabel;
+ }
+ else if ( rProperties[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE ))
+ {
+ rProperties[i].Value >>= nType;
+ }
+ }
+
+ if ( nType == css::ui::ItemType::DEFAULT )
+ {
+ uno::Any a;
+ try
+ {
+ a = rCommandToLabelMap->getByName( aCommand );
+ bIsUserDefined = FALSE;
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ bIsUserDefined = TRUE;
+ }
+
+ // If custom label not set retrieve it from the command to info service
+ if ( aLabel.equals( OUString() ) )
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if ( aPropSeq[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ) )
+ {
+ aPropSeq[i].Value >>= aLabel;
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+const OUString&
+SvxConfigEntry::GetHelpText()
+{
+ if ( aHelpText.getLength() == 0 )
+ {
+ OUString helpid = OUString::createFromAscii( "helpid:" );
+ if ( aHelpURL.indexOf( helpid ) != -1 )
+ {
+ aHelpURL = aHelpURL.copy( helpid.getLength() );
+ }
+
+ Help* pHelp = Application::GetHelp();
+ if ( aHelpURL.toInt32() != 0 )
+ {
+ aHelpText = pHelp->GetHelpText( aHelpURL.toInt32(), NULL );
+ }
+
+ if ( aHelpText.getLength() == 0 && aCommand.getLength() != 0 )
+ {
+ aHelpText = pHelp->GetHelpText( aCommand, NULL );
+ }
+ }
+
+ return aHelpText;
+}
+
+uno::Sequence< beans::PropertyValue >
+SvxConfigEntry::GetProperties(
+ const uno::Reference< container::XNameAccess >& rCommandToLabelMap )
+{
+ if ( IsSeparator() )
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq( 1 );
+
+ aPropSeq[0].Name = OUString(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ) );
+ aPropSeq[0].Value <<= css::ui::ItemType::SEPARATOR_LINE;
+
+ return aPropSeq;
+ }
+
+ static const OUString aDescriptorCommandURL (
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ) );
+
+ static const OUString aDescriptorType(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ) );
+
+ static const OUString aDescriptorLabel(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL ) );
+
+ static const OUString aDescriptorHelpURL(
+ RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL ) );
+
+ uno::Sequence< beans::PropertyValue > aPropSeq( 4 );
+
+ aPropSeq[0].Name = aDescriptorCommandURL;
+ aPropSeq[0].Value <<= rtl::OUString( GetCommand() );
+
+ aPropSeq[1].Name = aDescriptorType;
+ aPropSeq[1].Value <<= css::ui::ItemType::DEFAULT;
+
+ // If the name has not been changed and the name is the same as
+ // in the default command to label map then the label can be stored
+ // as an empty string.
+ // It will be initialised again later using the command to label map.
+ aPropSeq[2].Name = aDescriptorLabel;
+ if ( HasChangedName() == FALSE && GetCommand().getLength() )
+ {
+ BOOL isDefaultName = FALSE;
+ try
+ {
+ uno::Any a( rCommandToLabelMap->getByName( GetCommand() ) );
+ uno::Sequence< beans::PropertyValue > tmpPropSeq;
+ if ( a >>= tmpPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < tmpPropSeq.getLength(); i++ )
+ {
+ if ( tmpPropSeq[i].Name.equals( aDescriptorLabel ) )
+ {
+ OUString tmpLabel;
+ tmpPropSeq[i].Value >>= tmpLabel;
+
+ if ( tmpLabel.equals( GetName() ) )
+ {
+ isDefaultName = TRUE;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // isDefaultName is left as FALSE
+ }
+
+ if ( isDefaultName )
+ {
+ aPropSeq[2].Value <<= rtl::OUString();
+ }
+ else
+ {
+ aPropSeq[2].Value <<= rtl::OUString( GetName() );
+ }
+ }
+ else
+ {
+ aPropSeq[2].Value <<= rtl::OUString( GetName() );
+ }
+
+ aPropSeq[3].Name = aDescriptorHelpURL;
+ aPropSeq[3].Value <<= rtl::OUString( GetHelpURL() );
+
+ return aPropSeq;
+}
+
+/*
+SvxMenuConfigEntry::SvxMenuConfigEntry(
+ const uno::Sequence< beans::PropertyValue >& rProperties,
+ const uno::Reference< container::XNameAccess >& rCommandToLabelMap )
+ :
+ SvxConfigEntry( rProperties, rCommandToLabelMap )
+{
+ uno::Reference< container::XIndexAccess > aChildren;
+
+ for ( sal_Int32 i = 0; i < rProperties.getLength(); i++ )
+ {
+ if ( rProperties[i].Name.equalsAscii( ITEM_DESCRIPTOR_CONTAINER ))
+ {
+ rProperties[i].Value >>= aChildren;
+ }
+ }
+
+ if ( aChildren.is() )
+ {
+ SetPopup( TRUE );
+ SetEntries( new SvxEntries() );
+
+ uno::Sequence< beans::PropertyValue > aProps;
+ for ( sal_Int32 i = 0; i < aChildren->getCount(); i++ )
+ {
+ if ( aChildren->getByIndex( i ) >>= aProps )
+ {
+ SvxConfigEntry* pEntry =
+ new SvxMenuConfigEntry( aProps, rCommandToLabelMap );
+ GetEntries()->push_back( pEntry );
+ }
+ }
+ }
+}
+*/
+
+SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName,
+ const OUString& rCommandURL, bool bPopup, bool bParentData )
+ : nId( 1 )
+ , aLabel(rDisplayName)
+ , aCommand(rCommandURL)
+ , bPopUp(bPopup)
+ , bStrEdited( FALSE )
+ , bIsUserDefined( FALSE )
+ , bIsMain( FALSE )
+ , bIsParentData( bParentData )
+ , bIsVisible( TRUE )
+ , nStyle( 0 )
+ , pEntries( 0 )
+{
+ if (bPopUp)
+ {
+ pEntries = new SvxEntries();
+ }
+}
+
+SvxConfigEntry::~SvxConfigEntry()
+{
+ if ( pEntries != NULL )
+ {
+ SvxEntries::const_iterator iter = pEntries->begin();
+
+ for ( ; iter != pEntries->end(); iter++ )
+ {
+ delete *iter;
+ }
+ delete pEntries;
+ }
+}
+
+bool SvxConfigEntry::IsMovable()
+{
+ if ( IsPopup() && !IsMain() )
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool SvxConfigEntry::IsDeletable()
+{
+ if ( IsMain() && !IsUserDefined() )
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool SvxConfigEntry::IsRenamable()
+{
+ if ( IsMain() && !IsUserDefined() )
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+SvxToolbarConfigPage::SvxToolbarConfigPage(
+ Window *pParent, const SfxItemSet& rSet )
+ :
+ SvxConfigPage( pParent, rSet )
+{
+ SetHelpId( HID_SVX_CONFIG_TOOLBAR );
+
+ aContentsListBox = new SvxToolbarEntriesListBox(this, CUI_RES(BOX_ENTRIES));
+ FreeResource();
+ PositionContentsListBox();
+ aContentsListBox->SetZOrder( &aAddCommandsButton, WINDOW_ZORDER_BEFOR );
+
+ aContentsListBox->SetHelpId( HID_SVX_CONFIG_TOOLBAR_CONTENTS );
+ aNewTopLevelButton.SetHelpId( HID_SVX_NEW_TOOLBAR );
+ aModifyTopLevelButton.SetHelpId( HID_SVX_MODIFY_TOOLBAR );
+ aAddCommandsButton.SetHelpId( HID_SVX_NEW_TOOLBAR_ITEM );
+ aModifyCommandButton.SetHelpId( HID_SVX_MODIFY_TOOLBAR_ITEM );
+ aSaveInListBox.SetHelpId( HID_SVX_SAVE_IN );
+
+ aTopLevelSeparator.SetText(
+ CUI_RES ( RID_SVXSTR_PRODUCTNAME_TOOLBARS ) );
+
+ aTopLevelLabel.SetText( CUI_RES( RID_SVXSTR_TOOLBAR ) );
+ aModifyTopLevelButton.SetText( CUI_RES( RID_SVXSTR_TOOLBAR ) );
+ aContentsSeparator.SetText( CUI_RES( RID_SVXSTR_TOOLBAR_CONTENT ) );
+ aContentsLabel.SetText( CUI_RES( RID_SVXSTR_COMMANDS ) );
+
+ aTopLevelListBox.SetSelectHdl(
+ LINK( this, SvxToolbarConfigPage, SelectToolbar ) );
+ aContentsListBox->SetSelectHdl(
+ LINK( this, SvxToolbarConfigPage, SelectToolbarEntry ) );
+
+ aNewTopLevelButton.SetClickHdl (
+ LINK( this, SvxToolbarConfigPage, NewToolbarHdl ) );
+
+ aAddCommandsButton.SetClickHdl (
+ LINK( this, SvxToolbarConfigPage, AddCommandsHdl ) );
+
+ aMoveUpButton.SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
+ aMoveDownButton.SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
+ // Always enable Up and Down buttons
+ // added for issue i53677 by shizhoubo
+ aMoveDownButton.Enable( TRUE );
+ aMoveUpButton.Enable( TRUE );
+
+ PopupMenu* pMenu = new PopupMenu( CUI_RES( MODIFY_TOOLBAR ) );
+ pMenu->SetMenuFlags(
+ pMenu->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
+
+ aModifyTopLevelButton.SetPopupMenu( pMenu );
+ aModifyTopLevelButton.SetSelectHdl(
+ LINK( this, SvxToolbarConfigPage, ToolbarSelectHdl ) );
+
+ PopupMenu* pEntry = new PopupMenu(
+ CUI_RES( MODIFY_TOOLBAR_CONTENT ) );
+ pEntry->SetMenuFlags(
+ pEntry->GetMenuFlags() | MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
+
+ aModifyCommandButton.SetPopupMenu( pEntry );
+ aModifyCommandButton.SetSelectHdl(
+ LINK( this, SvxToolbarConfigPage, EntrySelectHdl ) );
+
+ // default toolbar to select is standardbar unless a different one
+ // has been passed in
+ m_aURLToSelect = OUString::createFromAscii( ITEM_TOOLBAR_URL );
+ m_aURLToSelect += OUString::createFromAscii( "standardbar" );
+
+ const SfxPoolItem* pItem =
+ rSet.GetItem( rSet.GetPool()->GetWhich( SID_CONFIG ) );
+
+ if ( pItem )
+ {
+ OUString text = ((const SfxStringItem*)pItem)->GetValue();
+ if (text.indexOf(OUString::createFromAscii(ITEM_TOOLBAR_URL)) == 0)
+ {
+ m_aURLToSelect = text.copy( 0 );
+ }
+ }
+
+ long nTxtW = aTopLevelLabel.GetCtrlTextWidth( aTopLevelLabel.GetText() );
+ long nCtrlW = aTopLevelLabel.GetSizePixel().Width();
+ if ( nTxtW >= nCtrlW )
+ {
+ long nDelta = Max( (long)10, nTxtW - nCtrlW );
+ Size aNewSz = aTopLevelLabel.GetSizePixel();
+ aNewSz.Width() += nDelta;
+ aTopLevelLabel.SetSizePixel( aNewSz );
+ aNewSz = aTopLevelListBox.GetSizePixel();
+ aNewSz.Width() -= nDelta;
+ Point aNewPt = aTopLevelListBox.GetPosPixel();
+ aNewPt.X() += nDelta;
+ aTopLevelListBox.SetPosSizePixel( aNewPt, aNewSz );
+ }
+}
+
+SvxToolbarConfigPage::~SvxToolbarConfigPage()
+{
+ for ( USHORT i = 0 ; i < aSaveInListBox.GetEntryCount(); i++ )
+ {
+ ToolbarSaveInData* pData =
+ (ToolbarSaveInData*) aSaveInListBox.GetEntryData( i );
+
+ delete pData;
+ }
+
+ if ( pSelectorDlg != NULL )
+ {
+ delete pSelectorDlg;
+ }
+
+
+ delete aContentsListBox;
+}
+
+void SvxToolbarConfigPage::DeleteSelectedTopLevel()
+{
+ USHORT nSelectionPos = aTopLevelListBox.GetSelectEntryPos();
+ ToolbarSaveInData* pSaveInData = (ToolbarSaveInData*) GetSaveInData();
+ pSaveInData->RemoveToolbar( GetTopLevelSelection() );
+
+ if ( aTopLevelListBox.GetEntryCount() > 1 )
+ {
+ // select next entry after the one being deleted
+ // selection position is indexed from 0 so need to
+ // subtract one from the entry count
+ if ( nSelectionPos != aTopLevelListBox.GetEntryCount() - 1 )
+ {
+ aTopLevelListBox.SelectEntryPos( nSelectionPos + 1, TRUE );
+ }
+ else
+ {
+ aTopLevelListBox.SelectEntryPos( nSelectionPos - 1, TRUE );
+ }
+ aTopLevelListBox.GetSelectHdl().Call( this );
+
+ // and now remove the entry
+ aTopLevelListBox.RemoveEntry( nSelectionPos );
+ }
+ else
+ {
+ ReloadTopLevelListBox();
+ }
+}
+
+bool SvxToolbarConfigPage::DeleteSelectedContent()
+{
+ SvLBoxEntry *pActEntry = aContentsListBox->FirstSelected();
+
+ if ( pActEntry != NULL )
+ {
+ // get currently selected entry
+ SvxConfigEntry* pEntry =
+ (SvxConfigEntry*) pActEntry->GetUserData();
+
+ SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+ // remove entry from the list for this toolbar
+ RemoveEntry( pToolbar->GetEntries(), pEntry );
+
+ // remove toolbar entry from UI
+ aContentsListBox->GetModel()->Remove( pActEntry );
+
+ // delete data for toolbar entry
+ delete pEntry;
+
+ (( ToolbarSaveInData* ) GetSaveInData())->ApplyToolbar( pToolbar );
+ UpdateButtonStates();
+
+ // if this is the last entry in the toolbar and it is a user
+ // defined toolbar pop up a dialog asking the user if they
+ // want to delete the toolbar
+ if ( aContentsListBox->GetEntryCount() == 0 &&
+ GetTopLevelSelection()->IsDeletable() )
+ {
+ QueryBox qbox( this,
+ CUI_RES( QBX_CONFIRM_DELETE_TOOLBAR ) );
+
+ if ( qbox.Execute() == RET_YES )
+ {
+ DeleteSelectedTopLevel();
+ }
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+IMPL_LINK( SvxToolbarConfigPage, MoveHdl, Button *, pButton )
+{
+ MoveEntry( pButton == &aMoveUpButton );
+ return 0;
+}
+
+void SvxToolbarConfigPage::MoveEntry( bool bMoveUp )
+{
+ SvxConfigPage::MoveEntry( bMoveUp );
+
+ // Apply change to currently selected toolbar
+ SvxConfigEntry* pToolbar = GetTopLevelSelection();
+ if ( pToolbar )
+ ((ToolbarSaveInData*)GetSaveInData())->ApplyToolbar( pToolbar );
+ else
+ {
+ DBG_ERRORFILE( "SvxToolbarConfigPage::MoveEntry(): no entry" );
+ UpdateButtonStates();
+ }
+}
+
+IMPL_LINK( SvxToolbarConfigPage, ToolbarSelectHdl, MenuButton *, pButton )
+{
+ USHORT nSelectionPos = aTopLevelListBox.GetSelectEntryPos();
+
+ SvxConfigEntry* pToolbar =
+ (SvxConfigEntry*)aTopLevelListBox.GetEntryData( nSelectionPos );
+
+ ToolbarSaveInData* pSaveInData = (ToolbarSaveInData*) GetSaveInData();
+
+ switch( pButton->GetCurItemId() )
+ {
+ case ID_DELETE:
+ {
+ DeleteSelectedTopLevel();
+ UpdateButtonStates();
+ break;
+ }
+ case ID_RENAME:
+ {
+ String aNewName( stripHotKey( pToolbar->GetName() ) );
+ String aDesc = CUI_RESSSTR( RID_SVXSTR_LABEL_NEW_NAME );
+
+ SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
+ pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_TOOLBAR );
+ pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_TOOLBAR ) );
+
+ bool ret = pNameDialog->Execute();
+
+ if ( ret == RET_OK )
+ {
+ pNameDialog->GetName(aNewName);
+
+ pToolbar->SetName( aNewName );
+ pSaveInData->ApplyToolbar( pToolbar );
+
+ // have to use remove and insert to change the name
+ aTopLevelListBox.RemoveEntry( nSelectionPos );
+ nSelectionPos =
+ aTopLevelListBox.InsertEntry( aNewName, nSelectionPos );
+ aTopLevelListBox.SetEntryData( nSelectionPos, pToolbar );
+ aTopLevelListBox.SelectEntryPos( nSelectionPos );
+ }
+
+ delete pNameDialog;
+
+ break;
+ }
+ case ID_DEFAULT_STYLE:
+ {
+ QueryBox qbox( this,
+ CUI_RES( QBX_CONFIRM_RESTORE_DEFAULT ) );
+
+ if ( qbox.Execute() == RET_YES )
+ {
+ ToolbarSaveInData* pSaveInData_ =
+ (ToolbarSaveInData*) GetSaveInData();
+
+ pSaveInData_->RestoreToolbar( pToolbar );
+
+ aTopLevelListBox.GetSelectHdl().Call( this );
+ }
+
+ break;
+ }
+ case ID_ICONS_ONLY:
+ {
+ pToolbar->SetStyle( 0 );
+ pSaveInData->SetSystemStyle( m_xFrame, pToolbar->GetCommand(), 0 );
+
+ aTopLevelListBox.GetSelectHdl().Call( this );
+
+ break;
+ }
+ case ID_TEXT_ONLY:
+ {
+ pToolbar->SetStyle( 1 );
+ pSaveInData->SetSystemStyle( m_xFrame, pToolbar->GetCommand(), 1 );
+
+ aTopLevelListBox.GetSelectHdl().Call( this );
+
+ break;
+ }
+ case ID_ICONS_AND_TEXT:
+ {
+ pToolbar->SetStyle( 2 );
+ pSaveInData->SetSystemStyle( m_xFrame, pToolbar->GetCommand(), 2 );
+
+ aTopLevelListBox.GetSelectHdl().Call( this );
+
+ break;
+ }
+ }
+ return 1;
+}
+
+IMPL_LINK( SvxToolbarConfigPage, EntrySelectHdl, MenuButton *, pButton )
+{
+ bool bNeedsApply = FALSE;
+
+ // get currently selected toolbar
+ SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+ switch( pButton->GetCurItemId() )
+ {
+ case ID_RENAME:
+ {
+ SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
+ SvxConfigEntry* pEntry =
+ (SvxConfigEntry*) pActEntry->GetUserData();
+
+ String aNewName( stripHotKey( pEntry->GetName() ) );
+ String aDesc = CUI_RESSSTR( RID_SVXSTR_LABEL_NEW_NAME );
+
+ SvxNameDialog* pNameDialog = new SvxNameDialog( this, aNewName, aDesc );
+ pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM );
+ pNameDialog->SetText( CUI_RESSTR( RID_SVXSTR_RENAME_TOOLBAR ) );
+
+ bool ret = pNameDialog->Execute();
+
+ if ( ret == RET_OK ) {
+ pNameDialog->GetName(aNewName);
+
+ pEntry->SetName( aNewName );
+ aContentsListBox->SetEntryText( pActEntry, aNewName );
+
+ bNeedsApply = TRUE;
+ }
+
+ delete pNameDialog;
+ break;
+ }
+ case ID_DEFAULT_COMMAND:
+ {
+ SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
+ SvxConfigEntry* pEntry =
+ (SvxConfigEntry*) pActEntry->GetUserData();
+
+ USHORT nSelectionPos = 0;
+
+ // find position of entry within the list
+ for ( USHORT i = 0; i < aContentsListBox->GetEntryCount(); i++ )
+ {
+ if ( aContentsListBox->GetEntry( 0, i ) == pActEntry )
+ {
+ nSelectionPos = i;
+ break;
+ }
+ }
+
+ ToolbarSaveInData* pSaveInData =
+ (ToolbarSaveInData*) GetSaveInData();
+
+ OUString aSystemName =
+ pSaveInData->GetSystemUIName( pEntry->GetCommand() );
+
+ if ( !pEntry->GetName().equals( aSystemName ) )
+ {
+ pEntry->SetName( aSystemName );
+ aContentsListBox->SetEntryText(
+ pActEntry, stripHotKey( aSystemName ) );
+ bNeedsApply = TRUE;
+ }
+
+ uno::Sequence< OUString > aURLSeq( 1 );
+ aURLSeq[ 0 ] = pEntry->GetCommand();
+
+ try
+ {
+ GetSaveInData()->GetImageManager()->removeImages(
+ GetImageType(), aURLSeq );
+
+ // reset backup in entry
+ pEntry->SetBackupGraphic(
+ uno::Reference< graphic::XGraphic >() );
+
+ GetSaveInData()->PersistChanges(
+ GetSaveInData()->GetImageManager() );
+
+ aContentsListBox->GetModel()->Remove( pActEntry );
+
+ SvLBoxEntry* pNewLBEntry =
+ InsertEntryIntoUI( pEntry, nSelectionPos );
+
+ aContentsListBox->SetCheckButtonState( pNewLBEntry,
+ pEntry->IsVisible() ?
+ SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
+
+ aContentsListBox->Select( pNewLBEntry );
+ aContentsListBox->MakeVisible( pNewLBEntry );
+
+ bNeedsApply = TRUE;
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_TRACE("Error restoring image");
+ }
+ break;
+ }
+ case ID_BEGIN_GROUP:
+ {
+ SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
+ pNewEntryData->SetUserDefined( TRUE );
+
+ SvLBoxEntry* pNewLBEntry = InsertEntry( pNewEntryData );
+
+ aContentsListBox->SetCheckButtonState(
+ pNewLBEntry, SV_BUTTON_TRISTATE );
+
+ bNeedsApply = TRUE;
+ break;
+ }
+ case ID_DELETE:
+ {
+ DeleteSelectedContent();
+ break;
+ }
+ case ID_ICON_ONLY:
+ {
+ break;
+ }
+ case ID_TEXT_ONLY:
+ {
+ break;
+ }
+ case ID_ICON_AND_TEXT:
+ {
+ break;
+ }
+ case ID_CHANGE_SYMBOL:
+ {
+ SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
+ SvxConfigEntry* pEntry =
+ (SvxConfigEntry*) pActEntry->GetUserData();
+
+ USHORT nSelectionPos = 0;
+
+ // find position of entry within the list
+ for ( USHORT i = 0; i < aContentsListBox->GetEntryCount(); i++ )
+ {
+ if ( aContentsListBox->GetEntry( 0, i ) == pActEntry )
+ {
+ nSelectionPos = i;
+ break;
+ }
+ }
+
+ SvxIconSelectorDialog* pIconDialog =
+ new SvxIconSelectorDialog( 0,
+ GetSaveInData()->GetImageManager(),
+ GetSaveInData()->GetParentImageManager() );
+
+ bool ret = pIconDialog->Execute();
+
+ if ( ret == RET_OK )
+ {
+ uno::Reference< graphic::XGraphic > newgraphic =
+ pIconDialog->GetSelectedIcon();
+
+ if ( newgraphic.is() )
+ {
+ uno::Sequence< uno::Reference< graphic::XGraphic > >
+ aGraphicSeq( 1 );
+
+ uno::Sequence< OUString > aURLSeq( 1 );
+ aURLSeq[ 0 ] = pEntry->GetCommand();
+
+ if ( !pEntry->GetBackupGraphic().is() )
+ {
+ uno::Reference< graphic::XGraphic > backup;
+ backup = GetGraphic(
+ GetSaveInData()->GetImageManager(), aURLSeq[ 0 ] );
+
+ if ( backup.is() )
+ {
+ pEntry->SetBackupGraphic( backup );
+ }
+ }
+
+ aGraphicSeq[ 0 ] = newgraphic;
+ try
+ {
+ GetSaveInData()->GetImageManager()->replaceImages(
+ GetImageType(), aURLSeq, aGraphicSeq );
+
+ Image aImage( newgraphic );
+
+ aContentsListBox->GetModel()->Remove( pActEntry );
+ SvLBoxEntry* pNewLBEntry =
+ InsertEntryIntoUI( pEntry, nSelectionPos );
+
+ aContentsListBox->SetCheckButtonState( pNewLBEntry,
+ pEntry->IsVisible() ?
+ SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
+
+ aContentsListBox->Select( pNewLBEntry );
+ aContentsListBox->MakeVisible( pNewLBEntry );
+
+ GetSaveInData()->PersistChanges(
+ GetSaveInData()->GetImageManager() );
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_TRACE("Error replacing image");
+ }
+ }
+ }
+
+ delete pIconDialog;
+
+ break;
+ }
+ case ID_RESET_SYMBOL:
+ {
+ SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry();
+ SvxConfigEntry* pEntry =
+ (SvxConfigEntry*) pActEntry->GetUserData();
+
+ USHORT nSelectionPos = 0;
+
+ // find position of entry within the list
+ for ( USHORT i = 0; i < aContentsListBox->GetEntryCount(); i++ )
+ {
+ if ( aContentsListBox->GetEntry( 0, i ) == pActEntry )
+ {
+ nSelectionPos = i;
+ break;
+ }
+ }
+
+ uno::Reference< graphic::XGraphic > backup =
+ pEntry->GetBackupGraphic();
+
+ uno::Sequence< uno::Reference< graphic::XGraphic > >
+ aGraphicSeq( 1 );
+ aGraphicSeq[ 0 ] = backup;
+
+ uno::Sequence< OUString > aURLSeq( 1 );
+ aURLSeq[ 0 ] = pEntry->GetCommand();
+
+ try
+ {
+ GetSaveInData()->GetImageManager()->replaceImages(
+ GetImageType(), aURLSeq, aGraphicSeq );
+
+ Image aImage( backup );
+ aContentsListBox->GetModel()->Remove( pActEntry );
+
+ SvLBoxEntry* pNewLBEntry =
+ InsertEntryIntoUI( pEntry, nSelectionPos );
+
+ aContentsListBox->SetCheckButtonState( pNewLBEntry,
+ pEntry->IsVisible() ?
+ SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
+
+ aContentsListBox->Select( pNewLBEntry );
+ aContentsListBox->MakeVisible( pNewLBEntry );
+
+ // reset backup in entry
+ pEntry->SetBackupGraphic(
+ uno::Reference< graphic::XGraphic >() );
+
+ GetSaveInData()->PersistChanges(
+ GetSaveInData()->GetImageManager() );
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_TRACE("Error resetting image");
+ }
+ break;
+ }
+ }
+
+ if ( bNeedsApply == TRUE )
+ {
+ (( ToolbarSaveInData* ) GetSaveInData())->ApplyToolbar( pToolbar );
+ UpdateButtonStates();
+ }
+
+ return 1;
+}
+
+void SvxToolbarConfigPage::Init()
+{
+ // ensure that the UI is cleared before populating it
+ aTopLevelListBox.Clear();
+ aContentsListBox->Clear();
+
+ ReloadTopLevelListBox();
+
+ USHORT nPos = 0;
+ if ( m_aURLToSelect.getLength() != 0 )
+ {
+ for ( USHORT i = 0 ; i < aTopLevelListBox.GetEntryCount(); i++ )
+ {
+ SvxConfigEntry* pData =
+ (SvxConfigEntry*) aTopLevelListBox.GetEntryData( i );
+
+ if ( pData->GetCommand().equals( m_aURLToSelect ) )
+ {
+ nPos = i;
+ break;
+ }
+ }
+
+ // in future select the default toolbar: Standard
+ m_aURLToSelect = OUString::createFromAscii( ITEM_TOOLBAR_URL );
+ m_aURLToSelect += OUString::createFromAscii( "standardbar" );
+ }
+
+ aTopLevelListBox.SelectEntryPos(nPos, TRUE);
+ aTopLevelListBox.GetSelectHdl().Call(this);
+}
+
+SaveInData* SvxToolbarConfigPage::CreateSaveInData(
+ const uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
+ const uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr,
+ const OUString& aModuleId,
+ bool bDocConfig )
+{
+ return static_cast< SaveInData* >(
+ new ToolbarSaveInData( xCfgMgr, xParentCfgMgr, aModuleId, bDocConfig ));
+}
+
+ToolbarSaveInData::ToolbarSaveInData(
+ const uno::Reference < css::ui::XUIConfigurationManager >& xCfgMgr,
+ const uno::Reference < css::ui::XUIConfigurationManager >& xParentCfgMgr,
+ const OUString& aModuleId,
+ bool docConfig ) :
+
+ SaveInData ( xCfgMgr, xParentCfgMgr, aModuleId, docConfig ),
+ pRootEntry ( NULL ),
+ m_aDescriptorContainer ( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ) )
+
+{
+ // Initialize the m_xPersistentWindowState variable which is used
+ // to get the default properties of system toolbars such as name
+ uno::Reference< container::XNameAccess > xPWSS(
+ m_xServiceManager->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.ui.WindowStateConfiguration" ) ) ),
+ uno::UNO_QUERY );
+
+ if ( xPWSS.is() )
+ xPWSS->getByName( aModuleId ) >>= m_xPersistentWindowState;
+}
+
+ToolbarSaveInData::~ToolbarSaveInData()
+{
+ delete pRootEntry;
+}
+
+void ToolbarSaveInData::SetSystemStyle(
+ uno::Reference< frame::XFrame > xFrame,
+ const OUString& rResourceURL,
+ sal_Int32 nStyle )
+{
+ // change the style using the API
+ SetSystemStyle( rResourceURL, nStyle );
+
+ // this code is a temporary hack as the UI is not updating after
+ // changing the toolbar style via the API
+ uno::Reference< css::frame::XLayoutManager > xLayoutManager;
+ Window *window = NULL;
+
+ uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY );
+ if ( xPropSet.is() )
+ {
+ uno::Any a = xPropSet->getPropertyValue(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) );
+ a >>= xLayoutManager;
+ }
+
+ if ( xLayoutManager.is() )
+ {
+ uno::Reference< css::ui::XUIElement > xUIElement =
+ xLayoutManager->getElement( rResourceURL );
+
+ // check reference before we call getRealInterface. The layout manager
+ // can only provide references for elements that have been created
+ // before. It's possible that the current element is not available.
+ uno::Reference< com::sun::star::awt::XWindow > xWindow;
+ if ( xUIElement.is() )
+ xWindow = uno::Reference< com::sun::star::awt::XWindow >(
+ xUIElement->getRealInterface(), uno::UNO_QUERY );
+
+ window = VCLUnoHelper::GetWindow( xWindow );
+ }
+
+ if ( window != NULL && window->GetType() == WINDOW_TOOLBOX )
+ {
+ ToolBox* toolbox = (ToolBox*)window;
+
+ if ( nStyle == 0 )
+ {
+ toolbox->SetButtonType( BUTTON_SYMBOL );
+ }
+ else if ( nStyle == 1 )
+ {
+ toolbox->SetButtonType( BUTTON_TEXT );
+ }
+ if ( nStyle == 2 )
+ {
+ toolbox->SetButtonType( BUTTON_SYMBOLTEXT );
+ }
+ }
+}
+
+void ToolbarSaveInData::SetSystemStyle(
+ const OUString& rResourceURL,
+ sal_Int32 nStyle )
+{
+ if ( rResourceURL.indexOf( OUString::createFromAscii( "private" ) ) == 0 &&
+ m_xPersistentWindowState.is() &&
+ m_xPersistentWindowState->hasByName( rResourceURL ) )
+ {
+ try
+ {
+ uno::Sequence< beans::PropertyValue > aProps;
+
+ uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
+
+ if ( a >>= aProps )
+ {
+ for ( sal_Int32 i = 0; i < aProps.getLength(); i++ )
+ {
+ if ( aProps[ i ].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE) )
+ {
+ aProps[ i ].Value = uno::makeAny( nStyle );
+ break;
+ }
+ }
+ }
+
+ uno::Reference< container::XNameReplace >
+ xNameReplace( m_xPersistentWindowState, uno::UNO_QUERY );
+
+ xNameReplace->replaceByName( rResourceURL, uno::makeAny( aProps ) );
+ }
+ catch ( uno::Exception& )
+ {
+ // do nothing, a default value is returned
+ OSL_TRACE("Exception setting toolbar style");
+ }
+ }
+}
+
+sal_Int32 ToolbarSaveInData::GetSystemStyle( const OUString& rResourceURL )
+{
+ sal_Int32 result = 0;
+
+ if ( rResourceURL.indexOf( OUString::createFromAscii( "private" ) ) == 0 &&
+ m_xPersistentWindowState.is() &&
+ m_xPersistentWindowState->hasByName( rResourceURL ) )
+ {
+ try
+ {
+ uno::Sequence< beans::PropertyValue > aProps;
+ uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
+
+ if ( a >>= aProps )
+ {
+ for ( sal_Int32 i = 0; i < aProps.getLength(); i++ )
+ {
+ if ( aProps[ i ].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE) )
+ {
+ aProps[i].Value >>= result;
+ break;
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ // do nothing, a default value is returned
+ }
+ }
+
+ return result;
+}
+
+OUString ToolbarSaveInData::GetSystemUIName( const OUString& rResourceURL )
+{
+ OUString result;
+
+ if ( rResourceURL.indexOf( OUString::createFromAscii( "private" ) ) == 0 &&
+ m_xPersistentWindowState.is() &&
+ m_xPersistentWindowState->hasByName( rResourceURL ) )
+ {
+ try
+ {
+ uno::Sequence< beans::PropertyValue > aProps;
+ uno::Any a( m_xPersistentWindowState->getByName( rResourceURL ) );
+
+ if ( a >>= aProps )
+ {
+ for ( sal_Int32 i = 0; i < aProps.getLength(); i++ )
+ {
+ if ( aProps[ i ].Name.equalsAscii( ITEM_DESCRIPTOR_UINAME) )
+ {
+ aProps[ i ].Value >>= result;
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ // do nothing, an empty UIName will be returned
+ }
+ }
+
+ if ( rResourceURL.indexOf( OUString::createFromAscii( ".uno" ) ) == 0 &&
+ m_xCommandToLabelMap.is() &&
+ m_xCommandToLabelMap->hasByName( rResourceURL ) )
+ {
+ uno::Any a;
+ try
+ {
+ a = m_xCommandToLabelMap->getByName( rResourceURL );
+
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if ( aPropSeq[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ) )
+ {
+ aPropSeq[i].Value >>= result;
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ // not a system command name
+ }
+ }
+
+ return result;
+}
+
+bool EntrySort( SvxConfigEntry* a, SvxConfigEntry* b )
+{
+ return a->GetName().compareTo( b->GetName() ) < 0;
+}
+
+SvxEntries* ToolbarSaveInData::GetEntries()
+{
+ typedef ::std::hash_map< ::rtl::OUString,
+ bool,
+ ::rtl::OUStringHash,
+ ::std::equal_to< ::rtl::OUString > > ToolbarInfo;
+
+ ToolbarInfo aToolbarInfo;
+
+ if ( pRootEntry == NULL )
+ {
+
+ pRootEntry = new SvxConfigEntry(
+ String::CreateFromAscii("MainToolbars"), String(), TRUE );
+
+ uno::Sequence< uno::Sequence < beans::PropertyValue > > info =
+ GetConfigManager()->getUIElementsInfo(
+ css::ui::UIElementType::TOOLBAR );
+
+ for ( sal_Int32 i = 0; i < info.getLength(); i++ )
+ {
+ uno::Sequence< beans::PropertyValue > props = info[ i ];
+
+ OUString url;
+ OUString systemname;
+ OUString uiname;
+
+ for ( sal_Int32 j = 0; j < props.getLength(); j++ )
+ {
+ if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_RESOURCEURL) )
+ {
+ props[ j ].Value >>= url;
+ systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
+ }
+ else if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_UINAME) )
+ {
+ props[ j ].Value >>= uiname;
+ }
+ }
+
+ try
+ {
+ uno::Reference< container::XIndexAccess > xToolbarSettings =
+ GetConfigManager()->getSettings( url, sal_False );
+
+ if ( uiname.getLength() == 0 )
+ {
+ // try to get the name from m_xPersistentWindowState
+ uiname = GetSystemUIName( url );
+
+ if ( uiname.getLength() == 0 )
+ {
+ uiname = systemname;
+ }
+ }
+
+ SvxConfigEntry* pEntry = new SvxConfigEntry(
+ uiname, url, TRUE );
+
+ pEntry->SetMain( TRUE );
+ pEntry->SetStyle( GetSystemStyle( url ) );
+
+
+ // insert into hash_map to filter duplicates from the parent
+ aToolbarInfo.insert( ToolbarInfo::value_type( systemname, true ));
+
+ OUString custom = OUString::createFromAscii(CUSTOM_TOOLBAR_STR);
+ if ( systemname.indexOf( custom ) == 0 )
+ {
+ pEntry->SetUserDefined( TRUE );
+ }
+ else
+ {
+ pEntry->SetUserDefined( FALSE );
+ }
+
+ pRootEntry->GetEntries()->push_back( pEntry );
+
+ LoadToolbar( xToolbarSettings, pEntry );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // TODO, handle resourceURL with no settings
+ }
+ }
+
+ uno::Reference< css::ui::XUIConfigurationManager > xParentCfgMgr = GetParentConfigManager();
+ if ( xParentCfgMgr.is() )
+ {
+ // Retrieve also the parent toolbars to make it possible
+ // to configure module toolbars and save them into the document
+ // config manager.
+ uno::Sequence< uno::Sequence < beans::PropertyValue > > info_ =
+ xParentCfgMgr->getUIElementsInfo(
+ css::ui::UIElementType::TOOLBAR );
+
+ for ( sal_Int32 i = 0; i < info_.getLength(); i++ )
+ {
+ uno::Sequence< beans::PropertyValue > props = info_[ i ];
+
+ OUString url;
+ OUString systemname;
+ OUString uiname;
+
+ for ( sal_Int32 j = 0; j < props.getLength(); j++ )
+ {
+ if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_RESOURCEURL) )
+ {
+ props[ j ].Value >>= url;
+ systemname = url.copy( url.lastIndexOf( '/' ) + 1 );
+ }
+ else if ( props[ j ].Name.equalsAscii( ITEM_DESCRIPTOR_UINAME) )
+ {
+ props[ j ].Value >>= uiname;
+ }
+ }
+
+ // custom toolbars of the parent are not visible in the document layer
+ OUString custom = OUString::createFromAscii(CUSTOM_TOOLBAR_STR);
+ if ( systemname.indexOf( custom ) == 0 )
+ continue;
+
+ // check if toolbar is already in the document layer
+ ToolbarInfo::const_iterator pIter = aToolbarInfo.find( systemname );
+ if ( pIter == aToolbarInfo.end() )
+ {
+ aToolbarInfo.insert( ToolbarInfo::value_type( systemname, true ));
+
+ try
+ {
+ uno::Reference< container::XIndexAccess > xToolbarSettings =
+ xParentCfgMgr->getSettings( url, sal_False );
+
+ if ( uiname.getLength() == 0 )
+ {
+ // try to get the name from m_xPersistentWindowState
+ uiname = GetSystemUIName( url );
+
+ if ( uiname.getLength() == 0 )
+ {
+ uiname = systemname;
+ }
+ }
+
+ SvxConfigEntry* pEntry = new SvxConfigEntry(
+ uiname, url, TRUE, TRUE );
+
+ pEntry->SetMain( TRUE );
+ pEntry->SetStyle( GetSystemStyle( url ) );
+
+ if ( systemname.indexOf( custom ) == 0 )
+ {
+ pEntry->SetUserDefined( TRUE );
+ }
+ else
+ {
+ pEntry->SetUserDefined( FALSE );
+ }
+
+ pRootEntry->GetEntries()->push_back( pEntry );
+
+ LoadToolbar( xToolbarSettings, pEntry );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // TODO, handle resourceURL with no settings
+ }
+ }
+ }
+ }
+
+ std::sort( GetEntries()->begin(), GetEntries()->end(), EntrySort );
+ }
+
+ return pRootEntry->GetEntries();
+}
+
+void
+ToolbarSaveInData::SetEntries( SvxEntries* pNewEntries )
+{
+ // delete old menu hierarchy first
+ if ( pRootEntry != NULL && pRootEntry->GetEntries() != NULL )
+ {
+ delete pRootEntry->GetEntries();
+ }
+
+ // now set new menu hierarchy
+ pRootEntry->SetEntries( pNewEntries );
+}
+
+bool
+ToolbarSaveInData::HasURL( const OUString& rURL )
+{
+ SvxEntries::const_iterator iter = GetEntries()->begin();
+ SvxEntries::const_iterator end = GetEntries()->end();
+
+ while ( iter != end )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ if ( pEntry->GetCommand().equals( rURL ) )
+ {
+ if ( pEntry->IsParentData() )
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ iter++;
+ }
+ return FALSE;
+}
+
+bool ToolbarSaveInData::HasSettings()
+{
+ // return true if there is at least one toolbar entry
+ if ( GetEntries()->size() > 0 )
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void ToolbarSaveInData::Reset()
+{
+ SvxEntries::const_iterator toolbars = GetEntries()->begin();
+ SvxEntries::const_iterator end = GetEntries()->end();
+
+ // reset each toolbar by calling removeSettings for it's toolbar URL
+ for ( ; toolbars != end; toolbars++ )
+ {
+ SvxConfigEntry* pToolbar = *toolbars;
+
+ try
+ {
+ OUString url = pToolbar->GetCommand();
+ GetConfigManager()->removeSettings( url );
+ }
+ catch ( uno::Exception& )
+ {
+ // error occured removing the settings
+ // TODO - add error dialog in future?
+ }
+ }
+
+ // persist changes to toolbar storage
+ PersistChanges( GetConfigManager() );
+
+ // now delete the root SvxConfigEntry the next call to GetEntries()
+ // causes it to be reinitialised
+ delete pRootEntry;
+ pRootEntry = NULL;
+
+ // reset all icons to default
+ try
+ {
+ GetImageManager()->reset();
+ PersistChanges( GetImageManager() );
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_TRACE("Error resetting all icons when resetting toolbars");
+ }
+}
+
+bool ToolbarSaveInData::Apply()
+{
+ // toolbar changes are instantly applied
+ return FALSE;
+}
+
+void ToolbarSaveInData::ApplyToolbar(
+ uno::Reference< container::XIndexContainer >& rToolbarBar,
+ uno::Reference< lang::XSingleComponentFactory >& rFactory,
+ SvxConfigEntry* pToolbarData )
+{
+ SvxEntries::const_iterator iter = pToolbarData->GetEntries()->begin();
+ SvxEntries::const_iterator end = pToolbarData->GetEntries()->end();
+
+ for ( ; iter != end; iter++ )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ if ( pEntry->IsPopup() )
+ {
+ uno::Sequence< beans::PropertyValue > aPropValueSeq =
+ ConvertToolbarEntry( m_xCommandToLabelMap, pEntry );
+
+ uno::Reference< container::XIndexContainer > xSubMenuBar(
+ rFactory->createInstanceWithContext( m_xComponentContext ),
+ uno::UNO_QUERY );
+
+ sal_Int32 nIndex = aPropValueSeq.getLength();
+ aPropValueSeq.realloc( nIndex + 1 );
+ aPropValueSeq[nIndex].Name = m_aDescriptorContainer;
+ aPropValueSeq[nIndex].Value <<= xSubMenuBar;
+ rToolbarBar->insertByIndex(
+ rToolbarBar->getCount(), uno::makeAny( aPropValueSeq ));
+
+ ApplyToolbar( xSubMenuBar, rFactory, pEntry );
+ }
+ else if ( pEntry->IsSeparator() )
+ {
+ rToolbarBar->insertByIndex(
+ rToolbarBar->getCount(), uno::makeAny( m_aSeparatorSeq ));
+ }
+ else
+ {
+ uno::Sequence< beans::PropertyValue > aPropValueSeq =
+ ConvertToolbarEntry( m_xCommandToLabelMap, pEntry );
+
+ rToolbarBar->insertByIndex(
+ rToolbarBar->getCount(), uno::makeAny( aPropValueSeq ));
+ }
+ }
+}
+
+void ToolbarSaveInData::ApplyToolbar( SvxConfigEntry* pToolbar )
+{
+ // Apply new toolbar structure to our settings container
+ uno::Reference< container::XIndexAccess > xSettings(
+ GetConfigManager()->createSettings(), uno::UNO_QUERY );
+
+ uno::Reference< container::XIndexContainer > xIndexContainer (
+ xSettings, uno::UNO_QUERY );
+
+ uno::Reference< lang::XSingleComponentFactory > xFactory (
+ xSettings, uno::UNO_QUERY );
+
+ ApplyToolbar( xIndexContainer, xFactory, pToolbar );
+
+ uno::Reference< beans::XPropertySet > xProps(
+ xSettings, uno::UNO_QUERY );
+
+ if ( pToolbar->IsUserDefined() )
+ {
+ xProps->setPropertyValue(
+ OUString::createFromAscii( ITEM_DESCRIPTOR_UINAME ),
+ uno::makeAny( OUString( pToolbar->GetName() ) ) );
+ }
+
+ try
+ {
+ if ( GetConfigManager()->hasSettings( pToolbar->GetCommand() ) )
+ {
+ GetConfigManager()->replaceSettings(
+ pToolbar->GetCommand(), xSettings );
+ }
+ else
+ {
+ GetConfigManager()->insertSettings(
+ pToolbar->GetCommand(), xSettings );
+ if ( pToolbar->IsParentData() )
+ pToolbar->SetParentData( false );
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ OSL_TRACE("caught container::NoSuchElementException saving settings");
+ }
+ catch ( com::sun::star::io::IOException& )
+ {
+ OSL_TRACE("caught IOException saving settings");
+ }
+ catch ( com::sun::star::uno::Exception& )
+ {
+ OSL_TRACE("caught some other exception saving settings");
+ }
+
+ PersistChanges( GetConfigManager() );
+}
+
+void ToolbarSaveInData::CreateToolbar( SvxConfigEntry* pToolbar )
+{
+ // show the new toolbar in the UI also
+ uno::Reference< container::XIndexAccess >
+ xSettings( GetConfigManager()->createSettings(), uno::UNO_QUERY );
+
+ uno::Reference< container::XIndexContainer >
+ xIndexContainer ( xSettings, uno::UNO_QUERY );
+
+ uno::Reference< beans::XPropertySet >
+ xPropertySet( xSettings, uno::UNO_QUERY );
+
+ xPropertySet->setPropertyValue(
+ OUString::createFromAscii( ITEM_DESCRIPTOR_UINAME ),
+ uno::makeAny( pToolbar->GetName() ) );
+
+ try
+ {
+ GetConfigManager()->insertSettings( pToolbar->GetCommand(), xSettings );
+ }
+ catch ( container::ElementExistException& )
+ {
+ OSL_TRACE("caught ElementExistsException saving settings");
+ }
+ catch ( com::sun::star::lang::IllegalArgumentException& )
+ {
+ OSL_TRACE("caught IOException saving settings");
+ }
+ catch ( com::sun::star::lang::IllegalAccessException& )
+ {
+ OSL_TRACE("caught IOException saving settings");
+ }
+ catch ( com::sun::star::uno::Exception& )
+ {
+ OSL_TRACE("caught some other exception saving settings");
+ }
+
+ GetEntries()->push_back( pToolbar );
+
+ PersistChanges( GetConfigManager() );
+}
+
+void ToolbarSaveInData::RemoveToolbar( SvxConfigEntry* pToolbar )
+{
+ try
+ {
+ OUString url = pToolbar->GetCommand();
+ GetConfigManager()->removeSettings( url );
+ RemoveEntry( GetEntries(), pToolbar );
+ delete pToolbar;
+
+ PersistChanges( GetConfigManager() );
+
+ // remove the persistent window state data
+ css::uno::Reference< css::container::XNameContainer > xNameContainer(
+ m_xPersistentWindowState, css::uno::UNO_QUERY_THROW );
+
+ xNameContainer->removeByName( url );
+ }
+ catch ( uno::Exception& )
+ {
+ // error occured removing the settings
+ }
+}
+
+void ToolbarSaveInData::RestoreToolbar( SvxConfigEntry* pToolbar )
+{
+ OUString url = pToolbar->GetCommand();
+
+ // Restore of toolbar is done by removing it from
+ // it's configuration manager and then getting it again
+ bool bParentToolbar = pToolbar->IsParentData();
+
+ // Cannot restore parent toolbar
+ if ( bParentToolbar )
+ return;
+
+ try
+ {
+ GetConfigManager()->removeSettings( url );
+ pToolbar->GetEntries()->clear();
+ PersistChanges( GetConfigManager() );
+ }
+ catch ( uno::Exception& )
+ {
+ // if an error occurs removing the settings then just return
+ return;
+ }
+
+ // Now reload the toolbar settings
+ try
+ {
+ uno::Reference< container::XIndexAccess > xToolbarSettings;
+ if ( IsDocConfig() )
+ {
+ xToolbarSettings = GetParentConfigManager()->getSettings( url, sal_False );
+ pToolbar->SetParentData( true );
+ }
+ else
+ xToolbarSettings = GetConfigManager()->getSettings( url, sal_False );
+
+ LoadToolbar( xToolbarSettings, pToolbar );
+
+ // After reloading, ensure that the icon is reset of each entry
+ // in the toolbar
+ SvxEntries::const_iterator iter = pToolbar->GetEntries()->begin();
+ uno::Sequence< OUString > aURLSeq( 1 );
+ for ( ; iter != pToolbar->GetEntries()->end(); iter++ )
+ {
+ SvxConfigEntry* pEntry = *iter;
+ aURLSeq[ 0 ] = pEntry->GetCommand();
+
+ try
+ {
+ GetImageManager()->removeImages( GetImageType(), aURLSeq );
+ }
+ catch ( uno::Exception& )
+ {
+ OSL_TRACE("Error restoring icon when resetting toolbar");
+ }
+ }
+ PersistChanges( GetImageManager() );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // cannot find the resource URL after removing it
+ // so no entry will appear in the toolbar list
+ }
+}
+
+void ToolbarSaveInData::ReloadToolbar( const OUString& rResourceURL )
+{
+ SvxEntries::const_iterator iter = GetEntries()->begin();
+ SvxConfigEntry* pToolbar = NULL;
+
+ for ( ; iter != GetEntries()->end(); iter++ )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ if ( pEntry->GetCommand().equals( rResourceURL ) )
+ {
+ pToolbar = pEntry;
+ break;
+ }
+ }
+
+ if ( pToolbar != NULL )
+ {
+ delete pToolbar->GetEntries();
+
+ try
+ {
+ uno::Reference< container::XIndexAccess > xToolbarSettings;
+
+ if ( pToolbar->IsParentData() )
+ {
+ xToolbarSettings = GetParentConfigManager()->getSettings(
+ pToolbar->GetCommand(), sal_False);
+ }
+ else
+ {
+ xToolbarSettings = GetConfigManager()->getSettings(
+ pToolbar->GetCommand(), sal_False);
+ }
+
+ LoadToolbar( xToolbarSettings, pToolbar );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ // toolbar not found for some reason
+ // it will not appear in the toolbar list
+ }
+ }
+}
+
+bool ToolbarSaveInData::LoadToolbar(
+ const uno::Reference< container::XIndexAccess >& xToolbarSettings,
+ SvxConfigEntry* pParentData )
+{
+ SvxEntries* pEntries = pParentData->GetEntries();
+
+ for ( sal_Int32 nIndex = 0; nIndex < xToolbarSettings->getCount(); nIndex++ )
+ {
+ uno::Reference< container::XIndexAccess > xSubMenu;
+ OUString aCommandURL;
+ OUString aHelpURL;
+ OUString aLabel;
+ bool bIsUserDefined = TRUE;
+ sal_Bool bIsVisible;
+ sal_Int32 nStyle;
+
+ sal_uInt16 nType( css::ui::ItemType::DEFAULT );
+
+ bool bItem = GetToolbarItemData( xToolbarSettings, nIndex, aCommandURL,
+ aHelpURL, aLabel, nType, bIsVisible, nStyle, xSubMenu );
+
+ if ( bItem )
+ {
+ if ( nType == css::ui::ItemType::DEFAULT )
+ {
+ uno::Any a;
+ try
+ {
+ a = m_xCommandToLabelMap->getByName( aCommandURL );
+ bIsUserDefined = FALSE;
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ bIsUserDefined = TRUE;
+ }
+
+ // If custom label not set retrieve it from the command
+ // to info service
+ if ( aLabel.equals( OUString() ) )
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if ( aPropSeq[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL ) )
+ {
+ aPropSeq[i].Value >>= aLabel;
+ break;
+ }
+ }
+ }
+ }
+
+ if ( xSubMenu.is() )
+ {
+ SvxConfigEntry* pEntry = new SvxConfigEntry(
+ aLabel, aCommandURL, TRUE );
+
+ pEntry->SetUserDefined( bIsUserDefined );
+ pEntry->SetHelpURL( aHelpURL );
+ pEntry->SetVisible( bIsVisible );
+
+ pEntries->push_back( pEntry );
+
+ LoadToolbar( xSubMenu, pEntry );
+ }
+ else
+ {
+ SvxConfigEntry* pEntry = new SvxConfigEntry(
+ aLabel, aCommandURL, FALSE );
+ pEntry->SetUserDefined( bIsUserDefined );
+ pEntry->SetHelpURL( aHelpURL );
+ pEntry->SetVisible( bIsVisible );
+ pEntry->SetStyle( nStyle );
+ pEntries->push_back( pEntry );
+ }
+ }
+ else
+ {
+ SvxConfigEntry* pEntry = new SvxConfigEntry;
+ pEntry->SetUserDefined( bIsUserDefined );
+ pEntries->push_back( pEntry );
+ }
+ }
+ }
+
+ return true;
+}
+
+IMPL_LINK( SvxToolbarConfigPage, SelectToolbarEntry, Control *, pBox )
+{
+ (void)pBox;
+ UpdateButtonStates();
+ return 1;
+}
+
+void SvxToolbarConfigPage::UpdateButtonStates()
+{
+ PopupMenu* pPopup = aModifyCommandButton.GetPopupMenu();
+ pPopup->EnableItem( ID_RENAME, FALSE );
+ pPopup->EnableItem( ID_DELETE, FALSE );
+ pPopup->EnableItem( ID_BEGIN_GROUP, FALSE );
+ pPopup->EnableItem( ID_DEFAULT_COMMAND, FALSE );
+ pPopup->EnableItem( ID_ICON_ONLY, FALSE );
+ pPopup->EnableItem( ID_ICON_AND_TEXT, FALSE );
+ pPopup->EnableItem( ID_TEXT_ONLY, FALSE );
+ pPopup->EnableItem( ID_CHANGE_SYMBOL, FALSE );
+ pPopup->EnableItem( ID_RESET_SYMBOL, FALSE );
+
+ aDescriptionField.Clear();
+
+ SvLBoxEntry* selection = aContentsListBox->GetCurEntry();
+ if ( aContentsListBox->GetEntryCount() == 0 || selection == NULL )
+ {
+ return;
+ }
+
+ SvxConfigEntry* pEntryData = (SvxConfigEntry*) selection->GetUserData();
+ if ( pEntryData->IsSeparator() )
+ pPopup->EnableItem( ID_DELETE, TRUE );
+ else
+ {
+ pPopup->EnableItem( ID_BEGIN_GROUP, TRUE );
+ pPopup->EnableItem( ID_DELETE, TRUE );
+ pPopup->EnableItem( ID_RENAME, TRUE );
+ pPopup->EnableItem( ID_ICON_ONLY, TRUE );
+ pPopup->EnableItem( ID_ICON_AND_TEXT, TRUE );
+ pPopup->EnableItem( ID_TEXT_ONLY, TRUE );
+ pPopup->EnableItem( ID_CHANGE_SYMBOL, TRUE );
+
+ if ( !pEntryData->IsUserDefined() )
+ pPopup->EnableItem( ID_DEFAULT_COMMAND, TRUE );
+
+ if ( pEntryData->IsIconModified() )
+ pPopup->EnableItem( ID_RESET_SYMBOL, TRUE );
+
+ aDescriptionField.SetNewText( pEntryData->GetHelpText() );
+ }
+}
+
+short SvxToolbarConfigPage::QueryReset()
+{
+ String msg =
+ String( CUI_RES( RID_SVXSTR_CONFIRM_TOOLBAR_RESET ) );
+
+ String saveInName = aSaveInListBox.GetEntry(
+ aSaveInListBox.GetSelectEntryPos() );
+
+ OUString label = replaceSaveInName( msg, saveInName );
+
+ QueryBox qbox( this, WB_YES_NO, label );
+
+ return qbox.Execute();
+}
+
+IMPL_LINK( SvxToolbarConfigPage, SelectToolbar, ListBox *, pBox )
+{
+ (void)pBox;
+
+ aContentsListBox->Clear();
+
+ SvxConfigEntry* pToolbar = GetTopLevelSelection();
+ if ( pToolbar == NULL )
+ {
+ aModifyTopLevelButton.Enable( FALSE );
+ aModifyCommandButton.Enable( FALSE );
+ aAddCommandsButton.Enable( FALSE );
+
+ return 0;
+ }
+
+ aModifyTopLevelButton.Enable( TRUE );
+ aModifyCommandButton.Enable( TRUE );
+ aAddCommandsButton.Enable( TRUE );
+
+ PopupMenu* pPopup = aModifyTopLevelButton.GetPopupMenu();
+
+ pPopup->EnableItem( ID_DELETE, pToolbar->IsDeletable() );
+ pPopup->EnableItem( ID_RENAME, pToolbar->IsRenamable() );
+ pPopup->EnableItem( ID_DEFAULT_STYLE, !pToolbar->IsRenamable() );
+
+ switch( pToolbar->GetStyle() )
+ {
+ case 0:
+ {
+ pPopup->CheckItem( ID_ICONS_ONLY );
+ break;
+ }
+ case 1:
+ {
+ pPopup->CheckItem( ID_TEXT_ONLY );
+ break;
+ }
+ case 2:
+ {
+ pPopup->CheckItem( ID_ICONS_AND_TEXT );
+ break;
+ }
+ }
+
+ SvxEntries* pEntries = pToolbar->GetEntries();
+ SvxEntries::const_iterator iter = pEntries->begin();
+
+ for ( ; iter != pEntries->end(); iter++ )
+ {
+ SvxConfigEntry* pEntry = *iter;
+
+ SvLBoxEntry* pNewLBEntry = InsertEntryIntoUI( pEntry );
+
+ if (pEntry->IsBinding())
+ {
+ aContentsListBox->SetCheckButtonState( pNewLBEntry,
+ pEntry->IsVisible() ? SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
+ }
+ else
+ {
+ aContentsListBox->SetCheckButtonState(
+ pNewLBEntry, SV_BUTTON_TRISTATE );
+ }
+ }
+
+ UpdateButtonStates();
+
+ return 0;
+}
+
+IMPL_LINK( SvxToolbarConfigPage, NewToolbarHdl, Button *, pButton )
+{
+ (void)pButton;
+
+ String prefix =
+ String( CUI_RES( RID_SVXSTR_NEW_TOOLBAR ) );
+
+ OUString aNewName =
+ generateCustomName( prefix, GetSaveInData()->GetEntries() );
+
+ OUString aNewURL =
+ generateCustomURL( GetSaveInData()->GetEntries() );
+
+ SvxNewToolbarDialog* pNameDialog = new SvxNewToolbarDialog( 0, aNewName );
+
+ USHORT nInsertPos;
+ for ( USHORT i = 0 ; i < aSaveInListBox.GetEntryCount(); i++ )
+ {
+ SaveInData* pData =
+ (SaveInData*) aSaveInListBox.GetEntryData( i );
+
+ nInsertPos = pNameDialog->aSaveInListBox.InsertEntry(
+ aSaveInListBox.GetEntry( i ) );
+
+ pNameDialog->aSaveInListBox.SetEntryData( nInsertPos, pData );
+ }
+
+ pNameDialog->aSaveInListBox.SelectEntryPos(
+ aSaveInListBox.GetSelectEntryPos(), TRUE );
+
+ bool ret = pNameDialog->Execute();
+ if ( ret == RET_OK )
+ {
+ pNameDialog->GetName( aNewName );
+
+ nInsertPos = pNameDialog->aSaveInListBox.GetSelectEntryPos();
+
+ ToolbarSaveInData* pData = (ToolbarSaveInData*)
+ pNameDialog->aSaveInListBox.GetEntryData( nInsertPos );
+
+ if ( GetSaveInData() != pData )
+ {
+ aSaveInListBox.SelectEntryPos( nInsertPos, TRUE );
+ aSaveInListBox.GetSelectHdl().Call(this);
+ }
+
+ SvxConfigEntry* pToolbar =
+ new SvxConfigEntry( aNewName, aNewURL, TRUE );
+
+ pToolbar->SetUserDefined( TRUE );
+ pToolbar->SetMain( TRUE );
+
+ pData->CreateToolbar( pToolbar );
+
+ nInsertPos = aTopLevelListBox.InsertEntry( pToolbar->GetName() );
+ aTopLevelListBox.SetEntryData( nInsertPos, pToolbar );
+ aTopLevelListBox.SelectEntryPos( nInsertPos, TRUE );
+ aTopLevelListBox.GetSelectHdl().Call(this);
+
+ pData->SetModified( TRUE );
+ }
+
+ delete pNameDialog;
+
+ return 0;
+}
+
+IMPL_LINK( SvxToolbarConfigPage, AddCommandsHdl, Button *, pButton )
+{
+ (void)pButton;
+
+ if ( pSelectorDlg == NULL )
+ {
+ // Create Script Selector which shows slot commands
+ pSelectorDlg = new SvxScriptSelectorDialog( this, TRUE, m_xFrame );
+
+ // Position the Script Selector over the Add button so it is
+ // beside the menu contents list and does not obscure it
+ pSelectorDlg->SetPosPixel( aAddCommandsButton.GetPosPixel() );
+
+ pSelectorDlg->SetAddHdl(
+ LINK( this, SvxToolbarConfigPage, AddFunctionHdl ) );
+ }
+
+ pSelectorDlg->SetImageProvider(
+ static_cast< ImageProvider* >( GetSaveInData() ) );
+
+ pSelectorDlg->Show();
+ return 1;
+}
+
+IMPL_LINK( SvxToolbarConfigPage, AddFunctionHdl,
+ SvxScriptSelectorDialog *, pDialog )
+{
+ (void)pDialog;
+
+ AddFunction();
+
+ return 0;
+}
+
+SvLBoxEntry* SvxToolbarConfigPage::AddFunction(
+ SvLBoxEntry* pTarget, bool bFront, bool bAllowDuplicates )
+{
+ SvLBoxEntry* pNewLBEntry =
+ SvxConfigPage::AddFunction( pTarget, bFront, bAllowDuplicates );
+
+ SvxConfigEntry* pEntry = (SvxConfigEntry*) pNewLBEntry->GetUserData();
+
+ if ( pEntry->IsBinding() )
+ {
+ pEntry->SetVisible( TRUE );
+ aContentsListBox->SetCheckButtonState(
+ pNewLBEntry, SV_BUTTON_CHECKED );
+ }
+ else
+ {
+ aContentsListBox->SetCheckButtonState(
+ pNewLBEntry, SV_BUTTON_TRISTATE );
+ }
+
+ // get currently selected toolbar and apply change
+ SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+ if ( pToolbar != NULL )
+ {
+ ( ( ToolbarSaveInData* ) GetSaveInData() )->ApplyToolbar( pToolbar );
+ }
+
+ return pNewLBEntry;
+}
+
+// -----------------------------------------------------------------------
+
+SvxToolbarEntriesListBox::SvxToolbarEntriesListBox(
+ Window* pParent, const ResId& aResId )
+ :
+ SvxMenuEntriesListBox( pParent, aResId ),
+ pPage( ( SvxToolbarConfigPage* ) pParent )
+{
+ m_pButtonData = new SvLBoxButtonData( this );
+ BuildCheckBoxButtonImages( m_pButtonData );
+ EnableCheckButton( m_pButtonData );
+
+ m_bHiContrastMode = GetSettings().GetStyleSettings().GetHighContrastMode();
+}
+
+// --------------------------------------------------------
+
+SvxToolbarEntriesListBox::~SvxToolbarEntriesListBox()
+{
+ delete m_pButtonData;
+}
+
+// --------------------------------------------------------
+
+void SvxToolbarEntriesListBox::BuildCheckBoxButtonImages( SvLBoxButtonData* pData )
+{
+ // Build checkbox images according to the current application
+ // settings. This is necessary to be able to have correct colors
+ // in all color modes, like high contrast.
+ const AllSettings& rSettings = Application::GetSettings();
+
+ VirtualDevice aDev;
+ Size aSize( 26, 20 );
+
+ aDev.SetOutputSizePixel( aSize );
+
+ Image aImage = GetSizedImage( aDev, aSize,
+ CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT ));
+
+ // Fill button data struct with new images
+ pData->aBmps[SV_BMP_UNCHECKED] = aImage;
+ pData->aBmps[SV_BMP_CHECKED] = GetSizedImage( aDev, aSize, CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED ));
+ pData->aBmps[SV_BMP_HICHECKED] = GetSizedImage( aDev, aSize, CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_CHECKED | BUTTON_DRAW_PRESSED ));
+ pData->aBmps[SV_BMP_HIUNCHECKED] = GetSizedImage( aDev, aSize, CheckBox::GetCheckImage( rSettings, BUTTON_DRAW_DEFAULT | BUTTON_DRAW_PRESSED));
+ pData->aBmps[SV_BMP_TRISTATE] = GetSizedImage( aDev, aSize, Image() ); // Use tristate bitmaps to have no checkbox for separator entries
+ pData->aBmps[SV_BMP_HITRISTATE] = GetSizedImage( aDev, aSize, Image() );
+
+ // Get image size
+ m_aCheckBoxImageSizePixel = aImage.GetSizePixel();
+}
+
+Image SvxToolbarEntriesListBox::GetSizedImage(
+ VirtualDevice& aDev, const Size& aNewSize, const Image& aImage )
+{
+ // Create new checkbox images for treelistbox. They must have a
+ // decent width to have a clear column for the visibility checkbox.
+
+ // Standard transparent color is light magenta as is won't be
+ // used for other things
+ Color aFillColor( COL_LIGHTMAGENTA );
+
+ // Position image at the center of (width-2),(height) rectangle.
+ // We need 2 pixels to have a bigger border to the next button image
+ USHORT nPosX = std::max( (USHORT) (((( aNewSize.Width() - 2 ) - aImage.GetSizePixel().Width() ) / 2 ) - 1), (USHORT) 0 );
+ USHORT nPosY = std::max( (USHORT) (((( aNewSize.Height() - 2 ) - aImage.GetSizePixel().Height() ) / 2 ) + 1), (USHORT) 0 );
+ Point aPos( nPosX > 0 ? nPosX : 0, nPosY > 0 ? nPosY : 0 );
+ aDev.SetFillColor( aFillColor );
+ aDev.SetLineColor( aFillColor );
+ aDev.DrawRect( Rectangle( Point(), aNewSize ));
+ aDev.DrawImage( aPos, aImage );
+
+ // Draw separator line 2 pixels left from the right border
+ Color aLineColor = GetDisplayBackground().GetColor().IsDark() ? Color( COL_WHITE ) : Color( COL_BLACK );
+ aDev.SetLineColor( aLineColor );
+ aDev.DrawLine( Point( aNewSize.Width()-3, 0 ), Point( aNewSize.Width()-3, aNewSize.Height()-1 ));
+
+ // Create new image that uses the fillcolor as transparent
+ return Image( aDev.GetBitmap( Point(), aNewSize ), aFillColor );
+}
+
+void SvxToolbarEntriesListBox::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ SvTreeListBox::DataChanged( rDCEvt );
+
+ if (( rDCEvt.GetType() == DATACHANGED_SETTINGS ) &&
+ ( rDCEvt.GetFlags() & SETTINGS_STYLE ))
+ {
+ // We have to reset all images because we change to/from high contrast mode
+ m_bHiContrastMode = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ BuildCheckBoxButtonImages( m_pButtonData );
+ Invalidate();
+ }
+}
+
+// --------------------------------------------------------
+
+void SvxToolbarEntriesListBox::ChangeVisibility( SvLBoxEntry* pEntry )
+{
+ if ( pEntry != NULL )
+ {
+ SvxConfigEntry* pEntryData =
+ (SvxConfigEntry*) pEntry->GetUserData();
+
+ if ( pEntryData->IsBinding() )
+ {
+ pEntryData->SetVisible( !pEntryData->IsVisible() );
+
+ SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
+
+ ToolbarSaveInData* pToolbarSaveInData = ( ToolbarSaveInData* )
+ pPage->GetSaveInData();
+
+ pToolbarSaveInData->ApplyToolbar( pToolbar );
+
+ SetCheckButtonState( pEntry, pEntryData->IsVisible() ?
+ SV_BUTTON_CHECKED : SV_BUTTON_UNCHECKED );
+ }
+ }
+}
+
+void SvxToolbarEntriesListBox::CheckButtonHdl()
+{
+ ChangeVisibility( GetHdlEntry() );
+}
+
+void SvxToolbarEntriesListBox::KeyInput( const KeyEvent& rKeyEvent )
+{
+ // space key will change visibility of toolbar items
+ if ( rKeyEvent.GetKeyCode() == KEY_SPACE )
+ {
+ ChangeVisibility( GetCurEntry() );
+ }
+ else
+ {
+ // pass on to superclass
+ SvxMenuEntriesListBox::KeyInput( rKeyEvent );
+ }
+}
+
+BOOL SvxToolbarEntriesListBox::NotifyMoving(
+ SvLBoxEntry* pTarget, SvLBoxEntry* pSource,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos)
+{
+ bool result = SvxMenuEntriesListBox::NotifyMoving(
+ pTarget, pSource, rpNewParent, rNewChildPos );
+
+ if ( result == TRUE )
+ {
+ // Instant Apply changes to UI
+ SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
+ if ( pToolbar != NULL )
+ {
+ ToolbarSaveInData* pSaveInData =
+ ( ToolbarSaveInData*) pPage->GetSaveInData();
+ pSaveInData->ApplyToolbar( pToolbar );
+ }
+ }
+
+ return result;
+}
+
+BOOL SvxToolbarEntriesListBox::NotifyCopying(
+ SvLBoxEntry* pTarget,
+ SvLBoxEntry* pSource,
+ SvLBoxEntry*& rpNewParent,
+ ULONG& rNewChildPos)
+{
+ (void)pSource;
+ (void)rpNewParent;
+ (void)rNewChildPos;
+
+ if ( !m_bIsInternalDrag )
+ {
+ // if the target is NULL then add function to the start of the list
+ ((SvxToolbarConfigPage*)pPage)->AddFunction( pTarget, pTarget == NULL );
+
+ // Instant Apply changes to UI
+ SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection();
+ if ( pToolbar != NULL )
+ {
+ ToolbarSaveInData* pSaveInData =
+ ( ToolbarSaveInData*) pPage->GetSaveInData();
+ pSaveInData->ApplyToolbar( pToolbar );
+ }
+
+ // AddFunction already adds the listbox entry so return FALSE
+ // to stop another listbox entry being added
+ return FALSE;
+ }
+
+ // Copying is only allowed from external controls, not within the listbox
+ return FALSE;
+}
+
+SvxNewToolbarDialog::SvxNewToolbarDialog(
+ Window* pWindow, const String& rName )
+ :
+ ModalDialog ( pWindow, CUI_RES( MD_NEW_TOOLBAR ) ),
+ aFtDescription ( this, CUI_RES( FT_NAME ) ),
+ aEdtName ( this, CUI_RES( EDT_STRING ) ),
+ aSaveInText ( this, CUI_RES( TXT_SAVEIN ) ),
+ aBtnOK ( this, CUI_RES( BTN_OK ) ),
+ aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
+ aBtnHelp ( this, CUI_RES( BTN_HELP ) ),
+ aSaveInListBox ( this, CUI_RES( LB_SAVEIN ) )
+{
+ FreeResource();
+
+ aEdtName.SetText( rName );
+ aEdtName.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
+ ModifyHdl(&aEdtName);
+ aEdtName.SetModifyHdl(LINK(this, SvxNewToolbarDialog, ModifyHdl));
+}
+
+IMPL_LINK(SvxNewToolbarDialog, ModifyHdl, Edit*, pEdit)
+{
+ (void)pEdit;
+
+ if(aCheckNameHdl.IsSet())
+ aBtnOK.Enable(aCheckNameHdl.Call(this) > 0);
+
+ return 0;
+}
+
+/*******************************************************************************
+*
+* The SvxIconSelectorDialog class
+*
+*******************************************************************************/
+SvxIconSelectorDialog::SvxIconSelectorDialog( Window *pWindow,
+ const uno::Reference< css::ui::XImageManager >& rXImageManager,
+ const uno::Reference< css::ui::XImageManager >& rXParentImageManager )
+ :
+ ModalDialog ( pWindow, CUI_RES( MD_ICONSELECTOR ) ),
+ aFtDescription ( this, CUI_RES( FT_SYMBOLS ) ),
+ aTbSymbol ( this, CUI_RES( TB_SYMBOLS ) ),
+ aFtNote ( this, CUI_RES( FT_NOTE ) ),
+ aBtnOK ( this, CUI_RES( BTN_OK ) ),
+ aBtnCancel ( this, CUI_RES( BTN_CANCEL ) ),
+ aBtnHelp ( this, CUI_RES( BTN_HELP ) ),
+ aBtnImport ( this, CUI_RES( BTN_IMPORT ) ),
+ aBtnDelete ( this, CUI_RES( BTN_DELETE ) ),
+ aFlSeparator ( this, CUI_RES( FL_SEPARATOR ) ),
+ m_nNextId ( 0 ),
+ m_xImageManager ( rXImageManager ),
+ m_xParentImageManager( rXParentImageManager )
+{
+ FreeResource();
+
+ typedef ::std::hash_map< ::rtl::OUString,
+ bool,
+ ::rtl::OUStringHash,
+ ::std::equal_to< ::rtl::OUString > > ImageInfo;
+
+ aTbSymbol.SetPageScroll( TRUE );
+
+ bool bLargeIcons = GetImageType() & css::ui::ImageType::SIZE_LARGE;
+ m_nExpectedSize = bLargeIcons ? 26 : 16;
+
+ if ( m_nExpectedSize != 16 )
+ {
+ aFtNote.SetText( replaceSixteen( aFtNote.GetText(), m_nExpectedSize ) );
+ }
+
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager =
+ ::comphelper::getProcessServiceFactory();
+
+ if ( xServiceManager.is() )
+ {
+ m_xGraphProvider = uno::Reference< graphic::XGraphicProvider >(
+ xServiceManager->createInstance(
+ ::rtl::OUString::createFromAscii(
+ "com.sun.star.graphic.GraphicProvider" ) ),
+ uno::UNO_QUERY );
+ }
+
+ if ( !m_xGraphProvider.is() )
+ {
+ aBtnImport.Enable( FALSE );
+ }
+
+ uno::Reference< beans::XPropertySet > xPropSet(
+ xServiceManager->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.util.PathSettings" ) ),
+ uno::UNO_QUERY );
+
+ uno::Any aAny = xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserConfig" ) ) );
+
+ ::rtl::OUString aDirectory;
+
+ aAny >>= aDirectory;
+
+ sal_Int32 aCount = aDirectory.getLength();
+
+ if ( aCount > 0 )
+ {
+ sal_Unicode aChar = aDirectory[ aCount-1 ];
+ if ( aChar != '/')
+ {
+ aDirectory += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ }
+ }
+ else
+ {
+ aBtnImport.Enable( FALSE );
+ }
+
+ aDirectory += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "soffice.cfg/import" ) );
+
+ uno::Reference< lang::XSingleServiceFactory > xStorageFactory(
+ xServiceManager->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.embed.FileSystemStorageFactory" )),
+ uno::UNO_QUERY );
+
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[ 0 ] <<= aDirectory;
+ aArgs[ 1 ] <<= com::sun::star::embed::ElementModes::READWRITE;
+
+ uno::Reference< com::sun::star::embed::XStorage > xStorage(
+ xStorageFactory->createInstanceWithArguments( aArgs ), uno::UNO_QUERY );
+
+ uno::Sequence< uno::Any > aProp( 2 );
+ beans::PropertyValue aPropValue;
+
+ aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserConfigStorage" ) );
+ aPropValue.Value <<= xStorage;
+ aProp[ 0 ] <<= aPropValue;
+
+ aPropValue.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" ) );
+ aPropValue.Value <<= com::sun::star::embed::ElementModes::READWRITE;
+ aProp[ 1 ] <<= aPropValue;
+
+ m_xImportedImageManager = uno::Reference< com::sun::star::ui::XImageManager >(
+ xServiceManager->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii( "com.sun.star.ui.ImageManager" ), aProp ),
+ uno::UNO_QUERY );
+
+ ImageInfo mImageInfo;
+ uno::Sequence< OUString > names;
+ if ( m_xImportedImageManager.is() )
+ {
+ names = m_xImportedImageManager->getAllImageNames( GetImageType() );
+ for ( sal_Int32 n = 0; n < names.getLength(); n++ )
+ mImageInfo.insert( ImageInfo::value_type( names[n], false ));
+ }
+ USHORT nId = 1;
+ ImageInfo::const_iterator pConstIter = mImageInfo.begin();
+ uno::Sequence< OUString > name( 1 );
+ while ( pConstIter != mImageInfo.end() )
+ {
+ name[ 0 ] = pConstIter->first;
+ uno::Sequence< uno::Reference< graphic::XGraphic> > graphics = m_xImportedImageManager->getImages( GetImageType(), name );
+ if ( graphics.getLength() > 0 )
+ {
+ Image img = Image( graphics[ 0 ] );
+ aTbSymbol.InsertItem( nId, img, pConstIter->first );
+
+ graphics[ 0 ]->acquire();
+
+ aTbSymbol.SetItemData(
+ nId, static_cast< void * > ( graphics[ 0 ].get() ) );
+
+ ++nId;
+ }
+ ++pConstIter;
+ }
+
+ ImageInfo aImageInfo;
+
+ if ( m_xParentImageManager.is() )
+ {
+ names = m_xParentImageManager->getAllImageNames( GetImageType() );
+ for ( sal_Int32 n = 0; n < names.getLength(); n++ )
+ aImageInfo.insert( ImageInfo::value_type( names[n], false ));
+ }
+
+ names = m_xImageManager->getAllImageNames( GetImageType() );
+ for ( sal_Int32 n = 0; n < names.getLength(); n++ )
+ {
+ ImageInfo::iterator pIter = aImageInfo.find( names[n] );
+ if ( pIter != aImageInfo.end() )
+ pIter->second = true;
+ else
+ aImageInfo.insert( ImageInfo::value_type( names[n], true ));
+ }
+
+ // large growth factor, expecting many entries
+ pConstIter = aImageInfo.begin();
+ while ( pConstIter != aImageInfo.end() )
+ {
+ name[ 0 ] = pConstIter->first;
+
+ uno::Sequence< uno::Reference< graphic::XGraphic> > graphics;
+ try
+ {
+ if ( pConstIter->second )
+ graphics = m_xImageManager->getImages( GetImageType(), name );
+ else
+ graphics = m_xParentImageManager->getImages( GetImageType(), name );
+ }
+ catch ( uno::Exception& )
+ {
+ // can't get sequence for this name so it will not be
+ // added to the list
+ }
+
+ if ( graphics.getLength() > 0 )
+ {
+ Image img = Image( graphics[ 0 ] );
+ aTbSymbol.InsertItem( nId, img, pConstIter->first );
+
+ uno::Reference< graphic::XGraphic > xGraphic = graphics[ 0 ];
+
+ if ( xGraphic.is() )
+ xGraphic->acquire();
+
+ aTbSymbol.SetItemData(
+ nId, static_cast< void * > ( xGraphic.get() ) );
+
+ ++nId;
+ }
+
+ ++pConstIter;
+ }
+
+ aBtnDelete.Enable( FALSE );
+ aTbSymbol.SetSelectHdl( LINK(this, SvxIconSelectorDialog, SelectHdl) );
+ aBtnImport.SetClickHdl( LINK(this, SvxIconSelectorDialog, ImportHdl) );
+ aBtnDelete.SetClickHdl( LINK(this, SvxIconSelectorDialog, DeleteHdl) );
+
+ m_nNextId = aTbSymbol.GetItemCount()+1;
+}
+
+SvxIconSelectorDialog::~SvxIconSelectorDialog()
+{
+ USHORT nCount = aTbSymbol.GetItemCount();
+
+ for (USHORT n = 0; n < nCount; n++ )
+ {
+ USHORT nId = aTbSymbol.GetItemId(n);
+
+ uno::XInterface* xi = static_cast< uno::XInterface* >(
+ aTbSymbol.GetItemData( nId ) );
+
+ if ( xi != NULL )
+ {
+ xi->release();
+ }
+ }
+}
+
+uno::Reference< graphic::XGraphic> SvxIconSelectorDialog::GetSelectedIcon()
+{
+ uno::Reference< graphic::XGraphic > result;
+
+ USHORT nId;
+ for ( USHORT n = 0; n < aTbSymbol.GetItemCount(); n++ )
+ {
+ nId = aTbSymbol.GetItemId( n );
+ if ( aTbSymbol.IsItemChecked( nId ) )
+ {
+ result = uno::Reference< graphic::XGraphic >(
+ reinterpret_cast< graphic::XGraphic* >(
+ aTbSymbol.GetItemData( nId ) ) );
+ }
+ }
+
+ return result;
+}
+
+IMPL_LINK( SvxIconSelectorDialog, SelectHdl, ToolBox *, pToolBox )
+{
+ (void)pToolBox;
+
+ USHORT nCount = aTbSymbol.GetItemCount();
+
+ for (USHORT n = 0; n < nCount; n++ )
+ {
+ USHORT nId = aTbSymbol.GetItemId( n );
+
+ if ( aTbSymbol.IsItemChecked( nId ) )
+ {
+ aTbSymbol.CheckItem( nId, FALSE );
+ }
+ }
+
+ USHORT nId = aTbSymbol.GetCurItemId();
+ aTbSymbol.CheckItem( nId );
+
+ ::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId );
+ if ( m_xImportedImageManager->hasImage( GetImageType(), aSelImageText ) )
+ {
+ aBtnDelete.Enable( TRUE );
+ }
+ else
+ {
+ aBtnDelete.Enable( FALSE );
+ }
+
+ return 0;
+}
+
+IMPL_LINK( SvxIconSelectorDialog, ImportHdl, PushButton *, pButton )
+{
+ (void)pButton;
+
+ sfx2::FileDialogHelper aImportDialog(
+ css::ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW,
+ SFXWB_GRAPHIC | SFXWB_MULTISELECTION );
+
+ // disable the link checkbox in the dialog
+ uno::Reference< css::ui::dialogs::XFilePickerControlAccess >
+ xController( aImportDialog.GetFilePicker(), uno::UNO_QUERY);
+ if ( xController.is() )
+ {
+ xController->enableControl(
+ css::ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK,
+ sal_False);
+ }
+
+ aImportDialog.SetCurrentFilter(
+ String::CreateFromAscii( "PNG - Portable Network Graphic" ) );
+
+ if ( ERRCODE_NONE == aImportDialog.Execute() )
+ {
+ uno::Sequence< OUString > paths = aImportDialog.GetMPath();
+ ImportGraphics ( paths );
+ }
+
+ return 0;
+}
+
+IMPL_LINK( SvxIconSelectorDialog, DeleteHdl, PushButton *, pButton )
+{
+ (void)pButton;
+
+ OUString message = String( CUI_RES( RID_SVXSTR_DELETE_ICON_CONFIRM ) );
+ bool ret = WarningBox( this, WinBits(WB_OK_CANCEL), message ).Execute();
+
+ if ( ret == RET_OK )
+ {
+ USHORT nCount = aTbSymbol.GetItemCount();
+
+ for (USHORT n = 0; n < nCount; n++ )
+ {
+ USHORT nId = aTbSymbol.GetItemId( n );
+
+ if ( aTbSymbol.IsItemChecked( nId ) )
+ {
+ ::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId );
+ uno::Sequence< OUString > URLs(1);
+ URLs[0] = aSelImageText;
+ aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) );
+ m_xImportedImageManager->removeImages( GetImageType(), URLs );
+ uno::Reference< css::ui::XUIConfigurationPersistence >
+ xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY );
+ if ( xConfigPersistence.is() && xConfigPersistence->isModified() )
+ {
+ xConfigPersistence->store();
+ }
+ break;
+ }
+ }
+ }
+ return 0;
+}
+
+bool SvxIconSelectorDialog::ReplaceGraphicItem(
+ const ::rtl::OUString& aURL )
+{
+ uno::Sequence< OUString > URLs(1);
+ uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
+ uno::Reference< css::ui::XUIConfigurationPersistence >
+ xConfigPer( m_xImportedImageManager, uno::UNO_QUERY );
+
+ uno::Reference< graphic::XGraphic > xGraphic;
+ uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
+ aMediaProps[0].Name = ::rtl::OUString::createFromAscii("URL");
+ aMediaProps[0].Value <<= aURL;
+
+ com::sun::star::awt::Size aSize;
+ bool bOK = FALSE;
+ try
+ {
+ xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
+
+ uno::Reference< beans::XPropertySet > props =
+ m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
+ uno::Any a = props->getPropertyValue(
+ OUString::createFromAscii("SizePixel") );
+ a >>= aSize;
+ if (0 == aSize.Width || 0 == aSize.Height)
+ return FALSE;
+ else
+ bOK = TRUE;
+ }
+ catch ( uno::Exception& )
+ {
+ return false;
+ }
+
+ bool bResult( false );
+ USHORT nCount = aTbSymbol.GetItemCount();
+ for (USHORT n = 0; n < nCount; n++ )
+ {
+ USHORT nId = aTbSymbol.GetItemId( n );
+
+ if ( OUString( aTbSymbol.GetItemText( nId ) ) == aURL )
+ {
+ try
+ {
+ // replace/insert image with provided URL
+ aTbSymbol.RemoveItem( aTbSymbol.GetItemPos( nId ) );
+ aMediaProps[0].Value <<= aURL;
+
+ Image aImage( xGraphic );
+ if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
+ {
+ BitmapEx aBitmap = aImage.GetBitmapEx();
+ BitmapEx aBitmapex = AutoScaleBitmap(aBitmap, m_nExpectedSize);
+ aImage = Image( aBitmapex);
+ }
+ aTbSymbol.InsertItem( nId,aImage, aURL, 0, 0 ); //modify
+
+ xGraphic = aImage.GetXGraphic();
+
+ URLs[0] = aURL;
+ aImportGraph[ 0 ] = xGraphic;
+ m_xImportedImageManager->replaceImages( GetImageType(), URLs, aImportGraph );
+ xConfigPer->store();
+
+ bResult = true;
+ break;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ break;
+ }
+ }
+ }
+
+ return bResult;
+}
+
+void SvxIconSelectorDialog::ImportGraphics(
+ const uno::Sequence< OUString >& rPaths )
+{
+ uno::Sequence< OUString > rejected( rPaths.getLength() );
+ sal_Int32 rejectedCount = 0;
+
+ USHORT ret = 0;
+ sal_Int32 aIndex;
+ OUString aIconName;
+ uno::Sequence< OUString > URLs(1);
+ uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
+ uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
+ aMediaProps[0].Name = ::rtl::OUString::createFromAscii("URL");
+ uno::Reference< css::ui::XUIConfigurationPersistence >
+ xConfigPer( m_xImportedImageManager, uno::UNO_QUERY );
+
+ if ( rPaths.getLength() == 1 )
+ {
+ if ( m_xImportedImageManager->hasImage( GetImageType(), rPaths[0] ) )
+ {
+ aIndex = rPaths[0].lastIndexOf( '/' );
+ aIconName = rPaths[0].copy( aIndex+1 );
+ ret = SvxIconReplacementDialog( this, aIconName ).ShowDialog();
+ if ( ret == 2 )
+ {
+ ReplaceGraphicItem( rPaths[0] );
+ }
+ }
+ else
+ {
+ if ( ImportGraphic( rPaths[0] ) == FALSE )
+ {
+ rejected[0] = rPaths[0];
+ rejectedCount = 1;
+ }
+ }
+ }
+ else
+ {
+ ::rtl::OUString aSourcePath( rPaths[0] );
+ if ( rPaths[0].lastIndexOf( '/' ) != rPaths[0].getLength() -1 )
+ aSourcePath = rPaths[0] + ::rtl::OUString::createFromAscii( "/" );
+
+ for ( sal_Int32 i = 1; i < rPaths.getLength(); i++ )
+ {
+ ::rtl::OUString aPath = aSourcePath + rPaths[i];
+ if ( m_xImportedImageManager->hasImage( GetImageType(), aPath ) )
+ {
+ aIndex = rPaths[i].lastIndexOf( '/' );
+ aIconName = rPaths[i].copy( aIndex+1 );
+ ret = SvxIconReplacementDialog( this, aIconName, TRUE ).ShowDialog();
+ if ( ret == 2 )
+ {
+ ReplaceGraphicItem( aPath );
+ }
+ else if ( ret == 5 )
+ {
+ for ( sal_Int32 k = i; k < rPaths.getLength(); k++ )
+ {
+ aPath = aSourcePath + rPaths[k];
+ bool bHasReplaced = ReplaceGraphicItem( aPath );
+
+ if ( !bHasReplaced )
+ {
+ bool result = ImportGraphic( aPath );
+ if ( result == FALSE )
+ {
+ rejected[ rejectedCount ] = rPaths[i];
+ rejectedCount++;
+ }
+ }
+ }
+ break;
+ }
+ }
+ else
+ {
+ bool result = ImportGraphic( aSourcePath + rPaths[i] );
+ if ( result == FALSE )
+ {
+ rejected[ rejectedCount ] = rPaths[i];
+ rejectedCount++;
+ }
+ }
+ }
+ }
+
+ if ( rejectedCount != 0 )
+ {
+ OUString message =OUString::createFromAscii("");
+ OUString newLine = OUString::createFromAscii("\n");
+ rtl::OUString fPath = OUString::createFromAscii("");
+ if (rejectedCount > 1)
+ fPath = rPaths[0].copy(8) + ::rtl::OUString::createFromAscii( "/" );
+ for ( sal_Int32 i = 0; i < rejectedCount; i++ )
+ {
+ message += fPath + rejected[i];
+ message += newLine;
+ }
+
+ SvxIconChangeDialog aDialog(this, message);
+ aDialog.Execute();
+ }
+}
+
+bool SvxIconSelectorDialog::ImportGraphic( const OUString& aURL )
+{
+ bool result = FALSE;
+
+ USHORT nId = m_nNextId;
+ ++m_nNextId;
+
+ uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
+ aMediaProps[0].Name = ::rtl::OUString::createFromAscii("URL");
+
+ uno::Reference< graphic::XGraphic > xGraphic;
+ com::sun::star::awt::Size aSize;
+ bool bOK = TRUE;
+ aMediaProps[0].Value <<= aURL;
+ try
+ {
+ uno::Reference< beans::XPropertySet > props =
+ m_xGraphProvider->queryGraphicDescriptor( aMediaProps );
+
+ uno::Any a = props->getPropertyValue(
+ OUString::createFromAscii("SizePixel") );
+
+ xGraphic = m_xGraphProvider->queryGraphic( aMediaProps );
+ if ( xGraphic.is() )
+ {
+ a >>= aSize;
+ if ( 0 == aSize.Width || 0 == aSize.Height )
+ bOK = FALSE;
+
+ Image aImage( xGraphic );
+
+ if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) )
+ {
+ BitmapEx aBitmap = aImage.GetBitmapEx();
+ BitmapEx aBitmapex = AutoScaleBitmap(aBitmap, m_nExpectedSize);
+ aImage = Image( aBitmapex);
+ }
+ if ( bOK && !!aImage )
+ {
+ aTbSymbol.InsertItem( nId, aImage, aURL, 0, 0 );
+
+ xGraphic = aImage.GetXGraphic();
+ xGraphic->acquire();
+
+ aTbSymbol.SetItemData(
+ nId, static_cast< void * > ( xGraphic.get() ) );
+ uno::Sequence< OUString > aImportURL( 1 );
+ aImportURL[ 0 ] = aURL;
+ uno::Sequence< uno::Reference<graphic::XGraphic > > aImportGraph( 1 );
+ aImportGraph[ 0 ] = xGraphic;
+ m_xImportedImageManager->insertImages( GetImageType(), aImportURL, aImportGraph );
+ uno::Reference< css::ui::XUIConfigurationPersistence >
+ xConfigPersistence( m_xImportedImageManager, uno::UNO_QUERY );
+
+ if ( xConfigPersistence.is() && xConfigPersistence->isModified() )
+ {
+ xConfigPersistence->store();
+ }
+
+ result = TRUE;
+ }
+ else
+ {
+ OSL_TRACE("could not create Image from XGraphic");
+ }
+ }
+ else
+ {
+ OSL_TRACE("could not get query XGraphic");
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ OSL_TRACE("Caught exception importing XGraphic: %s", PRTSTR(e.Message));
+ }
+ return result;
+}
+
+/*******************************************************************************
+*
+* The SvxIconReplacementDialog class
+*
+*******************************************************************************/
+SvxIconReplacementDialog :: SvxIconReplacementDialog(
+ Window *pWindow, const rtl::OUString& aMessage, bool /*bYestoAll*/ )
+ :
+MessBox( pWindow, WB_DEF_YES, String( CUI_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ), String( CUI_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) )
+
+{
+ SetImage( WarningBox::GetStandardImage() );
+ SetMessText( ReplaceIconName( aMessage ) );
+ RemoveButton( 1 );
+ AddButton( BUTTON_YES, 2, 0 );
+ AddButton( String( CUI_RES( RID_SVXSTR_YESTOALL ) ), 5, 0 );
+ AddButton( BUTTON_NO, 3, 0 );
+ AddButton( BUTTON_CANCEL, 4, 0 );
+}
+
+SvxIconReplacementDialog :: SvxIconReplacementDialog(
+ Window *pWindow, const rtl::OUString& aMessage )
+ :
+MessBox( pWindow, WB_YES_NO_CANCEL, String( CUI_RES( RID_SVXSTR_REPLACE_ICON_CONFIRM ) ), String( CUI_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) ) )
+{
+ SetImage( WarningBox::GetStandardImage() );
+ SetMessText( ReplaceIconName( aMessage ));
+}
+
+rtl::OUString SvxIconReplacementDialog :: ReplaceIconName( const OUString& rMessage )
+{
+ rtl::OUString name;
+ rtl::OUString message = String( CUI_RES( RID_SVXSTR_REPLACE_ICON_WARNING ) );
+ rtl::OUString placeholder = OUString::createFromAscii( "%ICONNAME" );
+ sal_Int32 pos = message.indexOf( placeholder );
+ if ( pos != -1 )
+ {
+ name = message.replaceAt(
+ pos, placeholder.getLength(), rMessage );
+ }
+ return name;
+}
+
+USHORT SvxIconReplacementDialog :: ShowDialog()
+{
+ this->Execute();
+ return ( this->GetCurButtonId() );
+}
+/*******************************************************************************
+*
+* The SvxIconChangeDialog class added for issue83555
+*
+*******************************************************************************/
+SvxIconChangeDialog::SvxIconChangeDialog(
+ Window *pWindow, const rtl::OUString& aMessage)
+ :
+ ModalDialog ( pWindow, CUI_RES( MD_ICONCHANGE ) ),
+ aFImageInfo (this, CUI_RES( FI_INFO ) ),
+ aBtnOK (this, CUI_RES(MD_BTN_OK)),
+ aDescriptionLabel (this, CUI_RES(FTCHGE_DESCRIPTION)),
+ aLineEditDescription (this, CUI_RES(EDT_ADDR))
+{
+ FreeResource();
+ aFImageInfo.SetImage(InfoBox::GetStandardImage());
+ aLineEditDescription.SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
+ aLineEditDescription.SetAutoScroll( TRUE );
+ aLineEditDescription.EnableCursor( FALSE );
+ aLineEditDescription.SetText(aMessage);
+}
+
+BitmapEx SvxIconSelectorDialog::AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize)
+{
+ Point aEmptyPoint(0,0);
+ sal_Int32 imgNewWidth = 0;
+ sal_Int32 imgNewHeight = 0;
+ double imgposX = 0;
+ double imgposY = 0;
+ BitmapEx aRet = aBitmap;
+ double imgOldWidth = aRet.GetSizePixel().Width();
+ double imgOldHeight =aRet.GetSizePixel().Height();
+
+ Size aScaledSize;
+ if (imgOldWidth >= aStandardSize || imgOldHeight >= aStandardSize)
+ {
+ if (imgOldWidth >= imgOldHeight)
+ {
+ imgNewWidth = aStandardSize;
+ imgNewHeight = sal_Int32(imgOldHeight / (imgOldWidth / aStandardSize) + 0.5);
+ imgposX = 0;
+ imgposY = (aStandardSize - (imgOldHeight / (imgOldWidth / aStandardSize) + 0.5)) / 2 + 0.5;
+ }
+ else
+ {
+ imgNewHeight = aStandardSize;
+ imgNewWidth = sal_Int32(imgOldWidth / (imgOldHeight / aStandardSize) + 0.5);
+ imgposY = 0;
+ imgposX = (aStandardSize - (imgOldWidth / (imgOldHeight / aStandardSize) + 0.5)) / 2 + 0.5;
+ }
+
+ aScaledSize = Size( imgNewWidth, imgNewHeight );
+ aRet.Scale( aScaledSize, BMP_SCALE_INTERPOLATE );
+ }
+ else
+ {
+ imgposX = (aStandardSize - imgOldWidth) / 2 + 0.5;
+ imgposY = (aStandardSize - imgOldHeight) / 2 + 0.5;
+ }
+
+ Size aBmpSize = aRet.GetSizePixel();
+ Size aStdSize( aStandardSize, aStandardSize );
+ Rectangle aRect(aEmptyPoint, aStdSize );
+
+ VirtualDevice aVirDevice( *Application::GetDefaultDevice(), 0, 1 );
+ aVirDevice.SetOutputSizePixel( aStdSize );
+ aVirDevice.SetFillColor( COL_TRANSPARENT );
+ aVirDevice.SetLineColor( COL_TRANSPARENT );
+
+ //draw a rect into virDevice
+ aVirDevice.DrawRect( aRect );
+ Point aPointPixel( (long)imgposX, (long)imgposY );
+ aVirDevice.DrawBitmapEx( aPointPixel, aRet );
+ aRet = aVirDevice.GetBitmapEx( aEmptyPoint, aStdSize );
+
+ return aRet;
+}
diff --git a/cui/source/customize/cfg.hrc b/cui/source/customize/cfg.hrc
new file mode 100644
index 000000000000..74d7804dce8e
--- /dev/null
+++ b/cui/source/customize/cfg.hrc
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define CFG_OFFSET 300
+
+#define GRP_MENUS (9 + CFG_OFFSET)
+#define FT_MENUS (10 + CFG_OFFSET)
+#define LB_MENUS (11 + CFG_OFFSET)
+#define BTN_NEW (12 + CFG_OFFSET)
+#define BTN_CHANGE (14 + CFG_OFFSET)
+#define GRP_MENU_SEPARATOR (15 + CFG_OFFSET)
+#define GRP_MENU_ENTRIES (16 + CFG_OFFSET)
+#define BOX_ENTRIES (17 + CFG_OFFSET)
+#define BTN_CHANGE_ENTRY (18 + CFG_OFFSET)
+#define BTN_UP (19 + CFG_OFFSET)
+#define BTN_DOWN (20 + CFG_OFFSET)
+#define FT_DESCRIPTION (22 + CFG_OFFSET)
+#define TXT_SAVEIN (23 + CFG_OFFSET)
+#define LB_SAVEIN (24 + CFG_OFFSET)
+#define ED_DESCRIPTION (25 + CFG_OFFSET)
+#define BTN_ADD_COMMANDS (26 + CFG_OFFSET)
+
+#define MODIFY_MENU (40 + CFG_OFFSET)
+#define MODIFY_ENTRY (41 + CFG_OFFSET)
+#define ID_RENAME (42 + CFG_OFFSET)
+#define ID_MOVE (43 + CFG_OFFSET)
+#define ID_DELETE (44 + CFG_OFFSET)
+#define ID_ADD_SUBMENU (45 + CFG_OFFSET)
+#define ID_BEGIN_GROUP (46 + CFG_OFFSET)
+#define ID_DEFAULT_STYLE (47 + CFG_OFFSET)
+#define ID_ICONS_ONLY (48 + CFG_OFFSET)
+#define ID_ICONS_AND_TEXT (49 + CFG_OFFSET)
+#define ID_ICON_ONLY (50 + CFG_OFFSET)
+#define ID_ICON_AND_TEXT (51 + CFG_OFFSET)
+#define ID_TEXT_ONLY (52 + CFG_OFFSET)
+#define ID_CHANGE_SYMBOL (53 + CFG_OFFSET)
+#define ID_RESET_SYMBOL (54 + CFG_OFFSET)
+#define ID_DEFAULT_COMMAND (55 + CFG_OFFSET)
+
+#define MODIFY_TOOLBAR (60 + CFG_OFFSET)
+#define MODIFY_TOOLBAR_CONTENT (61 + CFG_OFFSET)
+
+#define IBX_MNUCFG_ALREADY_INCLUDED (63 + CFG_OFFSET)
+#define QBX_CONFIRM_RESET (64 + CFG_OFFSET)
+#define QBX_CONFIRM_DELETE_MENU (65 + CFG_OFFSET)
+#define QBX_CONFIRM_RESTORE_DEFAULT (66 + CFG_OFFSET)
+#define QBX_CONFIRM_DELETE_TOOLBAR (67 + CFG_OFFSET)
+
+#define MD_MENU_ORGANISER (79 + CFG_OFFSET)
+#define TXT_MENU (80 + CFG_OFFSET)
+#define BOX_MAIN_MENUS (81 + CFG_OFFSET)
+#define BTN_MENU_UP (82 + CFG_OFFSET)
+#define BTN_MENU_DOWN (83 + CFG_OFFSET)
+#define BTN_MENU_ADD (84 + CFG_OFFSET)
+#define BTN_MENU_CLOSE (85 + CFG_OFFSET)
+#define BTN_MENU_HELP (86 + CFG_OFFSET)
+#define TXT_MENU_NAME (87 + CFG_OFFSET)
+#define EDIT_MENU_NAME (88 + CFG_OFFSET)
+
+#define MD_ICONSELECTOR (90 + CFG_OFFSET)
+#define FT_SYMBOLS (91 + CFG_OFFSET)
+#define TB_SYMBOLS (92 + CFG_OFFSET)
+#define FT_NOTE (93 + CFG_OFFSET)
+#define BTN_IMPORT (97 + CFG_OFFSET)
+#define IMAGE_BTN_COLOR (98 + CFG_OFFSET)
+
+#define MD_NEW_TOOLBAR (101 + CFG_OFFSET)
+#define EDT_STRING (102 + CFG_OFFSET)
+#define BTN_OK (103 + CFG_OFFSET)
+#define BTN_CANCEL (104 + CFG_OFFSET)
+#define BTN_HELP (105 + CFG_OFFSET)
+#define FT_NAME (106 + CFG_OFFSET)
+
+#define FL_SEPARATOR (108 + CFG_OFFSET)
+#define BTN_DELETE (109 + CFG_OFFSET)
+//added for issue83555
+#define MD_ICONCHANGE (119 + CFG_OFFSET)
+#define FTCHGE_DESCRIPTION (120 + CFG_OFFSET)
+#define EDT_ADDR (121 + CFG_OFFSET)
+#define MD_BTN_OK (122 + CFG_OFFSET)
+#define FI_INFO (123 + CFG_OFFSET)
diff --git a/cui/source/customize/cfg.src b/cui/source/customize/cfg.src
new file mode 100644
index 000000000000..0b2489557053
--- /dev/null
+++ b/cui/source/customize/cfg.src
@@ -0,0 +1,872 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <cuires.hrc>
+#include "cfg.hrc"
+#include "helpid.hrc"
+
+TabDialog RID_SVXDLG_CUSTOMIZE
+{
+ OutputSize = TRUE ;
+ Text [ de ] = "Anpassen" ;
+ Text [ en-US ] = "Customize" ;
+ Moveable = TRUE ;
+ SvLook = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_MENUS ;
+ Text [ de ] = "Menüs" ;
+ Text [ en-US ] = "Menus" ;
+ PageResID = 300 ;
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_KEYBOARD ;
+ Text [ de ] = "Tastatur" ;
+ Text [ en-US ] = "Keyboard" ;
+ PageResID = 301 ;
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_TOOLBARS ;
+ Text [ de ] = "Symbolleisten" ;
+ Text [ en-US ] = "Toolbars" ;
+ PageResID = 302 ;
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_EVENTS ;
+ Text [ de ] = "Ereignisse" ;
+ Text [ en-US ] = "Events" ;
+ PageResID = 303 ;
+ };
+ };
+ };
+};
+
+#define TEXT_MENU \
+ Text [ de ] = "Menü" ; \
+ Text [ en-US ] = "Menu" ;\
+
+#define TEXT_BEGIN_GROUP \
+ Text [ de ] = "Gruppe beginnen" ; \
+ Text [ en-US ] = "Begin a Group" ;\
+
+#define TEXT_RENAME \
+ Text [ de ] = "Umbenennen..." ; \
+ Text [ en-US ] = "Rename..." ;\
+
+#define TEXT_DELETE \
+ Text [ de ] = "Entfernen..." ; \
+ Text [ en-US ] = "Delete..." ;\
+
+#define TEXT_DELETE_NODOTS \
+ Text [ de ] = "Entfernen" ; \
+ Text [ en-US ] = "Delete" ;\
+
+#define TEXT_MOVE \
+ Text [ de ] = "Verschieben..." ; \
+ Text [ en-US ] = "Move..." ;\
+
+#define TEXT_DEFAULT_STYLE \
+ Text [ de ] = "Standard Einstellungen herstellen" ; \
+ Text [ en-US ] = "Restore Default Settings" ;\
+
+#define TEXT_DEFAULT_COMMAND \
+ Text [ de ] = "Standardbefehl ~wiederherstellen" ; \
+ Text [ en-US ] = "Restore Default Command" ;\
+
+#define TEXT_TEXT_ONLY \
+ Text [ de ] = "Nur Text" ; \
+ Text [ en-US ] = "Text only" ;\
+
+#define TEXT_TOOLBAR_NAME \
+ Text [ de ] = "Name der Symbolleiste" ; \
+ Text [ en-US ] = "Toolbar Name" ;\
+
+#define TEXT_SAVE_IN \
+ Text [ de ] = "Speichern in" ; \
+ Text [ en-US ] = "Save In" ;\
+
+TabPage RID_SVXPAGE_MENUS
+{
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 273 , 258 ) ;
+ HelpId = HID_SVX_CONFIG_MENU ;
+ FixedLine GRP_MENUS
+ {
+ Pos = MAP_APPFONT ( 6 , 11 ) ;
+ Size = MAP_APPFONT ( 261 , 8 ) ;
+ Text [ de ] = "%PRODUCTNAME %MODULENAME Menüs" ;
+ Text [ en-US ] = "%PRODUCTNAME %MODULENAME Menus" ;
+ };
+ FixedText FT_MENUS
+ {
+ Pos = MAP_APPFONT ( 9 , 24 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ TEXT_MENU
+ };
+ ListBox LB_MENUS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 64 , 22 ) ;
+ Size = MAP_APPFONT ( 108 , 108 ) ;
+ DropDown = TRUE ;
+ };
+ PushButton BTN_NEW
+ {
+ Pos = MAP_APPFONT ( 192 , 22 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ de ] = "Neu..." ;
+ Text [ en-US ] = "New..." ;
+ };
+ MenuButton BTN_CHANGE
+ {
+ Pos = MAP_APPFONT ( 192 , 39 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ TEXT_MENU
+ };
+ FixedLine GRP_MENU_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 6 , 56 ) ;
+ Size = MAP_APPFONT ( 261 , 8 ) ;
+ Text [ de ] = "Menüinhalt" ;
+ Text [ en-US ] = "Menu Content" ;
+ };
+ FixedText GRP_MENU_ENTRIES
+ {
+ Pos = MAP_APPFONT ( 9 , 67 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Group = TRUE ;
+ Text [ de ] = "Einträge" ;
+ Text [ en-US ] = "Entries" ;
+ };
+ Control BOX_ENTRIES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 64 , 67 ) ;
+ Size = MAP_APPFONT ( 108 , 115 ) ;
+ TabStop = TRUE ;
+ HelpId = HID_SVX_CONFIG_MENU_CONTENTS ;
+ };
+ PushButton BTN_ADD_COMMANDS
+ {
+ Pos = MAP_APPFONT ( 192 , 67 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ de ] = "Hinzufügen..." ;
+ Text [ en-US ] = "Add..." ;
+ };
+ MenuButton BTN_CHANGE_ENTRY
+ {
+ Pos = MAP_APPFONT ( 192 , 84 ) ;
+ Size = MAP_APPFONT ( 75 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ de ] = "Ändern" ;
+ Text [ en-US ] = "Modify" ;
+ };
+ ImageButton BTN_UP
+ {
+ Pos = MAP_APPFONT ( 175 , 102 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ Symbol = IMAGEBUTTON_ARROW_UP ;
+ Disable = TRUE ;
+ };
+ ImageButton BTN_DOWN
+ {
+ Pos = MAP_APPFONT ( 175 , 119 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ Symbol = IMAGEBUTTON_ARROW_DOWN ;
+ Disable = TRUE ;
+ };
+ FixedText TXT_SAVEIN
+ {
+ Pos = MAP_APPFONT ( 9 , 190 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Group = TRUE ;
+ TEXT_SAVE_IN
+ };
+ ListBox LB_SAVEIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 64 , 188 ) ;
+ Size = MAP_APPFONT ( 108 , 53 ) ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 205 ) ;
+ Size = MAP_APPFONT ( 261 , 8 ) ;
+ Text [ de ] = "Beschreibung" ;
+ Text [ en-US ] = "Description" ;
+ };
+ MultiLineEdit ED_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 216 ) ;
+ Size = MAP_APPFONT ( 261 , 36 ) ;
+ Border = TRUE;
+ VScroll = TRUE;
+ IgnoreTab = TRUE;
+ ReadOnly = TRUE;
+ };
+};
+
+Menu MODIFY_MENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_MOVE ;
+ TEXT_MOVE
+ };
+ MenuItem
+ {
+ Identifier = ID_RENAME ;
+ TEXT_RENAME
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_DELETE ;
+ TEXT_DELETE
+ };
+ };
+};
+
+Menu MODIFY_ENTRY
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_ADD_SUBMENU ;
+ Text [ de ] = "Untermenü einfügen..." ;
+ Text [ en-US ] = "Add Submenu..." ;
+ };
+ MenuItem
+ {
+ Identifier = ID_BEGIN_GROUP ;
+ TEXT_BEGIN_GROUP
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_RENAME ;
+ TEXT_RENAME
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_DELETE ;
+ TEXT_DELETE_NODOTS
+ };
+ };
+};
+
+Menu MODIFY_TOOLBAR
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_RENAME ;
+ TEXT_RENAME
+ };
+ MenuItem
+ {
+ Identifier = ID_DELETE ;
+ TEXT_DELETE_NODOTS
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_DEFAULT_STYLE ;
+ TEXT_DEFAULT_STYLE
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_ICONS_ONLY ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ de ] = "Nur Symbole" ;
+ Text [ en-US ] = "Icons Only" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_TEXT_ONLY ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ TEXT_TEXT_ONLY
+ };
+ MenuItem
+ {
+ Identifier = ID_ICONS_AND_TEXT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ de ] = "Symbole & Text" ;
+ Text [ en-US ] = "Icons & Text" ;
+ };
+ };
+};
+
+Menu MODIFY_TOOLBAR_CONTENT
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_RENAME ;
+ TEXT_RENAME
+ };
+ MenuItem
+ {
+ Identifier = ID_DELETE ;
+ TEXT_DELETE_NODOTS
+ };
+ MenuItem
+ {
+ Identifier = ID_DEFAULT_COMMAND ;
+ TEXT_DEFAULT_COMMAND
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_BEGIN_GROUP ;
+ TEXT_BEGIN_GROUP
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ /*
+ MenuItem
+ {
+ Identifier = ID_ICON_ONLY ;
+ Text [ de ] = "Nur Symbol" ;
+ Text [ en-US ] = "Icon Only" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_TEXT_ONLY ;
+ Text [ de ] = "Nur Text" ;
+ Text [ en-US ] = "Text Only" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = ID_ICON_AND_TEXT ;
+ Text [ de ] = "Symbol & Text" ;
+ Text [ en-US ] = "Icon & Text" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ */
+ MenuItem
+ {
+ Identifier = ID_CHANGE_SYMBOL ;
+ Text [ de ] = "Symbol austauschen..." ;
+ Text [ en-US ] = "Change Icon..." ;
+ };
+ MenuItem
+ {
+ Identifier = ID_RESET_SYMBOL ;
+ Text [ de ] = "Symbol zurücksetzen" ;
+ Text [ en-US ] = "Reset Icon" ;
+ };
+ };
+};
+
+/* %n will be replaced at runtime by a number starting with 1 and increasing as necessary */
+String RID_SVXSTR_NEW_MENU
+{
+ Text [ de ] = "Neues Menü %n";
+ Text [ en-US ] = "New Menu %n";
+};
+
+/* %n will be replaced at runtime by a number starting with 1 and increasing as necessary */
+String RID_SVXSTR_NEW_TOOLBAR
+{
+ Text [ de ] = "Neue Symbolleiste %n";
+ Text [ en-US ] = "New Toolbar %n";
+};
+
+String RID_SVXSTR_MOVE_MENU
+{
+ Text [ de ] = "Menü verschieben";
+ Text [ en-US ] = "Move Menu";
+};
+
+String RID_SVXSTR_ADD_SUBMENU
+{
+ Text [ de ] = "Untermenü hinzufügen";
+ Text [ en-US ] = "Add Submenu";
+};
+
+String RID_SVXSTR_SUBMENU_NAME
+{
+ Text [ de ] = "Name des Untermenüs";
+ Text [ en-US ] = "Submenu name";
+};
+
+String RID_SVXSTR_MENU_ADDCOMMANDS_DESCRIPTION
+{
+ Text [ de ] = "Um Befehle einem menu hinzuzufügen, wählen Sie zuerst eine Kategorie und dann den Befehl. Alternativ ziehen Sie den Befehl in die Befehlsliste auf der Registerseite 'Menüs' im Dialog 'Anpassen'.";
+ Text [ en-US ] = "To add a command to a menu, select the category and then the command. You can also drag the command to the Commands list of the Menus tab page in the Customize dialog.";
+};
+
+ModalDialog MD_MENU_ORGANISER
+{
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 172 , 154 ) ;
+ Text [ de ] = "Neues Menü" ;
+ Text [ en-US ] = "New Menu" ;
+ SvLook = TRUE ;
+ Moveable = TRUE ;
+ HelpId = HID_SVX_CONFIG_MENU_ORGANIZER;
+ FixedText TXT_MENU_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Group = TRUE ;
+ Left = TRUE ;
+ Text [ de ] = "Menüname" ;
+ Text [ en-US ] = "Menu name" ;
+ };
+ Edit EDIT_MENU_NAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 93 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText TXT_MENU
+ {
+ Pos = MAP_APPFONT ( 6 , 37 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Group = TRUE ;
+ Left = TRUE ;
+ Text [ de ] = "Menüposition" ;
+ Text [ en-US ] = "Menu position" ;
+ };
+ Control BOX_MAIN_MENUS
+ {
+ HelpId = HID_SVX_CONFIG_MENU_LISTBOX ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 48 ) ;
+ Size = MAP_APPFONT ( 93 , 100 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton BTN_MENU_UP
+ {
+ Pos = MAP_APPFONT ( 102 , 80 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ Symbol = IMAGEBUTTON_ARROW_UP ;
+ };
+ ImageButton BTN_MENU_DOWN
+ {
+ Pos = MAP_APPFONT ( 102 , 97 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ Symbol = IMAGEBUTTON_ARROW_DOWN ;
+ };
+ OKButton BTN_MENU_ADD
+ {
+ DefButton = TRUE;
+ Pos = MAP_APPFONT ( 119 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ CancelButton BTN_MENU_CLOSE
+ {
+ Pos = MAP_APPFONT ( 119 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_MENU_HELP
+ {
+ Pos = MAP_APPFONT ( 119 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+// MD_NEW_TOOLBAR -------------------------------------------------
+ModalDialog MD_NEW_TOOLBAR
+{
+ OutputSize = TRUE ;
+ SvLook = TRUE ;
+ Size = MAP_APPFONT ( 165 , 63 ) ;
+ Text [ de ] = "Name" ;
+ Text [ en-US ] = "Name" ;
+ Moveable = TRUE ;
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 98 , 8 ) ;
+ TEXT_TOOLBAR_NAME
+ WordBreak = TRUE ;
+ };
+ Edit EDT_STRING
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 97 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText TXT_SAVEIN
+ {
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( 98 , 8 ) ;
+ Group = TRUE ;
+ TEXT_SAVE_IN
+ };
+ ListBox LB_SAVEIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 43 ) ;
+ Size = MAP_APPFONT ( 97 , 53 ) ;
+ DropDown = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 109 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 109 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 109 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+#ifndef IMAGE_STDBTN_COLOR
+#define IMAGE_STDBTN_COLOR Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; }
+#endif
+
+ModalDialog MD_ICONSELECTOR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 240 , 152 ) ;
+ Text [ de ] = "Symbole Austauschen" ;
+ Text [ en-US ] = "Change Icon" ;
+ Moveable = TRUE ;
+ HelpId = HID_SVX_CONFIG_ICON_SELECTOR;
+ FixedText FT_SYMBOLS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ Text [ de ] = "Symbole" ;
+ Text [ en-US ] = "Icons" ;
+ };
+ ToolBox TB_SYMBOLS
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 160 , 80 ) ;
+ Scroll = TRUE ;
+ LineSpacing = TRUE ;
+ Customize = FALSE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 60 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 120 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 180 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_IMPORT
+ {
+ Pos = MAP_APPFONT ( 184 , 7 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ de ] = "Importieren..." ;
+ Text[ en-US ] = "Import...";
+ };
+ PushButton BTN_DELETE
+ {
+ Pos = MAP_APPFONT ( 184 , 24 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text[ en-US ] = "Delete...";
+ };
+ FixedText FT_NOTE
+ {
+ Pos = MAP_APPFONT ( 12 , 95 ) ;
+ Size = MAP_APPFONT ( 200 , 24 ) ;
+ Text [ de ] = "Hinweis:\nBitte beachten Sie das für einen erfolgreichen Import die Symbole eine Größe von 16x16 Pixel haben müssen." ;
+ Text [ en-US ] = "Note:\nThe size of an icon should be 16x16 pixel to achieve best quality. Different sized icons will be scaled automatically." ;
+ Left = TRUE ;
+ WordBreak = TRUE;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0, 120 );
+ Size = MAP_APPFONT ( 240, 8 );
+ };
+ Color IMAGE_BTN_COLOR
+ {
+ Red = 0xC000 ;
+ Green = 0xC000 ;
+ Blue = 0xC000 ;
+ };
+};
+//added for issue83555
+ModalDialog MD_ICONCHANGE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 200 , 150 ) ;
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION" ;
+ Moveable = TRUE ;
+ FixedImage FI_INFO
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 24 , 24 ) ;
+ Fixed = Image
+ {
+
+ };
+ };
+ FixedText FTCHGE_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 30 ,15 ) ;
+ Size = MAP_APPFONT ( 200 , 50 ) ;
+ Text [ en-US ] = "The files listed below could not be imported.\nThe file format could not be interpreted." ;
+ };
+
+ MultiLineEdit EDT_ADDR
+ {
+ Pos = MAP_APPFONT ( 30 , 38) ;
+ Size = MAP_APPFONT ( 140 , 83 ) ;
+ Border = TRUE;
+ // VScroll = TRUE;
+ IgnoreTab = TRUE;
+ ReadOnly = TRUE;
+ };
+ OKButton MD_BTN_OK
+ {
+ Pos = MAP_APPFONT ( 68 , 131 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+
+};
+
+// Strings ---------------------------------------------------------------
+String RID_SVXSTR_IMPORT_ICON_ERROR
+{
+ Text [ de ] = "Die aufgelisteten Dateien konnten nicht importiert werden. Die Symbole entsprechen nicht der Größe von 16x16 Pixel." ;
+ Text [ en-US ] = "The files listed below could not be imported. The file format could not be interpreted." ;
+};
+
+String RID_SVXSTR_DELETE_ICON_CONFIRM //added for issue73355
+{
+ Text [ en-US ] = "Are you sure to delete the image?" ;
+};
+
+String RID_SVXSTR_REPLACE_ICON_WARNING //added for issue73355
+{
+ Text [ en-US ] = "The icon %ICONNAME is already contained in the image list.\nWould you like to replace the existing icon?";
+};
+
+String RID_SVXSTR_REPLACE_ICON_CONFIRM //added for issue73355
+{
+ Text [ en-US ] = "Confirm Icon Replacement";
+};
+
+String RID_SVXSTR_YESTOALL //added for issue73355
+{
+ Text [ en-US ] = "Yes to All";
+};
+
+String RID_SVXSTR_PRODUCTNAME_TOOLBARS
+{
+ Text [ de ] = "%PRODUCTNAME %MODULENAME Symbolleisten" ;
+ Text [ en-US ] = "%PRODUCTNAME %MODULENAME Toolbars" ;
+};
+
+String RID_SVXSTR_TOOLBAR
+{
+ Text [ de ] = "Symbolleiste" ;
+ Text [ en-US ] = "Toolbar" ;
+};
+
+String RID_SVXSTR_TOOLBAR_CONTENT
+{
+ Text [ de ] = "Symbolleisteninhalt" ;
+ Text [ en-US ] = "Toolbar Content" ;
+};
+
+String RID_SVXSTR_COMMANDS
+{
+ Text [ de ] = "Befehle" ;
+ Text [ en-US ] = "Commands" ;
+};
+
+String RID_SVXSTR_COMMAND
+{
+ Text [ de ] = "Befehl" ;
+ Text [ en-US ] = "Command" ;
+};
+
+String RID_SVXSTR_TOOLBAR_NAME
+{
+ TEXT_TOOLBAR_NAME
+};
+
+/* %MENUNAME will be replaced at runtime by the name of the selected menu. */
+QueryBox QBX_CONFIRM_DELETE_MENU
+{
+ Message [ de ] = "Sind Sie sicher, dass Sie das Menü '%MENUNAME' löschen möchten?";
+ Message [ en-US ] = "Are you sure you want to delete the '%MENUNAME' menu?";
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+};
+
+QueryBox QBX_CONFIRM_DELETE_TOOLBAR
+{
+ Message [ de ] = "Die Symbolleiste beinhaltet keine Befehle mehr. Soll die Symbolleiste gelöscht werden?";
+ Message [ en-US ] = "There are no more commands on the toolbar. Do you want to delete the toolbar?";
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+};
+
+/* Translators: Do not translate %SAVE IN SELECTION% It is a placeholder and will be
+ replaced at runtime by the name of the selected application or document.
+*/
+QueryBox QBX_CONFIRM_RESET
+{
+ Message [ de ] = "Die Menükonfiguration für %SAVE IN SELECTION% wird auf die Standardeinstellung zurückgesetzt. Möchten Sie fortfahren?";
+ Message [ en-US ] = "The menu configuration for %SAVE IN SELECTION% will be reset to the factory settings. Do you want to continue?";
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+};
+
+/* Translators: Do not translate %SAVE IN SELECTION% It is a placeholder
+ and will be replaced at runtime by the name of the selected application
+ or document.
+*/
+String RID_SVXSTR_CONFIRM_MENU_RESET
+{
+ Text [ de ] = "Die Menükonfiguration für %SAVE IN SELECTION% wird auf die Standardeinstellung zurückgesetzt. Möchten Sie fortfahren?";
+ Text [ en-US ] = "The menu configuration for %SAVE IN SELECTION% will be reset to the factory settings. Do you want to continue?";
+};
+
+String RID_SVXSTR_CONFIRM_TOOLBAR_RESET
+{
+ Text [ de ] = "Die Symbolleistenkonfiguration für %SAVE IN SELECTION% wird auf die Standardeinstellung zurückgesetzt. Möchten Sie fortfahren?";
+ Text [ en-US ] = "The toolbar configuration for %SAVE IN SELECTION% will be reset to the factory settings. Do you want to continue?";
+};
+
+QueryBox QBX_CONFIRM_RESTORE_DEFAULT
+{
+ Message [ de ] = "Alle Anpassungen die an dieser Symbolleiste vorgenommen wurden werden gelöscht. Möchten Sie diese Symbolleiste wirklich zurücksetzen?";
+ Message [ en-US ] = "This will delete all changes previously made to this toolbar. Do you really want to reset the toolbar?";
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_NO ;
+};
+
+InfoBox IBX_MNUCFG_ALREADY_INCLUDED
+{
+ Message [ de ] = "Die Funktion ist bereits in diesem Popup enthalten." ;
+ Message [ en-US ] = "Function is already included in this popup." ;
+};
+
+String RID_SVXSTR_LABEL_NEW_NAME
+{
+ Text [ de ] = "~Neuer Name";
+ Text [ en-US ] = "~New name";
+};
+
+String RID_SVXSTR_RENAME_MENU
+{
+ Text [ de ] = "Menü umbenennen";
+ Text [ en-US ] = "Rename Menu";
+};
+
+String RID_SVXSTR_RENAME_TOOLBAR
+{
+ Text [ de ] = "Symbolleiste umbenennen";
+ Text [ en-US ] = "Rename Toolbar";
+};
+
+
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
new file mode 100644
index 000000000000..952de1f9275e
--- /dev/null
+++ b/cui/source/customize/cfgutil.cxx
@@ -0,0 +1,1798 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cui.hxx"
+
+#include "cfgutil.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
+#include <com/sun/star/script/provider/XScriptProvider.hpp>
+#include <com/sun/star/script/browse/XBrowseNode.hpp>
+#include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
+
+#include <com/sun/star/script/browse/XBrowseNodeFactory.hpp>
+#include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+
+#include "acccfg.hrc"
+#include "helpid.hrc"
+#include <basic/sbx.hxx>
+#include <basic/basicmanagerrepository.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbxmeth.hxx>
+#include <basic/sbmod.hxx>
+#include <basic/basmgr.hxx>
+#include <tools/urlobj.hxx>
+#include "cuires.hrc"
+#include <sfx2/app.hxx>
+#include <sfx2/macrconf.hxx>
+#include <sfx2/minfitem.hxx>
+#include <unotools/processfactory.hxx>
+#include <comphelper/documentinfo.hxx>
+#include <svtools/imagemgr.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <unotools/configmgr.hxx>
+#include "dialmgr.hxx"
+#include <svl/stritem.hxx>
+
+#define _SVSTDARR_STRINGSDTOR
+#include <svl/svstdarr.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::document;
+namespace css = ::com::sun::star;
+
+static ::rtl::OUString SERVICE_UICATEGORYDESCRIPTION = ::rtl::OUString::createFromAscii("com.sun.star.ui.UICategoryDescription" );
+static ::rtl::OUString SERVICE_UICMDDESCRIPTION = ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription");
+
+SfxStylesInfo_Impl::SfxStylesInfo_Impl()
+{}
+
+void SfxStylesInfo_Impl::setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel)
+{
+ m_xDoc = xModel;
+}
+
+static ::rtl::OUString FAMILY_CHARACTERSTYLE = ::rtl::OUString::createFromAscii("CharacterStyles");
+static ::rtl::OUString FAMILY_PARAGRAPHSTYLE = ::rtl::OUString::createFromAscii("ParagraphStyles");
+static ::rtl::OUString FAMILY_FRAMESTYLE = ::rtl::OUString::createFromAscii("FrameStyles" );
+static ::rtl::OUString FAMILY_PAGESTYLE = ::rtl::OUString::createFromAscii("PageStyles" );
+static ::rtl::OUString FAMILY_NUMBERINGSTYLE = ::rtl::OUString::createFromAscii("NumberingStyles");
+
+static ::rtl::OUString CMDURL_SPART = ::rtl::OUString::createFromAscii(".uno:StyleApply?Style:string=");
+static ::rtl::OUString CMDURL_FPART2 = ::rtl::OUString::createFromAscii("&FamilyName:string=");
+
+static ::rtl::OUString CMDURL_STYLEPROT_ONLY = ::rtl::OUString::createFromAscii(".uno:StyleApply?");
+static ::rtl::OUString CMDURL_SPART_ONLY = ::rtl::OUString::createFromAscii("Style:string=");
+static ::rtl::OUString CMDURL_FPART_ONLY = ::rtl::OUString::createFromAscii("FamilyName:string=");
+
+static ::rtl::OUString STYLEPROP_UINAME = ::rtl::OUString::createFromAscii("DisplayName");
+
+::rtl::OUString SfxStylesInfo_Impl::generateCommand(const ::rtl::OUString& sFamily, const ::rtl::OUString& sStyle)
+{
+ ::rtl::OUStringBuffer sCommand(1024);
+ sCommand.append(CMDURL_SPART );
+ sCommand.append(sStyle );
+ sCommand.append(CMDURL_FPART2);
+ sCommand.append(sFamily );
+ return sCommand.makeStringAndClear();
+}
+
+sal_Bool SfxStylesInfo_Impl::parseStyleCommand(SfxStyleInfo_Impl& aStyle)
+{
+ static sal_Int32 LEN_STYLEPROT = CMDURL_STYLEPROT_ONLY.getLength();
+ static sal_Int32 LEN_SPART = CMDURL_SPART_ONLY.getLength();
+ static sal_Int32 LEN_FPART = CMDURL_FPART_ONLY.getLength();
+
+ if (aStyle.sCommand.indexOf(CMDURL_STYLEPROT_ONLY, 0) != 0)
+ return sal_False;
+
+ aStyle.sFamily = ::rtl::OUString();
+ aStyle.sStyle = ::rtl::OUString();
+
+ sal_Int32 nCmdLen = aStyle.sCommand.getLength();
+ ::rtl::OUString sCmdArgs = aStyle.sCommand.copy(LEN_STYLEPROT, nCmdLen-LEN_STYLEPROT);
+ sal_Int32 i = sCmdArgs.indexOf('&');
+ if (i<0)
+ return sal_False;
+
+ ::rtl::OUString sArg = sCmdArgs.copy(0, i);
+ if (sArg.indexOf(CMDURL_SPART_ONLY) == 0)
+ aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
+ else
+ if (sArg.indexOf(CMDURL_FPART_ONLY) == 0)
+ aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
+
+ sArg = sCmdArgs.copy(i+1, sCmdArgs.getLength()-i-1);
+ if (sArg.indexOf(CMDURL_SPART_ONLY) == 0)
+ aStyle.sStyle = sArg.copy(LEN_SPART, sArg.getLength()-LEN_SPART);
+ else
+ if (sArg.indexOf(CMDURL_FPART_ONLY) == 0)
+ aStyle.sFamily = sArg.copy(LEN_FPART, sArg.getLength()-LEN_FPART);
+
+ if (aStyle.sFamily.getLength() && aStyle.sStyle.getLength())
+ return sal_True;
+
+ return sal_False;
+}
+
+void SfxStylesInfo_Impl::getLabel4Style(SfxStyleInfo_Impl& aStyle)
+{
+ try
+ {
+ css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
+
+ css::uno::Reference< css::container::XNameAccess > xFamilies;
+ if (xModel.is())
+ xFamilies = xModel->getStyleFamilies();
+
+ css::uno::Reference< css::container::XNameAccess > xStyleSet;
+ if (xFamilies.is())
+ xFamilies->getByName(aStyle.sFamily) >>= xStyleSet;
+
+ css::uno::Reference< css::beans::XPropertySet > xStyle;
+ if (xStyleSet.is())
+ xStyleSet->getByName(aStyle.sStyle) >>= xStyle;
+
+ aStyle.sLabel = ::rtl::OUString();
+ if (xStyle.is())
+ xStyle->getPropertyValue(STYLEPROP_UINAME) >>= aStyle.sLabel;
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ { aStyle.sLabel = ::rtl::OUString(); }
+
+ if (!aStyle.sLabel.getLength())
+ {
+ aStyle.sLabel = aStyle.sCommand;
+ /*
+ #if OSL_DEBUG_LEVEL > 1
+ ::rtl::OUStringBuffer sMsg(256);
+ sMsg.appendAscii("There is no UIName for the style command \"");
+ sMsg.append (aStyle.sCommand );
+ sMsg.appendAscii("\". The UI will be invalid then ..." );
+ OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8).getStr());
+ #endif
+ */
+ }
+}
+
+::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyleFamilies()
+{
+ // Its an optional interface!
+ css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY);
+ if (!xModel.is())
+ return ::std::vector< SfxStyleInfo_Impl >();
+
+ css::uno::Reference< css::container::XNameAccess > xCont = xModel->getStyleFamilies();
+ css::uno::Sequence< ::rtl::OUString > lFamilyNames = xCont->getElementNames();
+ ::std::vector< SfxStyleInfo_Impl > lFamilies;
+ sal_Int32 c = lFamilyNames.getLength();
+ sal_Int32 i = 0;
+ for(i=0; i<c; ++i)
+ {
+ SfxStyleInfo_Impl aFamilyInfo;
+ aFamilyInfo.sFamily = lFamilyNames[i];
+
+ try
+ {
+ css::uno::Reference< css::beans::XPropertySet > xFamilyInfo;
+ xCont->getByName(aFamilyInfo.sFamily) >>= xFamilyInfo;
+ if (!xFamilyInfo.is())
+ {
+ // TODO_AS currently there is no support for an UIName property .. use internal family name instead
+ aFamilyInfo.sLabel = aFamilyInfo.sFamily;
+ }
+ else
+ xFamilyInfo->getPropertyValue(STYLEPROP_UINAME) >>= aFamilyInfo.sLabel;
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ { return ::std::vector< SfxStyleInfo_Impl >(); }
+
+ lFamilies.push_back(aFamilyInfo);
+ }
+
+ return lFamilies;
+}
+
+::std::vector< SfxStyleInfo_Impl > SfxStylesInfo_Impl::getStyles(const ::rtl::OUString& sFamily)
+{
+ static ::rtl::OUString PROP_UINAME = ::rtl::OUString::createFromAscii("DisplayName");
+
+ css::uno::Sequence< ::rtl::OUString > lStyleNames;
+ css::uno::Reference< css::style::XStyleFamiliesSupplier > xModel(m_xDoc, css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::container::XNameAccess > xFamilies = xModel->getStyleFamilies();
+ css::uno::Reference< css::container::XNameAccess > xStyleSet;
+ try
+ {
+ xFamilies->getByName(sFamily) >>= xStyleSet;
+ lStyleNames = xStyleSet->getElementNames();
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ { return ::std::vector< SfxStyleInfo_Impl >(); }
+
+ ::std::vector< SfxStyleInfo_Impl > lStyles;
+ sal_Int32 c = lStyleNames.getLength();
+ sal_Int32 i = 0;
+ for (i=0; i<c; ++i)
+ {
+ SfxStyleInfo_Impl aStyleInfo;
+ aStyleInfo.sFamily = sFamily;
+ aStyleInfo.sStyle = lStyleNames[i];
+ aStyleInfo.sCommand = SfxStylesInfo_Impl::generateCommand(aStyleInfo.sFamily, aStyleInfo.sStyle);
+
+ try
+ {
+ css::uno::Reference< css::beans::XPropertySet > xStyle;
+ xStyleSet->getByName(aStyleInfo.sStyle) >>= xStyle;
+ if (!xStyle.is())
+ continue;
+ xStyle->getPropertyValue(PROP_UINAME) >>= aStyleInfo.sLabel;
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ { continue; }
+
+ lStyles.push_back(aStyleInfo);
+ }
+ return lStyles;
+}
+SV_IMPL_PTRARR(SfxGroupInfoArr_Impl, SfxGroupInfoPtr);
+SfxConfigFunctionListBox_Impl::SfxConfigFunctionListBox_Impl( Window* pParent, const ResId& rResId)
+ : SvTreeListBox( pParent, rResId )
+ , pCurEntry( 0 )
+ , pStylesInfo( 0 )
+{
+ SetWindowBits( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
+ GetModel()->SetSortMode( SortAscending );
+
+ // Timer f"ur die BallonHelp
+ aTimer.SetTimeout( 200 );
+ aTimer.SetTimeoutHdl(
+ LINK( this, SfxConfigFunctionListBox_Impl, TimerHdl ) );
+}
+
+SfxConfigFunctionListBox_Impl::~SfxConfigFunctionListBox_Impl()
+{
+ ClearAll();
+}
+
+void SfxConfigFunctionListBox_Impl::MouseMove( const MouseEvent& )
+{
+ /* --> PB 2004-12-01 #i37000# - no own help text needed any longer
+ Point aMousePos = rMEvt.GetPosPixel();
+ pCurEntry = GetCurEntry();
+
+ if ( pCurEntry && GetEntry( aMousePos ) == pCurEntry )
+ aTimer.Start();
+ else
+ {
+ Help::ShowBalloon( this, aMousePos, String() );
+ aTimer.Stop();
+ }
+ */
+}
+
+
+IMPL_LINK( SfxConfigFunctionListBox_Impl, TimerHdl, Timer*, pTimer)
+/* Beschreibung
+ Timer-Handler f"ur die Einblendung eines Hilfetextes. Wenn nach Ablauf des Timers
+ der Mauszeiger immer noch auf dem aktuell selektierten Eintrag steht, wird der
+ Helptext des Entries als Balloon-Help eingeblendet.
+*/
+{
+ (void)pTimer; // unused
+ /* --> PB 2004-12-01 #i37000# - no own help text needed any longer
+ aTimer.Stop();
+ Point aMousePos = GetPointerPosPixel();
+ SvLBoxEntry *pEntry = GetCurEntry();
+ if ( pEntry && GetEntry( aMousePos ) == pEntry && pCurEntry == pEntry )
+ {
+ String sHelpText = GetHelpText( pEntry );
+ Help::ShowBalloon( this, OutputToScreenPixel( aMousePos ), sHelpText );
+ }
+ */
+ return 0L;
+}
+
+void SfxConfigFunctionListBox_Impl::ClearAll()
+/* Beschreibung
+ L"oscht alle Eintr"age in der FunctionListBox, alle UserDaten und alle evtl.
+ vorhandenen MacroInfos.
+*/
+{
+ USHORT nCount = aArr.Count();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ SfxGroupInfo_Impl *pData = aArr[i];
+
+ if ( pData->nKind == SFX_CFGFUNCTION_MACRO ||
+ pData->nKind == SFX_CFGFUNCTION_SCRIPT )
+ {
+ SfxMacroInfo *pInfo = (SfxMacroInfo*) pData->pObject;
+ SFX_APP()->GetMacroConfig()->ReleaseSlotId( pInfo->GetSlotId() );
+ delete pInfo;
+ }
+
+ if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER
+ || pData->nKind == SFX_CFGGROUP_DOCBASICMGR
+ )
+ {
+ XInterface* xi = static_cast<XInterface *>(pData->pObject);
+ if (xi != NULL)
+ {
+ xi->release();
+ }
+ }
+
+ delete pData;
+ }
+
+ aArr.Remove( 0, nCount );
+ Clear();
+}
+
+SvLBoxEntry* SfxConfigFunctionListBox_Impl::GetEntry_Impl( const String& rName )
+/* Beschreibung
+ Ermittelt den SvLBoxEntry zu einem "ubergebenen String. Das setzt voraus, da\s
+ die Namen eindeutig sind.
+*/
+{
+ SvLBoxEntry *pEntry = First();
+ while ( pEntry )
+ {
+ if ( GetEntryText( pEntry ) == rName )
+ return pEntry;
+ pEntry = Next( pEntry );
+ }
+
+ return NULL;
+}
+
+SvLBoxEntry* SfxConfigFunctionListBox_Impl::GetEntry_Impl( USHORT nId )
+/* Beschreibung
+ Ermittelt den SvLBoxEntry zu einer "ubergebenen Id.
+*/
+{
+ SvLBoxEntry *pEntry = First();
+ while ( pEntry )
+ {
+ SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ if ( pData && pData->nOrd == nId )
+ return pEntry;
+ pEntry = Next( pEntry );
+ }
+
+ return NULL;
+}
+
+SfxMacroInfo* SfxConfigFunctionListBox_Impl::GetMacroInfo()
+/* Beschreibung
+ Gibt die MacroInfo des selektierten Entry zur"uck ( sofern vorhanden ).
+*/
+{
+ SvLBoxEntry *pEntry = FirstSelected();
+ if ( pEntry )
+ {
+ SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ if ( pData && ( pData->nKind == SFX_CFGFUNCTION_MACRO ||
+ pData->nKind == SFX_CFGFUNCTION_SCRIPT ) )
+ return (SfxMacroInfo*) pData->pObject;
+ }
+
+ return 0;
+}
+
+String SfxConfigFunctionListBox_Impl::GetCurCommand()
+{
+ SvLBoxEntry *pEntry = FirstSelected();
+ if (!pEntry)
+ return String();
+ SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ if (!pData)
+ return String();
+ return pData->sCommand;
+}
+
+String SfxConfigFunctionListBox_Impl::GetCurLabel()
+{
+ SvLBoxEntry *pEntry = FirstSelected();
+ if (!pEntry)
+ return String();
+ SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ if (!pData)
+ return String();
+ if (pData->sLabel.Len())
+ return pData->sLabel;
+ return pData->sCommand;
+}
+
+USHORT SfxConfigFunctionListBox_Impl::GetId( SvLBoxEntry *pEntry )
+/* Beschreibung
+ Gibt die Ordnungsnummer ( SlotId oder Macro-Nummer ) des Eintrags zur"uck.
+*/
+{
+ SfxGroupInfo_Impl *pData = pEntry ?
+ (SfxGroupInfo_Impl*) pEntry->GetUserData() : 0;
+ if ( pData )
+ return pData->nOrd;
+ return 0;
+}
+
+/*
+String SfxConfigFunctionListBox_Impl::GetHelpText( SvLBoxEntry *pEntry )
+{
+ // Information zum selektierten Entry aus den Userdaten holen
+ SfxGroupInfo_Impl *pInfo = pEntry ? (SfxGroupInfo_Impl*) pEntry->GetUserData(): 0;
+ if ( pInfo )
+ {
+ switch ( pInfo->nKind )
+ {
+ case SFX_CFGGROUP_FUNCTION :
+ case SFX_CFGFUNCTION_SLOT :
+ {
+ // Eintrag ist eine Funktion, Hilfe aus der Office-Hilfe
+ USHORT nId = pInfo->nOrd;
+ String aText = Application::GetHelp()->GetHelpText( nId, this );
+
+ if ( !aText.Len() )
+ aText = SFX_SLOTPOOL().GetSlotHelpText_Impl( nId );
+ return aText;
+ }
+
+ case SFX_CFGGROUP_SCRIPTCONTAINER :
+ case SFX_CFGFUNCTION_SCRIPT :
+ case SFX_CFGGROUP_BASICMGR :
+ case SFX_CFGGROUP_DOCBASICMGR :
+ case SFX_CFGGROUP_BASICLIB :
+ case SFX_CFGGROUP_BASICMOD :
+ case SFX_CFGFUNCTION_MACRO :
+ {
+ // Eintrag ist ein Macro, Hilfe aus der MacroInfo
+ SfxMacroInfo *pMacInfo = (SfxMacroInfo*) pInfo->pObject;
+ return pMacInfo->GetHelpText();
+ }
+
+ case SFX_CFGGROUP_STYLES :
+ return String();
+ }
+ }
+
+ return String();
+}*/
+
+void SfxConfigFunctionListBox_Impl::FunctionSelected()
+/* Beschreibung
+ Setzt die Balloonhelp zur"uck, da diese immer den Helptext des selektierten
+ Entry anzeigen soll.
+*/
+{
+ /* --> PB 2004-12-01 #i37000# - no own help text needed any longer
+ Help::ShowBalloon( this, Point(), String() );
+ */
+}
+
+void SfxConfigFunctionListBox_Impl::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
+{
+ pStylesInfo = pStyles;
+}
+
+struct SvxConfigGroupBoxResource_Impl : public Resource
+{
+ Image m_hdImage;
+ Image m_hdImage_hc;
+ Image m_libImage;
+ Image m_libImage_hc;
+ Image m_macImage;
+ Image m_macImage_hc;
+ Image m_docImage;
+ Image m_docImage_hc;
+ ::rtl::OUString m_sMyMacros;
+ ::rtl::OUString m_sProdMacros;
+ String m_sMacros;
+ String m_sDlgMacros;
+ String m_aHumanAppName;
+ String m_aStrGroupStyles;
+ String m_aScriptType;
+ Image m_collapsedImage;
+ Image m_collapsedImage_hc;
+ Image m_expandedImage;
+ Image m_expandedImage_hc;
+
+ SvxConfigGroupBoxResource_Impl();
+};
+
+SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() :
+ Resource(CUI_RES(RID_SVXPAGE_CONFIGGROUPBOX)),
+ m_hdImage(CUI_RES(IMG_HARDDISK)),
+ m_hdImage_hc(CUI_RES(IMG_HARDDISK_HC)),
+ m_libImage(CUI_RES(IMG_LIB)),
+ m_libImage_hc(CUI_RES(IMG_LIB_HC)),
+ m_macImage(CUI_RES(IMG_MACRO)),
+ m_macImage_hc(CUI_RES(IMG_MACRO_HC)),
+ m_docImage(CUI_RES(IMG_DOC)),
+ m_docImage_hc(CUI_RES(IMG_DOC_HC)),
+ m_sMyMacros(String(CUI_RES(STR_MYMACROS))),
+ m_sProdMacros(String(CUI_RES(STR_PRODMACROS))),
+ m_sMacros(String(CUI_RES(STR_BASICMACROS))),
+ m_sDlgMacros(String(CUI_RES(STR_DLG_MACROS))),
+ m_aHumanAppName(String(CUI_RES(STR_HUMAN_APPNAME))),
+ m_aStrGroupStyles(String(CUI_RES(STR_GROUP_STYLES))),
+ m_aScriptType(String(CUI_RES(STR_BASICNAME))),
+ m_collapsedImage(CUI_RES(BMP_COLLAPSED)),
+ m_collapsedImage_hc(CUI_RES(BMP_COLLAPSED_HC)),
+ m_expandedImage(CUI_RES(BMP_EXPANDED)),
+ m_expandedImage_hc(CUI_RES(BMP_EXPANDED_HC))
+{
+ FreeResource();
+}
+
+SfxConfigGroupListBox_Impl::SfxConfigGroupListBox_Impl(
+ Window* pParent, const ResId& rResId, ULONG nConfigMode )
+ : SvTreeListBox( pParent, rResId )
+ , pImp(new SvxConfigGroupBoxResource_Impl()), pFunctionListBox(0), nMode( nConfigMode ), bShowSF( FALSE ), bShowBasic( TRUE ), pStylesInfo(0)
+{
+ SetWindowBits( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT );
+ SetNodeBitmaps( pImp->m_collapsedImage, pImp->m_expandedImage, BMP_COLOR_NORMAL );
+ SetNodeBitmaps( pImp->m_collapsedImage_hc, pImp->m_expandedImage_hc, BMP_COLOR_HIGHCONTRAST );
+
+ // Check configuration to see whether only Basic macros,
+ // only Scripting Framework scripts, or both should be listed
+ Any value;
+ sal_Bool tmp = false;
+
+ value = ::utl::ConfigManager::GetConfigManager()->GetLocalProperty(
+ ::rtl::OUString::createFromAscii(
+ "Office.Scripting/ScriptDisplaySettings/ShowBasic" ) );
+
+ value >>= tmp;
+
+ if (tmp == sal_True) {
+ bShowBasic = TRUE;
+ }
+ else {
+ bShowBasic = FALSE;
+ }
+
+ value = ::utl::ConfigManager::GetConfigManager()->GetLocalProperty(
+ ::rtl::OUString::createFromAscii(
+ "Office.Scripting/ScriptDisplaySettings/ShowSF" ) );
+
+ value >>= tmp;
+
+ if (tmp == sal_True) {
+ bShowSF = TRUE;
+ }
+ else {
+ bShowSF = FALSE;
+ }
+}
+
+
+SfxConfigGroupListBox_Impl::~SfxConfigGroupListBox_Impl()
+{
+ ClearAll();
+}
+
+void SfxConfigGroupListBox_Impl::ClearAll()
+{
+ USHORT nCount = aArr.Count();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ SfxGroupInfo_Impl *pData = aArr[i];
+ if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER
+ || pData->nKind == SFX_CFGGROUP_DOCBASICMGR
+ )
+ {
+ XInterface* xi = static_cast<XInterface *>(pData->pObject);
+ if (xi != NULL)
+ {
+ xi->release();
+ }
+ }
+ delete pData;
+ }
+
+ aArr.Remove( 0, nCount );
+ Clear();
+}
+
+void SfxConfigGroupListBox_Impl::SetScriptType( const String& rScriptType )
+{
+ pImp->m_aScriptType = rScriptType;
+ ULONG nPos=0;
+ SvLBoxEntry *pEntry = (SvLBoxEntry*) GetModel()->GetEntryAtAbsPos( nPos++ );
+ while ( pEntry )
+ {
+ SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ if ( pInfo->nKind == SFX_CFGGROUP_BASICLIB && ( IsExpanded( pEntry ) || pInfo->bWasOpened ) )
+ {
+ Collapse( pEntry );
+ SvLBoxEntry *pChild = FirstChild( pEntry );
+ while (pChild)
+ {
+ GetModel()->Remove( pChild );
+ pChild = FirstChild( pEntry );
+ }
+
+ Expand( pEntry );
+ }
+
+ pEntry = (SvLBoxEntry*) GetModel()->GetEntryAtAbsPos( nPos++ );
+ }
+}
+
+void SfxConfigGroupListBox_Impl::SetStylesInfo(SfxStylesInfo_Impl* pStyles)
+{
+ pStylesInfo = pStyles;
+}
+
+String SfxConfigGroupListBox_Impl::GetGroup()
+/* Beschreibung
+ Gibt den Namen der selektierten Funktionsgruppe bzw. des selektierten
+ Basics zur"uck.
+*/
+{
+ SvLBoxEntry *pEntry = FirstSelected();
+ while ( pEntry )
+ {
+ SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ if ( pInfo->nKind == SFX_CFGGROUP_FUNCTION )
+ return GetEntryText( pEntry );
+
+ if ( pInfo->nKind == SFX_CFGGROUP_BASICMGR )
+ {
+ BasicManager *pMgr = (BasicManager*) pInfo->pObject;
+ return pMgr->GetName();
+ }
+
+ if ( pInfo->nKind == SFX_CFGGROUP_DOCBASICMGR )
+ {
+ Reference< XModel > xDoc( static_cast< XModel* >( pInfo->pObject ) );
+ return ::comphelper::DocumentInfo::getDocumentTitle( xDoc );
+ }
+
+ pEntry = GetParent( pEntry );
+ }
+
+ return String();
+}
+
+//-----------------------------------------------
+BasicManager* SfxConfigGroupListBox_Impl::GetBasicManager( const SvLBoxEntry& _rEntry )
+{
+ BasicManager* pBasMgr = NULL;
+
+ SfxGroupInfo_Impl* pInfo = (SfxGroupInfo_Impl*) _rEntry.GetUserData();
+ switch ( pInfo->nKind )
+ {
+ case SFX_CFGGROUP_BASICMGR :
+ pBasMgr = (BasicManager*) pInfo->pObject;
+ break;
+ case SFX_CFGGROUP_DOCBASICMGR :
+ {
+ Reference< XModel > xDoc( static_cast< XModel* >( pInfo->pObject ) );
+ pBasMgr = ::basic::BasicManagerRepository::getDocumentBasicManager( xDoc );
+ }
+ break;
+ }
+ return pBasMgr;
+}
+
+//-----------------------------------------------
+void SfxConfigGroupListBox_Impl::InitModule()
+{
+ try
+ {
+ css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups();
+ sal_Int32 c1 = lGroups.getLength();
+ sal_Int32 i1 = 0;
+
+ for (i1=0; i1<c1; ++i1)
+ {
+ sal_Int16& rGroupID = lGroups[i1];
+ ::rtl::OUString sGroupID = ::rtl::OUString::valueOf((sal_Int32)rGroupID);
+ ::rtl::OUString sGroupName ;
+
+ try
+ {
+ m_xModuleCategoryInfo->getByName(sGroupID) >>= sGroupName;
+ if (!sGroupName.getLength())
+ continue;
+ }
+ catch(const css::container::NoSuchElementException&)
+ { continue; }
+
+ SvLBoxEntry* pEntry = InsertEntry(sGroupName, NULL);
+ SfxGroupInfo_Impl* pInfo = new SfxGroupInfo_Impl(SFX_CFGGROUP_FUNCTION, rGroupID);
+ pEntry->SetUserData(pInfo);
+ }
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ {}
+}
+
+//-----------------------------------------------
+void SfxConfigGroupListBox_Impl::InitBasic()
+{
+}
+
+//-----------------------------------------------
+void SfxConfigGroupListBox_Impl::InitStyles()
+{
+}
+
+//-----------------------------------------------
+namespace
+{
+ //...........................................
+ /** examines a component whether it supports XEmbeddedScripts, or provides access to such a
+ component by implementing XScriptInvocationContext.
+ @return
+ the model which supports the embedded scripts, or <NULL/> if it cannot find such a
+ model
+ */
+ static Reference< XModel > lcl_getDocumentWithScripts_throw( const Reference< XInterface >& _rxComponent )
+ {
+ Reference< XEmbeddedScripts > xScripts( _rxComponent, UNO_QUERY );
+ if ( !xScripts.is() )
+ {
+ Reference< XScriptInvocationContext > xContext( _rxComponent, UNO_QUERY );
+ if ( xContext.is() )
+ xScripts.set( xContext->getScriptContainer(), UNO_QUERY );
+ }
+
+ return Reference< XModel >( xScripts, UNO_QUERY );
+ }
+
+ //...........................................
+ static Reference< XModel > lcl_getScriptableDocument_nothrow( const Reference< XFrame >& _rxFrame )
+ {
+ Reference< XModel > xDocument;
+
+ // examine our associated frame
+ try
+ {
+ OSL_ENSURE( _rxFrame.is(), "lcl_getScriptableDocument_nothrow: you need to pass a frame to this dialog/tab page!" );
+ if ( _rxFrame.is() )
+ {
+ // first try the model in the frame
+ Reference< XController > xController( _rxFrame->getController(), UNO_SET_THROW );
+ xDocument = lcl_getDocumentWithScripts_throw( xController->getModel() );
+
+ if ( !xDocument.is() )
+ {
+ // if there is no suitable document in the frame, try the controller
+ xDocument = lcl_getDocumentWithScripts_throw( _rxFrame->getController() );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ //DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xDocument;
+ }
+}
+
+//-----------------------------------------------
+void SfxConfigGroupListBox_Impl::Init(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
+ const css::uno::Reference< css::frame::XFrame >& xFrame ,
+ const ::rtl::OUString& sModuleLongName)
+{
+ SetUpdateMode(FALSE);
+ ClearAll(); // Remove all old entries from treelist box
+
+ m_xFrame = xFrame;
+ if ( xSMGR.is())
+ {
+ m_xSMGR = xSMGR;
+ m_sModuleLongName = sModuleLongName;
+
+ m_xGlobalCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xSMGR->createInstance(SERVICE_UICATEGORYDESCRIPTION), css::uno::UNO_QUERY_THROW);
+ m_xModuleCategoryInfo = css::uno::Reference< css::container::XNameAccess >(m_xGlobalCategoryInfo->getByName(m_sModuleLongName) , css::uno::UNO_QUERY_THROW);
+ m_xUICmdDescription = css::uno::Reference< css::container::XNameAccess >(m_xSMGR->createInstance(SERVICE_UICMDDESCRIPTION) , css::uno::UNO_QUERY_THROW);
+
+ InitModule();
+ InitBasic();
+ InitStyles();
+ }
+
+ /*
+
+ // Verwendet wird der aktuelle Slotpool
+ if ( nMode )
+ {
+ pSlotPool = pPool ? pPool : &SFX_SLOTPOOL();
+ for ( USHORT i=1; i<pSlotPool->GetGroupCount(); i++ )
+ {
+ // Gruppe anw"ahlen ( Gruppe 0 ist intern )
+ String aName = pSlotPool->SeekGroup( i );
+ const SfxSlot *pSfxSlot = pSlotPool->FirstSlot();
+ if ( pSfxSlot )
+ {
+ // Check if all entries are not useable. Don't
+ // insert a group without any useable function.
+ sal_Bool bActiveEntries = sal_False;
+ while ( pSfxSlot )
+ {
+ USHORT nId = pSfxSlot->GetSlotId();
+ if ( pSfxSlot->GetMode() & nMode )
+ {
+ bActiveEntries = sal_True;
+ break;
+ }
+
+ pSfxSlot = pSlotPool->NextSlot();
+ }
+
+ if ( bActiveEntries )
+ {
+ // Wenn Gruppe nicht leer
+ SvLBoxEntry *pEntry = InsertEntry( aName, NULL );
+ SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_FUNCTION, i );
+ aArr.Insert( pInfo, aArr.Count() );
+ pEntry->SetUserData( pInfo );
+ }
+ }
+ }
+ }
+*/
+ SfxApplication *pSfxApp = SFX_APP();
+ if ( bShowBasic )
+ {
+ // Basics einsammeln
+ pSfxApp->EnterBasicCall();
+ String aMacroName(' ');
+ aMacroName += pImp->m_sDlgMacros;
+
+ // Zuerst AppBasic
+ BasicManager *pAppBasicMgr = pSfxApp->GetBasicManager();
+ BOOL bInsert = TRUE;
+ /*
+ if ( pArr )
+ {
+ bInsert = FALSE;
+ for ( USHORT n=0; n<pArr->Count(); n++ )
+ {
+ if ( *(*pArr)[n] == pSfxApp->GetName() )
+ {
+ bInsert = TRUE;
+ break;
+ }
+ }
+ }
+ */
+
+ if ( bInsert )
+ {
+ pAppBasicMgr->SetName( pSfxApp->GetName() );
+ if ( pAppBasicMgr->GetLibCount() )
+ {
+ // Nur einf"ugen, wenn Bibliotheken vorhanden
+ String aAppBasTitle( pImp->m_aHumanAppName );
+ aAppBasTitle += aMacroName;
+ SvLBoxEntry *pEntry = InsertEntry( aAppBasTitle, 0 );
+ SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_BASICMGR, 0, pAppBasicMgr );
+ // aArr.Insert( pInfo, aArr.Count() );
+ pEntry->SetUserData( pInfo );
+ pEntry->EnableChildsOnDemand( TRUE );
+ // Expand( pEntry );
+ }
+ }
+
+ Reference< XModel > xDoc( lcl_getScriptableDocument_nothrow( m_xFrame ) );
+ if ( xDoc.is() )
+ {
+ BasicManager* pBasicMgr = ::basic::BasicManagerRepository::getDocumentBasicManager( xDoc );
+ if ( pBasicMgr != pAppBasicMgr && pBasicMgr->GetLibCount() )
+ {
+ String sDocTitle( ::comphelper::DocumentInfo::getDocumentTitle( xDoc ) );
+ pBasicMgr->SetName( sDocTitle );
+
+ // Nur einf"ugen, wenn eigenes Basic mit Bibliotheken
+ SvLBoxEntry *pEntry = InsertEntry( sDocTitle.Append( aMacroName ), NULL );
+ xDoc->acquire();
+ SfxGroupInfo_Impl *pInfo =
+ new SfxGroupInfo_Impl( SFX_CFGGROUP_DOCBASICMGR, 0, xDoc.get() );
+ pEntry->SetUserData( pInfo );
+ pEntry->EnableChildsOnDemand( TRUE );
+ }
+ }
+
+ pSfxApp->LeaveBasicCall();
+ }
+
+ OSL_TRACE("** ** About to initialise SF Scripts");
+ if ( bShowSF )
+ {
+ OSL_TRACE("** ** bShowSF");
+ // Add Scripting Framework entries
+ Reference< browse::XBrowseNode > rootNode;
+ Reference< XComponentContext > xCtx;
+ try
+ {
+ Reference < beans::XPropertySet > xProps(
+ ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+ xCtx.set( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW );
+ Reference< browse::XBrowseNodeFactory > xFac( xCtx->getValueByName(
+ ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") ), UNO_QUERY_THROW );
+ rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) );
+ //rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROORGANIZER ) );
+ }
+ catch( Exception& e )
+ {
+ OSL_TRACE(" Caught some exception whilst retrieving browse nodes from factory... Exception: %s",
+ ::rtl::OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ // TODO exception handling
+ }
+
+
+ if ( rootNode.is() )
+ {
+ if ( nMode )
+ {
+ //We call acquire on the XBrowseNode so that it does not
+ //get autodestructed and become invalid when accessed later.
+ rootNode->acquire();
+
+ SfxGroupInfo_Impl *pInfo =
+ new SfxGroupInfo_Impl( SFX_CFGGROUP_SCRIPTCONTAINER, 0,
+ static_cast<void *>(rootNode.get()));
+
+ String aTitle(pImp->m_sDlgMacros);
+ SvLBoxEntry *pNewEntry = InsertEntry( aTitle, NULL );
+ pNewEntry->SetUserData( pInfo );
+ pNewEntry->EnableChildsOnDemand( TRUE );
+ aArr.Insert( pInfo, aArr.Count() );
+ }
+ else
+ {
+ //We are only showing scripts not slot APIs so skip
+ //Root node and show location nodes
+ try {
+ if ( rootNode->hasChildNodes() )
+ {
+ Sequence< Reference< browse::XBrowseNode > > children =
+ rootNode->getChildNodes();
+ BOOL bIsRootNode = FALSE;
+
+ ::rtl::OUString user = ::rtl::OUString::createFromAscii("user");
+ ::rtl::OUString share = ::rtl::OUString::createFromAscii("share");
+ if ( rootNode->getName().equals(::rtl::OUString::createFromAscii("Root") ))
+ {
+ bIsRootNode = TRUE;
+ }
+
+ //To mimic current starbasic behaviour we
+ //need to make sure that only the current document
+ //is displayed in the config tree. Tests below
+ //set the bDisplay flag to FALSE if the current
+ //node is a first level child of the Root and is NOT
+ //either the current document, user or share
+ ::rtl::OUString currentDocTitle;
+ Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
+ if ( xDocument.is() )
+ {
+ currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
+ }
+
+ for ( sal_Int32 n = 0; n < children.getLength(); n++ )
+ {
+ Reference< browse::XBrowseNode >& theChild = children[n];
+ BOOL bDisplay = TRUE;
+ ::rtl::OUString uiName = theChild->getName();
+ if ( bIsRootNode )
+ {
+ if ( ! ((theChild->getName().equals( user ) || theChild->getName().equals( share ) ||
+ theChild->getName().equals( currentDocTitle ) ) ) )
+ {
+ bDisplay=FALSE;
+ }
+ else
+ {
+ if ( uiName.equals( user ) )
+ {
+ uiName = pImp->m_sMyMacros;
+ }
+ else if ( uiName.equals( share ) )
+ {
+ uiName = pImp->m_sProdMacros;
+ }
+ }
+ }
+ if (children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
+ {
+
+// We call acquire on the XBrowseNode so that it does not
+// get autodestructed and become invalid when accessed later.
+ theChild->acquire();
+
+ SfxGroupInfo_Impl* pInfo =
+ new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
+ 0, static_cast<void *>( theChild.get()));
+
+ Image aImage = GetImage( theChild, xCtx, bIsRootNode,BMP_COLOR_NORMAL );
+ SvLBoxEntry* pNewEntry =
+ InsertEntry( uiName, NULL);
+ SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ aImage = GetImage( theChild, xCtx, bIsRootNode,BMP_COLOR_HIGHCONTRAST );
+ SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+ SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+
+ pNewEntry->SetUserData( pInfo );
+ aArr.Insert( pInfo, aArr.Count() );
+
+ if ( children[n]->hasChildNodes() )
+ {
+ Sequence< Reference< browse::XBrowseNode > > grandchildren =
+ children[n]->getChildNodes();
+
+ for ( sal_Int32 m = 0; m < grandchildren.getLength(); m++ )
+ {
+ if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
+ {
+ pNewEntry->EnableChildsOnDemand( TRUE );
+ m = grandchildren.getLength();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (RuntimeException&) {
+ // do nothing, the entry will not be displayed in the UI
+ }
+ }
+ }
+ }
+
+ // add styles
+ if ( m_xSMGR.is() )
+ {
+ String sStyle( pImp->m_aStrGroupStyles );
+ SvLBoxEntry *pEntry = InsertEntry( sStyle, 0 );
+ SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, 0 ); // TODO last parameter should contain user data
+ aArr.Insert( pInfo, aArr.Count() );
+ pEntry->SetUserData( pInfo );
+ pEntry->EnableChildsOnDemand( TRUE );
+ }
+
+/* {
+ String sSymbols( String::CreateFromAscii("Symbols") );
+ SvLBoxEntry *pEntry = InsertEntry( sSymbols, 0 );
+ SfxGroupInfo_Impl *pInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_SPECIALCHARACTERS, 0, 0 ); // TODO last parameter should contain user data
+ aArr.Insert( pInfo, aArr.Count() );
+ pEntry->SetUserData( pInfo );
+ } */
+
+ MakeVisible( GetEntry( 0,0 ) );
+ SetUpdateMode( TRUE );
+}
+Image SfxConfigGroupListBox_Impl::GetImage( Reference< browse::XBrowseNode > node, Reference< XComponentContext > xCtx, bool bIsRootNode, bool bHighContrast )
+{
+ Image aImage;
+ if ( bIsRootNode )
+ {
+ ::rtl::OUString user = ::rtl::OUString::createFromAscii("user");
+ ::rtl::OUString share = ::rtl::OUString::createFromAscii("share");
+ if (node->getName().equals( user ) || node->getName().equals(share ) )
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = pImp->m_hdImage;
+ else
+ aImage = pImp->m_hdImage_hc;
+ }
+ else
+ {
+ ::rtl::OUString factoryURL;
+ ::rtl::OUString nodeName = node->getName();
+ Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
+ if ( xDocumentModel.is() )
+ {
+ Reference< ::com::sun::star::frame::XModuleManager >
+ xModuleManager(
+ xCtx->getServiceManager()
+ ->createInstanceWithContext(
+ ::rtl::OUString::createFromAscii("" // xxx todo
+ "com.sun.star.frame.ModuleManager"),
+ xCtx ),
+ UNO_QUERY_THROW );
+ Reference<container::XNameAccess> xModuleConfig(
+ xModuleManager, UNO_QUERY_THROW );
+ // get the long name of the document:
+ ::rtl::OUString appModule( xModuleManager->identify(
+ xDocumentModel ) );
+ Sequence<beans::PropertyValue> moduleDescr;
+ Any aAny = xModuleConfig->getByName(appModule);
+ if( sal_True != ( aAny >>= moduleDescr ) )
+ {
+ throw RuntimeException(::rtl::OUString::createFromAscii("SFTreeListBox::Init: failed to get PropertyValue"), Reference< XInterface >());
+ }
+ beans::PropertyValue const * pmoduleDescr =
+ moduleDescr.getConstArray();
+ for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
+ {
+ if (pmoduleDescr[ pos ].Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM(
+ "ooSetupFactoryEmptyDocumentURL") ))
+ {
+ pmoduleDescr[ pos ].Value >>= factoryURL;
+ OSL_TRACE("factory url for doc images is %s",
+ ::rtl::OUStringToOString( factoryURL , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ break;
+ }
+ }
+ }
+ if( factoryURL.getLength() > 0 )
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = SvFileInformationManager::GetFileImage(
+ INetURLObject(factoryURL), false,
+ BMP_COLOR_NORMAL );
+ else
+ aImage = SvFileInformationManager::GetFileImage(
+ INetURLObject(factoryURL), false,
+ BMP_COLOR_HIGHCONTRAST );
+ }
+ else
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = pImp->m_docImage;
+ else
+ aImage = pImp->m_docImage_hc;
+ }
+ }
+ }
+ else
+ {
+ if( node->getType() == browse::BrowseNodeTypes::SCRIPT )
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = pImp->m_macImage;
+ else
+ aImage = pImp->m_macImage_hc;
+ }
+ else
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = pImp->m_libImage;
+ else
+ aImage = pImp->m_libImage_hc;
+ }
+ }
+ return aImage;
+}
+
+Reference< XInterface >
+SfxConfigGroupListBox_Impl::getDocumentModel( Reference< XComponentContext >& xCtx, ::rtl::OUString& docName )
+{
+ Reference< XInterface > xModel;
+ Reference< lang::XMultiComponentFactory > mcf =
+ xCtx->getServiceManager();
+ Reference< frame::XDesktop > desktop (
+ mcf->createInstanceWithContext(
+ ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx ),
+ UNO_QUERY );
+
+ Reference< container::XEnumerationAccess > componentsAccess =
+ desktop->getComponents();
+ Reference< container::XEnumeration > components =
+ componentsAccess->createEnumeration();
+ while (components->hasMoreElements())
+ {
+ Reference< frame::XModel > model(
+ components->nextElement(), UNO_QUERY );
+ if ( model.is() )
+ {
+ ::rtl::OUString sTdocUrl =
+ ::comphelper::DocumentInfo::getDocumentTitle( model );
+ if( sTdocUrl.equals( docName ) )
+ {
+ xModel = model;
+ break;
+ }
+ }
+ }
+ return xModel;
+}
+
+::rtl::OUString SfxConfigGroupListBox_Impl::parseLocationName( const ::rtl::OUString& location )
+{
+ // strip out the last leaf of location name
+ // e.g. file://dir1/dir2/Blah.sxw - > Blah.sxw
+ ::rtl::OUString temp = location;
+ sal_Int32 lastSlashIndex = temp.lastIndexOf( ::rtl::OUString::createFromAscii( "/" ) );
+
+ if ( ( lastSlashIndex + 1 ) < temp.getLength() )
+ {
+ temp = temp.copy( lastSlashIndex + 1 );
+ }
+ // maybe we should throw here!!!
+ else
+ {
+ OSL_TRACE("Something wrong with name, perhaps we should throw an exception");
+ }
+ return temp;
+}
+
+//-----------------------------------------------
+::rtl::OUString SfxConfigGroupListBox_Impl::MapCommand2UIName(const ::rtl::OUString& sCommand)
+{
+ ::rtl::OUString sUIName;
+ try
+ {
+ css::uno::Reference< css::container::XNameAccess > xModuleConf;
+ m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
+ if (xModuleConf.is())
+ {
+ ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
+ sUIName = lProps.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("Name"), ::rtl::OUString());
+ }
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(css::uno::Exception&)
+ { sUIName = ::rtl::OUString(); }
+
+ // fallback for missing UINames !?
+ if (!sUIName.getLength())
+ {
+ sUIName = sCommand;
+ /*
+ #if OSL_DEBUG_LEVEL > 1
+ ::rtl::OUStringBuffer sMsg(256);
+ sMsg.appendAscii("There is no UIName for the internal command \"");
+ sMsg.append (sCommand );
+ sMsg.appendAscii("\". The UI will be invalid then ..." );
+ OSL_ENSURE(sal_False, ::rtl::OUStringToOString(sMsg.makeStringAndClear(), RTL_TEXTENCODING_UTF8).getStr());
+ #endif
+ */
+ }
+
+ return sUIName;
+}
+
+//-----------------------------------------------
+void SfxConfigGroupListBox_Impl::GroupSelected()
+/* Beschreibung
+ Eine Funktionsgruppe oder eine Basicmodul wurde selektiert. Alle Funktionen bzw.
+ Macros werden in der Functionlistbox anzeigt.
+*/
+{
+ SvLBoxEntry *pEntry = FirstSelected();
+ SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ pFunctionListBox->SetUpdateMode(FALSE);
+ pFunctionListBox->ClearAll();
+ if ( pInfo->nKind != SFX_CFGGROUP_FUNCTION &&
+ pInfo->nKind != SFX_CFGGROUP_BASICMOD &&
+ pInfo->nKind != SFX_CFGGROUP_SCRIPTCONTAINER &&
+ pInfo->nKind != SFX_CFGGROUP_STYLES )
+ {
+ pFunctionListBox->SetUpdateMode(TRUE);
+ return;
+ }
+
+ switch ( pInfo->nKind )
+ {
+ case SFX_CFGGROUP_FUNCTION :
+ {
+ USHORT nGroup = pInfo->nOrd;
+ css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider (m_xFrame, css::uno::UNO_QUERY_THROW);
+ css::uno::Sequence< css::frame::DispatchInformation > lCommands = xProvider->getConfigurableDispatchInformation(nGroup);
+ sal_Int32 c = lCommands.getLength();
+ sal_Int32 i = 0;
+
+ for (i=0; i<c; ++i)
+ {
+ const css::frame::DispatchInformation& rInfo = lCommands[i];
+ ::rtl::OUString sUIName = MapCommand2UIName(rInfo.Command);
+ SvLBoxEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName, NULL);
+ SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl(SFX_CFGFUNCTION_SLOT, 0);
+ pGrpInfo->sCommand = rInfo.Command;
+ pGrpInfo->sLabel = sUIName;
+ pFuncEntry->SetUserData(pGrpInfo);
+ }
+
+ break;
+ }
+
+ case SFX_CFGGROUP_BASICMOD :
+ {
+ SvLBoxEntry *pLibEntry = GetParent( pEntry );
+ SfxGroupInfo_Impl *pLibInfo =
+ (SfxGroupInfo_Impl*) pLibEntry->GetUserData();
+ SvLBoxEntry *pBasEntry = GetParent( pLibEntry );
+ SfxGroupInfo_Impl *pBasInfo =
+ (SfxGroupInfo_Impl*) pBasEntry->GetUserData();
+
+ StarBASIC *pLib = (StarBASIC*) pLibInfo->pObject;
+ Reference< XModel > xDoc;
+ if ( pBasInfo->nKind == SFX_CFGGROUP_DOCBASICMGR )
+ xDoc = static_cast< XModel* >( pBasInfo->pObject );
+
+ SbModule *pMod = (SbModule*) pInfo->pObject;
+ for ( USHORT nMeth=0; nMeth < pMod->GetMethods()->Count(); nMeth++ )
+ {
+ SbxMethod *pMeth = (SbxMethod*)pMod->GetMethods()->Get(nMeth);
+ SfxMacroInfoPtr pInf = new SfxMacroInfo( !xDoc.is(),
+ pLib->GetName(),
+ pMod->GetName(),
+ pMeth->GetName());
+ if ( pMeth->GetInfo() )
+ pInf->SetHelpText( pMeth->GetInfo()->GetComment() );
+ USHORT nId = SFX_APP()->GetMacroConfig()->GetSlotId( pInf );
+ if ( !nId )
+ break; // Kein Slot mehr frei
+
+ SvLBoxEntry* pFuncEntry =
+ pFunctionListBox->InsertEntry( pMeth->GetName(), NULL );
+ SfxGroupInfo_Impl *pGrpInfo =
+ new SfxGroupInfo_Impl( SFX_CFGFUNCTION_MACRO, nId, pInf );
+ pFunctionListBox->aArr.Insert( pGrpInfo, pFunctionListBox->aArr.Count() );
+ pFuncEntry->SetUserData( pGrpInfo );
+ }
+
+ break;
+ }
+
+ case SFX_CFGGROUP_SCRIPTCONTAINER:
+ {
+ if ( !GetChildCount( pEntry ) )
+ {
+ Reference< browse::XBrowseNode > rootNode(
+ reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
+
+ try {
+ if ( rootNode->hasChildNodes() )
+ {
+ Sequence< Reference< browse::XBrowseNode > > children =
+ rootNode->getChildNodes();
+
+ for ( sal_Int32 n = 0; n < children.getLength(); n++ )
+ {
+ if (children[n]->getType() == browse::BrowseNodeTypes::SCRIPT)
+ {
+ ::rtl::OUString uri;
+
+ Reference < beans::XPropertySet >xPropSet( children[n], UNO_QUERY );
+ if (!xPropSet.is())
+ {
+ continue;
+ }
+
+ Any value =
+ xPropSet->getPropertyValue( String::CreateFromAscii( "URI" ) );
+ value >>= uri;
+
+ SfxMacroInfo* aInfo = new SfxMacroInfo( (String)uri );
+ aInfo->SetHelpText( uri );
+ SFX_APP()->GetMacroConfig()->GetSlotId( aInfo );
+
+ SfxGroupInfo_Impl* pGrpInfo =
+ new SfxGroupInfo_Impl(SFX_CFGFUNCTION_SCRIPT,
+ aInfo->GetSlotId(), aInfo);
+
+ Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_NORMAL );
+ SvLBoxEntry* pNewEntry =
+ pFunctionListBox->InsertEntry( children[n]->getName(), NULL );
+ pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_HIGHCONTRAST );
+ pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+ pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+
+ pGrpInfo->sCommand = uri;
+ pGrpInfo->sLabel = children[n]->getName();
+ pNewEntry->SetUserData( pGrpInfo );
+
+ pFunctionListBox->aArr.Insert(
+ pGrpInfo, pFunctionListBox->aArr.Count() );
+
+ }
+ }
+ }
+ }
+ catch (RuntimeException&) {
+ // do nothing, the entry will not be displayed in the UI
+ }
+ }
+ break;
+ }
+
+ case SFX_CFGGROUP_STYLES :
+ {
+ SfxStyleInfo_Impl* pFamily = (SfxStyleInfo_Impl*)(pInfo->pObject);
+ if (pFamily)
+ {
+ const ::std::vector< SfxStyleInfo_Impl > lStyles = pStylesInfo->getStyles(pFamily->sFamily);
+ ::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
+ for ( pIt = lStyles.begin();
+ pIt != lStyles.end() ;
+ ++pIt )
+ {
+ SfxStyleInfo_Impl* pStyle = new SfxStyleInfo_Impl(*pIt);
+ SvLBoxEntry* pFuncEntry = pFunctionListBox->InsertEntry( pStyle->sLabel, NULL );
+ SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pStyle );
+ pFunctionListBox->aArr.Insert( pGrpInfo, pFunctionListBox->aArr.Count() );
+ pGrpInfo->sCommand = pStyle->sCommand;
+ pGrpInfo->sLabel = pStyle->sLabel;
+ pFuncEntry->SetUserData( pGrpInfo );
+ }
+ }
+ break;
+ }
+
+ default:
+ return;
+ }
+
+ if ( pFunctionListBox->GetEntryCount() )
+ pFunctionListBox->Select( pFunctionListBox->GetEntry( 0, 0 ) );
+
+ pFunctionListBox->SetUpdateMode(TRUE);
+}
+
+BOOL SfxConfigGroupListBox_Impl::Expand( SvLBoxEntry* pParent )
+{
+ BOOL bRet = SvTreeListBox::Expand( pParent );
+ if ( bRet )
+ {
+ // Wieviele Entries k"onnen angezeigt werden ?
+ ULONG nEntries = GetOutputSizePixel().Height() / GetEntryHeight();
+
+ // Wieviele Kinder sollen angezeigt werden ?
+ ULONG nChildCount = GetVisibleChildCount( pParent );
+
+ // Passen alle Kinder und der parent gleichzeitig in die View ?
+ if ( nChildCount+1 > nEntries )
+ {
+ // Wenn nicht, wenigstens parent ganz nach oben schieben
+ MakeVisible( pParent, TRUE );
+ }
+ else
+ {
+ // An welcher relativen ViewPosition steht der aufzuklappende parent
+ SvLBoxEntry *pEntry = GetFirstEntryInView();
+ ULONG nParentPos = 0;
+ while ( pEntry && pEntry != pParent )
+ {
+ nParentPos++;
+ pEntry = GetNextEntryInView( pEntry );
+ }
+
+ // Ist unter dem parent noch genug Platz f"ur alle Kinder ?
+ if ( nParentPos + nChildCount + 1 > nEntries )
+ ScrollOutputArea( (short)( nEntries - ( nParentPos + nChildCount + 1 ) ) );
+ }
+ }
+
+ return bRet;
+}
+
+void SfxConfigGroupListBox_Impl::RequestingChilds( SvLBoxEntry *pEntry )
+/* Beschreibung
+ Ein Basic oder eine Bibliothek werden ge"offnet
+*/
+{
+ SfxGroupInfo_Impl *pInfo = (SfxGroupInfo_Impl*) pEntry->GetUserData();
+ pInfo->bWasOpened = TRUE;
+ switch ( pInfo->nKind )
+ {
+ case SFX_CFGGROUP_BASICMGR :
+ case SFX_CFGGROUP_DOCBASICMGR :
+ {
+ if ( !GetChildCount( pEntry ) )
+ {
+ // Erstmaliges "Offnen
+ BasicManager* pMgr( GetBasicManager( *pEntry ) );
+
+ SvLBoxEntry *pLibEntry = 0;
+ for ( USHORT nLib=0; nLib<pMgr->GetLibCount(); nLib++)
+ {
+ StarBASIC* pLib = pMgr->GetLib( nLib );
+ pLibEntry = InsertEntry( pMgr->GetLibName( nLib ), pEntry );
+ SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_BASICLIB, nLib, pLib );
+ aArr.Insert( pGrpInfo, aArr.Count() );
+ pLibEntry->SetUserData( pGrpInfo );
+ pLibEntry->EnableChildsOnDemand( TRUE );
+ }
+ }
+
+ break;
+ }
+
+ case SFX_CFGGROUP_BASICLIB :
+ {
+ if ( !GetChildCount( pEntry ) )
+ {
+ // Erstmaliges "Offnen
+ StarBASIC *pLib = (StarBASIC*) pInfo->pObject;
+ if ( !pLib )
+ {
+ // Lib mu\s nachgeladen werden
+ SvLBoxEntry *pParent = GetParent( pEntry );
+ BasicManager *pMgr( GetBasicManager( *pParent ) );
+
+ if ( pMgr->LoadLib( pInfo->nOrd ) )
+ pInfo->pObject = pLib = pMgr->GetLib( pInfo->nOrd );
+ else
+ break;
+ }
+
+ SvLBoxEntry *pModEntry = 0;
+ for ( USHORT nMod=0; nMod<pLib->GetModules()->Count(); nMod++ )
+ {
+ SbModule* pMod = (SbModule*)pLib->GetModules()->Get( nMod );
+
+ BOOL bIsStarScript = FALSE; //pMod->ISA( SbJScriptModule );
+ BOOL bWantsStarScript = pImp->m_aScriptType.EqualsAscii("StarScript");
+ if ( bIsStarScript != bWantsStarScript )
+ continue;
+ pModEntry = InsertEntry( pMod->GetName(), pEntry );
+ SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_BASICMOD, 0, pMod );
+ aArr.Insert( pGrpInfo, aArr.Count() );
+ pModEntry->SetUserData( pGrpInfo );
+ }
+ }
+
+ break;
+ }
+
+ case SFX_CFGGROUP_SCRIPTCONTAINER:
+ {
+ if ( !GetChildCount( pEntry ) )
+ {
+ Reference< browse::XBrowseNode > rootNode(
+ reinterpret_cast< browse::XBrowseNode* >( pInfo->pObject ) ) ;
+
+ try {
+ if ( rootNode->hasChildNodes() )
+ {
+ Sequence< Reference< browse::XBrowseNode > > children =
+ rootNode->getChildNodes();
+ BOOL bIsRootNode = FALSE;
+
+ ::rtl::OUString user = ::rtl::OUString::createFromAscii("user");
+ ::rtl::OUString share = ::rtl::OUString::createFromAscii("share");
+ if ( rootNode->getName().equals(::rtl::OUString::createFromAscii("Root") ))
+ {
+ bIsRootNode = TRUE;
+ }
+
+ /* To mimic current starbasic behaviour we
+ need to make sure that only the current document
+ is displayed in the config tree. Tests below
+ set the bDisplay flag to FALSE if the current
+ node is a first level child of the Root and is NOT
+ either the current document, user or share */
+ ::rtl::OUString currentDocTitle;
+ Reference< XModel > xDocument( lcl_getScriptableDocument_nothrow( m_xFrame ) );
+ if ( xDocument.is() )
+ {
+ currentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xDocument );
+ }
+
+ sal_Int32 nLen = children.getLength();
+ for ( sal_Int32 n = 0; n < nLen; n++ )
+ {
+ Reference< browse::XBrowseNode >& theChild = children[n];
+ ::rtl::OUString aName( theChild->getName() );
+ BOOL bDisplay = TRUE;
+ if ( bIsRootNode )
+ {
+ if ( !( (aName.equals(user) || aName.equals(share) || aName.equals(currentDocTitle) ) ) )
+ bDisplay=FALSE;
+ }
+ if ( children[n].is() && children[n]->getType() != browse::BrowseNodeTypes::SCRIPT && bDisplay )
+ {
+
+ /*
+ We call acquire on the XBrowseNode so that it does not
+ get autodestructed and become invalid when accessed later.
+ */
+ theChild->acquire();
+
+ SfxGroupInfo_Impl* pGrpInfo =
+ new SfxGroupInfo_Impl(SFX_CFGGROUP_SCRIPTCONTAINER,
+ 0, static_cast<void *>( theChild.get()));
+
+ Image aImage = GetImage( theChild, Reference< XComponentContext >(), sal_False, BMP_COLOR_NORMAL );
+ SvLBoxEntry* pNewEntry =
+ InsertEntry( theChild->getName(), pEntry );
+ SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ aImage = GetImage( theChild, Reference< XComponentContext >(), sal_False, BMP_COLOR_HIGHCONTRAST );
+ SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+ SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+
+ pNewEntry->SetUserData( pGrpInfo );
+ aArr.Insert( pGrpInfo, aArr.Count() );
+
+ if ( children[n]->hasChildNodes() )
+ {
+ Sequence< Reference< browse::XBrowseNode > > grandchildren =
+ children[n]->getChildNodes();
+
+ for ( sal_Int32 m = 0; m < grandchildren.getLength(); m++ )
+ {
+ if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
+ {
+ pNewEntry->EnableChildsOnDemand( TRUE );
+ m = grandchildren.getLength();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (RuntimeException&) {
+ // do nothing, the entry will not be displayed in the UI
+ }
+ }
+ break;
+ }
+
+ case SFX_CFGGROUP_STYLES:
+ {
+ if ( !GetChildCount( pEntry ) )
+ {
+ const ::std::vector< SfxStyleInfo_Impl > lStyleFamilies = pStylesInfo->getStyleFamilies();
+ ::std::vector< SfxStyleInfo_Impl >::const_iterator pIt;
+ for ( pIt = lStyleFamilies.begin();
+ pIt != lStyleFamilies.end() ;
+ ++pIt )
+ {
+ SfxStyleInfo_Impl* pFamily = new SfxStyleInfo_Impl(*pIt);
+ SvLBoxEntry* pStyleEntry = InsertEntry( pFamily->sLabel, pEntry );
+ SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_STYLES, 0, pFamily );
+ aArr.Insert( pGrpInfo, aArr.Count() );
+ pStyleEntry->SetUserData( pGrpInfo );
+ pStyleEntry->EnableChildsOnDemand( FALSE );
+ }
+ }
+ break;
+ }
+
+ default:
+ DBG_ERROR( "Falscher Gruppentyp!" );
+ break;
+ }
+}
+
+void SfxConfigGroupListBox_Impl::AddAndSelect( const SfxStringItem* , const SfxStringItem* )
+{
+ /*
+ if ( pText )
+ {
+ Select( GetEntry( GetEntryCount()-1) );
+ SvLBoxEntry* pFuncEntry = pFunctionListBox->InsertEntry( pText->GetValue(), NULL );
+ SfxGroupInfo_Impl *pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGGROUP_SPECIALCHARACTERS, 0, 0 );
+ String aCommand = String::CreateFromAscii(".uno:InsertSymbol?Symbols:string=");
+ aCommand += pText->GetValue();
+ pFunctionListBox->aArr.Insert( pGrpInfo, pFunctionListBox->aArr.Count() );
+ pGrpInfo->sCommand = aCommand;
+ pGrpInfo->sLabel = String::CreateFromAscii("Symbols: ");
+ pGrpInfo->sLabel += pText->GetValue();
+ pFuncEntry->SetUserData( pGrpInfo );
+ }
+ */
+}
+
+void SfxConfigGroupListBox_Impl::SelectMacro( const SfxMacroInfoItem *pItem )
+{
+ SelectMacro( pItem->GetBasicManager()->GetName(),
+ pItem->GetQualifiedName() );
+}
+
+void SfxConfigGroupListBox_Impl::SelectMacro( const String& rBasic,
+ const String& rMacro )
+{
+ String aBasicName( rBasic );
+ aBasicName += ' ';
+ aBasicName += pImp->m_sMacros;
+ String aLib, aModule, aMethod;
+ USHORT nCount = rMacro.GetTokenCount('.');
+ aMethod = rMacro.GetToken( nCount-1, '.' );
+ if ( nCount > 2 )
+ {
+ aLib = rMacro.GetToken( 0, '.' );
+ aModule = rMacro.GetToken( nCount-2, '.' );
+ }
+
+ SvLBoxEntry *pEntry = FirstChild(0);
+ while ( pEntry )
+ {
+ String aEntryBas = GetEntryText( pEntry );
+ if ( aEntryBas == aBasicName )
+ {
+ Expand( pEntry );
+ SvLBoxEntry *pLib = FirstChild( pEntry );
+ while ( pLib )
+ {
+ String aEntryLib = GetEntryText( pLib );
+ if ( aEntryLib == aLib )
+ {
+ Expand( pLib );
+ SvLBoxEntry *pMod = FirstChild( pLib );
+ while ( pMod )
+ {
+ String aEntryMod = GetEntryText( pMod );
+ if ( aEntryMod == aModule )
+ {
+ Expand( pMod );
+ MakeVisible( pMod );
+ Select( pMod );
+ SvLBoxEntry *pMethod = pFunctionListBox->First();
+ while ( pMethod )
+ {
+ String aEntryMethod = GetEntryText( pMethod );
+ if ( aEntryMethod == aMethod )
+ {
+ pFunctionListBox->Select( pMethod );
+ pFunctionListBox->MakeVisible( pMethod );
+ return;
+ }
+ pMethod = pFunctionListBox->Next( pMethod );
+ }
+ }
+ pMod = NextSibling( pMod );
+ }
+ }
+ pLib = NextSibling( pLib );
+ }
+ }
+ pEntry = NextSibling( pEntry );
+ }
+}
diff --git a/cui/source/customize/eventdlg.cxx b/cui/source/customize/eventdlg.cxx
new file mode 100644
index 000000000000..8592dbaded5f
--- /dev/null
+++ b/cui/source/customize/eventdlg.cxx
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cui.hxx"
+
+// include ***************************************************************
+#include <svtools/svmedit.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/document/XEventsSupplier.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/documentinfo.hxx>
+#include <unotools/configmgr.hxx>
+#include <rtl/ustring.hxx>
+
+#include "eventdlg.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/evntconf.hxx>
+#include <sfx2/macrconf.hxx>
+#include <sfx2/minfitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <unotools/eventcfg.hxx>
+
+#include "headertablistbox.hxx"
+#include "macropg_impl.hxx"
+
+#include <dialmgr.hxx>
+#include <cuires.hrc>
+#include "eventdlg.hrc"
+#include "helpid.hrc"
+#include "selector.hxx"
+#include "cfg.hxx"
+
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+// -----------------------------------------------------------------------
+
+SvxEventConfigPage::SvxEventConfigPage( Window *pParent, const SfxItemSet& rSet, SvxEventConfigPage::EarlyInit ) :
+
+ _SvxMacroTabPage( pParent, CUI_RES(RID_SVXPAGE_EVENTS), rSet ),
+ aSaveInText( this, CUI_RES( TXT_SAVEIN ) ),
+ aSaveInListBox( this, CUI_RES( LB_SAVEIN ) ),
+ bAppConfig ( TRUE )
+{
+ mpImpl->pStrEvent = new String( CUI_RES( STR_EVENT ));
+ mpImpl->pAssignedMacro = new String( CUI_RES( STR_ASSMACRO ));
+ mpImpl->pEventLB = new _HeaderTabListBox( this, CUI_RES( LB_EVENT ));
+ mpImpl->pAssignFT = new FixedText( this, CUI_RES( FT_ASSIGN ));
+ mpImpl->pAssignPB = new PushButton( this, CUI_RES( PB_ASSIGN ));
+ mpImpl->pDeletePB = new PushButton( this, CUI_RES( PB_DELETE ));
+ mpImpl->pMacroImg = new Image( CUI_RES( IMG_MACRO) );
+ mpImpl->pComponentImg = new Image( CUI_RES( IMG_COMPONENT) );
+ mpImpl->pMacroImg_h = new Image( CUI_RES( IMG_MACRO_H) );
+ mpImpl->pComponentImg_h = new Image( CUI_RES( IMG_COMPONENT_H) );
+
+ FreeResource();
+
+ // must be done after FreeResource is called
+ InitResources();
+
+ mpImpl->pEventLB->GetListBox().SetHelpId( HID_SVX_MACRO_LB_EVENT );
+
+ aSaveInListBox.SetSelectHdl( LINK( this, SvxEventConfigPage,
+ SelectHdl_Impl ) );
+
+ uno::Reference< document::XEventsSupplier > xSupplier;
+
+// xSupplier = uno::Reference< document::XEventsSupplier >( new GlobalEventConfig());
+ xSupplier = uno::Reference< document::XEventsSupplier > (
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ OUString::createFromAscii(
+ "com.sun.star.frame.GlobalEventBroadcaster" ) ),
+ uno::UNO_QUERY );
+
+ USHORT nPos(0);
+ if ( xSupplier.is() )
+ {
+ m_xAppEvents = xSupplier->getEvents();
+ OUString label;
+ utl::ConfigManager::GetDirectConfigProperty(
+ utl::ConfigManager::PRODUCTNAME ) >>= label;
+ nPos = aSaveInListBox.InsertEntry( label );
+ aSaveInListBox.SetEntryData( nPos, new bool(true) );
+ aSaveInListBox.SelectEntryPos( nPos, TRUE );
+ }
+}
+
+// -----------------------------------------------------------------------
+void SvxEventConfigPage::LateInit( const uno::Reference< frame::XFrame >& _rxFrame )
+{
+ SetFrame( _rxFrame );
+ ImplInitDocument();
+
+ InitAndSetHandler( m_xAppEvents, m_xDocumentEvents, m_xDocumentModifiable );
+
+ SelectHdl_Impl( NULL );
+}
+
+// -----------------------------------------------------------------------
+
+SvxEventConfigPage::~SvxEventConfigPage()
+{
+ //DF Do I need to delete bools?
+}
+
+// -----------------------------------------------------------------------
+
+void SvxEventConfigPage::ImplInitDocument()
+{
+ uno::Reference< frame::XFrame > xFrame( GetFrame() );
+ OUString aModuleId = SvxConfigPage::GetFrameWithDefaultAndIdentify( xFrame );
+ if ( !xFrame.is() )
+ return;
+
+ try
+ {
+ uno::Reference< frame::XModel > xModel;
+ if ( !SvxConfigPage::CanConfig( aModuleId ) )
+ return;
+
+ uno::Reference< frame::XController > xController =
+ xFrame->getController();
+
+ if ( xController.is() )
+ {
+ xModel = xController->getModel();
+ }
+
+ if ( !xModel.is() )
+ return;
+
+ uno::Reference< document::XEventsSupplier > xSupplier( xModel, uno::UNO_QUERY );
+
+ if ( xSupplier.is() )
+ {
+ m_xDocumentEvents = xSupplier->getEvents();
+ m_xDocumentModifiable = m_xDocumentModifiable.query( xModel );
+
+ OUString aTitle = ::comphelper::DocumentInfo::getDocumentTitle( xModel );
+ USHORT nPos = aSaveInListBox.InsertEntry( aTitle );
+
+ aSaveInListBox.SetEntryData( nPos, new bool(false) );
+ aSaveInListBox.SelectEntryPos( nPos, TRUE );
+
+ bAppConfig = false;
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxEventConfigPage, SelectHdl_Impl, ListBox *, pBox )
+{
+ (void)pBox;
+
+ bool* bApp = (bool*) aSaveInListBox.GetEntryData(
+ aSaveInListBox.GetSelectEntryPos());
+
+ mpImpl->pEventLB->SetUpdateMode( FALSE );
+ bAppConfig = *bApp;
+ if ( *bApp )
+ {
+ SetReadOnly( FALSE );
+ _SvxMacroTabPage::DisplayAppEvents( true );
+ }
+ else
+ {
+ bool isReadonly = FALSE;
+
+ uno::Reference< frame::XFramesSupplier > xFramesSupplier(
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ),
+ uno::UNO_QUERY );
+
+ uno::Reference< frame::XFrame > xFrame =
+ xFramesSupplier->getActiveFrame();
+
+ if ( xFrame.is() )
+ {
+ uno::Reference< frame::XController > xController =
+ xFrame->getController();
+
+ if ( xController.is() )
+ {
+ uno::Reference< frame::XStorable > xStorable(
+ xController->getModel(), uno::UNO_QUERY );
+ isReadonly = xStorable->isReadonly();
+ }
+ }
+
+ SetReadOnly( isReadonly );
+ _SvxMacroTabPage::DisplayAppEvents( false );
+ }
+
+ mpImpl->pEventLB->SetUpdateMode( TRUE );
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxEventConfigPage::FillItemSet( SfxItemSet& rSet )
+{
+ return _SvxMacroTabPage::FillItemSet( rSet );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxEventConfigPage::Reset( const SfxItemSet& )
+{
+ _SvxMacroTabPage::Reset();
+}
+
diff --git a/cui/source/customize/eventdlg.hrc b/cui/source/customize/eventdlg.hrc
new file mode 100644
index 000000000000..8e482d83b97f
--- /dev/null
+++ b/cui/source/customize/eventdlg.hrc
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* StarView ressource header file */
+
+ ////DF temp to figure out what's needed from these
+//DF #include "sfx.hrc"
+#include <cuires.hrc>
+#include "macropg.hrc"
+
+#define TXT_SAVEIN 10
+#define LB_SAVEIN 11
+
+#define MB_CONFIG 17
+#define CB_WARNING 18
+#define CB_WARNING_ALWAYS 19
+#define GB_SAFETY 20
+#define ID_APP 21
+#define ID_DOC 22
diff --git a/cui/source/customize/eventdlg.hxx b/cui/source/customize/eventdlg.hxx
new file mode 100644
index 000000000000..dc2e657d65fb
--- /dev/null
+++ b/cui/source/customize/eventdlg.hxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EVENTDLG_HXX
+#define _EVENTDLG_HXX
+
+#include <vcl/menubtn.hxx>
+
+#include <vcl/fixed.hxx>
+#include <sfx2/evntconf.hxx>
+#include "macropg.hxx"
+
+#include <com/sun/star/frame/XFrame.hpp>
+
+class Menu;
+class SfxMacroInfoItem;
+class SvxMacroItem;
+
+class SvxEventConfigPage : public _SvxMacroTabPage
+{
+ FixedText aSaveInText;
+ ListBox aSaveInListBox;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xAppEvents;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xDocumentEvents;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifiable > m_xDocumentModifiable;
+
+ BOOL bAppConfig;
+
+ DECL_LINK( SelectHdl_Impl, ListBox* );
+
+ // Forbidden and not implemented.
+ SvxEventConfigPage (const SvxEventConfigPage &);
+ SvxEventConfigPage & operator= (const SvxEventConfigPage &);
+
+public:
+ /// this is only to let callers know that there is a LateInit which *must* be called
+ struct EarlyInit { };
+ SvxEventConfigPage( Window *pParent, const SfxItemSet& rSet, EarlyInit );
+ ~SvxEventConfigPage();
+
+ void LateInit( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame );
+
+protected:
+ virtual BOOL FillItemSet( SfxItemSet& );
+ virtual void Reset( const SfxItemSet& );
+ using _SvxMacroTabPage::Reset;
+
+private:
+ void ImplInitDocument();
+};
+
+
+#endif
+
diff --git a/cui/source/customize/eventdlg.src b/cui/source/customize/eventdlg.src
new file mode 100644
index 000000000000..e8c0e21677ac
--- /dev/null
+++ b/cui/source/customize/eventdlg.src
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "helpid.hrc"
+#include "eventdlg.hrc"
+
+#define MASKCOLOR MaskColor = \
+ Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+ // TP_CONFIG_EVENT -------------------------------------------------------
+TabPage RID_SVXPAGE_EVENTS
+{
+ HelpId = HID_SVX_CONFIG_EVENT ;
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 272 , 258 ) ;
+ String STR_EVENT
+ {
+ Text [ en-US ] = "Event" ;
+ };
+ String STR_ASSMACRO
+ {
+ Text [ en-US ] = "Assigned Action" ;
+ };
+ Control LB_EVENT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 205 , 229 ) ;
+ TabStop = TRUE ;
+ HelpID = HID_SVX_MACRO_LB_EVENT ;
+ };
+ FixedText TXT_SAVEIN
+ {
+ Pos = MAP_APPFONT ( 6 , 240 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Group = TRUE ;
+ Text [ en-US ] = "Save In" ;
+ };
+ ListBox LB_SAVEIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 54 , 238 ) ;
+ Size = MAP_APPFONT ( 132 , 53 ) ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 217, ROW0 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Assign:" ;
+ };
+ PushButton PB_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 217 , ROW0A ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Disable = TRUE ;
+ Text [ en-US ] = "M~acro..." ;
+ };
+ PushButton PB_DELETE
+ {
+ Pos = MAP_APPFONT ( 217 , ROW0A+RSC_CD_PUSHBUTTON_HEIGHT+12 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Disable = TRUE ;
+ Text [ en-US ] = "~Remove" ;
+ };
+ Image IMG_MACRO
+ {
+ ImageBitmap = Bitmap { File = "id018.png"; };
+ MASKCOLOR
+ };
+ Image IMG_COMPONENT
+ {
+ ImageBitmap = Bitmap { File = "component_16.png"; };
+ MASKCOLOR
+ };
+ Image IMG_MACRO_H
+ {
+ ImageBitmap = Bitmap { File = "idh018.png"; };
+ MASKCOLOR
+ };
+ Image IMG_COMPONENT_H
+ {
+ ImageBitmap = Bitmap { File = "component_16_h.png"; };
+ MASKCOLOR
+ };
+};
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
new file mode 100644
index 000000000000..9b5453553ef3
--- /dev/null
+++ b/cui/source/customize/macropg.cxx
@@ -0,0 +1,1054 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cui.hxx"
+#include <basic/basmgr.hxx>
+
+#include "macropg.hxx"
+#include <vcl/msgbox.hxx>
+#define _SVSTDARR_STRINGSDTOR
+#include <svl/svstdarr.hxx>
+#include <svtools/svmedit.hxx>
+#include <svl/eitem.hxx>
+#include <tools/diagnose_ex.h>
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/macrconf.hxx>
+#include <sfx2/sfxdefs.hxx>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <dialmgr.hxx>
+#include "selector.hxx"
+#include "cfg.hxx"
+#include "macropg.hrc"
+#include "helpid.hrc"
+#include <cuires.hrc>
+#include "headertablistbox.hxx"
+#include "macropg_impl.hxx"
+#include <svx/dialogs.hrc> // RID_SVXPAGE_MACROASSIGN
+#include <comphelper/namedvaluecollection.hxx>
+
+#include <algorithm>
+#include <set>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+static ::rtl::OUString aVndSunStarUNO =
+ ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" );
+static ::rtl::OUString aVndSunStarScript =
+ ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" );
+
+_SvxMacroTabPage_Impl::_SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet ) :
+ pAssignFT( NULL ),
+ pAssignPB( NULL ),
+ pAssignComponentPB( NULL ),
+ pDeletePB( NULL ),
+ pMacroImg( NULL ),
+ pComponentImg( NULL ),
+ pMacroImg_h( NULL ),
+ pComponentImg_h( NULL ),
+ pStrEvent( NULL ),
+ pAssignedMacro( NULL ),
+ pEventLB( NULL ),
+ bReadOnly( FALSE ),
+ bIDEDialogMode( FALSE )
+{
+ const SfxPoolItem* pItem;
+ if ( SFX_ITEM_SET == rAttrSet.GetItemState( SID_ATTR_MACROITEM, FALSE, &pItem ) )
+ bIDEDialogMode = ((const SfxBoolItem*)pItem)->GetValue();
+}
+
+_SvxMacroTabPage_Impl::~_SvxMacroTabPage_Impl()
+{
+ delete pAssignFT;
+ delete pAssignPB;
+ delete pAssignComponentPB;
+ delete pDeletePB;
+ delete pMacroImg;
+ delete pComponentImg;
+ delete pMacroImg_h;
+ delete pComponentImg_h;
+ delete pStrEvent;
+ delete pAssignedMacro;
+ delete pEventLB;
+}
+
+// Achtung im Code wird dieses Array direkt (0, 1, ...) indiziert
+static long nTabs[] =
+ {
+ 2, // Number of Tabs
+ 0, 90
+ };
+
+#define TAB_WIDTH_MIN 10
+
+// IDs for items in HeaderBar of EventLB
+#define ITEMID_EVENT 1
+#define ITMEID_ASSMACRO 2
+
+
+#define LB_EVENTS_ITEMPOS 1
+#define LB_MACROS_ITEMPOS 2
+
+
+IMPL_LINK( _HeaderTabListBox, HeaderEndDrag_Impl, HeaderBar*, pBar )
+{
+ DBG_ASSERT( pBar == &maHeaderBar, "*_HeaderTabListBox::HeaderEndDrag_Impl: something is wrong here..." );
+ (void)pBar;
+
+ if( !maHeaderBar.GetCurItemId() )
+ return 0;
+
+ if( !maHeaderBar.IsItemMode() )
+ {
+ Size aSz;
+ USHORT _nTabs = maHeaderBar.GetItemCount();
+ long nTmpSz = 0;
+ long nWidth = maHeaderBar.GetItemSize( ITEMID_EVENT );
+ long nBarWidth = maHeaderBar.GetSizePixel().Width();
+
+ if( nWidth < TAB_WIDTH_MIN )
+ maHeaderBar.SetItemSize( ITEMID_EVENT, TAB_WIDTH_MIN );
+ else if( ( nBarWidth - nWidth ) < TAB_WIDTH_MIN )
+ maHeaderBar.SetItemSize( ITEMID_EVENT, nBarWidth - TAB_WIDTH_MIN );
+
+ {
+ long _nWidth;
+ for( USHORT i = 1 ; i < _nTabs ; ++i )
+ {
+ _nWidth = maHeaderBar.GetItemSize( i );
+ aSz.Width() = _nWidth + nTmpSz;
+ nTmpSz += _nWidth;
+ maListBox.SetTab( i, PixelToLogic( aSz, MapMode( MAP_APPFONT ) ).Width(), MAP_APPFONT );
+ }
+ }
+ }
+ return 1;
+}
+
+long _HeaderTabListBox::Notify( NotifyEvent& rNEvt )
+{
+ long nRet = Control::Notify( rNEvt );
+
+ if( rNEvt.GetType() == EVENT_GETFOCUS )
+ {
+ if ( rNEvt.GetWindow() != &maListBox )
+ maListBox.GrabFocus();
+ }
+
+ return nRet;
+}
+
+_HeaderTabListBox::_HeaderTabListBox( Window* pParent, const ResId& rId ) :
+ Control( pParent, rId ),
+ maListBox( this, WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP ),
+ maHeaderBar( this, WB_BUTTONSTYLE | WB_BOTTOMBORDER )
+{
+ maListBox.SetHelpId( HID_MACRO_HEADERTABLISTBOX );
+}
+
+_HeaderTabListBox::~_HeaderTabListBox()
+{
+}
+
+void _HeaderTabListBox::ConnectElements( void )
+{
+ // calc pos and size of header bar
+ Point aPnt( 0, 0 );
+ Size aSize( maHeaderBar.CalcWindowSizePixel() );
+ Size aCtrlSize( GetOutputSizePixel() );
+ aSize.Width() = aCtrlSize.Width();
+ maHeaderBar.SetPosSizePixel( aPnt, aSize );
+
+ // calc pos and size of ListBox
+ aPnt.Y() += aSize.Height();
+ aSize.Height() = aCtrlSize.Height() - aSize.Height();
+ maListBox.SetPosSizePixel( aPnt, aSize );
+
+ // set handler
+ maHeaderBar.SetEndDragHdl( LINK( this, _HeaderTabListBox, HeaderEndDrag_Impl ) );
+
+ maListBox.InitHeaderBar( &maHeaderBar );
+}
+
+void _HeaderTabListBox::Show( BOOL bVisible, USHORT nFlags )
+{
+ maListBox.Show( bVisible, nFlags );
+ maHeaderBar.Show( bVisible, nFlags );
+}
+
+void _HeaderTabListBox::Enable( bool bEnable, bool bChild )
+{
+ maListBox.Enable( bEnable, bChild );
+ maHeaderBar.Enable( bEnable, bChild );
+}
+
+// assign button ("Add Command") is enabled only if it is not read only
+// delete button ("Remove Command") is enabled if a current binding exists
+// and it is not read only
+void _SvxMacroTabPage::EnableButtons( const String& /*rLangName*/ )
+{
+ const SvLBoxEntry* pE = mpImpl->pEventLB->GetListBox().FirstSelected();
+ if ( pE )
+ {
+ SvLBoxString* pEventMacro = (SvLBoxString*)pE->GetItem( LB_MACROS_ITEMPOS );
+ mpImpl->pDeletePB->Enable( 0 != pEventMacro && !mpImpl->bReadOnly );
+
+ mpImpl->pAssignPB->Enable( !mpImpl->bReadOnly );
+ if( mpImpl->pAssignComponentPB )
+ mpImpl->pAssignComponentPB->Enable( !mpImpl->bReadOnly );
+ }
+}
+
+_SvxMacroTabPage::_SvxMacroTabPage( Window* pParent, const ResId& rResId, const SfxItemSet& rAttrSet )
+ : SfxTabPage( pParent, rResId, rAttrSet ),
+ m_xAppEvents(0),
+ m_xDocEvents(0),
+ bReadOnly(false),
+ bDocModified(false),
+ bAppEvents(false),
+ bInitialized(false)
+{
+ mpImpl = new _SvxMacroTabPage_Impl( rAttrSet );
+}
+
+_SvxMacroTabPage::~_SvxMacroTabPage()
+{
+ // need to delete the user data
+ SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
+ SvLBoxEntry* pE = rListBox.GetEntry( 0 );
+ while( pE )
+ {
+ ::rtl::OUString* pEventName = (::rtl::OUString*)pE->GetUserData();
+ delete pEventName;
+ pE->SetUserData((void*)0);
+ pE = rListBox.NextSibling( pE );
+ }
+ DELETEZ( mpImpl );
+}
+// -----------------------------------------------------------------------------
+void _SvxMacroTabPage::InitResources()
+{
+ // Note: the order here controls the order in which the events are displayed in the UI!
+
+ // the event name to UI string mappings for App Events
+ aDisplayNames.push_back( EventDisplayName( "OnStartApp", RID_SVXSTR_EVENT_STARTAPP ) );
+ aDisplayNames.push_back( EventDisplayName( "OnCloseApp", RID_SVXSTR_EVENT_CLOSEAPP ) );
+ aDisplayNames.push_back( EventDisplayName( "OnCreate", RID_SVXSTR_EVENT_CREATEDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnNew", RID_SVXSTR_EVENT_NEWDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnLoadFinished", RID_SVXSTR_EVENT_LOADDOCFINISHED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnLoad", RID_SVXSTR_EVENT_OPENDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnPrepareUnload", RID_SVXSTR_EVENT_PREPARECLOSEDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnUnload", RID_SVXSTR_EVENT_CLOSEDOC ) ) ;
+ aDisplayNames.push_back( EventDisplayName( "OnViewCreated", RID_SVXSTR_EVENT_VIEWCREATED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnPrepareViewClosing", RID_SVXSTR_EVENT_PREPARECLOSEVIEW ) );
+ aDisplayNames.push_back( EventDisplayName( "OnViewClosed", RID_SVXSTR_EVENT_CLOSEVIEW ) ) ;
+ aDisplayNames.push_back( EventDisplayName( "OnFocus", RID_SVXSTR_EVENT_ACTIVATEDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnUnfocus", RID_SVXSTR_EVENT_DEACTIVATEDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSave", RID_SVXSTR_EVENT_SAVEDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSaveDone", RID_SVXSTR_EVENT_SAVEDOCDONE ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSaveFailed", RID_SVXSTR_EVENT_SAVEDOCFAILED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSaveAs", RID_SVXSTR_EVENT_SAVEASDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSaveAsDone", RID_SVXSTR_EVENT_SAVEASDOCDONE ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSaveAsFailed", RID_SVXSTR_EVENT_SAVEASDOCFAILED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnCopyTo", RID_SVXSTR_EVENT_COPYTODOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnCopyToDone", RID_SVXSTR_EVENT_COPYTODOCDONE ) );
+ aDisplayNames.push_back( EventDisplayName( "OnCopyToFailed", RID_SVXSTR_EVENT_COPYTODOCFAILED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnPrint", RID_SVXSTR_EVENT_PRINTDOC ) );
+ aDisplayNames.push_back( EventDisplayName( "OnModifyChanged", RID_SVXSTR_EVENT_MODIFYCHANGED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnTitleChanged", RID_SVXSTR_EVENT_TITLECHANGED ) );
+// aDisplayNames.push_back( EventDisplayName( "OnModeChanged", RID_SVXSTR_EVENT_MODECHANGED ) );
+// aDisplayNames.push_back( EventDisplayName( "OnVisAreaChanged", RID_SVXSTR_EVENT_VISAREACHANGED ) );
+// aDisplayNames.push_back( EventDisplayName( "OnStorageChanged", RID_SVXSTR_EVENT_STORAGECHANGED ) );
+
+ // application specific events
+ aDisplayNames.push_back( EventDisplayName( "OnMailMerge", RID_SVXSTR_EVENT_MAILMERGE ) );
+ aDisplayNames.push_back( EventDisplayName( "OnMailMergeFinished", RID_SVXSTR_EVENT_MAILMERGE_END ) );
+ aDisplayNames.push_back( EventDisplayName( "OnFieldMerge", RID_SVXSTR_EVENT_FIELDMERGE ) );
+ aDisplayNames.push_back( EventDisplayName( "OnFieldMergeFinished", RID_SVXSTR_EVENT_FIELDMERGE_FINISHED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnPageCountChange", RID_SVXSTR_EVENT_PAGECOUNTCHANGE ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSubComponentOpened", RID_SVXSTR_EVENT_SUBCOMPONENT_OPENED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSubComponentClosed", RID_SVXSTR_EVENT_SUBCOMPONENT_CLOSED ) );
+// aDisplayNames.push_back( EventDisplayName( "OnLayoutFinished", RID_SVXSTR_EVENT_LAYOUT_FINISHED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnSelect", RID_SVXSTR_EVENT_SELECTIONCHANGED ) );
+ aDisplayNames.push_back( EventDisplayName( "OnDoubleClick", RID_SVXSTR_EVENT_DOUBLECLICK ) );
+ aDisplayNames.push_back( EventDisplayName( "OnRightClick", RID_SVXSTR_EVENT_RIGHTCLICK ) );
+ aDisplayNames.push_back( EventDisplayName( "OnCalculate", RID_SVXSTR_EVENT_CALCULATE ) );
+ aDisplayNames.push_back( EventDisplayName( "OnChange", RID_SVXSTR_EVENT_CONTENTCHANGED ) );
+
+ // the event name to UI string mappings for forms & dialogs
+ //
+ aDisplayNames.push_back( EventDisplayName( "approveAction", RID_SVXSTR_EVENT_APPROVEACTIONPERFORMED ) );
+ aDisplayNames.push_back( EventDisplayName( "actionPerformed", RID_SVXSTR_EVENT_ACTIONPERFORMED ) );
+ aDisplayNames.push_back( EventDisplayName( "changed", RID_SVXSTR_EVENT_CHANGED ) );
+ aDisplayNames.push_back( EventDisplayName( "textChanged", RID_SVXSTR_EVENT_TEXTCHANGED ) );
+ aDisplayNames.push_back( EventDisplayName( "itemStateChanged", RID_SVXSTR_EVENT_ITEMSTATECHANGED ) );
+ aDisplayNames.push_back( EventDisplayName( "focusGained", RID_SVXSTR_EVENT_FOCUSGAINED ) );
+ aDisplayNames.push_back( EventDisplayName( "focusLost", RID_SVXSTR_EVENT_FOCUSLOST ) );
+ aDisplayNames.push_back( EventDisplayName( "keyPressed", RID_SVXSTR_EVENT_KEYTYPED ) );
+ aDisplayNames.push_back( EventDisplayName( "keyReleased", RID_SVXSTR_EVENT_KEYUP ) );
+ aDisplayNames.push_back( EventDisplayName( "mouseEntered", RID_SVXSTR_EVENT_MOUSEENTERED ) );
+ aDisplayNames.push_back( EventDisplayName( "mouseDragged", RID_SVXSTR_EVENT_MOUSEDRAGGED ) );
+ aDisplayNames.push_back( EventDisplayName( "mouseMoved", RID_SVXSTR_EVENT_MOUSEMOVED ) );
+ aDisplayNames.push_back( EventDisplayName( "mousePressed", RID_SVXSTR_EVENT_MOUSEPRESSED ) );
+ aDisplayNames.push_back( EventDisplayName( "mouseReleased", RID_SVXSTR_EVENT_MOUSERELEASED ) );
+ aDisplayNames.push_back( EventDisplayName( "mouseExited", RID_SVXSTR_EVENT_MOUSEEXITED ) );
+ aDisplayNames.push_back( EventDisplayName( "approveReset", RID_SVXSTR_EVENT_APPROVERESETTED ) );
+ aDisplayNames.push_back( EventDisplayName( "resetted", RID_SVXSTR_EVENT_RESETTED ) );
+ aDisplayNames.push_back( EventDisplayName( "approveSubmit", RID_SVXSTR_EVENT_SUBMITTED ) );
+ aDisplayNames.push_back( EventDisplayName( "approveUpdate", RID_SVXSTR_EVENT_BEFOREUPDATE ) );
+ aDisplayNames.push_back( EventDisplayName( "updated", RID_SVXSTR_EVENT_AFTERUPDATE ) );
+ aDisplayNames.push_back( EventDisplayName( "loaded", RID_SVXSTR_EVENT_LOADED ) );
+ aDisplayNames.push_back( EventDisplayName( "reloading", RID_SVXSTR_EVENT_RELOADING ) );
+ aDisplayNames.push_back( EventDisplayName( "reloaded", RID_SVXSTR_EVENT_RELOADED ) );
+ aDisplayNames.push_back( EventDisplayName( "unloading", RID_SVXSTR_EVENT_UNLOADING ) );
+ aDisplayNames.push_back( EventDisplayName( "unloaded", RID_SVXSTR_EVENT_UNLOADED ) );
+ aDisplayNames.push_back( EventDisplayName( "confirmDelete", RID_SVXSTR_EVENT_CONFIRMDELETE ) );
+ aDisplayNames.push_back( EventDisplayName( "approveRowChange", RID_SVXSTR_EVENT_APPROVEROWCHANGE ) );
+ aDisplayNames.push_back( EventDisplayName( "rowChanged", RID_SVXSTR_EVENT_ROWCHANGE ) );
+ aDisplayNames.push_back( EventDisplayName( "approveCursorMove", RID_SVXSTR_EVENT_POSITIONING ) );
+ aDisplayNames.push_back( EventDisplayName( "cursorMoved", RID_SVXSTR_EVENT_POSITIONED ) );
+ aDisplayNames.push_back( EventDisplayName( "approveParameter", RID_SVXSTR_EVENT_APPROVEPARAMETER ) );
+ aDisplayNames.push_back( EventDisplayName( "errorOccured", RID_SVXSTR_EVENT_ERROROCCURED ) );
+ aDisplayNames.push_back( EventDisplayName( "adjustmentValueChanged", RID_SVXSTR_EVENT_ADJUSTMENTVALUECHANGED ) );
+}
+
+// the following method is called when the user clicks OK
+// We use the contents of the hashes to replace the settings
+BOOL _SvxMacroTabPage::FillItemSet( SfxItemSet& /*rSet*/ )
+{
+ try
+ {
+ ::rtl::OUString eventName;
+ if( m_xAppEvents.is() )
+ {
+ EventsHash::iterator h_itEnd = m_appEventsHash.end();
+ EventsHash::iterator h_it = m_appEventsHash.begin();
+ for ( ; h_it != h_itEnd; ++h_it )
+ {
+ eventName = h_it->first;
+ try
+ {
+ m_xAppEvents->replaceByName( eventName, GetPropsByName( eventName, m_appEventsHash ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ if( m_xDocEvents.is() && bDocModified )
+ {
+ EventsHash::iterator h_itEnd = m_docEventsHash.end();
+ EventsHash::iterator h_it = m_docEventsHash.begin();
+ for ( ; h_it != h_itEnd; ++h_it )
+ {
+ eventName = h_it->first;
+ try
+ {
+ m_xDocEvents->replaceByName( eventName, GetPropsByName( eventName, m_docEventsHash ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ // if we have a valid XModifiable (in the case of doc events)
+ // call setModified(true)
+ // in principle this should not be necessary (see issue ??)
+ if(m_xModifiable.is())
+ {
+ m_xModifiable->setModified( sal_True );
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ // what is the return value about??
+ return FALSE;
+}
+
+// the following method clears the bindings in the hashes for both doc & app
+void _SvxMacroTabPage::Reset()
+{
+ // called once in creation - don't reset the data this time
+ if(!bInitialized)
+ {
+ bInitialized = true;
+ return;
+ }
+
+ try
+ {
+ ::rtl::OUString sEmpty;
+ if( m_xAppEvents.is() )
+ {
+ EventsHash::iterator h_itEnd = m_appEventsHash.end();
+ EventsHash::iterator h_it = m_appEventsHash.begin();
+ for ( ; h_it != h_itEnd; ++h_it )
+ {
+ h_it->second.second = sEmpty;
+ }
+ }
+ if( m_xDocEvents.is() && bDocModified )
+ {
+ EventsHash::iterator h_itEnd = m_docEventsHash.end();
+ EventsHash::iterator h_it = m_docEventsHash.begin();
+ for ( ; h_it != h_itEnd; ++h_it )
+ {
+ h_it->second.second = sEmpty;
+ }
+ // if we have a valid XModifiable (in the case of doc events)
+ // call setModified(true)
+ if(m_xModifiable.is())
+ {
+ m_xModifiable->setModified( sal_True );
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ DisplayAppEvents(bAppEvents);
+}
+
+void _SvxMacroTabPage::SetReadOnly( BOOL bSet )
+{
+ mpImpl->bReadOnly = bSet;
+}
+
+BOOL _SvxMacroTabPage::IsReadOnly() const
+{
+ return mpImpl->bReadOnly;
+}
+
+
+class IconLBoxString : public SvLBoxString
+{
+ Image* m_pMacroImg;
+ Image* m_pComponentImg;
+ Image* m_pMacroImg_h;
+ Image* m_pComponentImg_h;
+ int m_nxImageOffset;
+
+ public:
+ IconLBoxString( SvLBoxEntry* pEntry, USHORT nFlags, const String& sText,
+ Image* pMacroImg, Image* pComponentImg,
+ Image* pMacroImg_h, Image* pComponentImg_h );
+ virtual void Paint(const Point& aPos, SvLBox& aDevice, USHORT nFlags, SvLBoxEntry* pEntry );
+};
+
+
+IconLBoxString::IconLBoxString( SvLBoxEntry* pEntry, USHORT nFlags, const String& sText,
+ Image* pMacroImg, Image* pComponentImg, Image* pMacroImg_h, Image* pComponentImg_h )
+ : SvLBoxString( pEntry, nFlags, sText )
+ , m_pMacroImg( pMacroImg )
+ , m_pComponentImg( pComponentImg )
+ , m_pMacroImg_h( pMacroImg_h )
+ , m_pComponentImg_h( pComponentImg_h )
+{
+ m_nxImageOffset = 20;
+}
+
+//===============================================
+void IconLBoxString::Paint( const Point& aPos, SvLBox& aDevice,
+ USHORT /*nFlags*/, SvLBoxEntry* /*pEntry*/ )
+{
+ String aTxt( GetText() );
+ if( aTxt.Len() )
+ {
+ ::rtl::OUString aURL( aTxt );
+ sal_Int32 nIndex = aURL.indexOf( aVndSunStarUNO );
+ bool bUNO = nIndex == 0;
+
+ BOOL bHC = aDevice.GetSettings().GetStyleSettings().GetHighContrastMode();
+ const Image* pImg;
+ if( bHC )
+ pImg = bUNO ? m_pComponentImg_h : m_pMacroImg_h;
+ else
+ pImg = bUNO ? m_pComponentImg : m_pMacroImg;
+ aDevice.DrawImage( aPos, *pImg );
+
+ ::rtl::OUString aPureMethod;
+ if( bUNO )
+ {
+ sal_Int32 nBegin = aVndSunStarUNO.getLength();
+ aPureMethod = aURL.copy( nBegin );
+ }
+ else
+ {
+ sal_Int32 nBegin = aVndSunStarScript.getLength();
+ aPureMethod = aURL.copy( nBegin );
+ aPureMethod = aPureMethod.copy( 0, aPureMethod.indexOf( '?' ) );
+ }
+
+ Point aPnt(aPos);
+ aPnt.X() += m_nxImageOffset;
+ aDevice.DrawText( aPnt, aPureMethod );
+ }
+}
+
+
+// displays the app events if appEvents=true, otherwise displays the doc events
+void _SvxMacroTabPage::DisplayAppEvents( bool appEvents)
+{
+ bAppEvents = appEvents;
+
+ SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
+ mpImpl->pEventLB->SetUpdateMode( FALSE );
+ rListBox.Clear();
+ SvLBoxEntry* pE = rListBox.GetEntry( 0 );
+ EventsHash* eventsHash;
+ Reference< container::XNameReplace> nameReplace;
+ if(bAppEvents)
+ {
+ eventsHash = &m_appEventsHash;
+ nameReplace = m_xAppEvents;
+ }
+ else
+ {
+ eventsHash = &m_docEventsHash;
+ nameReplace = m_xDocEvents;
+ }
+ // have to use the original XNameReplace since the hash iterators do
+ // not guarantee the order in which the elements are returned
+ if(!nameReplace.is())
+ {
+ return;
+ }
+
+ Sequence< ::rtl::OUString > eventNames = nameReplace->getElementNames();
+ ::std::set< ::rtl::OUString > aEventNamesCache;
+ ::std::copy(
+ eventNames.getConstArray(),
+ eventNames.getConstArray() + eventNames.getLength(),
+ ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aEventNamesCache, aEventNamesCache.end() )
+ );
+
+ for ( EventDisplayNames::const_iterator displayableEvent = aDisplayNames.begin();
+ displayableEvent != aDisplayNames.end();
+ ++displayableEvent
+ )
+ {
+ ::rtl::OUString sEventName( ::rtl::OUString::createFromAscii( displayableEvent->pAsciiEventName ) );
+ if ( !nameReplace->hasByName( sEventName ) )
+ continue;
+
+ EventsHash::iterator h_it = eventsHash->find( sEventName );
+ if( h_it == eventsHash->end() )
+ {
+ OSL_ENSURE( false, "_SvxMacroTabPage::DisplayAppEvents: something's suspicious here!" );
+ continue;
+ }
+
+ ::rtl::OUString eventURL = h_it->second.second;
+ String displayName( CUI_RES( displayableEvent->nEventResourceID ) );
+
+ displayName += '\t';
+ SvLBoxEntry* _pE = rListBox.InsertEntry( displayName );
+ ::rtl::OUString* pEventName = new ::rtl::OUString( sEventName );
+ _pE->SetUserData( (void*)pEventName );
+ String sNew( eventURL );
+ _pE->ReplaceItem( new IconLBoxString( _pE, 0, sNew,
+ mpImpl->pMacroImg, mpImpl->pComponentImg,
+ mpImpl->pMacroImg_h, mpImpl->pComponentImg_h ), LB_MACROS_ITEMPOS );
+ rListBox.GetModel()->InvalidateEntry( _pE );
+ rListBox.Select( _pE );
+ rListBox.MakeVisible( _pE );
+ }
+
+ pE = rListBox.GetEntry(0);
+ if( pE )
+ {
+ rListBox.Select( pE );
+ rListBox.MakeVisible( pE );
+ }
+
+ rListBox.SetUpdateMode( TRUE );
+ EnableButtons( String() );
+}
+
+// select event handler on the listbox
+IMPL_STATIC_LINK( _SvxMacroTabPage, SelectEvent_Impl, SvTabListBox*, EMPTYARG )
+{
+ _SvxMacroTabPage_Impl* pImpl = pThis->mpImpl;
+ SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox();
+ SvLBoxEntry* pE = rListBox.FirstSelected();
+ ULONG nPos;
+
+ if( !pE || LISTBOX_ENTRY_NOTFOUND ==
+ ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) )
+ {
+ DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
+ return 0;
+ }
+
+ pThis->EnableButtons( String() );
+ return 0;
+}
+
+IMPL_STATIC_LINK( _SvxMacroTabPage, AssignDeleteHdl_Impl, PushButton*, pBtn )
+{
+ return GenericHandler_Impl( pThis, pBtn );
+}
+
+IMPL_STATIC_LINK( _SvxMacroTabPage, DoubleClickHdl_Impl, SvTabListBox *, EMPTYARG )
+{
+ return GenericHandler_Impl( pThis, NULL );
+}
+
+// handler for double click on the listbox, and for the assign/delete buttons
+long _SvxMacroTabPage::GenericHandler_Impl( _SvxMacroTabPage* pThis, PushButton* pBtn )
+{
+ _SvxMacroTabPage_Impl* pImpl = pThis->mpImpl;
+ SvHeaderTabListBox& rListBox = pImpl->pEventLB->GetListBox();
+ SvLBoxEntry* pE = rListBox.FirstSelected();
+ ULONG nPos;
+ if( !pE || LISTBOX_ENTRY_NOTFOUND ==
+ ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) )
+ {
+ DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" );
+ return 0;
+ }
+
+ const BOOL bAssEnabled = pBtn != pImpl->pDeletePB && pImpl->pAssignPB->IsEnabled();
+
+ ::rtl::OUString* pEventName = (::rtl::OUString*)pE->GetUserData();
+
+ ::rtl::OUString sEventURL;
+ ::rtl::OUString sEventType;
+ if(pThis->bAppEvents)
+ {
+ EventsHash::iterator h_it = pThis->m_appEventsHash.find( *pEventName );
+ if(h_it != pThis->m_appEventsHash.end() )
+ {
+ sEventType = h_it->second.first;
+ sEventURL = h_it->second.second;
+ }
+ }
+ else
+ {
+ EventsHash::iterator h_it = pThis->m_docEventsHash.find( *pEventName );
+ if(h_it != pThis->m_docEventsHash.end() )
+ {
+ sEventType = h_it->second.first;
+ sEventURL = h_it->second.second;
+ }
+ }
+
+ bool bDoubleClick = (pBtn == NULL);
+ bool bUNOAssigned = (sEventURL.indexOf( aVndSunStarUNO ) == 0);
+ if( pBtn == pImpl->pDeletePB )
+ {
+ // delete pressed
+ sEventType = ::rtl::OUString::createFromAscii("Script");
+ sEventURL = ::rtl::OUString();
+ if(!pThis->bAppEvents)
+ pThis->bDocModified = true;
+ }
+ else if ( ( ( pBtn != NULL )
+ && ( pBtn == pImpl->pAssignComponentPB )
+ )
+ || ( bDoubleClick
+ && bUNOAssigned
+ )
+ )
+ {
+ AssignComponentDialog* pAssignDlg = new AssignComponentDialog( pThis, sEventURL );
+
+ short ret = pAssignDlg->Execute();
+ if( ret )
+ {
+ sEventType = ::rtl::OUString::createFromAscii("UNO");
+ sEventURL = pAssignDlg->getURL();
+ if(!pThis->bAppEvents)
+ pThis->bDocModified = true;
+ }
+ delete pAssignDlg;
+ }
+ else if( bAssEnabled )
+ {
+ // assign pressed
+ SvxScriptSelectorDialog* pDlg = new SvxScriptSelectorDialog( pThis, FALSE, pThis->GetFrame() );
+ if( pDlg )
+ {
+ short ret = pDlg->Execute();
+ if ( ret )
+ {
+ sEventType = ::rtl::OUString::createFromAscii("Script");
+ sEventURL = pDlg->GetScriptURL();
+ if(!pThis->bAppEvents)
+ pThis->bDocModified = true;
+ }
+ }
+ }
+
+ // update the hashes
+ if(pThis->bAppEvents)
+ {
+ EventsHash::iterator h_it = pThis->m_appEventsHash.find( *pEventName );
+ h_it->second.first = sEventType;
+ h_it->second.second = sEventURL;
+ }
+ else
+ {
+ EventsHash::iterator h_it = pThis->m_docEventsHash.find( *pEventName );
+ h_it->second.first = sEventType;
+ h_it->second.second = sEventURL;
+ }
+
+ // update the listbox entry
+ pImpl->pEventLB->SetUpdateMode( FALSE );
+ // pE->ReplaceItem( new SvLBoxString( pE, 0, sEventURL ), LB_MACROS_ITEMPOS );
+ pE->ReplaceItem( new IconLBoxString( pE, 0, sEventURL,
+ pImpl->pMacroImg, pImpl->pComponentImg,
+ pImpl->pMacroImg_h, pImpl->pComponentImg_h ), LB_MACROS_ITEMPOS );
+
+ rListBox.GetModel()->InvalidateEntry( pE );
+ rListBox.Select( pE );
+ rListBox.MakeVisible( pE );
+ rListBox.SetUpdateMode( TRUE );
+
+ pThis->EnableButtons( String() );
+ return 0;
+}
+
+// pass in the XNameReplace.
+// can remove the 3rd arg once issue ?? is fixed
+void _SvxMacroTabPage::InitAndSetHandler( Reference< container::XNameReplace> xAppEvents, Reference< container::XNameReplace> xDocEvents, Reference< util::XModifiable > xModifiable )
+{
+ m_xAppEvents = xAppEvents;
+ m_xDocEvents = xDocEvents;
+ m_xModifiable = xModifiable;
+ SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
+ HeaderBar& rHeaderBar = mpImpl->pEventLB->GetHeaderBar();
+ Link aLnk(STATIC_LINK(this, _SvxMacroTabPage, AssignDeleteHdl_Impl ));
+ mpImpl->pDeletePB->SetClickHdl( aLnk );
+ mpImpl->pAssignPB->SetClickHdl( aLnk );
+ if( mpImpl->pAssignComponentPB )
+ mpImpl->pAssignComponentPB->SetClickHdl( aLnk );
+ rListBox.SetDoubleClickHdl( STATIC_LINK(this, _SvxMacroTabPage, DoubleClickHdl_Impl ) );
+
+ rListBox.SetSelectHdl( STATIC_LINK( this, _SvxMacroTabPage, SelectEvent_Impl ));
+
+ rListBox.SetSelectionMode( SINGLE_SELECTION );
+ rListBox.SetTabs( &nTabs[0], MAP_APPFONT );
+ Size aSize( nTabs[ 2 ], 0 );
+ rHeaderBar.InsertItem( ITEMID_EVENT, *mpImpl->pStrEvent, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() );
+ aSize.Width() = 1764; // don't know what, so 42^2 is best to use...
+ rHeaderBar.InsertItem( ITMEID_ASSMACRO, *mpImpl->pAssignedMacro, LogicToPixel( aSize, MapMode( MAP_APPFONT ) ).Width() );
+ rListBox.SetSpaceBetweenEntries( 0 );
+
+ mpImpl->pEventLB->Show();
+ mpImpl->pEventLB->ConnectElements();
+
+ long nMinLineHeight = mpImpl->pMacroImg->GetSizePixel().Height() + 2;
+ if( nMinLineHeight > mpImpl->pEventLB->GetListBox().GetEntryHeight() )
+ mpImpl->pEventLB->GetListBox().SetEntryHeight(
+ sal::static_int_cast< short >(nMinLineHeight) );
+
+ mpImpl->pEventLB->Enable( TRUE );
+
+ if(!m_xAppEvents.is())
+ {
+ return;
+ }
+ Sequence< ::rtl::OUString > eventNames = m_xAppEvents->getElementNames();
+ sal_Int32 nEventCount = eventNames.getLength();
+ for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent )
+ {
+ //need exception handling here
+ try
+ {
+ m_appEventsHash[ eventNames[nEvent] ] = GetPairFromAny( m_xAppEvents->getByName( eventNames[nEvent] ) );
+ }
+ catch (Exception e)
+ {}
+ }
+ if(m_xDocEvents.is())
+ {
+ eventNames = m_xDocEvents->getElementNames();
+ nEventCount = eventNames.getLength();
+ for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent )
+ {
+ try
+ {
+ m_docEventsHash[ eventNames[nEvent] ] = GetPairFromAny( m_xDocEvents->getByName( eventNames[nEvent] ) );
+ }
+ catch (Exception e)
+ {}
+ }
+ }
+}
+
+// returns the two props EventType & Script for a given event name
+Any _SvxMacroTabPage::GetPropsByName( const ::rtl::OUString& eventName, EventsHash& eventsHash )
+{
+ const ::std::pair< ::rtl::OUString, ::rtl::OUString >& rAssignedEvent( eventsHash[ eventName ] );
+
+ Any aReturn;
+ ::comphelper::NamedValueCollection aProps;
+ if ( rAssignedEvent.first.getLength() && rAssignedEvent.second.getLength() )
+ {
+ aProps.put( "EventType", rAssignedEvent.first );
+ aProps.put( "Script", rAssignedEvent.second );
+ }
+ aReturn <<= aProps.getPropertyValues();
+
+ return aReturn;
+}
+
+// converts the Any returned by GetByName into a pair which can be stored in
+// the EventHash
+::std::pair< ::rtl::OUString, ::rtl::OUString > _SvxMacroTabPage::GetPairFromAny( Any aAny )
+{
+ Sequence< beans::PropertyValue > props;
+ ::rtl::OUString type, url;
+ if( sal_True == ( aAny >>= props ) )
+ {
+ ::comphelper::NamedValueCollection aProps( props );
+ type = aProps.getOrDefault( "EventType", type );
+ url = aProps.getOrDefault( "Script", url );
+ }
+ return ::std::make_pair( type, url );
+}
+
+SvxMacroTabPage::SvxMacroTabPage( Window* pParent, const Reference< frame::XFrame >& _rxDocumentFrame, const SfxItemSet& rSet, Reference< container::XNameReplace > xNameReplace, sal_uInt16 nSelectedIndex )
+ : _SvxMacroTabPage( pParent, CUI_RES( RID_SVXPAGE_MACROASSIGN ), rSet )
+{
+ mpImpl->pStrEvent = new String( CUI_RES( STR_EVENT ) );
+ mpImpl->pAssignedMacro = new String( CUI_RES( STR_ASSMACRO ) );
+ mpImpl->pEventLB = new _HeaderTabListBox( this, CUI_RES( LB_EVENT ) );
+ mpImpl->pAssignFT = new FixedText( this, CUI_RES( FT_ASSIGN ) );
+ mpImpl->pAssignPB = new PushButton( this, CUI_RES( PB_ASSIGN ) );
+ mpImpl->pDeletePB = new PushButton( this, CUI_RES( PB_DELETE ) );
+ mpImpl->pAssignComponentPB = new PushButton( this, CUI_RES( PB_ASSIGN_COMPONENT ) );
+ mpImpl->pMacroImg = new Image( CUI_RES(IMG_MACRO) );
+ mpImpl->pComponentImg = new Image( CUI_RES(IMG_COMPONENT) );
+ mpImpl->pMacroImg_h = new Image( CUI_RES(IMG_MACRO_H) );
+ mpImpl->pComponentImg_h = new Image( CUI_RES(IMG_COMPONENT_H) );
+
+ FreeResource();
+
+ SetFrame( _rxDocumentFrame );
+
+ if( !mpImpl->bIDEDialogMode )
+ {
+ // Size aSizeAssign;
+ // Point aPosAssign;
+ // mpImpl->pAssignPB->GetPosSizePixel( aPosAssign, aSizeAssign );
+ Point aPosAssign = mpImpl->pAssignPB->GetPosPixel();
+ Point aPosComp = mpImpl->pAssignComponentPB->GetPosPixel();
+
+ Point aPosDelete = mpImpl->pDeletePB->GetPosPixel();
+ long nYDiff = aPosComp.Y() - aPosAssign.Y();
+ aPosDelete.Y() -= nYDiff;
+ mpImpl->pDeletePB->SetPosPixel( aPosDelete );
+
+ mpImpl->pAssignComponentPB->Hide();
+ mpImpl->pAssignComponentPB->Disable();
+ }
+
+ // must be done after FreeResource is called
+ InitResources();
+
+ mpImpl->pEventLB->GetListBox().SetHelpId( HID_SVX_MACRO_LB_EVENT );
+
+ InitAndSetHandler( xNameReplace, Reference< container::XNameReplace>(0), Reference< util::XModifiable >(0));
+ DisplayAppEvents(true);
+ SvHeaderTabListBox& rListBox = mpImpl->pEventLB->GetListBox();
+ SvLBoxEntry* pE = rListBox.GetEntry( (ULONG)nSelectedIndex );
+ if( pE )
+ rListBox.Select(pE);
+}
+
+SvxMacroTabPage::~SvxMacroTabPage()
+{
+}
+
+SvxMacroAssignDlg::SvxMacroAssignDlg( Window* pParent, const Reference< frame::XFrame >& _rxDocumentFrame, const SfxItemSet& rSet,
+ const Reference< container::XNameReplace >& xNameReplace, sal_uInt16 nSelectedIndex )
+ : SvxMacroAssignSingleTabDialog( pParent, rSet, 0 )
+{
+ SetTabPage( new SvxMacroTabPage( this, _rxDocumentFrame, rSet, xNameReplace, nSelectedIndex ) );
+}
+
+SvxMacroAssignDlg::~SvxMacroAssignDlg()
+{
+}
+
+
+//===============================================
+
+IMPL_LINK(AssignComponentDialog, ButtonHandler, Button *, EMPTYARG)
+{
+ ::rtl::OUString aMethodName = maMethodEdit.GetText();
+ maURL = ::rtl::OUString();
+ if( aMethodName.getLength() )
+ {
+ maURL = aVndSunStarUNO;
+ maURL += aMethodName;
+ }
+ EndDialog(1);
+ return 0;
+}
+
+AssignComponentDialog::AssignComponentDialog( Window * pParent, const ::rtl::OUString& rURL )
+ : ModalDialog( pParent, CUI_RES( RID_SVXDLG_ASSIGNCOMPONENT ) )
+ , maMethodLabel( this, CUI_RES( FT_METHOD ) )
+ , maMethodEdit( this, CUI_RES( EDIT_METHOD ) )
+ , maOKButton( this, CUI_RES( RID_PB_OK ) )
+ , maCancelButton( this, CUI_RES( RID_PB_CANCEL ) )
+ , maHelpButton( this, CUI_RES( RID_PB_HELP ) )
+ , maURL( rURL )
+{
+ FreeResource();
+ maOKButton.SetClickHdl(LINK(this, AssignComponentDialog, ButtonHandler));
+
+ ::rtl::OUString aMethodName;
+ if( maURL.getLength() )
+ {
+ sal_Int32 nIndex = maURL.indexOf( aVndSunStarUNO );
+ if( nIndex == 0 )
+ {
+ sal_Int32 nBegin = aVndSunStarUNO.getLength();
+ aMethodName = maURL.copy( nBegin );
+ }
+ }
+ maMethodEdit.SetText( aMethodName, Selection( 0, SELECTION_MAX ) );
+}
+
+AssignComponentDialog::~AssignComponentDialog()
+{
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxMacroAssignSingleTabDialog, OKHdl_Impl, Button *, pButton )
+{
+ (void)pButton; //unused
+ pPage->FillItemSet( *pOutSet );
+ EndDialog( RET_CANCEL );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SvxMacroAssignSingleTabDialog::SvxMacroAssignSingleTabDialog
+ ( Window *pParent, const SfxItemSet& rSet, sal_uInt16 nUniqueId ) :
+ SfxModalDialog( pParent, nUniqueId, WinBits( WB_STDMODAL | WB_3DLOOK ) ),
+ pFixedLine ( 0 ),
+ pOKBtn ( 0 ),
+ pCancelBtn ( 0 ),
+ pHelpBtn ( 0 ),
+ pPage ( 0 ),
+ pOptions ( &rSet ),
+ pOutSet ( 0 )
+{}
+
+
+// -----------------------------------------------------------------------
+
+SvxMacroAssignSingleTabDialog::~SvxMacroAssignSingleTabDialog()
+{
+ delete pFixedLine;
+ delete pOKBtn;
+ delete pCancelBtn;
+ delete pHelpBtn;
+ delete pPage;
+}
+
+// -----------------------------------------------------------------------
+
+// According to SfxSingleTabDialog
+void SvxMacroAssignSingleTabDialog::SetTabPage( SfxTabPage* pTabPage )
+{
+ pFixedLine = new FixedLine( this );
+
+ pOKBtn = new OKButton( this, WB_DEFBUTTON );
+ pOKBtn->SetClickHdl( LINK( this, SvxMacroAssignSingleTabDialog, OKHdl_Impl ) );
+
+ pCancelBtn = new CancelButton( this );
+ pHelpBtn = new HelpButton( this );
+
+ pPage = pTabPage;
+
+ if ( pPage )
+ {
+ String sUserData;
+ pPage->SetUserData( sUserData );
+ pPage->Reset( *pOptions );
+ pPage->Show();
+
+ // Set dialog's and buttons' size and position according to tabpage size
+ long nSpaceX = LogicToPixel( Size( 6, 0 ), MAP_APPFONT ).Width();
+ long nSpaceY = LogicToPixel( Size( 0, 6 ), MAP_APPFONT ).Height();
+ long nHalfSpaceX = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
+ long nHalfSpaceY = LogicToPixel( Size( 0, 3 ), MAP_APPFONT ).Height();
+
+ pPage->SetPosPixel( Point() );
+ Size aTabpageSize( pPage->GetSizePixel() );
+ Size aDialogSize( aTabpageSize );
+ Size aButtonSize = LogicToPixel( Size( 50, 14 ), MAP_APPFONT );
+ long nButtonWidth = aButtonSize.Width();
+ long nButtonHeight = aButtonSize.Height();
+
+ Size aFixedLineSize( aTabpageSize );
+ long nFixedLineHeight = LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
+ aFixedLineSize.Height() = nFixedLineHeight;
+
+ aDialogSize.Height() += nFixedLineHeight + nButtonHeight + nSpaceY + nHalfSpaceY;
+ SetOutputSizePixel( aDialogSize );
+
+ long nButtonPosY = aTabpageSize.Height() + nFixedLineHeight + nHalfSpaceY;
+ long nHelpButtonPosX = nSpaceX;
+ pHelpBtn->SetPosSizePixel( Point( nHelpButtonPosX, nButtonPosY), aButtonSize );
+ pHelpBtn->Show();
+
+ long nCancelButtonPosX = aDialogSize.Width() - nButtonWidth - nSpaceX + 1;
+ pCancelBtn->SetPosSizePixel( Point( nCancelButtonPosX, nButtonPosY), aButtonSize );
+ pCancelBtn->Show();
+
+ long nOkButtonPosX = nCancelButtonPosX - nButtonWidth - nHalfSpaceX;
+ pOKBtn->SetPosSizePixel( Point( nOkButtonPosX, nButtonPosY), aButtonSize );
+ pOKBtn->Show();
+
+ long nFixedLinePosY = aTabpageSize.Height();
+ pFixedLine->SetPosSizePixel( Point( 0, nFixedLinePosY), aFixedLineSize );
+ pFixedLine->Show();
+
+ // Get text from TabPage
+ SetText( pPage->GetText() );
+
+ // Get IDs from TabPage
+ SetHelpId( pPage->GetHelpId() );
+ SetUniqueId( pPage->GetUniqueId() );
+ }
+}
diff --git a/cui/source/customize/macropg.hrc b/cui/source/customize/macropg.hrc
new file mode 100644
index 000000000000..a7387e410432
--- /dev/null
+++ b/cui/source/customize/macropg.hrc
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MACROPG_HRC
+#define _MACROPG_HRC
+
+#ifndef _SVT_CONTROLDIMS_HRC_
+#include <svtools/controldims.hrc>
+#endif
+
+#define LB_EVENT 1
+#define PB_ASSIGN 2
+#define PB_DELETE 3
+#define STR_EVENT 4
+#define STR_ASSMACRO 5
+#define FT_ASSIGN 6
+#define PB_ASSIGN_COMPONENT 7
+
+// Starting new IDs with 30 as eventdlg.hrc also includes this file
+#define IMG_MACRO 30
+#define IMG_COMPONENT 31
+#define IMG_MACRO_H 32
+#define IMG_COMPONENT_H 33
+
+#define RID_PB_OK 41
+#define RID_PB_CANCEL 42
+#define RID_PB_HELP 43
+#define FT_METHOD 44
+#define EDIT_METHOD 45
+
+
+// COL0<---------------WIDTH_1_2--------------->COL3<->COL4<----WIDTH4---->COL5
+// <--WIDTH1-->COL1<-SPACE1->COL2<--WIDTH2->
+
+#define WIDTH_TP 260 // of whole tabpage
+#define COL5 (WIDTH_TP-RSC_SP_DLG_INNERBORDER_RIGHT)
+#define COL4 (COL5-RSC_CD_PUSHBUTTON_WIDTH)
+#define COL3 (COL4-RSC_SP_CTRL_X)
+#define COL0 (RSC_SP_TBPG_INNERBORDER_LEFT)
+#define WIDTH1_2 (COL3-COL0) // width of upper listbox
+#define SPACE1 4 // space between lower listboxes
+#define WIDTH1 ((WIDTH1_2-SPACE1)/2) // width of lower left listbox
+#define WIDTH2 (WIDTH1_2-WIDTH1-SPACE1) // width of lower right listbox
+#define COL1 (COL0+WIDTH1)
+#define COL2 (COL1+SPACE1)
+
+#define HEIGHT0 158 // of upper listbox
+#define HEIGHT_TP (HEIGHT0+6) // of whole tabpage
+#define ROW0 6 // more than RSC_SP_FLGR_INNERBORDER_TOP cause of bad design
+#define ROW0A (ROW0+RSC_CD_FIXEDTEXT_HEIGHT+SPACE1)
+#define ROW1 (ROW0A+RSC_CD_PUSHBUTTON_HEIGHT) // Assign button
+#define ROW2 (ROW1+RSC_SP_CTRL_GROUP_Y)
+#define ROW3 (ROW2+RSC_CD_PUSHBUTTON_HEIGHT) // Assign component button
+#define ROW4 (ROW3+RSC_SP_CTRL_GROUP_Y)
+#define ROW5_REMOVE (ROW4+RSC_SP_CTRL_GROUP_Y) // Remove button
+#define ROW5 (ROW4+RSC_CD_DROPDOWN_HEIGHT) // script type listbox (hidden)
+#define ROW6 (ROW0+HEIGHT0)
+#define ROW7 (ROW6+RSC_SP_CTRL_Y)
+#define HEIGHT_EXTRA7 (RSC_CD_FIXEDTEXT_HEIGHT) // additional height for FT_LABEL4LB_MACROS
+#define ROW7A (ROW7+HEIGHT_EXTRA7)
+#define ROW8 (ROW7+RSC_CD_FIXEDTEXT_HEIGHT+HEIGHT_EXTRA7)// label for lower listboxes (2 lines!)
+#define ROW9 (HEIGHT_TP-RSC_SP_TBPG_INNERBORDER_BOTTOM)
+#define HEIGHT8 (ROW9-ROW8) // of lower listboxes
+
+#define COMP_EDIT_WIDTH 100
+#define COMP_DIST_Y 6
+#define COMP_WIDTH (COMP_EDIT_WIDTH+RSC_CD_PUSHBUTTON_WIDTH+3*COMP_DIST_Y)
+#define COMP_COL0 COMP_DIST_Y
+#define COMP_COL1 (COMP_COL0+COMP_EDIT_WIDTH+COMP_DIST_Y)
+#define COMP_ROW0 6
+#define COMP_ROW1 (COMP_ROW0+RSC_CD_PUSHBUTTON_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define COMP_ROW2 (COMP_ROW1+RSC_CD_PUSHBUTTON_HEIGHT+2*RSC_SP_CTRL_GROUP_Y)
+#define COMP_ROWEDIT (COMP_ROW0+RSC_CD_FIXEDTEXT_HEIGHT+2)
+#define COMP_HEIGHT (COMP_ROW2+RSC_CD_PUSHBUTTON_HEIGHT+2*RSC_SP_CTRL_GROUP_Y)
+
+#endif
+
diff --git a/cui/source/customize/macropg.src b/cui/source/customize/macropg.src
new file mode 100644
index 000000000000..10d9149233e0
--- /dev/null
+++ b/cui/source/customize/macropg.src
@@ -0,0 +1,485 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sfx2/sfx.hrc>
+#include "macropg.hrc"
+#include <cuires.hrc>
+#include "helpid.hrc"
+#include <svx/dialogs.hrc>
+
+#define MASKCOLOR MaskColor = \
+ Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+TabPage RID_SVXPAGE_MACROASSIGN
+{
+ // HelpID = HID_MACROASSIGN ;
+ Hide = TRUE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WIDTH_TP , HEIGHT_TP ) ;
+ Text [ en-US ] = "Assign action" ;
+ String STR_EVENT
+ {
+ Text [ en-US ] = "Event" ;
+ };
+ String STR_ASSMACRO
+ {
+ Text [ en-US ] = "Assigned Action" ;
+ };
+ Control LB_EVENT
+ {
+ Border = TRUE ;
+ TabStop = TRUE;
+ Pos = MAP_APPFONT ( COL0 , ROW0 ) ;
+ Size = MAP_APPFONT ( WIDTH1_2 , HEIGHT0 ) ;
+ HelpID = HID_SVX_MACRO_LB_EVENT ;
+ };
+ FixedText FT_ASSIGN
+ {
+ Pos = MAP_APPFONT ( COL4 , ROW0 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Assign:" ;
+ };
+ PushButton PB_ASSIGN
+ {
+ Pos = MAP_APPFONT ( COL4 , ROW0A ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ Text [ en-US ] = "M~acro..." ;
+ Disable = TRUE ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_ASSIGN_COMPONENT
+ {
+ Pos = MAP_APPFONT ( COL4 , ROW2 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ Disable = TRUE ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Com~ponent..." ;
+ };
+ PushButton PB_DELETE
+ {
+ Pos = MAP_APPFONT ( COL4 , ROW5_REMOVE ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ Text [ en-US ] = "~Remove" ;
+ Disable = TRUE ;
+ TabStop = TRUE ;
+ };
+ Image IMG_MACRO
+ {
+ ImageBitmap = Bitmap { File = "id018.png"; };
+ MASKCOLOR
+ };
+ Image IMG_COMPONENT
+ {
+ ImageBitmap = Bitmap { File = "component_16.png"; };
+ MASKCOLOR
+ };
+ Image IMG_MACRO_H
+ {
+ ImageBitmap = Bitmap { File = "idh018.png"; };
+ MASKCOLOR
+ };
+ Image IMG_COMPONENT_H
+ {
+ ImageBitmap = Bitmap { File = "component_16_h.png"; };
+ MASKCOLOR
+ };
+};
+
+ModalDialog RID_SVXDLG_ASSIGNCOMPONENT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( COMP_WIDTH , COMP_HEIGHT ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Assign Component";
+ OKButton RID_PB_OK
+ {
+ Pos = MAP_APPFONT ( COMP_COL1 , COMP_ROW0 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton RID_PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( COMP_COL1 , COMP_ROW1 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton RID_PB_HELP
+ {
+ Pos = MAP_APPFONT ( COMP_COL1 , COMP_ROW2 ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ };
+ FixedText FT_METHOD
+ {
+ Pos = MAP_APPFONT ( COMP_COL0 , ROW0 ) ;
+ Size = MAP_APPFONT ( COMP_EDIT_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Component method name" ;
+ };
+ Edit EDIT_METHOD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( COMP_COL0 , COMP_ROWEDIT ) ;
+ Size = MAP_APPFONT ( COMP_EDIT_WIDTH , RSC_CD_TEXTBOX_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+};
+
+
+//DF
+String RID_SVXSTR_EVENT_STARTAPP
+{
+ Text [ en-US ] = "Start Application" ;
+};
+
+String RID_SVXSTR_EVENT_CLOSEAPP
+{
+ Text [ en-US ] = "Close Application" ;
+};
+
+String RID_SVXSTR_EVENT_NEWDOC
+{
+ Text [ en-US ] = "New Document" ;
+};
+
+String RID_SVXSTR_EVENT_CLOSEDOC
+{
+ Text [ en-US ] = "Document closed" ;
+};
+
+String RID_SVXSTR_EVENT_PREPARECLOSEDOC
+{
+ Text [ en-US ] = "Document is going to be closed" ;
+};
+
+String RID_SVXSTR_EVENT_OPENDOC
+{
+ Text [ en-US ] = "Open Document" ;
+};
+
+String RID_SVXSTR_EVENT_SAVEDOC
+{
+ Text [ en-US ] = "Save Document" ;
+};
+
+String RID_SVXSTR_EVENT_SAVEASDOC
+{
+ Text [ en-US ] = "Save Document As" ;
+};
+
+String RID_SVXSTR_EVENT_SAVEDOCDONE
+{
+ Text [ en-US ] = "Document has been saved" ;
+};
+
+String RID_SVXSTR_EVENT_SAVEASDOCDONE
+{
+ Text [ en-US ] = "Document has been saved as" ;
+};
+
+String RID_SVXSTR_EVENT_ACTIVATEDOC
+{
+ Text [ en-US ] = "Activate Document" ;
+};
+
+String RID_SVXSTR_EVENT_DEACTIVATEDOC
+{
+ Text [ en-US ] = "Deactivate Document" ;
+};
+
+String RID_SVXSTR_EVENT_PRINTDOC
+{
+ Text [ en-US ] = "Print Document" ;
+};
+
+String RID_SVXSTR_EVENT_MODIFYCHANGED
+{
+ Text [ en-US ] = "'Modified' status was changed" ;
+};
+String RID_SVXSTR_EVENT_MAILMERGE
+{
+ Text [ en-US ] = "Printing of form letters started" ;
+};
+String RID_SVXSTR_EVENT_MAILMERGE_END
+{
+ Text [ en-US ] = "Printing of form letters finished" ;
+};
+String RID_SVXSTR_EVENT_FIELDMERGE
+{
+ Text [ en-US ] = "Merging of form fields started" ;
+};
+String RID_SVXSTR_EVENT_FIELDMERGE_FINISHED
+{
+ Text [ en-US ] = "Merging of form fields finished" ;
+};
+String RID_SVXSTR_EVENT_PAGECOUNTCHANGE
+{
+ Text [ en-US ] = "Changing the page count" ;
+};
+String RID_SVXSTR_EVENT_SUBCOMPONENT_OPENED
+{
+ Text [ en-US ] = "Loaded a sub component" ;
+};
+String RID_SVXSTR_EVENT_SUBCOMPONENT_CLOSED
+{
+ Text [ en-US ] = "Closed a sub component" ;
+};
+String RID_SVXSTR_EVENT_APPROVEPARAMETER
+{
+ Text [ en-US ] = "Fill parameters" ;
+};
+String RID_SVXSTR_EVENT_ACTIONPERFORMED
+{
+ Text [ en-US ] = "Execute action" ;
+};
+String RID_SVXSTR_EVENT_AFTERUPDATE
+{
+ Text [ en-US ] = "After updating" ;
+};
+String RID_SVXSTR_EVENT_BEFOREUPDATE
+{
+ Text [ en-US ] = "Before updating" ;
+};
+String RID_SVXSTR_EVENT_APPROVEROWCHANGE
+{
+ Text [ en-US ] = "Before record action" ;
+};
+String RID_SVXSTR_EVENT_ROWCHANGE
+{
+ Text [ en-US ] = "After record action" ;
+};
+String RID_SVXSTR_EVENT_CONFIRMDELETE
+{
+ Text [ en-US ] = "Confirm deletion" ;
+};
+String RID_SVXSTR_EVENT_ERROROCCURED
+{
+ Text [ en-US ] = "Error occurred" ;
+};
+String RID_SVXSTR_EVENT_ADJUSTMENTVALUECHANGED
+{
+ Text [ en-US ] = "While adjusting";
+};
+String RID_SVXSTR_EVENT_FOCUSGAINED
+{
+ Text [ en-US ] = "When receiving focus" ;
+};
+String RID_SVXSTR_EVENT_FOCUSLOST
+{
+ Text [ en-US ] = "When losing focus" ;
+};
+String RID_SVXSTR_EVENT_ITEMSTATECHANGED
+{
+ Text [ en-US ] = "Item status changed" ;
+};
+String RID_SVXSTR_EVENT_KEYTYPED
+{
+ Text [ en-US ] = "Key pressed" ;
+};
+String RID_SVXSTR_EVENT_KEYUP
+{
+ Text [ en-US ] = "Key released" ;
+};
+String RID_SVXSTR_EVENT_LOADED
+{
+ Text [ en-US ] = "When loading" ;
+};
+String RID_SVXSTR_EVENT_RELOADING
+{
+ Text [ en-US ] = "Before reloading" ;
+};
+String RID_SVXSTR_EVENT_RELOADED
+{
+ Text [ en-US ] = "When reloading" ;
+};
+String RID_SVXSTR_EVENT_MOUSEDRAGGED
+{
+ Text [ en-US ] = "Mouse moved while key pressed" ;
+};
+String RID_SVXSTR_EVENT_MOUSEENTERED
+{
+ Text [ en-US ] = "Mouse inside" ;
+};
+String RID_SVXSTR_EVENT_MOUSEEXITED
+{
+ Text [ en-US ] = "Mouse outside" ;
+};
+String RID_SVXSTR_EVENT_MOUSEMOVED
+{
+ Text [ en-US ] = "Mouse moved" ;
+};
+String RID_SVXSTR_EVENT_MOUSEPRESSED
+{
+ Text [ en-US ] = "Mouse button pressed" ;
+};
+String RID_SVXSTR_EVENT_MOUSERELEASED
+{
+ Text [ en-US ] = "Mouse button released" ;
+};
+String RID_SVXSTR_EVENT_POSITIONING
+{
+ Text [ en-US ] = "Before record change" ;
+};
+String RID_SVXSTR_EVENT_POSITIONED
+{
+ Text [ en-US ] = "After record change" ;
+};
+String RID_SVXSTR_EVENT_RESETTED
+{
+ Text [ en-US ] = "After resetting" ;
+};
+String RID_SVXSTR_EVENT_APPROVERESETTED
+{
+ Text [ en-US ] = "Prior to reset" ;
+};
+String RID_SVXSTR_EVENT_APPROVEACTIONPERFORMED
+{
+ Text [ en-US ] = "Approve action" ;
+};
+String RID_SVXSTR_EVENT_SUBMITTED
+{
+ Text [ en-US ] = "Before submitting" ;
+};
+String RID_SVXSTR_EVENT_TEXTCHANGED
+{
+ Text [ en-US ] = "Text modified" ;
+};
+String RID_SVXSTR_EVENT_UNLOADING
+{
+ Text [ en-US ] = "Before unloading" ;
+};
+String RID_SVXSTR_EVENT_UNLOADED
+{
+ Text [ en-US ] = "When unloading" ;
+};
+String RID_SVXSTR_EVENT_CHANGED
+{
+ Text [ en-US ] = "Changed" ;
+};
+
+String RID_SVXSTR_EVENT_CREATEDOC
+{
+ Text [ en-US ] = "Document created" ;
+};
+
+String RID_SVXSTR_EVENT_LOADDOCFINISHED
+{
+ Text [ en-US ] = "Document loading finished" ;
+};
+
+String RID_SVXSTR_EVENT_SAVEDOCFAILED
+{
+ Text [ en-US ] = "Saving of document failed" ;
+};
+
+String RID_SVXSTR_EVENT_SAVEASDOCFAILED
+{
+ Text [ en-US ] = "'Save as' has failed" ;
+};
+
+String RID_SVXSTR_EVENT_COPYTODOC
+{
+ Text [ en-US ] = "Storing or exporting copy of document" ;
+};
+
+String RID_SVXSTR_EVENT_COPYTODOCDONE
+{
+ Text [ en-US ] = "Document copy has been created" ;
+};
+
+String RID_SVXSTR_EVENT_COPYTODOCFAILED
+{
+ Text [ en-US ] = "Creating of document copy failed" ;
+};
+
+String RID_SVXSTR_EVENT_VIEWCREATED
+{
+ Text [ en-US ] = "View created" ;
+};
+
+String RID_SVXSTR_EVENT_PREPARECLOSEVIEW
+{
+ Text [ en-US ] = "View is going to be closed" ;
+};
+
+String RID_SVXSTR_EVENT_CLOSEVIEW
+{
+ Text [ en-US ] = "View closed" ;
+};
+
+String RID_SVXSTR_EVENT_TITLECHANGED
+{
+ Text [ en-US ] = "Document title changed" ;
+};
+
+String RID_SVXSTR_EVENT_MODECHANGED
+{
+ Text [ en-US ] = "Document mode changed" ;
+};
+
+String RID_SVXSTR_EVENT_VISAREACHANGED
+{
+ Text [ en-US ] = "Visible area changed" ;
+};
+
+String RID_SVXSTR_EVENT_STORAGECHANGED
+{
+ Text [ en-US ] = "Document has got a new storage" ;
+};
+
+String RID_SVXSTR_EVENT_LAYOUT_FINISHED
+{
+ Text [ en-US ] = "Document layout finished" ;
+};
+
+String RID_SVXSTR_EVENT_SELECTIONCHANGED
+{
+ Text [ en-US ] = "Selection changed" ;
+};
+
+String RID_SVXSTR_EVENT_DOUBLECLICK
+{
+ Text [ en-US ] = "Double click" ;
+};
+
+String RID_SVXSTR_EVENT_RIGHTCLICK
+{
+ Text [ en-US ] = "Right click" ;
+};
+
+String RID_SVXSTR_EVENT_CALCULATE
+{
+ Text [ en-US ] = "Formulas calculated" ;
+};
+
+String RID_SVXSTR_EVENT_CONTENTCHANGED
+{
+ Text [ en-US ] = "Content changed" ;
+};
+
diff --git a/cui/source/customize/macropg_impl.hxx b/cui/source/customize/macropg_impl.hxx
new file mode 100644
index 000000000000..63c977cf2422
--- /dev/null
+++ b/cui/source/customize/macropg_impl.hxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MACROPG_IMPL_HXX
+#define _MACROPG_IMPL_HXX
+
+class _SvxMacroTabPage_Impl
+{
+public:
+ _SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet );
+ ~_SvxMacroTabPage_Impl();
+
+ FixedText* pAssignFT;
+ PushButton* pAssignPB;
+ PushButton* pAssignComponentPB;
+ PushButton* pDeletePB;
+ Image* pMacroImg;
+ Image* pComponentImg;
+ Image* pMacroImg_h;
+ Image* pComponentImg_h;
+ String* pStrEvent;
+ String* pAssignedMacro;
+ _HeaderTabListBox* pEventLB;
+ BOOL bReadOnly;
+ BOOL bIDEDialogMode;
+};
+
+class AssignComponentDialog : public ModalDialog
+{
+private:
+ FixedText maMethodLabel;
+ Edit maMethodEdit;
+ OKButton maOKButton;
+ CancelButton maCancelButton;
+ HelpButton maHelpButton;
+
+ ::rtl::OUString maURL;
+
+ DECL_LINK(ButtonHandler, Button *);
+
+public:
+ AssignComponentDialog( Window * pParent, const ::rtl::OUString& rURL );
+ ~AssignComponentDialog();
+
+ ::rtl::OUString getURL( void ) const
+ { return maURL; }
+};
+
+#endif
diff --git a/cui/source/customize/makefile.mk b/cui/source/customize/makefile.mk
new file mode 100644
index 000000000000..4b7f5d1639bd
--- /dev/null
+++ b/cui/source/customize/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJNAME=cui
+TARGET=customize
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+.IF "$(ENABLE_LAYOUT)" == "TRUE"
+CFLAGS+= -DENABLE_LAYOUT=1 -I../$(PRJ)/layout/inc -I../$(PRJ)/layout/$(INPATH)/inc
+.ENDIF # ENABLE_LAYOUT == TRUE
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=customize
+SRC1FILES = \
+ acccfg.src \
+ cfg.src \
+ eventdlg.src \
+ macropg.src \
+ selector.src \
+
+
+SLOFILES+=\
+ $(SLO)$/acccfg.obj \
+ $(SLO)$/cfg.obj \
+ $(SLO)$/cfgutil.obj \
+ $(SLO)$/eventdlg.obj \
+ $(SLO)$/macropg.obj \
+ $(SLO)$/selector.obj \
+
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx
new file mode 100644
index 000000000000..3e99f3e95b5f
--- /dev/null
+++ b/cui/source/customize/selector.cxx
@@ -0,0 +1,1253 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cui.hxx"
+#include <vcl/help.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/metric.hxx>
+#include "selector.hxx"
+#include <dialmgr.hxx>
+#include "selector.hrc"
+#include <svx/fmresids.hrc> // for RID_SVXIMG_...
+#include <svx/dialmgr.hxx> // for RID_SVXIMG_...
+#include <cuires.hrc>
+#include <sfx2/app.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/msgpool.hxx>
+#include <sfx2/macrconf.hxx>
+#include <sfx2/minfitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <comphelper/documentinfo.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/componentcontext.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
+#include <com/sun/star/script/provider/XScriptProvider.hpp>
+#include <com/sun/star/script/browse/XBrowseNode.hpp>
+#include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
+#include <com/sun/star/script/browse/XBrowseNodeFactory.hpp>
+#include <com/sun/star/script/browse/BrowseNodeFactoryViewTypes.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/document/XEmbeddedScripts.hpp>
+#include <com/sun/star/document/XScriptInvocationContext.hpp>
+#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
+#include <com/sun/star/frame/DispatchInformation.hpp>
+#include <com/sun/star/container/XChild.hpp>
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::container;
+
+#define _SVSTDARR_STRINGSDTOR
+#include <svl/svstdarr.hxx>
+#include <svtools/imagemgr.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+
+SV_IMPL_PTRARR(SvxGroupInfoArr_Impl, SvxGroupInfoPtr);
+
+/*
+ * The implementations of SvxConfigFunctionListBox_Impl and
+ * SvxConfigGroupListBox_Impl are copied from sfx2/source/dialog/cfg.cxx
+ */
+SvxConfigFunctionListBox_Impl::SvxConfigFunctionListBox_Impl( Window* pParent, const ResId& rResId)
+ : SvTreeListBox( pParent, rResId )
+ , pCurEntry( 0 )
+ , m_pDraggingEntry( 0 )
+{
+ SetWindowBits( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT );
+ GetModel()->SetSortMode( SortAscending );
+
+ // Timer f"ur die BallonHelp
+ aTimer.SetTimeout( 200 );
+ aTimer.SetTimeoutHdl(
+ LINK( this, SvxConfigFunctionListBox_Impl, TimerHdl ) );
+}
+
+SvxConfigFunctionListBox_Impl::~SvxConfigFunctionListBox_Impl()
+{
+ ClearAll();
+}
+
+SvLBoxEntry* SvxConfigFunctionListBox_Impl::GetLastSelectedEntry()
+{
+ if ( m_pDraggingEntry != NULL )
+ {
+ return m_pDraggingEntry;
+ }
+ else
+ {
+ return FirstSelected();
+ }
+}
+
+void SvxConfigFunctionListBox_Impl::MouseMove( const MouseEvent& rMEvt )
+{
+ Point aMousePos = rMEvt.GetPosPixel();
+ pCurEntry = GetCurEntry();
+
+ if ( pCurEntry && GetEntry( aMousePos ) == pCurEntry )
+ aTimer.Start();
+ else
+ {
+ Help::ShowBalloon( this, aMousePos, String() );
+ aTimer.Stop();
+ }
+}
+
+
+IMPL_LINK( SvxConfigFunctionListBox_Impl, TimerHdl, Timer*, EMPTYARG)
+{
+ aTimer.Stop();
+ Point aMousePos = GetPointerPosPixel();
+ SvLBoxEntry *pEntry = GetCurEntry();
+ if ( pEntry && GetEntry( aMousePos ) == pEntry && pCurEntry == pEntry )
+ Help::ShowBalloon( this, OutputToScreenPixel( aMousePos ), GetHelpText( pEntry ) );
+ return 0L;
+}
+
+void SvxConfigFunctionListBox_Impl::ClearAll()
+{
+ USHORT nCount = aArr.Count();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ SvxGroupInfo_Impl *pData = aArr[i];
+ delete pData;
+ }
+
+ aArr.Remove( 0, nCount );
+ Clear();
+}
+
+SvLBoxEntry* SvxConfigFunctionListBox_Impl::GetEntry_Impl( const String& rName )
+{
+ SvLBoxEntry *pEntry = First();
+ while ( pEntry )
+ {
+ if ( GetEntryText( pEntry ) == rName )
+ return pEntry;
+ pEntry = Next( pEntry );
+ }
+
+ return NULL;
+}
+
+SvLBoxEntry* SvxConfigFunctionListBox_Impl::GetEntry_Impl( USHORT nId )
+{
+ SvLBoxEntry *pEntry = First();
+ while ( pEntry )
+ {
+ SvxGroupInfo_Impl *pData = (SvxGroupInfo_Impl*) pEntry->GetUserData();
+ if ( pData && pData->nOrd == nId )
+ return pEntry;
+ pEntry = Next( pEntry );
+ }
+
+ return NULL;
+}
+
+USHORT SvxConfigFunctionListBox_Impl::GetId( SvLBoxEntry *pEntry )
+{
+ SvxGroupInfo_Impl *pData = pEntry ?
+ (SvxGroupInfo_Impl*) pEntry->GetUserData() : 0;
+ if ( pData )
+ return pData->nOrd;
+ return 0;
+}
+
+String SvxConfigFunctionListBox_Impl::GetHelpText( SvLBoxEntry *pEntry )
+{
+ // Information zum selektierten Entry aus den Userdaten holen
+ SvxGroupInfo_Impl *pInfo =
+ pEntry ? (SvxGroupInfo_Impl*) pEntry->GetUserData(): 0;
+
+ if ( pInfo )
+ {
+ if ( pInfo->nKind == SVX_CFGFUNCTION_SLOT )
+ {
+ OUString aCmdURL( pInfo->sURL );
+
+ OUString aHelpText = Application::GetHelp()->GetHelpText( aCmdURL, this );
+
+ return aHelpText;
+ }
+ else if ( pInfo->nKind == SVX_CFGFUNCTION_SCRIPT )
+ {
+ return pInfo->sHelpText;
+ }
+ }
+
+ return String();
+}
+
+void SvxConfigFunctionListBox_Impl::FunctionSelected()
+{
+ Help::ShowBalloon( this, Point(), String() );
+}
+
+// drag and drop support
+DragDropMode SvxConfigFunctionListBox_Impl::NotifyStartDrag(
+ TransferDataContainer& /*aTransferDataContainer*/, SvLBoxEntry* pEntry )
+{
+ m_pDraggingEntry = pEntry;
+ return GetDragDropMode();
+}
+
+void SvxConfigFunctionListBox_Impl::DragFinished( sal_Int8 /*nDropAction*/ )
+{
+ m_pDraggingEntry = NULL;
+}
+
+sal_Int8
+SvxConfigFunctionListBox_Impl::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
+{
+ return DND_ACTION_NONE;
+}
+
+SvxConfigGroupListBox_Impl::SvxConfigGroupListBox_Impl(
+ Window* pParent, const ResId& rResId,
+ bool _bShowSlots, const Reference< frame::XFrame >& xFrame )
+ : SvTreeListBox( pParent, rResId )
+ , m_bShowSlots( _bShowSlots ),
+ m_hdImage(ResId(IMG_HARDDISK,*rResId.GetResMgr())),
+ m_hdImage_hc(ResId(IMG_HARDDISK_HC,*rResId.GetResMgr())),
+ m_libImage(ResId(IMG_LIB,*rResId.GetResMgr())),
+ m_libImage_hc(ResId(IMG_LIB_HC,*rResId.GetResMgr())),
+ m_macImage(ResId(IMG_MACRO,*rResId.GetResMgr())),
+ m_macImage_hc(ResId(IMG_MACRO_HC,*rResId.GetResMgr())),
+ m_docImage(ResId(IMG_DOC,*rResId.GetResMgr())),
+ m_docImage_hc(ResId(IMG_DOC_HC,*rResId.GetResMgr())),
+ m_sMyMacros(String(ResId(STR_MYMACROS,*rResId.GetResMgr()))),
+ m_sProdMacros(String(ResId(STR_PRODMACROS,*rResId.GetResMgr())))
+{
+ FreeResource();
+
+ if ( xFrame != NULL )
+ {
+ m_xFrame.set( xFrame );
+ }
+
+ SetWindowBits( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT );
+
+ ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) );
+
+ SetNodeBitmaps(
+ aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
+ aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ),
+ BMP_COLOR_NORMAL );
+
+ SetNodeBitmaps(
+ aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
+ aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ),
+ BMP_COLOR_HIGHCONTRAST );
+}
+
+
+SvxConfigGroupListBox_Impl::~SvxConfigGroupListBox_Impl()
+{
+ ClearAll();
+}
+
+void SvxConfigGroupListBox_Impl::ClearAll()
+{
+ USHORT nCount = aArr.Count();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ SvxGroupInfo_Impl *pData = aArr[i];
+ delete pData;
+ }
+
+ aArr.Remove( 0, nCount );
+ Clear();
+}
+
+//-----------------------------------------------
+namespace
+{
+ //...........................................
+ /** examines a component whether it supports XEmbeddedScripts, or provides access to such a
+ component by implementing XScriptInvocationContext.
+ @return
+ the model which supports the embedded scripts, or <NULL/> if it cannot find such a
+ model
+ */
+ static Reference< XModel > lcl_getDocumentWithScripts_throw( const Reference< XInterface >& _rxComponent )
+ {
+ Reference< XEmbeddedScripts > xScripts( _rxComponent, UNO_QUERY );
+ if ( !xScripts.is() )
+ {
+ Reference< XScriptInvocationContext > xContext( _rxComponent, UNO_QUERY );
+ if ( xContext.is() )
+ xScripts.set( xContext->getScriptContainer(), UNO_QUERY );
+ }
+
+ return Reference< XModel >( xScripts, UNO_QUERY );
+ }
+
+ //...........................................
+ static Reference< XModel > lcl_getScriptableDocument_nothrow( const Reference< XFrame >& _rxFrame )
+ {
+ Reference< XModel > xDocument;
+
+ // examine our associated frame
+ try
+ {
+ OSL_ENSURE( _rxFrame.is(), "lcl_getScriptableDocument_nothrow: you need to pass a frame to this dialog/tab page!" );
+ if ( _rxFrame.is() )
+ {
+ // first try the model in the frame
+ Reference< XController > xController( _rxFrame->getController(), UNO_SET_THROW );
+ xDocument = lcl_getDocumentWithScripts_throw( xController->getModel() );
+
+ if ( !xDocument.is() )
+ {
+ // if there is no suitable document in the frame, try the controller
+ xDocument = lcl_getDocumentWithScripts_throw( _rxFrame->getController() );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xDocument;
+ }
+}
+
+void SvxConfigGroupListBox_Impl::fillScriptList( const Reference< browse::XBrowseNode >& _rxRootNode, SvLBoxEntry* _pParentEntry, bool _bCheapChildsOnDemand )
+{
+ OSL_PRECOND( _rxRootNode.is(), "SvxConfigGroupListBox_Impl::fillScriptList: invalid root node!" );
+ if ( !_rxRootNode.is() )
+ return;
+
+ try
+ {
+ if ( _rxRootNode->hasChildNodes() )
+ {
+ Sequence< Reference< browse::XBrowseNode > > children =
+ _rxRootNode->getChildNodes();
+
+ BOOL bIsRootNode = _rxRootNode->getName().equalsAscii("Root");
+
+ /* To mimic current starbasic behaviour we
+ need to make sure that only the current document
+ is displayed in the config tree. Tests below
+ set the bDisplay flag to FALSE if the current
+ node is a first level child of the Root and is NOT
+ either the current document, user or share */
+ OUString sCurrentDocTitle;
+ Reference< XModel > xWorkingDocument = lcl_getScriptableDocument_nothrow( m_xFrame );
+ if ( xWorkingDocument.is() )
+ {
+ sCurrentDocTitle = ::comphelper::DocumentInfo::getDocumentTitle( xWorkingDocument );
+ }
+
+ for ( long n = 0; n < children.getLength(); n++ )
+ {
+ Reference< browse::XBrowseNode >& theChild = children[n];
+ //#139111# some crash reports show that it might be unset
+ if ( !theChild.is() )
+ continue;
+ ::rtl::OUString sUIName = theChild->getName();
+ BOOL bDisplay = TRUE;
+
+ if ( bIsRootNode
+ || ( m_bShowSlots && _pParentEntry && ( GetModel()->GetDepth( _pParentEntry ) == 0 ) )
+ // if we show slots (as in the customize dialog)
+ // then the user & share are added at depth=1
+ )
+ {
+ if ( sUIName.equalsAscii( "user" ) )
+ {
+ sUIName = m_sMyMacros;
+ bIsRootNode = sal_True;
+ }
+ else if ( sUIName.equalsAscii( "share" ) )
+ {
+ sUIName = m_sProdMacros;
+ bIsRootNode = sal_True;
+ }
+ else if ( !sUIName.equals( sCurrentDocTitle ) )
+ {
+ bDisplay = FALSE;
+ }
+ }
+
+ if ( !bDisplay )
+ continue;
+
+ if ( children[n]->getType() == browse::BrowseNodeTypes::SCRIPT )
+ continue;
+
+ SvLBoxEntry* pNewEntry = InsertEntry( sUIName, _pParentEntry );
+
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Image aImage = GetImage( theChild, aContext.getUNOContext(), bIsRootNode, BMP_COLOR_NORMAL );
+ SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL );
+ SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL );
+
+ aImage = GetImage( theChild, aContext.getUNOContext(), bIsRootNode, BMP_COLOR_HIGHCONTRAST );
+ SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST );
+
+ SvxGroupInfo_Impl* pInfo =
+ new SvxGroupInfo_Impl( SVX_CFGGROUP_SCRIPTCONTAINER, 0, theChild );
+ pNewEntry->SetUserData( pInfo );
+ aArr.Insert( pInfo, aArr.Count() );
+
+ if ( _bCheapChildsOnDemand )
+ {
+ /* i30923 - Would be nice if there was a better
+ * way to determine if a basic lib had children
+ * without having to ask for them (which forces
+ * the library to be loaded */
+ pNewEntry->EnableChildsOnDemand( TRUE );
+ }
+ else
+ {
+ // if there are granchildren we're interested in, display the '+' before
+ // the entry, but do not yet expand
+ Sequence< Reference< browse::XBrowseNode > > grandchildren =
+ children[n]->getChildNodes();
+
+ for ( sal_Int32 m = 0; m < grandchildren.getLength(); m++ )
+ {
+ if ( grandchildren[m]->getType() == browse::BrowseNodeTypes::CONTAINER )
+ {
+ pNewEntry->EnableChildsOnDemand( TRUE );
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+void SvxConfigGroupListBox_Impl::Init()
+{
+ SetUpdateMode(FALSE);
+ ClearAll();
+
+ Reference< XComponentContext > xContext;
+ Reference < beans::XPropertySet > xProps(
+ ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+
+ xContext.set( xProps->getPropertyValue(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))),
+ UNO_QUERY );
+
+ // are we showing builtin commands?
+ if ( m_bShowSlots && xContext.is() && m_xFrame.is() )
+ {
+ Reference< lang::XMultiComponentFactory > xMCF =
+ xContext->getServiceManager();
+
+ Reference< frame::XDispatchInformationProvider > xDIP(
+ m_xFrame, UNO_QUERY );
+
+ Reference< ::com::sun::star::frame::XModuleManager >
+ xModuleManager( xMCF->createInstanceWithContext(
+ OUString::createFromAscii(
+ "com.sun.star.frame.ModuleManager" ),
+ xContext ),
+ UNO_QUERY );
+
+ OUString aModuleId;
+ try{
+ aModuleId = xModuleManager->identify( m_xFrame );
+ }catch(const uno::Exception&)
+ { aModuleId = ::rtl::OUString(); }
+
+ Reference< container::XNameAccess > xNameAccess(
+ xMCF->createInstanceWithContext(
+ OUString::createFromAscii(
+ "com.sun.star.frame.UICommandDescription" ),
+ xContext ),
+ UNO_QUERY );
+
+ if ( xNameAccess.is() )
+ {
+ xNameAccess->getByName( aModuleId ) >>= m_xModuleCommands;
+ }
+
+ Reference< container::XNameAccess > xAllCategories(
+ xMCF->createInstanceWithContext(
+ OUString::createFromAscii(
+ "com.sun.star.ui.UICategoryDescription" ),
+ xContext ),
+ UNO_QUERY );
+
+ Reference< container::XNameAccess > xModuleCategories;
+ if ( xAllCategories.is() )
+ {
+ if ( aModuleId.getLength() != 0 )
+ {
+ try
+ {
+ xModuleCategories = Reference< container::XNameAccess >(
+ xAllCategories->getByName( aModuleId ), UNO_QUERY );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ }
+ }
+
+ if ( !xModuleCategories.is() )
+ {
+ xModuleCategories = xAllCategories;
+ }
+ }
+
+ if ( xModuleCategories.is() )
+ {
+ Sequence< sal_Int16 > gids =
+ xDIP->getSupportedCommandGroups();
+
+ for ( sal_Int32 i = 0; i < gids.getLength(); i++ )
+ {
+ Sequence< frame::DispatchInformation > commands;
+ try
+ {
+ commands =
+ xDIP->getConfigurableDispatchInformation( gids[i] );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ continue;
+ }
+
+ if ( commands.getLength() == 0 )
+ {
+ continue;
+ }
+
+ sal_Int32 gid = gids[i];
+ OUString idx = OUString::valueOf( gid );
+ OUString group = idx;
+ try
+ {
+ xModuleCategories->getByName( idx ) >>= group;
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ }
+
+ SvLBoxEntry *pEntry = InsertEntry( group, NULL );
+
+ SvxGroupInfo_Impl *pInfo =
+ new SvxGroupInfo_Impl( SVX_CFGGROUP_FUNCTION, gids[i] );
+ aArr.Insert( pInfo, aArr.Count() );
+
+ pEntry->SetUserData( pInfo );
+ }
+ }
+ }
+
+ if ( xContext.is() )
+ {
+ // Add Scripting Framework entries
+ Reference< browse::XBrowseNode > rootNode;
+ Reference< XComponentContext> xCtx;
+
+ try
+ {
+ Reference < beans::XPropertySet > _xProps(
+ ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+ xCtx.set( _xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW );
+ Reference< browse::XBrowseNodeFactory > xFac( xCtx->getValueByName(
+ OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") ), UNO_QUERY_THROW );
+ rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( rootNode.is() )
+ {
+ if ( m_bShowSlots )
+ {
+ SvxGroupInfo_Impl *pInfo =
+ new SvxGroupInfo_Impl( SVX_CFGGROUP_SCRIPTCONTAINER, 0, rootNode );
+
+ String aTitle =
+ String( CUI_RES( STR_SELECTOR_MACROS ) );
+
+ SvLBoxEntry *pNewEntry = InsertEntry( aTitle, NULL );
+ pNewEntry->SetUserData( pInfo );
+ pNewEntry->EnableChildsOnDemand( TRUE );
+ aArr.Insert( pInfo, aArr.Count() );
+ }
+ else
+ {
+ fillScriptList( rootNode, NULL, false );
+ }
+ }
+ }
+ MakeVisible( GetEntry( 0,0 ) );
+ SetUpdateMode( TRUE );
+}
+
+Image SvxConfigGroupListBox_Impl::GetImage( Reference< browse::XBrowseNode > node, Reference< XComponentContext > xCtx, bool bIsRootNode, bool bHighContrast )
+{
+ Image aImage;
+ if ( bIsRootNode )
+ {
+ if ( node->getName().equalsAscii( "user" ) || node->getName().equalsAscii( "share" ) )
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = m_hdImage;
+ else
+ aImage = m_hdImage_hc;
+ }
+ else
+ {
+ OUString factoryURL;
+ OUString nodeName = node->getName();
+ Reference<XInterface> xDocumentModel = getDocumentModel(xCtx, nodeName );
+ if ( xDocumentModel.is() )
+ {
+ Reference< ::com::sun::star::frame::XModuleManager >
+ xModuleManager(
+ xCtx->getServiceManager()
+ ->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.frame.ModuleManager"),
+ xCtx ),
+ UNO_QUERY_THROW );
+ Reference<container::XNameAccess> xModuleConfig(
+ xModuleManager, UNO_QUERY_THROW );
+ // get the long name of the document:
+ OUString appModule( xModuleManager->identify(
+ xDocumentModel ) );
+ Sequence<beans::PropertyValue> moduleDescr;
+ Any aAny = xModuleConfig->getByName(appModule);
+ if( sal_True != ( aAny >>= moduleDescr ) )
+ {
+ throw RuntimeException(OUString::createFromAscii("SFTreeListBox::Init: failed to get PropertyValue"), Reference< XInterface >());
+ }
+ beans::PropertyValue const * pmoduleDescr =
+ moduleDescr.getConstArray();
+ for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
+ {
+ if (pmoduleDescr[ pos ].Name.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM(
+ "ooSetupFactoryEmptyDocumentURL") ))
+ {
+ pmoduleDescr[ pos ].Value >>= factoryURL;
+ break;
+ }
+ }
+ }
+ if( factoryURL.getLength() > 0 )
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = SvFileInformationManager::GetFileImage(
+ INetURLObject(factoryURL), false,
+ BMP_COLOR_NORMAL );
+ else
+ aImage = SvFileInformationManager::GetFileImage(
+ INetURLObject(factoryURL), false,
+ BMP_COLOR_HIGHCONTRAST );
+ }
+ else
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = m_docImage;
+ else
+ aImage = m_docImage_hc;
+ }
+ }
+ }
+ else
+ {
+ if( node->getType() == browse::BrowseNodeTypes::SCRIPT )
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = m_macImage;
+ else
+ aImage = m_macImage_hc;
+ }
+ else
+ {
+ if( bHighContrast == BMP_COLOR_NORMAL )
+ aImage = m_libImage;
+ else
+ aImage = m_libImage_hc;
+ }
+ }
+ return aImage;
+}
+
+Reference< XInterface >
+SvxConfigGroupListBox_Impl::getDocumentModel(
+ Reference< XComponentContext >& xCtx, OUString& docName )
+{
+ Reference< XInterface > xModel;
+ Reference< lang::XMultiComponentFactory > mcf =
+ xCtx->getServiceManager();
+ Reference< frame::XDesktop > desktop (
+ mcf->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx ),
+ UNO_QUERY );
+
+ Reference< container::XEnumerationAccess > componentsAccess =
+ desktop->getComponents();
+ Reference< container::XEnumeration > components =
+ componentsAccess->createEnumeration();
+ while (components->hasMoreElements())
+ {
+ Reference< frame::XModel > model(
+ components->nextElement(), UNO_QUERY );
+ if ( model.is() )
+ {
+ OUString sTdocUrl = ::comphelper::DocumentInfo::getDocumentTitle( model );
+ if( sTdocUrl.equals( docName ) )
+ {
+ xModel = model;
+ break;
+ }
+ }
+ }
+ return xModel;
+}
+
+void SvxConfigGroupListBox_Impl::GroupSelected()
+{
+ SvLBoxEntry *pEntry = FirstSelected();
+ SvxGroupInfo_Impl *pInfo = (SvxGroupInfo_Impl*) pEntry->GetUserData();
+ pFunctionListBox->SetUpdateMode(FALSE);
+ pFunctionListBox->ClearAll();
+ if ( pInfo->nKind != SVX_CFGGROUP_FUNCTION &&
+ pInfo->nKind != SVX_CFGGROUP_SCRIPTCONTAINER )
+ {
+ pFunctionListBox->SetUpdateMode(TRUE);
+ return;
+ }
+
+ switch ( pInfo->nKind )
+ {
+ case SVX_CFGGROUP_FUNCTION :
+ {
+ SvLBoxEntry *_pEntry = FirstSelected();
+ if ( _pEntry != NULL )
+ {
+ SvxGroupInfo_Impl *_pInfo =
+ (SvxGroupInfo_Impl*) _pEntry->GetUserData();
+
+ Reference< frame::XDispatchInformationProvider > xDIP(
+ m_xFrame, UNO_QUERY );
+
+ Sequence< frame::DispatchInformation > commands;
+ try
+ {
+ commands = xDIP->getConfigurableDispatchInformation(
+ _pInfo->nOrd );
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ }
+
+ for ( sal_Int32 i = 0; i < commands.getLength(); i++ )
+ {
+ if ( commands[i].Command.getLength() == 0 )
+ {
+ continue;
+ }
+
+ Image aImage;
+
+ OUString aCmdURL( commands[i].Command );
+
+ if ( m_pImageProvider )
+ {
+ aImage = m_pImageProvider->GetImage( aCmdURL );
+ }
+
+ OUString aLabel;
+ try
+ {
+ Any a = m_xModuleCommands->getByName( aCmdURL );
+ Sequence< beans::PropertyValue > aPropSeq;
+
+ if ( a >>= aPropSeq )
+ {
+ for ( sal_Int32 k = 0; k < aPropSeq.getLength(); k++ )
+ {
+ if ( aPropSeq[k].Name.equalsAscii( "Name" ) )
+ {
+ aPropSeq[k].Value >>= aLabel;
+ break;
+ }
+ }
+ }
+ }
+ catch ( container::NoSuchElementException& )
+ {
+ }
+
+ if ( aLabel.getLength() == 0 )
+ {
+ aLabel = commands[i].Command;
+ }
+
+ SvLBoxEntry* pFuncEntry = NULL;
+ if ( !!aImage )
+ {
+ pFuncEntry = pFunctionListBox->InsertEntry(
+ aLabel, aImage, aImage );
+ }
+ else
+ {
+ pFuncEntry = pFunctionListBox->InsertEntry(
+ aLabel, NULL );
+ }
+
+ SvxGroupInfo_Impl *_pGroupInfo = new SvxGroupInfo_Impl(
+ SVX_CFGFUNCTION_SLOT, 123, aCmdURL, ::rtl::OUString() );
+
+ pFunctionListBox->aArr.Insert(
+ _pGroupInfo, pFunctionListBox->aArr.Count() );
+
+ pFuncEntry->SetUserData( _pGroupInfo );
+ }
+ }
+ break;
+ }
+
+ case SVX_CFGGROUP_SCRIPTCONTAINER:
+ {
+ Reference< browse::XBrowseNode > rootNode( pInfo->xBrowseNode );
+
+ try {
+ if ( rootNode->hasChildNodes() )
+ {
+ Sequence< Reference< browse::XBrowseNode > > children =
+ rootNode->getChildNodes();
+
+ for ( long n = 0; n < children.getLength(); n++ )
+ {
+ if (!children[n].is())
+ continue;
+ if (children[n]->getType() == browse::BrowseNodeTypes::SCRIPT)
+ {
+ OUString uri;
+ OUString description;
+
+ Reference < beans::XPropertySet >xPropSet( children[n], UNO_QUERY );
+ if (!xPropSet.is())
+ {
+ continue;
+ }
+
+ Any value =
+ xPropSet->getPropertyValue( String::CreateFromAscii( "URI" ) );
+ value >>= uri;
+
+ try
+ {
+ value = xPropSet->getPropertyValue(
+ String::CreateFromAscii( "Description" ) );
+ value >>= description;
+ }
+ catch (Exception &) {
+ // do nothing, the description will be empty
+ }
+
+ SvxGroupInfo_Impl* _pGroupInfo =
+ new SvxGroupInfo_Impl(
+ SVX_CFGFUNCTION_SCRIPT, 123, uri, description );
+
+ Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_NORMAL );
+ SvLBoxEntry* pNewEntry =
+ pFunctionListBox->InsertEntry( children[n]->getName(), NULL );
+ pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_NORMAL);
+ aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False, BMP_COLOR_HIGHCONTRAST );
+ pFunctionListBox->SetExpandedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+ pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage, BMP_COLOR_HIGHCONTRAST);
+
+ pNewEntry->SetUserData( _pGroupInfo );
+
+ pFunctionListBox->aArr.Insert(
+ _pGroupInfo, pFunctionListBox->aArr.Count() );
+
+ }
+ }
+ }
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ break;
+ }
+
+ default:
+ {
+ return;
+ }
+ }
+
+ if ( pFunctionListBox->GetEntryCount() )
+ pFunctionListBox->Select( pFunctionListBox->GetEntry( 0, 0 ) );
+
+ pFunctionListBox->SetUpdateMode(TRUE);
+}
+
+BOOL SvxConfigGroupListBox_Impl::Expand( SvLBoxEntry* pParent )
+{
+ BOOL bRet = SvTreeListBox::Expand( pParent );
+ if ( bRet )
+ {
+ // Wieviele Entries k"onnen angezeigt werden ?
+ ULONG nEntries = GetOutputSizePixel().Height() / GetEntryHeight();
+
+ // Wieviele Kinder sollen angezeigt werden ?
+ ULONG nChildCount = GetVisibleChildCount( pParent );
+
+ // Passen alle Kinder und der parent gleichzeitig in die View ?
+ if ( nChildCount+1 > nEntries )
+ {
+ // Wenn nicht, wenigstens parent ganz nach oben schieben
+ MakeVisible( pParent, TRUE );
+ }
+ else
+ {
+ // An welcher relativen ViewPosition steht der aufzuklappende parent
+ SvLBoxEntry *pEntry = GetFirstEntryInView();
+ ULONG nParentPos = 0;
+ while ( pEntry && pEntry != pParent )
+ {
+ nParentPos++;
+ pEntry = GetNextEntryInView( pEntry );
+ }
+
+ // Ist unter dem parent noch genug Platz f"ur alle Kinder ?
+ if ( nParentPos + nChildCount + 1 > nEntries )
+ ScrollOutputArea( (short)( nEntries - ( nParentPos + nChildCount + 1 ) ) );
+ }
+ }
+
+ return bRet;
+}
+
+void SvxConfigGroupListBox_Impl::RequestingChilds( SvLBoxEntry *pEntry )
+{
+ SvxGroupInfo_Impl *pInfo = (SvxGroupInfo_Impl*) pEntry->GetUserData();
+ pInfo->bWasOpened = TRUE;
+ switch ( pInfo->nKind )
+ {
+ case SVX_CFGGROUP_SCRIPTCONTAINER:
+ {
+ if ( !GetChildCount( pEntry ) )
+ {
+ Reference< browse::XBrowseNode > rootNode( pInfo->xBrowseNode ) ;
+ fillScriptList( rootNode, pEntry, true /* i30923 */ );
+ }
+ break;
+ }
+
+ default:
+ DBG_ERROR( "Falscher Gruppentyp!" );
+ break;
+ }
+}
+
+/*
+ * Implementation of SvxScriptSelectorDialog
+ *
+ * This dialog is used for selecting Slot API commands
+ * and Scripting Framework Scripts.
+ */
+
+SvxScriptSelectorDialog::SvxScriptSelectorDialog(
+ Window* pParent, BOOL bShowSlots, const Reference< frame::XFrame >& xFrame )
+ :
+ ModelessDialog( pParent, CUI_RES( RID_DLG_SCRIPTSELECTOR ) ),
+ aDialogDescription( this, CUI_RES( TXT_SELECTOR_DIALOG_DESCRIPTION ) ),
+ aGroupText( this, CUI_RES( TXT_SELECTOR_CATEGORIES ) ),
+ aCategories( this, CUI_RES( BOX_SELECTOR_CATEGORIES ), bShowSlots, xFrame ),
+ aFunctionText( this, CUI_RES( TXT_SELECTOR_COMMANDS ) ),
+ aCommands( this, CUI_RES( BOX_SELECTOR_COMMANDS ) ),
+ aOKButton( this, CUI_RES( BTN_SELECTOR_OK ) ),
+ aCancelButton( this, CUI_RES( BTN_SELECTOR_CANCEL ) ),
+ aHelpButton( this, CUI_RES( BTN_SELECTOR_HELP ) ),
+ aDescription( this, CUI_RES( GRP_SELECTOR_DESCRIPTION ) ),
+ aDescriptionText( this, CUI_RES( TXT_SELECTOR_DESCRIPTION ) ),
+ m_bShowSlots( bShowSlots )
+{
+
+ ResMgr& rMgr = CUI_MGR();
+
+ // If we are showing Slot API commands update labels in the UI, and
+ // enable drag'n'drop
+ if ( m_bShowSlots )
+ {
+ aGroupText.SetText( String( ResId( STR_SELECTOR_CATEGORIES, rMgr ) ) );
+ aOKButton.SetText( String( ResId( STR_SELECTOR_ADD, rMgr ) ) );
+ aCancelButton.SetText( String( ResId( STR_SELECTOR_CLOSE, rMgr ) ) );
+ aFunctionText.SetText( String( ResId( STR_SELECTOR_COMMANDS, rMgr ) ) );
+ SetDialogDescription(
+ String( ResId( STR_SELECTOR_ADD_COMMANDS_DESCRIPTION, rMgr ) ) );
+ SetText( String( ResId( STR_SELECTOR_ADD_COMMANDS, rMgr ) ) );
+
+ aCommands.SetDragDropMode( SV_DRAGDROP_APP_COPY );
+ }
+
+ ResizeControls();
+
+ aCategories.SetFunctionListBox( &aCommands );
+ aCategories.Init();
+ // aCategories.Select( aCategories.GetEntry( 0, 0 ) );
+
+ aCategories.SetSelectHdl(
+ LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
+ aCommands.SetSelectHdl( LINK( this, SvxScriptSelectorDialog, SelectHdl ) );
+ aCommands.SetDoubleClickHdl( LINK( this, SvxScriptSelectorDialog, FunctionDoubleClickHdl ) );
+
+ aOKButton.SetClickHdl( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
+ aCancelButton.SetClickHdl( LINK( this, SvxScriptSelectorDialog, ClickHdl ) );
+
+ UpdateUI();
+ FreeResource();
+}
+
+void SvxScriptSelectorDialog::ResizeControls()
+{
+ Point p, newp;
+ Size s, news;
+ long gap;
+
+ USHORT style = TEXT_DRAW_MULTILINE | TEXT_DRAW_TOP |
+ TEXT_DRAW_LEFT | TEXT_DRAW_WORDBREAK;
+
+ // get dimensions of dialog instructions control
+ p = aDialogDescription.GetPosPixel();
+ s = aDialogDescription.GetSizePixel();
+
+ // get dimensions occupied by text in the control
+ Rectangle rect =
+ GetTextRect( Rectangle( p, s ), aDialogDescription.GetText(), style );
+ news = rect.GetSize();
+
+ // the gap is the difference between the control height and its text height
+ gap = s.Height() - news.Height();
+
+ // resize the dialog instructions control
+ news = Size( s.Width(), s.Height() - gap );
+ aDialogDescription.SetSizePixel( news );
+
+ // resize other controls to fill the gap
+ p = aGroupText.GetPosPixel();
+ newp = Point( p.X(), p.Y() - gap );
+ aGroupText.SetPosPixel( newp );
+
+ p = aCategories.GetPosPixel();
+ newp = Point( p.X(), p.Y() - gap );
+ aCategories.SetPosPixel( newp );
+ s = aCategories.GetSizePixel();
+ news = Size( s.Width(), s.Height() + gap );
+ aCategories.SetSizePixel( news );
+
+ p = aFunctionText.GetPosPixel();
+ newp = Point( p.X(), p.Y() - gap );
+ aFunctionText.SetPosPixel( newp );
+
+ p = aCommands.GetPosPixel();
+ newp = Point( p.X(), p.Y() - gap );
+ aCommands.SetPosPixel( newp );
+ s = aCommands.GetSizePixel();
+ news = Size( s.Width(), s.Height() + gap );
+ aCommands.SetSizePixel( news );
+
+ p = aOKButton.GetPosPixel();
+ newp = Point( p.X(), p.Y() - gap );
+ aOKButton.SetPosPixel( newp );
+
+ p = aCancelButton.GetPosPixel();
+ newp = Point( p.X(), p.Y() - gap );
+ aCancelButton.SetPosPixel( newp );
+
+ p = aHelpButton.GetPosPixel();
+ newp = Point( p.X(), p.Y() - gap );
+ aHelpButton.SetPosPixel( newp );
+}
+
+SvxScriptSelectorDialog::~SvxScriptSelectorDialog()
+{
+}
+
+IMPL_LINK( SvxScriptSelectorDialog, SelectHdl, Control*, pCtrl )
+{
+ if ( pCtrl == &aCategories )
+ {
+ aCategories.GroupSelected();
+ }
+ else if ( pCtrl == &aCommands )
+ {
+ aCommands.FunctionSelected();
+ }
+ UpdateUI();
+ return 0;
+}
+
+IMPL_LINK( SvxScriptSelectorDialog, FunctionDoubleClickHdl, Control*, pCtrl )
+{
+ (void)pCtrl;
+ if ( aOKButton.IsEnabled() )
+ return ClickHdl( &aOKButton );
+ return 0;
+}
+
+// Check if command is selected and enable the OK button accordingly
+// Grab the help text for this id if available and update the description field
+void
+SvxScriptSelectorDialog::UpdateUI()
+{
+ OUString url = GetScriptURL();
+ if ( url != NULL && url.getLength() != 0 )
+ {
+ String rMessage =
+ aCommands.GetHelpText( aCommands.FirstSelected() );
+ aDescriptionText.SetText( rMessage );
+
+ aOKButton.Enable( TRUE );
+ }
+ else
+ {
+ aDescriptionText.SetText( String() );
+ aOKButton.Enable( FALSE );
+ }
+}
+
+IMPL_LINK( SvxScriptSelectorDialog, ClickHdl, Button *, pButton )
+{
+ if ( pButton == &aCancelButton )
+ {
+ // If we are displaying Slot API commands then the dialog is being
+ // run from Tools/Configure and we should not close it, just hide it
+ if ( m_bShowSlots == FALSE )
+ {
+ EndDialog( RET_CANCEL );
+ }
+ else
+ {
+ Hide();
+ }
+ }
+ else if ( pButton == &aOKButton )
+ {
+ GetAddHdl().Call( this );
+
+ // If we are displaying Slot API commands then this the dialog is being
+ // run from Tools/Configure and we should not close it
+ if ( m_bShowSlots == FALSE )
+ {
+ EndDialog( RET_OK );
+ }
+ else
+ {
+ // Select the next entry in the list if possible
+ SvLBoxEntry* current = aCommands.FirstSelected();
+ SvLBoxEntry* next = aCommands.NextSibling( current );
+
+ if ( next != NULL )
+ {
+ aCommands.Select( next );
+ }
+ }
+ }
+
+ return 0;
+}
+
+void
+SvxScriptSelectorDialog::SetRunLabel()
+{
+ aOKButton.SetText( String( CUI_RES( STR_SELECTOR_RUN ) ) );
+}
+
+void
+SvxScriptSelectorDialog::SetDialogDescription( const String& rDescription )
+{
+ aDialogDescription.SetText( rDescription );
+}
+
+USHORT
+SvxScriptSelectorDialog::GetSelectedId()
+{
+ return aCommands.GetId( aCommands.GetLastSelectedEntry() );
+}
+
+String
+SvxScriptSelectorDialog::GetScriptURL() const
+{
+ OUString result;
+
+ SvLBoxEntry *pEntry = const_cast< SvxScriptSelectorDialog* >( this )->aCommands.GetLastSelectedEntry();
+ if ( pEntry )
+ {
+ SvxGroupInfo_Impl *pData = (SvxGroupInfo_Impl*) pEntry->GetUserData();
+ if ( ( pData->nKind == SVX_CFGFUNCTION_SLOT )
+ || ( pData->nKind == SVX_CFGFUNCTION_SCRIPT )
+ )
+ {
+ result = pData->sURL;
+ }
+ }
+
+ return result;
+}
+
+String
+SvxScriptSelectorDialog::GetSelectedDisplayName()
+{
+ return aCommands.GetEntryText( aCommands.GetLastSelectedEntry() );
+}
+
+String
+SvxScriptSelectorDialog::GetSelectedHelpText()
+{
+ return aCommands.GetHelpText( aCommands.GetLastSelectedEntry() );
+}
diff --git a/cui/source/customize/selector.hrc b/cui/source/customize/selector.hrc
new file mode 100644
index 000000000000..78929c8c9de5
--- /dev/null
+++ b/cui/source/customize/selector.hrc
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define TXT_SELECTOR_DIALOG_DESCRIPTION 1
+#define TXT_SELECTOR_CATEGORIES 2
+#define BOX_SELECTOR_CATEGORIES 3
+#define TXT_SELECTOR_COMMANDS 4
+#define BOX_SELECTOR_COMMANDS 5
+#define BTN_SELECTOR_OK 6
+#define BTN_SELECTOR_CANCEL 7
+#define BTN_SELECTOR_HELP 8
+#define GRP_SELECTOR_DESCRIPTION 9
+#define TXT_SELECTOR_DESCRIPTION 10
+#define IMG_HARDDISK 1
+#define IMG_HARDDISK_HC 2
+#define IMG_LIB 3
+#define IMG_LIB_HC 4
+#define IMG_MACRO 5
+#define IMG_MACRO_HC 6
+#define IMG_DOC 7
+#define IMG_DOC_HC 8
+
+#define STR_SELECTOR_ADD 310
+#define STR_SELECTOR_CLOSE 311
+#define STR_SELECTOR_COMMANDS 312
+#define STR_SELECTOR_ADD_COMMANDS 313
+#define STR_SELECTOR_ADD_COMMANDS_DESCRIPTION 314
+#define STR_SELECTOR_MACROS 315
+#define STR_SELECTOR_CATEGORIES 316
+#define STR_BASICMACROS 317
+#define STR_SELECTOR_RUN 318
+#define STR_MYMACROS 319
+#define STR_PRODMACROS 320
diff --git a/cui/source/customize/selector.src b/cui/source/customize/selector.src
new file mode 100644
index 000000000000..cd4ea9dd5d12
--- /dev/null
+++ b/cui/source/customize/selector.src
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "helpid.hrc"
+#include <cuires.hrc>
+#include "selector.hrc"
+
+#define MASKCOLOR MaskColor = \
+ Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+#define FIXEDTEXT_DIALOG_DESCRIPTION \
+Text [ en-US ] = "Select the library that contains the macro you want. Then select the macro under 'Macro name'." ;\
+
+String STR_SELECTOR_ADD_COMMANDS
+{
+ TEXT [ en-US ] = "Add Commands" ;
+};
+
+String STR_SELECTOR_MACROS
+{
+ Text [ en-US ] = "%PRODUCTNAME Macros" ;
+};
+
+String STR_SELECTOR_CATEGORIES
+{
+ Text [ en-US ] = "~Category" ;
+};
+
+String STR_SELECTOR_COMMANDS
+{
+ Text [ en-US ] = "Commands" ;
+};
+
+String STR_SELECTOR_ADD
+{
+ TEXT [ en-US ] = "Add" ;
+};
+
+String STR_SELECTOR_RUN
+{
+ TEXT [ en-US ] = "Run" ;
+
+};
+
+String STR_SELECTOR_CLOSE
+{
+ TEXT [ en-US ] = "Close" ;
+
+};
+
+String STR_SELECTOR_ADD_COMMANDS_DESCRIPTION
+{
+ TEXT [ en-US ] = "To add a command to a toolbar, select the category and then the command. Then drag the command to the Commands list of the Toolbars tab page in the Customize dialog.";
+};
+
+String STR_BASICMACROS
+{
+ Text [ en-US ] = "BASIC Macros" ;
+};
+
+
+ModelessDialog RID_DLG_SCRIPTSELECTOR
+{
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 256 , 233 ) ;
+ Text [ en-US ] = "Macro Selector" ;
+ HelpId = HID_SELECTOR_DIALOG;
+ SvLook = TRUE ;
+ Moveable = TRUE ;
+ Hide = TRUE;
+ FixedText TXT_SELECTOR_DIALOG_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 190 , 48 ) ;
+ Group = TRUE ;
+ Left = TRUE ;
+ WordBreak = TRUE ;
+ FIXEDTEXT_DIALOG_DESCRIPTION
+ };
+ FixedText TXT_SELECTOR_CATEGORIES
+ {
+ Pos = MAP_APPFONT ( 6 , 62 ) ;
+ Size = MAP_APPFONT ( 83 , 8 ) ;
+ Group = TRUE ;
+ Left = TRUE ;
+ Text [ en-US ] = "Library" ;
+ };
+ Control BOX_SELECTOR_CATEGORIES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 73 ) ;
+ Size = MAP_APPFONT ( 83 , 89 ) ;
+ TabStop = TRUE;
+ HelpId = HID_SELECTOR_CATEGORIES;
+ String STR_MYMACROS
+ {
+ Text [ en-US ] = "My Macros";
+ };
+ String STR_PRODMACROS
+ {
+ Text [ en-US ] = "%PRODUCTNAME Macros";
+ };
+ Image IMG_HARDDISK
+ {
+ ImageBitmap = Bitmap { File = "harddisk_16.bmp" ; };
+ MASKCOLOR
+ };
+ Image IMG_HARDDISK_HC
+ {
+ ImageBitmap = Bitmap { File = "harddisk_16_h.bmp" ; };
+ MASKCOLOR
+ };
+ Image IMG_LIB
+ {
+ ImageBitmap = Bitmap { File = "im30820.png"; };
+ MASKCOLOR
+ };
+ Image IMG_LIB_HC
+ {
+ ImageBitmap = Bitmap { File = "imh30820.png"; };
+ MASKCOLOR
+ };
+ Image IMG_MACRO
+ {
+ ImageBitmap = Bitmap { File = "im30821.png"; };
+ MASKCOLOR
+ };
+ Image IMG_MACRO_HC
+ {
+ ImageBitmap = Bitmap { File = "imh30821.png"; };
+ MASKCOLOR
+ };
+ Image IMG_DOC
+ {
+ ImageBitmap = Bitmap { File = "im30826.png"; };
+ MASKCOLOR
+ };
+ Image IMG_DOC_HC
+ {
+ ImageBitmap = Bitmap { File = "imh30826.png"; };
+ MASKCOLOR
+ };
+ };
+ FixedText TXT_SELECTOR_COMMANDS
+ {
+ Pos = MAP_APPFONT ( 101 , 62 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "Macro name" ;
+ };
+ Control BOX_SELECTOR_COMMANDS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 101 , 73 ) ;
+ Size = MAP_APPFONT ( 93 , 89 ) ;
+ TabStop = TRUE;
+ HelpId = HID_SELECTOR_COMMANDS;
+ };
+ OKButton BTN_SELECTOR_OK
+ {
+ Pos = MAP_APPFONT ( 200 , 73 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton BTN_SELECTOR_CANCEL
+ {
+ Pos = MAP_APPFONT ( 200 , 90 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_SELECTOR_HELP
+ {
+ Pos = MAP_APPFONT ( 200 , 107 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedLine GRP_SELECTOR_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 6 , 168 ) ;
+ Size = MAP_APPFONT ( 224 , 8 ) ;
+ Group = TRUE ;
+ Text [ en-US ] = "Description" ;
+ };
+ FixedText TXT_SELECTOR_DESCRIPTION
+ {
+ Pos = MAP_APPFONT ( 12 , 179 ) ;
+ Size = MAP_APPFONT ( 224 , 48 ) ;
+ WordBreak = TRUE ;
+ };
+};
+ // ********************************************************************** EOF