From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- framework/inc/acceleratorconst.h | 35 ++ framework/inc/addonmenu.hxx | 84 ++++ framework/inc/bitmaps.hlst | 40 ++ framework/inc/classes/actiontriggercontainer.hxx | 68 +++ framework/inc/classes/actiontriggerpropertyset.hxx | 117 +++++ .../classes/actiontriggerseparatorpropertyset.hxx | 99 +++++ framework/inc/classes/converter.hxx | 50 +++ framework/inc/classes/framecontainer.hxx | 94 +++++ framework/inc/classes/fwkresid.hxx | 30 ++ framework/inc/classes/imagewrapper.hxx | 62 +++ framework/inc/classes/protocolhandlercache.hxx | 150 +++++++ framework/inc/classes/resource.hxx | 33 ++ .../inc/classes/rootactiontriggercontainer.hxx | 104 +++++ framework/inc/classes/taskcreator.hxx | 63 +++ framework/inc/dispatch/closedispatcher.hxx | 264 ++++++++++++ .../inc/dispatch/dispatchinformationprovider.hxx | 67 +++ framework/inc/dispatch/dispatchprovider.hxx | 116 +++++ framework/inc/dispatch/interceptionhelper.hxx | 257 +++++++++++ framework/inc/dispatch/mailtodispatcher.hxx | 101 +++++ framework/inc/dispatch/oxt_handler.hxx | 96 +++++ framework/inc/dispatch/popupmenudispatcher.hxx | 123 ++++++ framework/inc/dispatch/servicehandler.hxx | 105 +++++ framework/inc/dispatch/startmoduledispatcher.hxx | 129 ++++++ framework/inc/dispatch/systemexec.hxx | 104 +++++ framework/inc/fwidllapi.h | 33 ++ .../inc/helper/dockingareadefaultacceptor.hxx | 71 ++++ framework/inc/helper/mischelper.hxx | 262 ++++++++++++ framework/inc/helper/ocomponentaccess.hxx | 164 +++++++ framework/inc/helper/ocomponentenumeration.hxx | 163 +++++++ framework/inc/helper/oframes.hxx | 193 +++++++++ framework/inc/helper/persistentwindowstate.hxx | 165 ++++++++ framework/inc/helper/propertysetcontainer.hxx | 78 ++++ framework/inc/helper/shareablemutex.hxx | 94 +++++ framework/inc/helper/statusindicator.hxx | 106 +++++ framework/inc/helper/statusindicatorfactory.hxx | 273 ++++++++++++ framework/inc/helper/tagwindowasmodified.hxx | 96 +++++ framework/inc/helper/titlebarupdate.hxx | 145 +++++++ .../inc/helper/uiconfigelementwrapperbase.hxx | 143 +++++++ framework/inc/helper/uielementwrapperbase.hxx | 114 +++++ framework/inc/helper/vclstatusindicator.hxx | 92 ++++ framework/inc/helper/wakeupthread.hxx | 56 +++ framework/inc/interaction/quietinteraction.hxx | 113 +++++ framework/inc/jobs/configaccess.hxx | 92 ++++ framework/inc/jobs/helponstartup.hxx | 189 +++++++++ framework/inc/jobs/job.hxx | 205 +++++++++ framework/inc/jobs/jobconst.hxx | 48 +++ framework/inc/jobs/jobdata.hxx | 210 +++++++++ framework/inc/jobs/jobresult.hxx | 106 +++++ framework/inc/jobs/joburl.hxx | 111 +++++ framework/inc/jobs/shelljob.hxx | 130 ++++++ framework/inc/macros/registration.hxx | 90 ++++ framework/inc/macros/xinterface.hxx | 145 +++++++ framework/inc/macros/xserviceinfo.hxx | 183 ++++++++ framework/inc/macros/xtypeprovider.hxx | 119 ++++++ framework/inc/menuconfiguration.hxx | 108 +++++ framework/inc/pch/precompiled_fwe.cxx | 12 + framework/inc/pch/precompiled_fwe.hxx | 168 ++++++++ framework/inc/pch/precompiled_fwi.cxx | 12 + framework/inc/pch/precompiled_fwi.hxx | 89 ++++ framework/inc/pch/precompiled_fwk.cxx | 12 + framework/inc/pch/precompiled_fwk.hxx | 259 ++++++++++++ framework/inc/pch/precompiled_fwl.cxx | 12 + framework/inc/pch/precompiled_fwl.hxx | 211 +++++++++ framework/inc/properties.h | 182 ++++++++ framework/inc/protocols.h | 123 ++++++ framework/inc/recording/dispatchrecorder.hxx | 96 +++++ .../inc/recording/dispatchrecordersupplier.hxx | 91 ++++ framework/inc/services.h | 66 +++ framework/inc/services/desktop.hxx | 469 +++++++++++++++++++++ framework/inc/services/layoutmanager.hxx | 275 ++++++++++++ .../inc/services/mediatypedetectionhelper.hxx | 88 ++++ framework/inc/services/uriabbreviation.hxx | 59 +++ framework/inc/statusbarconfiguration.hxx | 50 +++ framework/inc/stdtypes.h | 71 ++++ framework/inc/strings.hrc | 59 +++ framework/inc/targets.h | 39 ++ framework/inc/taskcreatordefs.hxx | 58 +++ framework/inc/threadhelp/gate.hxx | 149 +++++++ framework/inc/threadhelp/transactionguard.hxx | 51 +++ framework/inc/threadhelp/transactionmanager.hxx | 128 ++++++ framework/inc/toolboxconfiguration.hxx | 50 +++ framework/inc/uiconfiguration/globalsettings.hxx | 55 +++ .../inc/uiconfiguration/graphicnameaccess.hxx | 57 +++ framework/inc/uiconfiguration/imagemanager.hxx | 97 +++++ framework/inc/uiconfiguration/imagetype.hxx | 38 ++ .../inc/uiconfiguration/moduleimagemanager.hxx | 76 ++++ .../inc/uiconfiguration/windowstateproperties.hxx | 42 ++ .../inc/uielement/FixedImageToolbarController.hxx | 57 +++ .../inc/uielement/FixedTextToolbarController.hxx | 55 +++ framework/inc/uielement/addonstoolbarmanager.hxx | 64 +++ framework/inc/uielement/addonstoolbarwrapper.hxx | 61 +++ .../inc/uielement/buttontoolbarcontroller.hxx | 97 +++++ .../inc/uielement/comboboxtoolbarcontroller.hxx | 67 +++ framework/inc/uielement/commandinfo.hxx | 47 +++ .../inc/uielement/complextoolbarcontroller.hxx | 102 +++++ framework/inc/uielement/constitemcontainer.hxx | 102 +++++ .../inc/uielement/dropdownboxtoolbarcontroller.hxx | 66 +++ framework/inc/uielement/edittoolbarcontroller.hxx | 67 +++ framework/inc/uielement/fontmenucontroller.hxx | 71 ++++ framework/inc/uielement/fontsizemenucontroller.hxx | 76 ++++ framework/inc/uielement/footermenucontroller.hxx | 49 +++ .../inc/uielement/genericstatusbarcontroller.hxx | 60 +++ .../inc/uielement/generictoolbarcontroller.hxx | 93 ++++ framework/inc/uielement/headermenucontroller.hxx | 66 +++ .../inc/uielement/imagebuttontoolbarcontroller.hxx | 57 +++ framework/inc/uielement/itemcontainer.hxx | 84 ++++ .../inc/uielement/langselectionmenucontroller.hxx | 92 ++++ framework/inc/uielement/macrosmenucontroller.hxx | 61 +++ framework/inc/uielement/menubarmanager.hxx | 210 +++++++++ framework/inc/uielement/menubarmerger.hxx | 110 +++++ framework/inc/uielement/menubarwrapper.hxx | 85 ++++ framework/inc/uielement/newmenucontroller.hxx | 92 ++++ framework/inc/uielement/progressbarwrapper.hxx | 85 ++++ framework/inc/uielement/rootitemcontainer.hxx | 129 ++++++ .../inc/uielement/spinfieldtoolbarcontroller.hxx | 83 ++++ framework/inc/uielement/statusbar.hxx | 55 +++ framework/inc/uielement/statusbaritem.hxx | 81 ++++ framework/inc/uielement/statusbarmanager.hxx | 106 +++++ framework/inc/uielement/statusbarmerger.hxx | 74 ++++ framework/inc/uielement/statusbarwrapper.hxx | 59 +++ .../uielement/statusindicatorinterfacewrapper.hxx | 56 +++ framework/inc/uielement/styletoolbarcontroller.hxx | 81 ++++ .../uielement/togglebuttontoolbarcontroller.hxx | 79 ++++ framework/inc/uielement/toolbarmanager.hxx | 184 ++++++++ framework/inc/uielement/toolbarmerger.hxx | 140 ++++++ .../inc/uielement/toolbarmodemenucontroller.hxx | 78 ++++ framework/inc/uielement/toolbarsmenucontroller.hxx | 97 +++++ framework/inc/uielement/toolbarwrapper.hxx | 79 ++++ framework/inc/uielement/uicommanddescription.hxx | 94 +++++ framework/inc/uielement/uielement.hxx | 108 +++++ framework/inc/uielement/uielementtypenames.hxx | 33 ++ .../configurationaccessfactorymanager.hxx | 84 ++++ framework/inc/uifactory/factoryconfiguration.hxx | 93 ++++ framework/inc/uifactory/menubarfactory.hxx | 76 ++++ .../inc/xml/acceleratorconfigurationreader.hxx | 136 ++++++ .../inc/xml/acceleratorconfigurationwriter.hxx | 81 ++++ framework/inc/xml/imagesconfiguration.hxx | 57 +++ framework/inc/xml/imagesdocumenthandler.hxx | 136 ++++++ framework/inc/xml/menudocumenthandler.hxx | 226 ++++++++++ framework/inc/xml/saxnamespacefilter.hxx | 83 ++++ framework/inc/xml/statusbardocumenthandler.hxx | 138 ++++++ framework/inc/xml/toolboxconfigurationdefines.hxx | 68 +++ framework/inc/xml/toolboxdocumenthandler.hxx | 162 +++++++ framework/inc/xml/xmlnamespaces.hxx | 56 +++ 144 files changed, 14820 insertions(+) create mode 100644 framework/inc/acceleratorconst.h create mode 100644 framework/inc/addonmenu.hxx create mode 100644 framework/inc/bitmaps.hlst create mode 100644 framework/inc/classes/actiontriggercontainer.hxx create mode 100644 framework/inc/classes/actiontriggerpropertyset.hxx create mode 100644 framework/inc/classes/actiontriggerseparatorpropertyset.hxx create mode 100644 framework/inc/classes/converter.hxx create mode 100644 framework/inc/classes/framecontainer.hxx create mode 100644 framework/inc/classes/fwkresid.hxx create mode 100644 framework/inc/classes/imagewrapper.hxx create mode 100644 framework/inc/classes/protocolhandlercache.hxx create mode 100644 framework/inc/classes/resource.hxx create mode 100644 framework/inc/classes/rootactiontriggercontainer.hxx create mode 100644 framework/inc/classes/taskcreator.hxx create mode 100644 framework/inc/dispatch/closedispatcher.hxx create mode 100644 framework/inc/dispatch/dispatchinformationprovider.hxx create mode 100644 framework/inc/dispatch/dispatchprovider.hxx create mode 100644 framework/inc/dispatch/interceptionhelper.hxx create mode 100644 framework/inc/dispatch/mailtodispatcher.hxx create mode 100644 framework/inc/dispatch/oxt_handler.hxx create mode 100644 framework/inc/dispatch/popupmenudispatcher.hxx create mode 100644 framework/inc/dispatch/servicehandler.hxx create mode 100644 framework/inc/dispatch/startmoduledispatcher.hxx create mode 100644 framework/inc/dispatch/systemexec.hxx create mode 100644 framework/inc/fwidllapi.h create mode 100644 framework/inc/helper/dockingareadefaultacceptor.hxx create mode 100644 framework/inc/helper/mischelper.hxx create mode 100644 framework/inc/helper/ocomponentaccess.hxx create mode 100644 framework/inc/helper/ocomponentenumeration.hxx create mode 100644 framework/inc/helper/oframes.hxx create mode 100644 framework/inc/helper/persistentwindowstate.hxx create mode 100644 framework/inc/helper/propertysetcontainer.hxx create mode 100644 framework/inc/helper/shareablemutex.hxx create mode 100644 framework/inc/helper/statusindicator.hxx create mode 100644 framework/inc/helper/statusindicatorfactory.hxx create mode 100644 framework/inc/helper/tagwindowasmodified.hxx create mode 100644 framework/inc/helper/titlebarupdate.hxx create mode 100644 framework/inc/helper/uiconfigelementwrapperbase.hxx create mode 100644 framework/inc/helper/uielementwrapperbase.hxx create mode 100644 framework/inc/helper/vclstatusindicator.hxx create mode 100644 framework/inc/helper/wakeupthread.hxx create mode 100644 framework/inc/interaction/quietinteraction.hxx create mode 100644 framework/inc/jobs/configaccess.hxx create mode 100644 framework/inc/jobs/helponstartup.hxx create mode 100644 framework/inc/jobs/job.hxx create mode 100644 framework/inc/jobs/jobconst.hxx create mode 100644 framework/inc/jobs/jobdata.hxx create mode 100644 framework/inc/jobs/jobresult.hxx create mode 100644 framework/inc/jobs/joburl.hxx create mode 100644 framework/inc/jobs/shelljob.hxx create mode 100644 framework/inc/macros/registration.hxx create mode 100644 framework/inc/macros/xinterface.hxx create mode 100644 framework/inc/macros/xserviceinfo.hxx create mode 100644 framework/inc/macros/xtypeprovider.hxx create mode 100644 framework/inc/menuconfiguration.hxx create mode 100644 framework/inc/pch/precompiled_fwe.cxx create mode 100644 framework/inc/pch/precompiled_fwe.hxx create mode 100644 framework/inc/pch/precompiled_fwi.cxx create mode 100644 framework/inc/pch/precompiled_fwi.hxx create mode 100644 framework/inc/pch/precompiled_fwk.cxx create mode 100644 framework/inc/pch/precompiled_fwk.hxx create mode 100644 framework/inc/pch/precompiled_fwl.cxx create mode 100644 framework/inc/pch/precompiled_fwl.hxx create mode 100644 framework/inc/properties.h create mode 100644 framework/inc/protocols.h create mode 100644 framework/inc/recording/dispatchrecorder.hxx create mode 100644 framework/inc/recording/dispatchrecordersupplier.hxx create mode 100644 framework/inc/services.h create mode 100644 framework/inc/services/desktop.hxx create mode 100644 framework/inc/services/layoutmanager.hxx create mode 100644 framework/inc/services/mediatypedetectionhelper.hxx create mode 100644 framework/inc/services/uriabbreviation.hxx create mode 100644 framework/inc/statusbarconfiguration.hxx create mode 100644 framework/inc/stdtypes.h create mode 100644 framework/inc/strings.hrc create mode 100644 framework/inc/targets.h create mode 100644 framework/inc/taskcreatordefs.hxx create mode 100644 framework/inc/threadhelp/gate.hxx create mode 100644 framework/inc/threadhelp/transactionguard.hxx create mode 100644 framework/inc/threadhelp/transactionmanager.hxx create mode 100644 framework/inc/toolboxconfiguration.hxx create mode 100644 framework/inc/uiconfiguration/globalsettings.hxx create mode 100644 framework/inc/uiconfiguration/graphicnameaccess.hxx create mode 100644 framework/inc/uiconfiguration/imagemanager.hxx create mode 100644 framework/inc/uiconfiguration/imagetype.hxx create mode 100644 framework/inc/uiconfiguration/moduleimagemanager.hxx create mode 100644 framework/inc/uiconfiguration/windowstateproperties.hxx create mode 100644 framework/inc/uielement/FixedImageToolbarController.hxx create mode 100644 framework/inc/uielement/FixedTextToolbarController.hxx create mode 100644 framework/inc/uielement/addonstoolbarmanager.hxx create mode 100644 framework/inc/uielement/addonstoolbarwrapper.hxx create mode 100644 framework/inc/uielement/buttontoolbarcontroller.hxx create mode 100644 framework/inc/uielement/comboboxtoolbarcontroller.hxx create mode 100644 framework/inc/uielement/commandinfo.hxx create mode 100644 framework/inc/uielement/complextoolbarcontroller.hxx create mode 100644 framework/inc/uielement/constitemcontainer.hxx create mode 100644 framework/inc/uielement/dropdownboxtoolbarcontroller.hxx create mode 100644 framework/inc/uielement/edittoolbarcontroller.hxx create mode 100644 framework/inc/uielement/fontmenucontroller.hxx create mode 100644 framework/inc/uielement/fontsizemenucontroller.hxx create mode 100644 framework/inc/uielement/footermenucontroller.hxx create mode 100644 framework/inc/uielement/genericstatusbarcontroller.hxx create mode 100644 framework/inc/uielement/generictoolbarcontroller.hxx create mode 100644 framework/inc/uielement/headermenucontroller.hxx create mode 100644 framework/inc/uielement/imagebuttontoolbarcontroller.hxx create mode 100644 framework/inc/uielement/itemcontainer.hxx create mode 100644 framework/inc/uielement/langselectionmenucontroller.hxx create mode 100644 framework/inc/uielement/macrosmenucontroller.hxx create mode 100644 framework/inc/uielement/menubarmanager.hxx create mode 100644 framework/inc/uielement/menubarmerger.hxx create mode 100644 framework/inc/uielement/menubarwrapper.hxx create mode 100644 framework/inc/uielement/newmenucontroller.hxx create mode 100644 framework/inc/uielement/progressbarwrapper.hxx create mode 100644 framework/inc/uielement/rootitemcontainer.hxx create mode 100644 framework/inc/uielement/spinfieldtoolbarcontroller.hxx create mode 100644 framework/inc/uielement/statusbar.hxx create mode 100644 framework/inc/uielement/statusbaritem.hxx create mode 100644 framework/inc/uielement/statusbarmanager.hxx create mode 100644 framework/inc/uielement/statusbarmerger.hxx create mode 100644 framework/inc/uielement/statusbarwrapper.hxx create mode 100644 framework/inc/uielement/statusindicatorinterfacewrapper.hxx create mode 100644 framework/inc/uielement/styletoolbarcontroller.hxx create mode 100644 framework/inc/uielement/togglebuttontoolbarcontroller.hxx create mode 100644 framework/inc/uielement/toolbarmanager.hxx create mode 100644 framework/inc/uielement/toolbarmerger.hxx create mode 100644 framework/inc/uielement/toolbarmodemenucontroller.hxx create mode 100644 framework/inc/uielement/toolbarsmenucontroller.hxx create mode 100644 framework/inc/uielement/toolbarwrapper.hxx create mode 100644 framework/inc/uielement/uicommanddescription.hxx create mode 100644 framework/inc/uielement/uielement.hxx create mode 100644 framework/inc/uielement/uielementtypenames.hxx create mode 100644 framework/inc/uifactory/configurationaccessfactorymanager.hxx create mode 100644 framework/inc/uifactory/factoryconfiguration.hxx create mode 100644 framework/inc/uifactory/menubarfactory.hxx create mode 100644 framework/inc/xml/acceleratorconfigurationreader.hxx create mode 100644 framework/inc/xml/acceleratorconfigurationwriter.hxx create mode 100644 framework/inc/xml/imagesconfiguration.hxx create mode 100644 framework/inc/xml/imagesdocumenthandler.hxx create mode 100644 framework/inc/xml/menudocumenthandler.hxx create mode 100644 framework/inc/xml/saxnamespacefilter.hxx create mode 100644 framework/inc/xml/statusbardocumenthandler.hxx create mode 100644 framework/inc/xml/toolboxconfigurationdefines.hxx create mode 100644 framework/inc/xml/toolboxdocumenthandler.hxx create mode 100644 framework/inc/xml/xmlnamespaces.hxx (limited to 'framework/inc') diff --git a/framework/inc/acceleratorconst.h b/framework/inc/acceleratorconst.h new file mode 100644 index 000000000..0a1cad5fa --- /dev/null +++ b/framework/inc/acceleratorconst.h @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"; you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_ACCELERATORCONST_H +#define INCLUDED_FRAMEWORK_INC_ACCELERATORCONST_H + +namespace framework{ + +#define ATTRIBUTE_TYPE_CDATA "CDATA" + +// same items with a name space alias +#define AL_ELEMENT_ACCELERATORLIST "accel:acceleratorlist" +#define AL_ELEMENT_ITEM "accel:item" + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_ACCELERATORCONST_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/addonmenu.hxx b/framework/inc/addonmenu.hxx new file mode 100644 index 000000000..ea19f677c --- /dev/null +++ b/framework/inc/addonmenu.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include +#include + +#include + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::uno { template class Sequence; } +namespace com::sun::star::uno { template class Reference; } + +class MenuBar; +class PopupMenu; + +#define ADDONMENU_ITEMID_START 2000 +#define ADDONMENU_ITEMID_END 3000 + +namespace framework +{ + +class UNLESS_MERGELIBS(FWE_DLLPUBLIC) AddonMenuManager +{ + public: + static bool HasAddonMenuElements(); + + // Check if the context string matches the provided xModel context + static bool IsCorrectContext(const OUString& rModuleIdentifier, const OUString& rContext); + + // Create the Add-Ons menu + static VclPtr CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame ); + + // Merge the Add-Ons help menu items into the given menu bar at a defined pos + static void MergeAddonHelpMenu( const css::uno::Reference< css::frame::XFrame >& rFrame, + MenuBar const * pMergeMenuBar ); + + // Merge the addon popup menus into the given menu bar at the provided pos. + static void MergeAddonPopupMenus( const css::uno::Reference< css::frame::XFrame >& rFrame, + sal_uInt16 nMergeAtPos, + MenuBar* pMergeMenuBar ); + + // Returns the next position to insert a menu item/sub menu + static sal_uInt16 GetNextPos( sal_uInt16 nPos ); + + // Build up the menu item and sub menu into the provided pCurrentMenu. The sub menus should be of type nSubMenuType. + static void BuildMenu( PopupMenu* pCurrentMenu, + sal_uInt16 nInsPos, + sal_uInt16& nUniqueMenuId, + const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& aAddonMenuDefinition, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const OUString& rModuleIdentifier ); + + // Retrieve the menu entry property values from a sequence + static void GetMenuEntry( const css::uno::Sequence< css::beans::PropertyValue >& rAddonMenuEntry, + OUString& rTitle, + OUString& rURL, + OUString& rTarget, + OUString& rImageId, + OUString& rContext, + css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rAddonSubMenu ); +}; + +} // namespace framework + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/bitmaps.hlst b/framework/inc/bitmaps.hlst new file mode 100644 index 000000000..71a3efe82 --- /dev/null +++ b/framework/inc/bitmaps.hlst @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_FRAMEWORK_INC_BITMAPS_HRC +#define INCLUDED_FRAMEWORK_INC_BITMAPS_HRC + +#define BMP_SAVEMODIFIED_SMALL "res/savemodified_small.png" +#define BMP_SAVEMODIFIED_LARGE "res/savemodified_large.png" +#define BMP_SAVEMODIFIED_EXTRALARGE "res/savemodified_extralarge.png" + +#define RID_SVXBMP_BUTTON "res/sx10594.png" +#define RID_SVXBMP_RADIOBUTTON "res/sx10595.png" +#define RID_SVXBMP_CHECKBOX "res/sx10596.png" +#define RID_SVXBMP_FIXEDTEXT "res/sx10597.png" +#define RID_SVXBMP_GROUPBOX "res/sx10598.png" +#define RID_SVXBMP_EDITBOX "res/sx10599.png" +#define RID_SVXBMP_LISTBOX "res/sx10600.png" +#define RID_SVXBMP_COMBOBOX "res/sx10600.png" +#define RID_SVXBMP_IMAGEBUTTON "res/sx10604.png" +#define RID_SVXBMP_IMAGECONTROL "res/sx10710.png" +#define RID_SVXBMP_FILECONTROL "res/sx10605.png" +#define RID_SVXBMP_DATEFIELD "res/sx10704.png" +#define RID_SVXBMP_TIMEFIELD "res/sx10705.png" +#define RID_SVXBMP_NUMERICFIELD "res/sx10706.png" +#define RID_SVXBMP_CURRENCYFIELD "res/sx10707.png" +#define RID_SVXBMP_PATTERNFIELD "res/sx10708.png" +#define RID_SVXBMP_FORMATTEDFIELD "res/sx10728.png" +#define RID_SVXBMP_SCROLLBAR "res/sx10768.png" +#define RID_SVXBMP_SPINBUTTON "res/sx10769.png" +#define RID_SVXBMP_NAVIGATIONBAR "res/sx10607.png" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/framework/inc/classes/actiontriggercontainer.hxx b/framework/inc/classes/actiontriggercontainer.hxx new file mode 100644 index 000000000..ad01f4111 --- /dev/null +++ b/framework/inc/classes/actiontriggercontainer.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERCONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERCONTAINER_HXX + +#include +#include +#include +#include +#include + +#define SERVICENAME_ACTIONTRIGGERCONTAINER "com.sun.star.ui.ActionTriggerContainer" +#define IMPLEMENTATIONNAME_ACTIONTRIGGERCONTAINER "com.sun.star.comp.ui.ActionTriggerContainer" + +namespace framework +{ + +class ActionTriggerContainer final : public PropertySetContainer, + public css::lang::XMultiServiceFactory, + public css::lang::XServiceInfo, + public css::lang::XTypeProvider +{ + public: + ActionTriggerContainer(); + virtual ~ActionTriggerContainer() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XMultiServiceFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/actiontriggerpropertyset.hxx b/framework/inc/classes/actiontriggerpropertyset.hxx new file mode 100644 index 000000000..8dd37f068 --- /dev/null +++ b/framework/inc/classes/actiontriggerpropertyset.hxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERPROPERTYSET_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERPROPERTYSET_HXX + +#include +#include +#include +#include + +#include +#include +#include +#include + +#define SERVICENAME_ACTIONTRIGGER "com.sun.star.ui.ActionTrigger" +#define IMPLEMENTATIONNAME_ACTIONTRIGGER "com.sun.star.comp.ui.ActionTrigger" + +namespace framework +{ + +class ActionTriggerPropertySet final : private cppu::BaseMutex, + public css::lang::XServiceInfo , + public css::lang::XTypeProvider, + public ::cppu::OBroadcastHelper , + public ::cppu::OPropertySetHelper , // -> XPropertySet, XFastPropertySet, XMultiPropertySet + public ::cppu::OWeakObject +{ + public: + ActionTriggerPropertySet(); + virtual ~ActionTriggerPropertySet() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; + + private: + + // OPropertySetHelper + + virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& aConvertedValue, + css::uno::Any& aOldValue, + sal_Int32 nHandle, + const css::uno::Any& aValue ) override; + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& aValue ) override; + + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue, sal_Int32 nHandle ) const override; + + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + // helper + + /// @throws css::lang::IllegalArgumentException + bool impl_tryToChangeProperty( const OUString& aCurrentValue , + const css::uno::Any& aNewValue , + css::uno::Any& aOldValue , + css::uno::Any& aConvertedValue ); + + /// @throws css::lang::IllegalArgumentException + bool impl_tryToChangeProperty( const css::uno::Reference< css::awt::XBitmap >& xBitmap, + const css::uno::Any& aNewValue , + css::uno::Any& aOldValue , + css::uno::Any& aConvertedValue ); + + /// @throws css::lang::IllegalArgumentException + bool impl_tryToChangeProperty( const css::uno::Reference< css::uno::XInterface >& xInterface, + const css::uno::Any& aNewValue , + css::uno::Any& aOldValue , + css::uno::Any& aConvertedValue ); + + // members + + OUString m_aCommandURL; + OUString m_aHelpURL; + OUString m_aText; + css::uno::Reference< css::awt::XBitmap > m_xBitmap; + css::uno::Reference< css::uno::XInterface > m_xActionTriggerContainer; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERPROPERTYSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/actiontriggerseparatorpropertyset.hxx b/framework/inc/classes/actiontriggerseparatorpropertyset.hxx new file mode 100644 index 000000000..ed213b8fa --- /dev/null +++ b/framework/inc/classes/actiontriggerseparatorpropertyset.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERSEPARATORPROPERTYSET_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERSEPARATORPROPERTYSET_HXX + +#include +#include +#include +#include +#include +#include + +#define SERVICENAME_ACTIONTRIGGERSEPARATOR "com.sun.star.ui.ActionTriggerSeparator" +#define IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR "com.sun.star.comp.ui.ActionTriggerSeparator" + +namespace framework +{ + +class ActionTriggerSeparatorPropertySet final : private cppu::BaseMutex, + public css::lang::XServiceInfo , + public css::lang::XTypeProvider, + public ::cppu::OBroadcastHelper , + public ::cppu::OPropertySetHelper , // -> XPropertySet, XFastPropertySet, XMultiPropertySet + public ::cppu::OWeakObject +{ + public: + ActionTriggerSeparatorPropertySet(); + virtual ~ActionTriggerSeparatorPropertySet() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; + + private: + + // OPropertySetHelper + + virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any& aConvertedValue, + css::uno::Any& aOldValue, + sal_Int32 nHandle, + const css::uno::Any& aValue ) override; + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& aValue ) override; + + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue, sal_Int32 nHandle ) const override; + + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + // helper + + /// @throws css::lang::IllegalArgumentException + /// @throws css::uno::RuntimeException + bool impl_tryToChangeProperty( sal_Int16 aCurrentValue , + const css::uno::Any& aNewValue , + css::uno::Any& aOldValue , + css::uno::Any& aConvertedValue ); + + // members + + sal_Int16 m_nSeparatorType; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_ACTIONTRIGGERSEPARATORPROPERTYSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/converter.hxx b/framework/inc/classes/converter.hxx new file mode 100644 index 000000000..15d36a5f0 --- /dev/null +++ b/framework/inc/classes/converter.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_CONVERTER_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_CONVERTER_HXX + +#include +#include + +#include +#include +#include +#include +#include + +namespace framework{ + +class UNLESS_MERGELIBS(FWI_DLLPUBLIC) Converter +{ + public: + // Seq <=> Seq + static css::uno::Sequence< css::beans::NamedValue > convert_seqPropVal2seqNamedVal ( const css::uno::Sequence< css::beans::PropertyValue >& lSource ); + + // Seq => Vector + static std::vector convert_seqOUString2OUStringList( const css::uno::Sequence< OUString >& lSource ); + + static OUString convert_DateTime2ISO8601 ( const DateTime& aSource ); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_CONVERTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/framecontainer.hxx b/framework/inc/classes/framecontainer.hxx new file mode 100644 index 000000000..72a868f66 --- /dev/null +++ b/framework/inc/classes/framecontainer.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_FRAMECONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_FRAMECONTAINER_HXX + +#include + +#include + +#include +#include + +#include + +namespace framework{ + +typedef ::std::vector< css::uno::Reference< css::frame::XFrame > > TFrameContainer; + +/*-************************************************************************************************************ + @short implement a container to hold children of frame, task or desktop + @descr Every object of frame, task or desktop hold reference to its children. These container is used as helper + to do this. Some helper-classes like OFrames or OTasksAccess use it to. They hold a pointer to an instance + of this class, which is a member of a frame, task or desktop! You can append and remove frames. + It's possible to set one of these frames as active or deactivate. You could have full index-access to + container-items. + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ +class FrameContainer final +{ + + // member + + private: + + /// list to hold all frames + TFrameContainer m_aContainer; + /// one container item can be the current active frame. It's necessary for Desktop or Frame implementation. + css::uno::Reference< css::frame::XFrame > m_xActiveFrame; + + // interface + + public: + + /// constructor / destructor + FrameContainer(); + ~FrameContainer(); + + /// add/remove/mark container items + void append ( const css::uno::Reference< css::frame::XFrame >& xFrame ); + void remove ( const css::uno::Reference< css::frame::XFrame >& xFrame ); + void setActive ( const css::uno::Reference< css::frame::XFrame >& xFrame ); + css::uno::Reference< css::frame::XFrame > getActive ( ) const; + + /// checks and free memory + bool exist ( const css::uno::Reference< css::frame::XFrame >& xFrame ) const; + void clear ( ); + + /// deprecated IndexAccess! + sal_uInt32 getCount ( ) const; + css::uno::Reference< css::frame::XFrame > operator[]( sal_uInt32 nIndex ) const; + + /// replacement for deprecated index access + css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > getAllElements() const; + + /// special helper for Frame::findFrame() + css::uno::Reference< css::frame::XFrame > searchOnAllChildrens ( const OUString& sName ) const; + css::uno::Reference< css::frame::XFrame > searchOnDirectChildrens( const OUString& sName ) const; + +}; // class FrameContainer + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_FRAMECONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/fwkresid.hxx b/framework/inc/classes/fwkresid.hxx new file mode 100644 index 000000000..c6606c527 --- /dev/null +++ b/framework/inc/classes/fwkresid.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_FWKRESID_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_FWKRESID_HXX + +#include +#include + +FWE_DLLPUBLIC OUString FwkResId(const char* pId); + +#endif // __FRAMEWORK_CLASSES_FWKRESID + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/imagewrapper.hxx b/framework/inc/classes/imagewrapper.hxx new file mode 100644 index 000000000..9818552cb --- /dev/null +++ b/framework/inc/classes/imagewrapper.hxx @@ -0,0 +1,62 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_IMAGEWRAPPER_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_IMAGEWRAPPER_HXX + +#include +#include +#include +#include +#include + +namespace framework +{ + +class ImageWrapper final : public ::cppu::WeakImplHelper< css::awt::XBitmap, + css::lang::XUnoTunnel > +{ + public: + ImageWrapper( const Image& aImage ); + virtual ~ImageWrapper() override; + + const Image& GetImage() const + { + return m_aImage; + } + + static css::uno::Sequence< sal_Int8 > const & GetUnoTunnelId(); + + // XBitmap + virtual css::awt::Size SAL_CALL getSize() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getDIB() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getMaskDIB() override; + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + + private: + Image m_aImage; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_IMAGEWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/protocolhandlercache.hxx b/framework/inc/classes/protocolhandlercache.hxx new file mode 100644 index 000000000..fa7907927 --- /dev/null +++ b/framework/inc/classes/protocolhandlercache.hxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_PROTOCOLHANDLERCACHE_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_PROTOCOLHANDLERCACHE_HXX + +#include +#include + +#include + +#include +#include +#include + +namespace framework{ + +#define PACKAGENAME_PROTOCOLHANDLER "Office.ProtocolHandler" /// name of our configuration package + +#define CFG_PATH_SEPARATOR "/" /// separator for configuration paths + +#define PROPERTY_PROTOCOLS "Protocols" /// properties of a protocol handler + +/** + Programmer can register his own services to handle different protocols. + Don't forget: It doesn't mean "handling of documents" ... these services could handle protocols ... + e.g. "mailto:", "file://", ".java:" + This struct holds the information about one such registered protocol handler. + A list of handler objects is defined as ProtocolHandlerHash. see below +*/ +struct FWI_DLLPUBLIC ProtocolHandler +{ + /* member */ + public: + + /// the uno implementation name of this handler + OUString m_sUNOName; + /// list of URL pattern which defines the protocols which this handler is registered for + std::vector m_lProtocols; +}; + +/** + This hash use registered pattern of all protocol handlers as keys and provide her + uno implementation names as value. Overloading of the index operator makes it possible + to search for a key by using a full qualified URL on list of all possible pattern keys. +*/ +typedef std::unordered_map PatternHash; + +/** + This hash holds protocol handler structs by her names. +*/ +typedef std::unordered_map HandlerHash; + +/** + @short this hash makes it easy to find a protocol handler by using his uno implementation name. + @descr It holds two lists of information: + - first holds all handler by her uno implementation names and + can be used to get her other properties + - another one maps her registered pattern to her uno names to + perform search on such data + But this lists a static for all instances of this class. So it's possible to + create new objects without opening configuration twice and free memory automatically + if last object will gone. + + @attention We implement a singleton concept - so we don't need any mutex member here. + Because to safe access on static member we must use a static global lock + here too. + + @devstatus ready to use + @threadsafe yes +*/ + +class HandlerCFGAccess; +class UNLESS_MERGELIBS(FWI_DLLPUBLIC) HandlerCache final +{ + /* member */ + private: + + /// list of all registered handler registered by her uno implementation names + static std::unique_ptr s_pHandler; + /// maps URL pattern to handler names + static std::unique_ptr s_pPattern; + /// informs about config updates + static HandlerCFGAccess* s_pConfig; + /// ref count to construct/destruct internal member lists on demand by using singleton mechanism + static sal_Int32 m_nRefCount; + + /* interface */ + public: + + HandlerCache(); + ~HandlerCache(); + + bool search( const OUString& sURL, ProtocolHandler* pReturn ) const; + bool search( const css::util::URL& aURL, ProtocolHandler* pReturn ) const; + + void takeOver(std::unique_ptr pHandler, std::unique_ptr pPattern); +}; + +/** + @short implements configuration access for handler configuration + @descr We use the ConfigItem mechanism to read/write values from/to configuration. + We set a data container pointer for filling or reading ... this class use it temp. + After successfully calling of read(), we can use filled container directly or merge it with an existing one. + After successfully calling of write() all values of given data container are flushed to our configuration - + but current implementation doesn't support writing really. + + @base ::utl::ConfigItem + base mechanism for configuration access + + @devstatus ready to use + @threadsafe no +*/ +class HandlerCFGAccess : public ::utl::ConfigItem +{ + private: + HandlerCache* m_pCache; + + virtual void ImplCommit() override; + + /* interface */ + public: + HandlerCFGAccess( const OUString& sPackage ); + void read ( HandlerHash& rHandlerHash, PatternHash& rPatternHash ); + + void setCache(HandlerCache* pCache) {m_pCache = pCache;}; + virtual void Notify(const css::uno::Sequence< OUString >& lPropertyNames) override; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_PROTOCOLHANDLERCACHE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/resource.hxx b/framework/inc/classes/resource.hxx new file mode 100644 index 000000000..04f00677c --- /dev/null +++ b/framework/inc/classes/resource.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_RESOURCE_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_RESOURCE_HXX + +#define MENUITEM_TOOLBAR_VISIBLEBUTTON 1 +#define MENUITEM_TOOLBAR_CUSTOMIZETOOLBAR 2 +#define MENUITEM_TOOLBAR_UNDOCKTOOLBAR 3 +#define MENUITEM_TOOLBAR_DOCKTOOLBAR 4 +#define MENUITEM_TOOLBAR_DOCKALLTOOLBAR 5 +#define MENUITEM_TOOLBAR_LOCKTOOLBARPOSITION 6 +#define MENUITEM_TOOLBAR_CLOSE 7 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/rootactiontriggercontainer.hxx b/framework/inc/classes/rootactiontriggercontainer.hxx new file mode 100644 index 000000000..42f8766a1 --- /dev/null +++ b/framework/inc/classes/rootactiontriggercontainer.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_ROOTACTIONTRIGGERCONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_ROOTACTIONTRIGGERCONTAINER_HXX + +#include +#include +#include +#include +#include +#include +#include +#include + +#define IMPLEMENTATIONNAME_ROOTACTIONTRIGGERCONTAINER "com.sun.star.comp.ui.RootActionTriggerContainer" + +namespace framework +{ + +class RootActionTriggerContainer final : public PropertySetContainer, + public css::lang::XMultiServiceFactory, + public css::lang::XServiceInfo, + public css::lang::XUnoTunnel, + public css::lang::XTypeProvider, + public css::container::XNamed +{ + public: + RootActionTriggerContainer( const Menu* pMenu, const OUString* pMenuIdentifier); + virtual ~RootActionTriggerContainer() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XMultiServiceFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const OUString& aServiceSpecifier ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override; + + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override; + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + + virtual sal_Bool SAL_CALL hasElements() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName( ) override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override; + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; + + // XNamed + virtual OUString SAL_CALL getName( ) override; + virtual void SAL_CALL setName( const OUString& aName ) override; + + private: + void FillContainer(); + + bool m_bContainerCreated; + VclPtr m_pMenu; + const OUString* m_pMenuIdentifier; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_ROOTACTIONTRIGGERCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/classes/taskcreator.hxx b/framework/inc/classes/taskcreator.hxx new file mode 100644 index 000000000..e9e98df4e --- /dev/null +++ b/framework/inc/classes/taskcreator.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_CLASSES_TASKCREATOR_HXX +#define INCLUDED_FRAMEWORK_INC_CLASSES_TASKCREATOR_HXX + +#include +#include + +#include +#include +#include + +namespace framework{ + +/* + @short a helper to create new tasks or sub frames for "_blank" or FrameSearchFlag::CREATE + @descr There are different places to create new (task)frames and it's not easy to service this code. + That's the reason for this helper. It encapsulates asynchronous/synchronous creation + by providing a simple interface. + + @devstatus ready to use + @threadsafe yes +*/ +class TaskCreator final +{ + + // member + private: + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + // interface + public: + + TaskCreator( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + ~TaskCreator( ); + + css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor ); + +}; // class TaskCreator + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_CLASSES_TASKCREATOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/closedispatcher.hxx b/framework/inc/dispatch/closedispatcher.hxx new file mode 100644 index 000000000..cb48569b5 --- /dev/null +++ b/framework/inc/dispatch/closedispatcher.hxx @@ -0,0 +1,264 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_CLOSEDISPATCHER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_CLOSEDISPATCHER_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +class SystemWindow; + +namespace framework{ + +/** + @short helper to dispatch the URLs ".uno:CloseDoc"/".uno:CloseWin"/".uno:CloseFrame" + to close a frame/document or the whole application implicitly in case it was the last frame + + @descr These URLs implements a special functionality to close a document or the whole frame ... + and handle the state, it was the last frame or document. Then we create the + default backing document which can be used to open new ones using the file open dialog + or some other menu entries. Or we terminate the whole application in case this backing mode should not + be used. + */ +class CloseDispatcher final : public ::cppu::WeakImplHelper< + css::frame::XNotifyingDispatch, // => XDispatch + css::frame::XDispatchInformationProvider > +{ + + // types + + private: + + /** @short describe, which request must be done here. + @descr The incoming URLs {.uno:CloseDoc/CloseWin and CloseFrame + can be classified so and checked later performant.}*/ + enum EOperation + { + E_CLOSE_DOC, + E_CLOSE_FRAME, + E_CLOSE_WIN + }; + + // member + + private: + + /** @short reference to a uno service manager, + which can be used to create own needed + uno resources. */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** @short reference to the target frame, which should be + closed by this dispatch. */ + css::uno::WeakReference< css::frame::XFrame > m_xCloseFrame; + + /** @short used for asynchronous callbacks within the main thread. + @descr Internally we work asynchronously. Because our callees + are not aware that their request can kill its own environment... */ + std::unique_ptr m_aAsyncCallback; + + /** @short used inside asynchronous callback to decide, + which operation must be executed. */ + EOperation m_eOperation; + + /** @short for asynchronous operations we must hold us self alive! */ + css::uno::Reference< css::uno::XInterface > m_xSelfHold; + + /** @short holded alive for internally asynchronous operations! */ + css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener; + + VclPtr m_pSysWindow; + + // native interface + + public: + + /** @short connect a new CloseDispatcher instance to its frame. + @descr One CloseDispatcher instance is bound to own frame only. + That makes an implementation (e.g. of listener support) + much more easier .-) + + @param rxContext + an un oservice manager, which is needed to create uno resource + internally. + + @param xFrame + the frame where the corresponding dispatch was started. + + @param sTarget + help us to find the right target for this close operation. + */ + CloseDispatcher(const css::uno::Reference< css::uno::XComponentContext >& rxContext , + const css::uno::Reference< css::frame::XFrame >& xFrame , + const OUString& sTarget); + + /** @short does nothing real. */ + virtual ~CloseDispatcher() override; + + // uno interface + + public: + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override; + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments) override; + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + + // XDispatchInformationProvider + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups ( ) override; + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) override; + + // internal helper + + private: + + /** @short a callback for asynchronous started operations. + + @descr As already mentioned, we make internally all operations + asynchronous. Otherwise our callis kill its own environment + during they call us... + */ + DECL_LINK( impl_asyncCallback, LinkParamNone*, void ); + + /** @short prepare m_xCloseFrame so it should be closeable without problems. + + @descr That's needed to be sure, that the document can't disagree + later with e.g. an office termination. + The problem: Closing of documents can show UI. If the user + ignores it and open/close other documents, we can't know + which state the office has after closing of this frame. + + @param bCloseAllOtherViewsToo + if there are other top level frames, which + contains views to the same document then our m_xCloseFrame, + they are forced to be closed too. + We need it to implement the CLOSE_DOC semantic. + + @return [boolean] + sal_True if closing was successful. + */ + bool implts_prepareFrameForClosing(const css::uno::Reference< css::frame::XFrame >& xFrame, + bool bCloseAllOtherViewsToo, + bool& bControllerSuspended ); + + /** @short close the member m_xCloseFrame. + + @descr This method does not look for any document + inside this frame. Such views must be cleared + before (e.g. by calling implts_closeView()! + + Otherwise e.g. the XController->suspend() + call is not made and no UI warn the user about + losing document changes. Because the + frame is closed... + + @return [bool] + sal_True if closing was successful. + */ + bool implts_closeFrame(); + + /** @short set the special BackingComponent (now StartModule) + as new component of our m_xCloseFrame. + + @return [bool] + sal_True if operation was successful. + */ + bool implts_establishBackingMode(); + + /** @short calls XDesktop->terminate(). + + @descr No office code has to be called + afterwards! Because the process is dying... + The only exception is a might be registered + listener at this instance here. + Because he should know, that such things will happen :-) + + @return [bool] + sal_True if termination of the application was started ... + */ + bool implts_terminateApplication(); + + /** @short notify a DispatchResultListener. + + @descr We check the listener reference before we use it. + So this method can be called every time! + + @parama xListener + the listener, which should be notified. + Can be null! + + @param nState + directly used as css::frame::DispatchResultState value. + + @param aResult + not used yet really ... + */ + void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener, + sal_Int16 nState , + const css::uno::Any& aResult ); + + /** @short try to find the right target frame where this close request + must be really done. + + @descr The problem behind: closing some resources depends sometimes from the + context where its dispatched. Sometimes the start frame of the dispatch + has to be closed itself (target=_self) ... sometimes its parent frame + has to be closed - BUT(!) it means a parent frame containing a top level + window. _top can't be used then for dispatch - because it address TopFrames + not frames containing top level windows. So normally _magic (which btw does not + exists at the moment .-) ) should be used. So we interpret target= + as _magic ! + + @param xFrame + start point for search of right dispatch frame. + + @param sTarget + give us an idea how this target frame must be searched. + */ + + static css::uno::Reference< css::frame::XFrame > static_impl_searchRightTargetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame , + const OUString& sTarget); + +}; // class CloseDispatcher + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_CLOSEDISPATCHER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/dispatchinformationprovider.hxx b/framework/inc/dispatch/dispatchinformationprovider.hxx new file mode 100644 index 000000000..9b2106083 --- /dev/null +++ b/framework/inc/dispatch/dispatchinformationprovider.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHINFORMATIONPROVIDER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHINFORMATIONPROVIDER_HXX + +#include +#include + +#include +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short a helper to merge dispatch information of different sources together. +*//*-*************************************************************************************************************/ +class DispatchInformationProvider final : public ::cppu::WeakImplHelper< css::frame::XDispatchInformationProvider > +{ + + // member + private: + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + // interface + public: + + DispatchInformationProvider(const css::uno::Reference< css::uno::XComponentContext >& xContext , + const css::uno::Reference< css::frame::XFrame >& xFrame); + + virtual ~DispatchInformationProvider() override; + + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups() override; + + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation(sal_Int16 nCommandGroup) override; + + // helper + private: + + css::uno::Sequence< css::uno::Reference< css::frame::XDispatchInformationProvider > > implts_getAllSubProvider(); + +}; // class DispatchInformationProvider + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHINFORMATIONPROVIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/dispatchprovider.hxx b/framework/inc/dispatch/dispatchprovider.hxx new file mode 100644 index 000000000..d94b53c45 --- /dev/null +++ b/framework/inc/dispatch/dispatchprovider.hxx @@ -0,0 +1,116 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX + +#include + +#include +#include +#include +#include +#include + +#include +#include + +namespace framework{ + +/** + @descr We know some special dispatch objects with different functionality. + The can be created internally by the following DispatchProvider. + Here we define some identifier to force creation of the right one. +*/ +enum EDispatchHelper +{ + E_DEFAULTDISPATCHER , + E_CREATEDISPATCHER , + E_BLANKDISPATCHER , + E_SELFDISPATCHER , + E_CLOSEDISPATCHER , + E_STARTMODULEDISPATCHER +}; + +/** + @short implement a helper for XDispatchProvider interface + @descr The result of a queryDispatch() call depends from the owner, which use an instance of this class. + (frame, desktop) All of them must provides different functionality. + E.g: - task can be created by the desktop only + - a task can have a beamer as direct child + - a normal frame never can create a new one by himself + + @attention Use this class as member only! Never use it as baseclass. + XInterface will be ambiguous and we hold a weakreference to our OWNER - not to our SUPERCLASS! + + @base OWeakObject + provides ref count and weak mechanism + + @devstatus ready to use + @threadsafe yes +*/ +class DispatchProvider final : public ::cppu::WeakImplHelper< css::frame::XDispatchProvider > +{ + /* member */ + private: + /// reference to global service manager to create new services + css::uno::Reference< css::uno::XComponentContext > m_xContext; + /// weakreference to owner frame (Don't use a hard reference. Owner can't delete us then!) + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + /// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols + HandlerCache m_aProtocolHandlerCache; + + /* interface */ + public: + + DispatchProvider( const css::uno::Reference< css::uno::XComponentContext >& xContext , + const css::uno::Reference< css::frame::XFrame >& xFrame ); + + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const OUString& sTargetFrameName , + sal_Int32 nSearchFlags ) override; + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptions ) override; + + /* helper */ + private: + // Let him protected! So nobody can use us as base ... + virtual ~DispatchProvider() override; + + css::uno::Reference< css::frame::XDispatch > implts_getOrCreateDispatchHelper ( EDispatchHelper eHelper , + const css::uno::Reference< css::frame::XFrame >& xOwner , + const OUString& sTarget = OUString() , + sal_Int32 nSearchFlags = 0 ); + bool implts_isLoadableContent ( const css::util::URL& aURL ); + css::uno::Reference< css::frame::XDispatch > implts_queryDesktopDispatch ( const css::uno::Reference< css::frame::XFrame >& xDesktop , + const css::util::URL& aURL , + const OUString& sTargetFrameName , + sal_Int32 nSearchFlags ); + css::uno::Reference< css::frame::XDispatch > implts_queryFrameDispatch ( const css::uno::Reference< css::frame::XFrame >& xFrame , + const css::util::URL& aURL , + const OUString& sTargetFrameName , + sal_Int32 nSearchFlags ); + css::uno::Reference< css::frame::XDispatch > implts_searchProtocolHandler ( const css::util::URL& aURL ); + +}; // class DispatchProvider + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_DISPATCHPROVIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/interceptionhelper.hxx b/framework/inc/dispatch/interceptionhelper.hxx new file mode 100644 index 000000000..73146ea92 --- /dev/null +++ b/framework/inc/dispatch/interceptionhelper.hxx @@ -0,0 +1,257 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_INTERCEPTIONHELPER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_INTERCEPTIONHELPER_HXX + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace framework{ + +/** @short implements a helper to support interception with additional functionality. + + @descr This helper implements the complete XDispatchProviderInterception interface with + master/slave functionality AND using of optional features like registration of URL pattern! + + @attention Don't use this class as direct member - use it dynamically. Do not derive from this class. + We hold a weakreference to our owner not to our superclass. + */ +class InterceptionHelper final : public ::cppu::WeakImplHelper< + css::frame::XDispatchProvider, + css::frame::XDispatchProviderInterception, + css::lang::XEventListener > +{ + + // structs, helper + + /** @short bind an interceptor component to its URL pattern registration. */ + struct InterceptorInfo + { + /** @short reference to the interceptor component. */ + css::uno::Reference< css::frame::XDispatchProvider > xInterceptor; + + /** @short it's registration for URL patterns. + + @descr If the interceptor component does not support the optional interface + XInterceptorInfo, it will be registered for one pattern "*" by default. + That would make it possible to handle it in the same manner then real + registered interceptor objects and we must not implement any special code. */ + css::uno::Sequence< OUString > lURLPattern; + }; + + /** @short implements a list of items of type InterceptorInfo, and provides some special + functions on it. + + @descr Because interceptor objects can be registered for URL patterns, + it supports a wildcard search on all list items. + */ + class InterceptorList : public ::std::deque< InterceptorInfo > + { + public: + + /** @short search for an interceptor inside this list using it's reference. + + @param xInterceptor + points to the interceptor object, which should be located inside this list. + + @return An iterator object, which points directly to the located item inside this list. + In case no interceptor could be found, it points to the end of this list! + */ + iterator findByReference(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) + { + iterator pIt; + for (pIt=begin(); pIt!=end(); ++pIt) + { + if (pIt->xInterceptor == xInterceptor) + return pIt; + } + return end(); + } + + /** @short search for an interceptor inside this list using it's reference. + + @param xInterceptor + points to the interceptor object, which should be located inside this list. + + @return An iterator object, which points directly to the located item inside this list. + In case no interceptor could be found, it points to the end of this list! + */ + iterator findByPattern(const OUString& sURL) + { + iterator pIt; + for (pIt=begin(); pIt!=end(); ++pIt) + { + sal_Int32 c = pIt->lURLPattern.getLength(); + const OUString* pPattern = pIt->lURLPattern.getConstArray(); + + for (sal_Int32 i=0; i m_xOwnerWeak; + + /** @short this interception helper implements the top level master of an interceptor list ... + but this member is the lowest possible slave! */ + css::uno::Reference< css::frame::XDispatchProvider > m_xSlave; + + /** @short contains all registered interceptor objects. */ + InterceptorList m_lInterceptionRegs; + + // native interface + + public: + + /** @short creates a new interception helper instance. + + @param xOwner + points to the frame, which use this instances to support its own interception interfaces. + + @param xSlave + an outside creates dispatch provider, which has to be used here as lowest slave "interceptor". + */ + InterceptionHelper(const css::uno::Reference< css::frame::XFrame >& xOwner, + const css::uno::Reference< css::frame::XDispatchProvider >& xSlave); + + private: + + /** @short standard destructor. + + @descr This method destruct an instance of this class and clear some member. + This method is protected, because it's not allowed to use this class as a direct member! + You MUST use a dynamical instance (pointer). That's the reason for a protected dtor. + */ + virtual ~InterceptionHelper() override; + + // uno interface + + public: + + // XDispatchProvider + + /** @short query for a dispatch, which implements the requested feature. + + @descr We search inside our list of interception registrations, to locate + any interested interceptor. In case no interceptor exists or nobody is + interested on this URL our lowest slave will be used. + + @param aURL + describes the requested dispatch functionality. + + @param sTargetFrameName + the name of the target frame or a special name like "_blank", "_top" ... + Won't be used here ... but may by one of our registered interceptor objects + or our slave. + + @param nSearchFlags + optional search parameter for targeting, if sTargetFrameName isn't a special one. + + @return A valid dispatch object, if any interceptor or at least our slave is interested on the given URL; + or NULL otherwise. + */ + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL& aURL , + const OUString& sTargetFrameName, + sal_Int32 nSearchFlags ) override; + + // XDispatchProvider + + /** @short implements an optimized queryDispatch() for remote. + + @descr It capsulate more than one queryDispatch() requests and return a list of dispatch objects + as result. Because both lists (in and out) correspond together, it's not allowed to + pack it - means suppress NULL references! + + @param lDescriptor + a list of queryDispatch() arguments. + + @return A list of dispatch objects. + */ + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor) override; + + // XDispatchProviderInterception + + /** @short register an interceptor. + + @descr Somebody can register himself to intercept all or some special dispatches. + It's depend from his supported interfaces. If he implement XInterceptorInfo + he his called for some special URLs only - otherwise we call it for every request! + + @attention We don't check for double registrations here! + + @param xInterceptor + reference to interceptor, which wishes to be registered here. + + @throw A RuntimeException if the given reference is NULL! + */ + virtual void SAL_CALL registerDispatchProviderInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override; + + // XDispatchProviderInterception + + /** @short release an interceptor. + + @descr Remove the registered interceptor from our internal list + and delete all special information about it. + + @param xInterceptor + reference to the interceptor, which wishes to be deregistered. + + @throw A RuntimeException if the given reference is NULL! + */ + virtual void SAL_CALL releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor ) override; + + // XEventListener + + /** @short Is called from our owner frame, in case he will be disposed. + + @descr We have to release all references to him then. + Normally we will die by ref count too... + */ + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + +}; // class InterceptionHelper + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_INTERCEPTIONHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/mailtodispatcher.hxx b/framework/inc/dispatch/mailtodispatcher.hxx new file mode 100644 index 000000000..a830822cd --- /dev/null +++ b/framework/inc/dispatch/mailtodispatcher.hxx @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_MAILTODISPATCHER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_MAILTODISPATCHER_HXX + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace framework{ + +/** + @short protocol handler for "mailto:" URLs + @descr It's a special dispatch object which is used registered for "mailto:*" URLs and + will be automatically used from the framework dispatch mechanism if such URL occurred. + + @base OWeakObject + provides XWeak and ref count mechanism + + @devstatus ready to use +*/ +class MailToDispatcher final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::frame::XDispatchProvider, + css::frame::XNotifyingDispatch> // => XDispatch +{ + /* member */ + private: + + /// reference to global uno service manager which had created us + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /* interface */ + public: + + // ctor/dtor + MailToDispatcher( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~MailToDispatcher( ) override; + + // XInterface, XTypeProvider, XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const OUString& sTarget , + sal_Int32 nFlags ) override; + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) override; + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override; + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + + /* internal */ + private: + /// @throws css::uno::RuntimeException + bool implts_dispatch( const css::util::URL& aURL ); + +}; // class MailToDispatcher + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_MAILTODISPATCHER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/oxt_handler.hxx b/framework/inc/dispatch/oxt_handler.hxx new file mode 100644 index 000000000..69bc07074 --- /dev/null +++ b/framework/inc/dispatch/oxt_handler.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_OXT_HANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_OXT_HANDLER_HXX + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short handler to detect and play sounds ("wav" and "au" only!) + @descr Register this implementation as a content handler to detect and/or play wav- and au-sounds. + It doesn't depend from the target platform. But one instance of this class + can play one sound at the same time only. Means every new dispatch request will stop the + might still running one. So we support one operation/one URL/one listener at the same time + only. + + @devstatus ready + @threadsafe yes +*//*-*************************************************************************************************************/ +class Oxt_Handler final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::frame::XNotifyingDispatch, // => XDispatch + css::document::XExtendedFilterDetection > +{ + + public: + + Oxt_Handler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~Oxt_Handler( ) override; + + // XInterface, XTypeProvider, XServiceInfo + + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XNotifyingDispatch + + virtual void SAL_CALL dispatchWithNotification(const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override; + + // XDispatch + + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; + // not supported ! + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ , + const css::util::URL& /*aURL*/ ) override {}; + virtual void SAL_CALL removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ , + const css::util::URL& /*aURL*/ ) override {}; + + // XExtendedFilterDetection + virtual OUString SAL_CALL detect ( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) override; + + private: + osl::Mutex m_mutex; + + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; /// global uno service factory to create new services + +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_OXT_HANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/popupmenudispatcher.hxx b/framework/inc/dispatch/popupmenudispatcher.hxx new file mode 100644 index 000000000..869ee956e --- /dev/null +++ b/framework/inc/dispatch/popupmenudispatcher.hxx @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_POPUPMENUDISPATCHER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_POPUPMENUDISPATCHER_HXX + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short helper for desktop only(!) to create new tasks on demand for dispatches + @descr Use this class as member only! Never use it as baseclass. + XInterface will be ambiguous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS! + + @implements XInterface + XDispatch + XLoadEventListener + XFrameActionListener + XEventListener + @base OWeakObject + + @devstatus ready to use +*//*-*************************************************************************************************************/ +class PopupMenuDispatcher final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::frame::XDispatchProvider, + css::frame::XDispatch, + css::frame::XFrameActionListener, + css::lang::XInitialization > +{ + + // public methods + + public: + + // constructor / destructor + PopupMenuDispatcher( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + + // XInterface, XTypeProvider, XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ) override; + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( + const css::util::URL& aURL , + const OUString& sTarget , + sal_Int32 nFlags ) override; + + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( + const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) override; + + // XDispatch + virtual void SAL_CALL dispatch( const css::util::URL& aURL, + const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) override; + + virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) override; + + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, + const css::util::URL& aURL ) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) override; + + // XEventListener + void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + private: + virtual ~PopupMenuDispatcher() override; + + void impl_RetrievePopupControllerQuery(); + + css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame; /// css::uno::WeakReference to frame (Don't use a hard css::uno::Reference. Owner can't delete us then!) + css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery; /// reference to query for popup controller + css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory; /// reference to the uri reference factory + css::uno::Reference< css::uno::XComponentContext > m_xContext; /// factory shared with our owner to create new services! + bool m_bAlreadyDisposed; /// Protection against multiple disposing calls. + bool m_bActivateListener; /// dispatcher is listener for frame activation + +}; // class PopupMenuDispatcher + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_POPUPMENUDISPATCHER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/servicehandler.hxx b/framework/inc/dispatch/servicehandler.hxx new file mode 100644 index 000000000..41d3343da --- /dev/null +++ b/framework/inc/dispatch/servicehandler.hxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_SERVICEHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_SERVICEHANDLER_HXX + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace framework{ + +/** + @short protocol handler for "service:*" URLs + @descr It's a special dispatch/provider object which is registered for such URL pattern and will + be automatically used by the framework dispatch mechanism if such URL occurred. + His job is to create any registered uno components which must be coded inside + dispatched URL (may with some optional given parameters). After that such created + service must be hold his self alive. Such mechanism can be useful for UI components + (e.g. Dialogs, Wizards) only. + + @base OWeakObject + provides XWeak and ref count mechanism + + @devstatus ready to use +*/ +class ServiceHandler final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo , + css::frame::XDispatchProvider , + css::frame::XNotifyingDispatch > // => XDispatch +{ + /* member */ + private: + + /// reference to global uno service manager which had created us + css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory; + + /* interface */ + public: + + // ctor/dtor + ServiceHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~ServiceHandler( ) override; + + // XInterface, XTypeProvider, XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const OUString& sTarget , + sal_Int32 nFlags ) override; + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) override; + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override; + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + + /* internal */ + private: + /// @throws css::uno::RuntimeException + css::uno::Reference< css::uno::XInterface > implts_dispatch( const css::util::URL& aURL ); + +}; // class ServiceHandler + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_SERVICEHANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/startmoduledispatcher.hxx b/framework/inc/dispatch/startmoduledispatcher.hxx new file mode 100644 index 000000000..3d3f53918 --- /dev/null +++ b/framework/inc/dispatch/startmoduledispatcher.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_STARTMODULEDISPATCHER_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_STARTMODULEDISPATCHER_HXX + +#include +#include +#include +#include +#include +#include + +#include + +namespace framework{ + +/** + @short helper to handle all URLs related to the StartModule + */ +class StartModuleDispatcher final : public ::cppu::WeakImplHelper< + css::frame::XNotifyingDispatch, // => XDispatch + css::frame::XDispatchInformationProvider > +{ + + // member + + private: + + /** @short reference to a uno service manager, + which can be used to create own needed + uno resources. */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + // native interface + + public: + + /** @short connect a new StartModuleDispatcher instance to its "owner frame". + + @descr Such "owner frame" is used as context for all related operations. + + @param xContext + a UNO service manager, which is needed to create UNO resource + internally. + + @param xFrame + the frame where the corresponding dispatch was started. + */ + StartModuleDispatcher(const css::uno::Reference< css::uno::XComponentContext >& rxContext); + + /** @short does nothing real. */ + virtual ~StartModuleDispatcher() override; + + // uno interface + + public: + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override; + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments) override; + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + + // XDispatchInformationProvider + virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups ( ) override; + virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) override; + + // internal helper + + private: + + /** @short check if StartModule can be shown. + */ + bool implts_isBackingModePossible(); + + /** @short open the special BackingComponent (now StartModule) + */ + void implts_establishBackingMode(); + + /** @short notify a DispatchResultListener. + + @descr We check the listener reference before we use it. + So this method can be called every time! + + @parama xListener + the listener, which should be notified. + Can be null! + + @param nState + directly used as css::frame::DispatchResultState value. + + @param aResult + not used yet really ... + */ + void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener, + sal_Int16 nState , + const css::uno::Any& aResult ); + +}; // class StartModuleDispatcher + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_STARTMODULEDISPATCHER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/dispatch/systemexec.hxx b/framework/inc/dispatch/systemexec.hxx new file mode 100644 index 000000000..e1be82672 --- /dev/null +++ b/framework/inc/dispatch/systemexec.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_SYSTEMEXEC_HXX +#define INCLUDED_FRAMEWORK_INC_DISPATCH_SYSTEMEXEC_HXX + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace framework{ + +/** + @short protocol handler for "systemexec:*" URLs + @descr It's a special dispatch/provider object which is registered for such URL pattern and will + be automatically used by the framework dispatch mechanism if such URL occurred. + It forwards all URL's to the underlying operating system. + So it would e.g. be possible to open HTML files outside the office within a web browser. + + @base OWeakObject + provides XWeak and ref count mechanism + + @devstatus ready to use +*/ +class SystemExec final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo , + css::frame::XDispatchProvider , + css::frame::XNotifyingDispatch > // => XDispatch +{ + /* member */ + private: + + /// reference to global uno service manager which had created us + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /* interface */ + public: + + // ctor/dtor + SystemExec( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~SystemExec( ) override; + + // XInterface, XTypeProvider, XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const OUString& sTarget , + sal_Int32 nFlags ) override; + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) override; + + // XNotifyingDispatch + virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override; + + // XDispatch + virtual void SAL_CALL dispatch ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; + virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener , + const css::util::URL& aURL ) override; + + /* internal */ + private: + + void impl_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener, + const sal_Int16 nState ); + +}; // class SystemExec + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_DISPATCH_SYSTEMEXEC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/fwidllapi.h b/framework/inc/fwidllapi.h new file mode 100644 index 000000000..290f18721 --- /dev/null +++ b/framework/inc/fwidllapi.h @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_FWIDLLAPI_H +#define INCLUDED_FRAMEWORK_INC_FWIDLLAPI_H + +#include + +#if defined(FWI_DLLIMPLEMENTATION) +#define FWI_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define FWI_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +#endif // INCLUDED_FRAMEWORK_INC_FWIDLLAPI_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/dockingareadefaultacceptor.hxx b/framework/inc/helper/dockingareadefaultacceptor.hxx new file mode 100644 index 000000000..16423fb6e --- /dev/null +++ b/framework/inc/helper/dockingareadefaultacceptor.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_DOCKINGAREADEFAULTACCEPTOR_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_DOCKINGAREADEFAULTACCEPTOR_HXX + +#include +#include + +#include +#include + +namespace framework{ + +class DockingAreaDefaultAcceptor final : public ::cppu::WeakImplHelper< css::ui::XDockingAreaAcceptor > +{ + public: + + // constructor / destructor + + /*-**************************************************************************************************** + @short constructor to initialize this instance + @descr A docking area acceptor + But we need an instance to create more than one enumerations to the same tasklist! + + @seealso class Desktop + @seealso class OTasksEnumeration + + @param "xOwner" is a reference to our owner and must be the desktop! + @param "pTasks" is a pointer to the taskcontainer of the desktop. We need it to create a new enumeration. + @onerror Do nothing and reset this object to default with an empty list. + *//*-*****************************************************************************************************/ + + DockingAreaDefaultAcceptor( const css::uno::Reference< css::frame::XFrame >& xOwner ); + virtual ~DockingAreaDefaultAcceptor() override; + + // XDockingAreaAcceptor + + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getContainerWindow() override; + virtual sal_Bool SAL_CALL requestDockingAreaSpace( const css::awt::Rectangle& RequestedSpace ) override; + virtual void SAL_CALL setDockingAreaSpace( const css::awt::Rectangle& BorderSpace ) override; + + // variables + // (should be private everyway!) + + private: + + css::uno::WeakReference< css::frame::XFrame > m_xOwner; /// weak reference to our frame object! +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_DOCKINGAREADEFAULTACCEPTOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx new file mode 100644 index 000000000..00f868948 --- /dev/null +++ b/framework/inc/helper/mischelper.hxx @@ -0,0 +1,262 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_MISCHELPER_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_MISCHELPER_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +namespace framework +{ + +// menu ids for language status bar control +enum LangMenuIDs +{ + MID_LANG_SEL_1 = 1, // need to start with 1 since xPopupMenu->execute will return 0 if the menu is cancelled + MID_LANG_SEL_2, + MID_LANG_SEL_3, + MID_LANG_SEL_4, + MID_LANG_SEL_5, + MID_LANG_SEL_6, + MID_LANG_SEL_7, + MID_LANG_SEL_8, + MID_LANG_SEL_9, + MID_LANG_SEL_NONE, + MID_LANG_SEL_RESET, + MID_LANG_SEL_MORE, + MID_LANG_DEF_NONE, + MID_LANG_DEF_RESET, + MID_LANG_DEF_MORE, + + MID_LANG_PARA_SEPARATOR, + MID_LANG_PARA_STRING, + + MID_LANG_PARA_1, + MID_LANG_PARA_2, + MID_LANG_PARA_3, + MID_LANG_PARA_4, + MID_LANG_PARA_5, + MID_LANG_PARA_6, + MID_LANG_PARA_7, + MID_LANG_PARA_8, + MID_LANG_PARA_9, + MID_LANG_PARA_NONE, + MID_LANG_PARA_RESET, + MID_LANG_PARA_MORE, +}; + +inline bool IsScriptTypeMatchingToLanguage( SvtScriptType nScriptType, LanguageType nLang ) +{ + return bool(nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang )); +} + +inline void RetrieveTypeNameFromResourceURL( const OUString& aResourceURL, OUString& aType, OUString& aName ) +{ + static const char RESOURCEURL_PREFIX[] = "private:resource/"; + static const sal_Int32 RESOURCEURL_PREFIX_SIZE = strlen(RESOURCEURL_PREFIX); + + if (aResourceURL.startsWith( RESOURCEURL_PREFIX )) + { + sal_Int32 nIdx{ RESOURCEURL_PREFIX_SIZE }; + while (nIdx=aResourceURL.getLength()) + return; + aType = aResourceURL.getToken(0, '/', nIdx); + if (nIdx<0) + return; + while (nIdx=aResourceURL.getLength()) + return; + aName = aResourceURL.getToken(0, '/', nIdx); + } +} + +class LanguageGuessingHelper +{ + mutable css::uno::Reference< css::linguistic2::XLanguageGuessing > m_xLanguageGuesser; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + +public: + LanguageGuessingHelper(const css::uno::Reference< css::uno::XComponentContext >& _xContext) : m_xContext(_xContext){} + + css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetGuesser() const; +}; + +FWI_DLLPUBLIC void FillLangItems( std::set< OUString > &rLangItems, + const css::uno::Reference< css::frame::XFrame > &rxFrame, + const LanguageGuessingHelper & rLangGuessHelper, + SvtScriptType nScriptType, + const OUString & rCurLang, + const OUString & rKeyboardLang, + const OUString & rGuessedTextLang ); + +//It's common for an object to want to create and own a Broadcaster and set +//itself as a Listener on its own Broadcaster member. + +//However, calling addListener on a Broadcaster means that the Broadcaster adds +//a reference to the Listener leading to an ownership cycle where the Listener +//owns the Broadcaster which "owns" the Listener. + +//The WeakContainerListener allows breaking this cycle and retrofitting +//afflicted implementations fairly easily. + +//OriginalListener owns the Broadcaster which "owns" the WeakContainerListener +//which forwards the events to the OriginalListener without taking ownership of +//it. +class WeakContainerListener final : public ::cppu::WeakImplHelper +{ + private: + css::uno::WeakReference mxOwner; + + public: + WeakContainerListener(css::uno::Reference const & xOwner) + : mxOwner(xOwner) + { + } + + // container.XContainerListener + virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->elementInserted(rEvent); + } + + virtual void SAL_CALL elementRemoved(const css::container::ContainerEvent& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->elementRemoved(rEvent); + } + + virtual void SAL_CALL elementReplaced(const css::container::ContainerEvent& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->elementReplaced(rEvent); + } + + // lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +class WeakChangesListener final : public ::cppu::WeakImplHelper +{ + private: + css::uno::WeakReference mxOwner; + + public: + WeakChangesListener(css::uno::Reference const & xOwner) + : mxOwner(xOwner) + { + } + + // util.XChangesListener + virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->changesOccurred(rEvent); + } + + // lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +class WeakDocumentEventListener final : public ::cppu::WeakImplHelper +{ + private: + css::uno::WeakReference mxOwner; + + public: + WeakDocumentEventListener(css::uno::Reference const & xOwner) + : mxOwner(xOwner) + { + } + + virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->documentEventOccured(rEvent); + + } + + // lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override + { + css::uno::Reference xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +FWI_DLLPUBLIC css::uno::Reference +GetFirstListenerWith_Impl( + css::uno::Reference const& xEventFocus, + std::function const&)> const& rPredicate); + +FWI_DLLPUBLIC extern auto (*g_pGetMultiplexerListener)( + css::uno::Reference const&, + std::function const&)> const&) + -> css::uno::Reference; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_MISCHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/ocomponentaccess.hxx b/framework/inc/helper/ocomponentaccess.hxx new file mode 100644 index 000000000..ed11756c0 --- /dev/null +++ b/framework/inc/helper/ocomponentaccess.hxx @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short implement XEnumerationAccess interface as helper to create many oneway enumeration of components + @descr We share mutex and framecontainer with our owner and have full access to its child tasks. + (Our owner can be the Desktop only!) We create oneway enumerations on demand. These "lists" + can be used for one time only. Step during the list from first to last element. + (The type of created enumerations is OComponentEnumeration.) + + @implements XInterface + XTypeProvider + XEnumerationAccess + XElementAccess + + @base OWeakObject + + @devstatus ready to use +*//*-*************************************************************************************************************/ + +class OComponentAccess final : public ::cppu::WeakImplHelper< css::container::XEnumerationAccess > +{ + + // public methods + + public: + + // constructor / destructor + + /*-**************************************************************************************************** + @short constructor to initialize this instance + @descr A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a + snapshot of the components of current tasks under the desktop. + But we need an instance to create more than one enumerations at different times! + + @seealso class Desktop + @seealso class OComponentEnumeration + + @param "xOwner" is a reference to our owner and must be the desktop! + @onerror Do nothing and reset this object to default with an empty list. + *//*-*****************************************************************************************************/ + + OComponentAccess( const css::uno::Reference< css::frame::XDesktop >& xOwner ); + + // XEnumerationAccess + + /*-**************************************************************************************************** + @short create a new enumeration of components + @descr You can call this method to get a new snapshot from all components of all tasks of the desktop as an enumeration. + + @seealso interface XEnumerationAccess + @seealso interface XEnumeration + @seealso class Desktop + @return If the desktop and some components exist => a valid reference to an enumeration
+ An NULL-reference, other way. + *//*-*****************************************************************************************************/ + + virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override; + + // XElementAccess + + /*-**************************************************************************************************** + @short get the type of elements in enumeration + @seealso interface XElementAccess + @seealso class OComponentEnumeration + @return The uno-type XComponent. + *//*-*****************************************************************************************************/ + + virtual css::uno::Type SAL_CALL getElementType() override; + + /*-**************************************************************************************************** + @short get state of componentlist of enumeration. + @seealso interface XElementAccess + @return sal_True ,if more than 0 elements exist. + @return sal_False ,otherwise. + *//*-*****************************************************************************************************/ + + virtual sal_Bool SAL_CALL hasElements() override; + + // protected methods + + private: + + /*-**************************************************************************************************** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + Don't use an instance of this class as normal member. Use it dynamically with a pointer. + We hold a weakreference to our owner and not to our superclass! + That's the reason for a protected dtor. + + @seealso class Desktop + *//*-*****************************************************************************************************/ + + virtual ~OComponentAccess() override; + + + /*-**************************************************************************************************** + @short recursive method (!) to collect all components of all frames from the subtree of given node + @descr This is necessary to create the enumeration. + + @seealso method createEnumeration + + @param "xNode" , root of subtree and start point of search + @param "seqComponents", result list of search. We can't use a return value, we search recursive + and must collect all information. + *//*-*****************************************************************************************************/ + + void impl_collectAllChildComponents( const css::uno::Reference< css::frame::XFramesSupplier >& xNode , + std::vector< css::uno::Reference< css::lang::XComponent > >& seqComponents ); + + /*-**************************************************************************************************** + @short get the component of a frame + @descr The component of a frame can be the window, the controller or the model. + + @seealso method createEnumeration + + @param "xFrame", frame which contains the component + @return A reference to the component of given frame. + + @onerror A null reference is returned. + *//*-*****************************************************************************************************/ + + css::uno::Reference< css::lang::XComponent > impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const; + + css::uno::WeakReference< css::frame::XDesktop > m_xOwner; /// weak reference to the desktop object! + +}; // class OComponentAccess + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/ocomponentenumeration.hxx b/framework/inc/helper/ocomponentenumeration.hxx new file mode 100644 index 000000000..10de97dd5 --- /dev/null +++ b/framework/inc/helper/ocomponentenumeration.hxx @@ -0,0 +1,163 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTENUMERATION_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTENUMERATION_HXX + +#include +#include +#include + +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short implement a helper for a oneway enumeration of components + @descr You can step during this list only for one time! It's a snapshot. + Don't forget to release the reference. You are the owner of an instance of this implementation. + You can't use this as a baseclass. Please use it as a dynamical object for return. + + @implements XInterface + XTypeProvider + XEventListener + XEnumeration + + @base OWeakObject + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ + +class OComponentEnumeration final : public ::cppu::WeakImplHelper< css::container::XEnumeration,css::lang::XEventListener > +{ + + // public methods + + public: + + // constructor / destructor + + /*-**************************************************************************************************** + @short constructor to initialize this enumeration + @descr An enumeration is a list with oneway-access! You can get every member only for one time. + This method allow to initialize this oneway list with values. + @param "seqComponents" is a sequence of interfaces, which are components. + @onerror Do nothing and reset this object to default with an empty list. + *//*-*****************************************************************************************************/ + + OComponentEnumeration( const std::vector< css::uno::Reference< css::lang::XComponent > >& seqComponents ); + + // XEventListener + + /*-**************************************************************************************************** + @short last chance to release all references and free memory + @descr This method is called, if the enumeration is used completely and has no more elements. + Then we must destroy our list and release all references to other objects. + + @seealso interface XEventListener + + @param "aEvent" describe the source of this event. + *//*-*****************************************************************************************************/ + + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + // XEnumeration + + /*-**************************************************************************************************** + @short check count of accessible elements of enumeration + @descr You can call this method to get information about accessible elements in future. + Elements you have already gotten are not accessible! + + @seealso interface XEnumeration + @return sal_True = if more elements accessible
+ sal_False = other way + + @onerror sal_False
+ (List is empty and there no accessible elements ...) + *//*-*****************************************************************************************************/ + + virtual sal_Bool SAL_CALL hasMoreElements() override; + + /*-**************************************************************************************************** + @short give the next element, if some exist + @descr If a call "hasMoreElements()" return true, you can get the next element of list. + + @seealso interface XEnumeration + @return A Reference to a component, safed in an Any-structure. + + @onerror If end of enumeration is arrived or there are no elements in list => a NoSuchElementException is thrown. + *//*-*****************************************************************************************************/ + + virtual css::uno::Any SAL_CALL nextElement() override; + + // protected methods + + private: + + /*-**************************************************************************************************** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + We make it protected, because it's not supported to use this class as normal instance! + You must create it dynamical in memory and use a pointer. + *//*-*****************************************************************************************************/ + + virtual ~OComponentEnumeration() override; + + /*-**************************************************************************************************** + @short reset instance to default values + + @descr There are two ways to delete an instance of this class.
+ 1) delete with destructor
+ 2) dispose from parent or factory ore ...
+ This method do the same for both ways! It free used memory and release references ... + + @seealso method dispose() + @seealso destructor ~TaskEnumeration() + *//*-*****************************************************************************************************/ + + void impl_resetObject(); + + + // debug methods + // (should be private everyway!) + + /*-**************************************************************************************************** + @short debug-method to check incoming parameter of some other methods of this class + @descr The following methods are used to check parameters for other methods + of this class. The return value is used directly for an ASSERT(...). + + @seealso ASSERT in implementation! + + @param references to checking variables + @return sal_False on invalid parameter
+ sal_True otherway + *//*-*****************************************************************************************************/ + + sal_uInt32 m_nPosition; /// current position in enumeration + std::vector< css::uno::Reference< css::lang::XComponent > > m_seqComponents; /// list of current components + +}; // class OComponentEnumeration + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTENUMERATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/oframes.hxx b/framework/inc/helper/oframes.hxx new file mode 100644 index 000000000..1da482c4e --- /dev/null +++ b/framework/inc/helper/oframes.hxx @@ -0,0 +1,193 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_OFRAMES_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_OFRAMES_HXX + +#include + +#include +#include + +#include +#include + +namespace framework{ + +/** + @short implement XFrames, XIndexAccess and XElementAccess interfaces as helper for services + @descr Use this class as helper for these interfaces. We share mutex and framecontainer with our owner. + The framecontainer is a member of it from type "FrameContainer". That means; + we have the same information as our owner. In current implementation we use mutex and lock-mechanism + to prevent against compete access. In future we plan support of semaphore! + + @devstatus deprecated + + @ATTENTION Don't use this class as direct member - use it dynamically. Do not derive from this class. + We hold a weakreference to our owner not to our superclass. +*/ +class OFrames final : public ::cppu::WeakImplHelper< css::frame::XFrames > +{ + public: + + /** + @short standard ctor + @descr These initialize a new instance of this class with all needed information for work. + We share framecontainer with owner implementation! It's a threadsafe container. + @param xOwner , reference to our owner. We hold a wekreference to prevent us against cross-references! + @param pFrameContainer , pointer to shared framecontainer of owner. It's valid only, if weakreference is valid! + */ + OFrames( const css::uno::Reference< css::frame::XFrame >& xOwner , + FrameContainer* pFrameContainer ); + + // XFrames + + /** + @short append frame to container + @descr We share the container with our owner. We can do this only, if no lock is set on container. + Valid references are accepted only! + + @seealso class FrameContainer + + @param "xFrame", reference to an existing frame to append. + @onerror We do nothing in release or throw an assert in debug version. + */ + virtual void SAL_CALL append( const css::uno::Reference< css::frame::XFrame >& xFrame ) override; + + /** + @short remove frame from container + @descr This is the companion to append(). We only accept valid references and don't work, if + a lock is set. + + @seealso class FrameContainer + + @param "xFrame", reference to an existing frame to remove. + @onerror We do nothing in release or throw an assert in debug version. + */ + virtual void SAL_CALL remove( const css::uno::Reference< css::frame::XFrame >& xFrame ) override; + + /** + @short return list of all applicable frames for given flags + @descr Call these to get a list of all frames, which are match with given search flags. + @param "nSearchFlag", flags to search right frames. + @return A list of founded frames. + + @onerror An empty list is returned. + */ + virtual css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > SAL_CALL queryFrames( sal_Int32 nSearchFlags ) override; + + // XIndexAccess + + /** + @short get count of all current frames in container + @descr This is the beginning of full index-access. With a count you can step over all items in container. + Next call should be getByIndex(). But these mechanism works only, if no lock in container is set! + + @seealso class FrameContainer + @seealso method getByIndex() + @return Count of current items in container. + + @onerror If a lock is set, we return 0 for prevent further access! + */ + virtual sal_Int32 SAL_CALL getCount() override; + + /** + @short get specified container item by index + @descr If you called getCount() successful - this method return the specified element as an Any. + You must observe the range from 0 to count-1! Otherwise an IndexOutOfBoundsException is thrown. + + @seealso class FrameContainer + @seealso method getCount() + + @param "nIndex", valid index to get container item. + @return A container item (specified by index) wrapped in an Any. + + @onerror If a lock is set, we return an empty Any! + @onerror If index out of range, an IndexOutOfBoundsException is thrown. + */ + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) override; + + // XElementAccess + + /** + @short get uno-type of all container items + @descr In current implementation type is fixed to XFrame! + (container-lock is ignored) + @return A uno-type descriptor. + */ + virtual css::uno::Type SAL_CALL getElementType() override; + + /** + @short get fill state of current container + @descr Call these to get information about, if items exist in container or not. + (container-lock is ignored) + @return sal_True, if container contains some items. + @return sal_False, otherwise. + + @onerror We return sal_False. + */ + virtual sal_Bool SAL_CALL hasElements() override; + + private: + + /** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + This method is protected, because it's not allowed to use this class as a member! + You MUST use a dynamical instance (pointer). That's the reason for a protected dtor. + */ + virtual ~OFrames() override; + + /** + @short reset instance to default values + @descr There are two ways to delete an instance of this class.
+ 1) delete with destructor
+ 2) dispose from parent or factory ore ...
+ This method do the same for both ways! It free used memory and release references ... + + @seealso method dispose() (if it exist!) + @seealso destructor ~TaskEnumeration() + */ + void impl_resetObject(); + + /** + @short append one sequence to another + @descr There is no operation to add to sequences! Use this helper-method to do this. + + @seealso class Sequence + + @param "seqDestination", reference to sequence on which operation will append the other sequence. + @param "seqSource" , reference to sequence for append. + @return "seqDestination" is parameter AND return value at the same time. + */ + void impl_appendSequence( css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqDestination , + const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqSource ); + + static bool impldbg_checkParameter_queryFrames ( sal_Int32 nSearchFlags ); + + css::uno::WeakReference< css::frame::XFrame > m_xOwner; /// reference to owner of this instance (Hold no hard reference!) + FrameContainer* m_pFrameContainer; /// with owner shared list to hold all direct children of an XFramesSupplier + bool m_bRecursiveSearchProtection; /// flag to protect against recursive searches of frames at parents +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/persistentwindowstate.hxx b/framework/inc/helper/persistentwindowstate.hxx new file mode 100644 index 000000000..f467ef9a2 --- /dev/null +++ b/framework/inc/helper/persistentwindowstate.hxx @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX + +#include +#include +#include +#include + +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short listener for closing document frames to make her window state persistent + @descr It's a feature of our office. If a document window was created by ourself (and not from + any external process e.g. the office bean) we save and restore the window state of it + corresponding to the document service factory. That means: one instance of this class will be + a listener on one frame which container window was created by ourself. + We listen for frame action events and every time a component will deattached from a frame + we store its current position and size to the configuration. Every time a new component is + attached to a frame first time(!) we restore this information again. + + @base OWeakObject + implements ref counting for this class. + + @devstatus ready + @threadsafe yes +*//*-*************************************************************************************************************/ +class PersistentWindowState final : public ::cppu::WeakImplHelper< + css::lang::XInitialization, + css::frame::XFrameActionListener > // => XEventListener +{ + + // member + + private: + + /// may we need a uno service manager to create own services + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /// reference to the frame which was created by the office himself + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + /// we call SetWindowState one times only for the same frame! + bool m_bWindowStateAlreadySet; + + // interface + + public: + + // ctor/dtor + PersistentWindowState(const css::uno::Reference< css::uno::XComponentContext >& xContext); + virtual ~PersistentWindowState( ) override; + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + // helper + + private: + + /** @short identify the application module, which is used behind the component + of our frame. + + @param rxContext + needed to create needed uno resources. + + @param xFrame + contains the component, which must be identified. + + @return [string] + a module identifier for the current frame component. + */ + static OUString implst_identifyModule(const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& xFrame); + + /** @short retrieve the window state from the configuration. + + @param rxContext + needed to create the configuration access. + + @param sModuleName + identifies the application module, where the + information should be obtained for. + + @return [string] + contains the information about position and size. + */ + static OUString implst_getWindowStateFromConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext , + const OUString& sModuleName); + + /** @short retrieve the window state from the container window. + + @param xWindow + must point to the container window of the frame. + We use it VCL part here - because the toolkit doesn't + provide the right functionality! + + @return [string] + contains the information about position and size. + */ + static OUString implst_getWindowStateFromWindow(const css::uno::Reference< css::awt::XWindow >& xWindow); + + /** @short restore the position and size on the container window. + + @param rxContext + needed to create the configuration access. + + @param sModuleName + identifies the application module, where the + information should be set on. + + @param sWindowState + contains the information about position and size. + */ + static void implst_setWindowStateOnConfig(const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const OUString& sModuleName , + const OUString& sWindowState ); + + /** @short restore the position and size on the container window. + + @param xWindow + must point to the container window of the frame. + We use it VCL part here - because the toolkit doesn't + provide the right functionality! + + @param sWindowState + contains the information about position and size. + */ + static void implst_setWindowStateOnWindow(const css::uno::Reference< css::awt::XWindow >& xWindow , + const OUString& sWindowState); + +}; // class PersistentWindowState + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_PERSISTENTWINDOWSTATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/propertysetcontainer.hxx b/framework/inc/helper/propertysetcontainer.hxx new file mode 100644 index 000000000..f5f649730 --- /dev/null +++ b/framework/inc/helper/propertysetcontainer.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_PROPERTYSETCONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_PROPERTYSETCONTAINER_HXX + +/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble + with solaris headers ... +*/ +#include +#include +#include +#include +#include + +namespace framework +{ + +class PropertySetContainer : public css::container::XIndexContainer , + public ::cppu::OWeakObject +{ + public: + PropertySetContainer(); + virtual ~PropertySetContainer() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override; + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override + { + return cppu::UnoType::get(); + } + + virtual sal_Bool SAL_CALL hasElements() override; + + private: + typedef std::vector< css::uno::Reference< css::beans::XPropertySet > > PropertySetVector; + PropertySetVector m_aPropertySetVector; + +}; + +} + +#endif // __FRAMEWORK_CLASSES_PROPERTYSETCONTAINER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/shareablemutex.hxx b/framework/inc/helper/shareablemutex.hxx new file mode 100644 index 000000000..9470983fb --- /dev/null +++ b/framework/inc/helper/shareablemutex.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_SHAREABLEMUTEX_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_SHAREABLEMUTEX_HXX + +#include +#include +#include + +namespace framework +{ + +/** + * This acts like a rtl::Reference + */ +class ShareableMutex +{ + public: + ShareableMutex(); + ShareableMutex( const ShareableMutex& rShareableMutex ); + ShareableMutex& operator=( const ShareableMutex& rShareableMutex ); + + ~ShareableMutex() { m_pMutexRef->release(); } + + /** acquire the shared mutex */ + void acquire(); + /** release the shared mutex */ + void release(); + + private: + /* ShareableMutex::MutexRef will destroy itself when the last ShareableMutex pointing to it is destroyed */ + struct MutexRef + { + MutexRef() : m_refCount(0) {} + void acquire() + { + osl_atomic_increment( &m_refCount ); + } + + void release() + { + if ( osl_atomic_decrement( &m_refCount ) == 0 ) + delete this; + } + + oslInterlockedCount m_refCount; + osl::Mutex m_oslMutex; + }; + + MutexRef* m_pMutexRef; +}; + +class ShareGuard +{ + public: + explicit ShareGuard( ShareableMutex& rShareMutex ) : + m_rShareMutex( rShareMutex ) + { + m_rShareMutex.acquire(); + } + + ~ShareGuard() + { + m_rShareMutex.release(); + } + + private: + ShareGuard& operator=( const ShareGuard& ) = delete; + + ShareableMutex& m_rShareMutex; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_SHAREABLEMUTEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/statusindicator.hxx b/framework/inc/helper/statusindicator.hxx new file mode 100644 index 000000000..66d5b1e75 --- /dev/null +++ b/framework/inc/helper/statusindicator.hxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATOR_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATOR_HXX + +// include files of own module +#include + +// include UNO interfaces +#include + +// include all others +#include +#include + +namespace framework{ + +/** + @short implement a status indicator object + + @descr With this indicator you can show a message and a progress... + but you share the output device with other indicator objects, + if this instances was created by the same factory. + Then the last created object has full access to device. + All others change her internal data structure only. + + All objects of this StatusIndicator class calls a C++ interface + on the StatusIndicatorFactory (where they were created). + The factory holds all data structures and paints the progress. + + @devstatus ready to use + @threadsafe yes +*/ +class StatusIndicator final : public ::cppu::WeakImplHelper< css::task::XStatusIndicator > +{ + + // member + private: + + /** @short weak reference to our factory + @descr All our interface calls will be forwarded + to a suitable c++ interface on this factory. + But we don't hold our factory alive. They + correspond with e.g. with a Frame service and + will be owned by him. If the frame will be closed + he close our factory too ... + */ + css::uno::WeakReference< css::task::XStatusIndicatorFactory > m_xFactory; + + sal_Int32 m_nRange; + // We want the callback percentages to increase monotonically + int m_nLastCallbackPercent; + + // c++ interface + public: + + /** @short initialize new instance of this class. + + @param pFactory + pointer to our factory + */ + StatusIndicator(StatusIndicatorFactory* pFactory); + + /** @short does nothing real... + */ + virtual ~StatusIndicator() override; + + // uno interface + public: + + // XStatusIndicator + virtual void SAL_CALL start(const OUString& sText , + sal_Int32 nRange) override; + + virtual void SAL_CALL end() override; + + virtual void SAL_CALL reset() override; + + virtual void SAL_CALL setText(const OUString& sText) override; + + virtual void SAL_CALL setValue(sal_Int32 nValue) override; + +}; // class StatusIndicator + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/statusindicatorfactory.hxx b/framework/inc/helper/statusindicatorfactory.hxx new file mode 100644 index 000000000..c16f1eb37 --- /dev/null +++ b/framework/inc/helper/statusindicatorfactory.hxx @@ -0,0 +1,273 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATORFACTORY_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATORFACTORY_HXX + +// Attention: stl headers must(!) be included at first. Otherwise it can make trouble +// with solaris headers ... +#include + +// include files of own module +#include + +// include uno interfaces +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace framework{ + +/** + @descr This struct hold some information about all currently running progress processes. + Because the can be used on a stack, we must cache her states but must paint only + the top most one. + */ +struct IndicatorInfo +{ + + // member + public: + + /** @short points to the indicator child, where we hold its states + alive here. */ + css::uno::Reference< css::task::XStatusIndicator > m_xIndicator; + + /** @short the last set text for this indicator */ + OUString m_sText; + + /** @short the last set value for this indicator */ + sal_Int32 m_nValue; + + // interface + public: + + /** @short initialize new instance of this class + + @param xIndicator + the new child indicator of our factory. + + @param sText + its initial text. + + @param nRange + the max range for this indicator. + */ + IndicatorInfo(const css::uno::Reference< css::task::XStatusIndicator >& xIndicator, + const OUString& sText ) + { + m_xIndicator = xIndicator; + m_sText = sText; + m_nValue = 0; + } + + /** @short Used to locate an info struct inside a stl structure... + + @descr The indicator object itself is used as key. Its values + are not interesting then. Because more than one child + indicator can use the same values... + */ + bool operator==(const css::uno::Reference< css::task::XStatusIndicator >& xIndicator) const + { + return (m_xIndicator == xIndicator); + } +}; + +/** @descr Define a list of child indicator objects and its data. */ +typedef ::std::vector< IndicatorInfo > IndicatorStack; + +/** @short implement a factory service to create new status indicator objects + + @descr Internally it uses: + - a vcl based + - or a uno based and by the frame layouted + progress implementation. + + This factory create different indicators and control his access + to a shared output device! Only the last activated component + can write its state to this device. All other requests will be + cached only. + + @devstatus ready to use + @threadsafe yes + */ +class StatusIndicatorFactory final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo + , css::lang::XInitialization + , css::task::XStatusIndicatorFactory + , css::util::XUpdatable > +{ + + // member + private: + osl::Mutex m_mutex; + + /** stack with all current indicator children. */ + IndicatorStack m_aStack; + + /** uno service manager to create own needed uno resources. */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** most active indicator child, which could work with our shared indicator window only. */ + css::uno::Reference< css::task::XStatusIndicator > m_xActiveChild; + + /** used to show the progress on the frame (layouted!) or + as a plugged vcl window. */ + css::uno::Reference< css::task::XStatusIndicator > m_xProgress; + + /** points to the frame, where we show the progress (in case + m_xProgress points to a frame progress. */ + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + /** points to an outside window, where we show the progress (in case + we are plugged into such window). */ + css::uno::WeakReference< css::awt::XWindow > m_xPluggWindow; + + /** Notify us if a fix time is over. We use it to implement an + intelligent "Reschedule" ... */ + rtl::Reference m_pWakeUp; + + /** Our WakeUpThread calls us in our interface method "XUpdatable::update(). + There we set this member m_bAllowReschedule to sal_True. Next time if our impl_reschedule() + method is called, we know, that an Application::Reschedule() should be made. + Because the last made Reschedule can be was taken long time ago ... may be.*/ + bool m_bAllowReschedule; + + /** enable/disable automatic showing of our parent window. */ + bool m_bAllowParentShow; + + /** enable/disable rescheduling. Default=enabled*/ + bool m_bDisableReschedule; + + /** prevent recursive calling of Application::Reschedule(). */ + static sal_Int32 m_nInReschedule; + + // interface + + public: + StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext); + + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.comp.framework.StatusIndicatorFactory"; + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override + { + css::uno::Sequence< OUString > aSeq { "com.sun.star.task.StatusIndicatorFactory" }; + return aSeq; + } + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XStatusIndicatorFactory + virtual css::uno::Reference< css::task::XStatusIndicator > SAL_CALL createStatusIndicator() override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // similar (XStatusIndicator) + void start(const css::uno::Reference< css::task::XStatusIndicator >& xChild, + const OUString& sText , + sal_Int32 nRange); + + void reset(const css::uno::Reference< css::task::XStatusIndicator >& xChild); + + void end(const css::uno::Reference< css::task::XStatusIndicator >& xChild); + + void setText(const css::uno::Reference< css::task::XStatusIndicator >& xChild, + const OUString& sText ); + + void setValue(const css::uno::Reference< css::task::XStatusIndicator >& xChild, + sal_Int32 nValue); + + // specials + + private: + + virtual ~StatusIndicatorFactory() override; + + // helper + + /** @short show the parent window of this progress ... + if it's allowed to do so. + + @descr By default we show the parent window automatically + if this progress is used. + If that isn't a valid operation, the user of this + progress can suppress this feature by initializing + us with a special parameter. + + @seealso initialize() + */ + void implts_makeParentVisibleIfAllowed(); + + /** @short creates a new internal used progress. + @descr This factory does not paint the progress itself. + It uses helper for that. They can be vcl based or + layouted by the frame and provided as a uno interface. + */ + void impl_createProgress(); + + /** @short shows the internal used progress. + @descr This factory does not paint the progress itself. + It uses helper for that. They can be vcl based or + layouted by the frame and provided as a uno interface. + */ + void impl_showProgress(); + + /** @short hides the internal used progress. + @descr This factory does not paint the progress itself. + It uses helper for that. They can be vcl based or + layouted by the frame and provided as a uno interface. + */ + void impl_hideProgress(); + + /** @short try to "share the current thread in an intelligent manner" :-) + + @param Overwrites our algorithm for Reschedule and force it to be sure + that our progress was painted right. + */ + void impl_reschedule(bool bForceUpdate); + + void impl_startWakeUpThread(); + void impl_stopWakeUpThread(); + +}; // class StatusIndicatorFactory + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_STATUSINDICATORFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/tagwindowasmodified.hxx b/framework/inc/helper/tagwindowasmodified.hxx new file mode 100644 index 000000000..f466803a0 --- /dev/null +++ b/framework/inc/helper/tagwindowasmodified.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_TAGWINDOWASMODIFIED_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_TAGWINDOWASMODIFIED_HXX + +#include +#include +#include +#include + +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short listen for modify events on model and tag frame container window so it can react accordingly + @descr Used e.g. by our MAC port where such state is shown separately on some controls of the + title bar. + + @base OWeakObject + implements ref counting for this class. + + @devstatus draft + @threadsafe yes +*//*-*************************************************************************************************************/ +class TagWindowAsModified final : public ::cppu::WeakImplHelper< + css::lang::XInitialization, + css::frame::XFrameActionListener, // => XEventListener + css::util::XModifyListener > // => XEventListener +{ + + // member + + private: + + /// reference to the frame, where we listen for new loaded documents for updating our own xModel reference + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + /// reference to the frame container window, where we must set the tag + css::uno::WeakReference< css::awt::XWindow > m_xWindow; + + /// we list on the model for modify events + css::uno::WeakReference< css::frame::XModel > m_xModel; + + // interface + + public: + + // ctor/dtor + TagWindowAsModified(); + virtual ~TagWindowAsModified( ) override; + + // XInterface, XTypeProvider + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XModifyListener + virtual void SAL_CALL modified(const css::lang::EventObject& aEvent) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + private: + + // @todo document me + void impl_update(const css::uno::Reference< css::frame::XFrame >& xFrame); + +}; // class TagWindowAsModified + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_TAGWINDOWASMODIFIED_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/titlebarupdate.hxx b/framework/inc/helper/titlebarupdate.hxx new file mode 100644 index 000000000..c06d23976 --- /dev/null +++ b/framework/inc/helper/titlebarupdate.hxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_TITLEBARUPDATE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_TITLEBARUPDATE_HXX + +#include +#include +#include +#include +#include +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short helps our frame on setting title/icon on the titlebar (including updates) + + @devstatus draft + @threadsafe yes +*//*-*************************************************************************************************************/ +class TitleBarUpdate final : public ::cppu::WeakImplHelper< + css::lang::XInitialization + , css::frame::XTitleChangeListener // => XEventListener + , css::frame::XFrameActionListener > // => XEventListener +{ + + // structs, types + + private: + + struct TModuleInfo + { + /// internal id of this module + OUString sID; + /// configured icon for this module + ::sal_Int32 nIcon; + }; + + // member + + private: + + /// may we need a uno service manager to create own services + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /// reference to the frame which was created by the office himself + css::uno::WeakReference< css::frame::XFrame > m_xFrame; + + // interface + + public: + + // ctor/dtor + TitleBarUpdate(const css::uno::Reference< css::uno::XComponentContext >& xContext); + virtual ~TitleBarUpdate( ) override; + + // XInterface, XTypeProvider + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any >& lArguments) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override; + + // XTitleChangeListener + virtual void SAL_CALL titleChanged(const css::frame::TitleChangedEvent& aEvent) override; + + // XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + // helper + + private: + + /** @short identify the application module, which is used behind the component + of our frame. + + @param xFrame + contains the component, which must be identified. + + @param rInfo + describe the module in its details. + Is set only if return value is true. + + @return [sal_Bool] + sal_True in case module could be identified and all needed values could be read. + sal_False otherwise. + */ + bool implst_getModuleInfo(const css::uno::Reference< css::frame::XFrame >& xFrame, + TModuleInfo& rInfo ); + + /** @short set a new icon and title on the title bar of our connected frame window. + + @descr It does not check if an update is really needed. That has to be done outside. + It retrieves all needed information and update the title bar - nothing less - + nothing more. + */ + void impl_forceUpdate(); + + /** @short identify the current component (inside the connected frame) + and set the right module icon on the title bar. + + @param xFrame + the frame which contains the component and where the icon must be set + on the window title bar. + */ + void impl_updateIcon(const css::uno::Reference< css::frame::XFrame >& xFrame); + + /** @short gets the current title from the frame and set it on the window. + + @param xFrame + the frame which contains the component and where the title must be set + on the window title bar. + */ + void impl_updateTitle(const css::uno::Reference< css::frame::XFrame >& xFrame); + + //Hook to set GNOME3/Windows 7 applicationID for toplevel frames + //http://msdn.microsoft.com/en-us/library/dd378459(v=VS.85).aspx + //http://live.gnome.org/GnomeShell/ApplicationBased + void impl_updateApplicationID(const css::uno::Reference< css::frame::XFrame >& xFrame); +}; // class TitleBarUpdate + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_TITLEBARUPDATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/uiconfigelementwrapperbase.hxx b/framework/inc/helper/uiconfigelementwrapperbase.hxx new file mode 100644 index 000000000..67d971bfb --- /dev/null +++ b/framework/inc/helper/uiconfigelementwrapperbase.hxx @@ -0,0 +1,143 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_UICONFIGELEMENTWRAPPERBASE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_UICONFIGELEMENTWRAPPERBASE_HXX + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace framework +{ + +typedef ::cppu::WeakImplHelper< + css::ui::XUIElement, + css::ui::XUIElementSettings, + css::lang::XInitialization, + css::lang::XComponent, + css::util::XUpdatable, + css::ui::XUIConfigurationListener > UIConfigElementWrapperBase_BASE; + +class UIConfigElementWrapperBase : private cppu::BaseMutex, + public ::cppu::OBroadcastHelper , + public ::cppu::OPropertySetHelper , + public UIConfigElementWrapperBase_BASE +{ + + // public methods + + public: + UIConfigElementWrapperBase( sal_Int16 nType ); + virtual ~UIConfigElementWrapperBase() override; + + // XInterface + virtual void SAL_CALL acquire() throw () override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () override + { OWeakObject::release(); } + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XComponent + virtual void SAL_CALL dispose() override = 0; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUIElementSettings + virtual void SAL_CALL updateSettings() override = 0; + virtual css::uno::Reference< css::container::XIndexAccess > SAL_CALL getSettings( sal_Bool bWriteable ) override; + virtual void SAL_CALL setSettings( const css::uno::Reference< css::container::XIndexAccess >& UISettings ) override; + + // XUIElement + virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override; + virtual OUString SAL_CALL getResourceURL() override; + virtual ::sal_Int16 SAL_CALL getType() override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override = 0; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XUIConfigurationListener + virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override; + + // XEventListener + using cppu::OPropertySetHelper::disposing; + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + // protected methods + + protected: + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , + css::uno::Any& aOldValue , + sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue , + sal_Int32 nHandle ) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + virtual void impl_fillNewData(); + + static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + sal_Int16 m_nType; + bool m_bPersistent : 1, + m_bInitialized : 1, + m_bConfigListener : 1, + m_bConfigListening : 1, + m_bDisposed : 1, + m_bNoClose : 1; + OUString m_aResourceURL; + css::uno::Reference< css::ui::XUIConfigurationManager > m_xConfigSource; + css::uno::Reference< css::container::XIndexAccess > m_xConfigData; + css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame; + css::uno::Reference< css::awt::XMenuBar > m_xMenuBar; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_UICONFIGELEMENTWRAPPERBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/uielementwrapperbase.hxx b/framework/inc/helper/uielementwrapperbase.hxx new file mode 100644 index 000000000..11c30680f --- /dev/null +++ b/framework/inc/helper/uielementwrapperbase.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_UIELEMENTWRAPPERBASE_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_UIELEMENTWRAPPERBASE_HXX + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace framework +{ + +typedef ::cppu::WeakImplHelper< + css::ui::XUIElement, + css::lang::XInitialization, + css::lang::XComponent, + css::util::XUpdatable > UIElementWrapperBase_BASE; + +class UIElementWrapperBase : private cppu::BaseMutex, + public ::cppu::OBroadcastHelper , + public ::cppu::OPropertySetHelper , + public UIElementWrapperBase_BASE +{ + + // public methods + + public: + UIElementWrapperBase( sal_Int16 nType ); + virtual ~UIElementWrapperBase() override; + + // XInterface + virtual void SAL_CALL acquire() throw () override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () override + { OWeakObject::release(); } + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XComponent + virtual void SAL_CALL dispose() override = 0; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XUIElement + virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getFrame() override; + virtual OUString SAL_CALL getResourceURL() override; + virtual ::sal_Int16 SAL_CALL getType() override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override = 0; + + // protected methods + + protected: + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , + css::uno::Any& aOldValue , + sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue , + sal_Int32 nHandle ) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener + OUString m_aResourceURL; + css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame; + sal_Int16 m_nType; + bool m_bInitialized : 1, + m_bDisposed; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_UIELEMENTWRAPPERBASE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/vclstatusindicator.hxx b/framework/inc/helper/vclstatusindicator.hxx new file mode 100644 index 000000000..ba0a84a0e --- /dev/null +++ b/framework/inc/helper/vclstatusindicator.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX + +#include +#include + +#include +#include + +namespace framework { + +// declaration + +class VCLStatusIndicator final : public ::cppu::WeakImplHelper< css::task::XStatusIndicator > +{ + + // member + + private: + + /** points to the parent window of this progress and + hold it alive. */ + css::uno::Reference< css::awt::XWindow > m_xParentWindow; + + /** shows the progress. + + @attention This member is not synchronized using our own mutex! + It's guarded by the solarmutex only. Otherwise + we have to lock two of them, which can force a deadlock... + */ + VclPtr m_pStatusBar; + + /** knows the current range of the progress. */ + sal_Int32 m_nRange; + + /** knows the current value of the progress. */ + sal_Int32 m_nValue; + + // interface + + public: + + /// ctor + VCLStatusIndicator(const css::uno::Reference< css::awt::XWindow >& xParentWindow); + + /// dtor + virtual ~VCLStatusIndicator() override; + + /// XStatusIndicator + virtual void SAL_CALL start(const OUString& sText , + sal_Int32 nRange) override; + + virtual void SAL_CALL reset() override; + + virtual void SAL_CALL end() override; + + virtual void SAL_CALL setText(const OUString& sText) override; + + virtual void SAL_CALL setValue(sal_Int32 nValue) override; + + // helper + + private: + + static void impl_recalcLayout(vcl::Window* pStatusBar , + vcl::Window const * pParentWindow); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_HELPER_VCLSTATUSINDICATOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/helper/wakeupthread.hxx b/framework/inc/helper/wakeupthread.hxx new file mode 100644 index 000000000..51cf859f0 --- /dev/null +++ b/framework/inc/helper/wakeupthread.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX +#define INCLUDED_FRAMEWORK_INC_HELPER_WAKEUPTHREAD_HXX + +#include + +#include +#include +#include +#include +#include + +namespace com::sun::star::util { + class XUpdatable; +} + +namespace framework{ + +class WakeUpThread final : public salhelper::Thread { + css::uno::WeakReference updatable_; + osl::Condition condition_; + + osl::Mutex mutex_; + bool terminate_; + + void execute() override; + +public: + WakeUpThread(css::uno::Reference const & updatable); + + void stop(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/interaction/quietinteraction.hxx b/framework/inc/interaction/quietinteraction.hxx new file mode 100644 index 000000000..008eab055 --- /dev/null +++ b/framework/inc/interaction/quietinteraction.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_INTERACTION_QUIETINTERACTION_HXX +#define INCLUDED_FRAMEWORK_INC_INTERACTION_QUIETINTERACTION_HXX + +#include +#include + +#include + +namespace framework{ + +/** + @short handle interactions non visible + @descr Sometimes it's necessary to use a non visible interaction handler. + He can't do anything, which a visible one can handle. + But it can be used to intercept problems e.g. during loading of documents. + + In current implementation we solve conflicts for following situations only: + - InteractiveIOException + - InteractiveAugmentedIOException + All other requests will be aborted. + */ +class QuietInteraction final : public ::cppu::WeakImplHelper< + css::task::XInteractionHandler > +{ + // member + private: + + /// in case an unknown interaction was aborted - we save it for our external user! + css::uno::Any m_aRequest; + + // uno interface + public: + + // XInterface, XTypeProvider + + /** + @interface XInteractionHandler + @short called from outside to handle a problem + @descr The only interaction we can handle here is to + decide which of two ambiguous filters should be really used. + We use the user selected one every time. + All other request will be aborted and can break the code, + which use this interaction handler. + + But you can use another method of this class to check for + some special interactions too: IO Exceptions + May a ComponentLoader needs that to throw suitable exception + on his own interface. + + @threadsafe yes + */ + virtual void SAL_CALL handle( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) override; + + // c++ interface + public: + /** + @short ctor to guarantee right initialized instances of this class + @threadsafe not necessary + */ + QuietInteraction(); + + /** + @short return the handled interaction request + @descr We saved any obtained interaction request internally. + Maybe the outside user of this class is interested + on that. Especially we got an unknown interaction + and aborted it hard. + + @return [com.sun.star.uno.Any] + the packed interaction request + Can be empty if no interaction was used! + + @threadsafe yes + */ + css::uno::Any getRequest() const; + + /** + @short returns information if interaction was used + @descr It can be useful to know the reason for a failed operation. + + @return [boolean] + for used interaction + otherwise + + @threadsafe yes + */ + bool wasUsed() const; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_INTERACTION_QUIETINTERACTION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/configaccess.hxx b/framework/inc/jobs/configaccess.hxx new file mode 100644 index 000000000..1bb8e0110 --- /dev/null +++ b/framework/inc/jobs/configaccess.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_CONFIGACCESS_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_CONFIGACCESS_HXX + +#include +#include + +#include +#include + +namespace framework{ + +/** + @short implements a simple configuration access + @descr Sometimes it's better to have direct config access + instead of using specialized config items of the svtools + project. This class can wrap such configuration access. + */ +class UNLESS_MERGELIBS(FWI_DLLPUBLIC) ConfigAccess final +{ + + public: + + /** represent the possible modes of the internal wrapped configuration access */ + enum EOpenMode + { + /// config isn't used yet + E_CLOSED, + /// config access is open for reading only + E_READONLY, + /// config access is open for reading/writing data + E_READWRITE + }; + + // member + + private: + mutable osl::Mutex m_mutex; + + /** + reference to the uno service manager + It's necessary to instantiate own needed services. + */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** hold an opened configuration alive */ + css::uno::Reference< css::uno::XInterface > m_xConfig; + + /** knows the root of the opened config access point */ + OUString m_sRoot; + + /** represent the current open mode */ + EOpenMode m_eMode; + + // native interface methods + + public: + + ConfigAccess( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const OUString& sRoot ); + ~ConfigAccess(); + + void open ( EOpenMode eMode ); + void close ( ); + EOpenMode getMode( ) const; + + const css::uno::Reference< css::uno::XInterface >& cfg(); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_CONFIGACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/helponstartup.hxx b/framework/inc/jobs/helponstartup.hxx new file mode 100644 index 000000000..723526f92 --- /dev/null +++ b/framework/inc/jobs/helponstartup.hxx @@ -0,0 +1,189 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX + +#include + +#include + +#include +#include +#include +#include +#include + +namespace framework{ + +/** @short implements a job component, which handle the special + feature to show a suitable help page for every (visible!) + loaded document. + */ +class HelpOnStartup final : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,css::lang::XEventListener,css::task::XJob > +{ + + // member + private: + osl::Mutex m_mutex; + + /** @short reference to a uno service manager. */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** @short such module manager is used to classify new opened documents. */ + css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager; + + /** @short is needed to locate a might open help frame. */ + css::uno::Reference< css::frame::XDesktop2 > m_xDesktop; + + /** @short provides read access to the underlying configuration. */ + css::uno::Reference< css::container::XNameAccess > m_xConfig; + + /** @short knows the current locale of this office session, + which is needed to build complete help URLs. + */ + OUString m_sLocale; + + /** @short knows the current operating system of this office session, + which is needed to build complete help URLs. + */ + OUString m_sSystem; + + // native interface + public: + + /** @short create new instance of this class. + + @param xContext + reference to the uno service manager, which created this instance. + Can be used later to create own needed uno resources on demand. + */ + HelpOnStartup(const css::uno::Reference< css::uno::XComponentContext >& xContext); + + /** @short does nothing real ... + + @descr But it should exists as virtual function, + so this class can't make trouble + related to inline/symbols etcpp.! + */ + virtual ~HelpOnStartup() override; + + // uno interface + public: + + // css.lang.XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // css.task.XJob + virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments) override; + + // css.lang.XEventListener + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override; + + // helper + private: + + /** @short analyze the given job arguments, try to locate a model reference + and try to classify this model. + + @descr As a result of this operation a module identifier will be returned. + It can be used against the module configuration then to retrieve further information. + + @param lArguments + the list of job arguments which is given on our interface method execute(). + + @return [string] + a module identifier ... or an empty value if no model could be located ... + or if it could not be classified successfully. + */ + OUString its_getModuleIdFromEnv(const css::uno::Sequence< css::beans::NamedValue >& lArguments); + + /** @short tries to locate the open help module and return + the url of the currently shown help content. + + @descr It returns an empty string, if the help isn't still + open at calling time. + + @return The URL of the current shown help content; + or an empty value if the help isn't still open. + */ + OUString its_getCurrentHelpURL(); + + /** @short checks if the given help url match to a default help url + of any office module. + + @param sHelpURL + the help url for checking. + + @return [bool] + sal_True if the given URL is any default one ... + sal_False otherwise. + */ + bool its_isHelpUrlADefaultOne(const OUString& sHelpURL); + + /** @short checks, if the help module should be shown automatically for the + currently opened office module. + + @descr This value is read from the module configuration. + In case the help should be shown, this method returns + a help URL, which can be used to show the right help content. + + @param sModule + identifies the used office module. + + @return [string] + A valid help URL in case the help content should be shown; + an empty value if such automatism was disabled for the specified office module. + */ + OUString its_checkIfHelpEnabledAndGetURL(const OUString& sModule); + + /** @short create a help URL for the given parameters. + + @param sBaseURL + must be the base URL for a requested help content + e.g. "vnd.sun.star.help://swriter/" + or "vnd.sun.star.help://swriter/67351" + + @param sLocale + the current office locale + e.g. "en-US" + + @param sSystem + the current operating system + e.g. "WIN" + + @return The URL which was generated. + e.g. + e.g. "vnd.sun.star.help://swriter/?Language=en-US&System=WIN" + or "vnd.sun.star.help://swriter/67351?Language=en-US&System=WIN" + */ + static OUString ist_createHelpURL(const OUString& sBaseURL, + const OUString& sLocale , + const OUString& sSystem ); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_HELPONSTARTUP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/job.hxx b/framework/inc/jobs/job.hxx new file mode 100644 index 000000000..a4e2e472c --- /dev/null +++ b/framework/inc/jobs/job.hxx @@ -0,0 +1,205 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOB_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_JOB_HXX + +#include + +#include +#include +#include +#include +#include + +#include +#include + +namespace framework{ + +/** + @short it represent a job; execute it and control its lifetime + + @descr This implementation can be used to wrap jobs, execute it + synchronously or asynchronous, control its lifetime + and differe between jobs with and without configuration. + */ +class Job final : public ::cppu::WeakImplHelper< + css::task::XJobListener + , css::frame::XTerminateListener + , css::util::XCloseListener > +{ + + // structs + + private: + + /** different possible states for the internal wrapped job. + It can be started, stopped by a queryClosing() request or + disposed() by a notifyClosing() request ... + */ + enum ERunState + { + E_NEW, + E_RUNNING, + E_STOPPED_OR_FINISHED, + E_DISPOSED + }; + + // member + + private: + + /** + hold all necessary information about this job. + It can be used for both modes: with and without configuration. + */ + JobData m_aJobCfg; + + /** + We need it to create own services on demand. + */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** + Hold the (may asynchronous) job alive. + */ + css::uno::Reference< css::uno::XInterface > m_xJob; + + /** + Used to wait for finishing of asynchronous started jobs. + */ + ::osl::Condition m_aAsyncWait; + + /** + For some special cases we must know the environment, in which + this job runs. Means the frame inside which we may was triggered. + We use it too, to listen for closing events of this resource. + + Please note: If m_xFrame is set - m_xModel should be NULL. + Only one environment can be supported really. + */ + css::uno::Reference< css::frame::XFrame > m_xFrame; + + /** + For some special cases we must know the environment, in which + this job runs. Means the document inside which we may was triggered. + We use it too, to listen for closing events of this resource. + + Please note: If m_xModel is set - m_xFrame should be NULL. + Only one environment can be supported really. + */ + css::uno::Reference< css::frame::XModel > m_xModel; + + /** + We are registered at this instance to listen for office shutdown events. + It's necessary suppress it (if possible) or to react in the right way. + */ + css::uno::Reference< css::frame::XDesktop2 > m_xDesktop; + + /** + A job can return a dispatch result event after finishing its work. + We have to transport it to any outside interested listener then. + (see m_xResultSourceFake for further information too!) + */ + css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener; + + /** + We can't set ourself as source of a dispatch result event ... nor our job. + Because the listener (set as m_xResultListener) expect the original instance, + where it was registered. This original instance is the user of this class. + It must be set explicitly and will be used to fake the source of the event! + */ + css::uno::Reference< css::uno::XInterface > m_xResultSourceFake; + + /** + Holds the state, if we are listen for desktop/frame or model closing events or not. + The used references are not really enough to detect a valid listener connection. + That's why we use this additional information here too. + */ + bool m_bListenOnDesktop; + bool m_bListenOnFrame; + bool m_bListenOnModel; + + /** + In case we got a close request from our desktop/frame/model (on which we listen) ... and + the ownership was delivered there ... we have to close ourself and this object + in case the internal wrapped and running job finish his work. + */ + bool m_bPendingCloseFrame; + bool m_bPendingCloseModel; + + /** + indicates in which state the internal job currently exist. + + We can use this information to throw any suitable veto exception + to prevent the environment against dying or suppress superfluous dispose() + calls at the job. + */ + ERunState m_eRunState; + + // native interface + + public: + + Job( const css::uno::Reference< css::uno::XComponentContext >& xContext , + const css::uno::Reference< css::frame::XFrame >& xFrame ); + Job( const css::uno::Reference< css::uno::XComponentContext >& xContext , + const css::uno::Reference< css::frame::XModel >& xModel ); + virtual ~Job( ) override; + + void setDispatchResultFake( const css::uno::Reference< css::frame::XDispatchResultListener >& xListener , + const css::uno::Reference< css::uno::XInterface >& xSourceFake ); + void setJobData ( const JobData& aData ); + void execute ( const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs ); + void die ( ); + + private: + + css::uno::Sequence< css::beans::NamedValue > impl_generateJobArgs ( const css::uno::Sequence< css::beans::NamedValue >& lDynamicArgs ); + void impl_reactForJobResult( const css::uno::Any& aResult ); + void impl_startListening ( ); + void impl_stopListening ( ); + + // uno interface + + public: + + // XJobListener + virtual void SAL_CALL jobFinished( const css::uno::Reference< css::task::XAsyncJob >& xJob, + const css::uno::Any& aResult ) override; + + // XTerminateListener + virtual void SAL_CALL queryTermination ( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL notifyTermination( const css::lang::EventObject& aEvent ) override; + + // XCloseListener + virtual void SAL_CALL queryClosing ( const css::lang::EventObject& aEvent , + sal_Bool bGetsOwnership ) override; + virtual void SAL_CALL notifyClosing( const css::lang::EventObject& aEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOB_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/jobconst.hxx b/framework/inc/jobs/jobconst.hxx new file mode 100644 index 000000000..80e78f4d9 --- /dev/null +++ b/framework/inc/jobs/jobconst.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOBCONST_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_JOBCONST_HXX + +#include +#include + +namespace framework{ + +/** + @short defines all constant values used within a job environment. + + @descr The protocol between job executor/dispatch and jobs is fix and well defined. + But why every implemented job should write such constant values directly into + it's code. Typos can occur or code will be changed by new developers ... + Shared set of constant values can help to improve the maintenance of this code. + */ +class FWI_DLLPUBLIC JobConst +{ + public: + static const OUString ANSWER_DEACTIVATE_JOB; + static const OUString ANSWER_SAVE_ARGUMENTS; + static const OUString ANSWER_SEND_DISPATCHRESULT; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBCONST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/jobdata.hxx b/framework/inc/jobs/jobdata.hxx new file mode 100644 index 000000000..5d64bcb8c --- /dev/null +++ b/framework/inc/jobs/jobdata.hxx @@ -0,0 +1,210 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX + +#include +#include + +#include + +#include + +namespace framework{ + +/** + @short holds all necessary information about a job and + handle it's configuration (if any exist!) + @descr It can be used from different use cases as a container + (or proxy) for all config data of a registered job. + But it doesn't implement any execute functionality! + */ +class JobData final +{ + public: + + /** These values can be used to differe between jobs with and jobs without + a configuration. Of course an "unknown state" should be available too, + to detect a missing initialization. + */ + enum EMode + { + /// indicates a missing initialization + E_UNKNOWN_MODE, + /// indicates a job with configuration (They alias represent the config key name.) + E_ALIAS, + /// indicates a job without configuration (The pure UNO implementation is used only.) + E_SERVICE, + /// indicates a job with configuration, which was triggered by an event + E_EVENT + }; + + /** These values represent the environment type, in which a job can run. + A job must known, from which binding it will be started. Because + it's initialization data depends from that! + */ + enum EEnvironment + { + /// indicates a missing initialization + E_UNKNOWN_ENVIRONMENT, + /// this job is used by the global JobExecutor service + E_EXECUTION, + /// this job is used by the global dispatch framework + E_DISPATCH, + /// this job is used by the global event broadcaster + E_DOCUMENTEVENT + }; + + /** Some jobs can be registered to "logical events", which are generated on demand if another document event + occurs. E.g. "onDocumentOpened" in case "OnNew" or "OnLoad" was notified to the JobExecutor instance. + And normally the original event is transported as parameter set to the executed job. But then such job + can't differ between e.g. "OnNew" and "onDocumentOpened". + That's why we must know, for which type of event the job was really triggered .-) + + The information "sDocEvent" from this struct must be set on the member JobData::m_sEvent from outside + user of such Jobdata structure. + */ + struct TJob2DocEventBinding + { + OUString m_sJobName; + OUString m_sDocEvent; + + TJob2DocEventBinding(const OUString& sJobName , + const OUString& sDocEvent) + : m_sJobName (sJobName ) + , m_sDocEvent(sDocEvent) + {} + }; + + // member + + private: + + /** + reference to the uno service manager. + We need it for creating of own uno services ... e.g. for + opening the configuration. + */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + /** + An instance of this class can be used in two different modes: + - as a configured job + - as a job without any configuration + First mode is triggered by an alias, which points to the + configuration entries. Second mode is specified by a uno service + or implementation name. Then we do the same things (use the same interfaces) + but don't handle any configuration data. + The effect: This mode can be detected by this member. + */ + EMode m_eMode; + + /** + Because jobs can be bind to different mechanism inside office, a job + should know inside which environment it runs. E.g. a job can be executed + by the global JobExecutor service (triggered by an event) or e.g. as part + of the global dispatch framework (triggered by an UI control e.g. a menu entry). + */ + EEnvironment m_eEnvironment; + + /** + the alias name of this job. + Is used as entry of configuration set for job registration, to find all + necessary properties of it... + */ + OUString m_sAlias; + + /** + the uno implementation name of this job. + It's read from the configuration. Don't set it from outside! + */ + OUString m_sService; + + /** + the module context list of this job. + It's read from the configuration. Don't set it from outside! + */ + OUString m_sContext; + + /** + a job can be registered for an event. + It can be an empty value! But it will be set from outside any times. + Because it's not clear which job this instance should represent if an event + (instead of an alias) comes in. Because there can be multiple registrations + for this event. We use this information only, to merge it with the job specific + arguments. A job can be called so, with a) its own config data and b) some dynamic + environment data. + */ + OUString m_sEvent; + + /** + job specific configuration items... unknown for us! + It's read from the configuration. Don't set it from outside! + */ + std::vector< css::beans::NamedValue > m_lArguments; + + // native interface + + public: + + JobData( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + JobData( const JobData& rCopy ); + ~JobData( ); + + JobData& operator=( const JobData& rCopy ); + + EMode getMode () const; + EEnvironment getEnvironment () const; + OUString getEnvironmentDescriptor() const; + OUString getService () const; + OUString getEvent () const; + css::uno::Sequence< css::beans::NamedValue > getConfig () const; + std::vector< css::beans::NamedValue > getJobConfig () const; + + bool hasConfig () const; + bool hasCorrectContext ( const OUString& rModuleIdent ) const; + + void setEnvironment ( EEnvironment eEnvironment ); + void setAlias ( const OUString& sAlias ); + void setService ( const OUString& sService ); + void setEvent ( const OUString& sEvent , + const OUString& sAlias ); + void setJobConfig ( const std::vector< css::beans::NamedValue >& lArguments ); + void disableJob ( ); + + static std::vector< OUString > getEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const OUString& sEvent ); + + static void appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const OUString& sEvent , + ::std::vector< JobData::TJob2DocEventBinding >& lJobs ); + + // private helper + + private: + + void impl_reset(); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/jobresult.hxx b/framework/inc/jobs/jobresult.hxx new file mode 100644 index 000000000..2178a541a --- /dev/null +++ b/framework/inc/jobs/jobresult.hxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOBRESULT_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_JOBRESULT_HXX + +#include +#include + +#include + +namespace framework{ + +/** + @short represent a result of a finished job execution + @descr Such result instance transport all necessary + data from the code place where the job was finished + to the outside code, where e.g. listener must be notified. + */ +class JobResult final +{ + + // types + + public: + + /** + These enum values are used to build a flag mask of possible set + parts of an analyzed pure job execution result. + An user of this class can decide, if a member of us can be valid + or not. So it can indicate, if a job used the special part inside + its returned result protocol. + To be usable as flags - it must be values of set {0,1,2,4,8,16 ...}! + */ + enum EParts + { + E_NOPART = 0, + E_ARGUMENTS = 1, + E_DEACTIVATE = 2, + E_DISPATCHRESULT = 4 + }; + + // member + + private: + + /** + an user of us must know, which (possible) parts of + a "pure result" was really set by an executed job. + Means which other members of this class are valid. + This mask can be used to find it out. + */ + sal_uInt32 m_eParts; + + /** + a job can have persistent data + They are part of the pure result and will be used to + write it to the configuration. But that's part of any + user of us. We provide this information here only. + */ + std::vector< css::beans::NamedValue > m_lArguments; + + /** + represent the part "DispatchResult" + It's a fulfilled event type, which was given + back by the executed job. Any user of us can send + it to its registered result listener directly. + */ + css::frame::DispatchResultEvent m_aDispatchResult; + + // native interface + + public: + + JobResult( const css::uno::Any& aResult ); + JobResult( const JobResult& rCopy ); + ~JobResult( ); + + JobResult& operator=( const JobResult& rCopy ); + + bool existPart ( sal_uInt32 eParts ) const; + std::vector< css::beans::NamedValue > getArguments ( ) const; + css::frame::DispatchResultEvent getDispatchResult( ) const; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBRESULT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/joburl.hxx b/framework/inc/jobs/joburl.hxx new file mode 100644 index 000000000..32c2fc809 --- /dev/null +++ b/framework/inc/jobs/joburl.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX + +#include + +namespace framework{ + +#define JOBURL_EVENT_STR "event=" +#define JOBURL_EVENT_LEN 6 + +#define JOBURL_ALIAS_STR "alias=" +#define JOBURL_ALIAS_LEN 6 + +#define JOBURL_SERVICE_STR "service=" +#define JOBURL_SERVICE_LEN 8 + +#define JOBURL_PART_SEPARATOR ';' +#define JOBURL_PARTARGS_SEPARATOR ',' + +/** + @short can be used to parse, validate and work with job URL's + @descr Job URLs are specified by the following syntax: + vnd.sun.star.job:{[event=]|[alias=]|[service=]} + This class can analyze this structure and separate it into his different parts. + After doing that these parts are accessible by the methods of this class. + */ +class JobURL +{ + + // types + + private: + + /** + possible states of a job URL + Note: These values are used in combination. So they must be + values in form 2^n. + */ + enum ERequest + { + /// mark a job URL as not valid + E_UNKNOWN = 0, + /// it's an event + E_EVENT = 1, + /// it's an alias + E_ALIAS = 2, + /// it's a service + E_SERVICE = 4 + }; + + // types + + private: + + /** knows the state of this URL instance */ + sal_uInt32 m_eRequest; + + /** holds the event part of a job URL */ + OUString m_sEvent; + + /** holds the alias part of a job URL */ + OUString m_sAlias; + + /** holds the service part of a job URL */ + OUString m_sService; + + // native interface + + public: + + JobURL ( const OUString& sURL ); + bool isValid ( ) const; + bool getEvent ( OUString& sEvent ) const; + bool getAlias ( OUString& sAlias ) const; + bool getService ( OUString& sService ) const; + + // private helper + + private: + + static bool implst_split( const OUString& sPart , + const char* pPartIdentifier , + sal_Int32 nPartLength , + OUString& rPartValue , + OUString& rPartArguments ); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_JOBURL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/jobs/shelljob.hxx b/framework/inc/jobs/shelljob.hxx new file mode 100644 index 000000000..387e3d142 --- /dev/null +++ b/framework/inc/jobs/shelljob.hxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX +#define INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX + +#include + +#include + +#include + +namespace framework{ + +/** @short implements a job component which can be used + to execute system shell commands. + + @descr Because the job will be implemented generic + it can be bound to any event where jobs can be + registered for. Further there is a generic + way to configure the shell command and it's list + of arguments. + */ +class ShellJob final : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,css::task::XJob > +{ + + // member + private: + + /** @short reference to a uno service manager. */ + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + // native interface + public: + + /** @short create new instance of this class. + + @param xContext + reference to the uno service manager, which created this instance. + Can be used later to create own needed uno resources on demand. + */ + ShellJob(const css::uno::Reference< css::uno::XComponentContext >& xContext); + + /** @short does nothing real ... + + @descr But it should exists as virtual function, + so this class can't make trouble + related to inline/symbols etcpp.! + */ + virtual ~ShellJob() override; + + // uno interface + public: + + // css.lang.XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // css.task.XJob + virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments) override; + + // helper + private: + + /** generate a return value for method execute() + which will force deactivation of this job for further requests. + + @return an Any following the job protocol for deactivation. + */ + static css::uno::Any impl_generateAnswer4Deactivation(); + + /** substitute all might existing placeholder variables + within the configured command. + + The command is part of the job configuration. + These will make changes more easy (no code changes required). + Further the command can use placeholder as they are supported + by the global substitution service (e.g. $(prog) etcpp) + + @param sCommand + the command containing placeholder variables. + + @return the substituted command. + */ + OUString impl_substituteCommandVariables(const OUString& sCommand); + + /** executes the command. + + @param sCommand + the absolute command as URL or system path (without any argument !). + + @param lArguments + the complete list of arguments configured for these job. + + @param bCheckExitCode + bind the execution result to the exit code of the started process. + If it's set to false we return false only in case executable couldn't be found + or couldn't be started. + + @return sal_True if command was executed successfully; sal_False otherwise. + */ + bool impl_execute(const OUString& sCommand , + const css::uno::Sequence< OUString >& lArguments , + bool bCheckExitCode); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/macros/registration.hxx b/framework/inc/macros/registration.hxx new file mode 100644 index 000000000..878bc89c4 --- /dev/null +++ b/framework/inc/macros/registration.hxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_MACROS_REGISTRATION_HXX +#define INCLUDED_FRAMEWORK_INC_MACROS_REGISTRATION_HXX + +#include + +//namespace framework{ + +/*_________________________________________________________________________________________________________________ + + macros for registration of services + Please use follow public macros only! + + IFFACTORY( CLASS ) => use it as parameter for COMPONENT_GETFACTORY( IFFACTORIES ) + COMPONENTGETFACTORY( LIB, IFFACTORIES ) => use it to define exported function LIB_component_getFactory() + +_________________________________________________________________________________________________________________*/ + +// public +// use it as parameter for COMPONENT_GETFACTORY( IFFACTORIES ) + +#define IFFACTORY( CLASS ) \ + /* If searched name found ... */ \ + /* You can't add some statements before follow line ... Here can be an ELSE-statement! */ \ + if ( CLASS::impl_getStaticImplementationName().equalsAscii( pImplementationName ) ) \ + { \ + /* ... then create right factory for this service. */ \ + /* xFactory and xServiceManager are local variables of method which use this macro. */ \ + xFactory = CLASS::impl_createFactory( xServiceManager ); \ + } + +// public +// define method to instantiate new services + +#define COMPONENTGETFACTORY( LIB, IFFACTORIES ) \ + extern "C" SAL_DLLPUBLIC_EXPORT void* LIB##_component_getFactory( const char* pImplementationName, \ + void* pServiceManager , \ + void* /*pRegistryKey*/ ) \ + { \ + /* Set default return value for this operation - if it failed. */ \ + void* pReturn = nullptr; \ + if ( \ + ( pImplementationName != nullptr ) && \ + ( pServiceManager != nullptr ) \ + ) \ + { \ + /* Define variables which are used in following macros. */ \ + css::uno::Reference< css::uno::XInterface > xFactory; \ + css::uno::Reference< css::lang::XMultiServiceFactory > xServiceManager = static_cast< css::lang::XMultiServiceFactory* >( pServiceManager ); \ + /* These parameter will expand to */ \ + /* "IF_NAME_CREATECOMPONENTFACTORY(a) */ \ + /* else */ \ + /* ... */ \ + /* else */ \ + /* IF_NAME_CREATECOMPONENTFACTORY(z)" */ \ + IFFACTORIES \ + /* Factory is valid, if service was found. */ \ + if ( xFactory.is() ) \ + { \ + xFactory->acquire(); \ + pReturn = xFactory.get(); \ + } \ + } \ + /* Return with result of this operation. */ \ + return pReturn; \ + } + +//} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_MACROS_REGISTRATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/macros/xinterface.hxx b/framework/inc/macros/xinterface.hxx new file mode 100644 index 000000000..da070f23a --- /dev/null +++ b/framework/inc/macros/xinterface.hxx @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_MACROS_XINTERFACE_HXX +#define INCLUDED_FRAMEWORK_INC_MACROS_XINTERFACE_HXX + +#include +#include +#include + +namespace framework{ + +/*_________________________________________________________________________________________________________________ + + macros for declaration and definition of XInterface + Please use follow public macros only! + + 1) DEFINE_XINTERFACE => use it in header to declare XInterface and his methods + 2) DIRECT_INTERFACE( INTERFACE ) => use it as parameter INTERFACEx at 4) if interface not ambiguous + 3) DERIVED_INTERFACE( BASEINTERFACE, DERIVEDINTERFACE ) => use it as parameter INTERFACEx at 4) if interface can be ambiguous + 4) DECLARE_XINTERFACE_0( CLASS, BASECLASS ) => use it to define implementation of XInterface for 0 additional interface to baseclass + DECLARE_XINTERFACE_1( CLASS, BASECLASS, INTERFACE1 ) => use it to define implementation of XInterface for 1 additional interface to baseclass + ... + DECLARE_XINTERFACE_16( CLASS, BASECLASS, INTERFACE1, ... , INTERFACE16 ) + +_________________________________________________________________________________________________________________*/ + +// private +// implementation of XInterface::acquire() +// XInterface::release() + +#define PRIVATE_DEFINE_XINTERFACE_ACQUIRE_RELEASE( CLASS, BASECLASS ) \ + void SAL_CALL CLASS::acquire() throw() \ + { \ + /* Don't use mutex in methods of XInterface! */ \ + BASECLASS::acquire(); \ + } \ + \ + void SAL_CALL CLASS::release() throw() \ + { \ + /* Don't use mutex in methods of XInterface! */ \ + BASECLASS::release(); \ + } + +// private +// complete implementation of XInterface with max. 12 other interfaces! + +#define PRIVATE_DEFINE_XINTERFACE( CLASS, BASECLASS, INTERFACES ) \ + PRIVATE_DEFINE_XINTERFACE_ACQUIRE_RELEASE( CLASS, BASECLASS ) \ + css::uno::Any SAL_CALL CLASS::queryInterface( const css::uno::Type& aType ) \ + { \ + /* Attention: Don't use mutex or guard in this method!!! Is a method of XInterface. */ \ + /* Ask for my own supported interfaces ... */ \ + css::uno::Any aReturn ( ::cppu::queryInterface INTERFACES \ + ); \ + /* If searched interface not supported by this class ... */ \ + if ( !aReturn.hasValue() ) \ + { \ + /* ... ask baseclass for interfaces! */ \ + aReturn = BASECLASS::queryInterface( aType ); \ + } \ + /* Return result of this search. */ \ + return aReturn; \ + } + +// private +// help macros to replace INTERFACES in queryInterface() [see before] + +#define PRIVATE_DEFINE_INTERFACE_11( INTERFACE1, INTERFACE2, INTERFACE3, INTERFACE4, INTERFACE5, INTERFACE6, INTERFACE7, INTERFACE8, INTERFACE9, INTERFACE10, INTERFACE11 ) \ + INTERFACE1, \ + INTERFACE2, \ + INTERFACE3, \ + INTERFACE4, \ + INTERFACE5, \ + INTERFACE6, \ + INTERFACE7, \ + INTERFACE8, \ + INTERFACE9, \ + INTERFACE10, \ + INTERFACE11 + +// public +// help macros for follow XInterface definitions + +// Use it as parameter for DEFINE_XINTERFACE_X(), if you CAN use an interface directly in queryInterface()! +#define DIRECT_INTERFACE( INTERFACE ) \ + static_cast< INTERFACE* >( this ) + +// Use it as parameter for DEFINE_XINTERFACE_X(), if you CAN'T use an interface directly in queryInterface()! +// (zB at ambiguous errors!) +#define DERIVED_INTERFACE( BASEINTERFACE, DERIVEDINTERFACE ) \ + static_cast< BASEINTERFACE* >( static_cast< DERIVEDINTERFACE* >( this ) ) + +// public +// declaration of XInterface + +#define FWK_DECLARE_XINTERFACE \ + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; \ + virtual void SAL_CALL acquire ( ) throw() override; \ + virtual void SAL_CALL release ( ) throw() override; + +// public +// implementation of XInterface + + +// implementation of XInterface with 11 additional interfaces for queryInterface() +#define DEFINE_XINTERFACE_11( CLASS, BASECLASS, INTERFACE1, INTERFACE2, INTERFACE3, INTERFACE4, INTERFACE5, INTERFACE6, INTERFACE7, INTERFACE8, INTERFACE9, INTERFACE10, INTERFACE11 ) \ + PRIVATE_DEFINE_XINTERFACE ( CLASS, \ + BASECLASS, \ + ( aType, PRIVATE_DEFINE_INTERFACE_11 ( INTERFACE1 , \ + INTERFACE2 , \ + INTERFACE3 , \ + INTERFACE4 , \ + INTERFACE5 , \ + INTERFACE6 , \ + INTERFACE7 , \ + INTERFACE8 , \ + INTERFACE9 , \ + INTERFACE10 , \ + INTERFACE11 \ + ) \ + ) \ + ) + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_MACROS_XINTERFACE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/macros/xserviceinfo.hxx b/framework/inc/macros/xserviceinfo.hxx new file mode 100644 index 000000000..9849c5d0e --- /dev/null +++ b/framework/inc/macros/xserviceinfo.hxx @@ -0,0 +1,183 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_MACROS_XSERVICEINFO_HXX +#define INCLUDED_FRAMEWORK_INC_MACROS_XSERVICEINFO_HXX + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace framework{ + +/* + macros for declaration and definition of XServiceInfo + Please use follow public macros only! + + 2) DEFINE_XSERVICEINFO_MULTISERVICE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) => use it to define XServiceInfo for multi service mode + 3) DEFINE_XSERVICEINFO_ONEINSTANCESERVICE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) => use it to define XServiceInfo for one instance service mode + 4) DEFINE_INIT_SERVICE( CLASS ) => use it to implement your own impl_initService() method, which is necessary for initializing object by using his own reference! +*/ + +#define PRIVATE_DEFINE_XSERVICEINFO_BASE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + \ + OUString SAL_CALL CLASS::getImplementationName() \ + { \ + return impl_getStaticImplementationName(); \ + } \ + \ + sal_Bool SAL_CALL CLASS::supportsService( const OUString& sServiceName ) \ + { \ + return cppu::supportsService(this, sServiceName); \ + } \ + \ + css::uno::Sequence< OUString > SAL_CALL CLASS::getSupportedServiceNames() \ + { \ + return impl_getStaticSupportedServiceNames(); \ + } \ + \ + css::uno::Sequence< OUString > CLASS::impl_getStaticSupportedServiceNames() \ + { \ + css::uno::Sequence< OUString > seqServiceNames { SERVICENAME }; \ + return seqServiceNames; \ + } \ + \ + OUString CLASS::impl_getStaticImplementationName() \ + { \ + return IMPLEMENTATIONNAME; \ + } + +#define PRIVATE_DEFINE_XSERVICEINFO_OLDSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_XSERVICEINFO_BASE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + /* Attention: To avoid against wrong ref counts during our own initialize procedure, we must */ \ + /* use right EXTERNAL handling of them. That's why you should do nothing in your ctor, which could*/ \ + /* work on your ref count! All other things are allowed. Do work with your own reference - please */ \ + /* use "impl_initService()" method. */ \ + css::uno::Reference< css::uno::XInterface > SAL_CALL CLASS::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) \ + { \ + /* create new instance of service */ \ + CLASS* pClass = new CLASS( xServiceManager ); \ + /* hold it alive by increasing his ref count!!! */ \ + css::uno::Reference< css::uno::XInterface > xService( static_cast< XINTERFACECAST* >(pClass), css::uno::UNO_QUERY ); \ + /* initialize new service instance ... he can use his own refcount ... we hold it! */ \ + pClass->impl_initService(); \ + /* return new created service as reference */ \ + return xService; \ + } + +#define PRIVATE_DEFINE_XSERVICEINFO_NEWSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_XSERVICEINFO_BASE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + /* Attention: To avoid against wrong ref counts during our own initialize procedure, we must */ \ + /* use right EXTERNAL handling of them. That's why you should do nothing in your ctor, which could*/ \ + /* work on your ref count! All other things are allowed. Do work with your own reference - please */ \ + /* use "impl_initService()" method. */ \ + css::uno::Reference< css::uno::XInterface > SAL_CALL CLASS::impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )\ + { \ + /* retrieve component context from the given service manager */ \ + css::uno::Reference< css::uno::XComponentContext > xComponentContext( \ + comphelper::getComponentContext( xServiceManager ) ); \ + /* create new instance of service */ \ + CLASS* pClass = new CLASS( xComponentContext ); \ + /* hold it alive by increasing his ref count!!! */ \ + css::uno::Reference< css::uno::XInterface > xService( static_cast< XINTERFACECAST* >(pClass), css::uno::UNO_QUERY ); \ + /* initialize new service instance ... he can use his own refcount ... we hold it! */ \ + pClass->impl_initService(); \ + /* return new created service as reference */ \ + return xService; \ + } + +#define PRIVATE_DEFINE_SINGLEFACTORY( CLASS ) \ + css::uno::Reference< css::lang::XSingleServiceFactory > CLASS::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) \ + { \ + css::uno::Reference< css::lang::XSingleServiceFactory > xReturn ( cppu::createSingleFactory ( xServiceManager , \ + CLASS::impl_getStaticImplementationName() , \ + CLASS::impl_createInstance , \ + CLASS::impl_getStaticSupportedServiceNames() \ + ) \ + ); \ + return xReturn; \ + } + +#define PRIVATE_DEFINE_ONEINSTANCEFACTORY( CLASS ) \ + css::uno::Reference< css::lang::XSingleServiceFactory > CLASS::impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) \ + { \ + css::uno::Reference< css::lang::XSingleServiceFactory > xReturn ( cppu::createOneInstanceFactory ( xServiceManager , \ + CLASS::impl_getStaticImplementationName() , \ + CLASS::impl_createInstance , \ + CLASS::impl_getStaticSupportedServiceNames() \ + ) \ + ); \ + return xReturn; \ + } + +#define DECLARE_XSERVICEINFO_NOFACTORY \ + /* interface XServiceInfo */ \ + virtual OUString SAL_CALL getImplementationName ( ) override; \ + virtual sal_Bool SAL_CALL supportsService ( const OUString& sServiceName ) override; \ + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames ( ) override; \ + /* Helper for XServiceInfo */ \ + static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames( ); \ + static OUString impl_getStaticImplementationName ( ); \ + /* Helper for initialization of service by using own reference! */ \ + void impl_initService ( ); \ + +#define DEFINE_XSERVICEINFO_MULTISERVICE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_XSERVICEINFO_OLDSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_SINGLEFACTORY( CLASS ) + +#define DEFINE_XSERVICEINFO_ONEINSTANCESERVICE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_XSERVICEINFO_OLDSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_ONEINSTANCEFACTORY( CLASS ) + +#define DEFINE_XSERVICEINFO_MULTISERVICE_2( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_XSERVICEINFO_NEWSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_SINGLEFACTORY( CLASS ) + +#define DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_XSERVICEINFO_NEWSTYLE( CLASS, XINTERFACECAST, SERVICENAME, IMPLEMENTATIONNAME ) \ + PRIVATE_DEFINE_ONEINSTANCEFACTORY( CLASS ) + +// public +// implementation of service initialize! +// example of using: DEFINE_INIT_SERVICE( MyClassName, +// { +// ... +// Reference< XInterface > xThis( this, UNO_QUERY ); +// myMember* pMember = new myMember( xThis ); +// ... +// } +// ) +#define DEFINE_INIT_SERVICE( CLASS, FUNCTIONBODY ) \ + void CLASS::impl_initService() \ + { \ + FUNCTIONBODY \ + } + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_MACROS_XSERVICEINFO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/macros/xtypeprovider.hxx b/framework/inc/macros/xtypeprovider.hxx new file mode 100644 index 000000000..27f9a0546 --- /dev/null +++ b/framework/inc/macros/xtypeprovider.hxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_MACROS_XTYPEPROVIDER_HXX +#define INCLUDED_FRAMEWORK_INC_MACROS_XTYPEPROVIDER_HXX + +#include + +#include +#include +#include + +namespace framework{ + +/*_________________________________________________________________________________________________________________ + + macros for declaration and definition of XTypeProvider + Please use follow public macros only! + + 1) DEFINE_XTYPEPROVIDER => use it in header to declare XTypeProvider and his methods + 2) DECLARE_TYPEPROVIDER_0( CLASS ) => use it to define implementation of XTypeProvider for 0 supported type + DECLARE_TYPEPROVIDER_1( CLASS, TYPE1 ) => use it to define implementation of XTypeProvider for 1 supported type + ... + DECLARE_TYPEPROVIDER_16( CLASS, TYPE1, ... , TYPE16 ) + 3) DEFINE_XTYPEPROVIDER_1_WITH_BASECLASS( CLASS, BASECLASS, TYPE1 ) => use it to define implementation of XTypeProvider for 1 additional supported type to baseclass + ... + DEFINE_XTYPEPROVIDER_5_WITH_BASECLASS( CLASS, BASECLASS, TYPE1, ..., TYPE5 ) + +_________________________________________________________________________________________________________________*/ + +// private +// implementation of XTypeProvider::getImplementationId() + +#define PRIVATE_DEFINE_XTYPEPROVIDER_GETIMPLEMENTATIONID( CLASS ) \ + css::uno::Sequence< sal_Int8 > SAL_CALL CLASS::getImplementationId() \ + { \ + return css::uno::Sequence(); \ + } + +// private +// help macros to replace TYPES in getTypes() [see before] + +#define PRIVATE_DEFINE_TYPE_11( TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, TYPE7, TYPE8, TYPE9, TYPE10, TYPE11 ) \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get(), \ + cppu::UnoType::get() + +// private +// complete implementation of XTypeProvider with max. 12 interfaces! + +#define PRIVATE_DEFINE_XTYPEPROVIDER( CLASS, TYPES ) \ + PRIVATE_DEFINE_XTYPEPROVIDER_GETIMPLEMENTATIONID( CLASS ) \ + css::uno::Sequence< css::uno::Type > SAL_CALL CLASS::getTypes() \ + { \ + /* Attention: "TYPES" will expand to "(...)"! */ \ + static cppu::OTypeCollection ourTypeCollection TYPES; \ + return ourTypeCollection.getTypes(); \ + } + +// public +// declaration of XTypeProvider + +#define FWK_DECLARE_XTYPEPROVIDER \ + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes () override;\ + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +// public +// implementation of XTypeProvider + +// implementation of XTypeProvider without additional interface for getTypes() +// XTypeProvider is used as the only one interface automatically. + + +// implementation of XTypeProvider with 11 additional interfaces for getTypes() +#define DEFINE_XTYPEPROVIDER_11( CLASS, TYPE1, TYPE2, TYPE3, TYPE4, TYPE5, TYPE6, TYPE7, TYPE8, TYPE9, TYPE10, TYPE11 ) \ + PRIVATE_DEFINE_XTYPEPROVIDER ( CLASS, \ + (PRIVATE_DEFINE_TYPE_11 ( TYPE1 , \ + TYPE2 , \ + TYPE3 , \ + TYPE4 , \ + TYPE5 , \ + TYPE6 , \ + TYPE7 , \ + TYPE8 , \ + TYPE9 , \ + TYPE10 , \ + TYPE11 \ + )) \ + ) + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_MACROS_XTYPEPROVIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/menuconfiguration.hxx b/framework/inc/menuconfiguration.hxx new file mode 100644 index 000000000..4024f9912 --- /dev/null +++ b/framework/inc/menuconfiguration.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include + +#include + +namespace com::sun::star::container { class XIndexAccess; } +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::io { class XOutputStream; } +namespace com::sun::star::uno { class XComponentContext; } + +const sal_uInt16 START_ITEMID_WINDOWLIST = 4600; +const sal_uInt16 END_ITEMID_WINDOWLIST = 4699; +const sal_uInt16 ITEMID_ADDONLIST = 6678; // used to be a SID in sfx2, now just a unique id... + +namespace framework +{ + +struct FWE_DLLPUBLIC MenuAttributes +{ +private: + oslInterlockedCount refCount; + + MenuAttributes(const OUString& rFrame, const OUString& rImageIdStr) + : refCount(0) + , aTargetFrame(rFrame) + , aImageId(rImageIdStr) + { + } + + MenuAttributes(const css::uno::WeakReference& rDispatchProvider) + : refCount(0) + , xDispatchProvider(rDispatchProvider) + { + } + + MenuAttributes(const MenuAttributes&) = delete; + +public: + OUString aTargetFrame; + OUString aImageId; + css::uno::WeakReference xDispatchProvider; + + static void* CreateAttribute(const OUString& rFrame, const OUString& rImageIdStr); + static void* CreateAttribute(const css::uno::WeakReference& rDispatchProvider); + static void ReleaseAttribute(void* nAttributePtr); + + void acquire() + { + osl_atomic_increment(&refCount); + } + + void release() + { + if (!osl_atomic_decrement(&refCount)) + delete this; + } +}; + +class UNLESS_MERGELIBS(FWE_DLLPUBLIC) MenuConfiguration final +{ +public: + MenuConfiguration( + // use const when giving a UNO reference by reference + const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + + ~MenuConfiguration(); + + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + css::uno::Reference< css::container::XIndexAccess > CreateMenuBarConfigurationFromXML( + css::uno::Reference< css::io::XInputStream > const & rInputStream ); + + /// @throws css::lang::WrappedTargetException + /// @throws css::uno::RuntimeException + void StoreMenuBarConfigurationToXML( + css::uno::Reference< css::container::XIndexAccess > const & rMenuBarConfiguration, + css::uno::Reference< css::io::XOutputStream > const & rOutputStream, + bool bIsMenuBar ); + +private: + css::uno::Reference< css::uno::XComponentContext> m_xContext; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwe.cxx b/framework/inc/pch/precompiled_fwe.cxx new file mode 100644 index 000000000..08c5958c1 --- /dev/null +++ b/framework/inc/pch/precompiled_fwe.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_fwe.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwe.hxx b/framework/inc/pch/precompiled_fwe.hxx new file mode 100644 index 000000000..f73501641 --- /dev/null +++ b/framework/inc/pch/precompiled_fwe.hxx @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-25 20:55:02 using: + ./bin/update_pch framework fwe --cutoff=10 --exclude:system --include:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./framework/inc/pch/precompiled_fwe.hxx "make framework.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwi.cxx b/framework/inc/pch/precompiled_fwi.cxx new file mode 100644 index 000000000..978ffd1d3 --- /dev/null +++ b/framework/inc/pch/precompiled_fwi.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_fwi.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwi.hxx b/framework/inc/pch/precompiled_fwi.hxx new file mode 100644 index 000000000..5a911cb2e --- /dev/null +++ b/framework/inc/pch/precompiled_fwi.hxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-25 20:55:02 using: + ./bin/update_pch framework fwi --cutoff=9 --exclude:system --include:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./framework/inc/pch/precompiled_fwi.hxx "make framework.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwk.cxx b/framework/inc/pch/precompiled_fwk.cxx new file mode 100644 index 000000000..e61e15d1e --- /dev/null +++ b/framework/inc/pch/precompiled_fwk.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_fwk.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx new file mode 100644 index 000000000..cc7bb0db2 --- /dev/null +++ b/framework/inc/pch/precompiled_fwk.hxx @@ -0,0 +1,259 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-25 20:55:02 using: + ./bin/update_pch framework fwk --cutoff=7 --exclude:system --include:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./framework/inc/pch/precompiled_fwk.hxx "make framework.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwl.cxx b/framework/inc/pch/precompiled_fwl.cxx new file mode 100644 index 000000000..28c5149d5 --- /dev/null +++ b/framework/inc/pch/precompiled_fwl.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "precompiled_fwl.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/pch/precompiled_fwl.hxx b/framework/inc/pch/precompiled_fwl.hxx new file mode 100644 index 000000000..83439f94e --- /dev/null +++ b/framework/inc/pch/precompiled_fwl.hxx @@ -0,0 +1,211 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +/* + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-04-25 20:55:03 using: + ./bin/update_pch framework fwl --cutoff=5 --exclude:system --include:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./framework/inc/pch/precompiled_fwl.hxx "make framework.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include +#include +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/properties.h b/framework/inc/properties.h new file mode 100644 index 000000000..5977b7b76 --- /dev/null +++ b/framework/inc/properties.h @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_PROPERTIES_H +#define INCLUDED_FRAMEWORK_INC_PROPERTIES_H + +#include + +namespace framework{ + +/** properties for "Frame" class */ + +#define FRAME_PROPNAME_ASCII_DISPATCHRECORDERSUPPLIER "DispatchRecorderSupplier" +#define FRAME_PROPNAME_ASCII_ISHIDDEN "IsHidden" +#define FRAME_PROPNAME_ASCII_LAYOUTMANAGER "LayoutManager" +#define FRAME_PROPNAME_ASCII_TITLE "Title" +#define FRAME_PROPNAME_ASCII_INDICATORINTERCEPTION "IndicatorInterception" + +// Please add new entries alphabetical sorted and correct all other handles! +// Start counting with 0, so it can be used as direct index into an array too. +// Don't forget updating of define FRAME_PROPCOUNT below!!! +#define FRAME_PROPHANDLE_DISPATCHRECORDERSUPPLIER 0 +#define FRAME_PROPHANDLE_ISHIDDEN 1 +#define FRAME_PROPHANDLE_LAYOUTMANAGER 2 +#define FRAME_PROPHANDLE_TITLE 3 +#define FRAME_PROPHANDLE_INDICATORINTERCEPTION 4 + +#define FRAME_PROPCOUNT 5 + +/** properties for "PathSettings" class */ + +#define PATHSETTINGS_PROPNAME_ASCII_ADDIN "Addin" +#define PATHSETTINGS_PROPNAME_ASCII_AUTOCORRECT "AutoCorrect" +#define PATHSETTINGS_PROPNAME_ASCII_AUTOTEXT "AutoText" +#define PATHSETTINGS_PROPNAME_ASCII_BACKUP "Backup" +#define PATHSETTINGS_PROPNAME_ASCII_BASIC "Basic" +#define PATHSETTINGS_PROPNAME_ASCII_BITMAP "Bitmap" +#define PATHSETTINGS_PROPNAME_ASCII_CONFIG "Config" +#define PATHSETTINGS_PROPNAME_ASCII_DICTIONARY "Dictionary" +#define PATHSETTINGS_PROPNAME_ASCII_FAVORITE "Favorite" +#define PATHSETTINGS_PROPNAME_ASCII_FILTER "Filter" +#define PATHSETTINGS_PROPNAME_ASCII_GALLERY "Gallery" +#define PATHSETTINGS_PROPNAME_ASCII_GRAPHIC "Graphic" +#define PATHSETTINGS_PROPNAME_ASCII_HELP "Help" +#define PATHSETTINGS_PROPNAME_ASCII_LINGUISTIC "Linguistic" +#define PATHSETTINGS_PROPNAME_ASCII_MODULE "Module" +#define PATHSETTINGS_PROPNAME_ASCII_PALETTE "Palette" +#define PATHSETTINGS_PROPNAME_ASCII_PLUGIN "Plugin" +#define PATHSETTINGS_PROPNAME_ASCII_STORAGE "Storage" +#define PATHSETTINGS_PROPNAME_ASCII_TEMP "Temp" +#define PATHSETTINGS_PROPNAME_ASCII_TEMPLATE "Template" +#define PATHSETTINGS_PROPNAME_ASCII_UICONFIG "UIConfig" +#define PATHSETTINGS_PROPNAME_ASCII_USERCONFIG "UserConfig" +#define PATHSETTINGS_PROPNAME_ASCII_USERDICTIONARY "UserDictionary" +#define PATHSETTINGS_PROPNAME_ASCII_WORK "Work" + + +/** properties for "LayoutManager" class */ + +#define LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER "MenuBarCloser" +#define LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS "AutomaticToolbars" +#define LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY "RefreshContextToolbarVisibility" +#define LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI "HideCurrentUI" +#define LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT "LockCount" +#define LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE "PreserveContentSize" + +#define LAYOUTMANAGER_PROPNAME_MENUBARCLOSER LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER + +#define LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER 0 +#define LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS 1 +#define LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY 2 +#define LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI 3 +#define LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT 4 +#define LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE 5 + +/** properties for "UICommandDescription" class */ +#define UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST "private:resource/image/commandimagelist" +#define UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST "private:resource/image/commandrotateimagelist" +#define UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST "private:resource/image/commandmirrorimagelist" + + +#define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 + +/** properties for "AutoRecovery" class */ + +#define AUTORECOVERY_PROPNAME_ASCII_EXISTS_RECOVERYDATA "ExistsRecoveryData" +#define AUTORECOVERY_PROPNAME_ASCII_EXISTS_SESSIONDATA "ExistsSessionData" +#define AUTORECOVERY_PROPNAME_ASCII_CRASHED "Crashed" + +#define AUTORECOVERY_PROPNAME_EXISTS_RECOVERYDATA AUTORECOVERY_PROPNAME_ASCII_EXISTS_RECOVERYDATA +#define AUTORECOVERY_PROPNAME_EXISTS_SESSIONDATA AUTORECOVERY_PROPNAME_ASCII_EXISTS_SESSIONDATA +#define AUTORECOVERY_PROPNAME_CRASHED AUTORECOVERY_PROPNAME_ASCII_CRASHED + +#define AUTORECOVERY_PROPHANDLE_EXISTS_RECOVERYDATA 0 +#define AUTORECOVERY_PROPHANDLE_EXISTS_SESSIONDATA 1 +#define AUTORECOVERY_PROPHANDLE_CRASHED 2 + +#define AUTORECOVERY_PROPCOUNT 3 + +/** properties for Filter config */ + +#define FILTER_PROPNAME_ASCII_DOCUMENTSERVICE "DocumentService" + +/** properties for office module config (Setup.xcu) */ + +#define OFFICEFACTORY_PROPNAME_ASCII_UINAME "ooSetupFactoryUIName" +#define OFFICEFACTORY_PROPNAME_ASCII_ICON "ooSetupFactoryIcon" + +/** properties for tab window (old) */ +#define TABWINDOW_PROPNAME_ASCII_PARENTWINDOW "ParentWindow" +#define TABWINDOW_PROPNAME_ASCII_TOPWINDOW "TopWindow" +#define TABWINDOW_PROPNAME_PARENTWINDOW TABWINDOW_PROPNAME_ASCII_PARENTWINDOW +#define TABWINDOW_PROPNAME_TOPWINDOW TABWINDOW_PROPNAME_ASCII_TOPWINDOW + +#define TABWINDOW_PROPHANDLE_PARENTWINDOW 0 +#define TABWINDOW_PROPHANDLE_TOPWINDOW 1 +#define TABWINDOW_PROPCOUNT 2 + +#define TABWINDOWSERVICE_PROPHANDLE_WINDOW 0 + +/** provides some helper methods to implement property sets. */ + +class PropHelper +{ + public: + + /** checks if given property will be changed by this settings. + * We compare the content of the given any values. If they are different we return sal_True - sal_False otherwise. + * + * @param aCurrentValue contains the current value for this property + * @param aNewValue contains the new value for this property + * @param aOldValue returns the current value, in case something will be changed + * @param aChangedValue returns the new value, in case something will be changed + * + * @return if value of this property will be changed; otherwise. + */ + + static bool willPropertyBeChanged( const css::uno::Any& aCurrentValue , + const css::uno::Any& aNewValue , + css::uno::Any& aOldValue , + css::uno::Any& aChangedValue ) + { + bool bChanged = false; + + // clear return parameter to be sure, to put out only valid values ... + aOldValue.clear(); + aChangedValue.clear(); + + // if value change ... + bChanged = aCurrentValue != aNewValue; + if (bChanged) + { + // ... set information of change. + aOldValue = aCurrentValue; + aChangedValue = aNewValue; + } + + return bChanged; + } +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_PROPERTIES_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/protocols.h b/framework/inc/protocols.h new file mode 100644 index 000000000..c0a1743b6 --- /dev/null +++ b/framework/inc/protocols.h @@ -0,0 +1,123 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +/*TODO outline this implementation :-) */ + +#ifndef INCLUDED_FRAMEWORK_INC_PROTOCOLS_H +#define INCLUDED_FRAMEWORK_INC_PROTOCOLS_H + +#include + +namespace framework{ + +/** + some protocols must be checked during loading or dispatching URLs manually + It can be necessary to decide, if a URL represent a non visible content or + a real visible component. + */ + +// indicates a loadable content in general! +#define SPECIALPROTOCOL_PRIVATE "private:" +// indicates loading of components using a model directly +#define SPECIALPROTOCOL_PRIVATE_OBJECT "private:object" +// indicates loading of components using a stream only +#define SPECIALPROTOCOL_PRIVATE_STREAM "private:stream" +// indicates creation of empty documents +#define SPECIALPROTOCOL_PRIVATE_FACTORY "private:factory" +// internal protocol of the sfx project for generic dispatch functionality +#define SPECIALPROTOCOL_SLOT "slot:" +// external representation of the slot protocol using names instead of id's +#define SPECIALPROTOCOL_UNO ".uno:" +// special sfx protocol to execute macros +#define SPECIALPROTOCOL_MACRO "macro:" +// generic way to start uno services during dispatch +#define SPECIALPROTOCOL_SERVICE "service:" +// for sending mails +#define SPECIALPROTOCOL_MAILTO "mailto:" +// for sending news +#define SPECIALPROTOCOL_NEWS "news:" + +/** well known protocols */ +enum class EProtocol +{ + PrivateObject, + PrivateStream, + PrivateFactory, + Slot, + Uno, + Macro, + Service, + MailTo, + News +}; + +class ProtocolCheck +{ + public: + + /** + it checks if given URL match the required protocol only + It should be used instead of specifyProtocol() if only this question + is interesting to perform the code. We must not check for all possible protocols here... + */ + static bool isProtocol( const OUString& sURL, EProtocol eRequired ) + { + bool bRet = false; + switch(eRequired) + { + case EProtocol::PrivateObject: + bRet = sURL.startsWith(SPECIALPROTOCOL_PRIVATE_OBJECT); + break; + case EProtocol::PrivateStream: + bRet = sURL.startsWith(SPECIALPROTOCOL_PRIVATE_STREAM); + break; + case EProtocol::PrivateFactory: + bRet = sURL.startsWith(SPECIALPROTOCOL_PRIVATE_FACTORY); + break; + case EProtocol::Slot: + bRet = sURL.startsWith(SPECIALPROTOCOL_SLOT); + break; + case EProtocol::Uno: + bRet = sURL.startsWith(SPECIALPROTOCOL_UNO); + break; + case EProtocol::Macro: + bRet = sURL.startsWith(SPECIALPROTOCOL_MACRO); + break; + case EProtocol::Service: + bRet = sURL.startsWith(SPECIALPROTOCOL_SERVICE); + break; + case EProtocol::MailTo: + bRet = sURL.startsWith(SPECIALPROTOCOL_MAILTO); + break; + case EProtocol::News: + bRet = sURL.startsWith(SPECIALPROTOCOL_NEWS); + break; + default: + bRet = false; + break; + } + return bRet; + } +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_PROTOCOLS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/recording/dispatchrecorder.hxx b/framework/inc/recording/dispatchrecorder.hxx new file mode 100644 index 000000000..41475e57a --- /dev/null +++ b/framework/inc/recording/dispatchrecorder.hxx @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_RECORDING_DISPATCHRECORDER_HXX +#define INCLUDED_FRAMEWORK_INC_RECORDING_DISPATCHRECORDER_HXX + +/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble + with solaris headers ... +*/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace framework{ + +class DispatchRecorder final + : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo + , css::frame::XDispatchRecorder + , css::container::XIndexReplace > +{ + // private member + private: + ::std::vector < css::frame::DispatchStatement > m_aStatements; + sal_Int32 m_nRecordingID; + css::uno::Reference< css::script::XTypeConverter > m_xConverter; + + // public interface + public: + DispatchRecorder( const css::uno::Reference< css::uno::XComponentContext >& xSMGR ); + virtual ~DispatchRecorder() override; + + // XInterface, XTypeProvider, XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XDispatchRecorder + virtual void SAL_CALL startRecording ( const css::uno::Reference< css::frame::XFrame >& xFrame ) override; + virtual void SAL_CALL recordDispatch ( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; + virtual void SAL_CALL recordDispatchAsComment( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; + virtual void SAL_CALL endRecording () override; + virtual OUString SAL_CALL getRecordedMacro () override; + + virtual css::uno::Type SAL_CALL getElementType() override; + + virtual sal_Bool SAL_CALL hasElements() override; + + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex(sal_Int32) override; + + virtual void SAL_CALL replaceByIndex(sal_Int32, const css::uno::Any&) override; + + // private functions + private: + void implts_recordMacro( const OUString& aURL, + const css::uno::Sequence< css::beans::PropertyValue >& lArguments, + bool bAsComment, OUStringBuffer& ); + void AppendToBuffer( const css::uno::Any& aValue, OUStringBuffer& aArgumentBuffer ); + +}; // class DispatcRecorder + +} // namespace framework + +#endif // define __FRAMEWORK... + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/recording/dispatchrecordersupplier.hxx b/framework/inc/recording/dispatchrecordersupplier.hxx new file mode 100644 index 000000000..b8eb844db --- /dev/null +++ b/framework/inc/recording/dispatchrecordersupplier.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_RECORDING_DISPATCHRECORDERSUPPLIER_HXX +#define INCLUDED_FRAMEWORK_INC_RECORDING_DISPATCHRECORDERSUPPLIER_HXX + +#include + +#include +#include +#include +#include + +#include + +namespace framework{ + +/** @short implement a supplier for dispatch recorder + @descr This supplier can be set on property "DispatchRecorderSupplier" on a frame. + By using of this supplier and his internal XDispatchRecorder it's possible to + record XDispatch::dispatch() requests. + + @threadsafe yes + */ +class DispatchRecorderSupplier final : public ::cppu::WeakImplHelper< + css::lang::XServiceInfo , + css::frame::XDispatchRecorderSupplier > +{ + + // member + + private: + + /** provided dispatch recorder of this supplier instance + + @life Is controlled from outside. Because this variable is set + from there and not created internally. But we release our + reference to it if we die. + */ + css::uno::Reference< css::frame::XDispatchRecorder > m_xDispatchRecorder; + + // uno interface + + public: + + // XInterface, XTypeProvider, XServiceInfo + + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XDispatchRecorderSupplier + + virtual void SAL_CALL setDispatchRecorder( const css::uno::Reference< css::frame::XDispatchRecorder >& xRecorder ) override; + virtual css::uno::Reference< css::frame::XDispatchRecorder > SAL_CALL getDispatchRecorder( ) override; + virtual void SAL_CALL dispatchAndRecord ( const css::util::URL& aURL , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments , + const css::uno::Reference< css::frame::XDispatch >& xDispatcher ) override; + + // native interface + + public: + + DispatchRecorderSupplier( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + virtual ~DispatchRecorderSupplier() override; + +}; // class DispatchRecorderSupplier + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_RECORDING_DISPATCHRECORDERSUPPLIER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/services.h b/framework/inc/services.h new file mode 100644 index 000000000..7b4627154 --- /dev/null +++ b/framework/inc/services.h @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_H +#define INCLUDED_FRAMEWORK_INC_SERVICES_H + +namespace framework{ + +// used servicenames by framework + +#define SERVICENAME_FILTERFACTORY "com.sun.star.document.FilterFactory" +#define SERVICENAME_CFGUPDATEACCESS "com.sun.star.configuration.ConfigurationUpdateAccess" // provides read/write access to the configuration +#define SERVICENAME_CFGREADACCESS "com.sun.star.configuration.ConfigurationAccess" // provides readonly access to the configuration +#define SERVICENAME_CONTENTHANDLER "com.sun.star.frame.ContentHandler" +#define SERVICENAME_JOB "com.sun.star.task.Job" +#define SERVICENAME_PROTOCOLHANDLER "com.sun.star.frame.ProtocolHandler" +#define SERVICENAME_POPUPMENUCONTROLLER "com.sun.star.frame.PopupMenuController" +#define SERVICENAME_STRINGABBREVIATION "com.sun.star.util.UriAbbreviation" + +// used implementationnames by framework + +#define IMPLEMENTATIONNAME_MEDIATYPEDETECTIONHELPER "com.sun.star.comp.framework.MediaTypeDetectionHelper" +#define IMPLEMENTATIONNAME_OXT_HANDLER "com.sun.star.comp.framework.OXTFileHandler" +#define IMPLEMENTATIONNAME_QUICKLAUNCHER "com.sun.star.comp.desktop.QuickstartWrapper" +#define IMPLEMENTATIONNAME_DISPATCHRECORDERSUPPLIER "com.sun.star.comp.framework.DispatchRecorderSupplier" +#define IMPLEMENTATIONNAME_MAILTODISPATCHER "com.sun.star.comp.framework.MailToDispatcher" +#define IMPLEMENTATIONNAME_SERVICEHANDLER "com.sun.star.comp.framework.ServiceHandler" +#define IMPLEMENTATIONNAME_DISPATCHHELPER "com.sun.star.comp.framework.services.DispatchHelper" +#define IMPLEMENTATIONNAME_DISPATCHDISABLER "com.sun.star.comp.framework.services.DispatchDisabler" +#define IMPLEMENTATIONNAME_MACROSMENUCONTROLLER "com.sun.star.comp.framework.MacrosMenuController" +#define IMPLEMENTATIONNAME_FONTMENUCONTROLLER "com.sun.star.comp.framework.FontMenuController" +#define IMPLEMENTATIONNAME_FONTSIZEMENUCONTROLLER "com.sun.star.comp.framework.FontSizeMenuController" +#define IMPLEMENTATIONNAME_HEADERMENUCONTROLLER "com.sun.star.comp.framework.HeaderMenuController" +#define IMPLEMENTATIONNAME_FOOTERMENUCONTROLLER "com.sun.star.comp.framework.FooterMenuController" +#define IMPLEMENTATIONNAME_NEWMENUCONTROLLER "com.sun.star.comp.framework.NewMenuController" +#define IMPLEMENTATIONNAME_TOOLBARMODEMENUCONTROLLER "com.sun.star.comp.framework.ToolbarModeMenuController" +#define IMPLEMENTATIONNAME_TOOLBARSMENUCONTROLLER "com.sun.star.comp.framework.ToolBarsMenuController" +#define IMPLEMENTATIONNAME_HELPONSTARTUP "com.sun.star.comp.framework.HelpOnStartup" +#define IMPLEMENTATIONNAME_SHELLJOB "com.sun.star.comp.framework.ShellJob" +#define IMPLEMENTATIONNAME_FWK_TASKCREATOR "com.sun.star.comp.framework.TaskCreator" +#define IMPLEMENTATIONNAME_SYSTEMEXEC "com.sun.star.comp.framework.SystemExecute" +#define IMPLEMENTATIONNAME_URIABBREVIATION "com.sun.star.comp.framework.UriAbbreviation" +#define IMPLEMENTATIONNAME_POPUPMENUDISPATCHER "com.sun.star.comp.framework.PopupMenuControllerDispatcher" +#define IMPLEMENTATIONNAME_LANGUAGESELECTIONMENUCONTROLLER "com.sun.star.comp.framework.LanguageSelectionMenuController" + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_SERVICES_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx new file mode 100644 index 000000000..90d2a04bd --- /dev/null +++ b/framework/inc/services/desktop.hxx @@ -0,0 +1,469 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_DESKTOP_HXX +#define INCLUDED_FRAMEWORK_INC_SERVICES_DESKTOP_HXX + +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace framework{ + +enum ELoadState +{ + E_NOTSET , + E_SUCCESSFUL , + E_FAILED , + E_INTERACTION +}; + +/*-************************************************************************************************************ + @short implement the topframe of frame tree + @descr This is the root of the frame tree. The desktop has no window, is not visible but he is the logical + "masternode" to build the hierarchy. + + @implements XInterface + XTypeProvider + XServiceInfo + XDesktop + XComponentLoader + XTasksSupplier + XDispatchProvider + XFramesSupplier + XFrame + XComponent + XPropertySet + XFastPropertySet + XMultiPropertySet + XDispatchResultListener + XEventListener + XInteractionHandler + + @devstatus ready to use + @threadsafe yes +*//*-*************************************************************************************************************/ +typedef cppu::WeakComponentImplHelper< + css::lang::XServiceInfo , + css::frame::XDesktop2 , + css::task::XJob, // for internal "shutdown" command + css::frame::XTasksSupplier , + css::frame::XDispatchResultListener , // => XEventListener + css::task::XInteractionHandler , + css::frame::XUntitledNumbers > Desktop_BASE; + +class Desktop final : private cppu::BaseMutex, + public Desktop_BASE, + public cppu::OPropertySetHelper +{ + // internal used types, const etcpp. + private: + + /** used temporary to know which listener was already called or not. */ + typedef ::std::vector< css::uno::Reference< css::frame::XTerminateListener > > TTerminateListenerList; + + // public methods + public: + + // constructor / destructor + Desktop( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~Desktop( ) override; + + void constructorInit(); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override; + + // XInterface + virtual void SAL_CALL acquire() throw () override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () override + { OWeakObject::release(); } + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + /** + @interface XDesktop + + @short try to shutdown these desktop environment. + + @descr Will try to close all frames. If at least one frame could + not be closed successfully termination will be stopped. + + Registered termination listener will be taken into account + also. As special feature some of our registered listener + are well known by its UNO implementation name. They are handled + different to all other listener. + + Btw: Desktop.terminate() was designed in the past to be used + within an UI based environment. So it's allowed e.g. to + call XController.suspend() here. If UI isn't an option ... please + use XCloseable.close() at these desktop implementation. + ... if it will be supported in the future .-)) + + @seealso XTerminateListener + @seealso XTerminateListener2 + + @return true if all open frames could be closed and no listener threw + a veto exception; false otherwise. + + @onerror False will be returned. + @threadsafe yes + */ + virtual sal_Bool SAL_CALL terminate() override; + + /** + @interface XDesktop + + @short add a listener for termination events + + @descr Additional to adding normal listener these method was implemented special. + Every listener will be asked for its uno implementation name. + Some of them are well known... and the corresponding listener won't be added + to the container of "normal listener". Those listener will be set as special + member. + see e.g. member m_xSfxTerminator + + @seealso terminate() + + @param xListener + the listener for registration. + + @threadsafe yes + */ + virtual void SAL_CALL addTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) override; + + /** + @interface XDesktop + + @short remove a listener from this container. + + @descr Additional to removing normal listener these method was implemented special. + Every listener will be asked for its uno implementation name. + Some of them are well known... and the corresponding listener was set as special member. + Now those special member will be reset also. + see e.g. member m_xSfxTerminator + + @seealso terminate() + + @param xListener + the listener for deregistration. + + @threadsafe yes + */ + virtual void SAL_CALL removeTerminateListener( const css::uno::Reference< css::frame::XTerminateListener >& xListener ) override; + + virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getComponents ( ) override; + virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getCurrentComponent ( ) override; + virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getCurrentFrame ( ) override; + + // XComponentLoader + virtual css::uno::Reference< css::lang::XComponent > SAL_CALL loadComponentFromURL ( const OUString& sURL , + const OUString& sTargetFrameName , + sal_Int32 nSearchFlags , + const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) override; + + // XTasksSupplier + virtual css::uno::Reference< css::container::XEnumerationAccess > SAL_CALL getTasks ( ) override; + virtual css::uno::Reference< css::frame::XTask > SAL_CALL getActiveTask ( ) override; + + // XDispatchProvider + virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch ( const css::util::URL& aURL , + const OUString& sTargetFrameName , + sal_Int32 nSearchFlags ) override; + virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches ( const css::uno::Sequence< css::frame::DispatchDescriptor >& lQueries ) override; + + // XDispatchProviderInterception + virtual void SAL_CALL registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override; + virtual void SAL_CALL releaseDispatchProviderInterceptor ( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override; + + // XFramesSupplier + virtual css::uno::Reference< css::frame::XFrames > SAL_CALL getFrames ( ) override; + virtual css::uno::Reference< css::frame::XFrame > SAL_CALL getActiveFrame ( ) override; + virtual void SAL_CALL setActiveFrame ( const css::uno::Reference< css::frame::XFrame >& xFrame ) override; + + // XFrame + // Attention: findFrame() is implemented only! Other methods make no sense for our desktop! + virtual css::uno::Reference< css::frame::XFrame > SAL_CALL findFrame ( const OUString& sTargetFrameName , + sal_Int32 nSearchFlags ) override; + virtual void SAL_CALL initialize ( const css::uno::Reference< css::awt::XWindow >& xWindow ) override; + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getContainerWindow ( ) override; + virtual void SAL_CALL setCreator ( const css::uno::Reference< css::frame::XFramesSupplier >& xCreator ) override; + virtual css::uno::Reference< css::frame::XFramesSupplier > SAL_CALL getCreator ( ) override; + virtual OUString SAL_CALL getName ( ) override; + virtual void SAL_CALL setName ( const OUString& sName ) override; + virtual sal_Bool SAL_CALL isTop ( ) override; + virtual void SAL_CALL activate ( ) override; + virtual void SAL_CALL deactivate ( ) override; + virtual sal_Bool SAL_CALL isActive ( ) override; + virtual sal_Bool SAL_CALL setComponent ( const css::uno::Reference< css::awt::XWindow >& xComponentWindow , + const css::uno::Reference< css::frame::XController >& xController ) override; + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL getComponentWindow ( ) override; + virtual css::uno::Reference< css::frame::XController > SAL_CALL getController ( ) override; + virtual void SAL_CALL contextChanged ( ) override; + virtual void SAL_CALL addFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) override; + virtual void SAL_CALL removeFrameActionListener ( const css::uno::Reference< css::frame::XFrameActionListener >& xListener ) override; + + // XComponent + virtual void SAL_CALL disposing() override; + virtual void SAL_CALL addEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener ( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + + // XDispatchResultListener + virtual void SAL_CALL dispatchFinished ( const css::frame::DispatchResultEvent& aEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing ( const css::lang::EventObject& aSource ) override; + + // XInteractionHandler + virtual void SAL_CALL handle ( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) override; + + // css.frame.XUntitledNumbers + virtual ::sal_Int32 SAL_CALL leaseNumber( const css::uno::Reference< css::uno::XInterface >& xComponent ) override; + + // css.frame.XUntitledNumbers + virtual void SAL_CALL releaseNumber( ::sal_Int32 nNumber ) override; + + // css.frame.XUntitledNumbers + virtual void SAL_CALL releaseNumberForComponent( const css::uno::Reference< css::uno::XInterface >& xComponent ) override; + + // css.frame.XUntitledNumbers + virtual OUString SAL_CALL getUntitledPrefix() override; + + // we need this wrapped terminate()-call to terminate even the QuickStarter + // non-virtual and non-UNO for now + /// @throws css::uno::RuntimeException + bool terminateQuickstarterToo(); + + css::uno::Any SAL_CALL execute(css::uno::Sequence const & Arguments) + override; + + private: + void shutdown(); + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , + css::uno::Any& aOldValue , + sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue ( css::uno::Any& aValue , + sal_Int32 nHandle ) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper ( ) override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo ( ) override; + + css::uno::Reference< css::lang::XComponent > impl_getFrameComponent ( const css::uno::Reference< css::frame::XFrame >& xFrame ) const; + + /** calls queryTermination() on every registered termination listener. + * + * Note: Only normal termination listener (registered in list m_aListenerContainer + * will be recognized here. Special listener like quick starter, pipe or others + * has to be handled explicitly ! + * + * @param [out] lCalledListener + * every called listener will be returned here. + * Those list will be used to inform all called listener + * about cancel this termination request. + * + * @return true if no one vetoed the termination. + * + * @see impl_sendCancelTerminationEvent() + */ + bool impl_sendQueryTerminationEvent(TTerminateListenerList& lCalledListener); + + /** calls cancelTermination() on every termination listener + * where queryTermination() was called before. + * + * Note: Only normal termination listener (registered in list m_aListenerContainer + * will be recognized here. Special listener like quick starter, pipe or others + * has to be handled explicitly ! + * + * @param [in] lCalledListener + * every listener in this list was called within its method + * queryTermination() before. + * + * @see impl_sendQueryTerminationEvent() + */ + void impl_sendCancelTerminationEvent(const TTerminateListenerList& lCalledListener); + + /** calls notifyTermination() on the clipboard listener + * + * The system clipboard may decide that it wants copies + * in several formats of the clipboard content requiring + * nearly all the services + * + */ + void impl_sendTerminateToClipboard(); + + /** calls notifyTermination() on every registered termination listener. + * + * Note: Only normal termination listener (registered in list m_aListenerContainer + * will be recognized here. Special listener like quick starter, pipe or others + * has to be handled explicitly ! + */ + void impl_sendNotifyTerminationEvent(); + + /** try to close all open frames. + * + * Iterates over all child frames and try to close them. + * Given parameter bAllowUI enable/disable showing any UI + * (which mostly occur on calling XController->suspend()). + * + * This method doesn't stop if one frame could not be closed. + * It will ignore such frames and try all other ones. + * But it returns false in such case - true otherwise. + * + * @param bAllowUI + * enable/disable showing of UI. + * + * @return true if all frames could be closed; false otherwise. + */ + bool impl_closeFrames(bool bAllowUI); + + private: + + mutable TransactionManager m_aTransactionManager; + + /** check flag to protect against multiple terminate runs + */ + bool m_bIsTerminated; + + /** check flag to protect us against dispose before terminate! + * see dispose() for further information! + */ + bool m_bIsShutdown; + + /** when true, the call came from session manager + * the method is Desktop::terminateQuickstarterToo() + * this the only one place where set this to true + * In this case, when one frame break, not make + * question for other, the break of shutdown or logout + * can be only once. + * In Desktop::impl_closeFrames would be test and break + * the loop and reset to false + */ + bool m_bSession; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; /// reference to factory, which has create this instance + FrameContainer m_aChildTaskContainer; /// array of child tasks (children of desktop are tasks; and tasks are also frames - But pure frames are not accepted!) + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener + css::uno::Reference< css::frame::XFrames > m_xFramesHelper; /// helper for XFrames, XIndexAccess, XElementAccess and implementation of a childcontainer! + css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchHelper; /// helper to dispatch something for new tasks, created by "_blank"! + ELoadState m_eLoadState; /// hold information about state of asynchron loading of component for loadComponentFromURL()! + bool m_bSuspendQuickstartVeto; /// don't ask quickstart for a veto + std::unique_ptr m_xCommandOptions; /// ref counted class to support disabling commands defined by configuration file + OUString m_sName; + OUString m_sTitle; + css::uno::Reference< css::frame::XDispatchRecorderSupplier > m_xDispatchRecorderSupplier; + + /** special terminate listener to close pipe and block external requests + * during/after termination process is/was running + */ + css::uno::Reference< css::frame::XTerminateListener > m_xPipeTerminator; + + /** special terminate listener shown inside system tray (quick starter) + * Will hinder the office on shutdown ... but wish to allow closing + * of open documents. And because that's different to a normal terminate listener + * it has to be handled special .-) + */ + css::uno::Reference< css::frame::XTerminateListener > m_xQuickLauncher; + + /** special terminate listener active when a macro is executing. + * Because basic runs Application::Yield internally the application may quit + * while running inside the internal basic event loop. So all the basic + * infrastructure may be deleted while the call is executing, leading to + * a variant of crashes. So this special terminate listener will + * veto the current quit attempt, stop basic execution, which will + * cause the inner event loop to quit, and on return to the outer normal + * application event loop then resend the quit attempt. + * So these implementation must be a special terminate listener too .-( + */ + css::uno::Reference< css::frame::XTerminateListener > m_xStarBasicQuitGuard; + + /** special terminate listener which loads images asynchronous for current open documents. + * Because internally it uses blocking system APIs... it can't be guaranteed that + * running jobs can be cancelled successfully if the corresponding document will be closed... + * it will not hinder those documents on closing. Instead it let all jobs running... + * but at least on terminate we have to wait for all those blocked requests. + * So these implementation must be a special terminate listener too .-( + */ + css::uno::Reference< css::frame::XTerminateListener > m_xSWThreadManager; + + /** special terminate listener shutting down the SfxApplication. + * Because these desktop instance closes documents and informs listener + * only... it does not really shutdown the whole application. + * + * Btw: that wouldn't be possible by design... because Desktop.terminate() + * has to return a boolean value about success... it can't really shutdown the + * process .-) + * + * So we uses a trick: a special listener (exactly these one here) listen for notifyTermination() + * and shutdown the process asynchronous. But desktop has to make this special + * notification as really last one ... Otherwise it can happen that asynchronous + * shutdown will be faster then all other code around Desktop.terminate() .-)) + */ + css::uno::Reference< css::frame::XTerminateListener > m_xSfxTerminator; + + css::uno::Reference< css::frame::XUntitledNumbers > m_xTitleNumberGenerator; + + std::vector> m_xComponentDllListeners; + +}; // class Desktop + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_SERVICES_DESKTOP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/services/layoutmanager.hxx b/framework/inc/services/layoutmanager.hxx new file mode 100644 index 000000000..955b2e425 --- /dev/null +++ b/framework/inc/services/layoutmanager.hxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +class MenuBar; +namespace framework +{ + + class ToolbarLayoutManager; + class GlobalSettings; + namespace detail + { + class InfoHelperBuilder; + } + typedef ::cppu::WeakImplHelper < css::lang::XServiceInfo + , css::frame::XLayoutManager2 + , css::awt::XWindowListener + > LayoutManager_Base; + typedef ::comphelper::OPropertyContainer LayoutManager_PBase; + class LayoutManager final : public LayoutManager_Base , + private cppu::BaseMutex, + public ::cppu::OBroadcastHelper , + public LayoutManager_PBase + { + public: + LayoutManager( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~LayoutManager() override; + + /** declaration of XInterface, XTypeProvider, XServiceInfo */ + DECLARE_XINTERFACE() + DECLARE_XTYPEPROVIDER() + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.comp.framework.LayoutManager"; + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override + { + css::uno::Sequence< OUString > aSeq { "com.sun.star.frame.LayoutManager" }; + return aSeq; + } + + // XLayoutManager + virtual void SAL_CALL attachFrame( const css::uno::Reference< css::frame::XFrame >& Frame ) override; + virtual void SAL_CALL reset() override; + virtual css::awt::Rectangle SAL_CALL getCurrentDockingArea( ) override; + virtual css::uno::Reference< css::ui::XDockingAreaAcceptor > SAL_CALL getDockingAreaAcceptor() override; + virtual void SAL_CALL setDockingAreaAcceptor( const css::uno::Reference< css::ui::XDockingAreaAcceptor >& xDockingAreaAcceptor ) final override; + virtual void SAL_CALL createElement( const OUString& aName ) override; + virtual void SAL_CALL destroyElement( const OUString& aName ) override; + virtual sal_Bool SAL_CALL requestElement( const OUString& ResourceURL ) override; + virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL getElement( const OUString& aName ) override; + virtual css::uno::Sequence< css::uno::Reference< css::ui::XUIElement > > SAL_CALL getElements( ) override; + virtual sal_Bool SAL_CALL showElement( const OUString& aName ) override; + virtual sal_Bool SAL_CALL hideElement( const OUString& aName ) override; + virtual sal_Bool SAL_CALL dockWindow( const OUString& aName, css::ui::DockingArea DockingArea, const css::awt::Point& Pos ) override; + virtual sal_Bool SAL_CALL dockAllWindows( ::sal_Int16 nElementType ) override; + virtual sal_Bool SAL_CALL floatWindow( const OUString& aName ) override; + virtual sal_Bool SAL_CALL lockWindow( const OUString& ResourceURL ) override; + virtual sal_Bool SAL_CALL unlockWindow( const OUString& ResourceURL ) override; + virtual void SAL_CALL setElementSize( const OUString& aName, const css::awt::Size& aSize ) override; + virtual void SAL_CALL setElementPos( const OUString& aName, const css::awt::Point& aPos ) override; + virtual void SAL_CALL setElementPosSize( const OUString& aName, const css::awt::Point& aPos, const css::awt::Size& aSize ) override; + virtual sal_Bool SAL_CALL isElementVisible( const OUString& aName ) override; + virtual sal_Bool SAL_CALL isElementFloating( const OUString& aName ) override; + virtual sal_Bool SAL_CALL isElementDocked( const OUString& aName ) override; + virtual sal_Bool SAL_CALL isElementLocked( const OUString& ResourceURL ) override; + virtual css::awt::Size SAL_CALL getElementSize( const OUString& aName ) override; + virtual css::awt::Point SAL_CALL getElementPos( const OUString& aName ) override; + virtual void SAL_CALL lock( ) override; + virtual void SAL_CALL unlock( ) override; + virtual void SAL_CALL doLayout( ) override; + virtual void SAL_CALL setVisible( sal_Bool bVisible ) override; + virtual sal_Bool SAL_CALL isVisible() override; + + // XMenuBarMergingAcceptor + + virtual sal_Bool SAL_CALL setMergedMenuBar( const css::uno::Reference< css::container::XIndexAccess >& xMergedMenuBar ) override; + virtual void SAL_CALL removeMergedMenuBar( ) override; + + // XWindowListener + virtual void SAL_CALL windowResized( const css::awt::WindowEvent& aEvent ) override; + virtual void SAL_CALL windowMoved( const css::awt::WindowEvent& aEvent ) override; + virtual void SAL_CALL windowShown( const css::lang::EventObject& aEvent ) override; + virtual void SAL_CALL windowHidden( const css::lang::EventObject& aEvent ) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) override; + + // XEventListener + using cppu::OPropertySetHelper::disposing; + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + // XUIConfigurationListener + virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override; + + // XLayoutManagerEventBroadcaster + virtual void SAL_CALL addLayoutManagerEventListener( const css::uno::Reference< css::frame::XLayoutManagerListener >& aLayoutManagerListener ) override; + virtual void SAL_CALL removeLayoutManagerEventListener( const css::uno::Reference< css::frame::XLayoutManagerListener >& aLayoutManagerListener ) override; + + DECL_LINK( MenuBarClose, void *, void); + DECL_LINK( WindowEventListener, VclWindowEvent&, void ); + + // called from ToolbarLayoutManager + void requestLayout(); + + /// Reading of settings - shared with ToolbarLayoutManager. + static bool readWindowStateData( const OUString& rName, UIElement& rElementData, + const css::uno::Reference< css::container::XNameAccess > &rPersistentWindowState, + std::unique_ptr &rGlobalSettings, bool &bInGlobalSettings, + const css::uno::Reference< css::uno::XComponentContext > &rComponentContext ); + + private: + DECL_LINK(AsyncLayoutHdl, Timer *, void); + + // menu bar + + void implts_createMenuBar( const OUString& rMenuBarName ); + void impl_clearUpMenuBar(); + void implts_reset( bool bAttach ); + void implts_updateMenuBarClose(); + bool implts_resetMenuBar(); + void implts_createMSCompatibleMenuBar(const OUString& rName); + + // locking + + void implts_lock(); + bool implts_unlock(); + + // query + + css::uno::Reference< css::ui::XUIElement > implts_findElement( const OUString& aName ); + + bool implts_readWindowStateData( const OUString& rName, UIElement& rElementData ); + void implts_writeWindowStateData( const OUString& rName, const UIElement& rElementData ); + void implts_destroyElements(); + void implts_toggleFloatingUIElementsVisibility( bool bActive ); + void implts_reparentChildWindows(); + css::uno::Reference< css::ui::XUIElement > implts_createDockingWindow( const OUString& aElementName ); + + bool implts_isEmbeddedLayoutManager() const; + css::uno::Reference< css::ui::XUIElement > implts_createElement( const OUString& aName ); + + // layouting methods + bool implts_resizeContainerWindow( const css::awt::Size& rContainerSize, const css::awt::Point& rComponentPos ); + ::Size implts_getContainerWindowOutputSize(); + + void implts_setDockingAreaWindowSizes(); + css::awt::Rectangle implts_calcDockingAreaSizes(); + bool implts_doLayout( bool bForceRequestBorderSpace, bool bOuterResize ); + void implts_doLayout_notify( bool bOuterResize ); + + // internal methods to control status/progress bar + ::Size implts_getStatusBarSize(); + void implts_destroyStatusBar(); + void implts_createStatusBar( const OUString& rStatusBarName ); + void implts_createProgressBar(); + void implts_destroyProgressBar(); + void implts_setStatusBarPosSize( const ::Point& rPos, const ::Size& rSize ); + bool implts_showStatusBar( bool bStoreState=false ); + bool implts_hideStatusBar( bool bStoreState=false ); + void implts_readStatusBarState( const OUString& rStatusBarName ); + bool implts_showProgressBar(); + bool implts_hideProgressBar(); + void implts_backupProgressBarWrapper(); + void implts_setOffset( const sal_Int32 nBottomOffset ); + + /// @throws css::uno::RuntimeException + void implts_setInplaceMenuBar( + const css::uno::Reference< css::container::XIndexAccess >& xMergedMenuBar ); + /// @throws css::uno::RuntimeException + void implts_resetInplaceMenuBar(); + + void implts_setVisibleState( bool bShow ); + void implts_updateUIElementsVisibleState( bool bShow ); + void implts_setCurrentUIVisibility( bool bShow ); + void implts_notifyListeners(short nEvent, const css::uno::Any& rInfoParam); + + // OPropertySetHelper + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; /** reference to factory, which has created this instance. */ + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + css::uno::Reference< css::frame::XFrame > m_xFrame; + css::uno::Reference< css::ui::XUIConfigurationManager > m_xModuleCfgMgr; + css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr; + css::uno::Reference< css::awt::XWindow > m_xContainerWindow; + css::uno::Reference< css::awt::XTopWindow2 > m_xContainerTopWindow; + sal_Int32 m_nLockCount; + bool m_bInplaceMenuSet; + bool m_bMenuVisible; + bool m_bVisible; + bool m_bParentWindowVisible; + bool m_bMustDoLayout; + bool m_bAutomaticToolbars; + bool m_bHideCurrentUI; + bool m_bGlobalSettings; + bool m_bPreserveContentSize; + bool m_bMenuBarCloseButton; + css::awt::Rectangle m_aDockingArea; + css::uno::Reference< css::ui::XDockingAreaAcceptor > m_xDockingAreaAcceptor; + rtl::Reference< MenuBarManager > m_xInplaceMenuBar; + css::uno::Reference< css::ui::XUIElement > m_xMenuBar; + UIElement m_aStatusBarElement; + UIElement m_aProgressBarElement; + css::uno::Reference< css::ui::XUIElement > m_xProgressBarBackup; + css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager; + css::uno::Reference< css::ui::XUIElementFactoryManager > m_xUIElementFactoryManager; + css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState; + css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowStateSupplier; + std::unique_ptr m_pGlobalSettings; + OUString m_aModuleIdentifier; + Timer m_aAsyncLayoutTimer; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; // container for ALL Listener + rtl::Reference< ToolbarLayoutManager > m_xToolbarManager; + + friend class detail::InfoHelperBuilder; + }; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_SERVICES_LAYOUTMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/services/mediatypedetectionhelper.hxx b/framework/inc/services/mediatypedetectionhelper.hxx new file mode 100644 index 000000000..8dd565301 --- /dev/null +++ b/framework/inc/services/mediatypedetectionhelper.hxx @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_MEDIATYPEDETECTIONHELPER_HXX +#define INCLUDED_FRAMEWORK_INC_SERVICES_MEDIATYPEDETECTIONHELPER_HXX + +#include + +#include + +#include + +// namespaces + +namespace framework{ + +/*-************************************************************************************************************ + @implements XInterface + XTypeProvider + XServiceInfo + XStringMapping + @base OWeakObject + + @devstatus deprecated +*//*-*************************************************************************************************************/ + +class MediaTypeDetectionHelper final : public ::cppu::WeakImplHelper< css::util::XStringMapping, css::lang::XServiceInfo> +{ + + // public methods + + public: + + // constructor / destructor + + /*-**************************************************************************************************** + @short standard ctor + @descr These initialize a new instance of this class with all needed information for work. + @param "xFactory", reference to factory which has created our owner(!). We can use these to create new uno-services. + *//*-*****************************************************************************************************/ + + MediaTypeDetectionHelper( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); + + /*-**************************************************************************************************** + @short standard destructor + @descr This method destruct an instance of this class and clear some member. + *//*-*****************************************************************************************************/ + + virtual ~MediaTypeDetectionHelper() override; + + // XInterface, XTypeProvider, XServiceInfo + + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XStringMapping + + /*-**************************************************************************************************** + *//*-*****************************************************************************************************/ + + virtual sal_Bool SAL_CALL mapStrings(css::uno::Sequence< OUString >& seqParameter) override; + +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_SERVICES_MEDIATYPEDETECTIONHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/services/uriabbreviation.hxx b/framework/inc/services/uriabbreviation.hxx new file mode 100644 index 000000000..a3794b63a --- /dev/null +++ b/framework/inc/services/uriabbreviation.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_SERVICES_URIABBREVIATION_HXX +#define INCLUDED_FRAMEWORK_INC_SERVICES_URIABBREVIATION_HXX + +#include + +#include +#include +#include + +#include + +namespace framework +{ + +class UriAbbreviation final : public ::cppu::WeakImplHelper< css::util::XStringAbbreviation, css::lang::XServiceInfo> +{ +public: + explicit UriAbbreviation(css::uno::Reference< css::uno::XComponentContext > const & context); + + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // css::util::XStringAbbreviation: + virtual OUString SAL_CALL abbreviateString(const css::uno::Reference< css::util::XStringWidth > & xStringWidth, ::sal_Int32 nWidth, const OUString & aString) override; + +private: + UriAbbreviation(UriAbbreviation const &) = delete; + UriAbbreviation& operator =(UriAbbreviation const &) = delete; + + virtual ~UriAbbreviation() override {} +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_SERVICES_URIABBREVIATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/statusbarconfiguration.hxx b/framework/inc/statusbarconfiguration.hxx new file mode 100644 index 000000000..adfcf623d --- /dev/null +++ b/framework/inc/statusbarconfiguration.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include + +namespace com::sun::star::container { class XIndexAccess; } +namespace com::sun::star::container { class XIndexContainer; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::io { class XOutputStream; } +namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::uno { template class Reference; } + +namespace framework +{ + +class UNLESS_MERGELIBS(FWE_DLLPUBLIC) StatusBarConfiguration +{ + public: + static bool LoadStatusBar( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::io::XInputStream >& xInputStream, + const css::uno::Reference< css::container::XIndexContainer >& rStatusbarConfiguration ); + + static bool StoreStatusBar( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::io::XOutputStream >& xOutputStream, + const css::uno::Reference< css::container::XIndexAccess >& rStatusbarConfiguration ); +}; + +} // namespace framework + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/stdtypes.h b/framework/inc/stdtypes.h new file mode 100644 index 000000000..ba4933b7d --- /dev/null +++ b/framework/inc/stdtypes.h @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_STDTYPES_H +#define INCLUDED_FRAMEWORK_INC_STDTYPES_H + +#include + +#include +#include + +namespace framework{ + +/** + Own hash functions used for stl-structures ... e.g. hash tables/maps ... +*/ + +struct KeyEventHashCode +{ + size_t operator()( const css::awt::KeyEvent& aEvent ) const + { + return static_cast(aEvent.KeyCode + + //aEvent.KeyChar + + //aEvent.KeyFunc + + aEvent.Modifiers); + } +}; + +struct KeyEventEqualsFunc +{ + bool operator()(const css::awt::KeyEvent& rKey1, + const css::awt::KeyEvent& rKey2) const + { + return ( + (rKey1.KeyCode == rKey2.KeyCode ) && + //(rKey1.KeyChar == rKey2.KeyChar ) && + //(rKey1.KeyFunc == rKey2.KeyFunc ) && + (rKey1.Modifiers == rKey2.Modifiers) + ); + } +}; + +/** + It can be used to map names (e.g. of properties) to her corresponding handles. + Our helper class OPropertySetHelper works optimized with handles but sometimes we have only a property name. + Mapping between these two parts of a property should be done in the fastest way :-) +*/ + +typedef cppu::OMultiTypeInterfaceContainerHelperVar ListenerHash; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_STDTYPES_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/strings.hrc b/framework/inc/strings.hrc new file mode 100644 index 000000000..d3f28fcc9 --- /dev/null +++ b/framework/inc/strings.hrc @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_STRINGS_HRC +#define INCLUDED_FRAMEWORK_INC_STRINGS_HRC + +#define NC_(Context, String) reinterpret_cast(Context "\004" u8##String) + +#define STR_MENU_HEADFOOTALL NC_("STR_MENU_HEADFOOTALL", "All" ) +#define STR_UPDATEDOC NC_("STR_UPDATEDOC", "~Update" ) +#define STR_CLOSEDOC_ANDRETURN NC_("STR_CLOSEDOC_ANDRETURN", "~Close & Return to " ) +#define STR_TOOLBAR_VISIBLE_BUTTONS NC_("STR_TOOLBAR_VISIBLE_BUTTONS", "Visible ~Buttons") +#define STR_TOOLBAR_CUSTOMIZE_TOOLBAR NC_("STR_TOOLBAR_CUSTOMIZE_TOOLBAR", "~Customize Toolbar...") +#define STR_TOOLBAR_UNDOCK_TOOLBAR NC_("STR_TOOLBAR_UNDOCK_TOOLBAR", "U~ndock Toolbar" ) +#define STR_TOOLBAR_DOCK_TOOLBAR NC_("STR_TOOLBAR_DOCK_TOOLBAR", "~Dock Toolbar" ) +#define STR_TOOLBAR_DOCK_ALL_TOOLBARS NC_("STR_TOOLBAR_DOCK_ALL_TOOLBARS", "Dock ~All Toolbars" ) +#define STR_TOOLBAR_LOCK_TOOLBAR NC_("STR_TOOLBAR_LOCK_TOOLBAR", "~Lock Toolbar Position" ) +#define STR_TOOLBAR_CLOSE_TOOLBAR NC_("STR_TOOLBAR_CLOSE_TOOLBAR", "Close ~Toolbar" ) +#define STR_SAVECOPYDOC NC_("STR_SAVECOPYDOC", "Save Copy ~as..." ) +#define STR_NODOCUMENT NC_("STR_NODOCUMENT", "No Documents") +#define STR_CLEAR_RECENT_FILES NC_("STR_CLEAR_RECENT_FILES", "Clear List") +#define STR_CLEAR_RECENT_FILES_HELP NC_("STR_CLEAR_RECENT_FILES_HELP", "Clears the list with the most recently opened files. This action can not be undone.") +#define STR_REMOTE_TITLE NC_("STR_REMOTE_TITLE", " (Remote)") +#define STR_SAFEMODE_TITLE NC_("STR_SAFEMODE_TITLE", " (Safe Mode)") +#define STR_TOOLBAR_TITLE_ADDON NC_("STR_TOOLBAR_TITLE_ADDON", "Add-On %num%") +#define STR_FULL_DISC_RETRY_BUTTON NC_("STR_FULL_DISC_RETRY_BUTTON", "Retry" ) +#define STR_FULL_DISC_MSG NC_("STR_FULL_DISC_MSG", "%PRODUCTNAME could not save important internal information due to insufficient free disk space at the following location:\n%PATH\n\nYou will not be able to continue working with %PRODUCTNAME without allocating more free disk space at that location.\n\nPress the 'Retry' button after you have allocated more free disk space to retry saving the data.\n\n" ) +#define STR_RESTORE_TOOLBARS NC_("STR_RESTORE_TOOLBARS", "~Reset" ) +#define STR_CORRUPT_UICFG_SHARE NC_("STR_CORRUPT_UICFG_SHARE", "An error occurred while loading the user interface configuration data. The application will be terminated now.\nPlease try to reinstall the application." ) +#define STR_CORRUPT_UICFG_USER NC_("STR_CORRUPT_UICFG_USER", "An error occurred while loading the user interface configuration data. The application will be terminated now.\nPlease try to remove your user profile for the application." ) +#define STR_CORRUPT_UICFG_GENERAL NC_("STR_CORRUPT_UICFG_GENERAL", "An error occurred while loading the user interface configuration data. The application will be terminated now.\nPlease try to remove your user profile for the application first or try to reinstall the application." ) +#define STR_UNTITLED_DOCUMENT NC_("STR_UNTITLED_DOCUMENT", "Untitled" ) +// To translators: for displaying 'Multiple Languages' in the language statusbar control +#define STR_LANGSTATUS_MULTIPLE_LANGUAGES NC_("STR_LANGSTATUS_MULTIPLE_LANGUAGES", "Multiple Languages" ) +#define STR_LANGSTATUS_NONE NC_("STR_LANGSTATUS_NONE", "None (Do not check spelling)" ) +#define STR_RESET_TO_DEFAULT_LANGUAGE NC_("STR_RESET_TO_DEFAULT_LANGUAGE", "Reset to Default Language" ) +#define STR_LANGSTATUS_MORE NC_("STR_LANGSTATUS_MORE", "More..." ) +#define STR_SET_LANGUAGE_FOR_PARAGRAPH NC_("STR_SET_LANGUAGE_FOR_PARAGRAPH", "Set Language for Paragraph" ) +#define STR_LANGSTATUS_HINT NC_("STR_LANGSTATUS_HINT", "Text Language. Right-click to set character or paragraph language" ) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/targets.h b/framework/inc/targets.h new file mode 100644 index 000000000..a15db1e84 --- /dev/null +++ b/framework/inc/targets.h @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_TARGETS_H +#define INCLUDED_FRAMEWORK_INC_TARGETS_H + +namespace framework{ + +// Values for special frame search ... sTargetFrameName of findFrame() or queryDispatch() or loadComponentFromURL() + +#define SPECIALTARGET_SELF "_self" // The frame himself is searched. +#define SPECIALTARGET_PARENT "_parent" // The direct parent frame is searched. +#define SPECIALTARGET_TOP "_top" // Search at our parents for the first task (if any exist) or a frame without a parent. +#define SPECIALTARGET_BLANK "_blank" // Create a new task. +#define SPECIALTARGET_DEFAULT "_default" // Create a new task or recycle an existing one +#define SPECIALTARGET_BEAMER "_beamer" // special frame in hierarchy +#define SPECIALTARGET_HELPTASK "OFFICE_HELP_TASK" // special name for our help task + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_TARGETS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/taskcreatordefs.hxx b/framework/inc/taskcreatordefs.hxx new file mode 100644 index 000000000..1b63cd281 --- /dev/null +++ b/framework/inc/taskcreatordefs.hxx @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_TASKCREATORDEFS_HXX +#define INCLUDED_FRAMEWORK_INC_TASKCREATORDEFS_HXX + +/// [XFrame] if it's set, it will be used as parent frame for the new created frame. +const char ARGUMENT_PARENTFRAME[] = "ParentFrame"; // XFrame + +/** [OUString] if it's not a special name (beginning with "_" ... which are not allowed here!) + it will be set as the API name of the new created frame. + */ +const char ARGUMENT_FRAMENAME[] = "FrameName"; // OUString + +/// [sal_Bool] If it's set to sal_True we will make the new created frame visible. +const char ARGUMENT_MAKEVISIBLE[] = "MakeVisible"; // sal_Bool + +/** [sal_Bool] If not "ContainerWindow" property is set it force creation of a + top level window as new container window. + */ +const char ARGUMENT_CREATETOPWINDOW[] = "CreateTopWindow"; // sal_Bool + +/// [Rectangle] Place the new created frame on this place and resize the container window. +const char ARGUMENT_POSSIZE[] = "PosSize"; // Rectangle + +/// [XWindow] an outside created window, used as container window of the new created frame. +const char ARGUMENT_CONTAINERWINDOW[] = "ContainerWindow"; // XWindow + +/** [sal_Bool] enable/disable special mode, where this frame will be part of + the persistent window state feature suitable for any office module window + */ +const char ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE[] = "SupportPersistentWindowState"; // sal_Bool + +/** [sal_Bool] enable/disable special mode, where the title bar of our + the new created frame will be updated automatically. + Default = ON ! + */ +const char ARGUMENT_ENABLE_TITLEBARUPDATE[] = "EnableTitleBarUpdate"; // sal_Bool + +#endif // INCLUDED_FRAMEWORK_INC_TASKCREATORDEFS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/threadhelp/gate.hxx b/framework/inc/threadhelp/gate.hxx new file mode 100644 index 000000000..627a3a7cb --- /dev/null +++ b/framework/inc/threadhelp/gate.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_GATE_HXX +#define INCLUDED_FRAMEWORK_INC_THREADHELP_GATE_HXX + +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @short implement a gate to block multiple threads at the same time or unblock all + @descr A gate can be used as a negative-condition! You can open a "door" - wait() will not block ... + or you can close it - wait() blocks till open() is called again. + Then all currently waiting threads are running immediately - but new ones are blocked! + + @attention To prevent us against wrong using, the default ctor, copy ctor and the =operator are marked private! + + @devstatus ready to use +*//*-*************************************************************************************************************/ +class Gate +{ + + // public methods + + public: + + /*-**************************************************************************************************** + @short ctor + @descr These initialize the object right as an open gate. + *//*-*****************************************************************************************************/ + Gate() + : m_bClosed ( false ) + { + open(); + } + + /*-**************************************************************************************************** + @short dtor + @descr Is user forget it - we open the gate ... + blocked threads can running ... but I don't know + if it's right - we are destroyed yet!? + *//*-*****************************************************************************************************/ + ~Gate() + { + open(); + } + /*-**************************************************************************************************** + @short copy-ctor + @descr Forbid copy construction + *//*-*****************************************************************************************************/ + Gate(const Gate&) = delete; + /*-**************************************************************************************************** + @short copy-assignment + @descr Forbid copy assigning + *//*-*****************************************************************************************************/ + Gate& operator=(const Gate&) = delete; + + /*-**************************************************************************************************** + @short open the gate + @descr A wait() call will not block then. + + @seealso method close() + *//*-*****************************************************************************************************/ + void open() + { + // We must safe access to our internal member! + ::osl::MutexGuard aLock( m_aAccessLock ); + // Set condition -> wait don't block any longer -> gate is open + m_aPassage.set(); + // Check if operation was successful! + // Check returns false if condition isn't set => m_bClosed will be true then => we must return false; opening failed + m_bClosed = !m_aPassage.check(); + } + + /*-**************************************************************************************************** + @short close the gate + @descr A wait() call will block then. + + @seealso method open() + *//*-*****************************************************************************************************/ + void close() + { + // We must safe access to our internal member! + ::osl::MutexGuard aLock( m_aAccessLock ); + // Reset condition -> wait blocks now -> gate is closed + m_aPassage.reset(); + // Check if operation was successful! + // Check returns false if condition was reset => m_bClosed will be true then => we can return true; closing ok + m_bClosed = !m_aPassage.check(); + } + + /*-**************************************************************************************************** + @short must be called to pass the gate + @descr If gate "open" => wait() will not block. + If gate "closed" => wait() will block till somewhere open it again. + + @seealso method wait() + @seealso method open() + + *//*-*****************************************************************************************************/ + void wait() + { + // We must safe access to our internal member! + ::osl::ClearableMutexGuard aLock( m_aAccessLock ); + // If gate not closed - caller can pass it. + if( m_bClosed ) + { + // Then we must release used access lock - + // because next call will block... + // and if we hold the access lock nobody else can use this object without a deadlock! + aLock.clear(); + // Wait for opening gate... + m_aPassage.wait(); + } + } + + // private member + + private: + + ::osl::Mutex m_aAccessLock; + ::osl::Condition m_aPassage; + bool m_bClosed; + +}; // class Gate + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_THREADHELP_GATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/threadhelp/transactionguard.hxx b/framework/inc/threadhelp/transactionguard.hxx new file mode 100644 index 000000000..2c4366cde --- /dev/null +++ b/framework/inc/threadhelp/transactionguard.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONGUARD_HXX +#define INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONGUARD_HXX + +#include + +namespace framework{ + +class TransactionGuard +{ + public: + TransactionGuard( TransactionManager& rManager, EExceptionMode eMode ) + : m_pManager( &rManager ) + { + m_pManager->registerTransaction( eMode ); + } + + ~TransactionGuard() + { + m_pManager->unregisterTransaction(); + } + TransactionGuard(const TransactionGuard&) = delete; + TransactionGuard& operator=(const TransactionGuard&) = delete; + + private: + TransactionManager* m_pManager; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/threadhelp/transactionmanager.hxx b/framework/inc/threadhelp/transactionmanager.hxx new file mode 100644 index 000000000..9dbdc3b38 --- /dev/null +++ b/framework/inc/threadhelp/transactionmanager.hxx @@ -0,0 +1,128 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONMANAGER_HXX + +#include +#include + +#include +#include + +namespace framework{ + +/*-************************************************************************************************************ + @descr Describe different states of a feature of following implementation. + During lifetime of an object different working states occur: + initialization - working - closing - closed + If you wish to implement thread safe classes you should use this feature to protect + your code against calls at wrong time. e.g. you are not full initialized but somewhere + call an interface method (initialize phase means startup time from creating object till + calling specified first method e.g. XInitialization::initialize()!) then you should refuse + this call. The same for closing/disposing the object! +*//*-*************************************************************************************************************/ +enum EWorkingMode +{ + E_INIT , // We stand in an init method -> some calls are accepted - some ones are rejected + E_WORK , // Object is ready for working -> all calls are accepted + E_BEFORECLOSE, // We stand in a close method -> some calls are accepted - some ones are rejected + E_CLOSE // Object is dead! -> all calls are rejected! +}; + +/*-************************************************************************************************************ + @descr A transaction object should support throwing exceptions if user used it at wrong working mode. + e.g. We can throw a DisposedException if user try to work and our mode is E_CLOSE! + But sometimes he doesn't need this feature - will handle it by himself. + Then we must differ between some exception-modi: + E_HARDEXCEPTIONS We throw exceptions for all working modes different from E_WORK! + E_SOFTEXCEPTIONS We throw exceptions for all working modes different from E_WORK AND E_INCLOSE! + This mode is useful for impl-methods which should be callable from dispose() method! + + e.g. void dispose() + { + m_aTransactionManager.setWorkingMode( E_BEFORECLOSE ); + ... + impl_setA( 0 ); + ... + m_aTransactionManager.setWorkingMode( E_CLOSE ); + } + + void impl_setA( int nA ) + { + ERejectReason EReason; + TransactionGuard aTransactionGuard( m_aTransactionManager, E_SOFTEXCEPTIONS, eReason ); + + m_nA = nA; + } + + Normally (if E_HARDEXCEPTIONS was used!) creation of guard + will throw an exception ... but using of E_SOFTEXCEPTIONS suppress it + and member "A" can be set. +*//*-*************************************************************************************************************/ +enum EExceptionMode +{ + E_HARDEXCEPTIONS, + E_SOFTEXCEPTIONS +}; + +/*-************************************************************************************************************ + @short implement a transaction manager to support non breakable interface methods + @descr Use it to support non breakable interface methods without using any thread + synchronization like e.g. mutex, rw-lock! + That protect your code against wrong calls at wrong time ... e.g. calls after disposing an object! + Use combination of EExceptionMode and ERejectReason to detect rejected requests + and react for it. You can enable automatically throwing of exceptions too. + + @devstatus draft +*//*-*************************************************************************************************************/ +class UNLESS_MERGELIBS(FWI_DLLPUBLIC) TransactionManager +{ + + // public methods + + public: + + TransactionManager ( ); + ~TransactionManager ( ); + TransactionManager(const TransactionManager&) = delete; + TransactionManager& operator=(const TransactionManager&) = delete; + void setWorkingMode ( EWorkingMode eMode ); + EWorkingMode getWorkingMode ( ) const; + /// @throws css::uno::RuntimeException + /// @throws css::lang::DisposedException + void registerTransaction ( EExceptionMode eMode ); + /// @throws css::uno::RuntimeException + /// @throws css::lang::DisposedException + void unregisterTransaction ( ); + + private: + + mutable ::osl::Mutex m_aAccessLock; /// regulate access on internal member of this instance + Gate m_aBarrier; /// used to block transactions requests during change or work mode + EWorkingMode m_eWorkingMode; /// current working mode of object which use this manager (used to reject calls at wrong time) + sal_Int32 m_nTransactionCount; /// every transaction request is registered by this counter + +}; // class TransactionManager + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_THREADHELP_TRANSACTIONMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/toolboxconfiguration.hxx b/framework/inc/toolboxconfiguration.hxx new file mode 100644 index 000000000..40df7d0c8 --- /dev/null +++ b/framework/inc/toolboxconfiguration.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include +#include + +namespace com::sun::star::container { class XIndexAccess; } +namespace com::sun::star::container { class XIndexContainer; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::io { class XOutputStream; } +namespace com::sun::star::uno { class XComponentContext; } +namespace com::sun::star::uno { template class Reference; } + +namespace framework +{ + +class UNLESS_MERGELIBS(FWE_DLLPUBLIC) ToolBoxConfiguration +{ + public: + static bool LoadToolBox( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::io::XInputStream >& rInputStream, + const css::uno::Reference< css::container::XIndexContainer >& rToolbarConfiguration ); + + static bool StoreToolBox( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::io::XOutputStream >& rOutputStream, + const css::uno::Reference< css::container::XIndexAccess >& rToolbarConfiguration ); +}; + +} // namespace framework + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uiconfiguration/globalsettings.hxx b/framework/inc/uiconfiguration/globalsettings.hxx new file mode 100644 index 000000000..c90ab1453 --- /dev/null +++ b/framework/inc/uiconfiguration/globalsettings.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UICONFIGURATION_GLOBALSETTINGS_HXX +#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_GLOBALSETTINGS_HXX + +#include + +namespace framework +{ + +class GlobalSettings +{ + public: + GlobalSettings( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + ~GlobalSettings(); + + enum StateInfo + { + STATEINFO_LOCKED, + STATEINFO_DOCKED + }; + + // settings access + bool HasToolbarStatesInfo() const; + bool GetToolbarStateInfo( StateInfo eStateInfo, css::uno::Any& aValue ); + + private: + GlobalSettings(const GlobalSettings&) = delete; + GlobalSettings& operator=(const GlobalSettings& ) = delete; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; +}; + +} // namespace framework + +#endif // __FRAMEWORK_UIELEMENT_WINDOWSTATECONFIGURATION_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uiconfiguration/graphicnameaccess.hxx b/framework/inc/uiconfiguration/graphicnameaccess.hxx new file mode 100644 index 000000000..b25061ff6 --- /dev/null +++ b/framework/inc/uiconfiguration/graphicnameaccess.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UICONFIGURATION_GRAPHICNAMEACCESS_HXX +#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_GRAPHICNAMEACCESS_HXX + +#include + +#include +#include +#include + +namespace framework +{ + class GraphicNameAccess final : public ::cppu::WeakImplHelper< css::container::XNameAccess > + { + public: + GraphicNameAccess(); + virtual ~GraphicNameAccess() override; + + void addElement( const OUString& rName, const css::uno::Reference< css::graphic::XGraphic >& rElement ); + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual sal_Bool SAL_CALL hasElements() override; + virtual css::uno::Type SAL_CALL getElementType( ) override; + + private: + typedef std::unordered_map> NameGraphicHashMap; + NameGraphicHashMap m_aNameToElementMap; + css::uno::Sequence< OUString > m_aSeq; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UICONFIGURATION_GRAPHICNAMEACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uiconfiguration/imagemanager.hxx b/framework/inc/uiconfiguration/imagemanager.hxx new file mode 100644 index 000000000..331b4ec09 --- /dev/null +++ b/framework/inc/uiconfiguration/imagemanager.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UICONFIGURATION_IMAGEMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_IMAGEMANAGER_HXX + +#include + +#include +#include +#include + +#include +#include +#include + +namespace framework +{ + class ImageManagerImpl; + class ImageManager final : public ::cppu::WeakImplHelper< css::ui::XImageManager, css::lang::XServiceInfo> + { + public: + ImageManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~ImageManager() override; + + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.comp.framework.ImageManager"; + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override + { + css::uno::Sequence< OUString > aSeq { "com.sun.star.ui.ImageManager" }; + return aSeq; + } + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XImageManager + virtual void SAL_CALL reset() override; + virtual css::uno::Sequence< OUString > SAL_CALL getAllImageNames( ::sal_Int16 nImageType ) override; + virtual sal_Bool SAL_CALL hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL ) override; + virtual css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > SAL_CALL getImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence ) override; + virtual void SAL_CALL replaceImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicsSequence ) override; + virtual void SAL_CALL removeImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aResourceURLSequence ) override; + virtual void SAL_CALL insertImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicSequence ) override; + + // XUIConfiguration + virtual void SAL_CALL addConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener ) override; + virtual void SAL_CALL removeConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener ) override; + + // XUIConfigurationPersistence + virtual void SAL_CALL reload() override; + virtual void SAL_CALL store() override; + virtual void SAL_CALL storeToStorage( const css::uno::Reference< css::embed::XStorage >& Storage ) override; + virtual sal_Bool SAL_CALL isModified() override; + virtual sal_Bool SAL_CALL isReadOnly() override; + + // Non-UNO methods + /// @throws css::uno::RuntimeException + void setStorage( const css::uno::Reference< css::embed::XStorage >& Storage ); + + private: + ::std::unique_ptr m_pImpl; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UICONFIGURATION_IMAGEMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uiconfiguration/imagetype.hxx b/framework/inc/uiconfiguration/imagetype.hxx new file mode 100644 index 000000000..783d1ce88 --- /dev/null +++ b/framework/inc/uiconfiguration/imagetype.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UICONFIGURATION_IMAGETYPE_HXX +#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_IMAGETYPE_HXX + +#include +#include + +namespace framework +{ + +typedef std::unordered_map< OUString, + OUString > CommandToImageNameMap; +typedef std::unordered_map< OUString, + bool > CommandMap; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UICONFIGURATION_IMAGETYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uiconfiguration/moduleimagemanager.hxx b/framework/inc/uiconfiguration/moduleimagemanager.hxx new file mode 100644 index 000000000..23d5fc5b6 --- /dev/null +++ b/framework/inc/uiconfiguration/moduleimagemanager.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UICONFIGURATION_MODULEIMAGEMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_MODULEIMAGEMANAGER_HXX + +#include +#include + +#include +#include + +#include + +namespace framework +{ + class ImageManagerImpl; + + class ModuleImageManager final : public ::cppu::WeakImplHelper< css::ui::XImageManager> + { + public: + ModuleImageManager( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~ModuleImageManager() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XImageManager + virtual void SAL_CALL reset() override; + virtual css::uno::Sequence< OUString > SAL_CALL getAllImageNames( ::sal_Int16 nImageType ) override; + virtual sal_Bool SAL_CALL hasImage( ::sal_Int16 nImageType, const OUString& aCommandURL ) override; + virtual css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > > SAL_CALL getImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence ) override; + virtual void SAL_CALL replaceImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicsSequence ) override; + virtual void SAL_CALL removeImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aResourceURLSequence ) override; + virtual void SAL_CALL insertImages( ::sal_Int16 nImageType, const css::uno::Sequence< OUString >& aCommandURLSequence, const css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >& aGraphicSequence ) override; + + // XUIConfiguration + virtual void SAL_CALL addConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener ) override; + virtual void SAL_CALL removeConfigurationListener( const css::uno::Reference< css::ui::XUIConfigurationListener >& Listener ) override; + + // XUIConfigurationPersistence + virtual void SAL_CALL reload() override; + virtual void SAL_CALL store() override; + virtual void SAL_CALL storeToStorage( const css::uno::Reference< css::embed::XStorage >& Storage ) override; + virtual sal_Bool SAL_CALL isModified() override; + virtual sal_Bool SAL_CALL isReadOnly() override; + + private: + ::std::unique_ptr m_pImpl; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UICONFIGURATION_MODULEIMAGEMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uiconfiguration/windowstateproperties.hxx b/framework/inc/uiconfiguration/windowstateproperties.hxx new file mode 100644 index 000000000..b4653c4a1 --- /dev/null +++ b/framework/inc/uiconfiguration/windowstateproperties.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UICONFIGURATION_WINDOWSTATEPROPERTIES_HXX +#define INCLUDED_FRAMEWORK_INC_UICONFIGURATION_WINDOWSTATEPROPERTIES_HXX + +#define WINDOWSTATE_PROPERTY_LOCKED "Locked" +#define WINDOWSTATE_PROPERTY_DOCKED "Docked" +#define WINDOWSTATE_PROPERTY_VISIBLE "Visible" +#define WINDOWSTATE_PROPERTY_DOCKINGAREA "DockingArea" +#define WINDOWSTATE_PROPERTY_DOCKPOS "DockPos" +#define WINDOWSTATE_PROPERTY_DOCKSIZE "DockSize" +#define WINDOWSTATE_PROPERTY_POS "Pos" +#define WINDOWSTATE_PROPERTY_SIZE "Size" +#define WINDOWSTATE_PROPERTY_UINAME "UIName" +#define WINDOWSTATE_PROPERTY_INTERNALSTATE "InternalState" +#define WINDOWSTATE_PROPERTY_STYLE "Style" +#define WINDOWSTATE_PROPERTY_CONTEXT "ContextSensitive" +#define WINDOWSTATE_PROPERTY_HIDEFROMENU "HideFromToolbarMenu" +#define WINDOWSTATE_PROPERTY_NOCLOSE "NoClose" +#define WINDOWSTATE_PROPERTY_SOFTCLOSE "SoftClose" +#define WINDOWSTATE_PROPERTY_CONTEXTACTIVE "ContextActive" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/FixedImageToolbarController.hxx b/framework/inc/uielement/FixedImageToolbarController.hxx new file mode 100644 index 000000000..2f10503e5 --- /dev/null +++ b/framework/inc/uielement/FixedImageToolbarController.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDIMAGETOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDIMAGETOOLBARCONTROLLER_HXX + +#include + +#include +#include + +class ToolBox; +class FixedImage; + +namespace framework +{ +class FixedImageToolbarController final : public ComplexToolbarController +{ +public: + FixedImageToolbarController(const css::uno::Reference& rxContext, + const css::uno::Reference& rFrame, + ToolBox* pToolBar, sal_uInt16 nID, const OUString& aCommand); + + // XComponent + virtual void SAL_CALL dispose() override; + + void CheckAndUpdateImages(); + +private: + virtual void executeControlCommand(const css::frame::ControlCommand& rControlCommand) override; + + DECL_LINK(MiscOptionsChanged, LinkParamNone*, void); + + VclPtr m_pFixedImageControl; + sal_Int16 m_eSymbolSize; +}; +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDIMAGETOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/FixedTextToolbarController.hxx b/framework/inc/uielement/FixedTextToolbarController.hxx new file mode 100644 index 000000000..299bb8098 --- /dev/null +++ b/framework/inc/uielement/FixedTextToolbarController.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDTEXTTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDTEXTTOOLBARCONTROLLER_HXX + +#include +#include + +#include +#include + +class ToolBox; +class FixedText; + +namespace framework +{ +class FixedTextToolbarController final : public ComplexToolbarController +{ +public: + FixedTextToolbarController(const css::uno::Reference& rxContext, + const css::uno::Reference& rFrame, + ToolBox* pToolBar, sal_uInt16 nID, const OUString& aCommand); + + // XComponent + virtual void SAL_CALL dispose() override; + +private: + virtual void executeControlCommand(const css::frame::ControlCommand& rControlCommand) override; + virtual css::uno::Sequence + getExecuteArgs(sal_Int16 KeyModifier) const override; + + VclPtr m_pFixedTextControl; +}; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_FIXEDTEXTTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/addonstoolbarmanager.hxx b/framework/inc/uielement/addonstoolbarmanager.hxx new file mode 100644 index 000000000..d13c3f14b --- /dev/null +++ b/framework/inc/uielement/addonstoolbarmanager.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_ADDONSTOOLBARMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_ADDONSTOOLBARMANAGER_HXX + +#include + +#include + +#include + +class ToolBox; + +namespace framework +{ + +class AddonsToolBarManager final : public ToolBarManager +{ + public: + AddonsToolBarManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const OUString& rResourceName, + ToolBox* pToolBar ); + virtual ~AddonsToolBarManager() override; + + // XComponent + void SAL_CALL dispose() override; + + virtual void RefreshImages() override; + using ToolBarManager::FillToolbar; + void FillToolbar( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rAddonToolbar ); + + private: + DECL_LINK(Click, ToolBox *, void); + DECL_LINK(DoubleClick, ToolBox *, void); + DECL_LINK(Select, ToolBox *, void); + DECL_LINK(StateChanged, StateChangedType const *, void ); + DECL_LINK(DataChanged, DataChangedEvent const *, void ); + + virtual bool MenuItemAllowed( sal_uInt16 ) const override; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_ADDONSTOOLBARMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/addonstoolbarwrapper.hxx b/framework/inc/uielement/addonstoolbarwrapper.hxx new file mode 100644 index 000000000..6d6fee13f --- /dev/null +++ b/framework/inc/uielement/addonstoolbarwrapper.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_ADDONSTOOLBARWRAPPER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_ADDONSTOOLBARWRAPPER_HXX + +#include + +#include +#include + +namespace framework +{ + +class AddonsToolBarManager; +class AddonsToolBarWrapper final : public UIElementWrapperBase +{ + public: + AddonsToolBarWrapper( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~AddonsToolBarWrapper() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUIElement + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override; + + // cf. ToolbarLayoutManager + void populateImages(); + + private: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::lang::XComponent > m_xToolBarManager; + css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > m_aConfigData; + bool m_bCreatedImages; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_ADDONSTOOLBARWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/buttontoolbarcontroller.hxx b/framework/inc/uielement/buttontoolbarcontroller.hxx new file mode 100644 index 000000000..989c95203 --- /dev/null +++ b/framework/inc/uielement/buttontoolbarcontroller.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_BUTTONTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_BUTTONTOOLBARCONTROLLER_HXX + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +class ToolBox; + +namespace framework +{ + +class ButtonToolbarController final : public css::frame::XStatusListener, + public css::frame::XToolbarController, + public css::lang::XInitialization, + public css::util::XUpdatable, + public css::lang::XComponent, + public ::cppu::BaseMutex, + public ::cppu::OWeakObject +{ + public: + ButtonToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + ToolBox* pToolBar, + const OUString& aCommand ); + virtual ~ButtonToolbarController() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() throw () override; + virtual void SAL_CALL release() throw () override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XComponent + virtual void SAL_CALL dispose() override; + virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override; + virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XToolbarController + virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override; + virtual void SAL_CALL click() override; + virtual void SAL_CALL doubleClick() override; + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override; + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) override; + + private: + bool m_bInitialized : 1, + m_bDisposed : 1; + OUString m_aCommandURL; + css::uno::Reference< css::frame::XFrame > m_xFrame; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + VclPtr m_pToolbar; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_BUTTONTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/comboboxtoolbarcontroller.hxx b/framework/inc/uielement/comboboxtoolbarcontroller.hxx new file mode 100644 index 000000000..df14769ca --- /dev/null +++ b/framework/inc/uielement/comboboxtoolbarcontroller.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_COMBOBOXTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_COMBOBOXTOOLBARCONTROLLER_HXX + +#include + +#include + +#include + +namespace framework +{ + +class ComboBoxControl; + +class ComboboxToolbarController final : public ComplexToolbarController + +{ + public: + ComboboxToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + sal_Int32 nWidth, + const OUString& aCommand ); + virtual ~ComboboxToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // called from ComboBoxControl + void Select(); + void Modify(); + void GetFocus(); + void LoseFocus(); + void Activate(); + + private: + virtual void executeControlCommand( const css::frame::ControlCommand& rControlCommand ) override; + virtual css::uno::Sequence< css::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const override; + + VclPtr m_pComboBox; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_COMBOBOXTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/commandinfo.hxx b/framework/inc/uielement/commandinfo.hxx new file mode 100644 index 000000000..b2c7c3e88 --- /dev/null +++ b/framework/inc/uielement/commandinfo.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_COMMANDINFO_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_COMMANDINFO_HXX + +#include + +#include +#include + +namespace framework +{ + +struct CommandInfo +{ + CommandInfo() : nId( 0 ), + nImageInfo( 0 ) {} + + sal_uInt16 nId; + ::std::vector< sal_uInt16 > aIds; + sal_Int16 nImageInfo; +}; + +typedef std::unordered_map CommandToInfoMap; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_COMMANDINFO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/complextoolbarcontroller.hxx b/framework/inc/uielement/complextoolbarcontroller.hxx new file mode 100644 index 000000000..5c5bf8499 --- /dev/null +++ b/framework/inc/uielement/complextoolbarcontroller.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_COMPLEXTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_COMPLEXTOOLBARCONTROLLER_HXX + +#include +#include +#include +#include +#include + +#include +#include +#include + +class ToolBox; +namespace vcl { class Window; } + +namespace framework +{ + +class ComplexToolbarController : public svt::ToolboxController + +{ + public: + ComplexToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + const OUString& aCommand ); + virtual ~ComplexToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XToolbarController + virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + DECL_STATIC_LINK( ComplexToolbarController, ExecuteHdl_Impl, void*, void ); + DECL_STATIC_LINK( ComplexToolbarController, Notify_Impl, void*, void); + + struct ExecuteInfo + { + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + css::uno::Sequence< css::beans::PropertyValue > aArgs; + }; + + struct NotifyInfo + { + OUString aEventName; + css::uno::Reference< css::frame::XControlNotificationListener > xNotifyListener; + css::util::URL aSourceURL; + css::uno::Sequence< css::beans::NamedValue > aInfoSeq; + }; + + protected: + static sal_Int32 getFontSizePixel( const vcl::Window* pWindow ); + css::uno::Reference< css::frame::XDispatch > getDispatchFromCommand( const OUString& aCommand ) const; + void addNotifyInfo( const OUString& aEventName, + const css::uno::Reference< css::frame::XDispatch >& xDispatch, + const css::uno::Sequence< css::beans::NamedValue >& rInfo ); + + virtual void executeControlCommand( const css::frame::ControlCommand& rControlCommand ) = 0; + virtual css::uno::Sequence< css::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const; + const css::util::URL& getInitializedURL(); + void notifyFocusGet(); + void notifyFocusLost(); + void notifyTextChanged( const OUString& aText ); + + VclPtr m_xToolbar; + sal_uInt16 m_nID; + bool m_bMadeInvisible; + mutable css::util::URL m_aURL; + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_COMPLEXTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/constitemcontainer.hxx b/framework/inc/uielement/constitemcontainer.hxx new file mode 100644 index 000000000..43f10597c --- /dev/null +++ b/framework/inc/uielement/constitemcontainer.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_CONSTITEMCONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_CONSTITEMCONTAINER_HXX + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +namespace framework +{ + +class RootItemContainer; +class ItemContainer; +class UNLESS_MERGELIBS(FWI_DLLPUBLIC) ConstItemContainer final : public ::cppu::WeakImplHelper< + css::container::XIndexAccess, + css::lang::XUnoTunnel , + css::beans::XFastPropertySet, + css::beans::XPropertySet > +{ + friend class RootItemContainer; + friend class ItemContainer; + + public: + ConstItemContainer(); + ConstItemContainer( const ItemContainer& rtemContainer ); + ConstItemContainer( const css::uno::Reference< css::container::XIndexAccess >& rSourceContainer, bool bFastCopy = false ); + virtual ~ConstItemContainer() override; + + // XUnoTunnel + static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() throw(); + sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override + { + return cppu::UnoType>::get(); + } + + virtual sal_Bool SAL_CALL hasElements() override; + + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; + virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; + virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; + virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; + virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; + + // XFastPropertySet + virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const css::uno::Any& aValue ) override; + virtual css::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) override; + + private: + ::cppu::IPropertyArrayHelper& getInfoHelper(); + css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + void copyItemContainer( const std::vector< css::uno::Sequence< css::beans::PropertyValue > >& rSourceVector ); + css::uno::Reference< css::container::XIndexAccess > deepCopyContainer( const css::uno::Reference< css::container::XIndexAccess >& rSubContainer ); + + std::vector< css::uno::Sequence< css::beans::PropertyValue > > m_aItemVector; + OUString m_aUIName; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_CONSTITEMCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/dropdownboxtoolbarcontroller.hxx b/framework/inc/uielement/dropdownboxtoolbarcontroller.hxx new file mode 100644 index 000000000..eb95c142c --- /dev/null +++ b/framework/inc/uielement/dropdownboxtoolbarcontroller.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_DROPDOWNBOXTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_DROPDOWNBOXTOOLBARCONTROLLER_HXX + +#include + +#include +#include + +class ToolBox; + +namespace framework +{ + +class ListBoxControl; + +class DropdownToolbarController final : public ComplexToolbarController + +{ + public: + DropdownToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + sal_Int32 nWidth, + const OUString& aCommand ); + virtual ~DropdownToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // called from ListBoxControl + void Select(); + void GetFocus(); + void LoseFocus(); + + private: + virtual void executeControlCommand( const css::frame::ControlCommand& rControlCommand ) override; + virtual css::uno::Sequence< css::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const override; + + VclPtr m_pListBoxControl; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_DROPDOWNBOXTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/edittoolbarcontroller.hxx b/framework/inc/uielement/edittoolbarcontroller.hxx new file mode 100644 index 000000000..193af5920 --- /dev/null +++ b/framework/inc/uielement/edittoolbarcontroller.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_EDITTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_EDITTOOLBARCONTROLLER_HXX + +#include + +#include +#include + +class ToolBox; + +namespace framework +{ + +class EditControl; + +class EditToolbarController final : public ComplexToolbarController + +{ + public: + EditToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + sal_Int32 nWidth, + const OUString& aCommand ); + virtual ~EditToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // called from EditControl + void Modify(); + void GetFocus(); + void LoseFocus(); + void Activate(); + + private: + virtual void executeControlCommand( const css::frame::ControlCommand& rControlCommand ) override; + virtual css::uno::Sequence< css::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const override; + + VclPtr m_pEditControl; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_EDITTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/fontmenucontroller.hxx b/framework/inc/uielement/fontmenucontroller.hxx new file mode 100644 index 000000000..ef8231f18 --- /dev/null +++ b/framework/inc/uielement/fontmenucontroller.hxx @@ -0,0 +1,71 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_FONTMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_FONTMENUCONTROLLER_HXX + +#include + +#include +#include + +#include +#include + +namespace framework +{ + class FontMenuController final : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + FontMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~FontMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XPopupMenuController + virtual void SAL_CALL updatePopupMenu() override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XMenuListener + virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + virtual void impl_setPopupMenu() override; + void fillPopupMenu( const css::uno::Sequence< OUString >& rFontNameSeq, css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + + OUString m_aFontFamilyName; + css::uno::Reference< css::frame::XDispatch > m_xFontListDispatch; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_FONTMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/fontsizemenucontroller.hxx b/framework/inc/uielement/fontsizemenucontroller.hxx new file mode 100644 index 000000000..36a960099 --- /dev/null +++ b/framework/inc/uielement/fontsizemenucontroller.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_FONTSIZEMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_FONTSIZEMENUCONTROLLER_HXX + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +namespace framework +{ + class FontSizeMenuController final : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + FontSizeMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~FontSizeMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XPopupMenuController + virtual void SAL_CALL updatePopupMenu() override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + virtual void impl_setPopupMenu() override; + void setCurHeight( long nHeight, css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + OUString retrievePrinterName( css::uno::Reference< css::frame::XFrame > const & rFrame ); + + std::unique_ptr m_pHeightArray; + css::awt::FontDescriptor m_aFontDescriptor; + css::frame::status::FontHeight m_aFontHeight; + css::uno::Reference< css::frame::XDispatch > m_xCurrentFontDispatch; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_FONTSIZEMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/footermenucontroller.hxx b/framework/inc/uielement/footermenucontroller.hxx new file mode 100644 index 000000000..732524a5e --- /dev/null +++ b/framework/inc/uielement/footermenucontroller.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_FOOTERMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_FOOTERMENUCONTROLLER_HXX + +#include + +namespace framework +{ + class FooterMenuController final : public HeaderMenuController + { + public: + FooterMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~FooterMenuController() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName ( ) override; + virtual sal_Bool SAL_CALL supportsService ( const OUString& sServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames ( ) override; + /* Helper for XServiceInfo */ + static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames( ); + static OUString impl_getStaticImplementationName ( ); + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_FOOTERMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/genericstatusbarcontroller.hxx b/framework/inc/uielement/genericstatusbarcontroller.hxx new file mode 100644 index 000000000..95521d2a2 --- /dev/null +++ b/framework/inc/uielement/genericstatusbarcontroller.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_GENERICSTATUSBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_GENERICSTATUSBARCONTROLLER_HXX + +#include + +#include + +namespace framework +{ + +struct AddonStatusbarItemData; + +class GenericStatusbarController final : public svt::StatusbarController +{ + public: + GenericStatusbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const css::uno::Reference< css::ui::XStatusbarItem >& rxItem, + AddonStatusbarItemData *pItemData ); + virtual ~GenericStatusbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + virtual void SAL_CALL paint( const css::uno::Reference< css::awt::XGraphics >& xGraphics, + const css::awt::Rectangle& rOutputRectangle, + ::sal_Int32 nStyle ) override; + + private: + bool m_bEnabled; + bool m_bOwnerDraw; + AddonStatusbarItemData* m_pItemData; + css::uno::Reference< css::graphic::XGraphic > m_xGraphic; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/generictoolbarcontroller.hxx b/framework/inc/uielement/generictoolbarcontroller.hxx new file mode 100644 index 000000000..eac6e8276 --- /dev/null +++ b/framework/inc/uielement/generictoolbarcontroller.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX + +#include +#include + +#include +#include +#include + +class PopupMenu; +class ToolBox; + +namespace framework +{ + +class GenericToolbarController final : public svt::ToolboxController +{ + public: + GenericToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + const OUString& aCommand ); + virtual ~GenericToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XToolbarController + virtual void SAL_CALL execute( sal_Int16 KeyModifier ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + DECL_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, void*, void ); + + struct ExecuteInfo + { + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + css::uno::Sequence< css::beans::PropertyValue > aArgs; + }; + + private: + VclPtr m_xToolbar; + sal_uInt16 m_nID; + bool m_bEnumCommand : 1, + m_bMadeInvisible : 1; + OUString m_aEnumCommand; +}; + +class MenuToolbarController final : public svt::ToolboxController +{ + css::uno::Reference< css::container::XIndexAccess > m_xMenuDesc; + VclPtr pMenu; + css::uno::Reference< css::lang::XComponent > m_xMenuManager; + +public: + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& ) override {} + // XComponent + virtual void SAL_CALL dispose() override; + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArgs ) override; + // XToolbarController + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/headermenucontroller.hxx b/framework/inc/uielement/headermenucontroller.hxx new file mode 100644 index 000000000..b92cb9755 --- /dev/null +++ b/framework/inc/uielement/headermenucontroller.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_HEADERMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_HEADERMENUCONTROLLER_HXX + +#include + +#include +#include + +#include + +namespace framework +{ + class HeaderMenuController : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + HeaderMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext, bool _bFooter = false ); + virtual ~HeaderMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XPopupMenuController + virtual void SAL_CALL updatePopupMenu() override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + void fillPopupMenu( const css::uno::Reference< css::frame::XModel >& rModel, css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + + css::uno::Reference< css::frame::XModel > m_xModel; + bool m_bFooter; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_HEADERMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/imagebuttontoolbarcontroller.hxx b/framework/inc/uielement/imagebuttontoolbarcontroller.hxx new file mode 100644 index 000000000..9b6250597 --- /dev/null +++ b/framework/inc/uielement/imagebuttontoolbarcontroller.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_IMAGEBUTTONTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_IMAGEBUTTONTOOLBARCONTROLLER_HXX + +#include + +#include +#include + +class ToolBox; + +namespace framework +{ + +class ImageButtonToolbarController final : public ComplexToolbarController + +{ + public: + ImageButtonToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + const OUString& aCommand ); + virtual ~ImageButtonToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + private: + virtual void executeControlCommand( const css::frame::ControlCommand& rControlCommand ) override; + + bool ReadImageFromURL( bool bBigImage, const OUString& aImageURL, Image& aImage ); +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_IMAGEBUTTONTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/itemcontainer.hxx b/framework/inc/uielement/itemcontainer.hxx new file mode 100644 index 000000000..d22fc9a09 --- /dev/null +++ b/framework/inc/uielement/itemcontainer.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_ITEMCONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_ITEMCONTAINER_HXX + +#include + +#include +#include + +#include + +#include +#include + +namespace framework +{ +class ConstItemContainer; +class ItemContainer final : public ::cppu::WeakImplHelper< css::container::XIndexContainer> +{ + friend class ConstItemContainer; + + public: + ItemContainer( const ShareableMutex& ); + ItemContainer( const ConstItemContainer& rConstItemContainer, const ShareableMutex& rMutex ); + ItemContainer( const css::uno::Reference< css::container::XIndexAccess >& rItemAccessContainer, const ShareableMutex& rMutex ); + virtual ~ItemContainer() override; + + // XInterface, XTypeProvider + + // XUnoTunnel + static const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() throw(); + + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override; + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override + { + return cppu::UnoType>::get(); + } + + virtual sal_Bool SAL_CALL hasElements() override; + + private: + void copyItemContainer( const std::vector< css::uno::Sequence< css::beans::PropertyValue > >& rSourceVector, const ShareableMutex& rMutex ); + css::uno::Reference< css::container::XIndexAccess > deepCopyContainer( const css::uno::Reference< css::container::XIndexAccess >& rSubContainer, const ShareableMutex& rMutex ); + + mutable ShareableMutex m_aShareMutex; + std::vector< css::uno::Sequence< css::beans::PropertyValue > > m_aItemVector; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_ITEMCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/langselectionmenucontroller.hxx b/framework/inc/uielement/langselectionmenucontroller.hxx new file mode 100644 index 000000000..080e98e32 --- /dev/null +++ b/framework/inc/uielement/langselectionmenucontroller.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_LANGSELECTIONMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_LANGSELECTIONMENUCONTROLLER_HXX + +#include + +#include +#include + +#include +#include + +#include + +namespace framework +{ + class LanguageSelectionMenuController final : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + LanguageSelectionMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~LanguageSelectionMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XPopupMenuController + virtual void SAL_CALL updatePopupMenu() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + virtual void impl_setPopupMenu() override; + enum Mode + { + MODE_SetLanguageSelectionMenu, + MODE_SetLanguageParagraphMenu, + MODE_SetLanguageAllTextMenu + }; + + bool m_bShowMenu; + OUString m_aLangStatusCommandURL; + css::uno::Reference< css::frame::XDispatch > m_xLanguageDispatch; + OUString m_aMenuCommandURL_Lang; + css::uno::Reference< css::frame::XDispatch > m_xMenuDispatch_Lang; + OUString m_aMenuCommandURL_Font; + css::uno::Reference< css::frame::XDispatch > m_xMenuDispatch_Font; + OUString m_aMenuCommandURL_CharDlgForParagraph; + css::uno::Reference< css::frame::XDispatch > m_xMenuDispatch_CharDlgForParagraph; + OUString m_aCurLang; + SvtScriptType m_nScriptType; + OUString m_aKeyboardLang; + OUString m_aGuessedTextLang; + LanguageGuessingHelper m_aLangGuessHelper; + + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu, const Mode rMode ); + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_LANGSELECTIONMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/macrosmenucontroller.hxx b/framework/inc/uielement/macrosmenucontroller.hxx new file mode 100644 index 000000000..c5fbd18f6 --- /dev/null +++ b/framework/inc/uielement/macrosmenucontroller.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_MACROSMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_MACROSMENUCONTROLLER_HXX + +#include +#include +#include +#include + +namespace framework +{ + class MacrosMenuController final : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + public: + MacrosMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~MacrosMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + void addScriptItems( PopupMenu* pPopupMenu, sal_uInt16 startItemId ); + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_MACROSMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/menubarmanager.hxx b/framework/inc/uielement/menubarmanager.hxx new file mode 100644 index 000000000..4fa42c8e8 --- /dev/null +++ b/framework/inc/uielement/menubarmanager.hxx @@ -0,0 +1,210 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARMANAGER_HXX + +/** Attention: stl headers must(!) be included at first. Otherwise it can make trouble + with solaris headers ... +*/ +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace framework +{ + +struct PopupControllerEntry +{ + css::uno::WeakReference< css::frame::XDispatchProvider > m_xDispatchProvider; +}; + +typedef std::unordered_map< OUString, PopupControllerEntry > PopupControllerCache; + +class MenuBarManager final : + protected cppu::BaseMutex, + public cppu::WeakComponentImplHelper< + css::frame::XStatusListener, + css::frame::XFrameActionListener, + css::ui::XUIConfigurationListener, + css::awt::XSystemDependentMenuPeer> +{ + MenuBarManager( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const css::uno::Reference< css::util::XURLTransformer >& _xURLTransformer, + Menu* pAddonMenu, + bool popup); + + public: + MenuBarManager( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const css::uno::Reference< css::util::XURLTransformer >& _xURLTransformer, + const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, + const OUString& aModuleIdentifier, + Menu* pMenu, + bool bDelete, + bool bHasMenuBar = true ); + + virtual ~MenuBarManager() override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XFrameActionListener + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XUIConfigurationListener + virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override; + + // XSystemDependentMenuPeer + virtual css::uno::Any SAL_CALL getMenuHandle( const css::uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType ) override; + + DECL_LINK( Select, Menu *, bool ); + + Menu* GetMenuBar() const { return m_pVCLMenu; } + + // Configuration methods + static void FillMenuWithConfiguration( sal_uInt16& nId, Menu* pMenu, + const OUString& rModuleIdentifier, + const css::uno::Reference< css::container::XIndexAccess >& rItemContainer, + const css::uno::Reference< css::util::XURLTransformer >& rTransformer ); + static void FillMenu( sal_uInt16& nId, + Menu* pMenu, + const OUString& rModuleIdentifier, + const css::uno::Reference< css::container::XIndexAccess >& rItemContainer, + const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider ); + + void FillMenuManager( Menu* pMenu, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, + const OUString& rModuleIdentifier, + bool bDelete ); + void SetItemContainer( const css::uno::Reference< css::container::XIndexAccess >& rItemContainer ); + void GetPopupController( PopupControllerCache& rPopupController ); + + private: + DECL_LINK( Activate, Menu *, bool ); + DECL_LINK( Deactivate, Menu *, bool ); + DECL_LINK( AsyncSettingsHdl, Timer *, void ); + + void SAL_CALL disposing() override; + void RemoveListener(); + void RequestImages(); + void RetrieveImageManagers(); + static bool MustBeHidden( PopupMenu* pPopupMenu, const css::uno::Reference< css::util::XURLTransformer >& rTransformer ); + OUString RetrieveLabelFromCommand(const OUString& rCmdURL); + + void Destroy(); + + struct MenuItemHandler + { + MenuItemHandler( sal_uInt16 aItemId, + css::uno::Reference< css::frame::XStatusListener > const & xManager, + css::uno::Reference< css::frame::XDispatch > const & rDispatch ) : + nItemId( aItemId ), + bMadeInvisible ( false ), + xSubMenuManager( xManager ), + xMenuItemDispatch( rDispatch ) {} + + sal_uInt16 nItemId; + bool bMadeInvisible; + OUString aTargetFrame; + OUString aMenuItemURL; + OUString aParsedItemURL; + css::uno::Reference< css::frame::XStatusListener > xSubMenuManager; + css::uno::Reference< css::frame::XDispatch > xMenuItemDispatch; + css::uno::Reference< css::frame::XPopupMenuController > xPopupMenuController; + css::uno::Reference< css::awt::XPopupMenu > xPopupMenu; + vcl::KeyCode aKeyCode; + }; + + void RetrieveShortcuts( std::vector< std::unique_ptr >& aMenuShortCuts ); + static void UpdateSpecialWindowMenu( Menu* pMenu, const css::uno::Reference< css::uno::XComponentContext >& xContext ); + static void FillMenuImages( css::uno::Reference< css::frame::XFrame > const & xFrame, Menu* _pMenu, bool bShowMenuImages ); + static void impl_RetrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg, + const css::uno::Sequence< OUString >& rCommands, + std::vector< std::unique_ptr >& aMenuShortCuts ); + static void MergeAddonMenus( Menu* pMenuBar, const MergeMenuInstructionContainer&, const OUString& aModuleIdentifier ); + + MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId ); + bool CreatePopupMenuController( MenuItemHandler* pMenuItemHandler ); + void AddMenu(MenuBarManager* pSubMenuManager,const OUString& _sItemCommand,sal_uInt16 _nItemId); + sal_uInt16 FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const; + void Init(const css::uno::Reference< css::frame::XFrame >& rFrame,Menu* pAddonMenu,bool _bHandlePopUp); + void SetHdl(); + + bool m_bDeleteMenu; + bool m_bActive; + bool m_bIsBookmarkMenu; + bool m_bShowMenuImages; + bool m_bRetrieveImages; + bool m_bAcceleratorCfg; + bool m_bModuleIdentified; + bool m_bHasMenuBar; + OUString m_aMenuItemCommand; + OUString m_aModuleIdentifier; + VclPtr m_pVCLMenu; + css::uno::Reference< css::frame::XFrame > m_xFrame; + css::uno::Reference< css::frame::XUIControllerFactory > m_xPopupMenuControllerFactory; + ::std::vector< std::unique_ptr > m_aMenuItemHandlerVector; + css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider; + css::uno::Reference< css::ui::XImageManager > m_xDocImageManager; + css::uno::Reference< css::ui::XImageManager > m_xModuleImageManager; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xDocAcceleratorManager; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobalAcceleratorManager; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + css::uno::Reference< css::container::XIndexAccess > m_xDeferedItemContainer; + OUString m_sIconTheme; + Timer m_aAsyncSettingsTimer; +}; + +} // namespace + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/menubarmerger.hxx b/framework/inc/uielement/menubarmerger.hxx new file mode 100644 index 000000000..139c40efc --- /dev/null +++ b/framework/inc/uielement/menubarmerger.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARMERGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARMERGER_HXX + +#include + +#include +#include +#include + +namespace framework +{ + +struct AddonMenuItem; +typedef ::std::vector< AddonMenuItem > AddonMenuContainer; + +struct AddonMenuItem +{ + OUString aTitle; + OUString aURL; + OUString aContext; + AddonMenuContainer aSubMenu; +}; + +enum RPResultInfo +{ + RP_OK, + RP_POPUPMENU_NOT_FOUND, + RP_MENUITEM_NOT_FOUND, + RP_MENUITEM_INSTEAD_OF_POPUPMENU_FOUND +}; + +struct ReferencePathInfo +{ + VclPtr pPopupMenu; + sal_uInt16 nPos; + sal_Int32 nLevel; + RPResultInfo eResult; +}; + +namespace MenuBarMerger +{ + bool IsCorrectContext( const OUString& aContext, const OUString& aModuleIdentifier ); + + void RetrieveReferencePath( const OUString&, + std::vector< OUString >& aReferencePath ); + ReferencePathInfo FindReferencePath( const std::vector< OUString >& aReferencePath, Menu* pMenu ); + sal_uInt16 FindMenuItem( const OUString& rCmd, + Menu const * pMenu ); + void GetMenuEntry( const css::uno::Sequence< css::beans::PropertyValue >& rAddonMenuEntry, + AddonMenuItem& aAddonMenu ); + void GetSubMenu( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSubMenuEntries, + AddonMenuContainer& rSubMenu ); + bool ProcessMergeOperation( Menu* pMenu, + sal_uInt16 nPos, + sal_uInt16& rItemId, + const OUString& rMergeCommand, + const OUString& rMergeCommandParameter, + const OUString& rModuleIdentifier, + const AddonMenuContainer& rAddonMenuItems ); + bool ProcessFallbackOperation( const ReferencePathInfo& aRefPathInfo, + sal_uInt16& rItemId, + const OUString& rMergeCommand, + const OUString& rMergeFallback, + const ::std::vector< OUString >& rReferencePath, + const OUString& rModuleIdentifier, + const AddonMenuContainer& rAddonMenuItems ); + bool MergeMenuItems( Menu* pMenu, + sal_uInt16 nPos, + sal_uInt16 nModIndex, + sal_uInt16& rItemId, + const OUString& rModuleIdentifier, + const AddonMenuContainer& rAddonMenuItems ); + bool ReplaceMenuItem( Menu* pMenu, + sal_uInt16 nPos, + sal_uInt16& rItemId, + const OUString& rModuleIdentifier, + const AddonMenuContainer& rAddonMenuItems ); + bool RemoveMenuItems( Menu* pMenu, + sal_uInt16 nPos, + const OUString& rMergeCommandParameter ); + bool CreateSubMenu( Menu* pSubMenu, + sal_uInt16& nItemId, + const OUString& rModuleIdentifier, + const AddonMenuContainer& rAddonSubMenu ); +} + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARMERGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/menubarwrapper.hxx b/framework/inc/uielement/menubarwrapper.hxx new file mode 100644 index 000000000..58ec21f83 --- /dev/null +++ b/framework/inc/uielement/menubarwrapper.hxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARWRAPPER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARWRAPPER_HXX + +#include +#include +#include +#include + +#include +#include + +namespace framework +{ + +class MenuBarWrapper final : public UIConfigElementWrapperBase, + public css::container::XNameAccess + +{ + public: + MenuBarWrapper( + const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~MenuBarWrapper() override; + + // XInterface, XTypeProvider + + FWK_DECLARE_XINTERFACE + FWK_DECLARE_XTYPEPROVIDER + + MenuBarManager* GetMenuBarManager() const { return static_cast< MenuBarManager* >( m_xMenuBarManager.get() ); } + + // XComponent + virtual void SAL_CALL dispose() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUIElement + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override; + + // XUIElementSettings + virtual void SAL_CALL updateSettings( ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + private: + virtual void impl_fillNewData() override; + void fillPopupControllerCache(); + + bool m_bRefreshPopupControllerCache : 1; + css::uno::Reference< css::lang::XComponent > m_xMenuBarManager; + PopupControllerCache m_aPopupControllerCache; + css::uno::Reference< css::uno::XComponentContext > m_xContext; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_MENUBARWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/newmenucontroller.hxx b/framework/inc/uielement/newmenucontroller.hxx new file mode 100644 index 000000000..96060e07f --- /dev/null +++ b/framework/inc/uielement/newmenucontroller.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_NEWMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_NEWMENUCONTROLLER_HXX + +#include + +#include +#include + +#include +#include +#include + +namespace framework +{ + class NewMenuController final : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + NewMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~NewMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XMenuListener + virtual void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) override; + virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + virtual void impl_setPopupMenu() override; + + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + void retrieveShortcutsFromConfiguration( const css::uno::Reference< css::ui::XAcceleratorConfiguration >& rAccelCfg, + const css::uno::Sequence< OUString >& rCommands, + std::vector< vcl::KeyCode >& aMenuShortCuts ); + void setAccelerators( PopupMenu* pPopupMenu ); + void determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const vcl::KeyCode& rKeyCode ); + void setMenuImages( PopupMenu* pPopupMenu, bool bSetImages ); + + private: + // members + bool m_bShowImages : 1, + m_bNewMenu : 1, + m_bModuleIdentified : 1, + m_bAcceleratorCfg : 1; + OUString m_aIconTheme; + OUString m_aTargetFrame; + OUString m_aModuleIdentifier; + OUString m_aEmptyDocURL; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xDocAcceleratorManager; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager; + css::uno::Reference< css::ui::XAcceleratorConfiguration > m_xGlobalAcceleratorManager; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_NEWMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/progressbarwrapper.hxx b/framework/inc/uielement/progressbarwrapper.hxx new file mode 100644 index 000000000..78dad538f --- /dev/null +++ b/framework/inc/uielement/progressbarwrapper.hxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_PROGRESSBARWRAPPER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_PROGRESSBARWRAPPER_HXX + +#include + +#include + +#include + +namespace framework{ + +class ProgressBarWrapper final : public UIElementWrapperBase +{ + public: + + // constructor / destructor + + ProgressBarWrapper(); + virtual ~ProgressBarWrapper() override; + + // public interfaces + void setStatusBar( const css::uno::Reference< css::awt::XWindow >& rStatusBar, bool bOwnsInstance = false ); + css::uno::Reference< css::awt::XWindow > getStatusBar() const; + + // wrapped methods of css::task::XStatusIndicator + /// @throws css::uno::RuntimeException + void start( const OUString& Text, ::sal_Int32 Range ); + /// @throws css::uno::RuntimeException + void end(); + /// @throws css::uno::RuntimeException + void setText( const OUString& Text ); + /// @throws css::uno::RuntimeException + void setValue( ::sal_Int32 Value ); + /// @throws css::uno::RuntimeException + void reset(); + + // UNO interfaces + // XComponent + virtual void SAL_CALL dispose() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XUIElement + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override; + + // variables + // (should be private everyway!) + + private: + css::uno::Reference< css::awt::XWindow > m_xStatusBar; // Reference to our status bar XWindow + css::uno::WeakReference< css::uno::XInterface > m_xProgressBarIfacWrapper; + bool m_bOwnsInstance; // Indicator that we are owner of the XWindow + sal_Int32 m_nRange; + sal_Int32 m_nValue; + OUString m_aText; +}; // class ProgressBarWrapper + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_PROGRESSBARWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/rootitemcontainer.hxx b/framework/inc/uielement/rootitemcontainer.hxx new file mode 100644 index 000000000..a71282b99 --- /dev/null +++ b/framework/inc/uielement/rootitemcontainer.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_ROOTITEMCONTAINER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_ROOTITEMCONTAINER_HXX + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +namespace framework +{ +class ConstItemContainer; + +typedef ::cppu::WeakImplHelper< + css::container::XIndexContainer, + css::lang::XSingleComponentFactory, + css::lang::XUnoTunnel > RootItemContainer_BASE; + +class RootItemContainer final : private cppu::BaseMutex, + public ::cppu::OBroadcastHelper , + public ::cppu::OPropertySetHelper , + public RootItemContainer_BASE +{ + friend class ConstItemContainer; + + public: + FWI_DLLPUBLIC RootItemContainer(); + FWI_DLLPUBLIC RootItemContainer( const css::uno::Reference< css::container::XIndexAccess >& rItemAccessContainer ); + virtual FWI_DLLPUBLIC ~RootItemContainer() override; + + // XInterface + virtual void SAL_CALL acquire() throw () override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () override + { OWeakObject::release(); } + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& type) override; + + // XTypeProvider + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; + + // XUnoTunnel + static FWI_DLLPUBLIC const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() throw(); + sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier ) override; + + // XIndexContainer + virtual void SAL_CALL insertByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + virtual void SAL_CALL removeByIndex( sal_Int32 Index ) override; + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const css::uno::Any& Element ) override; + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override + { + return cppu::UnoType>::get(); + } + + virtual sal_Bool SAL_CALL hasElements() override; + + // XSingleComponentFactory + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithContext( const css::uno::Reference< css::uno::XComponentContext >& Context ) override; + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& Context ) override; + + private: + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue ( css::uno::Any& aConvertedValue , + css::uno::Any& aOldValue , + sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle , + const css::uno::Any& aValue ) override; + using cppu::OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( css::uno::Any& aValue , + sal_Int32 nHandle ) const override; + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override; + + static css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor(); + + RootItemContainer& operator=( const RootItemContainer& ) = delete; + RootItemContainer( const RootItemContainer& ) = delete; + + css::uno::Reference< css::container::XIndexAccess > deepCopyContainer( const css::uno::Reference< css::container::XIndexAccess >& rSubContainer ); + + mutable ShareableMutex m_aShareMutex; + std::vector< css::uno::Sequence< css::beans::PropertyValue > > m_aItemVector; + OUString m_aUIName; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_ROOTITEMCONTAINER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/spinfieldtoolbarcontroller.hxx b/framework/inc/uielement/spinfieldtoolbarcontroller.hxx new file mode 100644 index 000000000..8445110b8 --- /dev/null +++ b/framework/inc/uielement/spinfieldtoolbarcontroller.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_SPINFIELDTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_SPINFIELDTOOLBARCONTROLLER_HXX + +#include + +#include +#include +#include + +class ToolBox; + +namespace framework +{ + +class SpinfieldControl; + +class SpinfieldToolbarController final : public ComplexToolbarController + +{ + public: + SpinfieldToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + sal_Int32 nWidth, + const OUString& aCommand ); + virtual ~SpinfieldToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // called from SpinfieldControl + void Up(); + void Down(); + void First(); + void Last(); + void Modify(); + void GetFocus(); + void LoseFocus(); + bool PreNotify( NotifyEvent const & rNEvt ); + + private: + virtual void executeControlCommand( const css::frame::ControlCommand& rControlCommand ) override; + virtual css::uno::Sequence< css::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const override; + + bool impl_getValue( const css::uno::Any& rAny, sal_Int32& nValue, double& fValue, bool& bFloat ); + OUString impl_formatOutputString( double fValue ); + + bool m_bFloat, + m_bMaxSet, + m_bMinSet; + double m_nMax; + double m_nMin; + double m_nValue; + double m_nStep; + VclPtr m_pSpinfieldControl; + OUString m_aOutFormat; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_SPINFIELDTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/statusbar.hxx b/framework/inc/uielement/statusbar.hxx new file mode 100644 index 000000000..fec07a45b --- /dev/null +++ b/framework/inc/uielement/statusbar.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBAR_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBAR_HXX + +#include + +#include + +namespace framework +{ + +class FrameworkStatusBar : public StatusBar +{ + public: + + FrameworkStatusBar( vcl::Window* pParent, + WinBits nWinBits ); + + void SetStatusBarManager( StatusBarManager* pStatusBarManager ); + + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void UserDraw(const UserDrawEvent& rUDEvt) override; + virtual void Command( const CommandEvent &rEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + + private: + StatusBarManager* m_pMgr; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/statusbaritem.hxx b/framework/inc/uielement/statusbaritem.hxx new file mode 100644 index 000000000..7dd3ed672 --- /dev/null +++ b/framework/inc/uielement/statusbaritem.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARITEM_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARITEM_HXX + +#include +#include +#include +#include + +class StatusBar; + +namespace framework +{ + +struct AddonStatusbarItemData; + +typedef cppu::WeakComponentImplHelper< css::ui::XStatusbarItem > StatusbarItem_Base; + +class StatusbarItem final : protected cppu::BaseMutex, + public StatusbarItem_Base +{ +public: + explicit StatusbarItem( + StatusBar *pStatusBar, + sal_uInt16 nId, + const OUString& aCommand ); + virtual ~StatusbarItem() override; + + void SAL_CALL disposing() override; + + // css::ui::XStatusbarItem Attributes + virtual OUString SAL_CALL getCommand() override; + virtual ::sal_uInt16 SAL_CALL getItemId() override; + virtual ::sal_uInt32 SAL_CALL getWidth() override; + virtual ::sal_uInt16 SAL_CALL getStyle() override; + virtual ::sal_Int32 SAL_CALL getOffset() override; + virtual css::awt::Rectangle SAL_CALL getItemRect() override; + virtual OUString SAL_CALL getText() override; + virtual void SAL_CALL setText( const OUString& rText ) override; + virtual OUString SAL_CALL getHelpText() override; + virtual void SAL_CALL setHelpText( const OUString& rHelpText ) override; + virtual OUString SAL_CALL getQuickHelpText() override; + virtual void SAL_CALL setQuickHelpText( const OUString& rQuickHelpText ) override; + virtual OUString SAL_CALL getAccessibleName() override; + virtual void SAL_CALL setAccessibleName( const OUString& rAccessibleName ) override; + virtual sal_Bool SAL_CALL getVisible() override; + virtual void SAL_CALL setVisible( sal_Bool bVisible ) override; + + // css::ui::XStatusbarItem Methods + virtual void SAL_CALL repaint( ) override; + +private: + VclPtr m_pStatusBar; + sal_uInt16 m_nId; + sal_uInt16 m_nStyle; + OUString m_aCommand; + +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/statusbarmanager.hxx b/framework/inc/uielement/statusbarmanager.hxx new file mode 100644 index 000000000..5fc341ae1 --- /dev/null +++ b/framework/inc/uielement/statusbarmanager.hxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMANAGER_HXX + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace framework +{ + +class FrameworkStatusBar; +class StatusBarManager final: public ::cppu::WeakImplHelper< + css::frame::XFrameActionListener, + css::lang::XComponent, + css::ui::XUIConfigurationListener > + +{ + friend class FrameworkStatusBar; + + public: + StatusBarManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + StatusBar* pStatusBar ); + virtual ~StatusBarManager() override; + + StatusBar* GetStatusBar() const; + + // XFrameActionListener + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XUIConfigurationListener + virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override; + + // XComponent + void SAL_CALL dispose() override; + void SAL_CALL addEventListener( const css::uno::Reference< XEventListener >& xListener ) override; + void SAL_CALL removeEventListener( const css::uno::Reference< XEventListener >& xListener ) override; + + void FillStatusBar( const css::uno::Reference< css::container::XIndexAccess >& rStatusBarData ); + + private: + void DataChanged( const DataChangedEvent& rDCEvt ); + void UserDraw( const UserDrawEvent& rUDEvt ); + void Command( const CommandEvent& rEvt ); + void MouseMove( const MouseEvent& rMEvt ); + void MouseButtonDown( const MouseEvent& rMEvt ); + void MouseButtonUp( const MouseEvent& rMEvt ); + DECL_LINK(Click, StatusBar*, void); + DECL_LINK(DoubleClick, StatusBar*, void); + + void RemoveControllers(); + void CreateControllers(); + void UpdateControllers(); + void MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL css::frame::XStatusbarController::*_pMethod )(const css::awt::MouseEvent&)); + + typedef std::map< sal_uInt16, css::uno::Reference< css::frame::XStatusbarController > > StatusBarControllerMap; + + bool m_bDisposed : 1, + m_bFrameActionRegistered : 1, + m_bUpdateControllers : 1; + VclPtr m_pStatusBar; + css::uno::Reference< css::frame::XFrame > m_xFrame; + StatusBarControllerMap m_aControllerMap; + osl::Mutex m_mutex; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::frame::XUIControllerFactory > m_xStatusbarControllerFactory; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/statusbarmerger.hxx b/framework/inc/uielement/statusbarmerger.hxx new file mode 100644 index 000000000..73aa7fd47 --- /dev/null +++ b/framework/inc/uielement/statusbarmerger.hxx @@ -0,0 +1,74 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMERGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARMERGER_HXX + +#include +#include +#include +#include + +namespace framework +{ + +struct AddonStatusbarItemData +{ + OUString aLabel; +}; + +struct AddonStatusbarItem +{ + OUString aCommandURL; + OUString aLabel; + OUString aContext; + StatusBarItemBits nItemBits; + sal_Int16 nWidth; +}; + +typedef ::std::vector< AddonStatusbarItem > AddonStatusbarItemContainer; + +namespace StatusbarMerger +{ + bool IsCorrectContext( const OUString& aContext ); + + bool ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence, + AddonStatusbarItemContainer& rContainer ); + + sal_uInt16 FindReferencePos( StatusBar* pStatusbar, + const OUString& rReferencePoint ); + + bool ProcessMergeOperation( StatusBar* pStatusbar, + sal_uInt16 nPos, + sal_uInt16& rItemId, + const OUString& rMergeCommand, + const OUString& rMergeCommandParameter, + const AddonStatusbarItemContainer& rItems ); + + bool ProcessMergeFallback( StatusBar* pStatusbar, + sal_uInt16& rItemId, + const OUString& rMergeCommand, + const OUString& rMergeFallback, + const AddonStatusbarItemContainer& rItems ); +} + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/statusbarwrapper.hxx b/framework/inc/uielement/statusbarwrapper.hxx new file mode 100644 index 000000000..c8f0e53e1 --- /dev/null +++ b/framework/inc/uielement/statusbarwrapper.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARWRAPPER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARWRAPPER_HXX + +#include + +#include +#include + +namespace framework +{ + +class StatusBarWrapper final : public UIConfigElementWrapperBase +{ + public: + StatusBarWrapper( + const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~StatusBarWrapper() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUIElement + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override; + + // XUIElementSettings + virtual void SAL_CALL updateSettings() override; + + private: + css::uno::Reference< css::lang::XComponent > m_xStatusBarManager; + css::uno::Reference< css::uno::XComponentContext > m_xContext; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSBARWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/statusindicatorinterfacewrapper.hxx b/framework/inc/uielement/statusindicatorinterfacewrapper.hxx new file mode 100644 index 000000000..c9913de0d --- /dev/null +++ b/framework/inc/uielement/statusindicatorinterfacewrapper.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSINDICATORINTERFACEWRAPPER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSINDICATORINTERFACEWRAPPER_HXX + +#include +#include + +#include +#include +#include + +namespace framework +{ + +class StatusIndicatorInterfaceWrapper final : public ::cppu::WeakImplHelper< css::task::XStatusIndicator> +{ + public: + StatusIndicatorInterfaceWrapper( const css::uno::Reference< css::lang::XComponent >& rStatusIndicatorImpl ); + virtual ~StatusIndicatorInterfaceWrapper() override; + + // XStatusIndicator + + virtual void SAL_CALL start ( const OUString& sText , + sal_Int32 nRange ) override; + virtual void SAL_CALL end ( ) override; + virtual void SAL_CALL reset ( ) override; + virtual void SAL_CALL setText ( const OUString& sText ) override; + virtual void SAL_CALL setValue( sal_Int32 nValue ) override; + + private: + css::uno::WeakReference< css::lang::XComponent > m_xStatusIndicatorImpl; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_STATUSINDICATORINTERFACEWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/styletoolbarcontroller.hxx b/framework/inc/uielement/styletoolbarcontroller.hxx new file mode 100644 index 000000000..e6d596905 --- /dev/null +++ b/framework/inc/uielement/styletoolbarcontroller.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_STYLETOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_STYLETOOLBARCONTROLLER_HXX + +#include +#include + +namespace framework { + +/** + * A dispatcher that serves as a proxy for style commands with arguments + * i.e. .uno:StyleApply?... in order to provide useful status updates to + * generic UI elements such as toolbars or menubar. It listens to special + * status commands, and computes a boolean status out of them. Then it + * forwards that boolean status to the listener, as if it was the status + * of the original command. + * + * Note that the implementation is minimal: Although the UI element appears + * to be the owner of the dispatcher, it's still responsible, as usual, to + * call removeStatusListener same amount of times as addStatusListener, + * otherwise the dispatcher might not be destructed. In addition this + * implementation might hold a hard reference on the owner, and it's the + * responsibility of the owner to destroy the dispatcher first, in order + * to break the cycle. + */ +class StyleDispatcher final : public cppu::WeakImplHelper< css::frame::XDispatch, css::frame::XStatusListener > +{ +public: + StyleDispatcher( const css::uno::Reference< css::frame::XFrame >& rFrame, + const css::uno::Reference< css::util::XURLTransformer >& rUrlTransformer, + const css::util::URL& rURL ); + + // XDispatch + void SAL_CALL dispatch( const css::util::URL& rURL, const css::uno::Sequence< css::beans::PropertyValue >& rArguments ) override; + void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& rListener, const css::util::URL& rURL ) override; + void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& rListener, const css::util::URL& rURL ) override; + + // XStatusListener + void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; + + // XEventListener + void SAL_CALL disposing( const css::lang::EventObject& rSource ) override; + +private: + OUString m_aStyleName, m_aCommand, m_aStatusCommand; + css::uno::Reference< css::util::XURLTransformer > m_xUrlTransformer; + css::uno::Reference< css::frame::XDispatchProvider > m_xFrame; + css::uno::Reference< css::frame::XDispatch > m_xStatusDispatch; + css::uno::Reference< css::frame::XStatusListener > m_xOwner; +}; + +class StyleToolbarController final : public svt::ToolboxController +{ +public: + StyleToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const OUString& rCommand ); + + // XUpdatable + void SAL_CALL update() override; + + // XStatusListener + void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) override; + + // XComponent + void SAL_CALL dispose() override; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/framework/inc/uielement/togglebuttontoolbarcontroller.hxx b/framework/inc/uielement/togglebuttontoolbarcontroller.hxx new file mode 100644 index 000000000..9e667da83 --- /dev/null +++ b/framework/inc/uielement/togglebuttontoolbarcontroller.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOGGLEBUTTONTOOLBARCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOGGLEBUTTONTOOLBARCONTROLLER_HXX + +#include + +#include +#include + +class Menu; +class ToolBox; + +namespace framework +{ + +class ToggleButtonToolbarController final : public ComplexToolbarController + +{ + public: + class DropdownMenuItem + { + public: + OUString mLabel; + OUString mTipHelpText; + }; + + enum class Style + { + DropDownButton, + ToggleDropDownButton + }; + + ToggleButtonToolbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + ToolBox* pToolBar, + sal_uInt16 nID, + Style eStyle, + const OUString& aCommand ); + virtual ~ToggleButtonToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XToolbarController + virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() override; + + private: + virtual void executeControlCommand( const css::frame::ControlCommand& rControlCommand ) override; + virtual css::uno::Sequence< css::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const override; + + DECL_LINK( MenuSelectHdl, Menu *, bool); + + OUString m_aCurrentSelection; + std::vector< DropdownMenuItem > m_aDropdownMenuList; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOGGLEBUTTONTOOLBARCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx new file mode 100644 index 000000000..8f3eb4c2b --- /dev/null +++ b/framework/inc/uielement/toolbarmanager.hxx @@ -0,0 +1,184 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +class PopupMenu; +class ToolBox; +class Menu; + +namespace framework +{ + +typedef ::cppu::WeakImplHelper< + css::frame::XFrameActionListener, + css::lang::XComponent, + css::ui::XUIConfigurationListener + > ToolbarManager_Base; + +class ToolBarManager : public ToolbarManager_Base +{ + public: + ToolBarManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + const OUString& rResourceName, + ToolBox* pToolBar ); + virtual ~ToolBarManager() override; + + ToolBox* GetToolBar() const; + + // XFrameActionListener + virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XUIConfigurationListener + virtual void SAL_CALL elementInserted( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::ui::ConfigurationEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::ui::ConfigurationEvent& Event ) override; + + // XComponent + void SAL_CALL dispose() override; + void SAL_CALL addEventListener( const css::uno::Reference< XEventListener >& xListener ) override; + void SAL_CALL removeEventListener( const css::uno::Reference< XEventListener >& xListener ) override; + + void CheckAndUpdateImages(); + virtual void RefreshImages(); + void FillToolbar( const css::uno::Reference< css::container::XIndexAccess >& rToolBarData ); + void FillOverflowToolbar( ToolBox const * pParent ); + void notifyRegisteredControllers( const OUString& aUIElementName, const OUString& aCommand ); + void Destroy(); + + enum ExecuteCommand + { + EXEC_CMD_CLOSETOOLBAR, + EXEC_CMD_UNDOCKTOOLBAR, + EXEC_CMD_DOCKTOOLBAR, + EXEC_CMD_DOCKALLTOOLBARS + }; + + struct ExecuteInfo + { + OUString aToolbarResName; + ExecuteCommand nCmd; + css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; + css::uno::Reference< css::awt::XWindow > xWindow; + }; + + protected: + DECL_LINK(Click, ToolBox *, void); + DECL_LINK(DropdownClick, ToolBox *, void); + DECL_LINK(DoubleClick, ToolBox *, void); + DECL_LINK(Select, ToolBox *, void); + DECL_LINK( StateChanged, StateChangedType const *, void ); + DECL_LINK( DataChanged, DataChangedEvent const *, void ); + DECL_LINK( MiscOptionsChanged, LinkParamNone*, void ); + + DECL_LINK( MenuButton, ToolBox *, void ); + DECL_LINK( MenuPreExecute, ToolBox *, void ); + DECL_LINK( MenuSelect, Menu *, bool ); + DECL_LINK(AsyncUpdateControllersHdl, Timer *, void); + DECL_LINK( OverflowEventListener, VclWindowEvent&, void ); + DECL_STATIC_LINK( ToolBarManager, ExecuteHdl_Impl, void*, void ); + + virtual bool MenuItemAllowed( sal_uInt16 ) const; + + void AddCustomizeMenuItems(ToolBox const * pToolBar); + void InitImageManager(); + void RemoveControllers(); + void CreateControllers(); + void UpdateControllers(); + //for update controller via Support Visible + void UpdateController( const css::uno::Reference< css::frame::XToolbarController >& xController); + //end + void AddFrameActionListener(); + void RequestImages(); + ToolBoxItemBits ConvertStyleToToolboxItemBits( sal_Int32 nStyle ); + css::uno::Reference< css::frame::XModel > GetModelFromFrame() const; + bool IsPluginMode() const; + void HandleClick(void ( SAL_CALL css::frame::XToolbarController::*_pClick )( )); + void setToolBarImage(const Image& _aImage,const CommandToInfoMap::const_iterator& _pIter); + void impl_elementChanged(bool _bRemove,const css::ui::ConfigurationEvent& Event ); + + protected: + typedef std::unordered_map< sal_uInt16, css::uno::Reference< css::frame::XStatusListener > > ToolBarControllerMap; + typedef ::std::vector< css::uno::Reference< css::frame::XSubToolbarController > > SubToolBarControllerVector; + typedef std::unordered_map SubToolBarToSubToolBarControllerMap; + + bool m_bDisposed : 1, + m_bAddedToTaskPaneList : 1, + m_bFrameActionRegistered : 1, + m_bUpdateControllers : 1; + + sal_Int16 m_eSymbolSize; + + VclPtr m_pToolBar; + + OUString m_aModuleIdentifier; + OUString m_aResourceName; + + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; + css::uno::Reference< css::frame::XFrame > m_xFrame; + ToolBarControllerMap m_aControllerMap; + osl::Mutex m_mutex; + ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::frame::XUIControllerFactory > m_xToolbarControllerFactory; + css::uno::Reference< css::ui::XImageManager > m_xModuleImageManager; + css::uno::Reference< css::ui::XImageManager > m_xDocImageManager; + + CommandToInfoMap m_aCommandMap; + SubToolBarToSubToolBarControllerMap m_aSubToolBarControllerMap; + Timer m_aAsyncUpdateControllersTimer; + OUString m_sIconTheme; + + rtl::Reference< ToolBarManager > m_aOverflowManager; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/toolbarmerger.hxx b/framework/inc/uielement/toolbarmerger.hxx new file mode 100644 index 000000000..95ca6cc01 --- /dev/null +++ b/framework/inc/uielement/toolbarmerger.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMERGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMERGER_HXX + +#include + +#include +#include + +#include +#include +#include + +namespace framework +{ + +struct AddonsParams +{ + OUString aImageId; + OUString aControlType; + sal_uInt16 nWidth; +}; + +struct AddonToolbarItem +{ + OUString aCommandURL; + OUString aLabel; + OUString aImageIdentifier; + OUString aTarget; + OUString aContext; + OUString aControlType; + sal_uInt16 nWidth; +}; + +typedef ::std::vector< AddonToolbarItem > AddonToolbarItemContainer; + +struct ReferenceToolbarPathInfo +{ + ToolBox::ImplToolItems::size_type nPos; + bool bResult; +}; + +class ToolBarMerger +{ + public: + static bool IsCorrectContext( const OUString& aContext, const OUString& aModuleIdentifier ); + + static void ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence, + AddonToolbarItemContainer& rContainer ); + + static void ConvertSequenceToValues( const css::uno::Sequence< css::beans::PropertyValue >& rSequence, + OUString& rCommandURL, + OUString& rLabel, + OUString& rImageIdentifier, + OUString& rTarget, + OUString& rContext, + OUString& rControlType, + sal_uInt16& rWidth ); + + static ReferenceToolbarPathInfo FindReferencePoint( const ToolBox* pToolbar, + const OUString& rReferencePoint ); + + static bool ProcessMergeOperation( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + sal_uInt16& rItemId, + CommandToInfoMap& rCommandMap, + const OUString& rModuleIdentifier, + const OUString& rMergeCommand, + const OUString& rMergeCommandParameter, + const AddonToolbarItemContainer& rItems ); + + static bool ProcessMergeFallback( ToolBox* pToolbar, + sal_uInt16& rItemId, + CommandToInfoMap& rCommandMap, + const OUString& rModuleIdentifier, + const OUString& rMergeCommand, + const OUString& rMergeFallback, + const AddonToolbarItemContainer& rItems ); + + static void MergeItems( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + sal_uInt16 nModIndex, + sal_uInt16& rItemId, + CommandToInfoMap& rCommandMap, + const OUString& rModuleIdentifier, + const AddonToolbarItemContainer& rAddonToolbarItems ); + + static void ReplaceItem( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + sal_uInt16& rItemId, + CommandToInfoMap& rCommandMap, + const OUString& rModuleIdentifier, + const AddonToolbarItemContainer& rAddonToolbarItems ); + + static void RemoveItems( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + const OUString& rMergeCommandParameter ); + + static ::cppu::OWeakObject* CreateController( + const css::uno::Reference< css::uno::XComponentContext > & rxContext, + const css::uno::Reference< css::frame::XFrame > & xFrame, + ToolBox* pToolbar, + const OUString& rCommandURL, + sal_uInt16 nId, + sal_uInt16 nWidth, + const OUString& rControlType ); + + static void CreateToolbarItem( ToolBox* pToolbox, + ToolBox::ImplToolItems::size_type nPos, + sal_uInt16 nItemId, + const AddonToolbarItem& rAddonToolbarItem ); + + private: + ToolBarMerger( const ToolBarMerger& ) = delete; + ToolBarMerger& operator=( const ToolBarMerger& ) = delete; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMERGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/toolbarmodemenucontroller.hxx b/framework/inc/uielement/toolbarmodemenucontroller.hxx new file mode 100644 index 000000000..28ec1de1c --- /dev/null +++ b/framework/inc/uielement/toolbarmodemenucontroller.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMODEMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMODEMENUCONTROLLER_HXX + +#include + +#include +#include + +#include + +namespace framework +{ + class ToolbarModeMenuController final : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + ToolbarModeMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~ToolbarModeMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XPopupMenuController + virtual void SAL_CALL setPopupMenu( const css::uno::Reference< css::awt::XPopupMenu >& PopupMenu ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XMenuListener + virtual void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) override; + virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + struct ExecuteInfo + { + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + css::uno::Sequence< css::beans::PropertyValue > aArgs; + }; + + DECL_STATIC_LINK( ToolbarModeMenuController, ExecuteHdl_Impl, void*, void ); + + private: + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARMODEMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/toolbarsmenucontroller.hxx b/framework/inc/uielement/toolbarsmenucontroller.hxx new file mode 100644 index 000000000..3d128f52e --- /dev/null +++ b/framework/inc/uielement/toolbarsmenucontroller.hxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace framework +{ + class ToolbarsMenuController final : public svt::PopupMenuControllerBase + { + using svt::PopupMenuControllerBase::disposing; + + public: + ToolbarsMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~ToolbarsMenuController() override; + + // XServiceInfo + DECLARE_XSERVICEINFO_NOFACTORY + /* Helper for registry */ + /// @throws css::uno::Exception + static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); + + // XPopupMenuController + virtual void SAL_CALL setPopupMenu( const css::uno::Reference< css::awt::XPopupMenu >& PopupMenu ) override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XStatusListener + virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override; + + // XMenuListener + virtual void SAL_CALL itemSelected( const css::awt::MenuEvent& rEvent ) override; + virtual void SAL_CALL itemActivated( const css::awt::MenuEvent& rEvent ) override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + struct ExecuteInfo + { + css::uno::Reference< css::frame::XDispatch > xDispatch; + css::util::URL aTargetURL; + css::uno::Sequence< css::beans::PropertyValue > aArgs; + }; + + DECL_STATIC_LINK( ToolbarsMenuController, ExecuteHdl_Impl, void*, void ); + + private: + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > getLayoutManagerToolbars( const css::uno::Reference< css::frame::XLayoutManager >& rLayoutManager ); + css::uno::Reference< css::frame::XDispatch > getDispatchFromCommandURL( const OUString& rCommandURL ); + void addCommand( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu, const OUString& rCommandURL, const OUString& aLabel ); + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::container::XNameAccess > m_xPersistentWindowState; + css::uno::Reference< css::ui::XUIConfigurationManager > m_xModuleCfgMgr; + css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocCfgMgr; + bool m_bResetActive; + std::vector< OUString > m_aCommandVector; + IntlWrapper m_aIntlWrapper; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARSMENUCONTROLLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/toolbarwrapper.hxx b/framework/inc/uielement/toolbarwrapper.hxx new file mode 100644 index 000000000..60d5759f6 --- /dev/null +++ b/framework/inc/uielement/toolbarwrapper.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARWRAPPER_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARWRAPPER_HXX + +#include + +#include +#include +#include + +namespace framework +{ + +class ToolBarManager; +class ToolBarWrapper final : public css::ui::XUIFunctionListener, + public UIConfigElementWrapperBase +{ + public: + ToolBarWrapper( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~ToolBarWrapper() override; + + // XInterface + virtual void SAL_CALL acquire() throw() override; + virtual void SAL_CALL release() throw() override; + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // XInitialization + virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override; + + // XUIElement + virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getRealInterface() override; + + // XUpdatable + virtual void SAL_CALL update() override; + + // XUIElementSettings + virtual void SAL_CALL updateSettings() override; + + // XUIFunctionListener + virtual void SAL_CALL functionExecute( const OUString& aUIElementName, const OUString& aCommand ) override; + + // XEventListener + using cppu::OPropertySetHelper::disposing; + virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override; + + private: + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& aValue ) override; + virtual void impl_fillNewData() override; + + css::uno::Reference< css::lang::XComponent > m_xToolBarManager; + css::uno::Reference< css::uno::XComponentContext > m_xContext; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_TOOLBARWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/uicommanddescription.hxx b/framework/inc/uielement/uicommanddescription.hxx new file mode 100644 index 000000000..6886224ce --- /dev/null +++ b/framework/inc/uielement/uicommanddescription.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace framework +{ +typedef ::cppu::WeakComponentImplHelper< css::lang::XServiceInfo, + css::container::XNameAccess > UICommandDescription_BASE; + +class UICommandDescription : private cppu::BaseMutex, + public UICommandDescription_BASE +{ + public: + UICommandDescription( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~UICommandDescription() override; + + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.comp.framework.UICommandDescription"; + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override + { + css::uno::Sequence< OUString > aSeq { "com.sun.star.frame.UICommandDescription" }; + return aSeq; + } + +private: + // XNameAccess + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override; + + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override; + + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override; + + // XElementAccess + virtual css::uno::Type SAL_CALL getElementType() override; + virtual sal_Bool SAL_CALL hasElements() override; + +public: + typedef std::unordered_map< OUString, + OUString > ModuleToCommandFileMap; + + typedef std::unordered_map< OUString, + css::uno::Reference< css::container::XNameAccess > > UICommandsHashMap; + + protected: + UICommandDescription( const css::uno::Reference< css::uno::XComponentContext>& rxContext, bool ); + void impl_fillElements(const char* _pName); + + OUString m_aPrivateResourceURL; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + ModuleToCommandFileMap m_aModuleToCommandFileMap; + UICommandsHashMap m_aUICommandsHashMap; + css::uno::Reference< css::container::XNameAccess > m_xGenericUICommands; + css::uno::Reference< css::frame::XModuleManager2 > m_xModuleManager; +}; + +} // namespace framework + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/uielement.hxx b/framework/inc/uielement/uielement.hxx new file mode 100644 index 000000000..9e63b1c0f --- /dev/null +++ b/framework/inc/uielement/uielement.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_UIELEMENT_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_UIELEMENT_HXX + +#include +#include +#include +#include + +#include +#include + +namespace framework +{ + +struct DockedData +{ + DockedData() : m_aPos( SAL_MAX_INT32, SAL_MAX_INT32 ), + m_nDockedArea( css::ui::DockingArea_DOCKINGAREA_TOP ), + m_bLocked( false ) {} + + css::awt::Point m_aPos; + css::ui::DockingArea m_nDockedArea; + bool m_bLocked; +}; + +struct FloatingData +{ + FloatingData() : m_aPos( SAL_MAX_INT32, SAL_MAX_INT32 ), + m_nLines( 1 ), + m_bIsHorizontal( true ) {} + + css::awt::Point m_aPos; + css::awt::Size m_aSize; + ToolBox::ImplToolItems::size_type m_nLines; + bool m_bIsHorizontal; +}; + +struct UIElement +{ + UIElement() : m_bFloating( false ), + m_bVisible( true ), + m_bUserActive( false ), + m_bMasterHide( false ), + m_bContextSensitive( false ), + m_bNoClose( false ), + m_bStateRead( false ), + m_nStyle( ButtonType::SYMBOLONLY ) + {} + + UIElement( const OUString& rName, + const OUString& rType, + const css::uno::Reference< css::ui::XUIElement >& rUIElement + ) : m_aType( rType ), + m_aName( rName ), + m_xUIElement( rUIElement ), + m_bFloating( false ), + m_bVisible( true ), + m_bUserActive( false ), + m_bMasterHide( false ), + m_bContextSensitive( false ), + m_bNoClose( false ), + m_bStateRead( false ), + m_nStyle( ButtonType::SYMBOLONLY ) {} + + bool operator< ( const UIElement& aUIElement ) const; + + OUString m_aType; + OUString m_aName; + OUString m_aUIName; + css::uno::Reference< css::ui::XUIElement > m_xUIElement; + bool m_bFloating, + m_bVisible, + m_bUserActive, + m_bMasterHide, + m_bContextSensitive; + bool m_bNoClose, + m_bStateRead; + ButtonType m_nStyle; + DockedData m_aDockedData; + FloatingData m_aFloatingData; +}; + +typedef std::vector< UIElement > UIElementVector; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_UIELEMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uielement/uielementtypenames.hxx b/framework/inc/uielement/uielementtypenames.hxx new file mode 100644 index 000000000..cd5617a8a --- /dev/null +++ b/framework/inc/uielement/uielementtypenames.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIELEMENT_UIELEMENTTYPENAMES_HXX +#define INCLUDED_FRAMEWORK_INC_UIELEMENT_UIELEMENTTYPENAMES_HXX + +#define UIELEMENTTYPE_MENUBAR_NAME "menubar" +#define UIELEMENTTYPE_POPUPMENU_NAME "popupmenu" +#define UIELEMENTTYPE_TOOLBAR_NAME "toolbar" +#define UIELEMENTTYPE_STATUSBAR_NAME "statusbar" +#define UIELEMENTTYPE_FLOATINGWINDOW_NAME "floater" +#define UIELEMENTTYPE_PROGRESSBAR_NAME "progressbar" +#define UIELEMENTTYPE_TOOLPANEL_NAME "toolpanel" + +#endif // INCLUDED_FRAMEWORK_INC_UIELEMENT_UIELEMENTTYPENAMES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uifactory/configurationaccessfactorymanager.hxx b/framework/inc/uifactory/configurationaccessfactorymanager.hxx new file mode 100644 index 000000000..4f186107a --- /dev/null +++ b/framework/inc/uifactory/configurationaccessfactorymanager.hxx @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_CONFIGURATIONACCESSFACTORYMANAGER_HXX +#define INCLUDED_FRAMEWORK_INC_UIFACTORY_CONFIGURATIONACCESSFACTORYMANAGER_HXX + +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace framework { + +class ConfigurationAccess_FactoryManager final : public ::cppu::WeakImplHelper< css::container::XContainerListener> +{ + public: + ConfigurationAccess_FactoryManager( const css::uno::Reference< css::uno::XComponentContext>& rxContext, const OUString& _sRoot ); + virtual ~ConfigurationAccess_FactoryManager() override; + + void readConfigurationData(); + + OUString getFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule ) const; + void addFactorySpecifierToTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule, const OUString& aServiceSpecifier ); + void removeFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule ); + css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > getFactoriesDescription() const; + + // container.XContainerListener + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // lang.XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + private: + class FactoryManagerMap : public std::unordered_map + { + }; + + bool impl_getElementProps( const css::uno::Any& rElement, OUString& rType, OUString& rName, OUString& rModule, OUString& rServiceSpecifier ) const; + + mutable osl::Mutex m_aMutex; + OUString m_aPropType; + OUString m_aPropName; + OUString m_aPropModule; + OUString m_aPropFactory; + OUString m_sRoot; + FactoryManagerMap m_aFactoryManagerMap; + css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider; + css::uno::Reference< css::container::XNameAccess > m_xConfigAccess; + css::uno::Reference< css::container::XContainerListener > m_xConfigListener; + bool m_bConfigAccessInitialized; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_CONFIGURATIONACCESSFACTORYMANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uifactory/factoryconfiguration.hxx b/framework/inc/uifactory/factoryconfiguration.hxx new file mode 100644 index 000000000..fad809575 --- /dev/null +++ b/framework/inc/uifactory/factoryconfiguration.hxx @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_FACTORYCONFIGURATION_HXX +#define INCLUDED_FRAMEWORK_INC_UIFACTORY_FACTORYCONFIGURATION_HXX + +#include +#include +#include +#include + +#include +#include +#include + +// Namespace + +namespace framework +{ + +// Configuration access class for PopupMenuControllerFactory implementation + +class ConfigurationAccess_ControllerFactory final : // interfaces + public ::cppu::WeakImplHelper< css::container::XContainerListener> +{ +public: + ConfigurationAccess_ControllerFactory( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const OUString& _sRoot ); + virtual ~ConfigurationAccess_ControllerFactory() override; + + void readConfigurationData(); + void updateConfigurationData(); + + OUString getServiceFromCommandModule( const OUString& rCommandURL, const OUString& rModule ) const; + OUString getValueFromCommandModule( const OUString& rCommandURL, const OUString& rModule ) const; + void addServiceToCommandModule( const OUString& rCommandURL, const OUString& rModule, const OUString& rServiceSpecifier ); + void removeServiceFromCommandModule( const OUString& rCommandURL, const OUString& rModule ); + + // container.XContainerListener + virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; + virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; + + // lang.XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + +private: + struct ControllerInfo + { + OUString m_aImplementationName; + OUString m_aValue; + ControllerInfo(const OUString& _aImplementationName,const OUString& _aValue) : m_aImplementationName(_aImplementationName),m_aValue(_aValue){} + ControllerInfo(){} + }; + class MenuControllerMap : public std::unordered_map< OUString, + ControllerInfo > + { + }; + + bool impl_getElementProps( const css::uno::Any& aElement, OUString& aCommand, OUString& aModule, OUString& aServiceSpecifier,OUString& aValue ) const; + + mutable osl::Mutex m_mutex; + OUString m_aPropCommand; + OUString m_aPropModule; + OUString m_aPropController; + OUString m_aPropValue; + OUString m_sRoot; + MenuControllerMap m_aMenuControllerMap; + css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider; + css::uno::Reference< css::container::XNameAccess > m_xConfigAccess; + css::uno::Reference< css::container::XContainerListener > m_xConfigAccessListener; + bool m_bConfigAccessInitialized; +}; + +} // namespace framework +#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_FACTORYCONFIGURATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/uifactory/menubarfactory.hxx b/framework/inc/uifactory/menubarfactory.hxx new file mode 100644 index 000000000..cadb67363 --- /dev/null +++ b/framework/inc/uifactory/menubarfactory.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_MENUBARFACTORY_HXX +#define INCLUDED_FRAMEWORK_INC_UIFACTORY_MENUBARFACTORY_HXX + +#include +#include +#include +#include + +#include +#include +#include + +namespace framework +{ +typedef ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::ui::XUIElementFactory> MenuBarFactory_BASE; + + class MenuBarFactory : public MenuBarFactory_BASE + { + public: + MenuBarFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~MenuBarFactory() override; + + virtual OUString SAL_CALL getImplementationName() override + { + return "com.sun.star.comp.framework.MenuBarFactory"; + } + + virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override + { + return cppu::supportsService(this, ServiceName); + } + + virtual css::uno::Sequence SAL_CALL getSupportedServiceNames() override + { + css::uno::Sequence< OUString > aSeq { "com.sun.star.ui.UIElementFactory" }; + return aSeq; + } + + // XUIElementFactory + virtual css::uno::Reference< css::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const css::uno::Sequence< css::beans::PropertyValue >& Args ) override; + + static void CreateUIElement(const OUString& ResourceURL + ,const css::uno::Sequence< css::beans::PropertyValue >& Args + ,const OUString& ResourceType + ,const css::uno::Reference< css::ui::XUIElement >& _xMenuBar + ,const css::uno::Reference< css::uno::XComponentContext >& _rxContext); + + protected: + css::uno::Reference< css::uno::XComponentContext > m_xContext; + }; +} + +#endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_MENUBARFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/acceleratorconfigurationreader.hxx b/framework/inc/xml/acceleratorconfigurationreader.hxx new file mode 100644 index 000000000..76a0a159c --- /dev/null +++ b/framework/inc/xml/acceleratorconfigurationreader.hxx @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONREADER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONREADER_HXX + +#include + +#include + +#include + +#include +#include + +namespace framework{ + +class AcceleratorConfigurationReader final : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > +{ + + // const, types + + private: + + /** @short classification of XML elements. */ + enum EXMLElement + { + E_ELEMENT_ACCELERATORLIST, + E_ELEMENT_ITEM + }; + + /** @short classification of XML attributes. */ + enum EXMLAttribute + { + E_ATTRIBUTE_KEYCODE, + E_ATTRIBUTE_MOD_SHIFT, + E_ATTRIBUTE_MOD_MOD1, + E_ATTRIBUTE_MOD_MOD2, + E_ATTRIBUTE_MOD_MOD3, + E_ATTRIBUTE_URL + }; + + // member + + private: + + /** @short reference to the outside container, where this + reader/writer must work on. */ + AcceleratorCache& m_rContainer; + + /** @short used to detect if an accelerator list + occurs recursive inside xml. */ + bool m_bInsideAcceleratorList; + + /** @short used to detect if an accelerator item + occurs recursive inside xml. */ + bool m_bInsideAcceleratorItem; + + /** @short provide information about the parsing state. + + @descr We use it to find out the line and column, where + an error occurred. + */ + css::uno::Reference< css::xml::sax::XLocator > m_xLocator; + + // interface + + public: + + /** @short connect this new reader/writer instance + to an outside container, which should be used + flushed to the underlying XML configuration or + filled from there. + + @param rContainer + a reference to the outside container. + */ + AcceleratorConfigurationReader(AcceleratorCache& rContainer); + + /** @short does nothing real ... */ + virtual ~AcceleratorConfigurationReader() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement(const OUString& sElement , + const css::uno::Reference< css::xml::sax::XAttributeList >& xAttributeList) override; + + virtual void SAL_CALL endElement(const OUString& sElement) override; + + virtual void SAL_CALL characters(const OUString& sChars) override; + + virtual void SAL_CALL ignorableWhitespace(const OUString& sWhitespaces) override; + + virtual void SAL_CALL processingInstruction(const OUString& sTarget, + const OUString& sData ) override; + + virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator >& xLocator) override; + + // helper + + private: + + /** TODO document me */ + static EXMLElement implst_classifyElement(const OUString& sElement); + + /** TODO document me */ + static EXMLAttribute implst_classifyAttribute(const OUString& sAttribute); + + /** TODO document me */ + OUString implts_getErrorLineString(); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONREADER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/acceleratorconfigurationwriter.hxx b/framework/inc/xml/acceleratorconfigurationwriter.hxx new file mode 100644 index 000000000..f66b5f6da --- /dev/null +++ b/framework/inc/xml/acceleratorconfigurationwriter.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONWRITER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONWRITER_HXX + +#include + +#include +#include + +namespace framework{ + +class AcceleratorConfigurationWriter final +{ + + // member + + private: + + /** @short needed to write the xml configuration. */ + css::uno::Reference< css::xml::sax::XDocumentHandler > m_xConfig; + + /** @short reference to the outside container, where this + writer must work on. */ + const AcceleratorCache& m_rContainer; + + // interface + + public: + + /** @short connect this new writer instance + to an outside container, which should be + flushed to the underlying XML configuration. + + @param rContainer + a reference to the outside container. + + @param xConfig + used to write the configuration there. + */ + AcceleratorConfigurationWriter(const AcceleratorCache& rContainer, + const css::uno::Reference< css::xml::sax::XDocumentHandler >& xConfig ); + + /** @short does nothing real ... */ + ~AcceleratorConfigurationWriter(); + + /** @short TODO */ + void flush(); + + // helper + + private: + + /** @short TODO */ + void impl_ts_writeKeyCommandPair(const css::awt::KeyEvent& aKey , + const OUString& sCommand, + const css::uno::Reference< css::xml::sax::XDocumentHandler >& xConfig ); +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_XML_ACCELERATORCONFIGURATIONWRITER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx new file mode 100644 index 000000000..cadf20e92 --- /dev/null +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_IMAGESCONFIGURATION_HXX +#define INCLUDED_FRAMEWORK_INC_XML_IMAGESCONFIGURATION_HXX + +#include +#include +#include + +#include + +namespace framework +{ + +struct ImageItemDescriptor +{ + OUString aCommandURL; // URL command to dispatch +}; + +typedef std::vector ImageItemDescriptorList; + +class ImagesConfiguration +{ + public: + static bool LoadImages( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::io::XInputStream >& rInputStream, + ImageItemDescriptorList& rItems ); + + static bool StoreImages( + const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::io::XOutputStream >& rOutputStream, + const ImageItemDescriptorList& rItems ); +}; + +} // namespace framework + +#endif // __FRAMEWORK_CLASSES_IMAGES + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx new file mode 100644 index 000000000..f9cbd6122 --- /dev/null +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_IMAGESDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_IMAGESDOCUMENTHANDLER_HXX + +#include + +#include +#include +#include + +#include + +namespace framework{ + +// Hash code function for using in all hash maps of follow implementation. + +class OReadImagesDocumentHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > +{ + public: + enum Image_XML_Entry + { + IMG_ELEMENT_IMAGECONTAINER, + IMG_ELEMENT_IMAGES, + IMG_ELEMENT_ENTRY, + IMG_ELEMENT_EXTERNALIMAGES, + IMG_ELEMENT_EXTERNALENTRY, + IMG_ATTRIBUTE_HREF, + IMG_ATTRIBUTE_MASKCOLOR, + IMG_ATTRIBUTE_COMMAND, + IMG_ATTRIBUTE_BITMAPINDEX, + IMG_ATTRIBUTE_MASKURL, + IMG_ATTRIBUTE_MASKMODE, + IMG_ATTRIBUTE_HIGHCONTRASTURL, + IMG_ATTRIBUTE_HIGHCONTRASTMASKURL, + IMG_XML_ENTRY_COUNT + }; + + enum Image_XML_Namespace + { + IMG_NS_IMAGE, + IMG_NS_XLINK + }; + + OReadImagesDocumentHandler( ImageItemDescriptorList& aItems ); + virtual ~OReadImagesDocumentHandler() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override; + + virtual void SAL_CALL processingInstruction(const OUString& aTarget, + const OUString& aData) override; + + virtual void SAL_CALL setDocumentLocator( + const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override; + + private: + OUString getErrorLineString(); + + class ImageHashMap : public std::unordered_map< OUString, Image_XML_Entry > + { + }; + + bool m_bImageContainerStartFound; + bool m_bImageContainerEndFound; + bool m_bImagesStartFound; + ImageHashMap m_aImageMap; + ImageItemDescriptorList& m_rImageList; + css::uno::Reference< css::xml::sax::XLocator > m_xLocator; +}; + +class OWriteImagesDocumentHandler final +{ + public: + OWriteImagesDocumentHandler( + const ImageItemDescriptorList& aItems, + css::uno::Reference< css::xml::sax::XDocumentHandler > const & + rWriteDocumentHandler); + ~OWriteImagesDocumentHandler(); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteImagesDocument(); + + private: + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteImageList( const ImageItemDescriptorList* ); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteImage( const ImageItemDescriptor* ); + + const ImageItemDescriptorList& m_rImageItemList; + css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; + css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList; + OUString m_aXMLImageNS; + OUString m_aAttributeType; + OUString m_aAttributeXlinkType; + OUString m_aAttributeValueSimple; +}; + +} // namespace framework + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/menudocumenthandler.hxx b/framework/inc/xml/menudocumenthandler.hxx new file mode 100644 index 000000000..236e83591 --- /dev/null +++ b/framework/inc/xml/menudocumenthandler.hxx @@ -0,0 +1,226 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace framework{ + +class ReadMenuDocumentHandlerBase : public ::cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > +{ + public: + ReadMenuDocumentHandlerBase(); + virtual ~ReadMenuDocumentHandlerBase() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override = 0; + + virtual void SAL_CALL endDocument() override = 0; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override = 0; + + virtual void SAL_CALL endElement(const OUString& aName) override = 0; + + virtual void SAL_CALL characters(const OUString& aChars) override = 0; + + virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override; + + virtual void SAL_CALL processingInstruction(const OUString& aTarget, + const OUString& aData) override; + + virtual void SAL_CALL setDocumentLocator( + const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override; + + protected: + OUString getErrorLineString(); + + css::uno::Reference< css::xml::sax::XLocator > m_xLocator; + css::uno::Reference< css::xml::sax::XDocumentHandler> m_xReader; + void initPropertyCommon( css::uno::Sequence< css::beans::PropertyValue > &rProps, + const OUString &rCommandURL, const OUString &rHelpId, + const OUString &rLabel, sal_Int16 nItemStyleBits ); + private: + OUString m_aType; + OUString m_aLabel; + OUString m_aContainer; + OUString m_aHelpURL; + OUString m_aCommandURL; + OUString m_aStyle; +}; + +class OReadMenuDocumentHandler final : public ReadMenuDocumentHandlerBase +{ + public: + OReadMenuDocumentHandler( + const css::uno::Reference< css::container::XIndexContainer >& rItemContainer ); + virtual ~OReadMenuDocumentHandler() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + private: + int m_nElementDepth; + enum class ReaderMode { None, MenuBar, MenuPopup }; + ReaderMode m_eReaderMode; + css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer; + css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory; +}; // OReadMenuDocumentHandler + +class OReadMenuBarHandler final : public ReadMenuDocumentHandlerBase +{ + public: + OReadMenuBarHandler( + const css::uno::Reference< css::container::XIndexContainer >& rMenuBarContainer, + const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory ); + virtual ~OReadMenuBarHandler() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + private: + int m_nElementDepth; + bool m_bMenuMode; + css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer; + css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory; +}; // OReadMenuBarHandler + +class OReadMenuHandler final : public ReadMenuDocumentHandlerBase +{ + public: + OReadMenuHandler( const css::uno::Reference< css::container::XIndexContainer >& rMenuContainer, + const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory ); + virtual ~OReadMenuHandler() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + private: + int m_nElementDepth; + bool m_bMenuPopupMode; + css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer; + css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory; +}; // OReadMenuHandler + +class OReadMenuPopupHandler final : public ReadMenuDocumentHandlerBase +{ + public: + OReadMenuPopupHandler( const css::uno::Reference< css::container::XIndexContainer >& rMenuContainer, + const css::uno::Reference< css::lang::XSingleComponentFactory >& rContainerFactory ); + virtual ~OReadMenuPopupHandler() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< + css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + private: + enum NextElementClose { ELEM_CLOSE_NONE, ELEM_CLOSE_MENUITEM, ELEM_CLOSE_MENUSEPARATOR }; + + int m_nElementDepth; + bool m_bMenuMode; + css::uno::Reference< css::container::XIndexContainer > m_xMenuContainer; + css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory; + css::uno::Reference< css::uno::XComponentContext > m_xComponentContext; + NextElementClose m_nNextElementExpected; +}; // OReadMenuPopupHandler + +class OWriteMenuDocumentHandler final +{ + public: + OWriteMenuDocumentHandler( + const css::uno::Reference< css::container::XIndexAccess >& rMenuBarContainer, + const css::uno::Reference< css::xml::sax::XDocumentHandler >& rDocumentHandler, + bool bIsMenuBar ); + ~OWriteMenuDocumentHandler(); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteMenuDocument(); + private: + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteMenu( const css::uno::Reference< css::container::XIndexAccess >& rSubMenuContainer ); + + void WriteMenuItem( const OUString& aCommandURL, const OUString& aLabel, const OUString& aHelpURL, sal_Int16 nStyle ); + void WriteMenuSeparator(); + + css::uno::Reference< css::container::XIndexAccess > m_xMenuBarContainer; + css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; + css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList; + OUString m_aAttributeType; + bool m_bIsMenuBar; +}; + +} // namespace framework + +#endif // INCLUDED_FRAMEWORK_INC_XML_MENUDOCUMENTHANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/saxnamespacefilter.hxx b/framework/inc/xml/saxnamespacefilter.hxx new file mode 100644 index 000000000..620ebd03d --- /dev/null +++ b/framework/inc/xml/saxnamespacefilter.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_SAXNAMESPACEFILTER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_SAXNAMESPACEFILTER_HXX + +#include +#include +#include +#include +#include + +#include +#include + +namespace framework +{ + +// workaround for incremental linking bugs in MSVC2015 +class SAL_DLLPUBLIC_TEMPLATE SaxNamespaceFilter_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {}; + +class UNLESS_MERGELIBS(FWE_DLLPUBLIC) SaxNamespaceFilter final : public SaxNamespaceFilter_Base +{ + public: + SaxNamespaceFilter( css::uno::Reference< css::xml::sax::XDocumentHandler > const & rSax1DocumentHandler ); + virtual ~SaxNamespaceFilter() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override; + + virtual void SAL_CALL processingInstruction(const OUString& aTarget, + const OUString& aData) override; + + virtual void SAL_CALL setDocumentLocator( + const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override; + + private: + typedef ::std::stack< XMLNamespaces > NamespaceStack; + + OUString getErrorLineString(); + + css::uno::Reference< css::xml::sax::XLocator > m_xLocator; + css::uno::Reference< css::xml::sax::XDocumentHandler> xDocumentHandler; + NamespaceStack m_aNamespaceStack; + + OUString m_aXMLAttributeNamespace; + OUString m_aXMLAttributeType; + +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_XML_SAXNAMESPACEFILTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/statusbardocumenthandler.hxx b/framework/inc/xml/statusbardocumenthandler.hxx new file mode 100644 index 000000000..9dea5b145 --- /dev/null +++ b/framework/inc/xml/statusbardocumenthandler.hxx @@ -0,0 +1,138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_STATUSBARDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_STATUSBARDOCUMENTHANDLER_HXX + +#include + +#include + +#include +#include + +#include +#include + +namespace framework{ + +// Hash code function for using in all hash maps of follow implementation. + +// workaround for incremental linking bugs in MSVC2015 +class SAL_DLLPUBLIC_TEMPLATE OReadStatusBarDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {}; + +class OReadStatusBarDocumentHandler final : public OReadStatusBarDocumentHandler_Base +{ + public: + enum StatusBar_XML_Entry + { + SB_ELEMENT_STATUSBAR, + SB_ELEMENT_STATUSBARITEM, + SB_ATTRIBUTE_URL, + SB_ATTRIBUTE_ALIGN, + SB_ATTRIBUTE_STYLE, + SB_ATTRIBUTE_AUTOSIZE, + SB_ATTRIBUTE_OWNERDRAW, + SB_ATTRIBUTE_WIDTH, + SB_ATTRIBUTE_OFFSET, + SB_ATTRIBUTE_HELPURL, + SB_ATTRIBUTE_MANDATORY, + SB_XML_ENTRY_COUNT + }; + + enum StatusBar_XML_Namespace + { + SB_NS_STATUSBAR, + SB_NS_XLINK + }; + + OReadStatusBarDocumentHandler( const css::uno::Reference< css::container::XIndexContainer >& aStatusBarItems ); + virtual ~OReadStatusBarDocumentHandler() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override; + + virtual void SAL_CALL processingInstruction(const OUString& aTarget, + const OUString& aData) override; + + virtual void SAL_CALL setDocumentLocator( + const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override; + + private: + OUString getErrorLineString(); + + class StatusBarHashMap : public std::unordered_map + { + }; + + bool m_bStatusBarStartFound; + bool m_bStatusBarItemStartFound; + StatusBarHashMap m_aStatusBarMap; + css::uno::Reference< css::container::XIndexContainer > m_aStatusBarItems; + css::uno::Reference< css::xml::sax::XLocator > m_xLocator; +}; + +class OWriteStatusBarDocumentHandler final +{ + public: + OWriteStatusBarDocumentHandler( + const css::uno::Reference< css::container::XIndexAccess >& rStatusBarItems, + const css::uno::Reference< css::xml::sax::XDocumentHandler >& rWriteDocHandler ); + ~OWriteStatusBarDocumentHandler(); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteStatusBarDocument(); + + private: + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteStatusBarItem( + const OUString& rCommandURL, + sal_Int16 nOffset, + sal_Int16 nStyle, + sal_Int16 nWidth ); + + css::uno::Reference< css::container::XIndexAccess > m_aStatusBarItems; + css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; + css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList; + OUString m_aXMLStatusBarNS; + OUString m_aXMLXlinkNS; + OUString m_aAttributeType; + OUString m_aAttributeURL; +}; + +} // namespace framework + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/toolboxconfigurationdefines.hxx b/framework/inc/xml/toolboxconfigurationdefines.hxx new file mode 100644 index 000000000..505133bb5 --- /dev/null +++ b/framework/inc/xml/toolboxconfigurationdefines.hxx @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_FRAMEWORK_INC_XML_TOOLBOXCONFIGURATIONDEFINES_HXX +#define INCLUDED_FRAMEWORK_INC_XML_TOOLBOXCONFIGURATIONDEFINES_HXX + +#define XMLNS_TOOLBAR "http://openoffice.org/2001/toolbar" +#define XMLNS_XLINK "http://www.w3.org/1999/xlink" +#define XMLNS_TOOLBAR_PREFIX "toolbar:" +#define XMLNS_XLINK_PREFIX "xlink:" + +#define XMLNS_FILTER_SEPARATOR "^" + +#define ELEMENT_TOOLBAR "toolbar" +#define ELEMENT_TOOLBARITEM "toolbaritem" +#define ELEMENT_TOOLBARSPACE "toolbarspace" +#define ELEMENT_TOOLBARBREAK "toolbarbreak" +#define ELEMENT_TOOLBARSEPARATOR "toolbarseparator" + +#define ATTRIBUTE_UINAME "uiname" + +#define ATTRIBUTE_TEXT "text" +#define ATTRIBUTE_URL "href" +#define ATTRIBUTE_VISIBLE "visible" +#define ATTRIBUTE_ITEMSTYLE "style" + +#define ELEMENT_NS_TOOLBAR "toolbar:toolbar" +#define ELEMENT_NS_TOOLBARITEM "toolbar:toolbaritem" +#define ELEMENT_NS_TOOLBARSPACE "toolbar:toolbarspace" +#define ELEMENT_NS_TOOLBARBREAK "toolbar:toolbarbreak" +#define ELEMENT_NS_TOOLBARSEPARATOR "toolbar:toolbarseparator" + +#define ATTRIBUTE_XMLNS_TOOLBAR "xmlns:toolbar" +#define ATTRIBUTE_XMLNS_XLINK "xmlns:xlink" + +#define ATTRIBUTE_TYPE_CDATA "CDATA" + +#define ATTRIBUTE_BOOLEAN_TRUE "true" +#define ATTRIBUTE_BOOLEAN_FALSE "false" + +#define ATTRIBUTE_ITEMSTYLE_RADIO "radio" +#define ATTRIBUTE_ITEMSTYLE_AUTO "auto" +#define ATTRIBUTE_ITEMSTYLE_LEFT "left" +#define ATTRIBUTE_ITEMSTYLE_AUTOSIZE "autosize" +#define ATTRIBUTE_ITEMSTYLE_DROPDOWN "dropdown" +#define ATTRIBUTE_ITEMSTYLE_REPEAT "repeat" +#define ATTRIBUTE_ITEMSTYLE_TEXT "text" +#define ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY "dropdownonly" +#define ATTRIBUTE_ITEMSTYLE_IMAGE "image" + +#endif // INCLUDED_FRAMEWORK_INC_XML_TOOLBOXCONFIGURATIONDEFINES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/toolboxdocumenthandler.hxx b/framework/inc/xml/toolboxdocumenthandler.hxx new file mode 100644 index 000000000..db9184605 --- /dev/null +++ b/framework/inc/xml/toolboxdocumenthandler.hxx @@ -0,0 +1,162 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX +#define INCLUDED_FRAMEWORK_INC_XML_TOOLBOXDOCUMENTHANDLER_HXX + +#include + +#include + +#include +#include +#include + +#include + +namespace framework{ + +// Hash code function for using in all hash maps of follow implementation. + +// workaround for incremental linking bugs in MSVC2015 +class SAL_DLLPUBLIC_TEMPLATE OReadToolBoxDocumentHandler_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {}; + +class OReadToolBoxDocumentHandler final : public OReadToolBoxDocumentHandler_Base +{ + public: + enum ToolBox_XML_Entry + { + TB_ELEMENT_TOOLBAR, + TB_ELEMENT_TOOLBARITEM, + TB_ELEMENT_TOOLBARSPACE, + TB_ELEMENT_TOOLBARBREAK, + TB_ELEMENT_TOOLBARSEPARATOR, + TB_ATTRIBUTE_TEXT, + TB_ATTRIBUTE_URL, + TB_ATTRIBUTE_VISIBLE, + TB_ATTRIBUTE_STYLE, + TB_ATTRIBUTE_UINAME, + TB_XML_ENTRY_COUNT + }; + + enum ToolBox_XML_Namespace + { + TB_NS_TOOLBAR, + TB_NS_XLINK + }; + + OReadToolBoxDocumentHandler( const css::uno::Reference< css::container::XIndexContainer >& rItemContainer ); + virtual ~OReadToolBoxDocumentHandler() override; + + // XDocumentHandler + virtual void SAL_CALL startDocument() override; + + virtual void SAL_CALL endDocument() override; + + virtual void SAL_CALL startElement( + const OUString& aName, + const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override; + + virtual void SAL_CALL endElement(const OUString& aName) override; + + virtual void SAL_CALL characters(const OUString& aChars) override; + + virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override; + + virtual void SAL_CALL processingInstruction(const OUString& aTarget, + const OUString& aData) override; + + virtual void SAL_CALL setDocumentLocator( + const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override; + + private: + OUString getErrorLineString(); + + class ToolBoxHashMap : public std::unordered_map + { + }; + + bool m_bToolBarStartFound : 1; + bool m_bToolBarItemStartFound : 1; + bool m_bToolBarSpaceStartFound : 1; + bool m_bToolBarBreakStartFound : 1; + bool m_bToolBarSeparatorStartFound : 1; + ToolBoxHashMap m_aToolBoxMap; + css::uno::Reference< css::container::XIndexContainer > m_rItemContainer; + css::uno::Reference< css::xml::sax::XLocator > m_xLocator; + + sal_Int32 m_nHashCode_Style_Radio; + sal_Int32 m_nHashCode_Style_Left; + sal_Int32 m_nHashCode_Style_AutoSize; + sal_Int32 m_nHashCode_Style_DropDown; + sal_Int32 m_nHashCode_Style_Repeat; + sal_Int32 m_nHashCode_Style_DropDownOnly; + sal_Int32 m_nHashCode_Style_Text; + sal_Int32 m_nHashCode_Style_Image; + OUString m_aType; + OUString m_aLabel; + OUString m_aStyle; + OUString m_aIsVisible; + OUString m_aCommandURL; +}; + +class OWriteToolBoxDocumentHandler final +{ + public: + OWriteToolBoxDocumentHandler( + const css::uno::Reference< css::container::XIndexAccess >& rItemAccess, + css::uno::Reference< css::xml::sax::XDocumentHandler > const & rDocumentHandler ); + ~OWriteToolBoxDocumentHandler(); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteToolBoxDocument(); + + private: + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteToolBoxItem( const OUString& aCommandURL, const OUString& aLabel, sal_Int16 nStyle, bool bVisible ); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteToolBoxSpace(); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteToolBoxBreak(); + + /// @throws css::xml::sax::SAXException + /// @throws css::uno::RuntimeException + void WriteToolBoxSeparator(); + + css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; + css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList; + css::uno::Reference< css::container::XIndexAccess > m_rItemAccess; + OUString m_aXMLToolbarNS; + OUString m_aXMLXlinkNS; + OUString m_aAttributeType; + OUString m_aAttributeURL; +}; + +} // namespace framework + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/framework/inc/xml/xmlnamespaces.hxx b/framework/inc/xml/xmlnamespaces.hxx new file mode 100644 index 000000000..5f0c9670e --- /dev/null +++ b/framework/inc/xml/xmlnamespaces.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_FRAMEWORK_INC_XML_XMLNAMESPACES_HXX +#define INCLUDED_FRAMEWORK_INC_XML_XMLNAMESPACES_HXX + +#include +#include + +#include + +namespace framework +{ + +class XMLNamespaces final +{ + public: + /// @throws css::xml::sax::SAXException + void addNamespace( const OUString& aName, const OUString& aValue ); + + /// @throws css::xml::sax::SAXException + OUString applyNSToAttributeName( const OUString& ) const; + /// @throws css::xml::sax::SAXException + OUString applyNSToElementName( const OUString& ) const; + + private: + typedef ::std::map< OUString, OUString > NamespaceMap; + + /// @throws css::xml::sax::SAXException + OUString const & getNamespaceValue( const OUString& aNamespace ) const; + + OUString m_aDefaultNamespace; + NamespaceMap m_aNamespaceMap; +}; + +} + +#endif // INCLUDED_FRAMEWORK_INC_XML_XMLNAMESPACES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3