diff options
author | Laurent Godard <lgodard.libre@laposte.net> | 2015-04-30 16:56:14 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2015-06-22 04:59:07 +0000 |
commit | a64999511ae654131d997eec9a3d78478cfc1c75 (patch) | |
tree | e2a06cde98747c7f8b1eb409f9c7b1918582c897 /include | |
parent | d16e154c627ecc0cb21aaf4b28f7f5ae48ebbde1 (diff) |
new uno sidebar api tdf#91806
the entry point is SfxBaseController::getSidebar()
the Decks and panels are now per SidebarController and not global anymore
' macro example
Sub testSidebarApi
controller = thisComponent.currentcontroller
frameIni = thisComponent.currentcontroller.frame
sidebar = thisComponent.currentcontroller.getSidebar()
sidebar.setVisible(true)
frame = sidebar.getFrame()
decks = sidebar.getdecks()
c = decks.count
h = decks.hasElements()
e = decks.getElementNames()
a = decks.hasByName("MyDeck")
deck = decks.getByName("MyDeck")
deck.activate(true)
t = deck.getTitle()
deck.setTitle("new deck title")
deck.moveFirst()
deck.moveLast()
deck.moveUp()
deck.moveDown()
index = deck.getOrderIndex()
panels = deck.getPanels()
ep = panels.getElementnames()
ap = panels.hasByName("aPanelName")
panel = panels.getByName("aPanelName")
panel.setTitle("new panel title")
panel.collapse()
panel.expand(true) ' expand and collapse other
index = panel.getOrderIndex()
panel.moveLast()
panel.moveFirst()
panel.moveDown()
panel.moveUp()
End Sub
Change-Id: I7a4b953f2277dea483bb296ba6ead35de7205ace
Reviewed-on: https://gerrit.libreoffice.org/15856
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
32 files changed, 2392 insertions, 0 deletions
diff --git a/include/dbaccess/genericcontroller.hxx b/include/dbaccess/genericcontroller.hxx index 07a9decc97ca..f1953218ef15 100644 --- a/include/dbaccess/genericcontroller.hxx +++ b/include/dbaccess/genericcontroller.hxx @@ -61,6 +61,8 @@ #include <sfx2/userinputinterception.hxx> #include <vcl/vclptr.hxx> +#include <com/sun/star/ui/XSidebarProvider.hpp> + namespace dbtools { class SQLExceptionInfo; @@ -465,6 +467,9 @@ namespace dbaui virtual OUString SAL_CALL getViewControllerName() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCreationArguments() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XSidebarProvider > SAL_CALL getSidebar() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // ::com::sun::star::frame::XController virtual void SAL_CALL attachFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & xFrame) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; virtual sal_Bool SAL_CALL attachModel(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE; diff --git a/include/sfx2/sfxbasecontroller.hxx b/include/sfx2/sfxbasecontroller.hxx index 0f77a44f0833..d387d80485ed 100644 --- a/include/sfx2/sfxbasecontroller.hxx +++ b/include/sfx2/sfxbasecontroller.hxx @@ -48,6 +48,8 @@ #include <tools/link.hxx> #include <vcl/button.hxx> +#include <com/sun/star/ui/XSidebarProvider.hpp> + #include <sfx2/viewsh.hxx> #include <sfx2/sfxuno.hxx> @@ -101,6 +103,8 @@ public: virtual OUString SAL_CALL getViewControllerName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCreationArguments() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual css::uno::Reference< css::ui::XSidebarProvider > SAL_CALL getSidebar() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // XController diff --git a/include/sfx2/sidebar/Accessible.hxx b/include/sfx2/sidebar/Accessible.hxx new file mode 100644 index 000000000000..6f786f00663a --- /dev/null +++ b/include/sfx2/sidebar/Accessible.hxx @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_ACCESSIBLE_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_ACCESSIBLE_HXX + +#include <boost/noncopyable.hpp> + +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/basemutex.hxx> + +namespace +{ + typedef ::cppu::WeakComponentImplHelper1 < + css::accessibility::XAccessible + > AccessibleInterfaceBase; +} + +namespace sfx2 { namespace sidebar { + + +/** Simple implementation of the XAccessible interface. + Its getAccessibleContext() method returns a context object given + to its constructor. +*/ +class Accessible + : private ::boost::noncopyable, + private ::cppu::BaseMutex, + public AccessibleInterfaceBase +{ +public: + explicit Accessible ( + const css::uno::Reference<css::accessibility::XAccessibleContext>& rxContext); + virtual ~Accessible(); + + virtual void SAL_CALL disposing() SAL_OVERRIDE; + // XAccessible + virtual css::uno::Reference<css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext() + throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + css::uno::Reference<css::accessibility::XAccessibleContext> mxContext; +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/AccessibleTitleBar.hxx b/include/sfx2/sidebar/AccessibleTitleBar.hxx new file mode 100644 index 000000000000..49e68e74265a --- /dev/null +++ b/include/sfx2/sidebar/AccessibleTitleBar.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_ACCESSIBLETITLEBAR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_ACCESSIBLETITLEBAR_HXX + +#include <toolkit/awt/vclxaccessiblecomponent.hxx> +#include <com/sun/star/accessibility/XAccessible.hpp> + +namespace sfx2 { namespace sidebar { + +class TitleBar; + +class AccessibleTitleBar + : public VCLXAccessibleComponent +{ +public: + static css::uno::Reference<css::accessibility::XAccessible> Create (TitleBar& rTitleBar); + +protected: + virtual void FillAccessibleStateSet (utl::AccessibleStateSetHelper& rStateSet) SAL_OVERRIDE; + +private: + explicit AccessibleTitleBar (VCLXWindow* pWindow); + virtual ~AccessibleTitleBar(); +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/AsynchronousCall.hxx b/include/sfx2/sidebar/AsynchronousCall.hxx new file mode 100644 index 000000000000..338505c83e4b --- /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 <boost/function.hpp> +#include <tools/solar.h> +#include <tools/link.hxx> + +struct ImplSVEvent; + +namespace sfx2 { namespace sidebar { + +/** A simple asynchronous call via Application::PostUserCall. +*/ +class AsynchronousCall +{ +public: + typedef ::boost::function<void()> Action; + + AsynchronousCall(); + AsynchronousCall (const Action& rAction); + ~AsynchronousCall(); + + void RequestCall(); + void CancelRequest(); + +private: + Action maAction; + ImplSVEvent * mnCallId; + + DECL_LINK(HandleUserCall, 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 000000000000..b9430baedfb3 --- /dev/null +++ b/include/sfx2/sidebar/Context.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXT_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXT_HXX + +#include <rtl/ustring.hxx> + +#include <vector> + +namespace sfx2 { namespace sidebar { + +class Context +{ +public: + ::rtl::OUString msApplication; + ::rtl::OUString msContext; + + Context(); + Context ( + const ::rtl::OUString& rsApplication, + const ::rtl::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 a 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/ContextList.hxx b/include/sfx2/sidebar/ContextList.hxx new file mode 100644 index 000000000000..5171072fa942 --- /dev/null +++ b/include/sfx2/sidebar/ContextList.hxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this 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_CONTEXTLIST_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXTLIST_HXX + +#include <sfx2/sidebar/Context.hxx> +#include <sal/types.h> +#include <rtl/ustring.hxx> + +#include <vector> + +namespace sfx2 { namespace sidebar { + +/** Per context data for deck and panel descriptors. +*/ +class ContextList +{ +public: + ContextList(); + ~ContextList(); + + class Entry + { + public: + Context maContext; + bool mbIsInitiallyVisible; + ::rtl::OUString msMenuCommand; + }; + + /** Return <TRUE/> when the given context matches any of the stored contexts. + */ + const Entry* GetMatch ( + const Context& rContext) const; + Entry* GetMatch ( + const Context& rContext); + + void AddContextDescription ( + const Context& rContext, + const bool bIsInitiallyVisible, + const ::rtl::OUString& rsMenuCommand); + + sal_Int32 GetCount(); + +private: + ::std::vector<Entry> maEntries; + + ::std::vector<Entry>::const_iterator FindBestMatch (const Context& rContext) const; +}; + +} } // 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 000000000000..edd735c3cc0e --- /dev/null +++ b/include/sfx2/sidebar/Deck.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 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX + +#include <sfx2/sidebar/Panel.hxx> + +#include <vcl/window.hxx> +#include <vcl/image.hxx> +#include <com/sun/star/ui/LayoutSize.hpp> + +class ScrollBar; + +namespace sfx2 { namespace sidebar { + +class DeckDescriptor; +class DeckTitleBar; + +/** This is the parent window of the panels. + It displays the deck title. +*/ +class Deck : public vcl::Window +{ +public: + Deck(const DeckDescriptor& rDeckDescriptor, + vcl::Window* pParentWindow, + const std::function<void()>& rCloserAction); + virtual ~Deck(); + virtual void dispose() SAL_OVERRIDE; + + const OUString& GetId() const { return msId; } + + DeckTitleBar* GetTitleBar() const; + Rectangle GetContentArea() const; + void ResetPanels (const SharedPanelContainer& rPanels); + const SharedPanelContainer& GetPanels() const { return maPanels; } + + Panel* GetPanel(OUString 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) SAL_OVERRIDE; + virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rUpdateArea) SAL_OVERRIDE; + virtual void DataChanged (const DataChangedEvent& rEvent) SAL_OVERRIDE; + virtual bool Notify(NotifyEvent& rEvent) SAL_OVERRIDE; + + static void PrintWindowSubTree (vcl::Window* pRoot, int nIndentation); + + sal_Int32 GetMinimalWidth() const { return mnMinimalWidth; } + + class ScrollContainerWindow : public vcl::Window + { + public: + ScrollContainerWindow(vcl::Window* pParentWindow); + virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rUpdateArea) SAL_OVERRIDE; + void SetSeparators(const ::std::vector<sal_Int32>& rSeparators); + private: + std::vector<sal_Int32> maSeparators; + }; + +private: + const OUString msId; + Image maIcon; + sal_Int32 mnMinimalWidth; + SharedPanelContainer maPanels; + VclPtr<DeckTitleBar> mpTitleBar; + VclPtr<vcl::Window> mpScrollClipWindow; + VclPtr<ScrollContainerWindow> mpScrollContainer; + VclPtr<vcl::Window> mpFiller; + VclPtr<ScrollBar> mpVerticalScrollBar; + + DECL_LINK(HandleVerticalScrollBarChange,void*); + bool ProcessWheelEvent(CommandEvent* pCommandEvent); +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/DeckDescriptor.hxx b/include/sfx2/sidebar/DeckDescriptor.hxx new file mode 100644 index 000000000000..a0980c6bde78 --- /dev/null +++ b/include/sfx2/sidebar/DeckDescriptor.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECKDESCRIPTOR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_DECKDESCRIPTOR_HXX + +#include <sfx2/sidebar/EnumContext.hxx> +#include "ContextList.hxx" +#include <boost/shared_ptr.hpp> + +#include <sfx2/sidebar/Deck.hxx> + +namespace sfx2 { namespace sidebar { + +class DeckDescriptor +{ +public: + OUString msTitle; + OUString msId; + OUString msIconURL; + OUString msHighContrastIconURL; + OUString msTitleBarIconURL; + OUString msHighContrastTitleBarIconURL; + OUString msHelpURL; + OUString msHelpText; + ContextList maContextList; + bool mbIsEnabled; + sal_Int32 mnOrderIndex; + bool mbExperimental; + + VclPtr<Deck> mpDeck; + + DeckDescriptor(); + DeckDescriptor (const DeckDescriptor& rOther); + ~DeckDescriptor(); +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/DeckLayouter.hxx b/include/sfx2/sidebar/DeckLayouter.hxx new file mode 100644 index 000000000000..8b3b24810aba --- /dev/null +++ b/include/sfx2/sidebar/DeckLayouter.hxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECKLAYOUTER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_DECKLAYOUTER_HXX + +#include <sfx2/sidebar/Panel.hxx> + +#include <tools/gen.hxx> + +#include <com/sun/star/ui/LayoutSize.hpp> + +#include <vector> + +class ScrollBar; +namespace vcl { class Window; } + +namespace sfx2 { namespace sidebar { + +class Panel; + +/** Helper for layouting the direct and indirect children of a + deck like title bars, panels, and scroll bars. +*/ +namespace DeckLayouter +{ + void LayoutDeck ( + const Rectangle& rContentArea, + sal_Int32& rMinimalWidth, + SharedPanelContainer& rPanels, + vcl::Window& pDeckTitleBar, + vcl::Window& pScrollClipWindow, + vcl::Window& pScrollContainer, + vcl::Window& pFiller, + ScrollBar& pVerticalScrollBar); +} + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/DeckTitleBar.hxx b/include/sfx2/sidebar/DeckTitleBar.hxx new file mode 100644 index 000000000000..3b42958f459e --- /dev/null +++ b/include/sfx2/sidebar/DeckTitleBar.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_DECKTITLEBAR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_DECKTITLEBAR_HXX + +#include <sfx2/sidebar/TitleBar.hxx> + +namespace sfx2 { namespace sidebar { + +class DeckTitleBar : public TitleBar +{ +public: + DeckTitleBar(const OUString& rsTitle, + vcl::Window* pParentWindow, + const std::function<void()>& rCloserAction); + + void SetCloserVisible(const bool bIsCloserVisible); + + virtual void DataChanged(const DataChangedEvent& rEvent) SAL_OVERRIDE; + +protected: + virtual Rectangle GetTitleArea(const Rectangle& rTitleBarBox) SAL_OVERRIDE; + virtual void PaintDecoration(vcl::RenderContext& rRenderContext, const Rectangle& rTitleBarBox) SAL_OVERRIDE; + virtual sidebar::Paint GetBackgroundPaint() SAL_OVERRIDE; + virtual Color GetTextColor() SAL_OVERRIDE; + virtual void HandleToolBoxItemClick(const sal_uInt16 nItemIndex) SAL_OVERRIDE; + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE; + +private: + const sal_uInt16 mnCloserItemIndex; + const std::function<void()> maCloserAction; + bool mbIsCloserVisible; +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/DrawHelper.hxx b/include/sfx2/sidebar/DrawHelper.hxx new file mode 100644 index 000000000000..97bdb0c04530 --- /dev/null +++ b/include/sfx2/sidebar/DrawHelper.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DRAWHELPER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_DRAWHELPER_HXX + +#include <vcl/window.hxx> + +#include <tools/svborder.hxx> + +class Color; + +namespace sfx2 { namespace sidebar { + +class Paint; + +/** Some convenience functions for painting backgrounds and borders. +*/ +class DrawHelper +{ +public: + static void DrawBorder(vcl::RenderContext& rRenderContext, const Rectangle& rBox, const SvBorder& rBorderSize, + const Paint& rHorizontalPaint, const Paint& rVerticalPaint); + static void DrawHorizontalLine(vcl::RenderContext& rRenderContext, const sal_Int32 nLeft, const sal_Int32 nRight, + const sal_Int32 nY, const sal_Int32 nHeight, const Paint& rPaint); + static void DrawVerticalLine(vcl::RenderContext& rRenderContext, const sal_Int32 nTop, const sal_Int32 nBottom, + const sal_Int32 nX, const sal_Int32 nWidth, const Paint& rPaint); + static void DrawRoundedRectangle(vcl::RenderContext& rRenderContext, const Rectangle& rBox, const sal_Int32 nCornerRadius, + const Color& rBorderColor, const Paint& rFillPaint); +}; + +}} // 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 000000000000..f93f9e82c368 --- /dev/null +++ b/include/sfx2/sidebar/FocusManager.hxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_FOCUSMANAGER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_FOCUSMANAGER_HXX + +#include "Panel.hxx" +#include <tools/link.hxx> +#include <vcl/keycod.hxx> + +class Button; +class VclSimpleEvent; + +namespace sfx2 { namespace 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); + ~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 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; + bool mbObservingContentControlFocus; + VclPtr<vcl::Window> mpFirstFocusedContentControl; + VclPtr<vcl::Window> mpLastFocusedWindow; + + 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, VclSimpleEvent*); + DECL_LINK(ChildEventListener, VclSimpleEvent*); + + 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); + bool MoveFocusInsidePanel(const FocusLocation& rLocation, + const sal_Int32 nDirection); + bool 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/MenuButton.hxx b/include/sfx2/sidebar/MenuButton.hxx new file mode 100644 index 000000000000..d725fb71c01d --- /dev/null +++ b/include/sfx2/sidebar/MenuButton.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 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_MENUBUTTON_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_MENUBUTTON_HXX + +#include <vcl/button.hxx> + +namespace sfx2 { namespace sidebar { + +class MenuButton + : public CheckBox +{ +public: + MenuButton (vcl::Window* pParentWindow); + + virtual void Paint (vcl::RenderContext& /*rRenderContext*/, const Rectangle& rUpdateArea) SAL_OVERRIDE; + virtual void MouseMove (const MouseEvent& rEvent) SAL_OVERRIDE; + virtual void MouseButtonDown (const MouseEvent& rMouseEvent) SAL_OVERRIDE; + virtual void MouseButtonUp (const MouseEvent& rMouseEvent) SAL_OVERRIDE; + +protected: + using CheckBox::FillLayoutData; + +private: + bool mbIsLeftButtonDown; + enum PaintType { + PT_Native, + PT_Theme + } mePaintType; +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/Paint.hxx b/include/sfx2/sidebar/Paint.hxx new file mode 100644 index 000000000000..91b36f093bf8 --- /dev/null +++ b/include/sfx2/sidebar/Paint.hxx @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_PAINT_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_PAINT_HXX + +#include <tools/color.hxx> +#include <vcl/gradient.hxx> +#include <vcl/wall.hxx> +#include <com/sun/star/awt/Gradient.hpp> + +#include <boost/variant.hpp> + +namespace sfx2 { namespace sidebar { + +/** Abstraction of different ways to fill outlines. + Can be + - none (empty: outline is not filled) + - singular color + - gradient +*/ +class Paint +{ +public: + enum Type + { + NoPaint, + ColorPaint, + GradientPaint + }; + + // Create a Paint object for an Any that may contain a color, a + // awt::Gradient, or nothing. + static Paint Create (const css::uno::Any& rValue); + + // Create paint with type NoPaint. + explicit Paint(); + + // Create a Paint object for the given color. + explicit Paint (const Color& rColor); + + // Create a Paint object for the given gradient. + explicit Paint (const Gradient& rGradient); + + Type GetType() const { return meType;} + const Color& GetColor() const; + const Gradient& GetGradient() const; + + Wallpaper GetWallpaper() const; + +private: + Type meType; + ::boost::variant< + Color, + Gradient + > maValue; +}; + +} } // end of namespace sfx2::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 000000000000..b42dbc9779f0 --- /dev/null +++ b/include/sfx2/sidebar/Panel.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_SOURCE_SIDEBAR_PANEL_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX + +#include <sfx2/sidebar/Context.hxx> + +#include <vcl/window.hxx> + +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XSidebarPanel.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <boost/scoped_ptr.hpp> +#include <boost/shared_ptr.hpp> +#include <vector> + +namespace sfx2 { namespace sidebar { + +class PanelDescriptor; +class TitleBar; +class PanelTitleBar; + +class Panel : 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(); + virtual void dispose() SAL_OVERRIDE; + + PanelTitleBar* GetTitleBar() const; + bool IsTitleBarOptional() const { return mbIsTitleBarOptional;} + void SetUIElement (const css::uno::Reference<css::ui::XUIElement>& rxElement); + 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;} + + virtual void Paint (vcl::RenderContext& rRenderContext, const Rectangle& rUpdateArea) SAL_OVERRIDE; + virtual void Resize() SAL_OVERRIDE; + virtual void DataChanged (const DataChangedEvent& rEvent) SAL_OVERRIDE; + virtual void Activate() SAL_OVERRIDE; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_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; + 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/PanelDescriptor.hxx b/include/sfx2/sidebar/PanelDescriptor.hxx new file mode 100644 index 000000000000..fa490b9ec0f0 --- /dev/null +++ b/include/sfx2/sidebar/PanelDescriptor.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 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_PANELDESCRIPTOR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_PANELDESCRIPTOR_HXX + +#include <sfx2/sidebar/EnumContext.hxx> +#include <sfx2/sidebar/ContextList.hxx> +#include <boost/shared_ptr.hpp> + +namespace sfx2 { namespace sidebar { + +class PanelDescriptor +{ +public: + OUString msTitle; + bool mbIsTitleBarOptional; + OUString msId; + OUString msDeckId; + OUString msTitleBarIconURL; + OUString msHighContrastTitleBarIconURL; + OUString msHelpURL; + ContextList maContextList; + OUString msImplementationURL; + sal_Int32 mnOrderIndex; + bool mbShowForReadOnlyDocuments; + bool mbWantsCanvas; + bool mbExperimental; + + PanelDescriptor(); + PanelDescriptor (const PanelDescriptor& rPanelDescriptor); + ~PanelDescriptor(); +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/PanelTitleBar.hxx b/include/sfx2/sidebar/PanelTitleBar.hxx new file mode 100644 index 000000000000..c08140244fb8 --- /dev/null +++ b/include/sfx2/sidebar/PanelTitleBar.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_SOURCE_SIDEBAR_PANELTITLEBAR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_PANELTITLEBAR_HXX + +#include <sfx2/sidebar/TitleBar.hxx> + +#include <com/sun/star/frame/XFrame.hpp> +#include <boost/function.hpp> + +namespace sfx2 { namespace sidebar { + +class Panel; + +class PanelTitleBar + : public TitleBar +{ +public: + PanelTitleBar(const OUString& rsTitle, vcl::Window* pParentWindow, Panel* pPanel); + virtual ~PanelTitleBar(); + virtual void dispose() SAL_OVERRIDE; + + void SetMoreOptionsCommand(const OUString& rsCommandName, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + virtual void DataChanged(const DataChangedEvent& rEvent) SAL_OVERRIDE; + virtual void MouseButtonDown(const MouseEvent& rMouseEvent) SAL_OVERRIDE; + virtual void MouseButtonUp(const MouseEvent& rMouseEvent) SAL_OVERRIDE; + +protected: + virtual Rectangle GetTitleArea(const Rectangle& rTitleBarBox) SAL_OVERRIDE; + virtual void PaintDecoration(vcl::RenderContext& rRenderContext, const Rectangle& rTitleBarBox) SAL_OVERRIDE; + virtual sidebar::Paint GetBackgroundPaint() SAL_OVERRIDE; + virtual Color GetTextColor() SAL_OVERRIDE; + virtual void HandleToolBoxItemClick (const sal_uInt16 nItemIndex) SAL_OVERRIDE; + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE; + +private: + bool mbIsLeftButtonDown; + VclPtr<Panel> mpPanel; + const sal_uInt16 mnMenuItemIndex; + css::uno::Reference<css::frame::XFrame> mxFrame; + OUString msMoreOptionsCommand; +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* 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 000000000000..4e6247d5c645 --- /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 "DeckDescriptor.hxx" +#include "PanelDescriptor.hxx" +#include <sfx2/sidebar/Context.hxx> +#include <unotools/confignode.hxx> +#include <com/sun/star/frame/XFrame.hpp> +#include <set> +#include <boost/shared_ptr.hpp> +#include <svtools/miscopt.hxx> + +namespace sfx2 { namespace 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(); + + static ResourceManager& Instance(); + + const DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId) const; + const PanelDescriptor* GetPanelDescriptor(const OUString& rsPanelId) const; + + /** Excluded or include a deck from being displayed in the tab + bar. + Note that this value is not persistent. + The flag can not be set directly at a DeckDescriptor object + because the ResourceManager gives access to them only + read-only. + */ + void SetIsDeckEnabled(const OUString& rsDeckId, const bool bIsEnabled); + + void SetDeckToDescriptor(const OUString& rsDeckId, VclPtr<Deck> aDeck); + + void SetDeckOrderIndex(const OUString& rsDeckId, const sal_Int32 orderIndex); + + void SetPanelOrderIndex(const OUString& rsPanelId, const sal_Int32 orderIndex); + + + 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::XFrame>& rxFrame); + + const PanelContextDescriptorContainer& GetMatchingPanels( + PanelContextDescriptorContainer& rPanelDescriptors, + const Context& rContext, + const OUString& rsDeckId, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + /** Remember the expansions state per panel and context. + This is not persistent past application end. + */ + void StorePanelExpansionState(const OUString& rsPanelId, + const bool bExpansionState, + const Context& rContext); + +private: + + + typedef std::vector<DeckDescriptor> DeckContainer; + DeckContainer maDecks; + + typedef std::vector<PanelDescriptor> PanelContainer; + PanelContainer maPanels; + mutable std::set<rtl::OUString> maProcessedApplications; + + SvtMiscOptions maMiscOptions; + + void ReadDeckList(); + void ReadPanelList(); + static void ReadContextList(const utl::OConfigurationNode& rNode, + ContextList& rContextList, + const OUString& rsDefaultMenuCommand); + void ReadLegacyAddons(const css::uno::Reference<css::frame::XFrame>& rxFrame); + static utl::OConfigurationTreeRoot GetLegacyAddonRootNode(const OUString& rsModuleName); + static void GetToolPanelNodeNames(std::vector<OUString>& rMatchingNames, + const utl::OConfigurationTreeRoot& aRoot); + static bool IsDeckEnabled(const OUString& rsDeckId, + const Context& rContext, + 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/Sidebar.hrc b/include/sfx2/sidebar/Sidebar.hrc new file mode 100644 index 000000000000..8f62aecbc91d --- /dev/null +++ b/include/sfx2/sidebar/Sidebar.hrc @@ -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 . + */ +#include <sfx2/sfx.hrc> + +#define RID_SIDEBAR_RESOURCE (RID_SFX_SIDEBAR_START + 0) + +#define IMAGE_SIDEBAR_PLUS 1 +#define IMAGE_SIDEBAR_MINUS 3 +#define IMAGE_SIDEBAR_GRIP 5 +#define IMAGE_SIDEBAR_MENU 7 +#define IMAGE_SIDEBAR_DETAIL_DIALOG 9 +#define IMAGE_SIDEBAR_TOOLBOX_SEPARATOR 11 +#define IMAGE_SIDEBAR_DECK_3D_LARGE 20 +#define IMAGE_SIDEBAR_DECK_3D_SMALL 22 +#define IMAGE_SIDEBAR_DECK_ANIMATION_LARGE 30 +#define IMAGE_SIDEBAR_DECK_ANIMATION_SMALL 32 +#define IMAGE_SIDEBAR_DECK_COLORS_LARGE 40 +#define IMAGE_SIDEBAR_DECK_COLORS_SMALL 42 +#define IMAGE_SIDEBAR_DECK_EYEDROPPER_LARGE 50 +#define IMAGE_SIDEBAR_DECK_EYEDROPPER_SMALL 52 +#define IMAGE_SIDEBAR_DECK_GALLERY_LARGE 60 +#define IMAGE_SIDEBAR_DECK_GALLERY_SMALL 62 +#define IMAGE_SIDEBAR_DECK_IMGANIM_LARGE 70 +#define IMAGE_SIDEBAR_DECK_IMGANIM_SMALL 72 +#define IMAGE_SIDEBAR_DECK_NAVIGATOR_LARGE 80 +#define IMAGE_SIDEBAR_DECK_NAVIGATOR_SMALL 82 +#define IMAGE_SIDEBAR_PROPERTIES_DECK_LARGE 90 +#define IMAGE_SIDEBAR_PROPERTIES_DECK_SMALL 92 +#define IMAGE_SIDEBAR_DECK_STYLE_LARGE 100 +#define IMAGE_SIDEBAR_DECK_STYLE_SMALL 102 +#define IMAGE_SIDEBAR_DECK_TEMPLATE_LARGE 110 +#define IMAGE_SIDEBAR_DECK_TEMPLATE_SMALL 112 +#define IMAGE_SIDEBAR_DECK_TRANSITION_LARGE 120 +#define IMAGE_SIDEBAR_DECK_TRANSITION_SMALL 122 +#define IMAGE_SIDEBAR_DECK_FUNCTIONS_LARGE 130 +#define IMAGE_SIDEBAR_DECK_FUNCTIONS_SMALL 132 +#define STRING_CUSTOMIZATION 200 +#define STRING_RESTORE 201 +#define STRING_HIDE_SIDEBAR 202 + +#define SFX_STR_SIDEBAR_MORE_OPTIONS (RID_SFX_SIDEBAR_START + 1) +#define SFX_STR_SIDEBAR_CLOSE_DECK (RID_SFX_SIDEBAR_START + 2) + +/* 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 000000000000..0e1fe0e09559 --- /dev/null +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -0,0 +1,275 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARCONTROLLER_HXX + +#include <sal/config.h> + +#include <map> + +#include <sfx2/sidebar/AsynchronousCall.hxx> +#include <sfx2/sidebar/Context.hxx> +#include <sfx2/sidebar/FocusManager.hxx> +#include <sfx2/sidebar/Panel.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> +#include <sfx2/sidebar/TabBar.hxx> + +#include <vcl/menu.hxx> + +#include <com/sun/star/awt/XWindowPeer.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/ui/XContextChangeEventListener.hpp> +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XSidebar.hpp> + +#include <boost/noncopyable.hpp> +#include <boost/optional.hpp> +#include <cppuhelper/compbase4.hxx> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/weakref.hxx> + + + +namespace +{ + typedef ::cppu::WeakComponentImplHelper4 < + css::ui::XContextChangeEventListener, + css::beans::XPropertyChangeListener, + css::ui::XSidebar, + css::frame::XStatusListener + > SidebarControllerInterfaceBase; +} + +class SfxSplitWindow; +class FixedBitmap; + +namespace sfx2 { namespace sidebar { + +class ContentPanelDescriptor; +class Deck; +class DeckDescriptor; +class SidebarDockingWindow; +class TabBar; +class TabBarConfiguration; + +class SidebarController + : private ::boost::noncopyable, + private ::cppu::BaseMutex, + public SidebarControllerInterfaceBase +{ +public: + SidebarController( + SidebarDockingWindow* pParentWindow, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + virtual ~SidebarController(); + + /** 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); + + // ui::XContextChangeEventListener + virtual void SAL_CALL notifyContextChangeEvent (const css::ui::ContextChangeEventObject& rEvent) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // XEventListener + virtual void SAL_CALL disposing (const css::lang::EventObject& rEventObject) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // beans::XPropertyChangeListener + virtual void SAL_CALL propertyChange (const css::beans::PropertyChangeEvent& rEvent) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // frame::XStatusListener + virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // ui::XSidebar + virtual void SAL_CALL requestLayout() + throw(css::uno::RuntimeException, std::exception) SAL_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 ::rtl::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 ::rtl::OUString& rsDeckId); + + FocusManager& GetFocusManager() { return maFocusManager;} + + ResourceManager* GetResourceManager() { return mpResourceManager.get();} + + // std::unique_ptr<ResourceManager> GetResourceManager() { return mpResourceManager;} + + Context GetCurrentContext() const { return maCurrentContext;} + bool IsDocumentReadOnly (void) const { return mbIsDocumentReadOnly;} + + void SwitchToDeck ( const ::rtl::OUString& rsDeckId); + void SwitchToDefaultDeck(); + + void CreateDeck(const ::rtl::OUString& rDeckId); + + ResourceManager::DeckContextDescriptorContainer GetMatchingDecks(); + ResourceManager::PanelContextDescriptorContainer GetMatchingPanels( const ::rtl::OUString& rDeckId); + +private: + typedef ::std::map< + const css::uno::Reference<css::frame::XFrame>, + css::uno::WeakReference<SidebarController> + > SidebarControllerContainer; + static SidebarControllerContainer maSidebarControllerContainer; + + VclPtr<Deck> mpCurrentDeck; + VclPtr<SidebarDockingWindow> mpParentWindow; + VclPtr<TabBar> mpTabBar; + css::uno::Reference<css::frame::XFrame> mxFrame; + Context maCurrentContext; + Context maRequestedContext; + /// Use a combination of SwitchFlag_* as value. + sal_Int32 mnRequestedForceFlags; + ::rtl::OUString msCurrentDeckId; + ::rtl::OUString msCurrentDeckTitle; + AsynchronousCall maPropertyChangeForwarder; + AsynchronousCall maContextChangeUpdate; + AsynchronousCall maAsynchronousDeckSwitch; + + /** 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. + */ + ::boost::optional<bool> mbIsDeckRequestedOpen; + ::boost::optional<bool> mbIsDeckOpen; + bool mbCanDeckBeOpened; + + /** Before the deck is closed the sidebar width is saved into this variable, + so that it can be restored when the deck is reopended. + */ + 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*); + /** Make maRequestedContext the current context. + */ + void UpdateConfigurations(); + + css::uno::Reference<css::ui::XUIElement> CreateUIElement ( + const css::uno::Reference<css::awt::XWindowPeer>& rxWindow, + const ::rtl::OUString& rsImplementationURL, + const bool bWantsCanvas, + const Context& rContext); + + VclPtr<Panel> CreatePanel ( + const ::rtl::OUString& rsPanelId, + vcl::Window* pParentWindow, + const bool bIsInitiallyExpanded, + const Context& rContext); + + void SwitchToDeck ( + const DeckDescriptor& rDeckDescriptor, + const Context& rContext); + void ShowPopupMenu ( + const Rectangle& rButtonBox, + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + ::boost::shared_ptr<PopupMenu> CreatePopupMenu ( + const ::std::vector<TabBar::DeckMenuData>& rMenuData) const; + DECL_LINK(OnMenuItemSelected, Menu*); + 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() SAL_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 000000000000..defbb17315e2 --- /dev/null +++ b/include/sfx2/sidebar/SidebarDockingWindow.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_SIDEBARDOCKINGWINDOW_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARDOCKINGWINDOW_HXX + +#include <sfx2/dockwin.hxx> + +#include <rtl/ref.hxx> + +namespace sfx2 { namespace sidebar { + +class SidebarChildWindow; + +class SidebarController; + +class SidebarDockingWindow : public SfxDockingWindow +{ +public: + SidebarDockingWindow(SfxBindings* pBindings, SidebarChildWindow& rChildWindow, + vcl::Window* pParent, WinBits nBits); + virtual ~SidebarDockingWindow(); + virtual void dispose() SAL_OVERRIDE; + + virtual bool Close() SAL_OVERRIDE; + +protected: + // Window overridables + virtual void GetFocus() SAL_OVERRIDE; + + virtual SfxChildAlignment CheckAlignment ( + SfxChildAlignment eCurrentAlignment, + SfxChildAlignment eRequestedAlignment) SAL_OVERRIDE; + +private: + ::rtl::Reference<sfx2::sidebar::SidebarController> mpSidebarController; + + void DoDispose(); +}; + +} } // end of namespace sfx2::sidebar + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarResource.hxx b/include/sfx2/sidebar/SidebarResource.hxx new file mode 100644 index 000000000000..78ce96b2b4ea --- /dev/null +++ b/include/sfx2/sidebar/SidebarResource.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 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARRESOURCE_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARRESOURCE_HXX + +#include <sfx2/sidebar/Sidebar.hrc> +#include <sfx2/sfxresid.hxx> +#include <tools/rc.hxx> + +class SidebarResource : public Resource +{ +public: + SidebarResource() : Resource(SfxResId(RID_SIDEBAR_RESOURCE)){} + ~SidebarResource() { FreeResource(); } +}; + +#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 000000000000..1fe2a27a9085 --- /dev/null +++ b/include/sfx2/sidebar/TabBar.hxx @@ -0,0 +1,136 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX + +#include "DeckDescriptor.hxx" +#include <sfx2/sidebar/ResourceManager.hxx> + + +#include <vcl/menu.hxx> +#include <vcl/window.hxx> + +#include <com/sun/star/frame/XFrame.hpp> +#include <boost/function.hpp> +#include <boost/tuple/tuple.hpp> +#include <boost/scoped_ptr.hpp> + +class Button; +class CheckBox; +class RadioButton; + +namespace sfx2 { namespace sidebar { + +class FocusManager; +class TabBarConfiguration; +class TabItem; +class SidebarController; + +/** The tab bar is the container for the individual tabs. +*/ +class TabBar + : public vcl::Window +{ +public: + /** DeckMenuData has entries for display name, deck id, and a flag: + - isCurrentDeck for the deck selection data + - isEnabled for the show/hide menu + */ + class DeckMenuData + { + public: + ::rtl::OUString msDisplayName; + ::rtl::OUString msDeckId; + bool mbIsCurrentDeck; + bool mbIsActive; + bool mbIsEnabled; + }; + typedef ::boost::function<void( + const Rectangle&, + const ::std::vector<DeckMenuData>& rMenuData)> PopupMenuProvider; + TabBar ( + vcl::Window* pParentWindow, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& rDeckActivationFunctor, + const PopupMenuProvider& rPopupMenuProvider, + SidebarController* rParentSidebarController); + + virtual ~TabBar(); + virtual void dispose() SAL_OVERRIDE; + + virtual void Paint (vcl::RenderContext& /*rRenderContext*/, const Rectangle& rUpdateArea) SAL_OVERRIDE; + virtual void DataChanged (const DataChangedEvent& rDataChangedEvent) SAL_OVERRIDE; + virtual bool Notify (NotifyEvent& rEvent) SAL_OVERRIDE; + + static sal_Int32 GetDefaultWidth(); + + void SetDecks ( + const ResourceManager::DeckContextDescriptorContainer& rDecks); + void HighlightDeck (const ::rtl::OUString& rsDeckId); + void RemoveDeckHighlight (); + void AddPopupMenuEntries ( + PopupMenu& rMenu, + const sal_Int32 nFirstIndex); + void AddCustomizationMenuEntries ( + PopupMenu& rMenu, + const sal_Int32 nFirstIndex); + const ::rtl::OUString GetDeckIdForIndex (const sal_Int32 nIndex) const; + void ToggleHideFlag (const sal_Int32 nIndex); + void RestoreHideFlags(); + + void UpdateFocusManager (FocusManager& rFocusManager); + +private: + css::uno::Reference<css::frame::XFrame> mxFrame; + VclPtr<CheckBox> mpMenuButton; + class Item + { + public: + DECL_LINK(HandleClick, Button*); + VclPtr<RadioButton> mpButton; + ::rtl::OUString msDeckId; + ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor; + bool mbIsHidden; + bool mbIsHiddenByDefault; + }; + typedef ::std::vector<Item> ItemContainer; + ItemContainer maItems; + const ::boost::function<void(const ::rtl::OUString&rsDeckId)> maDeckActivationFunctor; + sal_Int32 mnMenuSeparatorY; + PopupMenuProvider maPopupMenuProvider; + + VclPtr<RadioButton> CreateTabItem (const DeckDescriptor& rDeckDescriptor); + Image GetItemImage (const DeckDescriptor& rDeskDescriptor) const; + void Layout(); + void UpdateButtonIcons(); + + ::boost::shared_ptr<PopupMenu> CreatePopupMenu() const; + void ShowPopupMenu() const; + DECL_LINK(OnToolboxClicked, void*); + + SidebarController* pParentSidebarController; + +}; + + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/TabItem.hxx b/include/sfx2/sidebar/TabItem.hxx new file mode 100644 index 000000000000..c5eaabb858c1 --- /dev/null +++ b/include/sfx2/sidebar/TabItem.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_TABITEM_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_TABITEM_HXX + +#include <vcl/button.hxx> + +#include <sfx2/sidebar/DeckDescriptor.hxx> + +namespace vcl { class Window; } + +namespace sfx2 { namespace sidebar { + +/** A single button in the tab bar. +*/ +class TabItem + : public ImageRadioButton +{ +public: + TabItem (vcl::Window* pParentWindow); + + virtual void Paint (vcl::RenderContext& rRenderContext, const Rectangle& rUpdateArea) SAL_OVERRIDE; + virtual void MouseMove (const MouseEvent& rEvent) SAL_OVERRIDE; + virtual void MouseButtonDown (const MouseEvent& rMouseEvent) SAL_OVERRIDE; + virtual void MouseButtonUp (const MouseEvent& rMouseEvent) SAL_OVERRIDE; + +private: + bool mbIsLeftButtonDown; + enum PaintType { + PT_Native, + PT_Theme + } mePaintType; +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/TitleBar.hxx b/include/sfx2/sidebar/TitleBar.hxx new file mode 100644 index 000000000000..9a4d343cf067 --- /dev/null +++ b/include/sfx2/sidebar/TitleBar.hxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_TITLEBAR_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_TITLEBAR_HXX + +#include <sfx2/sidebar/Paint.hxx> + +#include <vcl/fixed.hxx> +#include <sfx2/sidebar/SidebarToolBox.hxx> + +namespace sfx2 { namespace sidebar { + +class TitleBar : public vcl::Window +{ +public: + TitleBar (const OUString& rsTitle, + vcl::Window* pParentWindow, + const sidebar::Paint& rInitialBackgroundPaint); + virtual ~TitleBar(); + virtual void dispose() SAL_OVERRIDE; + + void SetTitle (const OUString& rsTitle); + const OUString GetTitle() {return msTitle; } + + void SetIcon (const Image& rIcon); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE; + virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rUpdateArea) SAL_OVERRIDE; + virtual void DataChanged (const DataChangedEvent& rEvent) SAL_OVERRIDE; + virtual void setPosSizePixel (long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All) SAL_OVERRIDE; + + ToolBox& GetToolBox() + { + return *maToolBox.get(); + } + const ToolBox& GetToolBox() const + { + return *maToolBox.get(); + } + +protected: + VclPtr<SidebarToolBox> maToolBox; + OUString msTitle; + + virtual Rectangle GetTitleArea (const Rectangle& rTitleBarBox) = 0; + virtual void PaintDecoration (vcl::RenderContext& rRenderContext, const Rectangle& rTitleBarBox) = 0; + void PaintFocus(vcl::RenderContext& rRenderContext, const Rectangle& rFocusBox); + virtual sidebar::Paint GetBackgroundPaint() = 0; + virtual Color GetTextColor() = 0; + virtual void HandleToolBoxItemClick (const sal_uInt16 nItemIndex); + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() SAL_OVERRIDE; + +private: + Image maIcon; + sidebar::Paint maBackgroundPaint; + + void PaintTitle(vcl::RenderContext& rRenderContext, const Rectangle& rTitleBox); + DECL_LINK_TYPED(SelectionHandler, ToolBox*, void); +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/ToolBox.hxx b/include/sfx2/sidebar/ToolBox.hxx new file mode 100644 index 000000000000..834d7cb2b7a0 --- /dev/null +++ b/include/sfx2/sidebar/ToolBox.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 . + */ +#ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_TOOLBOX_HXX +#define INCLUDED_SFX2_SOURCE_SIDEBAR_TOOLBOX_HXX + +#include <vcl/toolbox.hxx> + +namespace sfx2 { namespace sidebar { + +class ToolBox + : public ::ToolBox +{ +public: + MenuButton (vcl::Window* pParentWindow); + virtual ~MenuButton(); + + virtual void Paint (const Rectangle& rUpdateArea); + virtual void MouseMove (const MouseEvent& rEvent); + virtual void MouseButtonDown (const MouseEvent& rMouseEvent); + virtual void MouseButtonUp (const MouseEvent& rMouseEvent); + +protected: + using CheckBox::FillLayoutData; + +private: + bool mbIsLeftButtonDown; + enum PaintType { + PT_Native, + PT_Theme + } mePaintType; +}; + +} } // end of namespace sfx2::sidebar + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/UnoDeck.hxx b/include/sfx2/sidebar/UnoDeck.hxx new file mode 100644 index 000000000000..1d9fcc2096b4 --- /dev/null +++ b/include/sfx2/sidebar/UnoDeck.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/. + * + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_UNODECK_HXX +#define INCLUDED_SFX2_SIDEBAR_UNODECK_HXX + + +#include <com/sun/star/ui/XDeck.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/ui/XPanels.hpp> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> + +/** get the decks +*/ +class SfxUnoDeck : public ::cppu::WeakImplHelper1< css::ui::XDeck > +{ + +public: + + SfxUnoDeck(const css::uno::Reference<css::frame::XFrame>& , const OUString&); + virtual ~SfxUnoDeck() {}; + + virtual OUString SAL_CALL getId() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual OUString SAL_CALL getTitle() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setTitle( const OUString& newTitle ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL isActive() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL activate( const sal_Bool bActivate ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Reference<css::ui::XPanels> SAL_CALL getPanels() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Int32 SAL_CALL getOrderIndex() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setOrderIndex( const sal_Int32 newOrderIndex ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveFirst() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveLast() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveUp() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveDown() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + + const css::uno::Reference<css::frame::XFrame> xFrame; + sfx2::sidebar::SidebarController* getSidebarController(); + + const OUString mDeckId; + const OUString mTitle; + + sal_Int32 GetMaxOrderIndex(sfx2::sidebar::ResourceManager::DeckContextDescriptorContainer aDecks); + sal_Int32 GetMinOrderIndex(sfx2::sidebar::ResourceManager::DeckContextDescriptorContainer aDecks); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/UnoDecks.hxx b/include/sfx2/sidebar/UnoDecks.hxx new file mode 100644 index 000000000000..5e0089935dd6 --- /dev/null +++ b/include/sfx2/sidebar/UnoDecks.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/. + * + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_DECKS_HXX +#define INCLUDED_SFX2_SIDEBAR_DECKS_HXX + + +#include <com/sun/star/ui/XDecks.hpp> + +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> + +/** get the decks +*/ +class SfxUnoDecks : public ::cppu::WeakImplHelper1< css::ui::XDecks > +{ + +public: + + SfxUnoDecks(const css::uno::Reference<css::frame::XFrame>&); + virtual ~SfxUnoDecks() {}; + +// XNameAccess + + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) + throw(css::container::NoSuchElementException, + css::lang::WrappedTargetException, + css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +// XIndexAccess + + virtual sal_Int32 SAL_CALL getCount() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) + throw(css::lang::IndexOutOfBoundsException, + css::lang::WrappedTargetException, + css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual sal_Bool SAL_CALL hasElements() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + + const css::uno::Reference<css::frame::XFrame> xFrame; + sfx2::sidebar::SidebarController* getSidebarController(); + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/include/sfx2/sidebar/UnoPanel.hxx b/include/sfx2/sidebar/UnoPanel.hxx new file mode 100644 index 000000000000..051a00d8d5a0 --- /dev/null +++ b/include/sfx2/sidebar/UnoPanel.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/. + * + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_UNOPANEL_HXX +#define INCLUDED_SFX2_SIDEBAR_UNOPANEL_HXX + +#include <com/sun/star/ui/XPanel.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/awt/XWindow.hpp> + + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/sidebar/Panel.hxx> +#include <sfx2/sidebar/Deck.hxx> +#include <sfx2/sidebar/ResourceManager.hxx> + + +/** get the Panel +*/ +class SfxUnoPanel : public ::cppu::WeakImplHelper1< css::ui::XPanel > +{ + +public: + + SfxUnoPanel(const css::uno::Reference<css::frame::XFrame>& , const OUString&, const OUString&); + virtual ~SfxUnoPanel() {}; + + virtual OUString SAL_CALL getId() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual OUString SAL_CALL getTitle() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setTitle( const OUString& newTitle ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL isExpanded() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL expand( const sal_Bool bCollapseOther ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL collapse( ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Int32 SAL_CALL getOrderIndex() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL setOrderIndex( const sal_Int32 newOrderIndex ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveFirst() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveLast() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveUp() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL moveDown() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Reference<css::awt::XWindow> SAL_CALL getDialog() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + + const css::uno::Reference<css::frame::XFrame> xFrame; + sfx2::sidebar::SidebarController* getSidebarController(); + + const OUString mPanelId; + const OUString mDeckId; + + sfx2::sidebar::Deck* mpDeck; + sfx2::sidebar::Panel* mpPanel; + + sal_Int32 GetMaxOrderIndex(sfx2::sidebar::ResourceManager::PanelContextDescriptorContainer aPanels); + sal_Int32 GetMinOrderIndex(sfx2::sidebar::ResourceManager::PanelContextDescriptorContainer aPanels); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/UnoPanels.hxx b/include/sfx2/sidebar/UnoPanels.hxx new file mode 100644 index 000000000000..679163347e46 --- /dev/null +++ b/include/sfx2/sidebar/UnoPanels.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/. + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_PANELS_HXX +#define INCLUDED_SFX2_SIDEBAR_PANELS_HXX + + +#include <com/sun/star/ui/XPanels.hpp> + +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> + +/** get the decks +*/ +class SfxUnoPanels : public ::cppu::WeakImplHelper1< css::ui::XPanels > +{ + +public: + + SfxUnoPanels(const css::uno::Reference<css::frame::XFrame>& , const OUString&); + virtual ~SfxUnoPanels() {}; + +// XPanels + virtual OUString SAL_CALL getDeckId() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +// XNameAccess + + virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) + throw(css::container::NoSuchElementException, + css::lang::WrappedTargetException, + css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +// XIndexAccess + + virtual sal_Int32 SAL_CALL getCount() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) + throw(css::lang::IndexOutOfBoundsException, + css::lang::WrappedTargetException, + css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +// XElementAccess + virtual css::uno::Type SAL_CALL getElementType() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual sal_Bool SAL_CALL hasElements() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +private: + + const css::uno::Reference<css::frame::XFrame> xFrame; + sfx2::sidebar::SidebarController* getSidebarController(); + const OUString& mDeckId; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/UnoSidebar.hxx b/include/sfx2/sidebar/UnoSidebar.hxx new file mode 100644 index 000000000000..6c154c0840a5 --- /dev/null +++ b/include/sfx2/sidebar/UnoSidebar.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/. + * + */ + +#ifndef INCLUDED_SFX2_SIDEBAR_SIDEBAR_HXX +#define INCLUDED_SFX2_SIDEBAR_SIDEBAR_HXX + +#include <sfx2/dllapi.h> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/ui/XSidebarProvider.hpp> + +#include <com/sun/star/awt/XWindow2.hpp> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/weakref.hxx> + +#include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/sidebar/SidebarDockingWindow.hxx> + +#include <sfx2/sidebar/UnoDecks.hxx> +#include <com/sun/star/ui/XDecks.hpp> + +/** get the sidebar for a given frame +*/ +class SfxUnoSidebar : public ::cppu::WeakImplHelper1< css::ui::XSidebarProvider > +{ + +private : + + const css::uno::Reference<css::frame::XFrame> xFrame; + sfx2::sidebar::SidebarController* getSidebarController(); + +public: + + SfxUnoSidebar(const css::uno::Reference<css::frame::XFrame>&); + + virtual void SAL_CALL showDecks (const sal_Bool bVisible) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + + virtual void SAL_CALL setVisible (const sal_Bool bVisible) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual sal_Bool SAL_CALL isVisible() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + + virtual css::uno::Reference<css::frame::XFrame> SAL_CALL getFrame() + throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + + virtual css::uno::Reference<css::ui::XDecks> SAL_CALL getDecks() + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |