diff options
Diffstat (limited to 'cui/source/customize')
-rw-r--r-- | cui/source/customize/acccfg.cxx | 1578 | ||||
-rw-r--r-- | cui/source/customize/acccfg.hrc | 68 | ||||
-rw-r--r-- | cui/source/customize/acccfg.src | 270 | ||||
-rw-r--r-- | cui/source/customize/cfg.cxx | 5755 | ||||
-rw-r--r-- | cui/source/customize/cfg.hrc | 110 | ||||
-rw-r--r-- | cui/source/customize/cfg.src | 899 | ||||
-rw-r--r-- | cui/source/customize/cfgutil.cxx | 1261 | ||||
-rw-r--r-- | cui/source/customize/eventdlg.cxx | 242 | ||||
-rw-r--r-- | cui/source/customize/eventdlg.hrc | 43 | ||||
-rw-r--r-- | cui/source/customize/eventdlg.hxx | 80 | ||||
-rw-r--r-- | cui/source/customize/eventdlg.src | 104 | ||||
-rw-r--r-- | cui/source/customize/macropg.cxx | 1027 | ||||
-rw-r--r-- | cui/source/customize/macropg.hrc | 99 | ||||
-rw-r--r-- | cui/source/customize/macropg.src | 480 | ||||
-rw-r--r-- | cui/source/customize/macropg_impl.hxx | 74 | ||||
-rw-r--r-- | cui/source/customize/selector.cxx | 1175 | ||||
-rw-r--r-- | cui/source/customize/selector.hrc | 54 | ||||
-rw-r--r-- | cui/source/customize/selector.src | 192 |
18 files changed, 0 insertions, 13511 deletions
diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx deleted file mode 100644 index fa46fb429..000000000 --- a/cui/source/customize/acccfg.cxx +++ /dev/null @@ -1,1578 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 own files - -#include "acccfg.hxx" -#include "cfgutil.hxx" -#include <dialmgr.hxx> - -#include <sfx2/msg.hxx> -#include <sfx2/app.hxx> -#include <sfx2/filedlghelper.hxx> -#include <sfx2/minfitem.hxx> -#include <sfx2/sfxresid.hxx> -#include <svl/stritem.hxx> - -#include <sal/macros.h> - -#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/ui/XModuleUIConfigurationManagerSupplier.hpp> -#include <com/sun/star/frame/XModuleManager.hpp> - -#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> -#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_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory" )); -static ::rtl::OUString SERVICE_UICONFIGMGR (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.UIConfigurationManager" )); -static ::rtl::OUString SERVICE_DESKTOP (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" )); -static ::rtl::OUString SERVICE_MODULEMANAGER (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.ModuleManager" )); -static ::rtl::OUString SERVICE_GLOBALACCCFG (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.GlobalAcceleratorConfiguration" )); -static ::rtl::OUString SERVICE_MODULEUICONFIGSUPPLIER (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")); -static ::rtl::OUString SERVICE_UICMDDESCRIPTION (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.UICommandDescription" )); - -static ::rtl::OUString MODULEPROP_SHORTNAME (RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryShortName" )); -static ::rtl::OUString MODULEPROP_UINAME (RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryUIName" )); -static ::rtl::OUString CMDPROP_UINAME (RTL_CONSTASCII_USTRINGPARAM("Name" )); - -static ::rtl::OUString FOLDERNAME_UICONFIG (RTL_CONSTASCII_USTRINGPARAM("Configurations2" )); - -static ::rtl::OUString MEDIATYPE_PROPNAME (RTL_CONSTASCII_USTRINGPARAM("MediaType" )); -static ::rtl::OUString MEDIATYPE_UICONFIG (RTL_CONSTASCII_USTRINGPARAM("application/vnd.sun.xml.ui.configuration" )); - -//----------------------------------------------- -static sal_uInt16 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_F13 , - KEY_F14 , - KEY_F15 , - KEY_F16 , - - 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_F13 | KEY_SHIFT, - KEY_F14 | KEY_SHIFT, - KEY_F15 | KEY_SHIFT, - KEY_F16 | 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_SEMICOLON | KEY_MOD1 , - KEY_BRACKETLEFT | KEY_MOD1 , - KEY_BRACKETRIGHT | 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_F13 | KEY_MOD1 , - KEY_F14 | KEY_MOD1 , - KEY_F15 | KEY_MOD1 , - KEY_F16 | 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_SEMICOLON | KEY_SHIFT | KEY_MOD1 , - KEY_BRACKETLEFT | KEY_SHIFT | KEY_MOD1 , - KEY_BRACKETRIGHT | 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_F13 | KEY_SHIFT | KEY_MOD1, - KEY_F14 | KEY_SHIFT | KEY_MOD1, - KEY_F15 | KEY_SHIFT | KEY_MOD1, - KEY_F16 | 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_SEMICOLON | KEY_MOD2 , - KEY_BRACKETLEFT | KEY_MOD2 , - KEY_BRACKETRIGHT | 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_F13 | KEY_MOD2 , - KEY_F14 | KEY_MOD2 , - KEY_F15 | KEY_MOD2 , - KEY_F16 | 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_SEMICOLON | KEY_SHIFT | KEY_MOD2 , - KEY_BRACKETLEFT | KEY_SHIFT | KEY_MOD2 , - KEY_BRACKETRIGHT | 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_F13 | KEY_SHIFT | KEY_MOD2, - KEY_F14 | KEY_SHIFT | KEY_MOD2, - KEY_F15 | KEY_SHIFT | KEY_MOD2, - KEY_F16 | 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_F13 | KEY_MOD1 | KEY_MOD2 , - KEY_F14 | KEY_MOD1 | KEY_MOD2 , - KEY_F15 | KEY_MOD1 | KEY_MOD2 , - KEY_F16 | 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_SEMICOLON | KEY_SHIFT | KEY_MOD1 | KEY_MOD2, - KEY_BRACKETLEFT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2, - KEY_BRACKETRIGHT | 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_F13 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2, - KEY_F14 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2, - KEY_F15 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2, - KEY_F16 | 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 sal_uInt16 KEYCODE_ARRAY_SIZE = SAL_N_ELEMENTS(KEYCODE_ARRAY); - -//----------------------------------------------- -// 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, - sal_uInt16 nFlags, - const String& sText ); - - virtual ~SfxAccCfgLBoxString_Impl(); - - virtual void Paint(const Point& aPos , - SvLBox& rDevice, - sal_uInt16 nFlags , - SvLBoxEntry* pEntry ); -}; - -//----------------------------------------------- -SfxAccCfgLBoxString_Impl::SfxAccCfgLBoxString_Impl( SvLBoxEntry* pEntry, - sal_uInt16 nFlags, - const String& sText ) - : SvLBoxString(pEntry, nFlags, sText) -{ -} - -//----------------------------------------------- -SfxAccCfgLBoxString_Impl::~SfxAccCfgLBoxString_Impl() -{ -} - -//----------------------------------------------- -void SfxAccCfgLBoxString_Impl::Paint(const Point& aPos , - SvLBox& rDevice, - sal_uInt16 /*nFlags*/, - SvLBoxEntry* pEntry ) -{ - - 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); - -} - -//----------------------------------------------- -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(); - sal_uInt16 nCode1 = aCode1.GetCode(); - sal_uInt16 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) - { - sal_uInt16 nCode2 = pUserData->m_aKey.GetCode(); - sal_uInt16 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 ) ) - , aFilterCfgStr ( CUI_RES( STR_FILTERNAME_CFG ) ) - , m_bStylesInfoInitialized(sal_False) - , m_xGlobal () - , m_xModule () - , m_xAct () -{ - FreeResource(); - - aFilterAllStr = String( SfxResId( STR_SFX_FILTERNAME_ALL ) ); - -// 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.SetStyle(aEntriesBox.GetStyle()|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 ( sal_uInt16 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.SetStyle(aKeyBox.GetStyle()|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. - sal_uInt16 c1 = KEYCODE_ARRAY_SIZE; - sal_uInt16 i1 = 0; - sal_uInt16 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; - sal_uInt16 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); - sal_uInt16 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 - sal_uLong c3 = Application::GetReservedKeyCodeCount(); - sal_uLong i3 = 0; - for (i3=0; i3<c3; ++i3) - { - const KeyCode* pKeyCode = Application::GetReservedKeyCode(i3); - sal_uInt16 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, aSaveAccelConfigStr ); - 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(sal_False); - ResetConfig(); - Init(m_xAct); - aEntriesBox.SetUpdateMode(sal_True); - aEntriesBox.Invalidate(); - aEntriesBox.Select(aEntriesBox.GetEntry(0, 0)); - - return 0; -} - -//----------------------------------------------- -IMPL_LINK( SfxAcceleratorConfigPage, ChangeHdl, Button*, EMPTYARG ) -{ - sal_uInt16 nPos = (sal_uInt16) 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; - sal_uInt16 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 - sal_uInt16 nPos = (sal_uInt16) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() ); - TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData(); - - // remove function name from selected entry - sal_uInt16 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 ) - { - sal_uInt16 nPos = (sal_uInt16) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() ); - TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData(); - ::rtl::OUString sPossibleNewCommand = pFunctionBox->GetCurCommand(); - - aRemoveButton.Enable( sal_False ); - aChangeButton.Enable( sal_False ); - - if (pEntry->m_bIsConfigurable) - { - if (pEntry->isConfigured()) - aRemoveButton.Enable( sal_True ); - aChangeButton.Enable( pEntry->m_sCommand != sPossibleNewCommand ); - } - } - else if ( pListBox == pGroupLBox ) - { - pGroupLBox->GroupSelected(); - if ( !pFunctionBox->FirstSelected() ) - aChangeButton.Enable( sal_False ); - } - else if ( pListBox == pFunctionBox ) - { - aRemoveButton.Enable( sal_False ); - aChangeButton.Enable( sal_False ); - - // #i36994 First selected can return zero! - SvLBoxEntry* pLBEntry = aEntriesBox.FirstSelected(); - if ( pLBEntry != 0 ) - { - sal_uInt16 nPos = (sal_uInt16) 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( sal_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, sal_True, LIST_APPEND ); - pE1->SetUserData(pU1); - pE1->EnableChildsOnDemand( sal_False ); - } - pIt = aEntriesBox.Next(pIt); - } - } - } - else - { - // goto selected "key" entry of the key box - SvLBoxEntry* pE2 = 0; - TAccInfo* pU2 = 0; - sal_uInt16 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( sal_False ); - ResetConfig(); - Init(m_xAct); - aEntriesBox.SetUpdateMode( sal_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(sal_False); - ResetConfig(); - Init(xTempAccMgr); - aEntriesBox.SetUpdateMode(sal_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; -} - -//----------------------------------------------- -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->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 ); -} - -//----------------------------------------------- -sal_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 sal_False; } - - return sal_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, sal_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, sal_True, &pStringItem ) ) - m_pStringItem = PTR_CAST( SfxStringItem, pStringItem ); - - const SfxPoolItem* pFontItem=0; - if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_SPECIALCHAR, sal_True, &pFontItem ) ) - m_pFontItem = PTR_CAST( SfxStringItem, pFontItem ); - } -} - -//----------------------------------------------- -sal_uInt16 SfxAcceleratorConfigPage::MapKeyCodeToPos(const KeyCode& aKey) const -{ - sal_uInt16 nCode1 = aKey.GetCode()+aKey.GetModifier(); - SvLBoxEntry* pEntry = aEntriesBox.First(); - sal_uInt16 i = 0; - - while (pEntry) - { - TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData(); - if (pUserData) - { - sal_uInt16 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 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/acccfg.hrc b/cui/source/customize/acccfg.hrc deleted file mode 100644 index eaa39b11e..000000000 --- a/cui/source/customize/acccfg.hrc +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#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 STR_PRODMACROS 50 -#define STR_MYMACROS 51 -#define IMG_LIB 52 -#define IMG_MACRO 54 -#define IMG_DOC 56 -#define STR_GROUP_STYLES 58 -#define STR_PDF_EXPORT_SEND 59 -#define STR_RECHECK_DOCUMENT 60 -#define IMG_INFO 61 - // FREE -#define BMP_COLLAPSED 63 -#define BMP_EXPANDED 64 -#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 deleted file mode 100644 index 874ac854f..000000000 --- a/cui/source/customize/acccfg.src +++ /dev/null @@ -1,270 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - // include --------------------------------------------------------------- -#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 - { - HelpID = "cui:RadioButton:RID_SVXPAGE_KEYBOARD:RB_OFFICE"; - Pos = MAP_APPFONT ( 192 , 6 ) ; - Size = MAP_APPFONT ( 75 , 10 ) ; - Text = "%PRODUCTNAME" ; - }; - RadioButton RB_MODULE - { - HelpID = "cui:RadioButton:RID_SVXPAGE_KEYBOARD:RB_MODULE"; - Pos = MAP_APPFONT ( 192 , 19 ) ; - Size = MAP_APPFONT ( 75 , 10 ) ; - Text = "$(MODULE)" ; - }; - PushButton BTN_ACC_CHANGE - { - HelpID = "cui:PushButton:RID_SVXPAGE_KEYBOARD:BTN_ACC_CHANGE"; - Pos = MAP_APPFONT ( 192 , 35 ) ; - Size = MAP_APPFONT ( 75 , 14 ) ; - TabStop = TRUE ; - PUSHBUTTON_TEXT_CHANGE - }; - PushButton BTN_ACC_REMOVE - { - HelpID = "cui:PushButton:RID_SVXPAGE_KEYBOARD: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 - { - HelpID = "cui:PushButton:RID_SVXPAGE_KEYBOARD:BTN_LOAD"; - Pos = MAP_APPFONT ( 192 , 86 ) ; - Size = MAP_APPFONT ( 75 , 14 ) ; - TabStop = TRUE ; - Group = TRUE ; - PUSHBUTTON_TEXT_LOAD - }; - PushButton BTN_SAVE - { - HelpID = "cui:PushButton:RID_SVXPAGE_KEYBOARD:BTN_SAVE"; - Pos = MAP_APPFONT ( 192 , 103 ) ; - Size = MAP_APPFONT ( 75 , 14 ) ; - TabStop = TRUE ; - Group = TRUE ; - PUSHBUTTON_TEXT_SAVE - }; - PushButton BTN_RESET - { - HelpID = "cui:PushButton:RID_SVXPAGE_KEYBOARD: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_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_LIB - { - ImageBitmap = Bitmap { File = "im30820.png"; }; - MASKCOLOR - }; - Image IMG_MACRO - { - ImageBitmap = Bitmap { File = "im30821.png"; }; - MASKCOLOR - }; - Image IMG_DOC - { - ImageBitmap = Bitmap { File = "im30826.png"; }; - MASKCOLOR - }; - Image BMP_COLLAPSED - { - ImageBitmap = Bitmap - { - File = "plus.bmp" ; - }; - }; - Image BMP_EXPANDED - { - ImageBitmap = Bitmap - { - File = "minus.bmp" ; - }; - }; -}; - - // ********************************************************************** EOF diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx deleted file mode 100644 index 0375964f6..000000000 --- a/cui/source/customize/cfg.cxx +++ /dev/null @@ -1,5755 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 <stdlib.h> -#include <time.h> - -#include <vcl/help.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/decoview.hxx> -#include <vcl/toolbox.hxx> -#include <vcl/scrbar.hxx> - -#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/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> -#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> -#include <unotools/configmgr.hxx> -#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> -#include <com/sun/star/ui/UIElementType.hpp> -#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_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 pSeparatorStr[] = - "----------------------------------"; -static const char 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; - -#if OSL_DEBUG_LEVEL > 1 - -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 ) - { - 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())); - } -} - -#endif - -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(RTL_CONSTASCII_USTRINGPARAM( "%SAVE IN SELECTION%" )); - - sal_Int32 pos = rMessage.indexOf( placeholder ); - - if ( pos != -1 ) - { - name = rMessage.replaceAt( - pos, placeholder.getLength(), rSaveInName ); - } - - 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(RTL_CONSTASCII_USTRINGPARAM( "%n" )); - - sal_Int32 pos = prefix.indexOf( - OUString(RTL_CONSTASCII_USTRINGPARAM( "%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(RTL_CONSTASCII_USTRINGPARAM( ITEM_TOOLBAR_URL )); - url += OUString(RTL_CONSTASCII_USTRINGPARAM( 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(RTL_CONSTASCII_USTRINGPARAM( 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; - } -} - -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.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.script.BasicIDE" ) ) - || aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.frame.Bibliography" ) ) - ) - { - return sal_False; - } - return sal_True; -} - -OUString GetModuleName( const OUString& aModuleId ) -{ - if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.TextDocument" ) ) || - aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.GlobalDocument" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Writer")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.text.WebDocument" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Writer/Web")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Draw")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Impress")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Calc")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.script.BasicIDE" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Basic")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.formula.FormulaProperties" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Math")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.sdb.RelationDesign" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Relation Design")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.sdb.QueryDesign" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Query Design")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.sdb.TableDesign" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Table Design")); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.sdb.DataSourceBrowser" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("Data Source Browser" )); - else if ( aModuleId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.sdb.DatabaseDocument" ) ) ) - return OUString(RTL_CONSTASCII_USTRINGPARAM("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.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "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& 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_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 sal_True; - } - } - catch ( ::com::sun::star::lang::IndexOutOfBoundsException& ) - { - } - - return sal_False; -} - -bool GetToolbarItemData( - const uno::Reference< container::XIndexAccess >& rItemContainer, - sal_Int32 nIndex, - OUString& rCommandURL, - 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_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 aDescriptorContainer( - RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ) ); - - uno::Sequence< beans::PropertyValue > aPropSeq( 3 ); - - 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() == sal_False && pEntry->GetCommand().getLength() ) - { - sal_Bool isDefaultName = sal_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 = sal_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() ); - } - - 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 aDescriptorContainer( - RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER ) ); - - static const OUString aIsVisible( - RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_ISVISIBLE ) ); - - 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() == sal_False && pEntry->GetCommand().getLength() ) - { - sal_Bool isDefaultName = sal_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 = sal_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 = aIsVisible; - aPropSeq[3].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_CONSTASCII_USTRINGPARAM ("com.sun.star.frame.ModuleManager") ); - static ::rtl::OUString SERVICENAME_DESKTOP (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.frame.Desktop" ) ); - static ::rtl::OUString MODULEID_STARTMODULE (RTL_CONSTASCII_USTRINGPARAM ("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(RTL_CONSTASCII_USTRINGPARAM(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( sal_uInt16 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; - } -} - -/****************************************************************************** - * - * 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( sal_False ), - bDocConfig( isDocConfig ), - bReadOnly( sal_False ), - m_xCfgMgr( xCfgMgr ), - m_xParentCfgMgr( xParentCfgMgr ) -{ - uno::Reference< beans::XPropertySet > xProps( - ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); - - xProps->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM( "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 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 = sal_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 = sal_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(), sal_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(); - - // Don't access non existing menu configuration! - if ( !xMenuSettings.is() ) - return true; - - for ( sal_Int32 nIndex = 0; nIndex < xMenuSettings->getCount(); ++nIndex ) - { - uno::Reference< container::XIndexAccess > xSubMenu; - OUString aCommandURL; - OUString aLabel; - bool bIsUserDefined = sal_True; - - sal_uInt16 nType( css::ui::ItemType::DEFAULT ); - - bool bItem = GetMenuItemData( xMenuSettings, nIndex, - aCommandURL, aLabel, nType, xSubMenu ); - - if ( bItem ) - { - if ( nType == css::ui::ItemType::DEFAULT ) - { - uno::Any a; - try - { - a = m_xCommandToLabelMap->getByName( aCommandURL ); - bIsUserDefined = sal_False; - } - catch ( container::NoSuchElementException& ) - { - bIsUserDefined = sal_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, sal_True ); - - pEntry->SetUserDefined( bIsUserDefined ); - - pEntries->push_back( pEntry ); - - OUString subMenuTitle( rBaseTitle ); - - if ( subMenuTitle.getLength() != 0 ) - { - subMenuTitle += - OUString::createFromAscii(pMenuSeparatorStr); - } - else - { - pEntry->SetMain( sal_True ); - } - - subMenuTitle += stripHotKey( aLabel ); - - LoadSubMenus( xSubMenu, subMenuTitle, pEntry ); - } - else - { - SvxConfigEntry* pEntry = new SvxConfigEntry( - aLabel, aCommandURL, sal_False ); - pEntry->SetUserDefined( bIsUserDefined ); - pEntries->push_back( pEntry ); - } - } - else - { - SvxConfigEntry* pEntry = new SvxConfigEntry; - pEntry->SetUserDefined( bIsUserDefined ); - pEntries->push_back( pEntry ); - } - } - } - return true; -} - -bool MenuSaveInData::Apply() -{ - bool result = sal_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( sal_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, - sal_uInt16 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( sal_False ) -{ - SetStyle( - 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 = sal_True; - return GetDragDropMode(); -} - -void SvxMenuEntriesListBox::DragFinished( sal_Int8 nDropAction ) -{ - (void)nDropAction; - m_bIsInternalDrag = sal_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 ); -} - -sal_Bool SvxMenuEntriesListBox::NotifyAcceptDrop( SvLBoxEntry* ) -{ - return sal_True; -} - -sal_Bool SvxMenuEntriesListBox::NotifyMoving( - SvLBoxEntry* pTarget, SvLBoxEntry* pSource, - SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos) -{ - // only try to do a move if we are dragging within the list box - if ( m_bIsInternalDrag ) - { - if ( pPage->MoveEntryData( pSource, pTarget ) == sal_True ) - { - SvTreeListBox::NotifyMoving( - pTarget, pSource, rpNewParent, rNewChildPos ); - return sal_True; - } - else - { - return sal_False; - } - } - else - { - return NotifyCopying( pTarget, pSource, rpNewParent, rNewChildPos ); - } -} - -sal_Bool SvxMenuEntriesListBox::NotifyCopying( - SvLBoxEntry* pTarget, SvLBoxEntry* pSource, - SvLBoxEntry*& rpNewParent, sal_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 sal_False; - } - - // Copying is only allowed from external controls, not within the listbox - return sal_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( sal_True ); - } - else if ( keycode.GetCode() == KEY_DOWN && keycode.IsMod1() ) - { - pPage->MoveEntry( sal_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( sal_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( sal_True ); - aDescriptionField.EnableCursor( sal_False ); - - aMoveUpButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_UP))); - aMoveDownButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_DOWN))); - aMoveUpButton.SetAccessibleRelationMemberOf(&aContentsSeparator); - aMoveDownButton.SetAccessibleRelationMemberOf(&aContentsSeparator); - aNewTopLevelButton.SetAccessibleRelationMemberOf(&aTopLevelSeparator); - aModifyTopLevelButton.SetAccessibleRelationMemberOf(&aTopLevelSeparator); - aAddCommandsButton.SetAccessibleRelationMemberOf(&aContentsSeparator); - aModifyCommandButton.SetAccessibleRelationMemberOf(&aContentsSeparator); -} - -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 ) - { - sal_uInt16 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(RTL_CONSTASCII_USTRINGPARAM( "%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, - sal_False ); - } - catch ( container::NoSuchElementException& ) - { - } - - if ( pModuleData != NULL ) - { - OUString label; - utl::ConfigManager::GetDirectConfigProperty( - utl::ConfigManager::PRODUCTNAME ) >>= label; - label += OUString(RTL_CONSTASCII_USTRINGPARAM( " " )); - 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, sal_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 = sal_False; - if ( m_aURLToSelect.getLength() != 0 ) - { - if ( pDocData != NULL && pDocData->HasURL( m_aURLToSelect ) ) - { - aSaveInListBox.SelectEntryPos( nPos, sal_True ); - pCurrentSaveInData = pDocData; - bURLToSelectFound = sal_True; - } - else if ( pModuleData->HasURL( m_aURLToSelect ) ) - { - aSaveInListBox.SelectEntryPos( 0, sal_True ); - pCurrentSaveInData = pModuleData; - bURLToSelectFound = sal_True; - } - } - - if ( bURLToSelectFound == sal_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, sal_True ); - pCurrentSaveInData = pDocData; - } - else - { - aSaveInListBox.SelectEntryPos( 0, sal_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, sal_True ); - - if ( pData && !pData->IsReadOnly() ) - { - nPos = aSaveInListBox.InsertEntry( aTitle2 ); - aSaveInListBox.SetEntryData( nPos, pData ); - } - } - } - } - } - } - - aSaveInListBox.SetSelectHdl( - LINK( this, SvxConfigPage, SelectSaveInLocation ) ); - - bInitialised = sal_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; -} - -sal_Bool SvxConfigPage::FillItemSet( SfxItemSet& ) -{ - bool result = sal_False; - - for ( sal_uInt16 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 ) -{ - sal_uInt16 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; - sal_uInt16 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, sal_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() ); - - sal_uInt16 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, sal_False ); - pNewEntryData->SetUserDefined( sal_True ); - - // 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 - sal_uInt16 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( sal_True ); - } - - return pNewEntry; -} - -SvLBoxEntry* SvxConfigPage::InsertEntryIntoUI( - SvxConfigEntry* pNewEntryData, sal_uLong nPos ) -{ - SvLBoxEntry* pNewEntry = NULL; - - if (pNewEntryData->IsSeparator()) - { - pNewEntry = aContentsListBox->InsertEntry( - String::CreateFromAscii( pSeparatorStr ), - 0, sal_False, nPos, pNewEntryData ); - } - else - { - OUString aName = stripHotKey( pNewEntryData->GetName() ); - - Image aImage = GetSaveInData()->GetImage( - pNewEntryData->GetCommand()); - - if ( !!aImage ) - { - pNewEntry = aContentsListBox->InsertEntry( - aName, aImage, aImage, 0, sal_False, nPos, pNewEntryData ); - } - else - { - pNewEntry = aContentsListBox->InsertEntry( - aName, 0, sal_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 sal_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( sal_True ); - - return sal_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( sal_True ); - - return sal_True; - } - } - - return sal_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, sal_True); - aTopLevelListBox.GetSelectHdl().Call(this); -} - -SvxMenuConfigPage::~SvxMenuConfigPage() -{ - for ( sal_uInt16 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( sal_False ); - aMoveDownButton.Enable( sal_False ); - - pPopup->EnableItem( ID_BEGIN_GROUP, sal_True ); - pPopup->EnableItem( ID_RENAME, sal_False ); - pPopup->EnableItem( ID_DELETE, sal_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, sal_True ); - pPopup->EnableItem( ID_BEGIN_GROUP, sal_False ); - pPopup->EnableItem( ID_RENAME, sal_False ); - - aDescriptionField.Clear(); - } - else - { - pPopup->EnableItem( ID_BEGIN_GROUP, sal_True ); - pPopup->EnableItem( ID_DELETE, sal_True ); - pPopup->EnableItem( ID_RENAME, sal_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( sal_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( sal_True ); - - return sal_True; - } - return sal_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(); - if ( pMenuData ) - { - 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( sal_True ); - } - - // #i68101# Memory 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( sal_True ); - } - - delete pDialog; - - break; - } - default: - return sal_False; - } - return sal_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, sal_True ); - pNewEntryData->SetUserDefined( sal_True ); - - InsertEntry( pNewEntryData ); - - ReloadTopLevelListBox(); - - GetSaveInData()->SetModified( sal_True ); - } - - delete pNameDialog; - - break; - } - case ID_BEGIN_GROUP: - { - SvxConfigEntry* pNewEntryData = new SvxConfigEntry; - pNewEntryData->SetUserDefined( sal_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( sal_True ); - } - - delete pNameDialog; - - break; - } - default: - { - return sal_False; - } - } - - if ( GetSaveInData()->IsModified() ) - { - UpdateButtonStates(); - } - - return sal_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, sal_True ); - - bool ret = pDialog->Execute(); - - if ( ret == RET_OK ) - { - GetSaveInData()->SetEntries( pDialog->GetEntries() ); - ReloadTopLevelListBox( pDialog->GetSelectedEntry() ); - GetSaveInData()->SetModified( sal_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, sal_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( sal_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, sal_True ); - pNewEntryData->SetUserDefined( sal_True ); - pNewEntryData->SetMain( sal_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) ); - - aMoveUpButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_UP))); - aMoveDownButton.SetAccessibleName(String(CUI_RES(BUTTON_STR_DOWN))); -} - -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 = sal_True; - } - } - - if ( bModified ) - { - UpdateButtonStates(); - } - - return 0; -} - -SvxEntries* SvxMainMenuOrganizerDialog::GetEntries() -{ - return pEntries; -} - -SvxConfigEntry* SvxMainMenuOrganizerDialog::GetSelectedEntry() -{ - return (SvxConfigEntry*)aMenuListBox.FirstSelected()->GetUserData(); -} - -const OUString& -SvxConfigEntry::GetHelpText() -{ - if ( aHelpText.getLength() == 0 ) - { - if ( aCommand.getLength() ) - { - aHelpText = Application::GetHelp()->GetHelpText( aCommand, NULL ); - } - } - - return aHelpText; -} - -SvxConfigEntry::SvxConfigEntry( const OUString& rDisplayName, - const OUString& rCommandURL, bool bPopup, bool bParentData ) - : nId( 1 ) - , aLabel(rDisplayName) - , aCommand(rCommandURL) - , bPopUp(bPopup) - , bStrEdited( sal_False ) - , bIsUserDefined( sal_False ) - , bIsMain( sal_False ) - , bIsParentData( bParentData ) - , bIsVisible( sal_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 sal_False; - } - return sal_True; -} - -bool SvxConfigEntry::IsDeletable() -{ - if ( IsMain() && !IsUserDefined() ) - { - return sal_False; - } - return sal_True; -} - -bool SvxConfigEntry::IsRenamable() -{ - if ( IsMain() && !IsUserDefined() ) - { - return sal_False; - } - return sal_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( sal_True ); - aMoveUpButton.Enable( sal_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(RTL_CONSTASCII_USTRINGPARAM( ITEM_TOOLBAR_URL )); - m_aURLToSelect += OUString(RTL_CONSTASCII_USTRINGPARAM( "standardbar" )); - - const SfxPoolItem* pItem = - rSet.GetItem( rSet.GetPool()->GetWhich( SID_CONFIG ) ); - - if ( pItem ) - { - OUString text = ((const SfxStringItem*)pItem)->GetValue(); - if (text.indexOf(OUString(RTL_CONSTASCII_USTRINGPARAM(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 ( sal_uInt16 i = 0 ; i < aSaveInListBox.GetEntryCount(); ++i ) - { - ToolbarSaveInData* pData = - (ToolbarSaveInData*) aSaveInListBox.GetEntryData( i ); - - delete pData; - } - - if ( pSelectorDlg != NULL ) - { - delete pSelectorDlg; - } - - - delete aContentsListBox; -} - -void SvxToolbarConfigPage::DeleteSelectedTopLevel() -{ - sal_uInt16 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, sal_True ); - } - else - { - aTopLevelListBox.SelectEntryPos( nSelectionPos - 1, sal_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 sal_True; - } - - return sal_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 ) -{ - sal_uInt16 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 = sal_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 = sal_True; - } - - delete pNameDialog; - break; - } - case ID_DEFAULT_COMMAND: - { - SvLBoxEntry* pActEntry = aContentsListBox->GetCurEntry(); - SvxConfigEntry* pEntry = - (SvxConfigEntry*) pActEntry->GetUserData(); - - sal_uInt16 nSelectionPos = 0; - - // find position of entry within the list - for ( sal_uInt16 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 = sal_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 = sal_True; - } - catch ( uno::Exception& ) - { - OSL_TRACE("Error restoring image"); - } - break; - } - case ID_BEGIN_GROUP: - { - SvxConfigEntry* pNewEntryData = new SvxConfigEntry; - pNewEntryData->SetUserDefined( sal_True ); - - SvLBoxEntry* pNewLBEntry = InsertEntry( pNewEntryData ); - - aContentsListBox->SetCheckButtonState( - pNewLBEntry, SV_BUTTON_TRISTATE ); - - bNeedsApply = sal_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(); - - sal_uInt16 nSelectionPos = 0; - - // find position of entry within the list - for ( sal_uInt16 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(); - - sal_uInt16 nSelectionPos = 0; - - // find position of entry within the list - for ( sal_uInt16 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 == sal_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(); - - sal_uInt16 nPos = 0; - if ( m_aURLToSelect.getLength() != 0 ) - { - for ( sal_uInt16 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(RTL_CONSTASCII_USTRINGPARAM( ITEM_TOOLBAR_URL )); - m_aURLToSelect += OUString(RTL_CONSTASCII_USTRINGPARAM( "standardbar" )); - } - - aTopLevelListBox.SelectEntryPos(nPos, sal_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(RTL_CONSTASCII_USTRINGPARAM( "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(RTL_CONSTASCII_USTRINGPARAM( "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(RTL_CONSTASCII_USTRINGPARAM( "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(RTL_CONSTASCII_USTRINGPARAM( ".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 ::boost::unordered_map< ::rtl::OUString, - bool, - ::rtl::OUStringHash, - ::std::equal_to< ::rtl::OUString > > ToolbarInfo; - - ToolbarInfo aToolbarInfo; - - if ( pRootEntry == NULL ) - { - - pRootEntry = new SvxConfigEntry( - String::CreateFromAscii("MainToolbars"), String(), sal_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, sal_True ); - - pEntry->SetMain( sal_True ); - pEntry->SetStyle( GetSystemStyle( url ) ); - - - // insert into boost::unordered_map to filter duplicates from the parent - aToolbarInfo.insert( ToolbarInfo::value_type( systemname, true )); - - OUString custom(RTL_CONSTASCII_USTRINGPARAM(CUSTOM_TOOLBAR_STR)); - if ( systemname.indexOf( custom ) == 0 ) - { - pEntry->SetUserDefined( sal_True ); - } - else - { - pEntry->SetUserDefined( sal_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(RTL_CONSTASCII_USTRINGPARAM(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, sal_True, sal_True ); - - pEntry->SetMain( sal_True ); - pEntry->SetStyle( GetSystemStyle( url ) ); - - if ( systemname.indexOf( custom ) == 0 ) - { - pEntry->SetUserDefined( sal_True ); - } - else - { - pEntry->SetUserDefined( sal_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 sal_False; - else - return sal_True; - } - - ++iter; - } - return sal_False; -} - -bool ToolbarSaveInData::HasSettings() -{ - // return true if there is at least one toolbar entry - if ( GetEntries()->size() > 0 ) - { - return sal_True; - } - return sal_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 occurred 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 sal_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(RTL_CONSTASCII_USTRINGPARAM( 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(RTL_CONSTASCII_USTRINGPARAM( 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 occurred 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 - } -} - -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 aLabel; - bool bIsUserDefined = sal_True; - sal_Bool bIsVisible; - sal_Int32 nStyle; - - sal_uInt16 nType( css::ui::ItemType::DEFAULT ); - - bool bItem = GetToolbarItemData( xToolbarSettings, nIndex, aCommandURL, - aLabel, nType, bIsVisible, nStyle, xSubMenu ); - - if ( bItem ) - { - if ( nType == css::ui::ItemType::DEFAULT ) - { - uno::Any a; - try - { - a = m_xCommandToLabelMap->getByName( aCommandURL ); - bIsUserDefined = sal_False; - } - catch ( container::NoSuchElementException& ) - { - bIsUserDefined = sal_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, sal_True ); - - pEntry->SetUserDefined( bIsUserDefined ); - pEntry->SetVisible( bIsVisible ); - - pEntries->push_back( pEntry ); - - LoadToolbar( xSubMenu, pEntry ); - } - else - { - SvxConfigEntry* pEntry = new SvxConfigEntry( - aLabel, aCommandURL, sal_False ); - pEntry->SetUserDefined( bIsUserDefined ); - 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, sal_False ); - pPopup->EnableItem( ID_DELETE, sal_False ); - pPopup->EnableItem( ID_BEGIN_GROUP, sal_False ); - pPopup->EnableItem( ID_DEFAULT_COMMAND, sal_False ); - pPopup->EnableItem( ID_ICON_ONLY, sal_False ); - pPopup->EnableItem( ID_ICON_AND_TEXT, sal_False ); - pPopup->EnableItem( ID_TEXT_ONLY, sal_False ); - pPopup->EnableItem( ID_CHANGE_SYMBOL, sal_False ); - pPopup->EnableItem( ID_RESET_SYMBOL, sal_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, sal_True ); - else - { - pPopup->EnableItem( ID_BEGIN_GROUP, sal_True ); - pPopup->EnableItem( ID_DELETE, sal_True ); - pPopup->EnableItem( ID_RENAME, sal_True ); - pPopup->EnableItem( ID_ICON_ONLY, sal_True ); - pPopup->EnableItem( ID_ICON_AND_TEXT, sal_True ); - pPopup->EnableItem( ID_TEXT_ONLY, sal_True ); - pPopup->EnableItem( ID_CHANGE_SYMBOL, sal_True ); - - if ( !pEntryData->IsUserDefined() ) - pPopup->EnableItem( ID_DEFAULT_COMMAND, sal_True ); - - if ( pEntryData->IsIconModified() ) - pPopup->EnableItem( ID_RESET_SYMBOL, sal_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( sal_False ); - aModifyCommandButton.Enable( sal_False ); - aAddCommandsButton.Enable( sal_False ); - - return 0; - } - - aModifyTopLevelButton.Enable( sal_True ); - aModifyCommandButton.Enable( sal_True ); - aAddCommandsButton.Enable( sal_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 ); - - sal_uInt16 nInsertPos; - for ( sal_uInt16 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(), sal_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, sal_True ); - aSaveInListBox.GetSelectHdl().Call(this); - } - - SvxConfigEntry* pToolbar = - new SvxConfigEntry( aNewName, aNewURL, sal_True ); - - pToolbar->SetUserDefined( sal_True ); - pToolbar->SetMain( sal_True ); - - pData->CreateToolbar( pToolbar ); - - nInsertPos = aTopLevelListBox.InsertEntry( pToolbar->GetName() ); - aTopLevelListBox.SetEntryData( nInsertPos, pToolbar ); - aTopLevelListBox.SelectEntryPos( nInsertPos, sal_True ); - aTopLevelListBox.GetSelectHdl().Call(this); - - pData->SetModified( sal_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, sal_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( sal_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 ); -} - -// -------------------------------------------------------- - -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 - sal_uInt16 nPosX = std::max( (sal_uInt16) (((( aNewSize.Width() - 2 ) - aImage.GetSizePixel().Width() ) / 2 ) - 1), (sal_uInt16) 0 ); - sal_uInt16 nPosY = std::max( (sal_uInt16) (((( aNewSize.Height() - 2 ) - aImage.GetSizePixel().Height() ) / 2 ) + 1), (sal_uInt16) 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 )) - { - 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 ); - } -} - -sal_Bool SvxToolbarEntriesListBox::NotifyMoving( - SvLBoxEntry* pTarget, SvLBoxEntry* pSource, - SvLBoxEntry*& rpNewParent, sal_uLong& rNewChildPos) -{ - bool result = SvxMenuEntriesListBox::NotifyMoving( - pTarget, pSource, rpNewParent, rNewChildPos ); - - if ( result == sal_True ) - { - // Instant Apply changes to UI - SvxConfigEntry* pToolbar = pPage->GetTopLevelSelection(); - if ( pToolbar != NULL ) - { - ToolbarSaveInData* pSaveInData = - ( ToolbarSaveInData*) pPage->GetSaveInData(); - pSaveInData->ApplyToolbar( pToolbar ); - } - } - - return result; -} - -sal_Bool SvxToolbarEntriesListBox::NotifyCopying( - SvLBoxEntry* pTarget, - SvLBoxEntry* pSource, - SvLBoxEntry*& rpNewParent, - sal_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 sal_False; - } - - // Copying is only allowed from external controls, not within the listbox - return sal_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 ::boost::unordered_map< ::rtl::OUString, - bool, - ::rtl::OUStringHash, - ::std::equal_to< ::rtl::OUString > > ImageInfo; - - aTbSymbol.SetPageScroll( sal_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(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider" ) ) ), - uno::UNO_QUERY ); - } - - if ( !m_xGraphProvider.is() ) - { - aBtnImport.Enable( sal_False ); - } - - uno::Reference< beans::XPropertySet > xPropSet( - xServiceManager->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "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( sal_False ); - } - - aDirectory += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "soffice.cfg/import" ) ); - - uno::Reference< lang::XSingleServiceFactory > xStorageFactory( - xServiceManager->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "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(RTL_CONSTASCII_USTRINGPARAM( "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 )); - } - sal_uInt16 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( sal_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() -{ - sal_uInt16 nCount = aTbSymbol.GetItemCount(); - - for (sal_uInt16 n = 0; n < nCount; ++n ) - { - sal_uInt16 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; - - sal_uInt16 nId; - for ( sal_uInt16 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; - - sal_uInt16 nCount = aTbSymbol.GetItemCount(); - - for (sal_uInt16 n = 0; n < nCount; ++n ) - { - sal_uInt16 nId = aTbSymbol.GetItemId( n ); - - if ( aTbSymbol.IsItemChecked( nId ) ) - { - aTbSymbol.CheckItem( nId, sal_False ); - } - } - - sal_uInt16 nId = aTbSymbol.GetCurItemId(); - aTbSymbol.CheckItem( nId ); - - ::rtl::OUString aSelImageText = aTbSymbol.GetItemText( nId ); - if ( m_xImportedImageManager->hasImage( GetImageType(), aSelImageText ) ) - { - aBtnDelete.Enable( sal_True ); - } - else - { - aBtnDelete.Enable( sal_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 ) - { - sal_uInt16 nCount = aTbSymbol.GetItemCount(); - - for (sal_uInt16 n = 0; n < nCount; ++n ) - { - sal_uInt16 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(RTL_CONSTASCII_USTRINGPARAM("URL") ); - aMediaProps[0].Value <<= aURL; - - com::sun::star::awt::Size aSize; - bool bOK = sal_False; - try - { - xGraphic = m_xGraphProvider->queryGraphic( aMediaProps ); - - uno::Reference< beans::XPropertySet > props = - m_xGraphProvider->queryGraphicDescriptor( aMediaProps ); - uno::Any a = props->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("SizePixel")) ); - a >>= aSize; - if (0 == aSize.Width || 0 == aSize.Height) - return sal_False; - else - bOK = sal_True; - } - catch ( uno::Exception& ) - { - return false; - } - - bool bResult( false ); - sal_uInt16 nCount = aTbSymbol.GetItemCount(); - for (sal_uInt16 n = 0; n < nCount; ++n ) - { - sal_uInt16 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 = BitmapEx::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; - - sal_uInt16 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(RTL_CONSTASCII_USTRINGPARAM("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] ) == sal_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(RTL_CONSTASCII_USTRINGPARAM( "/" ) ); - - 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, sal_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 == sal_False ) - { - rejected[ rejectedCount ] = rPaths[i]; - ++rejectedCount; - } - } - } - break; - } - } - else - { - bool result = ImportGraphic( aSourcePath + rPaths[i] ); - if ( result == sal_False ) - { - rejected[ rejectedCount ] = rPaths[i]; - ++rejectedCount; - } - } - } - } - - if ( rejectedCount != 0 ) - { - OUString message; - OUString newLine(RTL_CONSTASCII_USTRINGPARAM("\n")); - OUString fPath; - if (rejectedCount > 1) - fPath = rPaths[0].copy(8) + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/" ) ); - 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 = sal_False; - - sal_uInt16 nId = m_nNextId; - ++m_nNextId; - - uno::Sequence< beans::PropertyValue > aMediaProps( 1 ); - aMediaProps[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL") ); - - uno::Reference< graphic::XGraphic > xGraphic; - com::sun::star::awt::Size aSize; - bool bOK = sal_True; - aMediaProps[0].Value <<= aURL; - try - { - uno::Reference< beans::XPropertySet > props = - m_xGraphProvider->queryGraphicDescriptor( aMediaProps ); - - uno::Any a = props->getPropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("SizePixel")) ); - - xGraphic = m_xGraphProvider->queryGraphic( aMediaProps ); - if ( xGraphic.is() ) - { - a >>= aSize; - if ( 0 == aSize.Width || 0 == aSize.Height ) - bOK = sal_False; - - Image aImage( xGraphic ); - - if ( bOK && ((aSize.Width != m_nExpectedSize) || (aSize.Height != m_nExpectedSize)) ) - { - BitmapEx aBitmap = aImage.GetBitmapEx(); - BitmapEx aBitmapex = BitmapEx::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 = sal_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(RTL_CONSTASCII_USTRINGPARAM( "%ICONNAME" )); - sal_Int32 pos = message.indexOf( placeholder ); - if ( pos != -1 ) - { - name = message.replaceAt( - pos, placeholder.getLength(), rMessage ); - } - return name; -} - -sal_uInt16 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( sal_True ); - aLineEditDescription.EnableCursor( sal_False ); - aLineEditDescription.SetText(aMessage); -} - -BitmapEx SvxIconSelectorDialog::AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize) -{ - Point aEmptyPoint(0,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) - { - sal_Int32 imgNewWidth = 0; - sal_Int32 imgNewHeight = 0; - - 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 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; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/cfg.hrc b/cui/source/customize/cfg.hrc deleted file mode 100644 index adda4f458..000000000 --- a/cui/source/customize/cfg.hrc +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#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) - -//IAccessibility2 Implementation 2009----- -#define BUTTON_STR_UP (130 + CFG_OFFSET) -#define BUTTON_STR_DOWN (131 + CFG_OFFSET) -//-----IAccessibility2 Implementation 2009 diff --git a/cui/source/customize/cfg.src b/cui/source/customize/cfg.src deleted file mode 100644 index ab205b62f..000000000 --- a/cui/source/customize/cfg.src +++ /dev/null @@ -1,899 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <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 - { - HelpID = "cui:ListBox:RID_SVXPAGE_MENUS:LB_MENUS"; - Border = TRUE ; - Pos = MAP_APPFONT ( 64 , 22 ) ; - Size = MAP_APPFONT ( 108 , 108 ) ; - DropDown = TRUE ; - }; - PushButton BTN_NEW - { - HelpID = "cui:PushButton:RID_SVXPAGE_MENUS:BTN_NEW"; - Pos = MAP_APPFONT ( 192 , 22 ) ; - Size = MAP_APPFONT ( 75 , 14 ) ; - TabStop = TRUE ; - Text [ de ] = "Neu..." ; - Text [ en-US ] = "New..." ; - }; - MenuButton BTN_CHANGE - { - HelpID = "cui:MenuButton:RID_SVXPAGE_MENUS: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 - { - HelpID = "cui:PushButton:RID_SVXPAGE_MENUS: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 - { - HelpID = "cui:MenuButton:RID_SVXPAGE_MENUS: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 - { - HelpID = "cui:ImageButton:RID_SVXPAGE_MENUS:BTN_UP"; - Pos = MAP_APPFONT ( 175 , 102 ) ; - Size = MAP_APPFONT ( 14 , 14 ) ; - TabStop = TRUE ; - Symbol = IMAGEBUTTON_ARROW_UP ; - Disable = TRUE ; - }; - ImageButton BTN_DOWN - { - HelpID = "cui:ImageButton:RID_SVXPAGE_MENUS: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 - { - HelpID = "cui:ListBox:RID_SVXPAGE_MENUS: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 - { - HelpID = "cui:MultiLineEdit:RID_SVXPAGE_MENUS: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 - { - HelpID = "cui:Edit:MD_MENU_ORGANISER: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 - { - HelpID = "cui:ImageButton:MD_MENU_ORGANISER:BTN_MENU_UP"; - Pos = MAP_APPFONT ( 102 , 80 ) ; - Size = MAP_APPFONT ( 14 , 14 ) ; - TabStop = TRUE ; - Symbol = IMAGEBUTTON_ARROW_UP ; - }; - ImageButton BTN_MENU_DOWN - { - HelpID = "cui:ImageButton:MD_MENU_ORGANISER: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 -{ - HelpID = "cui: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 - { - HelpID = "cui:Edit:MD_NEW_TOOLBAR: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 - { - HelpID = "cui:ListBox:MD_NEW_TOOLBAR: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 - { - HelpID = "cui:PushButton:MD_ICONSELECTOR:BTN_IMPORT"; - Pos = MAP_APPFONT ( 184 , 7 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - Text [ de ] = "Importieren..." ; - Text[ en-US ] = "Import..."; - }; - PushButton BTN_DELETE - { - HelpID = "cui:PushButton:MD_ICONSELECTOR: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 -{ - HelpID = "cui: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 - { - HelpID = "cui:MultiLineEdit:MD_ICONCHANGE: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"; -}; - -String BUTTON_STR_UP -{ - Text [ en-US ] = "Up"; -}; -String BUTTON_STR_DOWN -{ - Text [ en-US ] = "Down"; -}; - diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx deleted file mode 100644 index a1203254a..000000000 --- a/cui/source/customize/cfgutil.cxx +++ /dev/null @@ -1,1261 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 "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/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_CONSTASCII_USTRINGPARAM("com.sun.star.ui.UICategoryDescription") ); -static ::rtl::OUString SERVICE_UICMDDESCRIPTION (RTL_CONSTASCII_USTRINGPARAM("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_CONSTASCII_USTRINGPARAM("CharacterStyles") ); -static ::rtl::OUString FAMILY_PARAGRAPHSTYLE (RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ); -static ::rtl::OUString FAMILY_FRAMESTYLE (RTL_CONSTASCII_USTRINGPARAM("FrameStyles" ) ); -static ::rtl::OUString FAMILY_PAGESTYLE (RTL_CONSTASCII_USTRINGPARAM("PageStyles" ) ); -static ::rtl::OUString FAMILY_NUMBERINGSTYLE (RTL_CONSTASCII_USTRINGPARAM("NumberingStyles") ); - -static ::rtl::OUString CMDURL_SPART (RTL_CONSTASCII_USTRINGPARAM(".uno:StyleApply?Style:string=") ); -static ::rtl::OUString CMDURL_FPART2 (RTL_CONSTASCII_USTRINGPARAM("&FamilyName:string=") ); - -static ::rtl::OUString CMDURL_STYLEPROT_ONLY (RTL_CONSTASCII_USTRINGPARAM(".uno:StyleApply?") ); -static ::rtl::OUString CMDURL_SPART_ONLY (RTL_CONSTASCII_USTRINGPARAM("Style:string=") ); -static ::rtl::OUString CMDURL_FPART_ONLY (RTL_CONSTASCII_USTRINGPARAM("FamilyName:string=") ); - -static ::rtl::OUString STYLEPROP_UINAME (RTL_CONSTASCII_USTRINGPARAM("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; - } -} - -::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_CONSTASCII_USTRINGPARAM("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 ) -{ - SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT ); - GetModel()->SetSortMode( SortAscending ); - - // Timer for the BallonHelp - aTimer.SetTimeout( 200 ); - aTimer.SetTimeoutHdl( - LINK( this, SfxConfigFunctionListBox_Impl, TimerHdl ) ); -} - -SfxConfigFunctionListBox_Impl::~SfxConfigFunctionListBox_Impl() -{ - ClearAll(); -} - -void SfxConfigFunctionListBox_Impl::MouseMove( const MouseEvent& ) -{ -} - -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 - return 0L; -} - -void SfxConfigFunctionListBox_Impl::ClearAll() -/* Beschreibung - L"oscht alle Eintr"age in der FunctionListBox, alle UserDaten und alle evtl. - vorhandenen MacroInfos. -*/ -{ - sal_uInt16 nCount = aArr.Count(); - for ( sal_uInt16 i=0; i<nCount; ++i ) - { - SfxGroupInfo_Impl *pData = aArr[i]; - - if ( pData->nKind == SFX_CFGFUNCTION_SCRIPT ) - { - String* pScriptURI = (String*)pData->pObject; - delete pScriptURI; - } - - if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER - ) - { - XInterface* xi = static_cast<XInterface *>(pData->pObject); - if (xi != NULL) - { - xi->release(); - } - } - - delete pData; - } - - aArr.Remove( 0, nCount ); - Clear(); -} - -String SfxConfigFunctionListBox_Impl::GetSelectedScriptURI() -{ - SvLBoxEntry *pEntry = FirstSelected(); - if ( pEntry ) - { - SfxGroupInfo_Impl *pData = (SfxGroupInfo_Impl*) pEntry->GetUserData(); - if ( pData && ( pData->nKind == SFX_CFGFUNCTION_SCRIPT ) ) - return *(String*)pData->pObject; - } - return String(); -} - -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; -} - -void SfxConfigFunctionListBox_Impl::FunctionSelected() -/* Beschreibung - Setzt die Balloonhelp zur"uck, da diese immer den Helptext des selektierten - Entry anzeigen soll. -*/ -{ -} - -void SfxConfigFunctionListBox_Impl::SetStylesInfo(SfxStylesInfo_Impl* pStyles) -{ - pStylesInfo = pStyles; -} - -struct SvxConfigGroupBoxResource_Impl : public Resource -{ - Image m_hdImage; - Image m_libImage; - Image m_macImage; - Image m_docImage; - ::rtl::OUString m_sMyMacros; - ::rtl::OUString m_sProdMacros; - String m_sMacros; - String m_sDlgMacros; - String m_aHumanAppName; - String m_aStrGroupStyles; - Image m_collapsedImage; - Image m_expandedImage; - - SvxConfigGroupBoxResource_Impl(); -}; - -SvxConfigGroupBoxResource_Impl::SvxConfigGroupBoxResource_Impl() : - Resource(CUI_RES(RID_SVXPAGE_CONFIGGROUPBOX)), - m_hdImage(CUI_RES(IMG_HARDDISK)), - m_libImage(CUI_RES(IMG_LIB)), - m_macImage(CUI_RES(IMG_MACRO)), - m_docImage(CUI_RES(IMG_DOC)), - 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_collapsedImage(CUI_RES(BMP_COLLAPSED)), - m_expandedImage(CUI_RES(BMP_EXPANDED)) -{ - FreeResource(); -} - -SfxConfigGroupListBox_Impl::SfxConfigGroupListBox_Impl( - Window* pParent, const ResId& rResId, sal_uLong nConfigMode ) - : SvTreeListBox( pParent, rResId ) - , pImp(new SvxConfigGroupBoxResource_Impl()), pFunctionListBox(0), nMode( nConfigMode ), pStylesInfo(0) -{ - SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT ); - SetNodeBitmaps( pImp->m_collapsedImage, pImp->m_expandedImage ); -} - - -SfxConfigGroupListBox_Impl::~SfxConfigGroupListBox_Impl() -{ - ClearAll(); -} - -void SfxConfigGroupListBox_Impl::ClearAll() -{ - sal_uInt16 nCount = aArr.Count(); - for ( sal_uInt16 i=0; i<nCount; ++i ) - { - SfxGroupInfo_Impl *pData = aArr[i]; - if ( pData->nKind == SFX_CFGGROUP_SCRIPTCONTAINER - ) - { - XInterface* xi = static_cast<XInterface *>(pData->pObject); - if (xi != NULL) - { - xi->release(); - } - } - delete pData; - } - - aArr.Remove( 0, nCount ); - Clear(); -} - -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 ); - - pEntry = GetParent( pEntry ); - } - - return String(); -} - -//----------------------------------------------- -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& ) - { - } - - 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(sal_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(); - } - - OSL_TRACE("** ** About to initialise SF Scripts"); - // 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(RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") ) ), UNO_QUERY_THROW ); - rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) ); - } - 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( sal_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(); - sal_Bool bIsRootNode = sal_False; - - ::rtl::OUString user( RTL_CONSTASCII_USTRINGPARAM("user") ); - ::rtl::OUString share( RTL_CONSTASCII_USTRINGPARAM("share") ); - if ( rootNode->getName().equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Root") ) ) ) - { - bIsRootNode = sal_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]; - sal_Bool bDisplay = sal_True; - ::rtl::OUString uiName = theChild->getName(); - if ( bIsRootNode ) - { - if ( ! ((theChild->getName().equals( user ) || theChild->getName().equals( share ) || - theChild->getName().equals( currentDocTitle ) ) ) ) - { - bDisplay=sal_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 ); - SvLBoxEntry* pNewEntry = - InsertEntry( uiName, NULL); - SetExpandedEntryBmp( pNewEntry, aImage ); - SetCollapsedEntryBmp( pNewEntry, aImage ); - - 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( sal_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( sal_True ); - } - - MakeVisible( GetEntry( 0,0 ) ); - SetUpdateMode( sal_True ); -} -Image SfxConfigGroupListBox_Impl::GetImage( - Reference< browse::XBrowseNode > node, - Reference< XComponentContext > xCtx, - bool bIsRootNode -) -{ - Image aImage; - if ( bIsRootNode ) - { - ::rtl::OUString user( RTL_CONSTASCII_USTRINGPARAM("user") ); - ::rtl::OUString share( RTL_CONSTASCII_USTRINGPARAM("share") ); - if (node->getName().equals( user ) || node->getName().equals(share ) ) - { - aImage = pImp->m_hdImage; - } - 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(RTL_CONSTASCII_USTRINGPARAM("" // 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(RTL_CONSTASCII_USTRINGPARAM("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 ) - { - aImage = SvFileInformationManager::GetFileImage( INetURLObject(factoryURL), false ); - } - else - { - aImage = pImp->m_docImage; - } - } - } - else - { - if( node->getType() == browse::BrowseNodeTypes::SCRIPT ) - aImage = pImp->m_macImage; - else - aImage = pImp->m_libImage; - } - 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(RTL_CONSTASCII_USTRINGPARAM("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::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(RTL_CONSTASCII_USTRINGPARAM("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; - } - - 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(sal_False); - pFunctionListBox->ClearAll(); - if ( pInfo->nKind != SFX_CFGGROUP_FUNCTION && - pInfo->nKind != SFX_CFGGROUP_SCRIPTCONTAINER && - pInfo->nKind != SFX_CFGGROUP_STYLES ) - { - pFunctionListBox->SetUpdateMode(sal_True); - return; - } - - switch ( pInfo->nKind ) - { - case SFX_CFGGROUP_FUNCTION : - { - sal_uInt16 nGroup = pInfo->nUniqueID; - 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_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; - - String* pScriptURI = new String( uri ); - SfxGroupInfo_Impl* pGrpInfo = new SfxGroupInfo_Impl( SFX_CFGFUNCTION_SCRIPT, 0, pScriptURI ); - - Image aImage = GetImage( children[n], Reference< XComponentContext >(), sal_False ); - SvLBoxEntry* pNewEntry = - pFunctionListBox->InsertEntry( children[n]->getName(), NULL ); - pFunctionListBox->SetExpandedEntryBmp( pNewEntry, aImage ); - pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage ); - - 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(sal_True); -} - -sal_Bool SfxConfigGroupListBox_Impl::Expand( SvLBoxEntry* pParent ) -{ - sal_Bool bRet = SvTreeListBox::Expand( pParent ); - if ( bRet ) - { - // Wieviele Entries k"onnen angezeigt werden ? - sal_uLong nEntries = GetOutputSizePixel().Height() / GetEntryHeight(); - - // Wieviele Kinder sollen angezeigt werden ? - sal_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, sal_True ); - } - else - { - // An welcher relativen ViewPosition steht der aufzuklappende parent - SvLBoxEntry *pEntry = GetFirstEntryInView(); - sal_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 = sal_True; - switch ( pInfo->nKind ) - { - 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(); - sal_Bool bIsRootNode = sal_False; - - ::rtl::OUString user( RTL_CONSTASCII_USTRINGPARAM("user") ); - ::rtl::OUString share( RTL_CONSTASCII_USTRINGPARAM("share" )); - if ( rootNode->getName().equals(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Root") ) ) ) - { - bIsRootNode = sal_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 sal_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() ); - sal_Bool bDisplay = sal_True; - if ( bIsRootNode ) - { - if ( !( (aName.equals(user) || aName.equals(share) || aName.equals(currentDocTitle) ) ) ) - bDisplay=sal_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 ); - SvLBoxEntry* pNewEntry = - InsertEntry( theChild->getName(), pEntry ); - SetExpandedEntryBmp( pNewEntry, aImage ); - SetCollapsedEntryBmp(pNewEntry, aImage ); - - 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( sal_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( sal_False ); - } - } - break; - } - - default: - OSL_FAIL( "Falscher Gruppentyp!" ); - break; - } -} - -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; - sal_uInt16 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 ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/eventdlg.cxx b/cui/source/customize/eventdlg.cxx deleted file mode 100644 index 07d1287e5..000000000 --- a/cui/source/customize/eventdlg.cxx +++ /dev/null @@ -1,242 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 <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/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 ( sal_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) ); - - 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 > ( - ::comphelper::getProcessServiceFactory()->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.frame.GlobalEventBroadcaster" )) ), - uno::UNO_QUERY ); - - sal_uInt16 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, sal_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 ); - sal_uInt16 nPos = aSaveInListBox.InsertEntry( aTitle ); - - aSaveInListBox.SetEntryData( nPos, new bool(false) ); - aSaveInListBox.SelectEntryPos( nPos, sal_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( sal_False ); - bAppConfig = *bApp; - if ( *bApp ) - { - SetReadOnly( sal_False ); - _SvxMacroTabPage::DisplayAppEvents( true ); - } - else - { - bool isReadonly = sal_False; - - uno::Reference< frame::XFramesSupplier > xFramesSupplier( - ::comphelper::getProcessServiceFactory()->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM( "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( sal_True ); - return sal_True; -} - -// ----------------------------------------------------------------------- - -sal_Bool SvxEventConfigPage::FillItemSet( SfxItemSet& rSet ) -{ - return _SvxMacroTabPage::FillItemSet( rSet ); -} - -// ----------------------------------------------------------------------- - -void SvxEventConfigPage::Reset( const SfxItemSet& ) -{ - _SvxMacroTabPage::Reset(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/eventdlg.hrc b/cui/source/customize/eventdlg.hrc deleted file mode 100644 index b75c04776..000000000 --- a/cui/source/customize/eventdlg.hrc +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/* 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 deleted file mode 100644 index 316364845..000000000 --- a/cui/source/customize/eventdlg.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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; - - sal_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 sal_Bool FillItemSet( SfxItemSet& ); - virtual void Reset( const SfxItemSet& ); - using _SvxMacroTabPage::Reset; - -private: - void ImplInitDocument(); -}; - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/eventdlg.src b/cui/source/customize/eventdlg.src deleted file mode 100644 index 835ed82b4..000000000 --- a/cui/source/customize/eventdlg.src +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "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 - { - HelpID = "cui:ListBox:RID_SVXPAGE_EVENTS: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 - { - HelpID = "cui:PushButton:RID_SVXPAGE_EVENTS:PB_ASSIGN"; - Pos = MAP_APPFONT ( 217 , ROW0A ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - Disable = TRUE ; - Text [ en-US ] = "M~acro..." ; - }; - PushButton PB_DELETE - { - HelpID = "cui:PushButton:RID_SVXPAGE_EVENTS: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 - }; -}; diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx deleted file mode 100644 index 944d6d0cb..000000000 --- a/cui/source/customize/macropg.cxx +++ /dev/null @@ -1,1027 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 <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/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_CONSTASCII_USTRINGPARAM( "vnd.sun.star.UNO:") ); -static ::rtl::OUString aVndSunStarScript( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.script:") ); - -_SvxMacroTabPage_Impl::_SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet ) : - pAssignFT( NULL ), - pAssignPB( NULL ), - pAssignComponentPB( NULL ), - pDeletePB( NULL ), - pMacroImg( NULL ), - pComponentImg( NULL ), - pStrEvent( NULL ), - pAssignedMacro( NULL ), - pEventLB( NULL ), - bReadOnly( sal_False ), - bIDEDialogMode( sal_False ) -{ - const SfxPoolItem* pItem; - if ( SFX_ITEM_SET == rAttrSet.GetItemState( SID_ATTR_MACROITEM, sal_False, &pItem ) ) - bIDEDialogMode = ((const SfxBoolItem*)pItem)->GetValue(); -} - -_SvxMacroTabPage_Impl::~_SvxMacroTabPage_Impl() -{ - delete pAssignFT; - delete pAssignPB; - delete pAssignComponentPB; - delete pDeletePB; - delete pMacroImg; - delete pComponentImg; - 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; - sal_uInt16 _nTabs = maHeaderBar.GetItemCount(); - 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, nTmpSz = 0; - for( sal_uInt16 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( sal_Bool bVisible, sal_uInt16 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 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 ) ); - - // 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( "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( "errorOccurred", RID_SVXSTR_EVENT_ERROROCCURRED ) ); - 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 -sal_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 (const Exception&) - { - } - // what is the return value about?? - return sal_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 (const Exception&) - { - } - DisplayAppEvents(bAppEvents); -} - -void _SvxMacroTabPage::SetReadOnly( sal_Bool bSet ) -{ - mpImpl->bReadOnly = bSet; -} - -sal_Bool _SvxMacroTabPage::IsReadOnly() const -{ - return mpImpl->bReadOnly; -} - - -class IconLBoxString : public SvLBoxString -{ - Image* m_pMacroImg; - Image* m_pComponentImg; - int m_nxImageOffset; - - public: - IconLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& sText, - Image* pMacroImg, Image* pComponentImg ); - virtual void Paint(const Point& aPos, SvLBox& aDevice, sal_uInt16 nFlags, SvLBoxEntry* pEntry ); -}; - - -IconLBoxString::IconLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& sText, - Image* pMacroImg, Image* pComponentImg ) - : SvLBoxString( pEntry, nFlags, sText ) - , m_pMacroImg( pMacroImg ) - , m_pComponentImg( pComponentImg ) -{ - m_nxImageOffset = 20; -} - -//=============================================== -void IconLBoxString::Paint( const Point& aPos, SvLBox& aDevice, - sal_uInt16 /*nFlags*/, SvLBoxEntry* /*pEntry*/ ) -{ - String aTxt( GetText() ); - if( aTxt.Len() ) - { - ::rtl::OUString aURL( aTxt ); - sal_Int32 nIndex = aURL.indexOf( aVndSunStarUNO ); - bool bUNO = nIndex == 0; - - const Image* 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( sal_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_FAIL( "_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 ), 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( sal_True ); - EnableButtons(); -} - -// 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(); - sal_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(); - 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(); - sal_uLong nPos; - if( !pE || LISTBOX_ENTRY_NOTFOUND == - ( nPos = rListBox.GetModel()->GetAbsPos( pE ) ) ) - { - DBG_ASSERT( pE, "wo kommt der leere Eintrag her?" ); - return 0; - } - - const sal_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(RTL_CONSTASCII_USTRINGPARAM("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(RTL_CONSTASCII_USTRINGPARAM("UNO")); - sEventURL = pAssignDlg->getURL(); - if(!pThis->bAppEvents) - pThis->bDocModified = true; - } - delete pAssignDlg; - } - else if( bAssEnabled ) - { - // assign pressed - SvxScriptSelectorDialog* pDlg = new SvxScriptSelectorDialog( pThis, sal_False, pThis->GetFrame() ); - if( pDlg ) - { - short ret = pDlg->Execute(); - if ( ret ) - { - sEventType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("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( sal_False ); - pE->ReplaceItem( new IconLBoxString( pE, 0, sEventURL, - pImpl->pMacroImg, pImpl->pComponentImg ), LB_MACROS_ITEMPOS ); - - rListBox.GetModel()->InvalidateEntry( pE ); - rListBox.Select( pE ); - rListBox.MakeVisible( pE ); - rListBox.SetUpdateMode( sal_True ); - - pThis->EnableButtons(); - 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( sal_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 (const Exception&) - { - } - } - 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 (const Exception&) - { - } - } - } -} - -// 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) ); - - FreeResource(); - - SetFrame( _rxDocumentFrame ); - - if( !mpImpl->bIDEDialogMode ) - { - 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( (sal_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_OK ); - 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() ); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/macropg.hrc b/cui/source/customize/macropg.hrc deleted file mode 100644 index f1245c0a6..000000000 --- a/cui/source/customize/macropg.hrc +++ /dev/null @@ -1,99 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#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 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 deleted file mode 100644 index bb4a17f9f..000000000 --- a/cui/source/customize/macropg.src +++ /dev/null @@ -1,480 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <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 = "cui:TabPage:RID_SVXPAGE_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 - { - HelpID = "cui:PushButton:RID_SVXPAGE_MACROASSIGN: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 - { - HelpID = "cui:PushButton:RID_SVXPAGE_MACROASSIGN: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 - { - HelpID = "cui:PushButton:RID_SVXPAGE_MACROASSIGN: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 - }; -}; - -ModalDialog RID_SVXDLG_ASSIGNCOMPONENT -{ - HelpID = "cui: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 - { - HelpID = "cui:Edit:RID_SVXDLG_ASSIGNCOMPONENT: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_ERROROCCURRED -{ - 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 deleted file mode 100644 index 52ffc9a21..000000000 --- a/cui/source/customize/macropg_impl.hxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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; - String* pStrEvent; - String* pAssignedMacro; - _HeaderTabListBox* pEventLB; - sal_Bool bReadOnly; - sal_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 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/selector.cxx b/cui/source/customize/selector.cxx deleted file mode 100644 index 81e0eeec8..000000000 --- a/cui/source/customize/selector.cxx +++ /dev/null @@ -1,1175 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 <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/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 ) -{ - SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT ); - GetModel()->SetSortMode( SortAscending ); - - // Timer for the 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() -{ - sal_uInt16 nCount = aArr.Count(); - for ( sal_uInt16 i=0; i<nCount; ++i ) - { - SvxGroupInfo_Impl *pData = aArr[i]; - delete pData; - } - - aArr.Remove( 0, nCount ); - Clear(); -} - -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_libImage(ResId(IMG_LIB,*rResId.GetResMgr())), - m_macImage(ResId(IMG_MACRO,*rResId.GetResMgr())), - m_docImage(ResId(IMG_DOC,*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 ); - } - - SetStyle( 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 ) - ); -} - - -SvxConfigGroupListBox_Impl::~SvxConfigGroupListBox_Impl() -{ - ClearAll(); -} - -void SvxConfigGroupListBox_Impl::ClearAll() -{ - sal_uInt16 nCount = aArr.Count(); - for ( sal_uInt16 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(); - - sal_Bool bIsRootNode = _rxRootNode->getName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("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 sal_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(); - sal_Bool bDisplay = sal_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.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "user" ) ) ) - { - sUIName = m_sMyMacros; - bIsRootNode = sal_True; - } - else if ( sUIName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "share" ) ) ) - { - sUIName = m_sProdMacros; - bIsRootNode = sal_True; - } - else if ( !sUIName.equals( sCurrentDocTitle ) ) - { - bDisplay = sal_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 ); - SetExpandedEntryBmp( pNewEntry, aImage ); - SetCollapsedEntryBmp( pNewEntry, aImage ); - - 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( sal_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( sal_True ); - break; - } - } - } - } - } - } - catch (const Exception&) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -void SvxConfigGroupListBox_Impl::Init() -{ - SetUpdateMode(sal_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(RTL_CONSTASCII_USTRINGPARAM( - "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(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.frame.UICommandDescription" )), - xContext ), - UNO_QUERY ); - - if ( xNameAccess.is() ) - { - xNameAccess->getByName( aModuleId ) >>= m_xModuleCommands; - } - - Reference< container::XNameAccess > xAllCategories( - xMCF->createInstanceWithContext( - OUString(RTL_CONSTASCII_USTRINGPARAM( - "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(RTL_CONSTASCII_USTRINGPARAM( "/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( sal_True ); - aArr.Insert( pInfo, aArr.Count() ); - } - else - { - fillScriptList( rootNode, NULL, false ); - } - } - } - MakeVisible( GetEntry( 0,0 ) ); - SetUpdateMode( sal_True ); -} - -Image SvxConfigGroupListBox_Impl::GetImage( - Reference< browse::XBrowseNode > node, - Reference< XComponentContext > xCtx, - bool bIsRootNode -) -{ - Image aImage; - if ( bIsRootNode ) - { - if ( node->getName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "user" ) ) || node->getName().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "share" ) ) ) - { - aImage = m_hdImage; - } - 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(RTL_CONSTASCII_USTRINGPARAM("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(RTL_CONSTASCII_USTRINGPARAM("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 ) - { - aImage = SvFileInformationManager::GetFileImage( INetURLObject(factoryURL), false ); - } - else - { - aImage = m_docImage; - } - } - } - else - { - if( node->getType() == browse::BrowseNodeTypes::SCRIPT ) - aImage = m_macImage; - else - aImage = m_libImage; - } - 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(RTL_CONSTASCII_USTRINGPARAM("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(sal_False); - pFunctionListBox->ClearAll(); - if ( pInfo->nKind != SVX_CFGGROUP_FUNCTION && - pInfo->nKind != SVX_CFGGROUP_SCRIPTCONTAINER ) - { - pFunctionListBox->SetUpdateMode(sal_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.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "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 ); - SvLBoxEntry* pNewEntry = - pFunctionListBox->InsertEntry( children[n]->getName(), NULL ); - pFunctionListBox->SetExpandedEntryBmp( pNewEntry, aImage ); - pFunctionListBox->SetCollapsedEntryBmp(pNewEntry, aImage ); - - 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(sal_True); -} - -sal_Bool SvxConfigGroupListBox_Impl::Expand( SvLBoxEntry* pParent ) -{ - sal_Bool bRet = SvTreeListBox::Expand( pParent ); - if ( bRet ) - { - // Wieviele Entries k"onnen angezeigt werden ? - sal_uLong nEntries = GetOutputSizePixel().Height() / GetEntryHeight(); - - // Wieviele Kinder sollen angezeigt werden ? - sal_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, sal_True ); - } - else - { - // An welcher relativen ViewPosition steht der aufzuklappende parent - SvLBoxEntry *pEntry = GetFirstEntryInView(); - sal_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 = sal_True; - switch ( pInfo->nKind ) - { - case SVX_CFGGROUP_SCRIPTCONTAINER: - { - if ( !GetChildCount( pEntry ) ) - { - Reference< browse::XBrowseNode > rootNode( pInfo->xBrowseNode ) ; - fillScriptList( rootNode, pEntry, true /* i30923 */ ); - } - break; - } - - default: - OSL_FAIL( "Falscher Gruppentyp!" ); - break; - } -} - -/* - * Implementation of SvxScriptSelectorDialog - * - * This dialog is used for selecting Slot API commands - * and Scripting Framework Scripts. - */ - -SvxScriptSelectorDialog::SvxScriptSelectorDialog( - Window* pParent, sal_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.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; - - sal_uInt16 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( sal_True ); - } - else - { - aDescriptionText.SetText( String() ); - aOKButton.Enable( sal_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 == sal_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 == sal_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 ); -} - -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() ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/customize/selector.hrc b/cui/source/customize/selector.hrc deleted file mode 100644 index a8dee0cc1..000000000 --- a/cui/source/customize/selector.hrc +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#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_LIB 3 -#define IMG_MACRO 5 -#define IMG_DOC 7 - -#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 deleted file mode 100644 index 34e7a7726..000000000 --- a/cui/source/customize/selector.src +++ /dev/null @@ -1,192 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "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_LIB - { - ImageBitmap = Bitmap { File = "im30820.png"; }; - MASKCOLOR - }; - Image IMG_MACRO - { - ImageBitmap = Bitmap { File = "im30821.png"; }; - MASKCOLOR - }; - Image IMG_DOC - { - ImageBitmap = Bitmap { File = "im30826.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 |