[PATCH] fdo#35973 [EasyHack] Remember the state of the sidebar pane in Impress

Rob Snelders programming at ertai.nl
Thu May 24 12:59:57 PDT 2012


---
 .../drawing/framework/XConfigurationController.idl |    6 +
 .../data/org/openoffice/Office/Impress.xcu         |   22 +
 .../schema/org/openoffice/Office/Impress.xcs       |   44 ++-
 .../configuration/ConfigurationController.cxx      |   10 +-
 sd/source/ui/framework/module/ResourceManager.cxx  |   24 +-
 sd/source/ui/framework/module/ResourceManager.hxx  |    3 +
 .../ui/framework/module/SlideSorterModule.cxx      |   31 +-
 .../ui/framework/module/SlideSorterModule.hxx      |    2 +-
 .../ui/inc/framework/ConfigurationController.hxx   |    3 +
 svtools/Library_svt.mk                             |    1 +
 svtools/Package_inc.mk                             |    1 +
 svtools/inc/svtools/slidesorterbaropt.hxx          |  134 +++++
 svtools/source/config/slidesorterbaropt.cxx        |  580 ++++++++++++++++++++
 13 files changed, 846 insertions(+), 15 deletions(-)
 create mode 100644 svtools/inc/svtools/slidesorterbaropt.hxx
 create mode 100644 svtools/source/config/slidesorterbaropt.cxx

diff --git a/offapi/com/sun/star/drawing/framework/XConfigurationController.idl b/offapi/com/sun/star/drawing/framework/XConfigurationController.idl
index 4c0fd46..1e7cdb2 100644
--- a/offapi/com/sun/star/drawing/framework/XConfigurationController.idl
+++ b/offapi/com/sun/star/drawing/framework/XConfigurationController.idl
@@ -154,6 +154,12 @@ interface XConfigurationController
     interface XConfigurationControllerBroadcaster;
     interface XResourceFactoryManager;
 
+    /** Check if the ConfigurationController is disposing
+        @return
+            When the ConfigurationController is disposing then true else false
+    */
+    boolean IsDisposing ();
+
     /** Request the activation of a resource.
         <p>The request is processed asynchronously.  Notifications about
         configuration changes are sent after this call returns.</p>
diff --git a/officecfg/registry/data/org/openoffice/Office/Impress.xcu b/officecfg/registry/data/org/openoffice/Office/Impress.xcu
index 6101cef..f894ccb 100644
--- a/officecfg/registry/data/org/openoffice/Office/Impress.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Impress.xcu
@@ -28,6 +28,28 @@
 <!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
 <oor:component-data oor:name="Impress" oor:package="org.openoffice.Office" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <node oor:name="MultiPaneGUI">
+    <node oor:name="SlideSorterBar">
+      <node oor:name="Visible">
+        <prop oor:name="ImpressView">
+          <value>true</value>
+        </prop>
+        <prop oor:name="OutlineView">
+          <value>true</value>
+        </prop>
+        <prop oor:name="NotesView">
+          <value>true</value>
+        </prop>
+        <prop oor:name="HandoutView">
+          <value>false</value>
+        </prop>
+        <prop oor:name="SlideSorterView">
+          <value>false</value>
+        </prop>
+        <prop oor:name="DrawView">
+          <value>true</value>
+        </prop>
+     </node>
+    </node>
     <node oor:name="Framework">
       <node oor:name="ResourceFactories">
         <node oor:name="F0" oor:op="replace">
diff --git a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs
index 094cee5..8350429 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Impress.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Impress.xcs
@@ -1402,11 +1402,53 @@
           </info>
         </set>
       </group>
-      <group oor:name="SlideSorter">
+      <group oor:name="SlideSorterBar">
         <info>
           <desc>Values related to the slide sorter.</desc>
           <label>Slide Sorter Options</label>
         </info>
+        <group oor:name="Visible">
+          <info>
+            <desc>Options that control the visibility of the slide sorter.</desc>
+            <label>Slide Sorter Visibility</label>
+          </info>
+          <prop oor:name="ImpressView" oor:type="xs:boolean">
+            <info>
+              <desc>Visibility of the Slide Sorter in the Impress view.</desc>
+              <label>Slide Sorter Visibility ImpressView</label>
+            </info>
+          </prop>
+          <prop oor:name="OutlineView" oor:type="xs:boolean">
+            <info>
+              <desc>Visibility of the Slide Sorter in the Outline view.</desc>
+              <label>Slide Sorter Visibility OutlineView</label>
+            </info>
+          </prop>
+          <prop oor:name="NotesView" oor:type="xs:boolean">
+            <info>
+              <desc>Visibility of the Slide Sorter in the Notes view.</desc>
+              <label>Slide Sorter Visibility NotesView</label>
+            </info>
+          </prop>
+          <prop oor:name="HandoutView" oor:type="xs:boolean">
+            <info>
+              <desc>Visibility of the Slide Sorter in the HandOut view.</desc>
+              <label>Slide Sorter Visibility HandOutView</label>
+            </info>
+          </prop>
+          <prop oor:name="SlideSorterView" oor:type="xs:boolean">
+            <info>
+              <desc>Visibility of the Slide Sorter in the SlideSorter view.</desc>
+              <label>Slide Sorter Visibility SlideSorterView</label>
+            </info>
+          </prop>
+          <prop oor:name="DrawView" oor:type="xs:boolean">
+            <info>
+              <desc>Visibility of the Slide Sorter in the Draw view.</desc>
+              <label>Slide Sorter Visibility DrawView</label>
+            </info>
+          </prop>
+        </group>
         <group oor:name="PreviewCache">
           <info>
             <desc>Values for tuning the preview cache of the slide sorter.</desc>
diff --git a/sd/source/ui/framework/configuration/ConfigurationController.cxx b/sd/source/ui/framework/configuration/ConfigurationController.cxx
index 0f49bae..6eb4299 100644
--- a/sd/source/ui/framework/configuration/ConfigurationController.cxx
+++ b/sd/source/ui/framework/configuration/ConfigurationController.cxx
@@ -155,7 +155,8 @@ ConfigurationController::Lock::~Lock (void)
 ConfigurationController::ConfigurationController (void) throw()
     : ConfigurationControllerInterfaceBase(MutexOwner::maMutex),
       mpImplementation(),
-      mbIsDisposed(false)
+      mbIsDisposed(false),
+      mbIsDisposing(false)
 {
 }
 
@@ -166,7 +167,10 @@ ConfigurationController::~ConfigurationController (void) throw()
 {
 }
 
-
+sal_Bool ConfigurationController::IsDisposing (void) throw (com::sun::star::uno::RuntimeException)
+{
+    return mbIsDisposing;
+}
 
 
 void SAL_CALL ConfigurationController::disposing (void)
@@ -174,6 +178,7 @@ void SAL_CALL ConfigurationController::disposing (void)
     if (mpImplementation.get() == NULL)
         return;
 
+    mbIsDisposing = true;
     SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ConfigurationController::disposing");
     SAL_INFO("sd.fwk", OSL_THIS_FUNC << ":     requesting empty configuration");
     // To destroy all resources an empty configuration is requested and then,
@@ -186,6 +191,7 @@ void SAL_CALL ConfigurationController::disposing (void)
     // Now that all resources have been deactivated, mark the controller as
     // disposed.
     mbIsDisposed = true;
+    mbIsDisposing = false;
 
     // Release the listeners.
     lang::EventObject aEvent;
diff --git a/sd/source/ui/framework/module/ResourceManager.cxx b/sd/source/ui/framework/module/ResourceManager.cxx
index 4787b05..e662af3 100644
--- a/sd/source/ui/framework/module/ResourceManager.cxx
+++ b/sd/source/ui/framework/module/ResourceManager.cxx
@@ -75,7 +75,8 @@ ResourceManager::ResourceManager (
       mxMainViewAnchorId(FrameworkHelper::Instance(rxController)->CreateResourceId(
           FrameworkHelper::msCenterPaneURL)),
       msCurrentMainViewURL(),
-      mbIsEnabled(true)
+      mbIsEnabled(true),
+      mbConfigurationControllerIsDisposing(false)
 {
     Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY);
     if (xControllerManager.is())
@@ -112,8 +113,15 @@ void ResourceManager::AddActiveMainView (
     mpActiveMainViewContainer->insert(rsMainViewURL);
 }
 
+sal_Bool ResourceManager::IsResourceActive (
+    const OUString& rsMainViewURL)
+{
+    return (mpActiveMainViewContainer->find(rsMainViewURL) != mpActiveMainViewContainer->end());
+}
 
-
+void ResourceManager::SaveResourceState (void)
+{
+}
 
 void SAL_CALL ResourceManager::disposing (void)
 {
@@ -153,6 +161,8 @@ void SAL_CALL ResourceManager::notifyConfigurationChange (
 
     sal_Int32 nEventType = 0;
     rEvent.UserData >>= nEventType;
+    if (!mxConfigurationController->IsDisposing())
+        mbConfigurationControllerIsDisposing = false;
     switch (nEventType)
     {
         case ResourceActivationRequestEvent:
@@ -185,6 +195,11 @@ void SAL_CALL ResourceManager::notifyConfigurationChange (
         case ResourceDeactivationRequestEvent:
             if (rEvent.ResourceId->compareTo(mxMainViewAnchorId) == 0)
             {
+                if (mxConfigurationController->IsDisposing() && !mbConfigurationControllerIsDisposing)
+                {
+                    mbConfigurationControllerIsDisposing = true;
+                    SaveResourceState();
+                }
                 HandleMainViewSwitch(
                     OUString(),
                     rEvent.Configuration,
@@ -192,6 +207,11 @@ void SAL_CALL ResourceManager::notifyConfigurationChange (
             }
             else if (rEvent.ResourceId->compareTo(mxResourceId) == 0)
             {
+                if (mxConfigurationController->IsDisposing() && !mbConfigurationControllerIsDisposing)
+                {
+                    mbConfigurationControllerIsDisposing = true;
+                    SaveResourceState();
+                }
                 // The resource managed by this ResourceManager has been
                 // explicitly been requested to be hidden (maybe by us).
                 // Remember this setting.
diff --git a/sd/source/ui/framework/module/ResourceManager.hxx b/sd/source/ui/framework/module/ResourceManager.hxx
index dc3215a..45da97e 100644
--- a/sd/source/ui/framework/module/ResourceManager.hxx
+++ b/sd/source/ui/framework/module/ResourceManager.hxx
@@ -71,6 +71,8 @@ public:
         activate the resource managed by the called object.
     */
     void AddActiveMainView (const ::rtl::OUString& rsMainViewURL);
+    sal_Bool IsResourceActive (const ::rtl::OUString& rsMainViewURL);
+    virtual void SaveResourceState (void);
 
     virtual void SAL_CALL disposing (void);
 
@@ -116,6 +118,7 @@ private:
 
     ::rtl::OUString msCurrentMainViewURL;
     bool mbIsEnabled;
+    bool mbConfigurationControllerIsDisposing;
 
     void HandleMainViewSwitch (
         const ::rtl::OUString& rsViewURL,
diff --git a/sd/source/ui/framework/module/SlideSorterModule.cxx b/sd/source/ui/framework/module/SlideSorterModule.cxx
index 2af2b42..c7d61b8d 100644
--- a/sd/source/ui/framework/module/SlideSorterModule.cxx
+++ b/sd/source/ui/framework/module/SlideSorterModule.cxx
@@ -35,6 +35,7 @@
 
 #include "strings.hrc"
 #include "sdresid.hxx"
+#include "svtools/slidesorterbaropt.hxx"
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
@@ -63,11 +64,18 @@ SlideSorterModule::SlideSorterModule (
     {
         UpdateViewTabBar(NULL);
 
-        AddActiveMainView(FrameworkHelper::msImpressViewURL);
-        AddActiveMainView(FrameworkHelper::msOutlineViewURL);
-        AddActiveMainView(FrameworkHelper::msNotesViewURL);
-
-        AddActiveMainView(FrameworkHelper::msDrawViewURL);
+        if (SvtSlideSorterBarOptions().GetVisibleImpressView()==sal_True)
+            AddActiveMainView(FrameworkHelper::msImpressViewURL);
+        if (SvtSlideSorterBarOptions().GetVisibleOutlineView()==sal_True)
+            AddActiveMainView(FrameworkHelper::msOutlineViewURL);
+        if (SvtSlideSorterBarOptions().GetVisibleNotesView()==sal_True)
+            AddActiveMainView(FrameworkHelper::msNotesViewURL);
+        if (SvtSlideSorterBarOptions().GetVisibleHandoutView()==sal_True)
+            AddActiveMainView(FrameworkHelper::msHandoutViewURL);
+        if (SvtSlideSorterBarOptions().GetVisibleSlideSorterView()==sal_True)
+            AddActiveMainView(FrameworkHelper::msSlideSorterURL);
+        if (SvtSlideSorterBarOptions().GetVisibleDrawView()==sal_True)
+            AddActiveMainView(FrameworkHelper::msDrawViewURL);
 
         mxConfigurationController->addConfigurationChangeListener(
             this,
@@ -83,7 +91,15 @@ SlideSorterModule::~SlideSorterModule (void)
 {
 }
 
-
+void SlideSorterModule::SaveResourceState (void)
+{
+    SvtSlideSorterBarOptions().SetVisibleImpressView(IsResourceActive(FrameworkHelper::msImpressViewURL));
+    SvtSlideSorterBarOptions().SetVisibleOutlineView(IsResourceActive(FrameworkHelper::msOutlineViewURL));
+    SvtSlideSorterBarOptions().SetVisibleNotesView(IsResourceActive(FrameworkHelper::msNotesViewURL));
+    SvtSlideSorterBarOptions().SetVisibleHandoutView(IsResourceActive(FrameworkHelper::msHandoutViewURL));
+    SvtSlideSorterBarOptions().SetVisibleSlideSorterView(IsResourceActive(FrameworkHelper::msSlideSorterURL));
+    SvtSlideSorterBarOptions().SetVisibleDrawView(IsResourceActive(FrameworkHelper::msDrawViewURL));
+}
 
 
 void SAL_CALL SlideSorterModule::notifyConfigurationChange (
@@ -115,9 +131,6 @@ void SAL_CALL SlideSorterModule::notifyConfigurationChange (
     }
 }
 
-
-
-
 void SlideSorterModule::UpdateViewTabBar (const Reference<XTabBar>& rxTabBar)
 {
     if ( ! mxControllerManager.is())
diff --git a/sd/source/ui/framework/module/SlideSorterModule.hxx b/sd/source/ui/framework/module/SlideSorterModule.hxx
index a89b359..30940c9 100644
--- a/sd/source/ui/framework/module/SlideSorterModule.hxx
+++ b/sd/source/ui/framework/module/SlideSorterModule.hxx
@@ -50,7 +50,7 @@ public:
         const ::rtl::OUString& rsLeftPaneURL);
     virtual ~SlideSorterModule (void);
 
-
+    virtual void SaveResourceState (void);
     // XConfigurationChangeListener
 
     virtual void SAL_CALL notifyConfigurationChange (
diff --git a/sd/source/ui/inc/framework/ConfigurationController.hxx b/sd/source/ui/inc/framework/ConfigurationController.hxx
index ce671cf..2a82443 100644
--- a/sd/source/ui/inc/framework/ConfigurationController.hxx
+++ b/sd/source/ui/inc/framework/ConfigurationController.hxx
@@ -85,6 +85,8 @@ public:
     ConfigurationController (void) throw();
     virtual ~ConfigurationController (void) throw();
 
+    sal_Bool IsDisposing (void) throw (com::sun::star::uno::RuntimeException);
+
     virtual void SAL_CALL disposing (void);
 
     void ProcessEvent (void);
@@ -218,6 +220,7 @@ private:
     class Implementation;
     ::boost::scoped_ptr<Implementation> mpImplementation;
     bool mbIsDisposed;
+    bool mbIsDisposing;
 
     /** When the called object has already been disposed this method throws
         an exception and does not return.
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk
index 7186bba..958f269 100644
--- a/svtools/Library_svt.mk
+++ b/svtools/Library_svt.mk
@@ -92,6 +92,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
     svtools/source/config/itemholder2 \
     svtools/source/config/menuoptions \
     svtools/source/config/miscopt \
+    svtools/source/config/slidesorterbaropt \
     svtools/source/config/optionsdrawinglayer \
     svtools/source/config/printoptions \
     svtools/source/contnr/DocumentInfoPreview \
diff --git a/svtools/Package_inc.mk b/svtools/Package_inc.mk
index f112021..1a56402 100644
--- a/svtools/Package_inc.mk
+++ b/svtools/Package_inc.mk
@@ -109,6 +109,7 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/langtab.hxx,svtools/la
 $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/localresaccess.hxx,svtools/localresaccess.hxx))
 $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/menuoptions.hxx,svtools/menuoptions.hxx))
 $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/miscopt.hxx,svtools/miscopt.hxx))
+$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/slidesorterbaropt.hxx,svtools/slidesorterbaropt.hxx))
 $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/optionsdrawinglayer.hxx,svtools/optionsdrawinglayer.hxx))
 $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/parhtml.hxx,svtools/parhtml.hxx))
 $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/parrtf.hxx,svtools/parrtf.hxx))
diff --git a/svtools/inc/svtools/slidesorterbaropt.hxx b/svtools/inc/svtools/slidesorterbaropt.hxx
new file mode 100644
index 0000000..3fd0750
--- /dev/null
+++ b/svtools/inc/svtools/slidesorterbaropt.hxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INCLUDED_SVTOOLS_SLIDESORTERBAROPT_HXX
+#define INCLUDED_SVTOOLS_SLIDESORTERBAROPT_HXX
+
+#include "svtools/svtdllapi.h"
+#include <sal/types.h>
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <rtl/ustring.hxx>
+#include <unotools/options.hxx>
+
+/*-************************************************************************************************************//**
+    @short          forward declaration to our private date container implementation
+    @descr          We use these class as internal member to support small memory requirements.
+                    You can create the container if it is neccessary. The class which use these mechanism
+                    is faster and smaller then a complete implementation!
+*//*-*************************************************************************************************************/
+
+class SvtSlideSorterBarOptions_Impl;
+class Link;
+
+/*-************************************************************************************************************//**
+    @short          collect informations about sidebar group
+    @descr          -
+
+    @implements     -
+    @base           -
+
+    @ATTENTION      This class is partially threadsafe.
+
+    @devstatus      ready to use
+*//*-*************************************************************************************************************/
+
+class SVT_DLLPUBLIC SvtSlideSorterBarOptions: public utl::detail::Options
+{
+    public:
+        /*-****************************************************************************************************//**
+            @short      standard constructor and destructor
+            @descr      This will initialize an instance with default values.
+                        We implement these class with a refcount mechanism! Every instance of this class increase it
+                        at create and decrease it at delete time - but all instances use the same data container!
+                        He is implemented as a static member ...
+
+            @seealso    member m_nRefCount
+            @seealso    member m_pDataContainer
+
+            @param      -
+            @return     -
+
+            @onerror    -
+        *//*-*****************************************************************************************************/
+
+         SvtSlideSorterBarOptions();
+        virtual ~SvtSlideSorterBarOptions();
+
+        void AddListenerLink( const Link& rLink );
+        void RemoveListenerLink( const Link& rLink );
+
+        sal_Bool    GetVisibleImpressView() const;
+        void        SetVisibleImpressView( sal_Bool bVisible );
+        sal_Bool    GetVisibleOutlineView() const;
+        void        SetVisibleOutlineView( sal_Bool bVisible );
+        sal_Bool    GetVisibleNotesView() const;
+        void        SetVisibleNotesView( sal_Bool bVisible );
+        sal_Bool    GetVisibleHandoutView() const;
+        void        SetVisibleHandoutView( sal_Bool bVisible );
+        sal_Bool    GetVisibleSlideSorterView() const;
+        void        SetVisibleSlideSorterView( sal_Bool bVisible );
+        sal_Bool    GetVisibleDrawView() const;
+        void        SetVisibleDrawView( sal_Bool bVisible );
+
+
+    private:
+
+        /*-****************************************************************************************************//**
+            @short      return a reference to a static mutex
+            @descr      These class is partially threadsafe (for de-/initialization only).
+                        All access methods are'nt safe!
+                        We create a static mutex only for one ime and use at different times.
+
+            @seealso    -
+
+            @param      -
+            @return     A reference to a static mutex member.
+
+            @onerror    -
+        *//*-*****************************************************************************************************/
+
+        SVT_DLLPRIVATE static ::osl::Mutex& GetInitMutex();
+
+    private:
+
+        /*Attention
+
+            Don't initialize these static member in these header!
+            a) Double dfined symbols will be detected ...
+            b) and unresolved externals exist at linking time.
+            Do it in your source only.
+         */
+
+        static SvtSlideSorterBarOptions_Impl* m_pDataContainer    ;   /// impl. data container as dynamic pointer for smaller memory requirements!
+        static sal_Int32                      m_nRefCount         ;   /// internal ref count mechanism
+
+};      // class SvtSlideSorterBarOptions
+
+#endif  // #ifndef INCLUDED_SVTOOLS_SLIDESORTERBAROPT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/config/slidesorterbaropt.cxx b/svtools/source/config/slidesorterbaropt.cxx
new file mode 100644
index 0000000..1379fcb
--- /dev/null
+++ b/svtools/source/config/slidesorterbaropt.cxx
@@ -0,0 +1,580 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <svtools/slidesorterbaropt.hxx>
+#include <unotools/configmgr.hxx>
+#include <unotools/configitem.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <tools/link.hxx>
+
+#include <rtl/logfile.hxx>
+#include <rtl/instance.hxx>
+#include "itemholder2.hxx"
+
+#include <svtools/imgdef.hxx>
+#include <vcl/svapp.hxx>
+
+#include <list>
+
+using namespace ::utl                   ;
+using namespace ::rtl                   ;
+using namespace ::osl                   ;
+using namespace ::com::sun::star::uno   ;
+using namespace ::com::sun::star;
+
+#define ASCII_STR(s)                        OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
+#define ROOTNODE_SLIDESORTERBAR             ASCII_STR("Office.Impress/MultiPaneGUI/SlideSorterBar/Visible")
+
+#define PROPERTYNAME_VISIBLE_IMPRESSVIEW       ASCII_STR("ImpressView")
+#define PROPERTYHANDLE_VISIBLE_IMPRESSVIEW     0
+#define PROPERTYNAME_VISIBLE_OUTLINEVIEW       ASCII_STR("OutlineView")
+#define PROPERTYHANDLE_VISIBLE_OUTLINEVIEW     1
+#define PROPERTYNAME_VISIBLE_NOTESVIEW         ASCII_STR("NotesView")
+#define PROPERTYHANDLE_VISIBLE_NOTESVIEW       2
+#define PROPERTYNAME_VISIBLE_HANDOUTVIEW       ASCII_STR("HandoutView")
+#define PROPERTYHANDLE_VISIBLE_HANDOUTVIEW     3
+#define PROPERTYNAME_VISIBLE_SLIDESORTERVIEW   ASCII_STR("SlideSorterView")
+#define PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW 4
+#define PROPERTYNAME_VISIBLE_DRAWVIEW          ASCII_STR("DrawView")
+#define PROPERTYHANDLE_VISIBLE_DRAWVIEW        5
+
+#define PROPERTYCOUNT                          6
+
+class SvtSlideSorterBarOptions_Impl : public ConfigItem
+{
+    private:
+    ::std::list<Link> aList;
+    sal_Bool    m_bVisibleImpressView;
+    sal_Bool    m_bVisibleOutlineView;
+    sal_Bool    m_bVisibleNotesView;
+    sal_Bool    m_bVisibleHandoutView;
+    sal_Bool    m_bVisibleSlideSorterView;
+    sal_Bool    m_bVisibleDrawView;
+
+    public:
+
+         SvtSlideSorterBarOptions_Impl();
+        ~SvtSlideSorterBarOptions_Impl();
+
+        /*-****************************************************************************************************//**
+            @short      called for notify of configmanager
+            @descr      These method is called from the ConfigManager before application ends or from the
+                         PropertyChangeListener if the sub tree broadcasts changes. You must update your
+                        internal values.
+
+            @seealso    baseclass ConfigItem
+
+            @param      "seqPropertyNames" is the list of properties which should be updated.
+            @return     -
+
+            @onerror    -
+        *//*-*****************************************************************************************************/
+
+        virtual void Notify( const Sequence< OUString >& seqPropertyNames );
+
+        /** loads required data from the configuration. It's called in the constructor to
+         read all entries and form ::Notify to re-read changed settings
+
+         */
+        void Load( const Sequence< OUString >& rPropertyNames );
+
+        /*-****************************************************************************************************//**
+            @short      write changes to configuration
+            @descr      These method writes the changed values into the sub tree
+                        and should always called in our destructor to guarantee consistency of config data.
+
+            @seealso    baseclass ConfigItem
+
+            @param      -
+            @return     -
+
+            @onerror    -
+        *//*-*****************************************************************************************************/
+
+        virtual void Commit();
+
+        //---------------------------------------------------------------------------------------------------------
+        //  public interface
+        //---------------------------------------------------------------------------------------------------------
+
+        void SetVisibleImpressView( sal_Bool bSet )
+        {  m_bVisibleImpressView = bSet; SetModified(); }
+
+        sal_Bool GetVisibleImpressView() const
+        { return m_bVisibleImpressView; }
+
+        void SetVisibleOutlineView( sal_Bool bSet )
+        {  m_bVisibleOutlineView = bSet; SetModified(); }
+
+        sal_Bool GetVisibleOutlineView() const
+        { return m_bVisibleOutlineView; }
+
+        void SetVisibleNotesView( sal_Bool bSet )
+        {  m_bVisibleNotesView = bSet; SetModified(); }
+
+        sal_Bool GetVisibleNotesView() const
+        { return m_bVisibleNotesView; }
+
+        void SetVisibleHandoutView( sal_Bool bSet )
+        {  m_bVisibleHandoutView = bSet; SetModified(); }
+
+        sal_Bool GetVisibleHandoutView() const
+        { return m_bVisibleHandoutView; }
+
+        void SetVisibleSlideSorterView( sal_Bool bSet )
+        {  m_bVisibleSlideSorterView = bSet; SetModified(); }
+
+        sal_Bool GetVisibleSlideSorterView() const
+        { return m_bVisibleSlideSorterView; }
+
+        void SetVisibleDrawView( sal_Bool bSet )
+        {  m_bVisibleDrawView = bSet; SetModified(); }
+
+        sal_Bool GetVisibleDrawView() const
+        { return m_bVisibleDrawView; }
+
+        void AddListenerLink( const Link& rLink );
+        void RemoveListenerLink( const Link& rLink );
+        void CallListeners();
+
+    //-------------------------------------------------------------------------------------------------------------
+    //  private methods
+    //-------------------------------------------------------------------------------------------------------------
+
+    private:
+
+        /*-****************************************************************************************************//**
+            @short      return list of key names of our configuration management which represent oue module tree
+            @descr      These methods return a static const list of key names. We need it to get needed values from our
+                        configuration management.
+
+            @seealso    -
+
+            @param      -
+            @return     A list of needed configuration keys is returned.
+
+            @onerror    -
+        *//*-*****************************************************************************************************/
+
+        static Sequence< OUString > GetPropertyNames();
+
+    protected:
+};
+
+//*****************************************************************************************************************
+//  constructor
+//*****************************************************************************************************************
+SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()
+    // Init baseclasses first
+    : ConfigItem( ROOTNODE_SLIDESORTERBAR )
+
+    , m_bVisibleImpressView( sal_False )
+    , m_bVisibleOutlineView( sal_False )
+    , m_bVisibleNotesView( sal_False )
+    , m_bVisibleHandoutView( sal_False )
+    , m_bVisibleSlideSorterView( sal_False )
+    , m_bVisibleDrawView( sal_False )
+
+{
+    // Use our static list of configuration keys to get his values.
+    Sequence< OUString >    seqNames    = GetPropertyNames  (           );
+    Load( seqNames );
+    Sequence< Any >         seqValues   = GetProperties     ( seqNames  );
+    Sequence< sal_Bool >    seqRO       = GetReadOnlyStates ( seqNames  );
+
+    // Safe impossible cases.
+    // We need values from ALL configuration keys.
+    // Follow assignment use order of values in relation to our list of key names!
+    DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+    // Copy values from list in right order to our internal member.
+    sal_Int32 nPropertyCount = seqValues.getLength();
+    for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+    {
+        if (seqValues[nProperty].hasValue()==sal_False)
+            continue;
+        switch( nProperty )
+        {
+            case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleImpressView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleImpressView\"!" );
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleOutlineView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleOutlineView\"!" );
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_NOTESVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleNotesView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleNotesView\"!" );
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleHandoutView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleHandoutView\"!" );
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleSlideSorterView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleSlideSorterView\"!" );
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_DRAWVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleDrawView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleDrawView\"!" );
+                break;
+            }
+        }
+    }
+
+    // Enable notification mechanism of our baseclass.
+    // We need it to get information about changes outside these class on our used configuration keys!
+    EnableNotification( seqNames );
+}
+
+//*****************************************************************************************************************
+//  destructor
+//*****************************************************************************************************************
+SvtSlideSorterBarOptions_Impl::~SvtSlideSorterBarOptions_Impl()
+{
+    // We must save our current values .. if user forgets it!
+    if( IsModified() == sal_True )
+    {
+        Commit();
+    }
+}
+
+static int lcl_MapPropertyName( const ::rtl::OUString rCompare,
+                const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames)
+{
+    for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
+    {
+        if( aInternalPropertyNames[nProp] == rCompare )
+            return nProp;
+    }
+    return -1;
+}
+
+void SvtSlideSorterBarOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
+{
+    const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames());
+    Sequence< Any > seqValues = GetProperties( rPropertyNames  );
+
+    // Safe impossible cases.
+    // We need values from ALL configuration keys.
+    // Follow assignment use order of values in relation to our list of key names!
+    DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()), "SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()\nI miss some values of configuration keys!\n" );
+
+    // Copy values from list in right order to our internal member.
+    sal_Int32 nPropertyCount = seqValues.getLength();
+    for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+    {
+        if (seqValues[nProperty].hasValue()==sal_False)
+            continue;
+        switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) )
+        {
+            case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW:
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleImpressView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleImpressView\"!" );
+            }
+            break;
+            case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleOutlineView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleOutlineView\"!" );
+            }
+            break;
+            case PROPERTYHANDLE_VISIBLE_NOTESVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleNotesView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleNotesView\"!" );
+            }
+            break;
+            case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleHandoutView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleHandoutView\"!" );
+            }
+            break;
+            case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleSlideSorterView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleSlideSorterView\"!" );
+            }
+            break;
+
+            case PROPERTYHANDLE_VISIBLE_DRAWVIEW :
+            {
+                if( !(seqValues[nProperty] >>= m_bVisibleDrawView) )
+                    OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleDrawView\"!" );
+            }
+            break;
+       }
+    }
+}
+
+void SvtSlideSorterBarOptions_Impl::AddListenerLink( const Link& rLink )
+{
+    aList.push_back( rLink );
+}
+
+void SvtSlideSorterBarOptions_Impl::RemoveListenerLink( const Link& rLink )
+{
+    for ( ::std::list<Link>::iterator iter = aList.begin(); iter != aList.end(); ++iter )
+    {
+        if ( *iter == rLink )
+        {
+            aList.erase(iter);
+            break;
+        }
+    }
+}
+
+void SvtSlideSorterBarOptions_Impl::CallListeners()
+{
+    for ( ::std::list<Link>::const_iterator iter = aList.begin(); iter != aList.end(); ++iter )
+        iter->Call( this );
+}
+
+//*****************************************************************************************************************
+//  public method
+//*****************************************************************************************************************
+void SvtSlideSorterBarOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
+{
+    Load( rPropertyNames );
+    CallListeners();
+}
+
+//*****************************************************************************************************************
+//  public method
+//*****************************************************************************************************************
+void SvtSlideSorterBarOptions_Impl::Commit()
+{
+    // Get names of supported properties, create a list for values and copy current values to it.
+    Sequence< OUString >    seqNames    = GetPropertyNames  ();
+    sal_Int32               nCount      = seqNames.getLength();
+    Sequence< Any >         seqValues   ( nCount );
+    for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
+    {
+        switch( nProperty )
+        {
+            case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW:
+            {
+                seqValues[nProperty] <<= m_bVisibleImpressView;
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW:
+            {
+                seqValues[nProperty] <<= m_bVisibleOutlineView;
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_NOTESVIEW:
+            {
+                seqValues[nProperty] <<= m_bVisibleNotesView;
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW:
+            {
+                seqValues[nProperty] <<= m_bVisibleHandoutView;
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW:
+            {
+                seqValues[nProperty] <<= m_bVisibleSlideSorterView;
+                break;
+            }
+            case PROPERTYHANDLE_VISIBLE_DRAWVIEW:
+            {
+                seqValues[nProperty] <<= m_bVisibleDrawView;
+                break;
+            }
+
+        }
+    }
+    // Set properties in configuration.
+    PutProperties( seqNames, seqValues );
+}
+
+//*****************************************************************************************************************
+//  private method
+//*****************************************************************************************************************
+Sequence< OUString > SvtSlideSorterBarOptions_Impl::GetPropertyNames()
+{
+    // Build list of configuration key names.
+    const OUString pProperties[] =
+    {
+        PROPERTYNAME_VISIBLE_IMPRESSVIEW,
+        PROPERTYNAME_VISIBLE_OUTLINEVIEW,
+        PROPERTYNAME_VISIBLE_NOTESVIEW,
+        PROPERTYNAME_VISIBLE_HANDOUTVIEW,
+        PROPERTYNAME_VISIBLE_SLIDESORTERVIEW,
+        PROPERTYNAME_VISIBLE_DRAWVIEW,
+    };
+
+    // Initialize return sequence with these list ...
+    const Sequence< OUString > seqPropertyNames( pProperties, SAL_N_ELEMENTS( pProperties ) );
+    // ... and return it.
+    return seqPropertyNames;
+}
+
+//*****************************************************************************************************************
+//  initialize static member
+//  DON'T DO IT IN YOUR HEADER!
+//  see definition for further informations
+//*****************************************************************************************************************
+SvtSlideSorterBarOptions_Impl* SvtSlideSorterBarOptions::m_pDataContainer    = NULL  ;
+sal_Int32                      SvtSlideSorterBarOptions::m_nRefCount = 0     ;
+
+//*****************************************************************************************************************
+//  constructor
+//*****************************************************************************************************************
+SvtSlideSorterBarOptions::SvtSlideSorterBarOptions()
+{
+    // Global access, must be guarded (multithreading!).
+    MutexGuard aGuard( GetInitMutex() );
+    // Increase our refcount ...
+    ++m_nRefCount;
+    // ... and initialize our data container only if it not already exist!
+    if( m_pDataContainer == NULL )
+    {
+       RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtSlideSorterBarOptions_Impl::ctor()");
+       m_pDataContainer = new SvtSlideSorterBarOptions_Impl;
+//       svtools::ItemHolder2::holdConfigItem(E_MISCOPTIONS);
+    }
+}
+
+//*****************************************************************************************************************
+//  destructor
+//*****************************************************************************************************************
+SvtSlideSorterBarOptions::~SvtSlideSorterBarOptions()
+{
+    // Global access, must be guarded (multithreading!)
+    MutexGuard aGuard( GetInitMutex() );
+    // Decrease our refcount.
+    --m_nRefCount;
+    // If last instance was deleted ...
+    // we must destroy our static data container!
+    if( m_nRefCount <= 0 )
+    {
+        delete m_pDataContainer;
+        m_pDataContainer = NULL;
+    }
+}
+
+sal_Bool SvtSlideSorterBarOptions::GetVisibleImpressView() const
+{
+    return m_pDataContainer->GetVisibleImpressView();
+}
+
+void SvtSlideSorterBarOptions::SetVisibleImpressView(sal_Bool bVisible)
+{
+    return m_pDataContainer->SetVisibleImpressView(bVisible);
+}
+
+sal_Bool SvtSlideSorterBarOptions::GetVisibleOutlineView() const
+{
+    return m_pDataContainer->GetVisibleOutlineView();
+}
+
+void SvtSlideSorterBarOptions::SetVisibleOutlineView(sal_Bool bVisible)
+{
+    return m_pDataContainer->SetVisibleOutlineView(bVisible);
+}
+
+sal_Bool SvtSlideSorterBarOptions::GetVisibleNotesView() const
+{
+    return m_pDataContainer->GetVisibleNotesView();
+}
+
+void SvtSlideSorterBarOptions::SetVisibleNotesView(sal_Bool bVisible)
+{
+    return m_pDataContainer->SetVisibleNotesView(bVisible);
+}
+
+sal_Bool SvtSlideSorterBarOptions::GetVisibleHandoutView() const
+{
+    return m_pDataContainer->GetVisibleHandoutView();
+}
+
+void SvtSlideSorterBarOptions::SetVisibleHandoutView(sal_Bool bVisible)
+{
+    return m_pDataContainer->SetVisibleHandoutView(bVisible);
+}
+
+sal_Bool SvtSlideSorterBarOptions::GetVisibleSlideSorterView() const
+{
+    return m_pDataContainer->GetVisibleSlideSorterView();
+}
+
+void SvtSlideSorterBarOptions::SetVisibleSlideSorterView(sal_Bool bVisible)
+{
+    return m_pDataContainer->SetVisibleSlideSorterView(bVisible);
+}
+
+sal_Bool SvtSlideSorterBarOptions::GetVisibleDrawView() const
+{
+    return m_pDataContainer->GetVisibleDrawView();
+}
+
+void SvtSlideSorterBarOptions::SetVisibleDrawView(sal_Bool bVisible)
+{
+    return m_pDataContainer->SetVisibleDrawView(bVisible);
+}
+
+namespace
+{
+    class theSvtSlideSorterBarOptionsMutex :
+        public rtl::Static< osl::Mutex, theSvtSlideSorterBarOptionsMutex > {};
+}
+
+Mutex & SvtSlideSorterBarOptions::GetInitMutex()
+{
+    return theSvtSlideSorterBarOptionsMutex::get();
+}
+
+void SvtSlideSorterBarOptions::AddListenerLink( const Link& rLink )
+{
+    m_pDataContainer->AddListenerLink( rLink );
+}
+
+void SvtSlideSorterBarOptions::RemoveListenerLink( const Link& rLink )
+{
+    m_pDataContainer->RemoveListenerLink( rLink );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-- 
1.7.5.4


--------------020504070508020205090600--


More information about the LibreOffice mailing list