diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /include/sfx2/sidebar | |
parent | Initial commit. (diff) | |
download | libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | include/sfx2/sidebar/AsynchronousCall.hxx | 55 | ||||
-rw-r--r-- | include/sfx2/sidebar/Context.hxx | 61 | ||||
-rw-r--r-- | include/sfx2/sidebar/ControllerItem.hxx | 82 | ||||
-rw-r--r-- | include/sfx2/sidebar/Deck.hxx | 111 | ||||
-rw-r--r-- | include/sfx2/sidebar/FocusManager.hxx | 149 | ||||
-rw-r--r-- | include/sfx2/sidebar/IContextChangeReceiver.hxx | 42 | ||||
-rw-r--r-- | include/sfx2/sidebar/ILayoutableWindow.hxx | 45 | ||||
-rw-r--r-- | include/sfx2/sidebar/Panel.hxx | 94 | ||||
-rw-r--r-- | include/sfx2/sidebar/PanelLayout.hxx | 48 | ||||
-rw-r--r-- | include/sfx2/sidebar/ResourceManager.hxx | 135 | ||||
-rw-r--r-- | include/sfx2/sidebar/Sidebar.hxx | 66 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarChildWindow.hxx | 49 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarController.hxx | 295 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarDockingWindow.hxx | 79 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarModelUpdate.hxx | 31 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarPanelBase.hxx | 102 | ||||
-rw-r--r-- | include/sfx2/sidebar/SidebarToolBox.hxx | 86 | ||||
-rw-r--r-- | include/sfx2/sidebar/TabBar.hxx | 129 | ||||
-rw-r--r-- | include/sfx2/sidebar/Theme.hxx | 245 |
19 files changed, 1904 insertions, 0 deletions
diff --git a/include/sfx2/sidebar/AsynchronousCall.hxx b/include/sfx2/sidebar/AsynchronousCall.hxx new file mode 100644 index 000000000..675e53b58 --- /dev/null +++ b/include/sfx2/sidebar/AsynchronousCall.hxx @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_ASYNCHRONOUSCALL_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_ASYNCHRONOUSCALL_HXX + +#include <tools/link.hxx> + +#include <functional> + +struct ImplSVEvent; + +namespace sfx2::sidebar { + +/** A simple asynchronous call via Application::PostUserCall. +*/ +class AsynchronousCall +{ +public: + typedef ::std::function<void()> Action; + + AsynchronousCall (const Action& rAction); + ~AsynchronousCall(); + + void RequestCall(); + void CancelRequest(); + void Sync(); + +private: + Action maAction; + ImplSVEvent * mnCallId; + + DECL_LINK(HandleUserCall, void*, void); +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Context.hxx b/include/sfx2/sidebar/Context.hxx new file mode 100644 index 000000000..b69838a8f --- /dev/null +++ b/include/sfx2/sidebar/Context.hxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXT_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXT_HXX + +#include <rtl/ustring.hxx> + +namespace sfx2::sidebar { + +class Context +{ +public: + OUString msApplication; + OUString msContext; + + Context(); + Context ( + const OUString& rsApplication, + const OUString& rsContext); + + /** When two contexts are matched against each other, then + application or context name may have the wildcard value 'any'. + In order to prefer matches without wildcards over matches with + wildcards we introduce an integer evaluation for matches. + */ + const static sal_Int32 NoMatch; + const static sal_Int32 OptimalMatch; + const static sal_Int32 ApplicationWildcardMatch; + const static sal_Int32 ContextWildcardMatch; + + /** Return the numeric value that describes how good the match + between two contexts is. + Smaller values represent better matches. + */ + sal_Int32 EvaluateMatch (const Context& rOther) const; + + bool operator== (const Context& rOther) const; + bool operator!= (const Context& rOther) const; +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ControllerItem.hxx b/include/sfx2/sidebar/ControllerItem.hxx new file mode 100644 index 000000000..ef75d0dc9 --- /dev/null +++ b/include/sfx2/sidebar/ControllerItem.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 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_CONTROLLERITEM_HXX +#define INCLUDED_SFX2_SIDEBAR_CONTROLLERITEM_HXX + +#include <sfx2/ctrlitem.hxx> + +namespace com::sun::star::lang { class XComponent; } + + +namespace sfx2::sidebar { + +/** The sfx2::sidebar::ControllerItem is a wrapper around the + SfxControllerItem that becomes necessary to allow objects (think + sidebar panels) to receive state changes without having one + SfxControllerItem per supported item as base class (which is not + possible in C++ anyway). + + It also gives access to the label and icon of a slot/command. +*/ +class SFX2_DLLPUBLIC ControllerItem final + : public SfxControllerItem +{ +public: + class SFX2_DLLPUBLIC ItemUpdateReceiverInterface + { + public: + virtual void NotifyItemUpdate( + const sal_uInt16 nSId, + const SfxItemState eState, + const SfxPoolItem* pState) = 0; + virtual void GetControlState( + const sal_uInt16 nSId, + boost::property_tree::ptree& rState) = 0; + virtual ~ItemUpdateReceiverInterface(); + }; + + /** This is the simpler constructor variant that still exists for + compatibility reasons. Note that GetLabel() and GetIcon() will + return empty strings/images. + */ + ControllerItem ( + const sal_uInt16 nId, + SfxBindings &rBindings, + ItemUpdateReceiverInterface& rItemUpdateReceiver); + + virtual ~ControllerItem() override; + + /** Force the controller item to call its NotifyItemUpdate + callback with up-to-date data. + */ + void RequestUpdate(); + +private: + + virtual void StateChanged (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState) override; + virtual void GetControlState (sal_uInt16 nSId, boost::property_tree::ptree& rState) override; + + ItemUpdateReceiverInterface& mrItemUpdateReceiver; +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx new file mode 100644 index 000000000..21e7dfad5 --- /dev/null +++ b/include/sfx2/sidebar/Deck.hxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX + +#include <sfx2/sidebar/Panel.hxx> + +#include <vcl/window.hxx> + +class ScrollBar; + +namespace sfx2::sidebar { + +class DeckDescriptor; +class DeckTitleBar; + +/** This is the parent window of the panels. + It displays the deck title. + + A deck consists of multiple panels. + E.g. Properties, Styles, Navigator. +*/ +class Deck final : public vcl::Window +{ +public: + Deck(const DeckDescriptor& rDeckDescriptor, + vcl::Window* pParentWindow, + const std::function<void()>& rCloserAction); + virtual ~Deck() override; + virtual void dispose() override; + + const OUString& GetId() const { return msId; } + + VclPtr<DeckTitleBar> const & GetTitleBar() const; + tools::Rectangle GetContentArea() const; + void ResetPanels (const SharedPanelContainer& rPanels); + const SharedPanelContainer& GetPanels() const { return maPanels; } + + Panel* GetPanel(OUString const & panelId); + + void RequestLayout(); + vcl::Window* GetPanelParentWindow(); + + /** Try to make the panel completely visible. + When the whole panel does not fit then make its top visible + and it off at the bottom. + */ + void ShowPanel (const Panel& rPanel); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rUpdateArea) override; + virtual void DataChanged (const DataChangedEvent& rEvent) override; + virtual bool EventNotify(NotifyEvent& rEvent) override; + virtual void Resize() override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + + static void PrintWindowSubTree (vcl::Window* pRoot, int nIndentation); + + sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; } + + class ScrollContainerWindow final : public vcl::Window + { + public: + ScrollContainerWindow(vcl::Window* pParentWindow); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rUpdateArea) override; + void SetSeparators(const ::std::vector<sal_Int32>& rSeparators); + private: + std::vector<sal_Int32> maSeparators; + }; + +private: + void RequestLayoutInternal(); + +private: + const OUString msId; + sal_Int32 mnMinimalWidth; + sal_Int32 mnMinimalHeight; + SharedPanelContainer maPanels; + VclPtr<DeckTitleBar> mpTitleBar; + VclPtr<vcl::Window> mpScrollClipWindow; + VclPtr<ScrollContainerWindow> mpScrollContainer; + VclPtr<vcl::Window> mpFiller; + VclPtr<ScrollBar> mpVerticalScrollBar; + + DECL_LINK(HandleVerticalScrollBarChange, ScrollBar*, void); + bool ProcessWheelEvent(CommandEvent const * pCommandEvent); + +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/FocusManager.hxx b/include/sfx2/sidebar/FocusManager.hxx new file mode 100644 index 000000000..afd32d017 --- /dev/null +++ b/include/sfx2/sidebar/FocusManager.hxx @@ -0,0 +1,149 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_FOCUSMANAGER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_FOCUSMANAGER_HXX + +#include <sfx2/sidebar/Panel.hxx> +#include <tools/link.hxx> +#include <vcl/keycod.hxx> + +class Button; + +namespace sfx2::sidebar { + +class DeckTitleBar; + +/** Concentrate all focus handling in this class. + + There is one ring of windows that accept the input focus which are + cycled through with the arrow keys: + - the closer in the deck title (present only when docked) + - the panel title bars + - the tab bar items + + When the focus is in a panel title then focus travels over + - the panel title + - the panel closer + - the panel content + + Once the focus is in the panel content then focus cycles through + all controls inside the panel but not back to the title bar of + the panel. Escape places the focus back in the panel title. +*/ +class FocusManager +{ +public: + FocusManager(const std::function<void(const Panel&)>& rShowPanelFunctor, + const std::function<bool(const sal_Int32)> &rIsDeckOpenFunctor); + ~FocusManager(); + + /** Forget all panels and buttons. Remove all window listeners. + */ + void Clear(); + + /** Transfer the focus into the sidebar tree of windows. This is + typically called from the SidebarChildWindow as result of + pressing the F6 key. + */ + void GrabFocus(); + void GrabFocusPanel(); + + void SetDeckTitle(DeckTitleBar* pDeckTitleBar); + void SetPanels(const SharedPanelContainer& rPanels); + void SetButtons(const ::std::vector<Button*>& rButtons); + +private: + VclPtr<DeckTitleBar> mpDeckTitleBar; + std::vector<VclPtr<Panel> > maPanels; + std::vector<VclPtr<Button> > maButtons; + const std::function<void(const Panel&)> maShowPanelFunctor; + const std::function<bool(const sal_Int32)> mbIsDeckOpenFunctor; + + enum PanelComponent + { + PC_DeckTitle, + PC_DeckToolBox, + PC_PanelTitle, + PC_PanelToolBox, + PC_PanelContent, + PC_TabBar, + PC_None + }; + class FocusLocation + { + public: + PanelComponent meComponent; + sal_Int32 mnIndex; + FocusLocation(const PanelComponent eComponent, const sal_Int32 nIndex); + }; + + /** Listen for key events for panels and buttons. + */ + DECL_LINK( WindowEventListener, VclWindowEvent&, void); + DECL_LINK(ChildEventListener, VclWindowEvent&, void); + + void ClearPanels(); + void ClearButtons(); + + /** Let the focus manager listen for window events for the given + window. + */ + void RegisterWindow(vcl::Window& rWindow); + void UnregisterWindow(vcl::Window& rWindow); + + /** Remove the window from the panel or the button container. + */ + void RemoveWindow(vcl::Window& rWindow); + + void FocusDeckTitle(); + bool IsDeckTitleVisible() const; + bool IsPanelTitleVisible(const sal_Int32 nPanelIndex) const; + + /** Set the focus to the title bar of the panel or, if the + title bar is not visible, directly to the panel. + @param nPanelIndex + Index of the panel to focus. + @param bFallbackToDeckTitle + When the panel title bar is not visible then The fallback + bias defines whether to focus the deck (true) or the panel + content (false) will be focused instead. + */ + void FocusPanel(const sal_Int32 nPanelIndex, + const bool bFallbackToDeckTitle); + + void FocusPanelContent(const sal_Int32 nPanelIndex); + void FocusButton(const sal_Int32 nButtonIndex); + void ClickButton(const sal_Int32 nButtonIndex); + void MoveFocusInsidePanel(const FocusLocation& rLocation, + const sal_Int32 nDirection); + void MoveFocusInsideDeckTitle(const FocusLocation& rLocation, + const sal_Int32 nDirection); + + void HandleKeyEvent(const vcl::KeyCode& rKeyCode, + const vcl::Window& rWindow); + + FocusLocation GetFocusLocation(const vcl::Window& rWindow) const; + +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/IContextChangeReceiver.hxx b/include/sfx2/sidebar/IContextChangeReceiver.hxx new file mode 100644 index 000000000..c3138c3f3 --- /dev/null +++ b/include/sfx2/sidebar/IContextChangeReceiver.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_ICONTEXTCHANGERECEIVER_HXX +#define INCLUDED_SFX2_SIDEBAR_ICONTEXTCHANGERECEIVER_HXX + +#include <sfx2/dllapi.h> + +namespace vcl { class EnumContext; } + + +namespace sfx2::sidebar { + + +class SFX2_DLLPUBLIC IContextChangeReceiver +{ +public: + virtual ~IContextChangeReceiver (); + + virtual void HandleContextChange (const vcl::EnumContext& rContext) = 0; +}; + +} // end of namespace ::sd::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ILayoutableWindow.hxx b/include/sfx2/sidebar/ILayoutableWindow.hxx new file mode 100644 index 000000000..cb78ec5ad --- /dev/null +++ b/include/sfx2/sidebar/ILayoutableWindow.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 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_ILAYOUTABLEWINDOW_HXX +#define INCLUDED_SFX2_SIDEBAR_ILAYOUTABLEWINDOW_HXX + +#include <sfx2/dllapi.h> +#include <sal/types.h> +#include <com/sun/star/ui/LayoutSize.hpp> + +namespace sfx2::sidebar { + + +class SFX2_DLLPUBLIC ILayoutableWindow +{ +public: + virtual ~ILayoutableWindow(); + + /** Return the preferred height with the constraint, that the + window will be set to the given width. + */ + virtual css::ui::LayoutSize GetHeightForWidth (const sal_Int32 nWidth) = 0; +}; + + +} // end of namespace ::sd::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Panel.hxx b/include/sfx2/sidebar/Panel.hxx new file mode 100644 index 000000000..cae82bbc1 --- /dev/null +++ b/include/sfx2/sidebar/Panel.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX + +#include <sfx2/dllapi.h> + +#include <vcl/window.hxx> + +#include <vector> + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::ui { class XSidebarPanel; } +namespace com::sun::star::ui { class XUIElement; } +namespace com::sun::star::awt { class XWindow; } + +namespace sfx2::sidebar { + +class PanelDescriptor; +class PanelTitleBar; +class Context; + +/** + * Multiple panels form a single deck. + * E.g. the Properties deck has panels like Styles, Character, paragraph. + */ +class SFX2_DLLPUBLIC Panel final : public vcl::Window +{ +public: + Panel(const PanelDescriptor& rPanelDescriptor, vcl::Window* pParentWindow, + const bool bIsInitiallyExpanded, const std::function<void()>& rDeckLayoutTrigger, + const std::function<Context()>& rContextAccess, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + virtual ~Panel() override; + virtual void dispose() override; + + VclPtr<PanelTitleBar> const & GetTitleBar() const; + bool IsTitleBarOptional() const { return mbIsTitleBarOptional;} + void SetUIElement (const css::uno::Reference<css::ui::XUIElement>& rxElement); + const css::uno::Reference<css::ui::XSidebarPanel>& GetPanelComponent() const { return mxPanelComponent;} + css::uno::Reference<css::awt::XWindow> GetElementWindow(); + void SetExpanded (const bool bIsExpanded); + bool IsExpanded() const { return mbIsExpanded;} + bool HasIdPredicate (const OUString& rsId) const; + const OUString& GetId() const { return msPanelId;} + void TriggerDeckLayouting() { maDeckLayoutTrigger(); } + + /// Set whether a panel should be present but invisible / inactive + void SetLurkMode(bool bLurk); + bool IsLurking() const { return mbLurking; } + + virtual void Resize() override; + virtual void DataChanged (const DataChangedEvent& rEvent) override; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + +private: + const OUString msPanelId; + VclPtr<PanelTitleBar> mpTitleBar; + const bool mbIsTitleBarOptional; + css::uno::Reference<css::ui::XUIElement> mxElement; + css::uno::Reference<css::ui::XSidebarPanel> mxPanelComponent; + bool mbIsExpanded; + bool mbLurking; + const std::function<void()> maDeckLayoutTrigger; + const std::function<Context()> maContextAccess; + + const css::uno::Reference<css::frame::XFrame>& mxFrame; + +}; +typedef std::vector<VclPtr<Panel> > SharedPanelContainer; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/PanelLayout.hxx b/include/sfx2/sidebar/PanelLayout.hxx new file mode 100644 index 000000000..c3a22d868 --- /dev/null +++ b/include/sfx2/sidebar/PanelLayout.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/. + */ + +#pragma once + +#include <sfx2/dllapi.h> + +#include <vcl/ctrl.hxx> +#include <vcl/timer.hxx> +#include <vcl/idle.hxx> +#include <vcl/weld.hxx> + +#include <com/sun/star/frame/XFrame.hpp> + +/// This class is the base for the Widget Layout-based sidebar panels. +class SFX2_DLLPUBLIC PanelLayout : public Control +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> m_xContainer; + +private: + Idle m_aPanelLayoutIdle; + bool m_bInClose; + css::uno::Reference<css::frame::XFrame> mxFrame; + + DECL_DLLPRIVATE_LINK(ImplHandlePanelLayoutTimerHdl, Timer*, void); + +public: + PanelLayout(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame> &rFrame); + virtual ~PanelLayout() override; + virtual void dispose() override; + + virtual Size GetOptimalSize() const override; + virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All) override; + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; + virtual bool EventNotify(NotifyEvent& rNEvt) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx new file mode 100644 index 000000000..97987ea1a --- /dev/null +++ b/include/sfx2/sidebar/ResourceManager.hxx @@ -0,0 +1,135 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_RESOURCEMANAGER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_RESOURCEMANAGER_HXX + +#include <unotools/confignode.hxx> +#include <map> +#include <set> +#include <svtools/miscopt.hxx> + +namespace com::sun::star::frame { class XController; } +namespace com::sun::star::frame { class XModel; } +namespace sfx2::sidebar { class DeckDescriptor; } +namespace sfx2::sidebar { class PanelDescriptor; } + +namespace sfx2::sidebar { + +class Context; +class ContextList; + +/** Read the content of the Sidebar.xcu file and provide access + methods so that the sidebar can easily decide which content panels + to display for a certain context. +*/ +class ResourceManager +{ +public: + + ResourceManager(); + ~ResourceManager(); + + std::shared_ptr<DeckDescriptor> GetDeckDescriptor(const OUString& rsDeckId) const; + std::shared_ptr<PanelDescriptor> GetPanelDescriptor(const OUString& rsPanelId) const; + + void UpdateModel(const css::uno::Reference<css::frame::XModel>& xModel); + + void InitDeckContext(const Context& rContex); + void SaveDecksSettings(const Context& rContext); + void SaveDeckSettings(const DeckDescriptor* pDeckDesc); + void SaveLastActiveDeck(const Context& rContext, const OUString& rActiveDeck); + + void disposeDecks(); + + class DeckContextDescriptor + { + public: + OUString msId; + bool mbIsEnabled; + }; + typedef std::vector<DeckContextDescriptor> DeckContextDescriptorContainer; + + class PanelContextDescriptor + { + public: + OUString msId; + OUString msMenuCommand; + bool mbIsInitiallyVisible; + bool mbShowForReadOnlyDocuments; + }; + typedef std::vector<PanelContextDescriptor> PanelContextDescriptorContainer; + + const DeckContextDescriptorContainer& GetMatchingDecks( + DeckContextDescriptorContainer& rDeckDescriptors, + const Context& rContext, + const bool bIsDocumentReadOnly, + const css::uno::Reference<css::frame::XController>& rxController); + + const PanelContextDescriptorContainer& GetMatchingPanels( + PanelContextDescriptorContainer& rPanelDescriptors, + const Context& rContext, + const OUString& rsDeckId, + const css::uno::Reference<css::frame::XController>& rxController); + + const OUString& GetLastActiveDeck( const Context& rContext ); + void SetLastActiveDeck( const Context& rContext, const OUString& rsDeckId ); + + /** Remember the expansions state per panel and context. + */ + void StorePanelExpansionState(const OUString& rsPanelId, + const bool bExpansionState, + const Context& rContext); + +private: + + + typedef std::vector<std::shared_ptr<DeckDescriptor>> DeckContainer; + DeckContainer maDecks; + + typedef std::vector<std::shared_ptr<PanelDescriptor>> PanelContainer; + PanelContainer maPanels; + mutable std::set<OUString> maProcessedApplications; + std::map<OUString, OUString> maLastActiveDecks; + + SvtMiscOptions maMiscOptions; + + void ReadDeckList(); + void ReadPanelList(); + void ReadLastActive(); + static void ReadContextList(const utl::OConfigurationNode& rNode, + ContextList& rContextList, + const OUString& rsDefaultMenuCommand); + + void ReadLegacyAddons(const css::uno::Reference<css::frame::XController>& rxController); + static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName); + static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames, + const utl::OConfigurationTreeRoot& aRoot); + bool IsDeckEnabled(const OUString& rsDeckId, + const Context& rContext, + const css::uno::Reference<css::frame::XController>& rxController); + + std::shared_ptr<DeckDescriptor> ImplGetDeckDescriptor(const OUString& rsDeckId) const; + std::shared_ptr<PanelDescriptor> ImplGetPanelDescriptor(const OUString& rsPanelId) const; +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Sidebar.hxx b/include/sfx2/sidebar/Sidebar.hxx new file mode 100644 index 000000000..2ac3b0e6a --- /dev/null +++ b/include/sfx2/sidebar/Sidebar.hxx @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_SIDEBAR_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBAR_HXX + +#include <sfx2/dllapi.h> +#include <rtl/ustring.hxx> + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::uno { template <typename > class Reference; } + + +namespace sfx2::sidebar { + +/** Accept requests for switching to certain panels or decks. +*/ +class SFX2_DLLPUBLIC Sidebar +{ +public: + /** Switch to the deck that contains the specified panel and make + sure that the panel is visible (expanded and scrolled into the + visible area.) + Note that most of the work is done asynchronously and that + this function probably returns before the requested panel is visible. + */ + static void ShowPanel ( + const OUString& rsPanelId, + const css::uno::Reference<css::frame::XFrame>& rxFrame, bool bFocus = false); + + /** Switch to the deck that contains the specified panel and toggle + the visibility of the panel (expanded and scrolled into the + visible area when visible) + Note that most of the work is done asynchronously and that + this function probably returns before the requested panel is visible. + */ + static void TogglePanel ( + const OUString& rsPanelId, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + static bool IsPanelVisible( + const OUString& rsPanelId, + const css::uno::Reference<css::frame::XFrame>& rxFrame); +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarChildWindow.hxx b/include/sfx2/sidebar/SidebarChildWindow.hxx new file mode 100644 index 000000000..6a9254df5 --- /dev/null +++ b/include/sfx2/sidebar/SidebarChildWindow.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_SIDEBARCHILDWINDOW_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBARCHILDWINDOW_HXX + +#include <sfx2/childwin.hxx> + + +namespace sfx2::sidebar { + +/** Outer container of the sidebar window. + + Has to be registered for every application via the + RegisterChildWindow() method from the RegisterControllers() method + of the applications DLL. +*/ +class SFX2_DLLPUBLIC SidebarChildWindow final : public SfxChildWindow +{ +public: + SidebarChildWindow(vcl::Window* pParent, sal_uInt16 nId, + SfxBindings* pBindings, SfxChildWinInfo* pInfo); + + SFX_DECL_CHILDWINDOW_WITHID(SidebarChildWindow); + + static sal_Int32 GetDefaultWidth(vcl::Window const * pWindow); +}; + + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx new file mode 100644 index 000000000..d03576b34 --- /dev/null +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -0,0 +1,295 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX + +#include <memory> +#include <sal/config.h> + +#include <sfx2/sidebar/AsynchronousCall.hxx> +#include <sfx2/sidebar/Context.hxx> +#include <sfx2/sidebar/Deck.hxx> +#include <sfx2/sidebar/FocusManager.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> +#include <sfx2/sidebar/TabBar.hxx> +#include <sfx2/viewfrm.hxx> + +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +#include <com/sun/star/frame/XFrameActionListener.hpp> +#include <com/sun/star/ui/XContextChangeEventListener.hpp> +#include <com/sun/star/ui/XSidebar.hpp> + +#include <optional> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> + +namespace com::sun::star::awt { class XWindowPeer; } +namespace com::sun::star::frame { class XDispatch; } +namespace com::sun::star::ui { class XUIElement; } + +typedef cppu::WeakComponentImplHelper < + css::ui::XContextChangeEventListener, + css::beans::XPropertyChangeListener, + css::ui::XSidebar, + css::frame::XStatusListener, + css::frame::XFrameActionListener + > SidebarControllerInterfaceBase; + +class SfxSplitWindow; + +namespace sfx2::sidebar { + +class DeckDescriptor; +class SidebarDockingWindow; + +class SFX2_DLLPUBLIC SidebarController + : private ::cppu::BaseMutex, + public SidebarControllerInterfaceBase +{ +public: + static rtl::Reference<SidebarController> create(SidebarDockingWindow* pParentWindow, + const SfxViewFrame* pViewFrame); + virtual ~SidebarController() override; + SidebarController(const SidebarController&) = delete; + SidebarController& operator=( const SidebarController& ) = delete; + + /** Return the SidebarController object that is associated with + the given XFrame. + @return + When there is no SidebarController object for the given + XFrame then <NULL/> is returned. + */ + static SidebarController* GetSidebarControllerForFrame ( + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + static void registerSidebarForFrame(SidebarController* pController, const css::uno::Reference<css::frame::XController>& xFrame); + + static void unregisterSidebarForFrame(SidebarController* pController, const css::uno::Reference<css::frame::XController>& xFrame); + + // ui::XContextChangeEventListener + virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) override; + + // XEventListener + virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) override; + + // beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent) override; + + // frame::XStatusListener + virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) override; + + // frame::XFrameActionListener + virtual void SAL_CALL frameAction (const css::frame::FrameActionEvent& rEvent) override; + + // ui::XSidebar + virtual void SAL_CALL requestLayout() override; + + void NotifyResize(); + + /** In some situations it is necessary to force an update of the + current deck and its panels. One reason is a change of the + view scale. Some panels can handle this only when + constructed. In this case we have to a context change and + also force that all panels are destroyed and created new. + */ + const static sal_Int32 SwitchFlag_NoForce = 0x00; + const static sal_Int32 SwitchFlag_ForceSwitch = 0x01; + const static sal_Int32 SwitchFlag_ForceNewDeck = 0x02; + const static sal_Int32 SwitchFlag_ForceNewPanels = 0x02; + + void OpenThenSwitchToDeck(const OUString& rsDeckId); + void OpenThenToggleDeck(const OUString& rsDeckId); + + /** Show only the tab bar, not the deck. + */ + void RequestCloseDeck(); + + /** Open the deck area and restore the parent window to its old width. + */ + void RequestOpenDeck(); + + /** Returns true when the given deck is the currently visible deck + */ + bool IsDeckVisible(const OUString& rsDeckId); + + bool IsDeckOpen(const sal_Int32 nIndex = -1); + + FocusManager& GetFocusManager() { return maFocusManager;} + + ResourceManager* GetResourceManager() { return mpResourceManager.get();} + + // std::unique_ptr<ResourceManager> GetResourceManager() { return mpResourceManager;} + + const Context& GetCurrentContext() const { return maCurrentContext;} + bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;} + + void SwitchToDeck(const OUString& rsDeckId); + void SwitchToDefaultDeck(); + bool WasFloatingDeckClosed() const { return mbFloatingDeckClosed; } + void SetFloatingDeckClosed(bool bWasClosed) { mbFloatingDeckClosed = bWasClosed; } + + void CreateDeck(const OUString& rDeckId); + void CreateDeck(const OUString& rDeckId, const Context& rContext, bool bForceCreate = false); + + ResourceManager::DeckContextDescriptorContainer GetMatchingDecks(); + ResourceManager::PanelContextDescriptorContainer GetMatchingPanels(const OUString& rDeckId); + + void notifyDeckTitle(const OUString& targetDeckId); + + void updateModel(const css::uno::Reference<css::frame::XModel>& xModel); + + void disposeDecks(); + + void FadeIn(); + void FadeOut(); + + tools::Rectangle GetDeckDragArea() const; + + css::uno::Reference<css::frame::XFrame> const & getXFrame() const {return mxFrame;} + + sal_Int32 getMaximumWidth() const { return mnMaximumSidebarWidth; } + void setMaximumWidth(sal_Int32 nMaximumWidth) { mnMaximumSidebarWidth = nMaximumWidth; } + + void saveDeckState(); + + void SyncUpdate(); + +private: + SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* pViewFrame); + + VclPtr<Deck> mpCurrentDeck; + VclPtr<SidebarDockingWindow> mpParentWindow; + const SfxViewFrame* mpViewFrame; + css::uno::Reference<css::frame::XFrame> mxFrame; + VclPtr<TabBar> mpTabBar; + Context maCurrentContext; + Context maRequestedContext; + css::uno::Reference<css::frame::XController> mxCurrentController; + /// Use a combination of SwitchFlag_* as value. + sal_Int32 mnRequestedForceFlags; + sal_Int32 mnMaximumSidebarWidth; + OUString msCurrentDeckId; + AsynchronousCall maPropertyChangeForwarder; + AsynchronousCall maContextChangeUpdate; + + /** Two flags control whether the deck is displayed or if only the + tab bar remains visible. + The mbIsDeckOpen flag stores the current state while + mbIsDeckRequestedOpen stores how this state should be. User + actions like clicking on the deck closer affect the + mbIsDeckRequestedOpen. Normally both flags have the same + value. A document being read-only can prevent the deck from opening. + */ + ::std::optional<bool> mbIsDeckRequestedOpen; + ::std::optional<bool> mbIsDeckOpen; + + bool mbFloatingDeckClosed; + + /** Before the deck is closed the sidebar width is saved into this variable, + so that it can be restored when the deck is reopened. + */ + sal_Int32 mnSavedSidebarWidth; + FocusManager maFocusManager; + css::uno::Reference<css::frame::XDispatch> mxReadOnlyModeDispatch; + bool mbIsDocumentReadOnly; + VclPtr<SfxSplitWindow> mpSplitWindow; + /** When the user moves the splitter then we remember the + width at that time. + */ + sal_Int32 mnWidthOnSplitterButtonDown; + /** Control that is temporarily used as replacement for the deck + to indicate that when the current mouse drag operation ends, the + sidebar will only show the tab bar. + */ + VclPtr<vcl::Window> mpCloseIndicator; + + DECL_LINK(WindowEventHandler, VclWindowEvent&, void); + /** Make maRequestedContext the current context. + */ + void UpdateConfigurations(); + + css::uno::Reference<css::ui::XUIElement> CreateUIElement ( + const css::uno::Reference<css::awt::XWindowPeer>& rxWindow, + const OUString& rsImplementationURL, + const bool bWantsCanvas, + const Context& rContext); + + void CreatePanels( + const OUString& rDeckId, + const Context& rContext); + VclPtr<Panel> CreatePanel ( + const OUString& rsPanelId, + vcl::Window* pParentWindow, + const bool bIsInitiallyExpanded, + const Context& rContext, + const VclPtr<Deck>& pDeck); + + void SwitchToDeck ( + const DeckDescriptor& rDeckDescriptor, + const Context& rContext); + + void ShowPopupMenu ( + const tools::Rectangle& rButtonBox, + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + VclPtr<PopupMenu> CreatePopupMenu ( + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + DECL_LINK(OnMenuItemSelected, Menu*, bool); + void BroadcastPropertyChange(); + + /** The close of the deck changes the width of the child window. + That is only possible if there is no other docking window docked above or below the sidebar. + Return whether the width of the child window can be modified. + */ + bool CanModifyChildWindowWidth(); + + /** Set the child window container to a new width. + Return the old width. + */ + sal_Int32 SetChildWindowWidth (const sal_Int32 nNewWidth); + + /** Update the icons displayed in the title bars of the deck and + the panels. This is called once when a deck is created and + every time when a data change event is processed. + */ + void UpdateTitleBarIcons(); + + void UpdateDeckOpenState(); + void RestrictWidth (sal_Int32 nWidth); + SfxSplitWindow* GetSplitWindow(); + void ProcessNewWidth (const sal_Int32 nNewWidth); + void UpdateCloseIndicator (const bool bIsIndicatorVisible); + + /** Typically called when a panel is focused via keyboard. + Tries to scroll the deck up or down to make the given panel + completely visible. + */ + void ShowPanel (const Panel& rPanel); + + virtual void SAL_CALL disposing() override; + + std::unique_ptr<ResourceManager> mpResourceManager; + +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx new file mode 100644 index 000000000..6d726ddd1 --- /dev/null +++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARDOCKINGWINDOW_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARDOCKINGWINDOW_HXX + +#include <sfx2/dockwin.hxx> + +#include <rtl/ref.hxx> + +class SfxViewShell; + +namespace svt { class AcceleratorExecute; } + +namespace sfx2::sidebar { + +class SidebarChildWindow; + +class SidebarController; + +class SidebarNotifyIdle; + +class SFX2_DLLPUBLIC SidebarDockingWindow final : public SfxDockingWindow +{ +public: + SidebarDockingWindow(SfxBindings* pBindings, SidebarChildWindow& rChildWindow, + vcl::Window* pParent, WinBits nBits); + virtual ~SidebarDockingWindow() override; + virtual void dispose() override; + virtual bool EventNotify(NotifyEvent& rEvent) override; + virtual bool Close() override; + + /// Force generation of all panels by completion. + void SyncUpdate(); + + void NotifyResize(); + + using SfxDockingWindow::Close; + +private: + // Window overridables + virtual void GetFocus() override; + virtual void Resize() override; + + virtual SfxChildAlignment CheckAlignment ( + SfxChildAlignment eCurrentAlignment, + SfxChildAlignment eRequestedAlignment) override; + + /// Notify LOKit that we closed and release the LOKNotifier. + void LOKClose(); + + ::rtl::Reference<sfx2::sidebar::SidebarController> mpSidebarController; + bool mbIsReadyToDrag; + std::unique_ptr<svt::AcceleratorExecute> mpAccel; + + std::unique_ptr<SidebarNotifyIdle> mpIdleNotify; +}; + +} // end of namespace sfx2::sidebar + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarModelUpdate.hxx b/include/sfx2/sidebar/SidebarModelUpdate.hxx new file mode 100644 index 000000000..0ecb988e5 --- /dev/null +++ b/include/sfx2/sidebar/SidebarModelUpdate.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX +#define INCLUDED_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX + +#include <sfx2/dllapi.h> + +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::uno { template <typename > class Reference; } + +namespace sfx2::sidebar { + +class SFX2_DLLPUBLIC SidebarModelUpdate +{ +public: + virtual ~SidebarModelUpdate(); + virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) = 0; +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarPanelBase.hxx b/include/sfx2/sidebar/SidebarPanelBase.hxx new file mode 100644 index 000000000..84a3e4dfb --- /dev/null +++ b/include/sfx2/sidebar/SidebarPanelBase.hxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_SIDEBARPANELBASE_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBARPANELBASE_HXX + +#include <sfx2/dllapi.h> + +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <com/sun/star/ui/XContextChangeEventListener.hpp> +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XToolPanel.hpp> +#include <com/sun/star/ui/XSidebarPanel.hpp> +#include <com/sun/star/ui/XUpdateModel.hpp> + +#include <vcl/vclptr.hxx> + + +namespace vcl { class Window; } + +namespace sfx2::sidebar { + +typedef cppu::WeakComponentImplHelper<css::ui::XContextChangeEventListener, + css::ui::XUIElement, + css::ui::XToolPanel, + css::ui::XSidebarPanel, + css::ui::XUpdateModel> + SidebarPanelBaseInterfaceBase; + +/** Base class for sidebar panels that provides some convenience + functionality. +*/ +class SFX2_DLLPUBLIC SidebarPanelBase final : private ::cppu::BaseMutex, + public SidebarPanelBaseInterfaceBase +{ +public: + static css::uno::Reference<css::ui::XUIElement> Create(const OUString& rsResourceURL, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + vcl::Window* pControl, + const css::ui::LayoutSize& rLayoutSize); + + // XContextChangeEventListener + virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) override; + + // XEventListener + virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) 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; + + // XToolPanel + virtual css::uno::Reference<css::accessibility::XAccessible> SAL_CALL createAccessible( + const css::uno::Reference<css::accessibility::XAccessible>& rxParentAccessible) override; + virtual css::uno::Reference<css::awt::XWindow> SAL_CALL getWindow() override; + + // XSidebarPanel + virtual css::ui::LayoutSize SAL_CALL getHeightForWidth(sal_Int32 nWidth) override; + virtual sal_Int32 SAL_CALL getMinimalWidth() override; + + // XUpdateModel + virtual void SAL_CALL updateModel(const css::uno::Reference<css::frame::XModel>& xModel) override; + +private: + SidebarPanelBase(const OUString& rsResourceURL, const css::uno::Reference<css::frame::XFrame>& rxFrame, + vcl::Window* pWindow, const css::ui::LayoutSize& rLayoutSize); + virtual ~SidebarPanelBase() override; + SidebarPanelBase(const SidebarPanelBase&) = delete; + SidebarPanelBase& operator=( const SidebarPanelBase& ) = delete; + + virtual void SAL_CALL disposing() override; + + css::uno::Reference<css::frame::XFrame> mxFrame; + VclPtr<vcl::Window> mpControl; + const OUString msResourceURL; + const css::ui::LayoutSize maLayoutSize; +}; + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx new file mode 100644 index 000000000..bf0fbf60c --- /dev/null +++ b/include/sfx2/sidebar/SidebarToolBox.hxx @@ -0,0 +1,86 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_SIDEBARTOOLBOX_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBARTOOLBOX_HXX + +#include <config_options.h> +#include <sfx2/dllapi.h> +#include <vcl/toolbox.hxx> +#include <map> + +namespace com::sun::star::frame { class XToolbarController; } + +namespace sfx2::sidebar { + +/** The sidebar tool box has two responsibilities: + 1. Coordinated location, size, and other states with its parent + background window. + 2. Create and handle tool bar controller for its items. +*/ +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SidebarToolBox : public ToolBox +{ +public: + SidebarToolBox(vcl::Window* pParentWindow); + virtual ~SidebarToolBox() override; + virtual void dispose() override; + + virtual ToolBoxButtonSize GetDefaultButtonSize() const; + + using ToolBox::InsertItem; + virtual void InsertItem(const OUString& rCommand, + const css::uno::Reference<css::frame::XFrame>& rFrame, + ToolBoxItemBits nBits, + const Size& rRequestedSize, + ImplToolItems::size_type nPos = APPEND) override; + + virtual bool EventNotify(NotifyEvent& rEvent) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + void SetController(const sal_uInt16 nItemId, + const css::uno::Reference<css::frame::XToolbarController>& rxController); + + void InitToolBox(VclBuilder::stringmap& rMap); + +protected: + typedef std::map<sal_uInt16, css::uno::Reference<css::frame::XToolbarController>> ControllerContainer; + ControllerContainer maControllers; + bool mbAreHandlersRegistered; + bool mbUseDefaultButtonSize; + bool mbSideBar; + + DECL_LINK(DropDownClickHandler, ToolBox*, void); + DECL_LINK(ClickHandler, ToolBox*, void); + DECL_LINK(DoubleClickHandler, ToolBox*, void); + DECL_LINK(SelectHandler, ToolBox*, void); + DECL_LINK(ChangedIconSizeHandler, LinkParamNone*, void ); + + css::uno::Reference<css::frame::XToolbarController> GetControllerForItemId(const sal_uInt16 nItemId) const; + + void CreateController(const sal_uInt16 nItemId, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + const sal_Int32 nItemWidth, bool bSideBar); + void RegisterHandlers(); +}; + + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx new file mode 100644 index 000000000..0d10efa82 --- /dev/null +++ b/include/sfx2/sidebar/TabBar.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX + +#include <config_options.h> +#include <sfx2//dllapi.h> +#include <sfx2/sidebar/ResourceManager.hxx> + + +#include <vcl/menu.hxx> +#include <vcl/window.hxx> + +#include <functional> + +class Button; +class CheckBox; +class RadioButton; + +namespace svt { class AcceleratorExecute; } + +namespace sfx2::sidebar { + +class FocusManager; +class SidebarController; + +/** The tab bar is the container for the individual tabs. +*/ +class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) TabBar final + : public vcl::Window +{ +public: + /** DeckMenuData has entries for display name, and a flag: + - isCurrentDeck for the deck selection data + - isEnabled for the show/hide menu + */ + class DeckMenuData + { + public: + OUString msDisplayName; + bool mbIsCurrentDeck; + bool mbIsActive; + bool mbIsEnabled; + }; + typedef ::std::function<void ( + const tools::Rectangle&, + const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider; + TabBar ( + vcl::Window* pParentWindow, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + const ::std::function<void (const OUString& rsDeckId)>& rDeckActivationFunctor, + const PopupMenuProvider& rPopupMenuProvider, + SidebarController* rParentSidebarController); + + virtual ~TabBar() override; + virtual void dispose() override; + + virtual void Paint (vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rUpdateArea) override; + virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) override; + virtual bool EventNotify (NotifyEvent& rEvent) override; + + static sal_Int32 GetDefaultWidth(); + + void SetDecks ( + const ResourceManager::DeckContextDescriptorContainer& rDecks); + void HighlightDeck (const OUString& rsDeckId); + void RemoveDeckHighlight (); + OUString const & GetDeckIdForIndex (const sal_Int32 nIndex) const; + void ToggleHideFlag (const sal_Int32 nIndex); + void RestoreHideFlags(); + + void UpdateFocusManager (FocusManager& rFocusManager); + + /// Enables/Disables the menu button. Used by LoKit. + void EnableMenuButton(const bool bEnable); + +private: + css::uno::Reference<css::frame::XFrame> mxFrame; + VclPtr<CheckBox> mpMenuButton; + class Item + { + public: + DECL_LINK(HandleClick, Button*, void); + VclPtr<RadioButton> mpButton; + OUString msDeckId; + ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; + bool mbIsHidden; + bool mbIsHiddenByDefault; + }; + typedef ::std::vector<Item> ItemContainer; + ItemContainer maItems; + const ::std::function<void (const OUString& rsDeckId)> maDeckActivationFunctor; + sal_Int32 mnMenuSeparatorY; + PopupMenuProvider maPopupMenuProvider; + + VclPtr<RadioButton> CreateTabItem (const DeckDescriptor& rDeckDescriptor); + Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const; + void Layout(); + void UpdateButtonIcons(); + + DECL_LINK(OnToolboxClicked, Button*, void); + + SidebarController* pParentSidebarController; + std::unique_ptr<svt::AcceleratorExecute> mpAccel; + +}; + + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Theme.hxx b/include/sfx2/sidebar/Theme.hxx new file mode 100644 index 000000000..a1500364d --- /dev/null +++ b/include/sfx2/sidebar/Theme.hxx @@ -0,0 +1,245 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SIDEBAR_THEME_HXX +#define INCLUDED_SFX2_SIDEBAR_THEME_HXX + +#include <sfx2/dllapi.h> + +#include <tools/color.hxx> +#include <vcl/image.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <tools/gen.hxx> +#include <vcl/wall.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <map> +#include <unordered_map> + + +namespace sfx2::sidebar { + +typedef cppu::WeakComponentImplHelper < + css::beans::XPropertySet, + css::beans::XPropertySetInfo + > ThemeInterfaceBase; + +class Paint; + +/** Simple collection of colors, gradients, fonts that define the + look of the sidebar and its controls. +*/ +class SFX2_DLLPUBLIC Theme final + : private ::cppu::BaseMutex, + public ThemeInterfaceBase +{ +public: + enum ThemeItem + { + Begin_, + Pre_Image_ = Begin_, + + AnyItem_ = Pre_Image_, + + Image_Grip, + Image_Expand, + Image_Collapse, + Image_TabBarMenu, + Image_PanelMenu, + Image_Closer, + Image_CloseIndicator, + + Image_Color_, + + Color_DeckTitleFont, + Color_PanelTitleFont, + Color_TabMenuSeparator, + Color_TabItemBorder, + Color_DropDownBorder, + Color_Highlight, + Color_HighlightText, + + Color_Paint_, + + Paint_DeckBackground, + Paint_DeckTitleBarBackground, + Paint_PanelBackground, + Paint_PanelTitleBarBackground, + Paint_TabBarBackground, + Paint_TabItemBackgroundNormal, + Paint_TabItemBackgroundHighlight, + Paint_HorizontalBorder, + Paint_VerticalBorder, + Paint_ToolBoxBackground, + Paint_ToolBoxBorderTopLeft, + Paint_ToolBoxBorderCenterCorners, + Paint_ToolBoxBorderBottomRight, + Paint_DropDownBackground, + + Paint_Int_, + + Int_DeckTitleBarHeight, + Int_DeckBorderSize, + Int_DeckSeparatorHeight, + Int_PanelTitleBarHeight, + Int_TabMenuPadding, + Int_TabMenuSeparatorPadding, + Int_TabItemWidth, + Int_TabItemHeight, + Int_DeckLeftPadding, + Int_DeckTopPadding, + Int_DeckRightPadding, + Int_DeckBottomPadding, + Int_TabBarLeftPadding, + Int_TabBarTopPadding, + Int_TabBarRightPadding, + Int_TabBarBottomPadding, + Int_ButtonCornerRadius, + + Int_Bool_, + + Bool_UseSystemColors, + Bool_IsHighContrastModeActive, + + Bool_Rect_, + + Rect_ToolBoxPadding, + Rect_ToolBoxBorder, + + Post_Rect_, + End_=Post_Rect_ + }; + + static Image GetImage (const ThemeItem eItem); + static Color GetColor (const ThemeItem eItem); + static const Paint& GetPaint (const ThemeItem eItem); + static Wallpaper GetWallpaper (const ThemeItem eItem); + static sal_Int32 GetInteger (const ThemeItem eItem); + static bool GetBoolean (const ThemeItem eItem); + + static bool IsHighContrastMode(); + + static void HandleDataChange(); + + void InitializeTheme(); + + Theme(); + virtual ~Theme() override; + Theme(const Theme&) = delete; + Theme& operator=( const Theme& ) = delete; + + virtual void SAL_CALL disposing() override; + + static css::uno::Reference<css::beans::XPropertySet> GetPropertySet(); + + // beans::XPropertySet + virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override; + virtual void SAL_CALL setPropertyValue ( + const OUString& rsPropertyName, + const css::uno::Any& rValue) override; + virtual css::uno::Any SAL_CALL getPropertyValue ( + const OUString& rsPropertyName) override; + virtual void SAL_CALL addPropertyChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) override; + virtual void SAL_CALL removePropertyChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) override; + virtual void SAL_CALL addVetoableChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override; + virtual void SAL_CALL removeVetoableChangeListener( + const OUString& rsPropertyName, + const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) override; + + // beans::XPropertySetInfo + virtual css::uno::Sequence<css::beans::Property> SAL_CALL getProperties() override; + virtual css::beans::Property SAL_CALL getPropertyByName (const OUString& rsName) override; + virtual sal_Bool SAL_CALL hasPropertyByName (const OUString& rsName) override; + +private: + static Theme& GetCurrentTheme(); + + std::vector<Image> maImages; + std::vector<Color> maColors; + std::vector<Paint> maPaints; + std::vector<sal_Int32> maIntegers; + std::vector<bool> maBooleans; + std::vector<tools::Rectangle> maRectangles; + bool mbIsHighContrastMode; + bool mbIsHighContrastModeSetManually; + + typedef std::unordered_map<OUString,ThemeItem> PropertyNameToIdMap; + PropertyNameToIdMap maPropertyNameToIdMap; + typedef std::vector<OUString> PropertyIdToNameMap; + PropertyIdToNameMap maPropertyIdToNameMap; + typedef ::std::vector<css::uno::Any> RawValueContainer; + RawValueContainer maRawValues; + + typedef std::vector<css::uno::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer; + typedef std::map<ThemeItem,ChangeListenerContainer> ChangeListeners; + ChangeListeners maChangeListeners; + typedef std::vector<css::uno::Reference<css::beans::XVetoableChangeListener> > VetoableListenerContainer; + typedef std::map<ThemeItem,VetoableListenerContainer> VetoableListeners; + VetoableListeners maVetoableListeners; + + enum PropertyType + { + PT_Image, + PT_Color, + PT_Paint, + PT_Integer, + PT_Boolean, + PT_Rectangle, + PT_Invalid + }; + + void SetupPropertyMaps(); + void UpdateTheme(); + static PropertyType GetPropertyType (const ThemeItem eItem); + static css::uno::Type const & GetCppuType (const PropertyType eType); + static sal_Int32 GetIndex ( + const ThemeItem eItem, + const PropertyType eType); + + VetoableListenerContainer* GetVetoableListeners ( + const ThemeItem eItem, + const bool bCreate); + ChangeListenerContainer* GetChangeListeners ( + const ThemeItem eItem, + const bool bCreate); + static bool DoVetoableListenersVeto ( + const VetoableListenerContainer* pListeners, + const css::beans::PropertyChangeEvent& rEvent); + static void BroadcastPropertyChange ( + const ChangeListenerContainer* pListeners, + const css::beans::PropertyChangeEvent& rEvent); + void ProcessNewValue ( + const css::uno::Any& rValue, + const ThemeItem eItem, + const PropertyType eType); +}; + + +} // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |