diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /framework/inc | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'framework/inc')
125 files changed, 12224 insertions, 0 deletions
diff --git a/framework/inc/acceleratorconst.h b/framework/inc/acceleratorconst.h new file mode 100644 index 000000000..55f9435ff --- /dev/null +++ b/framework/inc/acceleratorconst.h @@ -0,0 +1,34 @@ +/* -*- 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 <rtl/ustring.hxx> + +namespace framework{ + +inline constexpr OUStringLiteral ATTRIBUTE_TYPE_CDATA = u"CDATA"; + +// same items with a name space alias +inline constexpr OUStringLiteral AL_ELEMENT_ACCELERATORLIST = u"accel:acceleratorlist"; +inline constexpr OUStringLiteral AL_ELEMENT_ITEM = u"accel:item"; + +} // namespace framework + +/* 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..d6f244cdc --- /dev/null +++ b/framework/inc/addonmenu.hxx @@ -0,0 +1,80 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <vcl/vclptr.hxx> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::uno { template <class E> class Sequence; } +namespace com::sun::star::uno { template <typename > class Reference; } + +class MenuBar; +class PopupMenu; + +#define ADDONMENU_ITEMID_START 2000 +#define ADDONMENU_ITEMID_END 3000 + +namespace framework +{ + +class AddonMenuManager +{ + public: + static bool HasAddonMenuElements(); + + // Check if the context string matches the provided xModel context + static bool IsCorrectContext(std::u16string_view rModuleIdentifier, std::u16string_view rContext); + + // Create the Add-Ons menu + static VclPtr<PopupMenu> 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& 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..78211ef9e --- /dev/null +++ b/framework/inc/bitmaps.hlst @@ -0,0 +1,39 @@ +/* -*- 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/. + */ + +#pragma once + +#include <rtl/ustring.hxx> + +inline constexpr OUStringLiteral BMP_SAVEMODIFIED_SMALL = u"res/savemodified_small.png"; +inline constexpr OUStringLiteral BMP_SAVEMODIFIED_LARGE = u"res/savemodified_large.png"; +inline constexpr OUStringLiteral BMP_SAVEMODIFIED_EXTRALARGE = u"res/savemodified_extralarge.png"; + +inline constexpr OUStringLiteral RID_SVXBMP_BUTTON = u"res/sx10594.png"; +inline constexpr OUStringLiteral RID_SVXBMP_RADIOBUTTON = u"res/sx10595.png"; +inline constexpr OUStringLiteral RID_SVXBMP_CHECKBOX = u"res/sx10596.png"; +inline constexpr OUStringLiteral RID_SVXBMP_FIXEDTEXT = u"res/sx10597.png"; +inline constexpr OUStringLiteral RID_SVXBMP_GROUPBOX = u"res/sx10598.png"; +inline constexpr OUStringLiteral RID_SVXBMP_EDITBOX = u"res/sx10599.png"; +inline constexpr OUStringLiteral RID_SVXBMP_LISTBOX = u"res/sx10600.png"; +inline constexpr OUStringLiteral RID_SVXBMP_COMBOBOX = u"res/sx10601.png"; +inline constexpr OUStringLiteral RID_SVXBMP_IMAGEBUTTON = u"res/sx10604.png"; +inline constexpr OUStringLiteral RID_SVXBMP_IMAGECONTROL = u"res/sx10710.png"; +inline constexpr OUStringLiteral RID_SVXBMP_FILECONTROL = u"res/sx10605.png"; +inline constexpr OUStringLiteral RID_SVXBMP_DATEFIELD = u"res/sx10704.png"; +inline constexpr OUStringLiteral RID_SVXBMP_TIMEFIELD = u"res/sx10705.png"; +inline constexpr OUStringLiteral RID_SVXBMP_NUMERICFIELD = u"res/sx10706.png"; +inline constexpr OUStringLiteral RID_SVXBMP_CURRENCYFIELD = u"res/sx10707.png"; +inline constexpr OUStringLiteral RID_SVXBMP_PATTERNFIELD = u"res/sx10708.png"; +inline constexpr OUStringLiteral RID_SVXBMP_FORMATTEDFIELD = u"res/sx10728.png"; +inline constexpr OUStringLiteral RID_SVXBMP_SCROLLBAR = u"res/sx10768.png"; +inline constexpr OUStringLiteral RID_SVXBMP_SPINBUTTON = u"res/sx10769.png"; +inline constexpr OUStringLiteral RID_SVXBMP_NAVIGATIONBAR = u"res/sx10607.png"; + +/* 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..71d4100d9 --- /dev/null +++ b/framework/inc/classes/actiontriggercontainer.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 . + */ + +#pragma once + +#include <helper/propertysetcontainer.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> + +inline constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGERCONTAINER = u"com.sun.star.ui.ActionTriggerContainer"; +inline constexpr OUStringLiteral IMPLEMENTATIONNAME_ACTIONTRIGGERCONTAINER = u"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() noexcept override; + virtual void SAL_CALL release() noexcept 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; +}; + +} + +/* 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..78d49e7ef --- /dev/null +++ b/framework/inc/classes/actiontriggerpropertyset.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 . + */ + +#pragma once + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/weak.hxx> +#include <rtl/ustring.hxx> + +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> + +inline constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGER = u"com.sun.star.ui.ActionTrigger"; +inline constexpr OUStringLiteral IMPLEMENTATIONNAME_ACTIONTRIGGER = u"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() noexcept override; + virtual void SAL_CALL release() noexcept 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; +}; + +} + +/* 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..b68493696 --- /dev/null +++ b/framework/inc/classes/actiontriggerseparatorpropertyset.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 . + */ + +#pragma once + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/weak.hxx> +#include <rtl/ustring.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> + +inline constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGERSEPARATOR = u"com.sun.star.ui.ActionTriggerSeparator"; +inline constexpr OUStringLiteral IMPLEMENTATIONNAME_ACTIONTRIGGERSEPARATOR = u"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() noexcept override; + virtual void SAL_CALL release() noexcept 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; +}; + +} + +/* 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..17198ec2c --- /dev/null +++ b/framework/inc/classes/converter.hxx @@ -0,0 +1,45 @@ +/* -*- 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 <vector> + +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <tools/datetime.hxx> + +namespace framework{ + +class Converter +{ + public: + // Seq<beans.NamedValue> <=> Seq<beans.PropertyValue> + static css::uno::Sequence< css::beans::NamedValue > convert_seqPropVal2seqNamedVal ( const css::uno::Sequence< css::beans::PropertyValue >& lSource ); + + // Seq<String> => Vector<String> + static std::vector<OUString> convert_seqOUString2OUStringList( const css::uno::Sequence< OUString >& lSource ); + + static OUString convert_DateTime2ISO8601 ( const DateTime& aSource ); +}; + +} // namespace framework + +/* 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..5023f34a2 --- /dev/null +++ b/framework/inc/classes/fwkresid.hxx @@ -0,0 +1,27 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <unotools/resmgr.hxx> + +OUString FwkResId(TranslateId aId); + +/* 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..e156f9b0d --- /dev/null +++ b/framework/inc/classes/protocolhandlercache.hxx @@ -0,0 +1,146 @@ +/* -*- 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 <unordered_map> +#include <optional> + +#include <com/sun/star/util/URL.hpp> + +#include <unotools/configitem.hxx> +#include <rtl/ustring.hxx> + +namespace framework{ + +inline constexpr OUStringLiteral PACKAGENAME_PROTOCOLHANDLER = u"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 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<OUString> 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<OUString, OUString> PatternHash; + +/** + This hash holds protocol handler structs by her names. +*/ +typedef std::unordered_map<OUString, ProtocolHandler> 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 HandlerCache final +{ + /* member */ + private: + + /// list of all registered handler registered by her uno implementation names + static std::optional<HandlerHash> s_pHandler; + /// maps URL pattern to handler names + static std::optional<PatternHash> 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(HandlerHash aHandler, PatternHash aPattern); +}; + +/** + @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 final : 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 + +/* 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..64d89d119 --- /dev/null +++ b/framework/inc/classes/resource.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 . + */ + +#pragma once + +#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 + +/* 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..4fd5f24f9 --- /dev/null +++ b/framework/inc/classes/rootactiontriggercontainer.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 . + */ + +#pragma once + +#include <helper/propertysetcontainer.hxx> +#include <com/sun/star/awt/XPopupMenu.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/lang/XTypeProvider.hpp> + +inline constexpr OUStringLiteral IMPLEMENTATIONNAME_ROOTACTIONTRIGGERCONTAINER = u"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(css::uno::Reference<css::awt::XPopupMenu> xMenu, 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() noexcept override; + virtual void SAL_CALL release() noexcept 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; + static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() noexcept; + + // 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; + css::uno::Reference<css::awt::XPopupMenu> m_xMenu; + const OUString* m_pMenuIdentifier; +}; + +} + +/* 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..d57cc406e --- /dev/null +++ b/framework/inc/classes/taskcreator.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <com/sun/star/uno/Reference.hxx> +#include <rtl/ustring.hxx> +#include <unotools/mediadescriptor.hxx> + +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( 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 + +/* 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..2217afa9c --- /dev/null +++ b/framework/inc/dispatch/closedispatcher.hxx @@ -0,0 +1,261 @@ +/* -*- 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 <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatchInformationProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/XDispatchResultListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> +#include <vcl/evntpost.hxx> +#include <vcl/vclptr.hxx> + +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<vcl::EventPoster> 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<SystemWindow> 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(css::uno::Reference< css::uno::XComponentContext > xContext , + const css::uno::Reference< css::frame::XFrame >& xFrame , + std::u16string_view 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=<empty> + 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 , + std::u16string_view sTarget); + +}; // class CloseDispatcher + +} // namespace framework + +/* 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..e5bdeddc1 --- /dev/null +++ b/framework/inc/dispatch/dispatchinformationprovider.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XDispatchInformationProvider.hpp> + +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/implbase.hxx> +#include <vcl/svapp.hxx> + +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(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 + +/* 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..c6656948e --- /dev/null +++ b/framework/inc/dispatch/dispatchprovider.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 . + */ + +#pragma once + +#include <classes/protocolhandlercache.hxx> + +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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; + std::unordered_map<OUString, css::uno::Reference<css::frame::XDispatchProvider>> + m_aProtocolHandlers; + + /* interface */ + public: + + DispatchProvider( 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; + + void ClearProtocolHandlers() { m_aProtocolHandlers.clear(); } + + /* 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 + +/* 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..fda3a81dd --- /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 . + */ + +#pragma once + +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> + +#include <tools/wldcrd.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +#include <deque> +#include <string_view> + +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(std::u16string_view 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<c; ++i) + { + WildCard aPattern(pPattern[i]); + if (aPattern.Matches(sURL)) + return pIt; + } + } + return end(); + } + }; + + // member + + private: + + /** @short reference to the frame, which uses this instance to implement its own interception. + + @descr We hold a weak reference only, to make disposing operations easy. */ + css::uno::WeakReference< css::frame::XFrame > 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, + 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; + + css::uno::Reference<css::frame::XDispatchProvider> GetSlave() const { return m_xSlave; } + +}; // class InterceptionHelper + +} // namespace framework + +/* 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..d6fe52d93 --- /dev/null +++ b/framework/inc/dispatch/mailtodispatcher.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> + +#include <cppuhelper/implbase.hxx> + +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( css::uno::Reference< css::uno::XComponentContext > xContext ); + virtual ~MailToDispatcher( ) override; + + /* 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; + + // 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 + +/* 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..09b80ea8c --- /dev/null +++ b/framework/inc/dispatch/oxt_handler.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/document/XExtendedFilterDetection.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <mutex> + +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( css::uno::Reference< css::uno::XComponentContext > ); + virtual ~Oxt_Handler( ) override; + + /* 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; + + // 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: + std::mutex m_mutex; + + css::uno::Reference< css::uno::XComponentContext > m_xContext; /// global uno service factory to create new services + +}; + +} + +/* 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..0d22beb86 --- /dev/null +++ b/framework/inc/dispatch/popupmenudispatcher.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/uri/XUriReferenceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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( css::uno::Reference< css::uno::XComponentContext > xContext ); + + /* 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; + + // 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 + +/* 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..0b1ee8ab9 --- /dev/null +++ b/framework/inc/dispatch/servicehandler.hxx @@ -0,0 +1,100 @@ +/* -*- 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 <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> + +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::uno::XComponentContext > m_xContext; + + /* interface */ + public: + + // ctor/dtor + ServiceHandler( css::uno::Reference< css::uno::XComponentContext > ); + virtual ~ServiceHandler( ) override; + + /* 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; + + // 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 + +/* 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..c575004d4 --- /dev/null +++ b/framework/inc/dispatch/startmoduledispatcher.hxx @@ -0,0 +1,126 @@ +/* -*- 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 <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatchInformationProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/frame/XDispatchResultListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> + +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(css::uno::Reference< css::uno::XComponentContext > xContext); + + /** @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 + +/* 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..67a36b724 --- /dev/null +++ b/framework/inc/dispatch/systemexec.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> + +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( css::uno::Reference< css::uno::XComponentContext > xContext ); + virtual ~SystemExec( ) override; + + /* 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; + + // 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 + +/* 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..f591e12ef --- /dev/null +++ b/framework/inc/helper/dockingareadefaultacceptor.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 . + */ + +#pragma once + +#include <com/sun/star/ui/XDockingAreaAcceptor.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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 + +/* 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..7e028d18e --- /dev/null +++ b/framework/inc/helper/mischelper.hxx @@ -0,0 +1,261 @@ +/* -*- 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 <com/sun/star/linguistic2/XLanguageGuessing.hpp> +#include <com/sun/star/document/XDocumentEventListener.hpp> +#include <com/sun/star/util/XChangesListener.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/ui/XContextChangeEventListener.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +#include <i18nlangtag/lang.h> +#include <svl/languageoptions.hxx> +#include <rtl/ustring.hxx> + +#include <functional> +#include <set> +#include <utility> + +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() && aResourceURL[nIdx]=='/') ++nIdx; + if (nIdx>=aResourceURL.getLength()) + return; + aType = aResourceURL.getToken(0, '/', nIdx); + if (nIdx<0) + return; + while (nIdx<aResourceURL.getLength() && aResourceURL[nIdx]=='/') ++nIdx; + if (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(css::uno::Reference< css::uno::XComponentContext > _xContext) : m_xContext(std::move(_xContext)){} + + css::uno::Reference< css::linguistic2::XLanguageGuessing > const & GetGuesser() const; +}; + +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<css::container::XContainerListener> +{ + private: + css::uno::WeakReference<css::container::XContainerListener> mxOwner; + + public: + WeakContainerListener(css::uno::Reference<css::container::XContainerListener> const & xOwner) + : mxOwner(xOwner) + { + } + + // container.XContainerListener + virtual void SAL_CALL elementInserted(const css::container::ContainerEvent& rEvent) override + { + css::uno::Reference<css::container::XContainerListener> 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<css::container::XContainerListener> 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<css::container::XContainerListener> 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<css::container::XContainerListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +class WeakChangesListener final : public ::cppu::WeakImplHelper<css::util::XChangesListener> +{ + private: + css::uno::WeakReference<css::util::XChangesListener> mxOwner; + + public: + WeakChangesListener(css::uno::Reference<css::util::XChangesListener> const & xOwner) + : mxOwner(xOwner) + { + } + + // util.XChangesListener + virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& rEvent) override + { + css::uno::Reference<css::util::XChangesListener> 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<css::util::XChangesListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +class WeakDocumentEventListener final : public ::cppu::WeakImplHelper<css::document::XDocumentEventListener> +{ + private: + css::uno::WeakReference<css::document::XDocumentEventListener> mxOwner; + + public: + WeakDocumentEventListener(css::uno::Reference<css::document::XDocumentEventListener> const & xOwner) + : mxOwner(xOwner) + { + } + + virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent& rEvent) override + { + css::uno::Reference<css::document::XDocumentEventListener> 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<css::document::XDocumentEventListener> xOwner(mxOwner.get(), + css::uno::UNO_QUERY); + if (xOwner.is()) + xOwner->disposing(rEvent); + + } +}; + +css::uno::Reference<css::ui::XContextChangeEventListener> +GetFirstListenerWith_Impl( + css::uno::Reference<css::uno::XComponentContext> const & xComponentContext, + css::uno::Reference<css::uno::XInterface> const& xEventFocus, + std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const& rPredicate); + +extern auto (*g_pGetMultiplexerListener)( + css::uno::Reference<css::uno::XComponentContext> const & xComponentContext, + css::uno::Reference<css::uno::XInterface> const&, + std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const&) + -> css::uno::Reference<css::ui::XContextChangeEventListener>; + +} // namespace framework + +/* 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..9c444953a --- /dev/null +++ b/framework/inc/helper/ocomponentaccess.hxx @@ -0,0 +1,161 @@ +/* -*- 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 <com/sun/star/frame/XFramesSupplier.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> +#include <vector> + +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<BR> + 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 + +/* 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..5791b3877 --- /dev/null +++ b/framework/inc/helper/ocomponentenumeration.hxx @@ -0,0 +1,160 @@ +/* -*- 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 <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/container/XEnumeration.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vector> + +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( 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<BR> + sal_False = other way + + @onerror sal_False<BR> + (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.<BR> + 1) delete with destructor<BR> + 2) dispose from parent or factory or...<BR> + This method does the same for both ways! It frees used memory and releases 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<BR> + 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 + +/* 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..d29063407 --- /dev/null +++ b/framework/inc/helper/oframes.hxx @@ -0,0 +1,190 @@ +/* -*- 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 <framework/framecontainer.hxx> + +#include <com/sun/star/frame/XFrames.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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.<BR> + 1) delete with destructor<BR> + 2) dispose from parent or factory ore ...<BR> + 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 +}; + +} + +/* 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..8d062488f --- /dev/null +++ b/framework/inc/helper/persistentwindowstate.hxx @@ -0,0 +1,166 @@ +/* -*- 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 <sal/config.h> + +#include <string_view> + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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 detached 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(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 , + std::u16string_view 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, + std::u16string_view 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 , + std::u16string_view sWindowState); + +}; // class PersistentWindowState + +} // namespace framework + +/* 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..75c8414c3 --- /dev/null +++ b/framework/inc/helper/propertysetcontainer.hxx @@ -0,0 +1,73 @@ +/* -*- 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 <sal/config.h> + +#include <vector> +#include <cppuhelper/weak.hxx> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +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() noexcept override; + virtual void SAL_CALL release() noexcept 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<css::beans::XPropertySet>::get(); + } + + virtual sal_Bool SAL_CALL hasElements() override; + + private: + typedef std::vector< css::uno::Reference< css::beans::XPropertySet > > PropertySetVector; + PropertySetVector m_aPropertySetVector; + +}; + +} + +/* 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..d43b3e938 --- /dev/null +++ b/framework/inc/helper/shareablemutex.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 . + */ + +#pragma once + +#include <osl/interlck.h> +#include <osl/mutex.hxx> + +namespace framework +{ + +/** + * This acts like a rtl::Reference<osl::Mutex> + */ +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; +}; + +} + +/* 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..8d97738d0 --- /dev/null +++ b/framework/inc/helper/statusindicator.hxx @@ -0,0 +1,103 @@ +/* -*- 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 files of own module +#include <helper/statusindicatorfactory.hxx> + +// include UNO interfaces +#include <com/sun/star/task/XStatusIndicator.hpp> + +// include all others +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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 + +/* 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..c492a645f --- /dev/null +++ b/framework/inc/helper/statusindicatorfactory.hxx @@ -0,0 +1,270 @@ +/* -*- 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 <sal/config.h> + +#include <vector> +#include <mutex> + +// include files of own module +#include <helper/wakeupthread.hxx> + +// include uno interfaces +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/task/XStatusIndicatorFactory.hpp> +#include <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> + +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: + std::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<WakeUpThread> 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(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<OUString> SAL_CALL getSupportedServiceNames() override + { + return { "com.sun.star.task.StatusIndicatorFactory" }; + } + + // 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 + +/* 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..e8c9fff22 --- /dev/null +++ b/framework/inc/helper/tagwindowasmodified.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 <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/util/XModifiable.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/window.hxx> + +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::Reference< css::frame::XFrame > m_xFrame; + + /// reference to the frame container window, where we must set the tag + VclPtr<vcl::Window> m_xWindow; + + /// we list on the model for modify events + css::uno::Reference< css::util::XModifiable > 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 + +/* 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..11aba17dc --- /dev/null +++ b/framework/inc/helper/titlebarupdate.hxx @@ -0,0 +1,142 @@ +/* -*- 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 <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/frame/XTitleChangeListener.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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(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 + +/* 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..5b561bef5 --- /dev/null +++ b/framework/inc/helper/uiconfigelementwrapperbase.hxx @@ -0,0 +1,141 @@ +/* -*- 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 <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XUIElementSettings.hpp> +#include <com/sun/star/ui/XUIConfigurationManager.hpp> +#include <com/sun/star/ui/XUIConfigurationListener.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/awt/XMenuBar.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <rtl/ustring.hxx> +#include <comphelper/multicontainer2.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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() noexcept override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() noexcept 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; + comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer; /// container for ALL Listener +}; + +} // namespace framework + +/* 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..573755f20 --- /dev/null +++ b/framework/inc/helper/uielementwrapperbase.hxx @@ -0,0 +1,112 @@ +/* -*- 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 <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/util/XUpdatable.hpp> + +#include <rtl/ustring.hxx> +#include <comphelper/multicontainer2.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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() noexcept override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() noexcept 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(); + + comphelper::OMultiTypeInterfaceContainerHelper2 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 + +/* 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..6afae9565 --- /dev/null +++ b/framework/inc/helper/vclstatusindicator.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 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 <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/awt/XWindow.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/status.hxx> + +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<StatusBar> 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(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 + +/* 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..cdc8700a5 --- /dev/null +++ b/framework/inc/helper/wakeupthread.hxx @@ -0,0 +1,53 @@ +/* -*- 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 <sal/config.h> + +#include <com/sun/star/uno/Reference.hxx> +#include <cppuhelper/weakref.hxx> +#include <condition_variable> +#include <mutex> +#include <salhelper/thread.hxx> + +namespace com::sun::star::util +{ +class XUpdatable; +} + +namespace framework +{ +class WakeUpThread final : public salhelper::Thread +{ + css::uno::WeakReference<css::util::XUpdatable> updatable_; + std::condition_variable condition_; + std::mutex mutex_; + bool terminate_; + + void execute() override; + +public: + WakeUpThread(css::uno::Reference<css::util::XUpdatable> const& updatable); + + void stop(); +}; +} + +/* 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..ce0969bd1 --- /dev/null +++ b/framework/inc/interaction/quietinteraction.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 . + */ + +#pragma once + +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/task/XInteractionRequest.hpp> + +#include <cppuhelper/implbase.hxx> + +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] + <TRUE/> for used interaction + <FALSE/> otherwise + + @threadsafe yes + */ + bool wasUsed() const; +}; + +} // namespace framework + +/* 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..2efc22cb8 --- /dev/null +++ b/framework/inc/jobs/configaccess.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 . + */ + +#pragma once + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <rtl/ustring.hxx> +#include <mutex> + +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 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 std::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 + + void closeImpl(); + public: + + ConfigAccess( css::uno::Reference< css::uno::XComponentContext > xContext, + OUString sRoot ); + ~ConfigAccess(); + + void open ( EOpenMode eMode ); + void close ( ); + EOpenMode getMode( ) const; + + const css::uno::Reference< css::uno::XInterface >& cfg(); +}; + +} // namespace framework + +/* 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..aaaf35492 --- /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 . + */ + +#pragma once + +#include <sal/config.h> + +#include <mutex> +#include <string_view> + +#include <cppuhelper/implbase.hxx> + +#include <com/sun/star/task/XJob.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/frame/XDesktop2.hpp> +#include <com/sun/star/frame/XModuleManager2.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +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: + std::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(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: + + /* 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; + + // 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(std::u16string_view 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(std::u16string_view sBaseURL, + std::u16string_view sLocale , + std::u16string_view sSystem ); +}; + +} // namespace framework + +/* 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..8afc1966f --- /dev/null +++ b/framework/inc/jobs/job.hxx @@ -0,0 +1,202 @@ +/* -*- 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 <jobs/jobdata.hxx> + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XDesktop2.hpp> +#include <com/sun/star/frame/XDispatchResultListener.hpp> +#include <com/sun/star/task/XJobListener.hpp> +#include <com/sun/star/util/XCloseListener.hpp> + +#include <cppuhelper/implbase.hxx> +#include <osl/conditn.hxx> + +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 , + css::uno::Reference< css::frame::XFrame > xFrame ); + Job( const css::uno::Reference< css::uno::XComponentContext >& xContext , + 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 + +/* 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..7c6fc17cc --- /dev/null +++ b/framework/inc/jobs/jobconst.hxx @@ -0,0 +1,44 @@ +/* -*- 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 <rtl/ustring.hxx> + +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 JobConst +{ +public: + static constexpr OUStringLiteral ANSWER_DEACTIVATE_JOB = u"Deactivate"; + static constexpr OUStringLiteral ANSWER_SAVE_ARGUMENTS = u"SaveArguments"; + static constexpr OUStringLiteral ANSWER_SEND_DISPATCHRESULT = u"SendDispatchResult"; +}; + +} // namespace framework + +/* 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..fd23a665e --- /dev/null +++ b/framework/inc/jobs/jobdata.hxx @@ -0,0 +1,209 @@ +/* -*- 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 <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/beans/NamedValue.hpp> + +#include <rtl/ustring.hxx> + +#include <string_view> +#include <utility> +#include <vector> + +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(OUString sJobName , + OUString sDocEvent) + : m_sJobName (std::move(sJobName )) + , m_sDocEvent(std::move(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( css::uno::Reference< css::uno::XComponentContext > xContext ); + 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 ( std::vector< css::beans::NamedValue >&& lArguments ); + void disableJob ( ); + + static std::vector< OUString > getEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + std::u16string_view 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 + +/* 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..a9d3f189b --- /dev/null +++ b/framework/inc/jobs/jobresult.hxx @@ -0,0 +1,103 @@ +/* -*- 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 <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/frame/DispatchResultEvent.hpp> + +#include <vector> + +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 + +/* 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..3a227a375 --- /dev/null +++ b/framework/inc/jobs/joburl.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 <rtl/ustring.hxx> + +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=<name>]|[alias=<name>]|[service=<name>]} + 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 + +/* 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..9152da515 --- /dev/null +++ b/framework/inc/jobs/shelljob.hxx @@ -0,0 +1,125 @@ +/* -*- 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 <cppuhelper/implbase.hxx> + +#include <com/sun/star/task/XJob.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +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(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: + + /* 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; + + // 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 + +/* 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..9389ed3e3 --- /dev/null +++ b/framework/inc/menuconfiguration.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 . + */ + +#pragma once + +#include <cppuhelper/weakref.hxx> +#include <utility> + +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; } + +namespace framework +{ + +struct MenuAttributes +{ +private: + oslInterlockedCount refCount; + + MenuAttributes(OUString sFrame, OUString sImageIdStr) + : refCount(0) + , aTargetFrame(std::move(sFrame)) + , aImageId(std::move(sImageIdStr)) + { + } + + MenuAttributes(css::uno::WeakReference<css::frame::XDispatchProvider> _xDispatchProvider) + : refCount(0) + , xDispatchProvider(std::move(_xDispatchProvider)) + { + } + + MenuAttributes(const MenuAttributes&) = delete; + +public: + OUString aTargetFrame; + OUString aImageId; + css::uno::WeakReference<css::frame::XDispatchProvider> xDispatchProvider; + + static void* CreateAttribute(const OUString& rFrame, const OUString& rImageIdStr); + static void* CreateAttribute(const css::uno::WeakReference<css::frame::XDispatchProvider>& rDispatchProvider); + static void ReleaseAttribute(void* nAttributePtr); + + void acquire() + { + osl_atomic_increment(&refCount); + } + + void release() + { + if (!osl_atomic_decrement(&refCount)) + delete this; + } +}; + +class MenuConfiguration final +{ +public: + MenuConfiguration( + // use const when giving a UNO reference by reference + 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_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..0011dcb8a --- /dev/null +++ b/framework/inc/pch/precompiled_fwk.hxx @@ -0,0 +1,303 @@ +/* -*- 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 2021-11-29 09:45:56 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 +*/ + +#include <sal/config.h> +#if PCH_LEVEL >= 1 +#include <algorithm> +#include <array> +#include <cassert> +#include <chrono> +#include <cmath> +#include <cstddef> +#include <cstdlib> +#include <float.h> +#include <functional> +#include <initializer_list> +#include <iomanip> +#include <limits.h> +#include <limits> +#include <map> +#include <math.h> +#include <memory> +#include <mutex> +#include <new> +#include <numeric> +#include <optional> +#include <ostream> +#include <stddef.h> +#include <string.h> +#include <string> +#include <string_view> +#include <type_traits> +#include <unordered_map> +#include <utility> +#include <vector> +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include <osl/conditn.h> +#include <osl/conditn.hxx> +#include <osl/diagnose.h> +#include <osl/endian.h> +#include <osl/file.hxx> +#include <osl/interlck.h> +#include <osl/mutex.hxx> +#include <osl/process.h> +#include <osl/security.hxx> +#include <osl/thread.h> +#include <osl/time.h> +#include <rtl/alloc.h> +#include <rtl/bootstrap.hxx> +#include <rtl/character.hxx> +#include <rtl/locale.h> +#include <rtl/math.h> +#include <rtl/ref.hxx> +#include <rtl/strbuf.hxx> +#include <rtl/string.h> +#include <rtl/string.hxx> +#include <rtl/stringconcat.hxx> +#include <rtl/stringutils.hxx> +#include <rtl/textcvt.h> +#include <rtl/textenc.h> +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.h> +#include <rtl/ustring.hxx> +#include <sal/detail/log.h> +#include <sal/log.hxx> +#include <sal/macros.h> +#include <sal/saldllapi.h> +#include <sal/types.h> +#include <sal/typesizes.h> +#include <vcl/Scanline.hxx> +#include <vcl/alpha.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/bitmap/BitmapTypes.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/cairo.hxx> +#include <vcl/checksum.hxx> +#include <vcl/commandinfoprovider.hxx> +#include <vcl/devicecoordinate.hxx> +#include <vcl/dllapi.h> +#include <vcl/fntstyle.hxx> +#include <vcl/font.hxx> +#include <vcl/gradient.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/menu.hxx> +#include <vcl/metaactiontypes.hxx> +#include <vcl/region.hxx> +#include <vcl/rendercontext/AddFontSubstituteFlags.hxx> +#include <vcl/rendercontext/AntialiasingFlags.hxx> +#include <vcl/rendercontext/DrawGridFlags.hxx> +#include <vcl/rendercontext/DrawImageFlags.hxx> +#include <vcl/rendercontext/DrawModeFlags.hxx> +#include <vcl/rendercontext/DrawTextFlags.hxx> +#include <vcl/rendercontext/GetDefaultFontFlags.hxx> +#include <vcl/rendercontext/ImplMapRes.hxx> +#include <vcl/rendercontext/InvertFlags.hxx> +#include <vcl/rendercontext/RasterOp.hxx> +#include <vcl/rendercontext/SalLayoutFlags.hxx> +#include <vcl/rendercontext/State.hxx> +#include <vcl/rendercontext/SystemTextColorFlags.hxx> +#include <vcl/salnativewidgets.hxx> +#include <vcl/scopedbitmapaccess.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <vcl/task.hxx> +#include <vcl/timer.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/vclreferencebase.hxx> +#include <vcl/wall.hxx> +#include <vcl/window.hxx> +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include <basegfx/basegfxdllapi.h> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/numeric/ftools.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/point/b2ipoint.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/range/basicrange.hxx> +#include <basegfx/tuple/Tuple2D.hxx> +#include <basegfx/tuple/Tuple3D.hxx> +#include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/tuple/b2i64tuple.hxx> +#include <basegfx/tuple/b2ituple.hxx> +#include <basegfx/tuple/b3dtuple.hxx> +#include <basegfx/utils/common.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <basegfx/vector/b2enums.hxx> +#include <basegfx/vector/b2ivector.hxx> +#include <classes/fwkresid.hxx> +#include <com/sun/star/awt/DeviceInfo.hpp> +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/KeyEvent.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetOption.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/drawing/LineCap.hpp> +#include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/frame/ControlCommand.hpp> +#include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/frame/DispatchResultState.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/ModuleManager.hpp> +#include <com/sun/star/frame/XControlNotificationListener.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/frame/XNotifyingDispatch.hpp> +#include <com/sun/star/frame/XPopupMenuController.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XUIControllerFactory.hpp> +#include <com/sun/star/io/IOException.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/EventObject.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/ui/ItemStyle.hpp> +#include <com/sun/star/ui/UIElementType.hpp> +#include <com/sun/star/ui/XUIConfigurationListener.hpp> +#include <com/sun/star/ui/XUIConfigurationManager.hpp> +#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/uno/Any.h> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Exception.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/Type.h> +#include <com/sun/star/uno/Type.hxx> +#include <com/sun/star/uno/TypeClass.hdl> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/uno/XInterface.hpp> +#include <com/sun/star/uno/XWeak.hpp> +#include <com/sun/star/uno/genfunc.h> +#include <com/sun/star/uno/genfunc.hxx> +#include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/util/URLTransformer.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/xml/sax/SAXException.hpp> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <comphelper/comphelperdllapi.h> +#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/lok.hxx> +#include <comphelper/multicontainer2.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/propertysequence.hxx> +#include <comphelper/propertyvalue.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <comphelper/servicehelper.hxx> +#include <cppu/cppudllapi.h> +#include <cppu/unotype.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/cppuhelperdllapi.h> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/interfacecontainer.h> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakref.hxx> +#include <helper/mischelper.hxx> +#include <i18nlangtag/i18nlangtagdllapi.h> +#include <i18nlangtag/lang.h> +#include <i18nlangtag/languagetag.hxx> +#include <o3tl/cow_wrapper.hxx> +#include <o3tl/safeint.hxx> +#include <o3tl/span.hxx> +#include <o3tl/strong_int.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <o3tl/underlyingenumvalue.hxx> +#include <o3tl/unit_conversion.hxx> +#include <officecfg/Office/Common.hxx> +#include <salhelper/salhelperdllapi.h> +#include <salhelper/thread.hxx> +#include <svl/svldllapi.h> +#include <svtools/popupmenucontrollerbase.hxx> +#include <svtools/svtdllapi.h> +#include <svtools/toolboxcontroller.hxx> +#include <toolkit/awt/vclxmenu.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/color.hxx> +#include <tools/date.hxx> +#include <tools/degree.hxx> +#include <tools/diagnose_ex.h> +#include <tools/fontenum.hxx> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <tools/long.hxx> +#include <tools/mapunit.hxx> +#include <tools/poly.hxx> +#include <tools/ref.hxx> +#include <tools/solar.h> +#include <tools/toolsdllapi.h> +#include <tools/urlobj.hxx> +#include <typelib/typeclass.h> +#include <typelib/typedescription.h> +#include <typelib/uik.h> +#include <uielement/complextoolbarcontroller.hxx> +#include <uno/any2.h> +#include <uno/data.h> +#include <uno/sequence2.h> +#include <unotools/configmgr.hxx> +#include <unotools/fontdefs.hxx> +#include <unotools/mediadescriptor.hxx> +#include <unotools/options.hxx> +#include <unotools/unotoolsdllapi.h> +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include <framework/addonsoptions.hxx> +#include <framework/fwkdllapi.h> +#include <menuconfiguration.hxx> +#include <properties.h> +#include <services.h> +#include <targets.h> +#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..fead8e3e1 --- /dev/null +++ b/framework/inc/properties.h @@ -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 . + */ + +#pragma once + +#include <com/sun/star/uno/Any.hxx> + +namespace framework{ + +/** properties for "Frame" class */ + +inline constexpr OUStringLiteral FRAME_PROPNAME_ASCII_DISPATCHRECORDERSUPPLIER = u"DispatchRecorderSupplier"; +inline constexpr OUStringLiteral FRAME_PROPNAME_ASCII_ISHIDDEN = u"IsHidden"; +inline constexpr OUStringLiteral FRAME_PROPNAME_ASCII_LAYOUTMANAGER = u"LayoutManager"; +inline constexpr OUStringLiteral FRAME_PROPNAME_ASCII_TITLE = u"Title"; +inline constexpr OUStringLiteral FRAME_PROPNAME_ASCII_INDICATORINTERCEPTION = u"IndicatorInterception"; +inline constexpr OUStringLiteral FRAME_PROPNAME_ASCII_URL = u"URL"; + +// 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. +#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_PROPHANDLE_URL 5 + +/** properties for "LayoutManager" class */ + +inline constexpr OUStringLiteral LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER = u"MenuBarCloser"; +inline constexpr OUStringLiteral LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS = u"AutomaticToolbars"; +inline constexpr OUStringLiteral LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY = u"RefreshContextToolbarVisibility"; +inline constexpr OUStringLiteral LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI = u"HideCurrentUI"; +inline constexpr OUStringLiteral LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT = u"LockCount"; +inline constexpr OUStringLiteral LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE = u"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 */ +inline constexpr OUStringLiteral UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST = u"private:resource/image/commandimagelist"; +inline constexpr OUStringLiteral UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST = u"private:resource/image/commandrotateimagelist"; +inline constexpr OUStringLiteral UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST = u"private:resource/image/commandmirrorimagelist"; + + +#define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 + +/** properties for "AutoRecovery" class */ + +inline constexpr OUStringLiteral AUTORECOVERY_PROPNAME_ASCII_EXISTS_RECOVERYDATA = u"ExistsRecoveryData"; +inline constexpr OUStringLiteral AUTORECOVERY_PROPNAME_ASCII_EXISTS_SESSIONDATA = u"ExistsSessionData"; +inline constexpr OUStringLiteral AUTORECOVERY_PROPNAME_ASCII_CRASHED = u"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 + +/** properties for Filter config */ + +inline constexpr OUStringLiteral FILTER_PROPNAME_ASCII_DOCUMENTSERVICE = u"DocumentService"; + +/** properties for office module config (Setup.xcu) */ + +inline constexpr OUStringLiteral OFFICEFACTORY_PROPNAME_ASCII_UINAME = u"ooSetupFactoryUIName"; +inline constexpr OUStringLiteral OFFICEFACTORY_PROPNAME_ASCII_ICON = u"ooSetupFactoryIcon"; + +/** 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 <True/> if value of this property will be changed; <False/> 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 + +/* 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..bbadb7e71 --- /dev/null +++ b/framework/inc/protocols.h @@ -0,0 +1,124 @@ +/* -*- 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 :-) */ + +#pragma once + +#include <sal/config.h> + +#include <string_view> + +#include <o3tl/string_view.hxx> + +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 u"private:object" +// indicates loading of components using a stream only +#define SPECIALPROTOCOL_PRIVATE_STREAM u"private:stream" +// indicates creation of empty documents +#define SPECIALPROTOCOL_PRIVATE_FACTORY u"private:factory" +// internal protocol of the sfx project for generic dispatch functionality +#define SPECIALPROTOCOL_SLOT u"slot:" +// external representation of the slot protocol using names instead of id's +#define SPECIALPROTOCOL_UNO u".uno:" +// special sfx protocol to execute macros +#define SPECIALPROTOCOL_MACRO u"macro:" +// generic way to start uno services during dispatch +#define SPECIALPROTOCOL_SERVICE u"service:" +// for sending mails +#define SPECIALPROTOCOL_MAILTO u"mailto:" +// for sending news +#define SPECIALPROTOCOL_NEWS u"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( std::u16string_view sURL, EProtocol eRequired ) + { + bool bRet = false; + switch(eRequired) + { + case EProtocol::PrivateObject: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_OBJECT); + break; + case EProtocol::PrivateStream: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_STREAM); + break; + case EProtocol::PrivateFactory: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_FACTORY); + break; + case EProtocol::Slot: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_SLOT); + break; + case EProtocol::Uno: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_UNO); + break; + case EProtocol::Macro: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_MACRO); + break; + case EProtocol::Service: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_SERVICE); + break; + case EProtocol::MailTo: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_MAILTO); + break; + case EProtocol::News: + bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_NEWS); + break; + default: + bRet = false; + break; + } + return bRet; + } +}; + +} // namespace framework + +/* 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..ec03189d3 --- /dev/null +++ b/framework/inc/recording/dispatchrecorder.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 . + */ + +#pragma once + +#include <sal/config.h> + +#include <vector> + +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include <com/sun/star/frame/XDispatchRecorder.hpp> +#include <com/sun/star/frame/DispatchStatement.hpp> +#include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/script/XTypeConverter.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/implbase.hxx> + +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; + + /* 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; + + // 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( std::u16string_view 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 + +/* 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..d01cec161 --- /dev/null +++ b/framework/inc/recording/dispatchrecordersupplier.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XDispatchRecorderSupplier.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <cppuhelper/implbase.hxx> + +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: + + /* 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; + + // 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(); + virtual ~DispatchRecorderSupplier() override; + +}; // class DispatchRecorderSupplier + +} // namespace framework + +/* 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..aa07586b8 --- /dev/null +++ b/framework/inc/services.h @@ -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 . + */ + +#pragma once + +#include <rtl/ustring.hxx> + +namespace framework{ + +// used servicenames by framework + +inline constexpr OUStringLiteral SERVICENAME_FILTERFACTORY = u"com.sun.star.document.FilterFactory"; +inline constexpr OUStringLiteral SERVICENAME_CFGUPDATEACCESS = u"com.sun.star.configuration.ConfigurationUpdateAccess"; // provides read/write access to the configuration +inline constexpr OUStringLiteral SERVICENAME_CFGREADACCESS = u"com.sun.star.configuration.ConfigurationAccess"; // provides readonly access to the configuration +inline constexpr OUStringLiteral SERVICENAME_JOB = u"com.sun.star.task.Job"; +inline constexpr OUStringLiteral SERVICENAME_PROTOCOLHANDLER = u"com.sun.star.frame.ProtocolHandler"; +inline constexpr OUStringLiteral SERVICENAME_POPUPMENUCONTROLLER = u"com.sun.star.frame.PopupMenuController"; + +// used implementationnames by framework + +#define IMPLEMENTATIONNAME_QUICKLAUNCHER "com.sun.star.comp.desktop.QuickstartWrapper" +inline constexpr OUStringLiteral IMPLEMENTATIONNAME_FWK_TASKCREATOR = u"com.sun.star.comp.framework.TaskCreator"; + +} // namespace framework + +/* 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..28f78d5bd --- /dev/null +++ b/framework/inc/services/layoutmanager.hxx @@ -0,0 +1,272 @@ +/* -*- 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 <uielement/menubarmanager.hxx> +#include <uielement/uielement.hxx> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/frame/XLayoutManager2.hpp> +#include <com/sun/star/ui/XUIConfigurationManager.hpp> +#include <com/sun/star/frame/XModuleManager2.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/ui/XUIElementFactoryManager.hpp> +#include <com/sun/star/ui/DockingArea.hpp> +#include <com/sun/star/awt/XTopWindow2.hpp> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase.hxx> +#include <comphelper/multicontainer2.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <comphelper/propertycontainer.hxx> +#include <comphelper/uno3.hxx> +#include <vcl/timer.hxx> + +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<OUString> 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<GlobalSettings> &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( std::u16string_view 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<GlobalSettings> m_pGlobalSettings; + OUString m_aModuleIdentifier; + Timer m_aAsyncLayoutTimer; + comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerContainer; // container for ALL Listener + rtl::Reference< ToolbarLayoutManager > m_xToolbarManager; + + friend class detail::InfoHelperBuilder; + }; + +} // namespace framework + +/* 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..fd89d5c68 --- /dev/null +++ b/framework/inc/services/mediatypedetectionhelper.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 . + */ + +#pragma once + +#include <com/sun/star/util/XStringMapping.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <cppuhelper/implbase.hxx> + +// 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: + + MediaTypeDetectionHelper(); + virtual ~MediaTypeDetectionHelper() override; + + /* 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; + + // XStringMapping + + /*-**************************************************************************************************** + *//*-*****************************************************************************************************/ + + virtual sal_Bool SAL_CALL mapStrings(css::uno::Sequence< OUString >& seqParameter) override; + +}; + +} // namespace framework + +/* 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..d33255b3a --- /dev/null +++ b/framework/inc/services/uriabbreviation.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 . + */ + +#pragma once + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XStringAbbreviation.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> + +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); + + /* 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; + + // 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 + +/* 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..a65a9ab4a --- /dev/null +++ b/framework/inc/statusbarconfiguration.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 . + */ +#pragma once + +#include <sal/types.h> + +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 <typename > class Reference; } + +namespace framework +{ + +class 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..265daba77 --- /dev/null +++ b/framework/inc/stdtypes.h @@ -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 . + */ + +#pragma once + +#include <com/sun/star/awt/KeyEvent.hpp> + +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<size_t>(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) + ); + } +}; + +} // namespace framework + +/* 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..18b372915 --- /dev/null +++ b/framework/inc/strings.hrc @@ -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 . + */ + +#pragma once + +#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(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_LOCK_TOOLBARS NC_("STR_LOCK_TOOLBARS", "~Lock Toolbars" ) +#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" ) + +#define RID_STR_PROPTITLE_EDIT NC_("RID_STR_PROPTITLE_EDIT", "Text Box") +#define RID_STR_PROPTITLE_CHECKBOX NC_("RID_STR_PROPTITLE_CHECKBOX", "Check Box") +#define RID_STR_PROPTITLE_COMBOBOX NC_("RID_STR_PROPTITLE_COMBOBOX", "Combo Box") +#define RID_STR_PROPTITLE_LISTBOX NC_("RID_STR_PROPTITLE_LISTBOX", "List Box") +#define RID_STR_PROPTITLE_DATEFIELD NC_("RID_STR_PROPTITLE_DATEFIELD", "Date Field") +#define RID_STR_PROPTITLE_TIMEFIELD NC_("RID_STR_PROPTITLE_TIMEFIELD", "Time Field") +#define RID_STR_PROPTITLE_NUMERICFIELD NC_("RID_STR_PROPTITLE_NUMERICFIELD", "Numeric Field") +#define RID_STR_PROPTITLE_CURRENCYFIELD NC_("RID_STR_PROPTITLE_CURRENCYFIELD", "Currency Field") +#define RID_STR_PROPTITLE_PATTERNFIELD NC_("RID_STR_PROPTITLE_PATTERNFIELD", "Pattern Field") +#define RID_STR_PROPTITLE_FORMATTED NC_("RID_STR_PROPTITLE_FORMATTED", "Formatted Field") + +#define RID_STR_PROPTITLE_PUSHBUTTON NC_("RID_STR_PROPTITLE_PUSHBUTTON", "Push Button") +#define RID_STR_PROPTITLE_RADIOBUTTON NC_("RID_STR_PROPTITLE_RADIOBUTTON", "Option Button") +#define RID_STR_PROPTITLE_FIXEDTEXT NC_("RID_STR_PROPTITLE_FIXEDTEXT", "Label Field") +#define RID_STR_PROPTITLE_GROUPBOX NC_("RID_STR_PROPTITLE_GROUPBOX", "Group Box") +#define RID_STR_PROPTITLE_IMAGEBUTTON NC_("RID_STR_PROPTITLE_IMAGEBUTTON", "Image Button") +#define RID_STR_PROPTITLE_IMAGECONTROL NC_("RID_STR_PROPTITLE_IMAGECONTROL", "Image Control") +#define RID_STR_PROPTITLE_FILECONTROL NC_("RID_STR_PROPTITLE_FILECONTROL", "File Selection") +#define RID_STR_PROPTITLE_SCROLLBAR NC_("RID_STR_PROPTITLE_SCROLLBAR", "Scrollbar") +#define RID_STR_PROPTITLE_SPINBUTTON NC_("RID_STR_PROPTITLE_SPINBUTTON", "Spin Button") +#define RID_STR_PROPTITLE_NAVBAR NC_("RID_STR_PROPTITLE_NAVBAR", "Navigation Bar") + +/* 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..9d7ffb9ef --- /dev/null +++ b/framework/inc/targets.h @@ -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 . + */ + +#pragma once + +#include <rtl/ustring.hxx> + +namespace framework{ + +// Values for special frame search ... sTargetFrameName of findFrame() or queryDispatch() or loadComponentFromURL() + +inline constexpr OUStringLiteral SPECIALTARGET_SELF = u"_self"; // The frame himself is searched. +#define SPECIALTARGET_PARENT u"_parent" // The direct parent frame is searched. +inline constexpr OUStringLiteral SPECIALTARGET_TOP = u"_top"; // Search at our parents for the first task (if any exist) or a frame without a parent. +inline constexpr OUStringLiteral SPECIALTARGET_BLANK = u"_blank"; // Create a new task. +inline constexpr OUStringLiteral SPECIALTARGET_DEFAULT = u"_default"; // Create a new task or recycle an existing one +inline constexpr OUStringLiteral SPECIALTARGET_BEAMER = u"_beamer"; // special frame in hierarchy +inline constexpr OUStringLiteral SPECIALTARGET_HELPTASK = u"OFFICE_HELP_TASK"; // special name for our help task + +} // namespace framework + +/* 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..262de19f5 --- /dev/null +++ b/framework/inc/taskcreatordefs.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 . + */ + +#pragma once + +#include <rtl/ustring.hxx> + +/// [XFrame] if it's set, it will be used as parent frame for the new created frame. +inline constexpr OUStringLiteral ARGUMENT_PARENTFRAME = u"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. + */ +inline constexpr OUStringLiteral ARGUMENT_FRAMENAME = u"FrameName"; // OUString + +/// [sal_Bool] If it's set to sal_True we will make the new created frame visible. +inline constexpr OUStringLiteral ARGUMENT_MAKEVISIBLE = u"MakeVisible"; // sal_Bool + +/** [sal_Bool] If not "ContainerWindow" property is set it force creation of a + top level window as new container window. + */ +inline constexpr OUStringLiteral ARGUMENT_CREATETOPWINDOW = u"CreateTopWindow"; // sal_Bool + +/// [Rectangle] Place the new created frame on this place and resize the container window. +inline constexpr OUStringLiteral ARGUMENT_POSSIZE = u"PosSize"; // Rectangle + +/// [XWindow] an outside created window, used as container window of the new created frame. +inline constexpr OUStringLiteral ARGUMENT_CONTAINERWINDOW = u"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 + */ +inline constexpr OUStringLiteral ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE + = u"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 ! + */ +inline constexpr OUStringLiteral ARGUMENT_ENABLE_TITLEBARUPDATE + = u"EnableTitleBarUpdate"; // sal_Bool + +/* 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..24c273be6 --- /dev/null +++ b/framework/inc/threadhelp/transactionguard.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 . + */ + +#pragma once + +#include <framework/transactionmanager.hxx> + +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; +}; + +} + +/* 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..66bedb153 --- /dev/null +++ b/framework/inc/toolboxconfiguration.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 . + */ +#pragma once + +#include <sal/types.h> + +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 <typename > class Reference; } + +namespace framework +{ + +class 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..feb5fe8ea --- /dev/null +++ b/framework/inc/uiconfiguration/globalsettings.hxx @@ -0,0 +1,52 @@ +/* -*- 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 <com/sun/star/uno/XComponentContext.hpp> + +namespace framework +{ + +class GlobalSettings +{ + public: + GlobalSettings( css::uno::Reference< css::uno::XComponentContext > xContext ); + ~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 + +/* 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..bba9aaed9 --- /dev/null +++ b/framework/inc/uiconfiguration/graphicnameaccess.hxx @@ -0,0 +1,54 @@ +/* -*- 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 <unordered_map> + +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <cppuhelper/implbase.hxx> + +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<OUString, css::uno::Reference< css::graphic::XGraphic >> NameGraphicHashMap; + NameGraphicHashMap m_aNameToElementMap; + css::uno::Sequence< OUString > m_aSeq; + }; +} + +/* 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..aacc8bbd3 --- /dev/null +++ b/framework/inc/uiconfiguration/imagemanager.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 <memory> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ui/XImageManager.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <rtl/ustring.hxx> + +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, bool bForModule ); + 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<OUString> 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<ImageManagerImpl> m_pImpl; + }; +} + +/* 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..54ac4b168 --- /dev/null +++ b/framework/inc/uiconfiguration/imagetype.hxx @@ -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 . + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include <unordered_map> + +namespace framework +{ + +typedef std::unordered_map< OUString, + OUString > CommandToImageNameMap; +typedef std::unordered_map< OUString, + bool > CommandMap; + +} + +/* 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..bec99da06 --- /dev/null +++ b/framework/inc/uiconfiguration/windowstateproperties.hxx @@ -0,0 +1,41 @@ +/* -*- 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 <rtl/ustring.hxx> + +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_LOCKED = u"Locked"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKED = u"Docked"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_VISIBLE = u"Visible"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKINGAREA = u"DockingArea"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKPOS = u"DockPos"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKSIZE = u"DockSize"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_POS = u"Pos"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_SIZE = u"Size"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_UINAME = u"UIName"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_INTERNALSTATE = u"InternalState"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_STYLE = u"Style"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_CONTEXT = u"ContextSensitive"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_HIDEFROMENU = u"HideFromToolbarMenu"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_NOCLOSE = u"NoClose"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_SOFTCLOSE = u"SoftClose"; +inline constexpr OUStringLiteral WINDOWSTATE_PROPERTY_CONTEXTACTIVE = u"ContextActive"; + +/* 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..ffe40713b --- /dev/null +++ b/framework/inc/uielement/FixedImageToolbarController.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 . + */ + +#pragma once + +#include <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> +#include <vcl/vclptr.hxx> + +class ToolBox; + +namespace framework +{ +class FixedImageControl; + +class FixedImageToolbarController final : public ComplexToolbarController +{ +public: + FixedImageToolbarController(const css::uno::Reference<css::uno::XComponentContext>& rxContext, + const css::uno::Reference<css::frame::XFrame>& rFrame, + ToolBox* pToolBar, ToolBoxItemId 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<FixedImageControl> m_pFixedImageControl; + sal_Int16 m_eSymbolSize; +}; +} // namespace framework + +/* 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..bcf1d093f --- /dev/null +++ b/framework/inc/uielement/FixedTextToolbarController.hxx @@ -0,0 +1,52 @@ +/* -*- 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 <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> + +class ToolBox; + +namespace framework +{ +class FixedTextControl; + +class FixedTextToolbarController final : public ComplexToolbarController +{ +public: + FixedTextToolbarController(const css::uno::Reference<css::uno::XComponentContext>& rxContext, + const css::uno::Reference<css::frame::XFrame>& rFrame, + ToolBox* pToolBar, ToolBoxItemId 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<css::beans::PropertyValue> + getExecuteArgs(sal_Int16 KeyModifier) const override; + + VclPtr<FixedTextControl> m_pFixedTextControl; +}; +} + +/* 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..68cfc0ff3 --- /dev/null +++ b/framework/inc/uielement/addonstoolbarwrapper.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 . + */ + +#pragma once + +#include <helper/uielementwrapperbase.hxx> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +namespace framework +{ + +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; +}; + +} + +/* 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..759775ef8 --- /dev/null +++ b/framework/inc/uielement/buttontoolbarcontroller.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 <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/frame/XToolbarController.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/weak.hxx> +#include <vcl/vclptr.hxx> + +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( css::uno::Reference< css::uno::XComponentContext > xContext, + ToolBox* pToolBar, + OUString aCommand ); + virtual ~ButtonToolbarController() override; + + // XInterface + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept 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<ToolBox> m_pToolbar; +}; + +} + +/* 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..126aab650 --- /dev/null +++ b/framework/inc/uielement/comboboxtoolbarcontroller.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 . + */ + +#pragma once + +#include <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> + +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, + ToolBoxItemId 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<ComboBoxControl> m_pComboBox; +}; + +} + +/* 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..a93c693e6 --- /dev/null +++ b/framework/inc/uielement/commandinfo.hxx @@ -0,0 +1,45 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <vcl/toolbox.hxx> + +#include <unordered_map> +#include <vector> + +namespace framework +{ + +struct CommandInfo +{ + CommandInfo() : nId( 0 ), + nImageInfo( 0 ) {} + + ::std::vector< ToolBoxItemId > aIds; + ToolBoxItemId nId; + sal_Int16 nImageInfo; +}; + +typedef std::unordered_map<OUString, CommandInfo> CommandToInfoMap; + +} // namespace framework + +/* 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..0aa10471b --- /dev/null +++ b/framework/inc/uielement/complextoolbarcontroller.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 . + */ + +#pragma once + +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/ControlCommand.hpp> +#include <com/sun/star/frame/XControlNotificationListener.hpp> + +#include <svtools/toolboxcontroller.hxx> +#include <tools/link.hxx> +#include <vcl/vclptr.hxx> + +class ToolBox; + +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, + ToolBoxItemId 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: + 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<ToolBox> m_xToolbar; + ToolBoxItemId m_nID; + bool m_bMadeInvisible; + mutable css::util::URL m_aURL; + css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; +}; + +} + +/* 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..e25edc57f --- /dev/null +++ b/framework/inc/uielement/constitemcontainer.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 . + */ + +#pragma once + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/propshlp.hxx> + +#include <vector> + +namespace framework +{ + +class RootItemContainer; +class ItemContainer; +class 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() noexcept; + 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<css::uno::Sequence< css::beans::PropertyValue >>::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; +}; + +} + +/* 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..cb0157862 --- /dev/null +++ b/framework/inc/uielement/dropdownboxtoolbarcontroller.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 . + */ + +#pragma once + +#include <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> +#include <vcl/vclptr.hxx> + +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, + ToolBoxItemId 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<ListBoxControl> m_pListBoxControl; +}; + +} + +/* 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..c45aa3893 --- /dev/null +++ b/framework/inc/uielement/edittoolbarcontroller.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 . + */ + +#pragma once + +#include <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> + +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, + ToolBoxItemId 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<EditControl> m_pEditControl; +}; + +} + +/* 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..b98e8c7b1 --- /dev/null +++ b/framework/inc/uielement/fontmenucontroller.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XDispatch.hpp> + +#include <svtools/popupmenucontrollerbase.hxx> +#include <rtl/ustring.hxx> + +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; + + /* 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; + + // 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; + }; +} + +/* 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..d04bc637a --- /dev/null +++ b/framework/inc/uielement/fontsizemenucontroller.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/status/FontHeight.hpp> + +#include <svtools/popupmenucontrollerbase.hxx> +#include <rtl/ustring.hxx> +#include <tools/long.hxx> + +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; + + /* 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; + + // 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( tools::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::vector<tools::Long> m_aHeightArray; + css::frame::status::FontHeight m_aFontHeight; + css::uno::Reference< css::frame::XDispatch > m_xCurrentFontDispatch; + }; +} + +/* 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..304ffeec3 --- /dev/null +++ b/framework/inc/uielement/footermenucontroller.hxx @@ -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 . + */ + +#pragma once + +#include <uielement/headermenucontroller.hxx> + +namespace framework +{ + class FooterMenuController final : public HeaderMenuController + { + public: + FooterMenuController( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~FooterMenuController() override; + + /* 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; + }; +} + +/* 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..e0eae738f --- /dev/null +++ b/framework/inc/uielement/genericstatusbarcontroller.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 . + */ +#pragma once + +#include <svtools/statusbarcontroller.hxx> + +#include <com/sun/star/graphic/XGraphic.hpp> + +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; +}; + +} + +/* 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..cdd48fea4 --- /dev/null +++ b/framework/inc/uielement/headermenucontroller.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XModel.hpp> + +#include <svtools/popupmenucontrollerbase.hxx> + +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; + + /* 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; + + // 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; + }; +} + +/* 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..0e8ecbae6 --- /dev/null +++ b/framework/inc/uielement/imagebuttontoolbarcontroller.hxx @@ -0,0 +1,54 @@ +/* -*- 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 <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> +#include <vcl/image.hxx> + +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, + ToolBoxItemId 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 ); +}; + +} + +/* 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..5d5bc9c85 --- /dev/null +++ b/framework/inc/uielement/itemcontainer.hxx @@ -0,0 +1,80 @@ +/* -*- 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 <helper/shareablemutex.hxx> + +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + +#include <cppuhelper/implbase.hxx> + +#include <vector> + +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() noexcept; + + // 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<css::uno::Sequence< css::beans::PropertyValue >>::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; +}; + +} + +/* 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..c27f42b56 --- /dev/null +++ b/framework/inc/uielement/langselectionmenucontroller.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 <com/sun/star/frame/XDispatch.hpp> + +#include <svtools/popupmenucontrollerbase.hxx> +#include <rtl/ustring.hxx> + +#include <helper/mischelper.hxx> + +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; + + /* 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; + + // 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 ); + }; +} + +/* 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..7419f02a7 --- /dev/null +++ b/framework/inc/uielement/macrosmenucontroller.hxx @@ -0,0 +1,53 @@ +/* -*- 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 <svtools/popupmenucontrollerbase.hxx> + +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; + + /* 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; + + // 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::awt::XPopupMenu>& rPopupMenu); + void addScriptItems(const css::uno::Reference<css::awt::XPopupMenu>& rPopupMenu, sal_uInt16 startItemId); + }; +} + +/* 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..61bec0443 --- /dev/null +++ b/framework/inc/uielement/menubarmanager.hxx @@ -0,0 +1,194 @@ +/* -*- 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 <sal/config.h> + +#include <unordered_map> +#include <utility> +#include <vector> + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/FeatureStateEvent.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/frame/XPopupMenuController.hpp> +#include <com/sun/star/awt/XSystemDependentMenuPeer.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/frame/XUIControllerFactory.hpp> +#include <com/sun/star/ui/XUIConfigurationListener.hpp> +#include <com/sun/star/ui/XImageManager.hpp> +#include <com/sun/star/ui/XAcceleratorConfiguration.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> + +#include <rtl/ustring.hxx> +#include <vcl/menu.hxx> +#include <vcl/timer.hxx> +#include <comphelper/compbase.hxx> +#include <cppuhelper/weakref.hxx> +#include <framework/addonsoptions.hxx> + +namespace framework +{ + +struct PopupControllerEntry +{ + css::uno::WeakReference< css::frame::XDispatchProvider > m_xDispatchProvider; +}; + +typedef std::unordered_map< OUString, PopupControllerEntry > PopupControllerCache; + +class MenuBarManager final : + public comphelper::WeakComponentImplHelper< + css::frame::XStatusListener, + css::frame::XFrameActionListener, + css::ui::XUIConfigurationListener, + css::awt::XSystemDependentMenuPeer> +{ + 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 disposing(std::unique_lock<std::mutex>&) 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); + + struct MenuItemHandler + { + MenuItemHandler( sal_uInt16 aItemId, + css::uno::Reference< css::frame::XStatusListener > xManager, + css::uno::Reference< css::frame::XDispatch > xDispatch ) : + nItemId( aItemId ), + bMadeInvisible ( false ), + xSubMenuManager(std::move( xManager )), + xMenuItemDispatch(std::move( xDispatch )) {} + + 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<MenuItemHandler> >& aMenuShortCuts ); + 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<MenuItemHandler> >& aMenuShortCuts ); + static void MergeAddonMenus( Menu* pMenuBar, const MergeMenuInstructionContainer&, const OUString& aModuleIdentifier ); + + MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId ); + bool CreatePopupMenuController( MenuItemHandler* pMenuItemHandler, + const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, + const OUString& rModuleIdentifier ); + void AddMenu(MenuBarManager* pSubMenuManager,const OUString& _sItemCommand,sal_uInt16 _nItemId); + sal_uInt16 FillItemCommand(OUString& _rItemCommand, Menu* _pMenu,sal_uInt16 _nIndex) const; + void SetHdl(); + + bool m_bDeleteMenu; + bool m_bActive; + bool m_bShowMenuImages; + bool m_bRetrieveImages; + bool m_bAcceleratorCfg; + bool m_bHasMenuBar; + OUString m_aModuleIdentifier; + VclPtr<Menu> m_pVCLMenu; + css::uno::Reference< css::frame::XFrame > m_xFrame; + css::uno::Reference< css::frame::XUIControllerFactory > m_xPopupMenuControllerFactory; + ::std::vector< std::unique_ptr<MenuItemHandler> > 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_xDeferredItemContainer; + OUString m_sIconTheme; + Timer m_aAsyncSettingsTimer; +}; + +} // namespace + +/* 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..16bb8ec67 --- /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 . + */ + +#pragma once + +#include <com/sun/star/beans/PropertyValue.hpp> + +#include <rtl/ustring.hxx> +#include <vcl/menu.hxx> + +#include <string_view> +#include <vector> + +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<Menu> pPopupMenu; + sal_uInt16 nPos; + sal_Int32 nLevel; + RPResultInfo eResult; +}; + +namespace MenuBarMerger +{ + bool IsCorrectContext( + std::u16string_view aContext, std::u16string_view aModuleIdentifier ); + + void RetrieveReferencePath( std::u16string_view, + std::vector< OUString >& aReferencePath ); + ReferencePathInfo FindReferencePath( const std::vector< OUString >& aReferencePath, Menu* pMenu ); + sal_uInt16 FindMenuItem( std::u16string_view 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, + std::u16string_view rMergeCommand, + std::u16string_view rMergeCommandParameter, + const OUString& rModuleIdentifier, + const AddonMenuContainer& rAddonMenuItems ); + bool ProcessFallbackOperation( const ReferencePathInfo& aRefPathInfo, + sal_uInt16& rItemId, + std::u16string_view rMergeCommand, + std::u16string_view rMergeFallback, + const ::std::vector< OUString >& rReferencePath, + std::u16string_view 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, + std::u16string_view rMergeCommandParameter ); + bool CreateSubMenu( Menu* pSubMenu, + sal_uInt16& nItemId, + const OUString& rModuleIdentifier, + const AddonMenuContainer& rAddonSubMenu ); +} + +} // namespace framework + +/* 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..d696ec6c3 --- /dev/null +++ b/framework/inc/uielement/menubarwrapper.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 . + */ + +#pragma once + +#include <helper/uiconfigelementwrapperbase.hxx> +#include <uielement/menubarmanager.hxx> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/container/XNameAccess.hpp> + +namespace framework +{ + +class MenuBarWrapper final : public UIConfigElementWrapperBase, + public css::container::XNameAccess + +{ + public: + MenuBarWrapper( css::uno::Reference< css::uno::XComponentContext > xContext ); + virtual ~MenuBarWrapper() override; + + // XInterface, XTypeProvider + virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; + virtual void SAL_CALL acquire() noexcept override; + virtual void SAL_CALL release() noexcept override; + virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override; + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + 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 + +/* 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..57e58239f --- /dev/null +++ b/framework/inc/uielement/newmenucontroller.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 <com/sun/star/ui/XAcceleratorConfiguration.hpp> + +#include <svtools/popupmenucontrollerbase.hxx> +#include <rtl/ustring.hxx> +#include <vcl/menu.hxx> + +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; + + /* 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; + + // 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(); + void determineAndSetNewDocAccel(const css::awt::KeyEvent& 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; + }; +} + +/* 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..5b6ca9019 --- /dev/null +++ b/framework/inc/uielement/progressbarwrapper.hxx @@ -0,0 +1,82 @@ +/* -*- 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 <helper/uielementwrapperbase.hxx> + +#include <com/sun/star/awt/XWindow.hpp> + +#include <cppuhelper/weakref.hxx> + +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 + +/* 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..cdfc82fad --- /dev/null +++ b/framework/inc/uielement/rootitemcontainer.hxx @@ -0,0 +1,125 @@ +/* -*- 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 <helper/shareablemutex.hxx> + +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/propshlp.hxx> + +#include <vector> + +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: + RootItemContainer(); + RootItemContainer( const css::uno::Reference< css::container::XIndexAccess >& rItemAccessContainer ); + virtual ~RootItemContainer() override; + + // XInterface + virtual void SAL_CALL acquire() noexcept override + { OWeakObject::acquire(); } + virtual void SAL_CALL release() noexcept 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 const css::uno::Sequence< sal_Int8 >& getUnoTunnelId() noexcept; + 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<css::uno::Sequence< css::beans::PropertyValue >>::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; +}; + +} + +/* 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..609f4ec01 --- /dev/null +++ b/framework/inc/uielement/spinfieldtoolbarcontroller.hxx @@ -0,0 +1,73 @@ +/* -*- 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 <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> +#include <vcl/vclptr.hxx> + +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, + ToolBoxItemId nID, + sal_Int32 nWidth, + const OUString& aCommand ); + virtual ~SpinfieldToolbarController() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + // called from SpinfieldControl + void Modify(); + void GetFocus(); + void LoseFocus(); + void Activate(); + + OUString FormatOutputString(double fValue); + 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 ); + + bool m_bFloat; + double m_nMax; + double m_nMin; + double m_nValue; + double m_nStep; + VclPtr<SpinfieldControl> m_pSpinfieldControl; + OUString m_aOutFormat; +}; + +} + +/* 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..6d33396db --- /dev/null +++ b/framework/inc/uielement/statusbar.hxx @@ -0,0 +1,52 @@ +/* -*- 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 <uielement/statusbarmanager.hxx> + +#include <vcl/status.hxx> + +namespace framework +{ + +class FrameworkStatusBar final : 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; +}; + +} + +/* 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..b9597bd2a --- /dev/null +++ b/framework/inc/uielement/statusbaritem.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 . + */ +#pragma once + +#include <com/sun/star/ui/XStatusbarItem.hpp> +#include <comphelper/compbase.hxx> +#include <vcl/vclptr.hxx> + +class StatusBar; + +namespace framework +{ + +struct AddonStatusbarItemData; + +typedef comphelper::WeakComponentImplHelper< css::ui::XStatusbarItem > StatusbarItem_Base; + +class StatusbarItem final : public StatusbarItem_Base +{ +public: + explicit StatusbarItem( + StatusBar *pStatusBar, + sal_uInt16 nId, + OUString aCommand ); + virtual ~StatusbarItem() override; + + void disposing(std::unique_lock<std::mutex>&) 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<StatusBar> m_pStatusBar; + sal_uInt16 m_nId; + sal_uInt16 m_nStyle; + OUString m_aCommand; + +}; + +} + +/* 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..c893e4abd --- /dev/null +++ b/framework/inc/uielement/statusbarmanager.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 . + */ + +#pragma once + +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XStatusbarController.hpp> +#include <com/sun/star/frame/XUIControllerFactory.hpp> +#include <com/sun/star/ui/XUIConfigurationListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <comphelper/interfacecontainer4.hxx> +#include <vcl/status.hxx> +#include <vcl/vclptr.hxx> +#include <map> +#include <mutex> + +namespace framework +{ + +class FrameworkStatusBar; +class StatusBarManager final: public ::cppu::WeakImplHelper< + css::frame::XFrameActionListener, + css::lang::XComponent, + css::ui::XUIConfigurationListener > + +{ + friend class FrameworkStatusBar; + + public: + StatusBarManager( css::uno::Reference< css::uno::XComponentContext > xContext, + css::uno::Reference< css::frame::XFrame > xFrame, + 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<StatusBar> m_pStatusBar; + css::uno::Reference< css::frame::XFrame > m_xFrame; + StatusBarControllerMap m_aControllerMap; + std::mutex m_mutex; + comphelper::OInterfaceContainerHelper4<XEventListener> m_aListenerContainer; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::frame::XUIControllerFactory > m_xStatusbarControllerFactory; +}; + +} + +/* 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..1eaec5a88 --- /dev/null +++ b/framework/inc/uielement/statusbarmerger.hxx @@ -0,0 +1,75 @@ +/* -*- 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 <sal/config.h> + +#include <string_view> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <rtl/ustring.hxx> +#include <vcl/status.hxx> + +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( std::u16string_view aContext ); + + bool ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence, + AddonStatusbarItemContainer& rContainer ); + + sal_uInt16 FindReferencePos( StatusBar* pStatusbar, + std::u16string_view rReferencePoint ); + + bool ProcessMergeOperation( StatusBar* pStatusbar, + sal_uInt16 nPos, + sal_uInt16& rItemId, + std::u16string_view rMergeCommand, + std::u16string_view rMergeCommandParameter, + const AddonStatusbarItemContainer& rItems ); + + bool ProcessMergeFallback( StatusBar* pStatusbar, + sal_uInt16& rItemId, + std::u16string_view rMergeCommand, + std::u16string_view rMergeFallback, + const AddonStatusbarItemContainer& rItems ); +} + +} + +/* 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..203ae6956 --- /dev/null +++ b/framework/inc/uielement/statusbarwrapper.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 . + */ + +#pragma once + +#include <helper/uiconfigelementwrapperbase.hxx> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +namespace framework +{ + +class StatusBarWrapper final : public UIConfigElementWrapperBase +{ + public: + StatusBarWrapper( + css::uno::Reference< css::uno::XComponentContext > xContext ); + 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 + +/* 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..abfae53e7 --- /dev/null +++ b/framework/inc/uielement/statusindicatorinterfacewrapper.hxx @@ -0,0 +1,53 @@ +/* -*- 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 <com/sun/star/task/XStatusIndicator.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/weakref.hxx> + +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; +}; + +} + +/* 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..45b1ad7ec --- /dev/null +++ b/framework/inc/uielement/styletoolbarcontroller.hxx @@ -0,0 +1,78 @@ +/* -*- 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/. + */ + +#pragma once + +#include <svtools/toolboxcontroller.hxx> +#include <com/sun/star/frame/XDispatchProvider.hpp> + +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, + css::uno::Reference< css::util::XURLTransformer > xUrlTransformer, + 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; +}; + +} + +/* 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..fe1143343 --- /dev/null +++ b/framework/inc/uielement/togglebuttontoolbarcontroller.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 . + */ + +#pragma once + +#include <com/sun/star/frame/ControlCommand.hpp> + +#include <uielement/complextoolbarcontroller.hxx> +#include <tools/link.hxx> + +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, + ToolBoxItemId 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; +}; + +} + +/* 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..1cfddd99e --- /dev/null +++ b/framework/inc/uielement/toolbarmanager.hxx @@ -0,0 +1,249 @@ +/* -*- 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 <uielement/commandinfo.hxx> + +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XUIControllerFactory.hpp> +#include <com/sun/star/frame/XSubToolbarController.hpp> +#include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/frame/XToolbarController.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/ui/XImageManager.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> + +#include <framework/addonsoptions.hxx> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> +#include <comphelper/interfacecontainer4.hxx> + +#include <tools/link.hxx> +#include <vcl/weld.hxx> +#include <vcl/window.hxx> +#include <vcl/timer.hxx> +#include <vcl/toolbox.hxx> + +#include <mutex> +#include <unordered_map> + +class PopupMenu; +class ToolBox; +class Menu; + +namespace framework +{ + +class ToolBarManager; + +class ToolBarManagerImpl +{ +public: + virtual ~ToolBarManagerImpl() = default; + virtual void Init() = 0; + virtual void Destroy() = 0; + virtual css::uno::Reference<css::awt::XWindow> GetInterface() = 0; + virtual css::uno::Reference<css::frame::XStatusListener> CreateToolBoxController( + const css::uno::Reference<css::frame::XFrame>& rFrame, + ToolBoxItemId nId, + const OUString& aCommandURL ) = 0; + virtual void InsertItem(ToolBoxItemId nId, + const OUString& rString, + const OUString& rCommandURL, + const OUString& rTooltip, + const OUString& rLabel, + ToolBoxItemBits nItemBits) = 0; + virtual void InsertSeparator() = 0; + virtual void InsertSpace() = 0; + virtual void InsertBreak() = 0; + virtual ToolBoxItemId GetItemId(sal_uInt16 nPos) = 0; + virtual ToolBoxItemId GetCurItemId() = 0; + virtual OUString GetItemCommand(ToolBoxItemId nId) = 0; + virtual sal_uInt16 GetItemCount() = 0; + virtual void SetItemCheckable(ToolBoxItemId nId) = 0; + virtual void HideItem(ToolBoxItemId nId, const OUString& rCommandURL) = 0; + virtual bool IsItemVisible(ToolBoxItemId nId, const OUString& rCommandURL) = 0; + virtual void Clear() = 0; + virtual void SetName(const OUString& rName) = 0; + virtual void SetHelpId(const OString& rHelpId) = 0; + virtual bool WillUsePopupMode() = 0; + virtual bool IsReallyVisible() = 0; + virtual void SetIconSize(ToolBoxButtonSize eSize) = 0; + virtual vcl::ImageType GetImageSize() = 0; + virtual void ConnectCallbacks(ToolBarManager* pManager) = 0; + virtual void SetMenuType(ToolBoxMenuType eType) = 0; + virtual void MergeToolbar(ToolBoxItemId & rItemId, + const OUString& rModuleIdentifier, + CommandToInfoMap& rCommandMap, + MergeToolbarInstruction& rInstruction) = 0; + virtual void SetItemImage(ToolBoxItemId nId, + const OUString& rCommandURL, + const Image& rImage) = 0; + virtual void UpdateSize() = 0; + virtual void SetItemWindow(ToolBoxItemId nItemId, vcl::Window* pNewWindow) = 0; +}; + +typedef ::cppu::WeakImplHelper< + css::frame::XFrameActionListener, + css::lang::XComponent, + css::ui::XUIConfigurationListener + > ToolbarManager_Base; + +class ToolBarManager final : public ToolbarManager_Base +{ + public: + ToolBarManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + OUString aResourceName, + ToolBox* pToolBar ); + ToolBarManager( const css::uno::Reference< css::uno::XComponentContext >& rxContext, + const css::uno::Reference< css::frame::XFrame >& rFrame, + OUString aResourceName, + weld::Toolbar* pToolBar, + weld::Builder* pBuilder ); + 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(); + void RequestImages(); + void FillToolbar( const css::uno::Reference< css::container::XIndexAccess >& rToolBarData ); + void FillAddonToolbar( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rAddonToolbar ); + 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 + }; + + enum ClickAction + { + Click, + DblClick, + Execute + }; + + struct ExecuteInfo + { + OUString aToolbarResName; + ExecuteCommand nCmd; + css::uno::Reference< css::frame::XLayoutManager > xLayoutManager; + css::uno::Reference< css::awt::XWindow > xWindow; + }; + + public: + void OnClick(bool bUseExecute = false); + void OnDropdownClick(bool bCreatePopupWindow = true); + + 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 ); + + private: + void Init(); + 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 RefreshImages(); + ToolBoxItemBits ConvertStyleToToolboxItemBits( sal_Int32 nStyle ); + css::uno::Reference< css::frame::XModel > GetModelFromFrame() const; + bool IsPluginMode() const; + void HandleClick(ClickAction eAction); + void setToolBarImage(const Image& _aImage,const CommandToInfoMap::const_iterator& _pIter); + void impl_elementChanged(bool _bRemove,const css::ui::ConfigurationEvent& Event ); + + typedef std::unordered_map< ToolBoxItemId, css::uno::Reference< css::frame::XStatusListener > > ToolBarControllerMap; + typedef ::std::vector< css::uno::Reference< css::frame::XSubToolbarController > > SubToolBarControllerVector; + typedef std::unordered_map<OUString, SubToolBarControllerVector> SubToolBarToSubToolBarControllerMap; + + bool m_bDisposed : 1, + m_bFrameActionRegistered : 1, + m_bUpdateControllers : 1; + + sal_Int16 m_eSymbolSize; + + std::unique_ptr<ToolBarManagerImpl> m_pImpl; + VclPtr<ToolBox> 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; + std::mutex m_mutex; + comphelper::OInterfaceContainerHelper4<XEventListener> m_aListenerContainer; + 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; +}; + +} + +/* 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..837507baa --- /dev/null +++ b/framework/inc/uielement/toolbarmerger.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 . + */ + +#pragma once + +#include <sal/config.h> + +#include <string_view> + +#include <uielement/commandinfo.hxx> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/weak.hxx> +#include <rtl/ustring.hxx> +#include <vcl/toolbox.hxx> + +namespace framework +{ + +struct AddonsParams +{ + OUString aControlType; + sal_uInt16 nWidth; +}; + +struct AddonToolbarItem +{ + OUString aCommandURL; + OUString aLabel; + 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( std::u16string_view aContext, std::u16string_view 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& rTarget, + OUString& rContext, + OUString& rControlType, + sal_uInt16& rWidth ); + + static ReferenceToolbarPathInfo FindReferencePoint( const ToolBox* pToolbar, + std::u16string_view rReferencePoint ); + + static bool ProcessMergeOperation( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + ToolBoxItemId& rItemId, + CommandToInfoMap& rCommandMap, + std::u16string_view rModuleIdentifier, + std::u16string_view rMergeCommand, + std::u16string_view rMergeCommandParameter, + const AddonToolbarItemContainer& rItems ); + + static bool ProcessMergeFallback( ToolBox* pToolbar, + ToolBoxItemId& rItemId, + CommandToInfoMap& rCommandMap, + std::u16string_view rModuleIdentifier, + std::u16string_view rMergeCommand, + std::u16string_view rMergeFallback, + const AddonToolbarItemContainer& rItems ); + + static void MergeItems( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + sal_uInt16 nModIndex, + ToolBoxItemId& rItemId, + CommandToInfoMap& rCommandMap, + std::u16string_view rModuleIdentifier, + const AddonToolbarItemContainer& rAddonToolbarItems ); + + static void ReplaceItem( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + ToolBoxItemId& rItemId, + CommandToInfoMap& rCommandMap, + std::u16string_view rModuleIdentifier, + const AddonToolbarItemContainer& rAddonToolbarItems ); + + static void RemoveItems( ToolBox* pToolbar, + ToolBox::ImplToolItems::size_type nPos, + std::u16string_view rMergeCommandParameter ); + + static rtl::Reference<::cppu::OWeakObject> CreateController( + const css::uno::Reference< css::uno::XComponentContext > & rxContext, + const css::uno::Reference< css::frame::XFrame > & xFrame, + ToolBox* pToolbar, + const OUString& rCommandURL, + ToolBoxItemId nId, + sal_uInt16 nWidth, + std::u16string_view rControlType ); + + static void CreateToolbarItem( ToolBox* pToolbox, + ToolBox::ImplToolItems::size_type nPos, + ToolBoxItemId nItemId, + const AddonToolbarItem& rAddonToolbarItem ); + + private: + ToolBarMerger( const ToolBarMerger& ) = delete; + ToolBarMerger& operator=( const ToolBarMerger& ) = delete; +}; + +} // namespace framework + +/* 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..cee2b0dac --- /dev/null +++ b/framework/inc/uielement/toolbarmodemenucontroller.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 . + */ + +#pragma once + +#include <svtools/popupmenucontrollerbase.hxx> + +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; + + /* 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; + + // 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; + + private: + void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu > const & rPopupMenu ); + + css::uno::Reference< css::uno::XComponentContext > m_xContext; + }; +} + +/* 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..99d64775d --- /dev/null +++ b/framework/inc/uielement/toolbarsmenucontroller.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 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 <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/ui/XUIConfigurationManager.hpp> + +#include <svtools/popupmenucontrollerbase.hxx> +#include <rtl/ustring.hxx> +#include <unotools/intlwrapper.hxx> + +#include <vector> + +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; + + /* 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; + + // 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; + }; +} + +/* 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..da90455b2 --- /dev/null +++ b/framework/inc/uielement/toolbarwrapper.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 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 <helper/uiconfigelementwrapperbase.hxx> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/ui/XUIFunctionListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> + +namespace weld +{ + class Builder; + class Container; + class Toolbar; +} + +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() noexcept override; + virtual void SAL_CALL release() noexcept 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; + + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xTopLevel; + std::unique_ptr<weld::Toolbar> m_xWeldedToolbar; +}; + +} + +/* 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..aeeb1f9aa --- /dev/null +++ b/framework/inc/uielement/uicommanddescription.hxx @@ -0,0 +1,95 @@ +/* -*- 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 <unordered_map> +#include <map> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/frame/XModuleManager2.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <comphelper/compbase.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <rtl/ustring.hxx> +#include <i18nlangtag/languagetag.hxx> + +namespace framework +{ +typedef comphelper::WeakComponentImplHelper< css::lang::XServiceInfo, + css::container::XNameAccess > UICommandDescription_BASE; + +class UICommandDescription : 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<OUString> 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); + void ensureGenericUICommandsForLanguage(const LanguageTag& rLanguage); + + OUString m_aPrivateResourceURL; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + ModuleToCommandFileMap m_aModuleToCommandFileMap; + std::map<LanguageTag, UICommandsHashMap> m_aUICommandsHashMap; + std::map<LanguageTag, 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..8e6f0c7de --- /dev/null +++ b/framework/inc/uielement/uielement.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 . + */ + +#pragma once + +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/DockingArea.hpp> +#include <com/sun/star/awt/Point.hpp> +#include <com/sun/star/awt/Size.hpp> + +#include <rtl/ustring.hxx> +#include <utility> +#include <vcl/toolbox.hxx> + +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( OUString aName, + OUString aType, + css::uno::Reference< css::ui::XUIElement > xUIElement + ) : m_aType(std::move( aType )), + m_aName(std::move( aName )), + m_xUIElement(std::move( xUIElement )), + 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 + +/* 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..a248a0d9f --- /dev/null +++ b/framework/inc/uielement/uielementtypenames.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 . + */ + +#pragma once + +#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" + +/* 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..af0345b49 --- /dev/null +++ b/framework/inc/uifactory/configurationaccessfactorymanager.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 . + */ + +#pragma once + +#include <sal/config.h> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <rtl/ustring.hxx> + +#include <mutex> +#include <string_view> +#include <unordered_map> + +namespace framework { + +class ConfigurationAccess_FactoryManager final : public ::cppu::WeakImplHelper< css::container::XContainerListener> +{ + public: + ConfigurationAccess_FactoryManager( const css::uno::Reference< css::uno::XComponentContext>& rxContext, OUString _sRoot ); + virtual ~ConfigurationAccess_FactoryManager() override; + + void readConfigurationData(); + + OUString getFactorySpecifierFromTypeNameModule( std::u16string_view rType, std::u16string_view rName, std::u16string_view rModule ) const; + void addFactorySpecifierToTypeNameModule( std::u16string_view rType, std::u16string_view rName, std::u16string_view rModule, const OUString& aServiceSpecifier ); + void removeFactorySpecifierFromTypeNameModule( std::u16string_view rType, std::u16string_view rName, std::u16string_view 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<OUString, + OUString> + { + }; + + bool impl_getElementProps( const css::uno::Any& rElement, OUString& rType, OUString& rName, OUString& rModule, OUString& rServiceSpecifier ) const; + + mutable std::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 + +/* 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..4e5ea6c4b --- /dev/null +++ b/framework/inc/uifactory/factoryconfiguration.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 . + */ + +#pragma once + +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <rtl/ustring.hxx> + +#include <mutex> +#include <string_view> +#include <unordered_map> +#include <utility> + +// 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, OUString _sRoot ); + virtual ~ConfigurationAccess_ControllerFactory() override; + + void readConfigurationData(); + + OUString getServiceFromCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule ) const; + OUString getValueFromCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule ) const; + void addServiceToCommandModule( std::u16string_view rCommandURL, std::u16string_view rModule, const OUString& rServiceSpecifier ); + void removeServiceFromCommandModule( std::u16string_view rCommandURL, std::u16string_view 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: + void updateConfigurationDataImpl(); + + struct ControllerInfo + { + OUString m_aImplementationName; + OUString m_aValue; + ControllerInfo(OUString _aImplementationName, OUString _aValue) : m_aImplementationName(std::move(_aImplementationName)),m_aValue(std::move(_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 std::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 + +/* 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..a3ec76daa --- /dev/null +++ b/framework/inc/uifactory/menubarfactory.hxx @@ -0,0 +1,73 @@ +/* -*- 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 <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/ui/XUIElementFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/supportsservice.hxx> +#include <rtl/ustring.hxx> + +namespace framework +{ +typedef ::cppu::WeakImplHelper< + css::lang::XServiceInfo, + css::ui::XUIElementFactory> MenuBarFactory_BASE; + + class MenuBarFactory : public MenuBarFactory_BASE + { + public: + MenuBarFactory( 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<OUString> 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 + ,std::u16string_view 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; + }; +} + +/* 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..775463013 --- /dev/null +++ b/framework/inc/xml/acceleratorconfigurationreader.hxx @@ -0,0 +1,133 @@ +/* -*- 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 <accelerators/acceleratorcache.hxx> + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <com/sun/star/xml/sax/XLocator.hpp> + +#include <cppuhelper/implbase.hxx> +#include <rtl/ustring.hxx> + +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(std::u16string_view sElement); + + /** TODO document me */ + static EXMLAttribute implst_classifyAttribute(std::u16string_view sAttribute); + + /** TODO document me */ + OUString implts_getErrorLineString(); +}; + +} // namespace framework + +/* 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..ae5580675 --- /dev/null +++ b/framework/inc/xml/acceleratorconfigurationwriter.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 . + */ + +#pragma once + +#include <accelerators/acceleratorcache.hxx> + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <rtl/ustring.hxx> + +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, + 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 + +/* 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..4b17b7c98 --- /dev/null +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -0,0 +1,54 @@ +/* -*- 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 <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <vector> + +namespace framework +{ + +struct ImageItemDescriptor +{ + OUString aCommandURL; // URL command to dispatch +}; + +typedef std::vector<ImageItemDescriptor> 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 + +/* 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..d8cd84f4d --- /dev/null +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -0,0 +1,133 @@ +/* -*- 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 <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <xml/imagesconfiguration.hxx> +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> + +#include <unordered_map> + +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 + +/* 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..f3a0238d0 --- /dev/null +++ b/framework/inc/xml/menudocumenthandler.hxx @@ -0,0 +1,222 @@ +/* -*- 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 <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.h> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> + +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 + +/* 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..04f5bd4fe --- /dev/null +++ b/framework/inc/xml/saxnamespacefilter.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 . + */ + +#pragma once + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> +#include <xml/xmlnamespaces.hxx> +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> + +#include <stack> + +namespace framework +{ + +// workaround for incremental linking bugs in MSVC2015 +class SAL_DLLPUBLIC_TEMPLATE SaxNamespaceFilter_Base : public cppu::WeakImplHelper< css::xml::sax::XDocumentHandler > {}; + +class 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; +}; + +} + +/* 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..829cd0b97 --- /dev/null +++ b/framework/inc/xml/statusbardocumenthandler.hxx @@ -0,0 +1,134 @@ +/* -*- 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 <statusbarconfiguration.hxx> + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> + +#include <unordered_map> + +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<OUString, + StatusBar_XML_Entry > + { + }; + + 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 + +/* 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..399693044 --- /dev/null +++ b/framework/inc/xml/toolboxconfigurationdefines.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 . + */ +#pragma once + +#include <rtl/ustring.hxx> + +#define XMLNS_TOOLBAR "http://openoffice.org/2001/toolbar" +#define XMLNS_XLINK "http://www.w3.org/1999/xlink" +inline constexpr OUStringLiteral XMLNS_TOOLBAR_PREFIX = u"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" + +inline constexpr OUStringLiteral ELEMENT_NS_TOOLBAR = u"toolbar:toolbar"; +inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARITEM = u"toolbar:toolbaritem"; +inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARSPACE = u"toolbar:toolbarspace"; +inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARBREAK = u"toolbar:toolbarbreak"; +inline constexpr OUStringLiteral ELEMENT_NS_TOOLBARSEPARATOR = u"toolbar:toolbarseparator"; + +inline constexpr OUStringLiteral ATTRIBUTE_XMLNS_TOOLBAR = u"xmlns:toolbar"; +inline constexpr OUStringLiteral ATTRIBUTE_XMLNS_XLINK = u"xmlns:xlink"; + +inline constexpr OUStringLiteral ATTRIBUTE_TYPE_CDATA = u"CDATA"; + +#define ATTRIBUTE_BOOLEAN_TRUE "true" +inline constexpr OUStringLiteral ATTRIBUTE_BOOLEAN_FALSE = u"false"; + +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_RADIO = u"radio"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_AUTO = u"auto"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_LEFT = u"left"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_AUTOSIZE = u"autosize"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_DROPDOWN = u"dropdown"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_REPEAT = u"repeat"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_TEXT = u"text"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY = u"dropdownonly"; +inline constexpr OUStringLiteral ATTRIBUTE_ITEMSTYLE_IMAGE = u"image"; + +/* 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..79657e532 --- /dev/null +++ b/framework/inc/xml/toolboxdocumenthandler.hxx @@ -0,0 +1,158 @@ +/* -*- 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 <toolboxconfiguration.hxx> + +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <rtl/ustring.hxx> +#include <cppuhelper/implbase.hxx> + +#include <unordered_map> + +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<OUString, + ToolBox_XML_Entry> + { + }; + + 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 + +/* 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..1c01b03cc --- /dev/null +++ b/framework/inc/xml/xmlnamespaces.hxx @@ -0,0 +1,52 @@ +/* -*- 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 <map> + +#include <rtl/ustring.hxx> + +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; +}; + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |