dbaccess/source/ui/browser/genericcontroller.cxx |   10 
 include/dbaccess/genericcontroller.hxx           |    5 
 include/sfx2/sfxbasecontroller.hxx               |    4 
 include/sfx2/sidebar/Accessible.hxx              |   67 +++++
 include/sfx2/sidebar/AccessibleTitleBar.hxx      |   47 +++
 include/sfx2/sidebar/AsynchronousCall.hxx        |   55 ++++
 include/sfx2/sidebar/Context.hxx                 |   63 +++++
 include/sfx2/sidebar/ContextList.hxx             |   70 +++++
 include/sfx2/sidebar/Deck.hxx                    |  103 ++++++++
 include/sfx2/sidebar/DeckDescriptor.hxx          |   57 ++++
 include/sfx2/sidebar/DeckLayouter.hxx            |   57 ++++
 include/sfx2/sidebar/DeckTitleBar.hxx            |   55 ++++
 include/sfx2/sidebar/DrawHelper.hxx              |   51 ++++
 include/sfx2/sidebar/FocusManager.hxx            |  150 ++++++++++++
 include/sfx2/sidebar/MenuButton.hxx              |   52 ++++
 include/sfx2/sidebar/Paint.hxx                   |   78 ++++++
 include/sfx2/sidebar/Panel.hxx                   |   86 +++++++
 include/sfx2/sidebar/PanelDescriptor.hxx         |   54 ++++
 include/sfx2/sidebar/PanelTitleBar.hxx           |   66 +++++
 include/sfx2/sidebar/ResourceManager.hxx         |  135 +++++++++++
 include/sfx2/sidebar/Sidebar.hrc                 |   60 +++++
 include/sfx2/sidebar/SidebarController.hxx       |  275 +++++++++++++++++++++++
 include/sfx2/sidebar/SidebarDockingWindow.hxx    |   61 +++++
 include/sfx2/sidebar/SidebarResource.hxx         |   35 ++
 include/sfx2/sidebar/TabBar.hxx                  |  136 +++++++++++
 include/sfx2/sidebar/TabItem.hxx                 |   55 ++++
 include/sfx2/sidebar/TitleBar.hxx                |   81 ++++++
 include/sfx2/sidebar/ToolBox.hxx                 |   53 ++++
 include/sfx2/sidebar/UnoDeck.hxx                 |   79 ++++++
 include/sfx2/sidebar/UnoDecks.hxx                |   75 ++++++
 include/sfx2/sidebar/UnoPanel.hxx                |   86 +++++++
 include/sfx2/sidebar/UnoPanels.hxx               |   78 ++++++
 include/sfx2/sidebar/UnoSidebar.hxx              |   63 +++++
 offapi/UnoApi_offapi.mk                          |    5 
 offapi/com/sun/star/frame/XController2.idl       |    5 
 offapi/com/sun/star/ui/XDeck.idl                 |   90 +++++++
 offapi/com/sun/star/ui/XDecks.idl                |   32 ++
 offapi/com/sun/star/ui/XPanel.idl                |   92 +++++++
 offapi/com/sun/star/ui/XPanels.idl               |   34 ++
 offapi/com/sun/star/ui/XSidebarProvider.idl      |   61 +++++
 sfx2/Library_sfx.mk                              |    5 
 sfx2/source/sidebar/Accessible.cxx               |    2 
 sfx2/source/sidebar/Accessible.hxx               |   67 -----
 sfx2/source/sidebar/AccessibleTitleBar.cxx       |    6 
 sfx2/source/sidebar/AccessibleTitleBar.hxx       |   47 ---
 sfx2/source/sidebar/AsynchronousCall.cxx         |    3 
 sfx2/source/sidebar/AsynchronousCall.hxx         |   55 ----
 sfx2/source/sidebar/Context.cxx                  |    3 
 sfx2/source/sidebar/Context.hxx                  |   63 -----
 sfx2/source/sidebar/ContextList.cxx              |    9 
 sfx2/source/sidebar/ContextList.hxx              |   68 -----
 sfx2/source/sidebar/ControlFactory.cxx           |    4 
 sfx2/source/sidebar/Deck.cxx                     |   29 +-
 sfx2/source/sidebar/Deck.hxx                     |  105 --------
 sfx2/source/sidebar/DeckDescriptor.cxx           |    8 
 sfx2/source/sidebar/DeckDescriptor.hxx           |   53 ----
 sfx2/source/sidebar/DeckLayouter.cxx             |    8 
 sfx2/source/sidebar/DeckLayouter.hxx             |   57 ----
 sfx2/source/sidebar/DeckTitleBar.cxx             |    5 
 sfx2/source/sidebar/DeckTitleBar.hxx             |   55 ----
 sfx2/source/sidebar/DrawHelper.cxx               |    4 
 sfx2/source/sidebar/DrawHelper.hxx               |   51 ----
 sfx2/source/sidebar/FocusManager.cxx             |   10 
 sfx2/source/sidebar/FocusManager.hxx             |  150 ------------
 sfx2/source/sidebar/MenuButton.cxx               |    6 
 sfx2/source/sidebar/MenuButton.hxx               |   52 ----
 sfx2/source/sidebar/Paint.cxx                    |    2 
 sfx2/source/sidebar/Paint.hxx                    |   78 ------
 sfx2/source/sidebar/Panel.cxx                    |   24 +-
 sfx2/source/sidebar/Panel.hxx                    |   79 ------
 sfx2/source/sidebar/PanelDescriptor.cxx          |    2 
 sfx2/source/sidebar/PanelDescriptor.hxx          |   54 ----
 sfx2/source/sidebar/PanelTitleBar.cxx            |    9 
 sfx2/source/sidebar/PanelTitleBar.hxx            |   66 -----
 sfx2/source/sidebar/ResourceManager.cxx          |   48 +++-
 sfx2/source/sidebar/ResourceManager.hxx          |  125 ----------
 sfx2/source/sidebar/Sidebar.cxx                  |    8 
 sfx2/source/sidebar/Sidebar.hrc                  |   60 -----
 sfx2/source/sidebar/Sidebar.src                  |    2 
 sfx2/source/sidebar/SidebarChildWindow.cxx       |    4 
 sfx2/source/sidebar/SidebarController.cxx        |  155 +++++++++---
 sfx2/source/sidebar/SidebarController.hxx        |  257 ---------------------
 sfx2/source/sidebar/SidebarDockingWindow.cxx     |    4 
 sfx2/source/sidebar/SidebarDockingWindow.hxx     |   61 -----
 sfx2/source/sidebar/SidebarResource.hxx          |   35 --
 sfx2/source/sidebar/TabBar.cxx                   |   31 +-
 sfx2/source/sidebar/TabBar.hxx                   |  130 ----------
 sfx2/source/sidebar/TabItem.cxx                  |    6 
 sfx2/source/sidebar/TabItem.hxx                  |   55 ----
 sfx2/source/sidebar/Theme.cxx                    |    4 
 sfx2/source/sidebar/TitleBar.cxx                 |    8 
 sfx2/source/sidebar/TitleBar.hxx                 |   79 ------
 sfx2/source/sidebar/ToolBox.hxx                  |   53 ----
 sfx2/source/sidebar/UnoDeck.cxx                  |  262 +++++++++++++++++++++
 sfx2/source/sidebar/UnoDecks.cxx                 |  168 ++++++++++++++
 sfx2/source/sidebar/UnoPanel.cxx                 |  271 ++++++++++++++++++++++
 sfx2/source/sidebar/UnoPanels.cxx                |  180 +++++++++++++++
 sfx2/source/sidebar/UnoSidebar.cxx               |  102 ++++++++
 sfx2/source/view/sfxbasecontroller.cxx           |   15 +
 vcl/source/window/window.cxx                     |    1 
 100 files changed, 4007 insertions(+), 2077 deletions(-)

New commits:
commit a64999511ae654131d997eec9a3d78478cfc1c75
Author: Laurent Godard <lgodard.li...@laposte.net>
Date:   Thu Apr 30 16:56:14 2015 +0200

    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 <c...@libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    Tested-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx 
b/dbaccess/source/ui/browser/genericcontroller.cxx
index 405bb91..42bd37f 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -45,6 +45,10 @@
 #include "UITools.hxx"
 #include "commontypes.hxx"
 
+#include <com/sun/star/ui/XSidebarProvider.hpp>
+#include <sfx2/sidebar/UnoSidebar.hxx>
+
+
 #include <vcl/waitobj.hxx>
 #include <svl/urihelper.hxx>
 #include "datasourceconnector.hxx"
@@ -72,6 +76,7 @@ using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::sdb;
 using namespace ::com::sun::star::task;
 using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::ui;
 using namespace ::dbtools;
 using namespace ::comphelper;
 
@@ -367,6 +372,11 @@ Reference< XWindow > SAL_CALL 
OGenericUnoController::getComponentWindow() throw
     return VCLUnoHelper::GetInterface( getView() );
 }
 
+Reference<XSidebarProvider> SAL_CALL OGenericUnoController::getSidebar() throw 
(RuntimeException, std::exception)
+{
+        return NULL;
+}
+
 OUString SAL_CALL OGenericUnoController::getViewControllerName() throw 
(::com::sun::star::uno::RuntimeException, std::exception)
 {
     return OUString( "Default" );
diff --git a/include/dbaccess/genericcontroller.hxx 
b/include/dbaccess/genericcontroller.hxx
index 07a9dec..f195321 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 0f77a44..d387d80 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/sfx2/source/sidebar/Accessible.hxx 
b/include/sfx2/sidebar/Accessible.hxx
similarity index 100%
rename from sfx2/source/sidebar/Accessible.hxx
rename to include/sfx2/sidebar/Accessible.hxx
diff --git a/sfx2/source/sidebar/AccessibleTitleBar.hxx 
b/include/sfx2/sidebar/AccessibleTitleBar.hxx
similarity index 100%
rename from sfx2/source/sidebar/AccessibleTitleBar.hxx
rename to include/sfx2/sidebar/AccessibleTitleBar.hxx
diff --git a/sfx2/source/sidebar/AsynchronousCall.hxx 
b/include/sfx2/sidebar/AsynchronousCall.hxx
similarity index 100%
rename from sfx2/source/sidebar/AsynchronousCall.hxx
rename to include/sfx2/sidebar/AsynchronousCall.hxx
diff --git a/sfx2/source/sidebar/Context.hxx b/include/sfx2/sidebar/Context.hxx
similarity index 100%
rename from sfx2/source/sidebar/Context.hxx
rename to include/sfx2/sidebar/Context.hxx
diff --git a/sfx2/source/sidebar/ContextList.hxx 
b/include/sfx2/sidebar/ContextList.hxx
similarity index 96%
rename from sfx2/source/sidebar/ContextList.hxx
rename to include/sfx2/sidebar/ContextList.hxx
index 9886007..5171072 100644
--- a/sfx2/source/sidebar/ContextList.hxx
+++ b/include/sfx2/sidebar/ContextList.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXTLIST_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_CONTEXTLIST_HXX
 
-#include "Context.hxx"
+#include <sfx2/sidebar/Context.hxx>
 #include <sal/types.h>
 #include <rtl/ustring.hxx>
 
@@ -55,6 +55,8 @@ public:
         const bool bIsInitiallyVisible,
         const ::rtl::OUString& rsMenuCommand);
 
+    sal_Int32 GetCount();
+
 private:
     ::std::vector<Entry> maEntries;
 
diff --git a/sfx2/source/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx
similarity index 94%
rename from sfx2/source/sidebar/Deck.hxx
rename to include/sfx2/sidebar/Deck.hxx
index 9efaadc..edd735c 100644
--- a/sfx2/source/sidebar/Deck.hxx
+++ b/include/sfx2/sidebar/Deck.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_DECK_HXX
 
-#include "Panel.hxx"
+#include <sfx2/sidebar/Panel.hxx>
 
 #include <vcl/window.hxx>
 #include <vcl/image.hxx>
@@ -44,17 +44,15 @@ public:
     virtual ~Deck();
     virtual void dispose() SAL_OVERRIDE;
 
-    const OUString& GetId() const
-    {
-        return msId;
-    }
+    const OUString& GetId() const { return msId; }
+
     DeckTitleBar* GetTitleBar() const;
     Rectangle GetContentArea() const;
     void ResetPanels (const SharedPanelContainer& rPanels);
-    const SharedPanelContainer& GetPanels() const
-    {
-        return maPanels;
-    }
+    const SharedPanelContainer& GetPanels() const  { return maPanels; }
+
+    Panel* GetPanel(OUString panelId);
+
     void RequestLayout();
     vcl::Window* GetPanelParentWindow();
 
diff --git a/sfx2/source/sidebar/DeckDescriptor.hxx 
b/include/sfx2/sidebar/DeckDescriptor.hxx
similarity index 96%
rename from sfx2/source/sidebar/DeckDescriptor.hxx
rename to include/sfx2/sidebar/DeckDescriptor.hxx
index 77f811e..a0980c6 100644
--- a/sfx2/source/sidebar/DeckDescriptor.hxx
+++ b/include/sfx2/sidebar/DeckDescriptor.hxx
@@ -23,6 +23,8 @@
 #include "ContextList.hxx"
 #include <boost/shared_ptr.hpp>
 
+#include <sfx2/sidebar/Deck.hxx>
+
 namespace sfx2 { namespace sidebar {
 
 class DeckDescriptor
@@ -41,6 +43,8 @@ public:
     sal_Int32 mnOrderIndex;
     bool mbExperimental;
 
+    VclPtr<Deck> mpDeck;
+
     DeckDescriptor();
     DeckDescriptor (const DeckDescriptor& rOther);
     ~DeckDescriptor();
diff --git a/sfx2/source/sidebar/DeckLayouter.hxx 
b/include/sfx2/sidebar/DeckLayouter.hxx
similarity index 98%
rename from sfx2/source/sidebar/DeckLayouter.hxx
rename to include/sfx2/sidebar/DeckLayouter.hxx
index 965fb56..8b3b248 100644
--- a/sfx2/source/sidebar/DeckLayouter.hxx
+++ b/include/sfx2/sidebar/DeckLayouter.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECKLAYOUTER_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_DECKLAYOUTER_HXX
 
-#include "Panel.hxx"
+#include <sfx2/sidebar/Panel.hxx>
 
 #include <tools/gen.hxx>
 
diff --git a/sfx2/source/sidebar/DeckTitleBar.hxx 
b/include/sfx2/sidebar/DeckTitleBar.hxx
similarity index 98%
rename from sfx2/source/sidebar/DeckTitleBar.hxx
rename to include/sfx2/sidebar/DeckTitleBar.hxx
index bd47883..3b42958 100644
--- a/sfx2/source/sidebar/DeckTitleBar.hxx
+++ b/include/sfx2/sidebar/DeckTitleBar.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_DECKTITLEBAR_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_DECKTITLEBAR_HXX
 
-#include "TitleBar.hxx"
+#include <sfx2/sidebar/TitleBar.hxx>
 
 namespace sfx2 { namespace sidebar {
 
diff --git a/sfx2/source/sidebar/DrawHelper.hxx 
b/include/sfx2/sidebar/DrawHelper.hxx
similarity index 100%
rename from sfx2/source/sidebar/DrawHelper.hxx
rename to include/sfx2/sidebar/DrawHelper.hxx
diff --git a/sfx2/source/sidebar/FocusManager.hxx 
b/include/sfx2/sidebar/FocusManager.hxx
similarity index 100%
rename from sfx2/source/sidebar/FocusManager.hxx
rename to include/sfx2/sidebar/FocusManager.hxx
diff --git a/sfx2/source/sidebar/MenuButton.hxx 
b/include/sfx2/sidebar/MenuButton.hxx
similarity index 100%
rename from sfx2/source/sidebar/MenuButton.hxx
rename to include/sfx2/sidebar/MenuButton.hxx
diff --git a/sfx2/source/sidebar/Paint.hxx b/include/sfx2/sidebar/Paint.hxx
similarity index 100%
rename from sfx2/source/sidebar/Paint.hxx
rename to include/sfx2/sidebar/Paint.hxx
diff --git a/sfx2/source/sidebar/Panel.hxx b/include/sfx2/sidebar/Panel.hxx
similarity index 91%
rename from sfx2/source/sidebar/Panel.hxx
rename to include/sfx2/sidebar/Panel.hxx
index 52e6e49..b42dbc9 100644
--- a/sfx2/source/sidebar/Panel.hxx
+++ b/include/sfx2/sidebar/Panel.hxx
@@ -19,11 +19,13 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_PANEL_HXX
 
-#include "Context.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>
@@ -40,7 +42,9 @@ 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 std::function<Context()>& rContextAccess,
+          const css::uno::Reference<css::frame::XFrame>& rxFrame);
+
     virtual ~Panel();
     virtual void dispose() SAL_OVERRIDE;
 
@@ -69,6 +73,9 @@ private:
     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;
 
diff --git a/sfx2/source/sidebar/PanelDescriptor.hxx 
b/include/sfx2/sidebar/PanelDescriptor.hxx
similarity index 97%
rename from sfx2/source/sidebar/PanelDescriptor.hxx
rename to include/sfx2/sidebar/PanelDescriptor.hxx
index f67a128..fa490b9 100644
--- a/sfx2/source/sidebar/PanelDescriptor.hxx
+++ b/include/sfx2/sidebar/PanelDescriptor.hxx
@@ -20,7 +20,7 @@
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_PANELDESCRIPTOR_HXX
 
 #include <sfx2/sidebar/EnumContext.hxx>
-#include "ContextList.hxx"
+#include <sfx2/sidebar/ContextList.hxx>
 #include <boost/shared_ptr.hpp>
 
 namespace sfx2 { namespace sidebar {
diff --git a/sfx2/source/sidebar/PanelTitleBar.hxx 
b/include/sfx2/sidebar/PanelTitleBar.hxx
similarity index 98%
rename from sfx2/source/sidebar/PanelTitleBar.hxx
rename to include/sfx2/sidebar/PanelTitleBar.hxx
index 8c0f7e8..c081402 100644
--- a/sfx2/source/sidebar/PanelTitleBar.hxx
+++ b/include/sfx2/sidebar/PanelTitleBar.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_PANELTITLEBAR_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_PANELTITLEBAR_HXX
 
-#include "TitleBar.hxx"
+#include <sfx2/sidebar/TitleBar.hxx>
 
 #include <com/sun/star/frame/XFrame.hpp>
 #include <boost/function.hpp>
diff --git a/sfx2/source/sidebar/ResourceManager.hxx 
b/include/sfx2/sidebar/ResourceManager.hxx
similarity index 93%
rename from sfx2/source/sidebar/ResourceManager.hxx
rename to include/sfx2/sidebar/ResourceManager.hxx
index 9151760..4e6247d 100644
--- a/sfx2/source/sidebar/ResourceManager.hxx
+++ b/include/sfx2/sidebar/ResourceManager.hxx
@@ -21,7 +21,7 @@
 
 #include "DeckDescriptor.hxx"
 #include "PanelDescriptor.hxx"
-#include "Context.hxx"
+#include <sfx2/sidebar/Context.hxx>
 #include <unotools/confignode.hxx>
 #include <com/sun/star/frame/XFrame.hpp>
 #include <set>
@@ -40,6 +40,10 @@ class ContextList;
 class ResourceManager
 {
 public:
+
+     ResourceManager();
+    ~ResourceManager();
+
     static ResourceManager& Instance();
 
     const DeckDescriptor* GetDeckDescriptor(const OUString& rsDeckId) const;
@@ -54,6 +58,13 @@ public:
     */
     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:
@@ -92,8 +103,7 @@ public:
                                   const Context& rContext);
 
 private:
-    ResourceManager();
-    ~ResourceManager();
+
 
     typedef std::vector<DeckDescriptor> DeckContainer;
     DeckContainer maDecks;
diff --git a/sfx2/source/sidebar/Sidebar.hrc b/include/sfx2/sidebar/Sidebar.hrc
similarity index 100%
rename from sfx2/source/sidebar/Sidebar.hrc
rename to include/sfx2/sidebar/Sidebar.hrc
diff --git a/sfx2/source/sidebar/SidebarController.hxx 
b/include/sfx2/sidebar/SidebarController.hxx
similarity index 91%
rename from sfx2/source/sidebar/SidebarController.hxx
rename to include/sfx2/sidebar/SidebarController.hxx
index 5fb8466..0e1fe0e 100644
--- a/sfx2/source/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -23,12 +23,12 @@
 
 #include <map>
 
-#include "AsynchronousCall.hxx"
-#include "Context.hxx"
-#include "FocusManager.hxx"
-#include "Panel.hxx"
-#include "ResourceManager.hxx"
-#include "TabBar.hxx"
+#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>
 
@@ -45,6 +45,8 @@
 #include <cppuhelper/basemutex.hxx>
 #include <cppuhelper/weakref.hxx>
 
+
+
 namespace
 {
     typedef ::cppu::WeakComponentImplHelper4 <
@@ -137,6 +139,21 @@ public:
 
     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>,
@@ -198,13 +215,13 @@ private:
         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 ::rtl::OUString& rsDeckId);
+
     void SwitchToDeck (
         const DeckDescriptor& rDeckDescriptor,
         const Context& rContext);
@@ -245,9 +262,10 @@ private:
     */
     void ShowPanel (const Panel& rPanel);
 
-    Context GetCurrentContext() const { return maCurrentContext;}
-
     virtual void SAL_CALL disposing() SAL_OVERRIDE;
+
+    std::unique_ptr<ResourceManager> mpResourceManager;
+
 };
 
 } } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.hxx 
b/include/sfx2/sidebar/SidebarDockingWindow.hxx
similarity index 100%
rename from sfx2/source/sidebar/SidebarDockingWindow.hxx
rename to include/sfx2/sidebar/SidebarDockingWindow.hxx
diff --git a/sfx2/source/sidebar/SidebarResource.hxx 
b/include/sfx2/sidebar/SidebarResource.hxx
similarity index 97%
rename from sfx2/source/sidebar/SidebarResource.hxx
rename to include/sfx2/sidebar/SidebarResource.hxx
index 3a6363a..78ce96b 100644
--- a/sfx2/source/sidebar/SidebarResource.hxx
+++ b/include/sfx2/sidebar/SidebarResource.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARRESOURCE_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_SIDEBARRESOURCE_HXX
 
-#include "Sidebar.hrc"
+#include <sfx2/sidebar/Sidebar.hrc>
 #include <sfx2/sfxresid.hxx>
 #include <tools/rc.hxx>
 
diff --git a/sfx2/source/sidebar/TabBar.hxx b/include/sfx2/sidebar/TabBar.hxx
similarity index 94%
rename from sfx2/source/sidebar/TabBar.hxx
rename to include/sfx2/sidebar/TabBar.hxx
index 37089f8..1fe2a27 100644
--- a/sfx2/source/sidebar/TabBar.hxx
+++ b/include/sfx2/sidebar/TabBar.hxx
@@ -20,7 +20,8 @@
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_TABBAR_HXX
 
 #include "DeckDescriptor.hxx"
-#include "ResourceManager.hxx"
+#include <sfx2/sidebar/ResourceManager.hxx>
+
 
 #include <vcl/menu.hxx>
 #include <vcl/window.hxx>
@@ -39,6 +40,7 @@ namespace sfx2 { namespace sidebar {
 class FocusManager;
 class TabBarConfiguration;
 class TabItem;
+class SidebarController;
 
 /** The tab bar is the container for the individual tabs.
 */
@@ -66,7 +68,9 @@ public:
         vcl::Window* pParentWindow,
         const css::uno::Reference<css::frame::XFrame>& rxFrame,
         const ::boost::function<void(const ::rtl::OUString&rsDeckId)>& 
rDeckActivationFunctor,
-        const PopupMenuProvider& rPopupMenuProvider);
+        const PopupMenuProvider& rPopupMenuProvider,
+        SidebarController* rParentSidebarController);
+
     virtual ~TabBar();
     virtual void dispose() SAL_OVERRIDE;
 
@@ -120,6 +124,8 @@ private:
     void ShowPopupMenu() const;
     DECL_LINK(OnToolboxClicked, void*);
 
+    SidebarController* pParentSidebarController;
+
 };
 
 
diff --git a/sfx2/source/sidebar/TabItem.hxx b/include/sfx2/sidebar/TabItem.hxx
similarity index 97%
rename from sfx2/source/sidebar/TabItem.hxx
rename to include/sfx2/sidebar/TabItem.hxx
index f63e4e2..c5eaabb 100644
--- a/sfx2/source/sidebar/TabItem.hxx
+++ b/include/sfx2/sidebar/TabItem.hxx
@@ -21,7 +21,7 @@
 
 #include <vcl/button.hxx>
 
-#include "DeckDescriptor.hxx"
+#include <sfx2/sidebar/DeckDescriptor.hxx>
 
 namespace vcl { class Window; }
 
diff --git a/sfx2/source/sidebar/TitleBar.hxx 
b/include/sfx2/sidebar/TitleBar.hxx
similarity index 95%
rename from sfx2/source/sidebar/TitleBar.hxx
rename to include/sfx2/sidebar/TitleBar.hxx
index b0bc5d8..9a4d343 100644
--- a/sfx2/source/sidebar/TitleBar.hxx
+++ b/include/sfx2/sidebar/TitleBar.hxx
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_SFX2_SOURCE_SIDEBAR_TITLEBAR_HXX
 #define INCLUDED_SFX2_SOURCE_SIDEBAR_TITLEBAR_HXX
 
-#include "Paint.hxx"
+#include <sfx2/sidebar/Paint.hxx>
 
 #include <vcl/fixed.hxx>
 #include <sfx2/sidebar/SidebarToolBox.hxx>
@@ -35,7 +35,9 @@ public:
     virtual ~TitleBar();
     virtual void dispose() SAL_OVERRIDE;
 
-    void SetTitle (const ::rtl::OUString& rsTitle);
+    void SetTitle (const OUString& rsTitle);
+    const OUString GetTitle() {return msTitle; }
+
     void SetIcon (const Image& rIcon);
 
     virtual void ApplySettings(vcl::RenderContext& rRenderContext) 
SAL_OVERRIDE;
diff --git a/sfx2/source/sidebar/ToolBox.hxx b/include/sfx2/sidebar/ToolBox.hxx
similarity index 100%
rename from sfx2/source/sidebar/ToolBox.hxx
rename to include/sfx2/sidebar/ToolBox.hxx
diff --git a/include/sfx2/sidebar/UnoDeck.hxx b/include/sfx2/sidebar/UnoDeck.hxx
new file mode 100644
index 0000000..1d9fcc2
--- /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 0000000..5e00899
--- /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 0000000..051a00d
--- /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 0000000..6791633
--- /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 0000000..6c154c0
--- /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: */
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index 97f4f3e..fd1b03a 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -4020,6 +4020,11 @@ $(eval $(call 
gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui,\
        XModuleUIConfigurationManagerSupplier \
        XSidebar \
        XSidebarPanel \
+       XPanel \
+       XPanels \
+       XDeck \
+       XDecks \
+       XSidebarProvider \
        XStatusbarItem \
        XToolPanel \
        XUIConfiguration \
diff --git a/offapi/com/sun/star/frame/XController2.idl 
b/offapi/com/sun/star/frame/XController2.idl
index bd4eaba..400b7ae 100644
--- a/offapi/com/sun/star/frame/XController2.idl
+++ b/offapi/com/sun/star/frame/XController2.idl
@@ -23,6 +23,7 @@
 #include <com/sun/star/frame/XController.idl>
 #include <com/sun/star/awt/XWindow.idl>
 #include <com/sun/star/beans/PropertyValue.idl>
+#include <com/sun/star/ui/XSidebarProvider.idl>
 
 
 module com {  module sun {  module star {  module frame {
@@ -60,6 +61,10 @@ interface XController2 : XController
     */
     [readonly, attribute] sequence< ::com::sun::star::beans::PropertyValue >
                                                             CreationArguments;
+
+    /** get the sidebar if exists
+    */
+    ::com::sun::star::ui::XSidebarProvider getSidebar();
 };
 
 
diff --git a/offapi/com/sun/star/ui/XDeck.idl b/offapi/com/sun/star/ui/XDeck.idl
new file mode 100644
index 0000000..53b7397
--- /dev/null
+++ b/offapi/com/sun/star/ui/XDeck.idl
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+#ifndef __com_sun_star_ui_XDeck_idl__
+#define __com_sun_star_ui_XDeck_idl__
+
+#include <com/sun/star/ui/XPanels.idl>
+
+
+ module com {  module sun {  module star {  module ui {
+
+/** provides access to Desk */
+
+interface XDeck
+
+{
+    /** The deck identifier
+    */
+    string getId();
+
+    /** Get the deck title string
+    */
+    string getTitle();
+
+    /** Set the deck title string
+
+        @param newTitle
+            The new title string
+    */
+    void setTitle( [in] string newTitle );
+
+    /** Is the deck the active one
+    */
+    boolean isActive();
+
+    /** Activate the deck and isplays its content
+
+        @param bActivate
+            The requested state for the deck
+            <ul>
+            <li>TRUE sets the deck as the active one</li>
+            <li>FALSE hide the deck and defaults to the first deck of the 
sidebar</li>
+            </ul>
+    */
+    void activate( [in] boolean bActivate );
+
+    /** Get the ordering index of the deck button in sidebar
+    */
+    long getOrderIndex();
+
+    /** Set the ordering index of the deck button in sidebar
+
+        @param newOrderIndex
+        The new position
+    */
+    void setOrderIndex( [in] long newOrderIndex );
+
+    /** Move deck button at first position in sidebar
+    */
+    void moveFirst();
+
+    /** Move deck button at last position in sidebar
+    */
+    void moveLast();
+
+    /** Move deck one step up in the sidebar
+    */
+    void moveUp();
+
+    /** Move deck one step down in the sidebar
+    */
+    void moveDown();
+
+    /** Panels collection attached to the deck
+    */
+    com::sun::star::ui::XPanels getPanels();
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/offapi/com/sun/star/ui/XDecks.idl 
b/offapi/com/sun/star/ui/XDecks.idl
new file mode 100644
index 0000000..ba7c3a7
--- /dev/null
+++ b/offapi/com/sun/star/ui/XDecks.idl
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.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 __com_sun_star_ui_XDecks_idl__
+#define __com_sun_star_ui_XDecks_idl__
+
+#include <com/sun/star/container/XIndexAccess.idl>
+#include <com/sun/star/container/XNameAccess.idl>
+
+ module com {  module sun {  module star {  module ui {
+
+/** provides access to Desks of a Sidebar.*/
+
+interface XDecks
+
+{
+    interface com::sun::star::container::XIndexAccess;
+    interface com::sun::star::container::XNameAccess;
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/offapi/com/sun/star/ui/XPanel.idl 
b/offapi/com/sun/star/ui/XPanel.idl
new file mode 100644
index 0000000..0070d23
--- /dev/null
+++ b/offapi/com/sun/star/ui/XPanel.idl
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+#ifndef __com_sun_star_ui_XPanel_idl__
+#define __com_sun_star_ui_XPanel_idl__
+
+#include <com/sun/star/ui/XPanel.idl>
+#include <com/sun/star/awt/XWindow.idl>
+
+
+ module com {  module sun {  module star {  module ui {
+
+/** provides access to Desk */
+
+interface XPanel
+
+{
+    /** The panel identifier
+    */
+    string getId();
+
+    /** Get the panel title string
+    */
+    string getTitle();
+
+    /** Set the panel title string
+
+        @param newTitle
+            The new title string
+    */
+    void setTitle( [in] string newTitle );
+
+    /** Is the panel expanded
+    */
+    boolean isExpanded();
+
+    /** Collapse the panel to only show its title bar
+    */
+    void collapse ();
+
+    /** Expand and display the panel
+
+        @param bCollapseOther
+            <ul>
+            <li>TRUE collapse all other panels of the deck</li>
+            <li>FALSE do not change other panels state</li>
+            </ul>
+    */
+    void expand ( [in] boolean bCollapseOther );
+
+    /** Get the ordering index of the panel in the deck
+    */
+    long getOrderIndex();
+
+    /** Set the ordering index of the panel in the deck
+    */
+    void setOrderIndex( [in] long newOrderIndex );
+
+    /** Move panel as first item of the deck
+    */
+    void moveFirst();
+
+    /** Move panel as last item of the deck
+    **/
+    void moveLast();
+
+    /** Move panel one step up in the deck
+    */
+    void moveUp();
+
+    /** Move the panel one step down in the deck
+    */
+    void moveDown();
+
+    /** Get the panel dialog element
+    */
+    com::sun::star::awt::XWindow getDialog();
+
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/offapi/com/sun/star/ui/XPanels.idl 
b/offapi/com/sun/star/ui/XPanels.idl
new file mode 100644
index 0000000..a2aa851
--- /dev/null
+++ b/offapi/com/sun/star/ui/XPanels.idl
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+#ifndef __com_sun_star_ui_XPanels_idl__
+#define __com_sun_star_ui_XPanels_idl__
+
+#include <com/sun/star/container/XIndexAccess.idl>
+#include <com/sun/star/container/XNameAccess.idl>
+
+ module com {  module sun {  module star {  module ui {
+
+/** provides access to Panels of a Deck.*/
+
+interface XPanels
+
+{
+    interface com::sun::star::container::XIndexAccess;
+    interface com::sun::star::container::XNameAccess;
+
+    string getDeckId();
+};
+
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/offapi/com/sun/star/ui/XSidebarProvider.idl 
b/offapi/com/sun/star/ui/XSidebarProvider.idl
new file mode 100644
index 0000000..370925e
--- /dev/null
+++ b/offapi/com/sun/star/ui/XSidebarProvider.idl
@@ -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/.
+ *
+ */
+#ifndef __com_sun_star_ui_XSidebarProvider_idl__
+#define __com_sun_star_ui_XSidebarProvider_idl__
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/frame/XFrame.idl>
+#include <com/sun/star/awt/XWindow2.idl>
+
+#include <com/sun/star/ui/XDecks.idl>
+
+
+module com { module sun { module star { module ui {
+
+/** Interface of the sidebar
+*/
+interface XSidebarProvider: com::sun::star::uno::XInterface
+{
+    /** Display the sidebar
+
+        @param bVisible
+            the requested visible state
+    */
+    void setVisible ( [in] boolean bVisible);
+
+    /** Is the sidebar visible
+    */
+    boolean isVisible();
+
+    /** Get the XFrame owner
+    */
+    com::sun::star::frame::XFrame getFrame();
+
+    /* Decks collection attached to the sidebar
+    */
+    com::sun::star::ui::XDecks getDecks();
+
+    /** Decks container visibility
+
+        @param bVisible
+            the requested visible state
+            <ul>
+            <li>FALSE collapses the deck container horizontally. Then Only 
shows the deck TabBar selector</li>
+            <li>TRUE  expands the deck container and show active Deck 
content</li>
+            </ul>
+    */
+    void showDecks([in] boolean bVisible);
+} ;
+
+} ; } ; } ; } ;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 0a1100e..5db89dd 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -283,6 +283,11 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/sidebar/TitleBar \
     sfx2/source/sidebar/Theme \
     sfx2/source/sidebar/Tools \
+    sfx2/source/sidebar/UnoPanel \
+    sfx2/source/sidebar/UnoPanels \
+    sfx2/source/sidebar/UnoDeck \
+    sfx2/source/sidebar/UnoDecks \
+    sfx2/source/sidebar/UnoSidebar \
     sfx2/source/statbar/stbitem \
     sfx2/source/toolbox/imgmgr \
     sfx2/source/toolbox/tbxitem \
diff --git a/sfx2/source/sidebar/Accessible.cxx 
b/sfx2/source/sidebar/Accessible.cxx
index 7cf157e..10b01dc 100644
--- a/sfx2/source/sidebar/Accessible.cxx
+++ b/sfx2/source/sidebar/Accessible.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "Accessible.hxx"
+#include <sfx2/sidebar/Accessible.hxx>
 
 using namespace css;
 using namespace css::uno;
diff --git a/sfx2/source/sidebar/AccessibleTitleBar.cxx 
b/sfx2/source/sidebar/AccessibleTitleBar.cxx
index 5405837..0d2597b 100644
--- a/sfx2/source/sidebar/AccessibleTitleBar.cxx
+++ b/sfx2/source/sidebar/AccessibleTitleBar.cxx
@@ -17,9 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "AccessibleTitleBar.hxx"
-#include "Accessible.hxx"
-#include "TitleBar.hxx"
+#include <sfx2/sidebar/AccessibleTitleBar.hxx>
+#include <sfx2/sidebar/Accessible.hxx>
+#include <sfx2/sidebar/TitleBar.hxx>
 
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 
diff --git a/sfx2/source/sidebar/AsynchronousCall.cxx 
b/sfx2/source/sidebar/AsynchronousCall.cxx
index a4080fd..f9ebe18 100644
--- a/sfx2/source/sidebar/AsynchronousCall.cxx
+++ b/sfx2/source/sidebar/AsynchronousCall.cxx
@@ -16,7 +16,8 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#include "AsynchronousCall.hxx"
+
+#include <sfx2/sidebar/AsynchronousCall.hxx>
 #include <vcl/svapp.hxx>
 
 namespace sfx2 { namespace sidebar {
diff --git a/sfx2/source/sidebar/Context.cxx b/sfx2/source/sidebar/Context.cxx
index 27d35dd..3a7ce01 100644
--- a/sfx2/source/sidebar/Context.cxx
+++ b/sfx2/source/sidebar/Context.cxx
@@ -16,7 +16,8 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#include "Context.hxx"
+#include <sfx2/sidebar/Context.hxx>
+
 
 #define AnyApplicationName "any"
 #define AnyContextName "any"
diff --git a/sfx2/source/sidebar/ContextList.cxx 
b/sfx2/source/sidebar/ContextList.cxx
index a64b43a..20cdcbc 100644
--- a/sfx2/source/sidebar/ContextList.cxx
+++ b/sfx2/source/sidebar/ContextList.cxx
@@ -16,8 +16,8 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#include "ContextList.hxx"
-#include "Context.hxx"
+#include <sfx2/sidebar/ContextList.hxx>
+#include <sfx2/sidebar/Context.hxx>
 
 using ::rtl::OUString;
 
@@ -85,6 +85,11 @@ void ContextList::AddContextDescription (
     maEntries.back().msMenuCommand = rsMenuCommand;
 }
 
+sal_Int32 ContextList::GetCount()
+{
+    return maEntries.size();
+}
+
 } } // end of namespace sfx2::sidebar
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/ControlFactory.cxx 
b/sfx2/source/sidebar/ControlFactory.cxx
index 1376f9e..96bd62a 100644
--- a/sfx2/source/sidebar/ControlFactory.cxx
+++ b/sfx2/source/sidebar/ControlFactory.cxx
@@ -18,8 +18,8 @@
  */
 #include <sfx2/sidebar/ControlFactory.hxx>
 
-#include "MenuButton.hxx"
-#include "TabItem.hxx"
+#include <sfx2/sidebar/MenuButton.hxx>
+#include <sfx2/sidebar/TabItem.hxx>
 #include <sfx2/sidebar/SidebarToolBox.hxx>
 #include <vcl/toolbox.hxx>
 
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index d5dc5d3..b2eb225 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -17,14 +17,14 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "Deck.hxx"
-#include "DeckDescriptor.hxx"
-#include "DeckLayouter.hxx"
-#include "DrawHelper.hxx"
-#include "DeckTitleBar.hxx"
-#include "PanelTitleBar.hxx"
-#include "Paint.hxx"
-#include "Panel.hxx"
+#include <sfx2/sidebar/Deck.hxx>
+#include <sfx2/sidebar/DeckDescriptor.hxx>
+#include <sfx2/sidebar/DeckLayouter.hxx>
+#include <sfx2/sidebar/DrawHelper.hxx>
+#include <sfx2/sidebar/DeckTitleBar.hxx>
+#include <sfx2/sidebar/PanelTitleBar.hxx>
+#include <sfx2/sidebar/Paint.hxx>
+#include <sfx2/sidebar/Panel.hxx>
 #include <sfx2/sidebar/Tools.hxx>
 #include <sfx2/sidebar/Theme.hxx>
 
@@ -223,6 +223,19 @@ vcl::Window* Deck::GetPanelParentWindow()
     return mpScrollContainer.get();
 }
 
+Panel* Deck::GetPanel(const OUString panelId)
+{
+    for (size_t i = 0; i < maPanels.size(); i++)
+    {
+        if(maPanels[i].get()->GetId() == panelId)
+        {
+            return maPanels[i].get();
+        }
+    }
+    return NULL;
+
+}
+
 void Deck::ShowPanel(const Panel& rPanel)
 {
     if (mpVerticalScrollBar && mpVerticalScrollBar->IsVisible())
diff --git a/sfx2/source/sidebar/DeckDescriptor.cxx 
b/sfx2/source/sidebar/DeckDescriptor.cxx
index 2f431e5..fd4f640 100644
--- a/sfx2/source/sidebar/DeckDescriptor.cxx
+++ b/sfx2/source/sidebar/DeckDescriptor.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "DeckDescriptor.hxx"
+#include <sfx2/sidebar/DeckDescriptor.hxx>
 
 namespace sfx2 { namespace sidebar {
 
@@ -33,7 +33,8 @@ DeckDescriptor::DeckDescriptor()
       maContextList(),
       mbIsEnabled(true),
       mnOrderIndex(10000), // Default value as defined in Sidebar.xcs
-      mbExperimental(false)
+      mbExperimental(false),
+      mpDeck()
 {
 }
 
@@ -49,7 +50,8 @@ DeckDescriptor::DeckDescriptor (const DeckDescriptor& rOther)
       maContextList(rOther.maContextList),
       mbIsEnabled(rOther.mbIsEnabled),
       mnOrderIndex(rOther.mnOrderIndex),
-      mbExperimental(rOther.mbExperimental)
+      mbExperimental(rOther.mbExperimental),
+      mpDeck(rOther.mpDeck)
 {
 }
 
diff --git a/sfx2/source/sidebar/DeckLayouter.cxx 
b/sfx2/source/sidebar/DeckLayouter.cxx
index 3a2edfc..896edd8 100644
--- a/sfx2/source/sidebar/DeckLayouter.cxx
+++ b/sfx2/source/sidebar/DeckLayouter.cxx
@@ -17,11 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "DeckLayouter.hxx"
+#include <sfx2/sidebar/DeckLayouter.hxx>
 #include <sfx2/sidebar/Theme.hxx>
-#include "Panel.hxx"
-#include "PanelTitleBar.hxx"
-#include "Deck.hxx"
+#include <sfx2/sidebar/Panel.hxx>
+#include <sfx2/sidebar/PanelTitleBar.hxx>
+#include <sfx2/sidebar/Deck.hxx>
 
 #include <vcl/window.hxx>
 #include <vcl/scrbar.hxx>
diff --git a/sfx2/source/sidebar/DeckTitleBar.cxx 
b/sfx2/source/sidebar/DeckTitleBar.cxx
index 41c8fcf..a55fef6 100644
--- a/sfx2/source/sidebar/DeckTitleBar.cxx
+++ b/sfx2/source/sidebar/DeckTitleBar.cxx
@@ -17,10 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "DeckTitleBar.hxx"
+#include <sfx2/sidebar/DeckTitleBar.hxx>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sfxresid.hxx>
-#include "Sidebar.hrc"
+
+#include <sfx2/sidebar/Sidebar.hrc>
 
 #include <vcl/image.hxx>
 
diff --git a/sfx2/source/sidebar/DrawHelper.cxx 
b/sfx2/source/sidebar/DrawHelper.cxx
index 66ac2f7..7297fc2 100644
--- a/sfx2/source/sidebar/DrawHelper.cxx
+++ b/sfx2/source/sidebar/DrawHelper.cxx
@@ -17,8 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "DrawHelper.hxx"
-#include "Paint.hxx"
+#include <sfx2/sidebar/DrawHelper.hxx>
+#include <sfx2/sidebar/Paint.hxx>
 
 #include <vcl/lineinfo.hxx>
 
diff --git a/sfx2/source/sidebar/FocusManager.cxx 
b/sfx2/source/sidebar/FocusManager.cxx
index 16452fe..fbb326f 100644
--- a/sfx2/source/sidebar/FocusManager.cxx
+++ b/sfx2/source/sidebar/FocusManager.cxx
@@ -17,12 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "FocusManager.hxx"
-#include "Panel.hxx"
-#include "DeckTitleBar.hxx"
-#include "PanelTitleBar.hxx"
+#include <sfx2/sidebar/FocusManager.hxx>
+#include <sfx2/sidebar/Panel.hxx>
+#include <sfx2/sidebar/DeckTitleBar.hxx>
+#include <sfx2/sidebar/PanelTitleBar.hxx>
 #include <sfx2/sidebar/Tools.hxx>
-#include "TitleBar.hxx"
+#include <sfx2/sidebar/TitleBar.hxx>
 #include <vcl/button.hxx>
 #include <vcl/toolbox.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
diff --git a/sfx2/source/sidebar/MenuButton.cxx 
b/sfx2/source/sidebar/MenuButton.cxx
index 47e5971..428cdaf 100644
--- a/sfx2/source/sidebar/MenuButton.cxx
+++ b/sfx2/source/sidebar/MenuButton.cxx
@@ -17,10 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "MenuButton.hxx"
+#include <sfx2/sidebar/MenuButton.hxx>
 
-#include "DrawHelper.hxx"
-#include "Paint.hxx"
+#include <sfx2/sidebar/DrawHelper.hxx>
+#include <sfx2/sidebar/Paint.hxx>
 #include <sfx2/sidebar/Tools.hxx>
 #include <sfx2/sidebar/Theme.hxx>
 
diff --git a/sfx2/source/sidebar/Paint.cxx b/sfx2/source/sidebar/Paint.cxx
index caa371d..414d0b5 100644
--- a/sfx2/source/sidebar/Paint.cxx
+++ b/sfx2/source/sidebar/Paint.cxx
@@ -16,7 +16,7 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#include "Paint.hxx"
+#include <sfx2/sidebar/Paint.hxx>
 #include <sfx2/sidebar/Tools.hxx>
 #include <com/sun/star/awt/Gradient.hpp>
 
diff --git a/sfx2/source/sidebar/Panel.cxx b/sfx2/source/sidebar/Panel.cxx
index 7ea2689..e67d9d9 100644
--- a/sfx2/source/sidebar/Panel.cxx
+++ b/sfx2/source/sidebar/Panel.cxx
@@ -17,16 +17,19 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "Panel.hxx"
-#include "PanelTitleBar.hxx"
-#include "PanelDescriptor.hxx"
+#include <sfx2/sidebar/Panel.hxx>
+#include <sfx2/sidebar/PanelTitleBar.hxx>
+#include <sfx2/sidebar/PanelDescriptor.hxx>
 #include <sfx2/sidebar/Theme.hxx>
-#include "Paint.hxx"
-#include "ResourceManager.hxx"
+#include <sfx2/sidebar/Paint.hxx>
+#include <sfx2/sidebar/ResourceManager.hxx>
+
+#include <sfx2/sidebar/SidebarController.hxx>
+
 
 #ifdef DEBUG
 #include <sfx2/sidebar/Tools.hxx>
-#include "Deck.hxx"
+#include <sfx2/sidebar/Deck.hxx>
 #endif
 
 #include <tools/svborder.hxx>
@@ -47,7 +50,9 @@ Panel::Panel(const PanelDescriptor& rPanelDescriptor,
              vcl::Window* pParentWindow,
              const bool bIsInitiallyExpanded,
              const std::function<void()>& rDeckLayoutTrigger,
-             const std::function<Context()>& rContextAccess)
+             const std::function<Context()>& rContextAccess,
+             const css::uno::Reference<css::frame::XFrame>& rxFrame
+            )
     : Window(pParentWindow)
     , msPanelId(rPanelDescriptor.msId)
     , mpTitleBar(VclPtr<PanelTitleBar>::Create(rPanelDescriptor.msTitle, 
pParentWindow, this))
@@ -57,6 +62,7 @@ Panel::Panel(const PanelDescriptor& rPanelDescriptor,
     , mbIsExpanded(bIsInitiallyExpanded)
     , maDeckLayoutTrigger(rDeckLayoutTrigger)
     , maContextAccess(rContextAccess)
+    , mxFrame(rxFrame)
 {
 #ifdef DEBUG
     SetText(OUString("Panel"));
@@ -111,6 +117,8 @@ void Panel::SetUIElement (const Reference<ui::XUIElement>& 
rxElement)
 
 void Panel::SetExpanded (const bool bIsExpanded)
 {
+    SidebarController* pSidebarController= 
SidebarController::GetSidebarControllerForFrame(mxFrame);
+
     if (mbIsExpanded != bIsExpanded)
     {
         mbIsExpanded = bIsExpanded;
@@ -118,7 +126,7 @@ void Panel::SetExpanded (const bool bIsExpanded)
 
         if (maContextAccess)
         {
-            ResourceManager::Instance().StorePanelExpansionState(
+            pSidebarController->GetResourceManager()->StorePanelExpansionState(
                 msPanelId,
                 bIsExpanded,
                 maContextAccess());
diff --git a/sfx2/source/sidebar/PanelDescriptor.cxx 
b/sfx2/source/sidebar/PanelDescriptor.cxx
index c88f21b..4342617 100644
--- a/sfx2/source/sidebar/PanelDescriptor.cxx
+++ b/sfx2/source/sidebar/PanelDescriptor.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "PanelDescriptor.hxx"
+#include <sfx2/sidebar/PanelDescriptor.hxx>
 
 namespace sfx2 { namespace sidebar {
 
diff --git a/sfx2/source/sidebar/PanelTitleBar.cxx 
b/sfx2/source/sidebar/PanelTitleBar.cxx
index eda513b..fd6c06e 100644
--- a/sfx2/source/sidebar/PanelTitleBar.cxx
+++ b/sfx2/source/sidebar/PanelTitleBar.cxx
@@ -17,12 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "PanelTitleBar.hxx"
+#include <sfx2/sidebar/PanelTitleBar.hxx>
 #include <sfx2/sfxresid.hxx>
-#include "Sidebar.hrc"
 
-#include "Paint.hxx"
-#include "Panel.hxx"
+#include <sfx2/sidebar/Sidebar.hrc>
+
+#include <sfx2/sidebar/Paint.hxx>
+#include <sfx2/sidebar/Panel.hxx>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/ControllerFactory.hxx>
 #include <sfx2/sidebar/Tools.hxx>
diff --git a/sfx2/source/sidebar/ResourceManager.cxx 
b/sfx2/source/sidebar/ResourceManager.cxx
index 1535675..79b2432 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -17,7 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "ResourceManager.hxx"
+#include <sfx2/sidebar/ResourceManager.hxx>
 #include <sfx2/sidebar/Tools.hxx>
 
 #include <unotools/confignode.hxx>
@@ -114,6 +114,51 @@ void ResourceManager::SetIsDeckEnabled(const OUString& 
rsDeckId, const bool bIsE
     }
 }
 
+void ResourceManager::SetDeckToDescriptor(const OUString& rsDeckId, 
VclPtr<Deck> aDeck)
+{
+    DeckContainer::iterator iDeck;
+    for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck)
+    {
+        if (iDeck->mbExperimental && !maMiscOptions.IsExperimentalMode())
+            continue;
+        if (iDeck->msId.equals(rsDeckId))
+        {
+            iDeck->mpDeck = aDeck;
+            return;
+        }
+    }
+}
+
+void ResourceManager::SetDeckOrderIndex(const OUString& rsDeckId, const 
sal_Int32 orderIndex)
+{
+    DeckContainer::iterator iDeck;
+    for (iDeck = maDecks.begin(); iDeck != maDecks.end(); ++iDeck)
+    {
+        if (iDeck->mbExperimental && !maMiscOptions.IsExperimentalMode())
+            continue;
+        if (iDeck->msId.equals(rsDeckId))
+        {
+            iDeck->mnOrderIndex = orderIndex;
+            return;
+        }
+    }
+}
+
+void ResourceManager::SetPanelOrderIndex(const OUString& rsPanelId, const 
sal_Int32 orderIndex)
+{
+    PanelContainer::iterator iPanel;
+    for (iPanel = maPanels.begin(); iPanel != maPanels.end(); ++iPanel)
+    {
+        if (iPanel->mbExperimental && !maMiscOptions.IsExperimentalMode())
+            continue;
+        if (iPanel->msId.equals(rsPanelId))
+        {
+            iPanel->mnOrderIndex = orderIndex;
+            return;
+        }
+    }
+}
+
 const ResourceManager::DeckContextDescriptorContainer& 
ResourceManager::GetMatchingDecks (
                                                             
DeckContextDescriptorContainer& rDecks,
                                                             const Context& 
rContext,
@@ -569,6 +614,7 @@ bool ResourceManager::IsDeckEnabled (
     // Check if any panel that matches the current context can be
     // displayed.
     ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
+
     ResourceManager::Instance().GetMatchingPanels(aPanelContextDescriptors,
                                                   rContext, rsDeckId, rxFrame);
 
diff --git a/sfx2/source/sidebar/Sidebar.cxx b/sfx2/source/sidebar/Sidebar.cxx
index a740048..112ffc7 100644
--- a/sfx2/source/sidebar/Sidebar.cxx
+++ b/sfx2/source/sidebar/Sidebar.cxx
@@ -18,8 +18,8 @@
  */
 
 #include <sfx2/sidebar/Sidebar.hxx>
-#include "SidebarController.hxx"
-#include "ResourceManager.hxx"
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <sfx2/sidebar/ResourceManager.hxx>
 
 using namespace css;
 
@@ -30,7 +30,9 @@ void Sidebar::ShowPanel (
     const css::uno::Reference<frame::XFrame>& rxFrame)
 {
     SidebarController* pController = 
SidebarController::GetSidebarControllerForFrame(rxFrame);
-    const PanelDescriptor* pPanelDescriptor = 
ResourceManager::Instance().GetPanelDescriptor(rsPanelId);
+
+    const PanelDescriptor* pPanelDescriptor = 
pController->GetResourceManager()->GetPanelDescriptor(rsPanelId);
+
     if (pController!=NULL && pPanelDescriptor != NULL)
     {
         // This should be a lot more sophisticated:
diff --git a/sfx2/source/sidebar/Sidebar.src b/sfx2/source/sidebar/Sidebar.src
index a929dc5..534bebd 100644
--- a/sfx2/source/sidebar/Sidebar.src
+++ b/sfx2/source/sidebar/Sidebar.src
@@ -16,7 +16,7 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#include "Sidebar.hrc"
+#include <sfx2/sidebar/Sidebar.hrc>
 
 Resource RID_SIDEBAR_RESOURCE
 {
diff --git a/sfx2/source/sidebar/SidebarChildWindow.cxx 
b/sfx2/source/sidebar/SidebarChildWindow.cxx
index 0925bf8..a37d500 100644
--- a/sfx2/source/sidebar/SidebarChildWindow.cxx
+++ b/sfx2/source/sidebar/SidebarChildWindow.cxx
@@ -17,10 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "TabBar.hxx"
+#include <sfx2/sidebar/TabBar.hxx>
 #include <sfx2/bindings.hxx>
 #include <sfx2/sidebar/SidebarChildWindow.hxx>
-#include "SidebarDockingWindow.hxx"
+#include <sfx2/sidebar/SidebarDockingWindow.hxx>
 #include <sfx2/sfxsids.hrc>
 #include "helpid.hrc"
 #include <sfx2/dockwin.hxx>
diff --git a/sfx2/source/sidebar/SidebarController.cxx 
b/sfx2/source/sidebar/SidebarController.cxx
index 918b5ac..c81927e 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -16,18 +16,20 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#include "SidebarController.hxx"
-#include "Deck.hxx"
-#include "DeckTitleBar.hxx"
-#include "Panel.hxx"
-#include "PanelTitleBar.hxx"
-#include "SidebarResource.hxx"
-#include "TabBar.hxx"
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <sfx2/sidebar/Deck.hxx>
+#include <sfx2/sidebar/DeckTitleBar.hxx>
+#include <sfx2/sidebar/Panel.hxx>
+#include <sfx2/sidebar/PanelTitleBar.hxx>
+#include <sfx2/sidebar/SidebarResource.hxx>
+#include <sfx2/sidebar/TabBar.hxx>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/SidebarChildWindow.hxx>
 #include <sfx2/sidebar/Tools.hxx>
-#include "SidebarDockingWindow.hxx"
-#include "Context.hxx"
+#include <sfx2/sidebar/SidebarDockingWindow.hxx>
+#include <sfx2/sidebar/Context.hxx>
+#include <sfx2/sidebar/ContextList.hxx>
+
 
 #include <sfx2/sfxresid.hxx>
 #include <sfx2/sfxsids.hrc>
@@ -98,7 +100,8 @@ SidebarController::SidebarController (
               mpParentWindow,
               rxFrame,
               ::boost::bind(&SidebarController::OpenThenSwitchToDeck, this, 
_1),
-              ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2))),
+              ::boost::bind(&SidebarController::ShowPopupMenu, this, _1,_2),
+              this)),
       mxFrame(rxFrame),
       maCurrentContext(OUString(), OUString()),
       maRequestedContext(),
@@ -116,8 +119,12 @@ SidebarController::SidebarController (
       mxReadOnlyModeDispatch(),
       mbIsDocumentReadOnly(false),
       mpSplitWindow(NULL),
-      mnWidthOnSplitterButtonDown(0)
+      mnWidthOnSplitterButtonDown(0),
+      mpResourceManager()
 {
+    // Decks and panel collections for this sidebar
+    mpResourceManager = std::unique_ptr<ResourceManager>(new 
ResourceManager());
+
     // Listen for context change events.
     css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
         css::ui::ContextChangeEventMultiplexer::get(
@@ -173,12 +180,33 @@ void SAL_CALL SidebarController::disposing()
 {
     mpCloseIndicator.disposeAndClear();
 
+    maFocusManager.Clear();
+    mpTabBar.disposeAndClear();
+
+
+        // clear decks
+    ResourceManager::DeckContextDescriptorContainer aDecks;
+
+        mpResourceManager->GetMatchingDecks (
+            aDecks,
+            GetCurrentContext(),
+            IsDocumentReadOnly(),
+            mxFrame);
+
+        for (ResourceManager::DeckContextDescriptorContainer::const_iterator
+            iDeck(aDecks.begin()), iEnd(aDecks.end());
+            iDeck!=iEnd; ++iDeck)
+            {
+                const DeckDescriptor* deckDesc = 
mpResourceManager->GetDeckDescriptor(iDeck->msId);
+                VclPtr<Deck> aDeck = deckDesc->mpDeck;
+                if (aDeck)
+                    aDeck.disposeAndClear();
+            }
+
     SidebarControllerContainer::iterator iEntry 
(maSidebarControllerContainer.find(mxFrame));
     if (iEntry != maSidebarControllerContainer.end())
         maSidebarControllerContainer.erase(iEntry);
 
-    maFocusManager.Clear();
-
     css::uno::Reference<css::ui::XContextChangeEventMultiplexer> xMultiplexer (
         css::ui::ContextChangeEventMultiplexer::get(
             ::comphelper::getProcessComponentContext()));
@@ -200,19 +228,13 @@ void SAL_CALL SidebarController::disposing()
         mpParentWindow = NULL;
     }
 
-    if (mpCurrentDeck)
-    {
-        mpCurrentDeck.disposeAndClear();
-    }
-
-    mpTabBar.disposeAndClear();
-
     Theme::GetPropertySet()->removePropertyChangeListener(
         OUString(""),
         static_cast<css::beans::XPropertyChangeListener*>(this));
 
     maContextChangeUpdate.CancelRequest();
     maAsynchronousDeckSwitch.CancelRequest();
+
 }
 
 void SAL_CALL SidebarController::notifyContextChangeEvent (const 
css::ui::ContextChangeEventObject& rEvent)
@@ -397,7 +419,8 @@ void SidebarController::UpdateConfigurations()
 
         // Find the set of decks that could be displayed for the new context.
         ResourceManager::DeckContextDescriptorContainer aDecks;
-        ResourceManager::Instance().GetMatchingDecks (
+
+        mpResourceManager->GetMatchingDecks (
             aDecks,
             maCurrentContext,
             mbIsDocumentReadOnly,
@@ -439,8 +462,7 @@ void SidebarController::UpdateConfigurations()
         // with the deck.
         mpTabBar->HighlightDeck(sNewDeckId);
 
-        const DeckDescriptor* pDescriptor =
-            ResourceManager::Instance().GetDeckDescriptor(sNewDeckId);
+        const DeckDescriptor* pDescriptor = 
mpResourceManager->GetDeckDescriptor(sNewDeckId);
 
         if (pDescriptor)
         {
@@ -475,6 +497,11 @@ void SidebarController::OpenThenSwitchToDeck (
     mpTabBar->HighlightDeck(rsDeckId);
 }
 
+void SidebarController::SwitchToDefaultDeck()
+{
+    SwitchToDeck(gsDefaultDeckId);
+}
+
 void SidebarController::SwitchToDeck (
     const ::rtl::OUString& rsDeckId)
 {
@@ -482,27 +509,48 @@ void SidebarController::SwitchToDeck (
         || ! mbIsDeckOpen
         || mnRequestedForceFlags!=SwitchFlag_NoForce)
     {
-        const DeckDescriptor* pDeckDescriptor = 
ResourceManager::Instance().GetDeckDescriptor(rsDeckId);
+        const DeckDescriptor* pDeckDescriptor = 
mpResourceManager->GetDeckDescriptor(rsDeckId);
+
         if (pDeckDescriptor != NULL)
             SwitchToDeck(*pDeckDescriptor, maCurrentContext);
     }
 }
 
+
+void SidebarController::CreateDeck(const ::rtl::OUString& rDeckId)
+{
+    const DeckDescriptor* pDeckDescriptor = 
mpResourceManager->GetDeckDescriptor(rDeckId);
+
+    if (pDeckDescriptor->mpDeck.get()==nullptr)
+    {
+        VclPtr<Deck> aDeck = VclPtr<Deck>::Create(
+                *pDeckDescriptor,
+                mpParentWindow,
+                ::boost::bind(&SidebarController::RequestCloseDeck, this));
+
+        mpResourceManager->SetDeckToDescriptor(rDeckId, aDeck);
+
+    }
+
+}
+
+
 void SidebarController::SwitchToDeck (
     const DeckDescriptor& rDeckDescriptor,
     const Context& rContext)
 {
+
     maFocusManager.Clear();
 
     const bool bForceNewDeck 
((mnRequestedForceFlags&SwitchFlag_ForceNewDeck)!=0);
     const bool bForceNewPanels 
((mnRequestedForceFlags&SwitchFlag_ForceNewPanels)!=0);
+    mnRequestedForceFlags = SwitchFlag_NoForce;
 
     if ( ! msCurrentDeckId.equals(rDeckDescriptor.msId)
         || bForceNewDeck)
     {
-        // When the deck changes then destroy the deck and all panels
-        // and create everything new.
-        mpCurrentDeck.disposeAndClear();
+        if (mpCurrentDeck)
+            mpCurrentDeck->Hide();
 
         msCurrentDeckId = rDeckDescriptor.msId;
     }
@@ -510,7 +558,8 @@ void SidebarController::SwitchToDeck (
 
     // Determine the panels to display in the deck.
     ResourceManager::PanelContextDescriptorContainer aPanelContextDescriptors;
-    ResourceManager::Instance().GetMatchingPanels(
+
+    mpResourceManager->GetMatchingPanels(
         aPanelContextDescriptors,
         rContext,
         rDeckDescriptor.msId,
@@ -537,16 +586,10 @@ void SidebarController::SwitchToDeck (
     }
 
     // Provide a configuration and Deck object.
-    if ( ! mpCurrentDeck)
-    {
-        mpCurrentDeck.reset(
-            VclPtr<Deck>::Create(
-                rDeckDescriptor,
-                mpParentWindow,
-                ::boost::bind(&SidebarController::RequestCloseDeck, this)));
-        msCurrentDeckTitle = rDeckDescriptor.msTitle;
 
-    }
+    CreateDeck(rDeckDescriptor.msId);
+    mpCurrentDeck.reset(rDeckDescriptor.mpDeck);
+
     if ( ! mpCurrentDeck)
         return;
 
@@ -557,6 +600,7 @@ void SidebarController::SwitchToDeck (
         pDebugTitleBar->SetTitle(rDeckDescriptor.msTitle + " (" + 
maCurrentContext.msContext + ")");
 #endif
 
+
     // Update the panel list.
     const sal_Int32 nNewPanelCount (aPanelContextDescriptors.size());
     SharedPanelContainer aNewPanels;
@@ -608,6 +652,7 @@ void SidebarController::SwitchToDeck (
                 rContext);
             bHasPanelSetChanged = true;
         }
+
         if (aNewPanels[nWriteIndex] != nullptr)
         {
             // Depending on the context we have to change the command
@@ -627,6 +672,7 @@ void SidebarController::SwitchToDeck (
     // mpCurrentPanels - may miss stuff (?)
     aNewPanels.resize(nWriteIndex);
 
+
     SfxSplitWindow* pSplitWindow = GetSplitWindow();
     sal_Int32 nTabBarDefaultWidth = TabBar::GetDefaultWidth() * 
mpTabBar->GetDPIScaleFactor();
     WindowAlign eAlign = pSplitWindow ? pSplitWindow->GetAlign() : 
WINDOWALIGN_RIGHT;
@@ -640,6 +686,7 @@ void SidebarController::SwitchToDeck (
         nDeckX = 0;
     }
 
+
     // Activate the deck and the new set of panels.
     mpCurrentDeck->setPosSizePixel(
         nDeckX,
@@ -658,7 +705,8 @@ void SidebarController::SwitchToDeck (
     // Tell the focus manager about the new panels and tab bar
     // buttons.
     maFocusManager.SetDeckTitle(mpCurrentDeck->GetTitleBar());
-    maFocusManager.SetPanels(aNewPanels);
+    maFocusManager.SetPanels(mpCurrentDeck->GetPanels());
+
     mpTabBar->UpdateFocusManager(maFocusManager);
     UpdateTitleBarIcons();
 }
@@ -669,7 +717,8 @@ VclPtr<Panel> SidebarController::CreatePanel (
     const bool bIsInitiallyExpanded,
     const Context& rContext)
 {
-    const PanelDescriptor* pPanelDescriptor = 
ResourceManager::Instance().GetPanelDescriptor(rsPanelId);
+    const PanelDescriptor* pPanelDescriptor = 
mpResourceManager->GetPanelDescriptor(rsPanelId);
+
     if (pPanelDescriptor == NULL)
         return NULL;
 
@@ -679,7 +728,8 @@ VclPtr<Panel> SidebarController::CreatePanel (
         pParentWindow,
         bIsInitiallyExpanded,
         ::boost::bind(&Deck::RequestLayout, mpCurrentDeck.get()),
-        ::boost::bind(&SidebarController::GetCurrentContext, this));
+        ::boost::bind(&SidebarController::GetCurrentContext, this),
+        mxFrame);
 
     // Create the XUIElement.
     Reference<ui::XUIElement> xUIElement (CreateUIElement(
@@ -1110,7 +1160,8 @@ void SidebarController::UpdateTitleBarIcons()
         return;
 
     const bool bIsHighContrastModeActive (Theme::IsHighContrastMode());
-    const ResourceManager& rResourceManager (ResourceManager::Instance());
+
+    const ResourceManager& rResourceManager = *mpResourceManager;
 
     // Update the deck icon.
     const DeckDescriptor* pDeckDescriptor = 
rResourceManager.GetDeckDescriptor(mpCurrentDeck->GetId());
@@ -1151,6 +1202,28 @@ void SidebarController::ShowPanel (const Panel& rPanel)
         mpCurrentDeck->ShowPanel(rPanel);
 }
 
+ResourceManager::DeckContextDescriptorContainer 
SidebarController::GetMatchingDecks()
+{
+    ResourceManager::DeckContextDescriptorContainer aDecks;
+    mpResourceManager->GetMatchingDecks (aDecks,
+                                        GetCurrentContext(),
+                                        IsDocumentReadOnly(),
+                                        mxFrame);
+    return aDecks;
+}
+
+ResourceManager::PanelContextDescriptorContainer 
SidebarController::GetMatchingPanels(const ::rtl::OUString& rDeckId)
+{
+    ResourceManager::PanelContextDescriptorContainer aPanels;
+
+    mpResourceManager->GetMatchingPanels(aPanels,
+                                        GetCurrentContext(),
+                                        rDeckId,
+                                        mxFrame);
+    return aPanels;
+}
+
+
 } } // end of namespace sfx2::sidebar
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx 
b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 2cc2ae7..c32566e 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -16,9 +16,9 @@
  *   except in compliance with the License. You may obtain a copy of
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
-#include "SidebarDockingWindow.hxx"
+#include <sfx2/sidebar/SidebarDockingWindow.hxx>
 #include <sfx2/sidebar/SidebarChildWindow.hxx>
-#include "SidebarController.hxx"
+#include <sfx2/sidebar/SidebarController.hxx>
 
 #include <sfx2/bindings.hxx>
 #include <sfx2/dispatch.hxx>
diff --git a/sfx2/source/sidebar/TabBar.cxx b/sfx2/source/sidebar/TabBar.cxx
index bc2fe28..4733898 100644
--- a/sfx2/source/sidebar/TabBar.cxx
+++ b/sfx2/source/sidebar/TabBar.cxx
@@ -17,14 +17,16 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "TabBar.hxx"
-#include "TabItem.hxx"
+#include <sfx2/sidebar/TabBar.hxx>
+#include <sfx2/sidebar/TabItem.hxx>
 #include <sfx2/sidebar/ControlFactory.hxx>
-#include "DeckDescriptor.hxx"
-#include "Paint.hxx"
+#include <sfx2/sidebar/DeckDescriptor.hxx>
+#include <sfx2/sidebar/Paint.hxx>
 #include <sfx2/sidebar/Theme.hxx>
 #include <sfx2/sidebar/Tools.hxx>
-#include "FocusManager.hxx"
+#include <sfx2/sidebar/FocusManager.hxx>
+
+#include <sfx2/sidebar/SidebarController.hxx>
 
 #include <vcl/gradient.hxx>
 #include <vcl/image.hxx>
@@ -42,14 +44,18 @@ namespace sfx2 { namespace sidebar {
 TabBar::TabBar(vcl::Window* pParentWindow,
                const Reference<frame::XFrame>& rxFrame,
                const boost::function<void(const OUString&)>& 
rDeckActivationFunctor,
-               const PopupMenuProvider& rPopupMenuProvider)
+               const PopupMenuProvider& rPopupMenuProvider,
+               SidebarController* rParentSidebarController
+              )
     : Window(pParentWindow, WB_DIALOGCONTROL),
       mxFrame(rxFrame),
       mpMenuButton(ControlFactory::CreateMenuButton(this)),
       maItems(),
       maDeckActivationFunctor(rDeckActivationFunctor),
-      maPopupMenuProvider(rPopupMenuProvider)
+      maPopupMenuProvider(rPopupMenuProvider),
+      pParentSidebarController(rParentSidebarController)
 {
+
     
SetBackground(Theme::GetPaint(Theme::Paint_TabBarBackground).GetWallpaper());
 
     mpMenuButton->SetModeImage(Theme::GetImage(Theme::Image_TabBarMenu));
@@ -110,7 +116,7 @@ void TabBar::SetDecks(const 
ResourceManager::DeckContextDescriptorContainer& rDe
     for (ResourceManager::DeckContextDescriptorContainer::const_iterator
              iDeck(rDecks.begin()); iDeck != rDecks.end(); ++iDeck)
     {
-        const DeckDescriptor* pDescriptor = 
ResourceManager::Instance().GetDeckDescriptor(iDeck->msId);
+        const DeckDescriptor* pDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId);
         if (pDescriptor == NULL)
         {
             OSL_ASSERT(pDescriptor!=NULL);
@@ -149,7 +155,8 @@ void TabBar::UpdateButtonIcons()
         iItem!=iEnd;
         ++iItem)
     {
-        const DeckDescriptor* pDeckDescriptor = 
ResourceManager::Instance().GetDeckDescriptor(iItem->msDeckId);
+        const DeckDescriptor* pDeckDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId);
+
         if (pDeckDescriptor != NULL)
         {
             aImage = GetItemImage(*pDeckDescriptor);
@@ -293,7 +300,8 @@ void TabBar::ToggleHideFlag (const sal_Int32 nIndex)
     else
     {
         maItems[nIndex].mbIsHidden = ! maItems[nIndex].mbIsHidden;
-        ResourceManager::Instance().SetIsDeckEnabled(
+
+    pParentSidebarController->GetResourceManager()->SetIsDeckEnabled(
             maItems[nIndex].msDeckId,
             maItems[nIndex].mbIsHidden);
         Layout();
@@ -337,7 +345,8 @@ IMPL_LINK_NOARG(TabBar, OnToolboxClicked)
 
     for (ItemContainer::const_iterator iItem(maItems.begin()); iItem != 
maItems.end(); ++iItem)
     {
-        const DeckDescriptor* pDeckDescriptor = 
ResourceManager::Instance().GetDeckDescriptor(iItem->msDeckId);
+        const DeckDescriptor* pDeckDescriptor = 
pParentSidebarController->GetResourceManager()->GetDeckDescriptor(iItem->msDeckId);
+
         if (pDeckDescriptor != NULL)
         {
             DeckMenuData aData;
diff --git a/sfx2/source/sidebar/TabItem.cxx b/sfx2/source/sidebar/TabItem.cxx
index d053f32..8042528 100644
--- a/sfx2/source/sidebar/TabItem.cxx
+++ b/sfx2/source/sidebar/TabItem.cxx
@@ -17,10 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "TabItem.hxx"
+#include <sfx2/sidebar/TabItem.hxx>
 
-#include "DrawHelper.hxx"
-#include "Paint.hxx"
+#include <sfx2/sidebar/DrawHelper.hxx>
+#include <sfx2/sidebar/Paint.hxx>
 #include <sfx2/sidebar/Tools.hxx>
 
 #include <sfx2/sidebar/Theme.hxx>
diff --git a/sfx2/source/sidebar/Theme.cxx b/sfx2/source/sidebar/Theme.cxx
index df46912..50f0bb9 100644
--- a/sfx2/source/sidebar/Theme.cxx
+++ b/sfx2/source/sidebar/Theme.cxx
@@ -17,8 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 #include <sfx2/sidebar/Theme.hxx>
-#include "Paint.hxx"
-#include "SidebarResource.hxx"
+#include <sfx2/sidebar/Paint.hxx>
+#include <sfx2/sidebar/SidebarResource.hxx>
 #include <sfx2/sidebar/Tools.hxx>
 #include <sfx2/app.hxx>
 
diff --git a/sfx2/source/sidebar/TitleBar.cxx b/sfx2/source/sidebar/TitleBar.cxx
index 239cf04..eb362af 100644
--- a/sfx2/source/sidebar/TitleBar.cxx
+++ b/sfx2/source/sidebar/TitleBar.cxx
@@ -17,10 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "TitleBar.hxx"
-#include "Paint.hxx"
-#include "Accessible.hxx"
-#include "AccessibleTitleBar.hxx"
+#include <sfx2/sidebar/TitleBar.hxx>
+#include <sfx2/sidebar/Paint.hxx>
+#include <sfx2/sidebar/Accessible.hxx>
+#include <sfx2/sidebar/AccessibleTitleBar.hxx>
 
 #include <tools/svborder.hxx>
 #include <vcl/gradient.hxx>
diff --git a/sfx2/source/sidebar/UnoDeck.cxx b/sfx2/source/sidebar/UnoDeck.cxx
new file mode 100644
index 0000000..b90b266
--- /dev/null
+++ b/sfx2/source/sidebar/UnoDeck.cxx
@@ -0,0 +1,262 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <sfx2/sidebar/UnoDeck.hxx>
+
+#include <sfx2/sidebar/UnoPanels.hxx>
+
+#include <sfx2/sidebar/ResourceManager.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <sfx2/sidebar/DeckTitleBar.hxx>
+#include <sfx2/sidebar/Deck.hxx>
+
+#include <vcl/svapp.hxx>
+
+using namespace css;
+using namespace ::sfx2::sidebar;
+
+SfxUnoDeck::SfxUnoDeck(const uno::Reference<frame::XFrame>& rFrame, const 
OUString& deckId):
+xFrame(rFrame),
+mDeckId(deckId),
+mTitle(deckId)
+{
+
+}
+SidebarController* SfxUnoDeck::getSidebarController()
+{
+    return SidebarController::GetSidebarControllerForFrame(xFrame);
+}
+
+OUString SAL_CALL SfxUnoDeck::getId()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    return mDeckId;
+}
+
+OUString SAL_CALL  SfxUnoDeck::getTitle()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    SidebarController* pSidebarController = getSidebarController();
+    Deck* pDeck = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck;
+
+    if (!pDeck)
+    {
+        pSidebarController->CreateDeck(mDeckId);
+        pDeck = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck;
+    }
+
+    DeckTitleBar* pTitleBar = pDeck->GetTitleBar();
+    return pTitleBar->GetTitle();
+}
+
+void SAL_CALL SfxUnoDeck::setTitle( const OUString& newTitle )
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    SidebarController* pSidebarController = getSidebarController();
+    pSidebarController->CreateDeck(mDeckId);
+
+    Deck* pDeck = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck;
+
+    DeckTitleBar* pTitleBar = pDeck->GetTitleBar();
+    pTitleBar->SetTitle(newTitle);
+}
+
+sal_Bool SAL_CALL SfxUnoDeck::isActive()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    SidebarController* pSidebarController = getSidebarController();
+    return pSidebarController->IsDeckVisible(mDeckId);
+}
+
+
+void SAL_CALL SfxUnoDeck::activate( const sal_Bool bActivate )
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    SidebarController* pSidebarController = getSidebarController();
+
+    if (bActivate)
+        pSidebarController->SwitchToDeck(mDeckId);
+    else
+        pSidebarController->SwitchToDefaultDeck();
+}
+
+uno::Reference<ui::XPanels> SAL_CALL SfxUnoDeck::getPanels()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    uno::Reference<ui::XPanels> panels = new SfxUnoPanels(xFrame, mDeckId);
+    return panels;
+}
+
+sal_Int32 SAL_CALL SfxUnoDeck::getOrderIndex()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    SidebarController* pSidebarController = getSidebarController();
+
+    sal_Int32 index = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mnOrderIndex;
+    return index;
+}
+
+void SAL_CALL SfxUnoDeck::setOrderIndex( const sal_Int32 newOrderIndex )
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    SidebarController* pSidebarController = getSidebarController();
+
+    pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, 
newOrderIndex);
+
+    pSidebarController->NotifyResize();
+}
+
+void SAL_CALL SfxUnoDeck::moveFirst()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    SidebarController* pSidebarController = getSidebarController();
+
+    ResourceManager::DeckContextDescriptorContainer aDecks = 
pSidebarController->GetMatchingDecks();
+
+    sal_Int32 minIndex = GetMinOrderIndex(aDecks);
+    sal_Int32 curOrderIndex = getOrderIndex();
+
+    if (curOrderIndex != minIndex) // is deck already in place ?
+    {
+        minIndex -= 1;
+        pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, 
minIndex);
+        pSidebarController->NotifyResize();
+    }
+}
+
+void SAL_CALL SfxUnoDeck::moveLast()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    SidebarController* pSidebarController = getSidebarController();
+
+    ResourceManager::DeckContextDescriptorContainer aDecks = 
pSidebarController->GetMatchingDecks();
+
+    sal_Int32 maxIndex = GetMaxOrderIndex(aDecks);
+    sal_Int32 curOrderIndex = getOrderIndex();
+
+    if (curOrderIndex != maxIndex) // is deck already in place ?
+    {
+        maxIndex += 1;
+        pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, 
maxIndex);
+        pSidebarController->NotifyResize();
+    }
+}
+
+void SAL_CALL SfxUnoDeck::moveUp()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    SidebarController* pSidebarController = getSidebarController();
+
+    // Search for previous deck OrderIndex
+    ResourceManager::DeckContextDescriptorContainer aDecks = 
pSidebarController->GetMatchingDecks();
+
+    sal_Int32 curOrderIndex = getOrderIndex();
+    sal_Int32 previousIndex = GetMinOrderIndex(aDecks);
+
+    ResourceManager::DeckContextDescriptorContainer::const_iterator iDeck;
+    for (iDeck = aDecks.begin(); iDeck != aDecks.end(); ++iDeck)
+    {
+        sal_Int32 index = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId)->mnOrderIndex;
+        if( index < curOrderIndex && index > previousIndex)
+            previousIndex = index;
+    }
+
+    if (curOrderIndex != previousIndex) // is deck already in place ?
+    {
+        previousIndex -= 1;
+        pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, 
previousIndex);
+        pSidebarController->NotifyResize();
+    }
+}
+
+void SAL_CALL SfxUnoDeck::moveDown()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    SidebarController* pSidebarController = getSidebarController();
+
+    ResourceManager::DeckContextDescriptorContainer aDecks = 
pSidebarController->GetMatchingDecks();
+
+    // Search for next deck OrderIndex
+    sal_Int32 curOrderIndex = getOrderIndex();
+    sal_Int32 nextIndex = GetMaxOrderIndex(aDecks);
+
+
+    ResourceManager::DeckContextDescriptorContainer::const_iterator iDeck;
+    for (iDeck = aDecks.begin(); iDeck != aDecks.end(); ++iDeck)
+    {
+        sal_Int32 index = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId)->mnOrderIndex;
+        if( index > curOrderIndex && index < nextIndex)
+            nextIndex = index;
+    }
+
+    if (curOrderIndex != nextIndex) // is deck already in place ?
+    {
+        nextIndex += 1;
+        pSidebarController->GetResourceManager()->SetDeckOrderIndex(mDeckId, 
nextIndex);
+        pSidebarController->NotifyResize();
+    }
+}
+
+
+sal_Int32 
SfxUnoDeck::GetMinOrderIndex(ResourceManager::DeckContextDescriptorContainer 
aDecks)
+{
+    SidebarController* pSidebarController = getSidebarController();
+
+    ResourceManager::DeckContextDescriptorContainer::const_iterator iDeck;
+
+    iDeck = aDecks.begin();
+    sal_Int32 minIndex = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId)->mnOrderIndex;
+
+    for (iDeck = aDecks.begin(); iDeck != aDecks.end(); ++iDeck)
+    {
+        sal_Int32 index = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId)->mnOrderIndex;
+        if(minIndex > index)
+            minIndex = index;
+    }
+    return minIndex;
+}
+
+sal_Int32 
SfxUnoDeck::GetMaxOrderIndex(ResourceManager::DeckContextDescriptorContainer 
aDecks)
+{
+    SidebarController* pSidebarController = getSidebarController();
+
+    ResourceManager::DeckContextDescriptorContainer::const_iterator iDeck;
+
+    iDeck = aDecks.begin();
+    sal_Int32 maxIndex = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId)->mnOrderIndex;
+
+    for (iDeck = aDecks.begin(); iDeck != aDecks.end(); ++iDeck)
+    {
+        sal_Int32 index = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(iDeck->msId)->mnOrderIndex;
+        if(maxIndex < index)
+            maxIndex = index;
+    }
+    return maxIndex;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/sidebar/UnoDecks.cxx b/sfx2/source/sidebar/UnoDecks.cxx
new file mode 100644
index 0000000..e088733
--- /dev/null
+++ b/sfx2/source/sidebar/UnoDecks.cxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <sfx2/sidebar/UnoDecks.hxx>
+#include <sfx2/sidebar/UnoDeck.hxx>
+
+#include <sfx2/sidebar/ResourceManager.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
+
+#include <vcl/svapp.hxx>
+
+using namespace css;
+using namespace ::sfx2::sidebar;
+
+SfxUnoDecks::SfxUnoDecks(const uno::Reference<frame::XFrame>& rFrame):
+xFrame(rFrame)
+{
+}
+
+SidebarController* SfxUnoDecks::getSidebarController()
+{
+    return SidebarController::GetSidebarControllerForFrame(xFrame);
+}
+
+// XNameAccess
+
+uno::Any SAL_CALL SfxUnoDecks::getByName( const OUString& aName )
+                                throw(container::NoSuchElementException,
+                                    lang::WrappedTargetException,
+                                    uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    uno::Any aRet;
+
+    if (hasByName(aName))
+    {
+        uno::Reference<ui::XDeck> xDeck = new SfxUnoDeck(xFrame, aName);
+        aRet <<= xDeck;
+    }
+    else
+        throw container::NoSuchElementException();
+
+    return aRet;
+}
+
+
+uno::Sequence< OUString > SAL_CALL SfxUnoDecks::getElementNames()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    SidebarController* pSidebarController = getSidebarController();
+
+    ResourceManager::DeckContextDescriptorContainer aDecks;
+    css::uno::Sequence< OUString > deckList(aDecks.size());
+
+    if (pSidebarController)
+    {
+        pSidebarController->GetResourceManager()->GetMatchingDecks (
+            aDecks,
+            pSidebarController->GetCurrentContext(),
+            pSidebarController->IsDocumentReadOnly(),
+            xFrame);
+
+        deckList.realloc(aDecks.size());
+
+        long n = 0;
+
+        for (ResourceManager::DeckContextDescriptorContainer::const_iterator
+            iDeck(aDecks.begin()), iEnd(aDecks.end());
+            iDeck!=iEnd; ++iDeck)
+            {
+                deckList[n] = iDeck->msId;
+                n++;
+            }
+    }
+
+    return deckList;
+
+}
+
+sal_Bool SAL_CALL SfxUnoDecks::hasByName( const OUString& aName )
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    SidebarController* pSidebarController = getSidebarController();
+
+    sal_Bool bFound = false;
+
+    if (pSidebarController)
+    {
+        ResourceManager::DeckContextDescriptorContainer aDecks;
+
+        pSidebarController->GetResourceManager()->GetMatchingDecks (
+            aDecks,
+            pSidebarController->GetCurrentContext(),
+            pSidebarController->IsDocumentReadOnly(),
+            xFrame);
+
+        for (ResourceManager::DeckContextDescriptorContainer::const_iterator
+            iDeck(aDecks.begin()), iEnd(aDecks.end());
+            iDeck!=iEnd && !bFound; ++iDeck)
+            {
+                if (iDeck->msId == aName)
+                    bFound = true;
+            }
+    }
+
+    return bFound;
+
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL SfxUnoDecks::getCount() throw(uno::RuntimeException, 
std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    uno::Sequence< OUString > decks = getElementNames();
+    return decks.getLength();
+}
+
+uno::Any SAL_CALL SfxUnoDecks::getByIndex( sal_Int32 Index )
+                                throw(lang::IndexOutOfBoundsException,
+                                    lang::WrappedTargetException,
+                                    uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    uno::Any aRet;
+
+    uno::Sequence< OUString > decks = getElementNames();
+
+    if (Index > decks.getLength()-1 || Index < 0)
+        throw lang::IndexOutOfBoundsException();
+
+    uno::Reference<ui::XDeck> xDeck = new SfxUnoDeck(xFrame, decks[Index]);
+    aRet <<= xDeck;
+    return aRet;
+
+}
+
+// XElementAccess
+uno::Type SAL_CALL SfxUnoDecks::getElementType()
+                                throw(::com::sun::star::uno::RuntimeException, 
std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    return uno::Type();
+}
+
+sal_Bool SAL_CALL SfxUnoDecks::hasElements() 
throw(::com::sun::star::uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    uno::Sequence< OUString > decks = getElementNames();
+    return decks.hasElements();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/sfx2/source/sidebar/UnoPanel.cxx b/sfx2/source/sidebar/UnoPanel.cxx
new file mode 100644
index 0000000..e52bb27
--- /dev/null
+++ b/sfx2/source/sidebar/UnoPanel.cxx
@@ -0,0 +1,271 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <sfx2/sidebar/UnoPanel.hxx>
+
+#include <sfx2/sidebar/ResourceManager.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
+
+#include <sfx2/sidebar/PanelTitleBar.hxx>
+#include <sfx2/sidebar/Panel.hxx>
+#include <sfx2/sidebar/Deck.hxx>
+
+#include <vcl/svapp.hxx>
+
+using namespace css;
+using namespace ::sfx2::sidebar;
+
+SfxUnoPanel::SfxUnoPanel(const uno::Reference<frame::XFrame>& rFrame, const 
OUString& panelId, const OUString& deckId):
+xFrame(rFrame),
+mPanelId(panelId),
+mDeckId(deckId),
+mpDeck(),
+mpPanel()
+{
+    SidebarController* pSidebarController = getSidebarController();
+
+    mpDeck = 
pSidebarController->GetResourceManager()->GetDeckDescriptor(mDeckId)->mpDeck;
+    mpPanel = mpDeck->GetPanel(mPanelId);
+}
+SidebarController* SfxUnoPanel::getSidebarController()
+{
+    return SidebarController::GetSidebarControllerForFrame(xFrame);
+}
+
+OUString SAL_CALL SfxUnoPanel::getId()
+                               throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    return mPanelId;
+}
+
+OUString SAL_CALL  SfxUnoPanel::getTitle()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    PanelTitleBar* pTitleBar = mpPanel->GetTitleBar();
+    return pTitleBar->GetTitle();
+}
+
+void SAL_CALL SfxUnoPanel::setTitle( const OUString& newTitle )
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    PanelTitleBar* pTitleBar = mpPanel->GetTitleBar();
+    pTitleBar->SetTitle(newTitle);
+}
+
+sal_Bool SAL_CALL SfxUnoPanel::isExpanded()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    return mpPanel->IsExpanded();
+}
+
+
+void SAL_CALL SfxUnoPanel::expand( const sal_Bool bCollapseOther )
+                                throw(uno::RuntimeException, std::exception)
+{
+
+    SolarMutexGuard aGuard;
+
+    mpPanel->SetExpanded(true);
+
+    if (bCollapseOther)
+    {
+     Panel* aPanel;
+
+     SharedPanelContainer maPanels = mpDeck->GetPanels();
+     for ( SharedPanelContainer::iterator iPanel(maPanels.begin()), 
iEnd(maPanels.end());
+        iPanel!=iEnd; ++iPanel)
+        {
+            aPanel = *iPanel;
+
+            if (! aPanel->HasIdPredicate(mPanelId))
+                aPanel->SetExpanded(false);
+        }
+    }
+
+}
+
+void SAL_CALL SfxUnoPanel::collapse()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    mpPanel->SetExpanded(false);
+}
+
+uno::Reference<awt::XWindow> SAL_CALL SfxUnoPanel::getDialog()
+                                throw(uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+
+    return mpPanel->GetElementWindow();
+}
+
+
+sal_Int32 SAL_CALL SfxUnoPanel::getOrderIndex()
+                                throw(uno::RuntimeException, std::exception)
+{

... etc. - the rest is truncated
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to