Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi Tor,

I have updated the license/header, I forgot to change them when I copied them from the miscopt-class. Also removed some comments with especially the art, seems usefull to me.

--
Greetings,
Rob Snelders


Op 25-05-12 12:39, Tor Lillqvist schreef:
It will take a while for me to digest and approve the patch (others
are welcome to do it quicker, of course), but just a few stylistic
questions at a start:

- You use the old Oracle LGPL-only header in a couple of new files the
patch introduces. Is this because the files in question are largely
based on existing files thatuse that license/header, or just an
oversight? Somebody, correct me if I am wrong, but I think new code
should be MPL licensed, and use the must shorter
TEMPLATE.SOURCECODE.HEADER. (Patches to existing code should be
MPL/LGPL dual licensed.)

- Is it really a convention to use those @ATTENTION thingies? I see
only a handful of those elsewhere in the codebase.

- Do we really want to introduce new instances of ASCII graphics like
/*-************************************************************************************************************//**
?

(My own opinion is that at some point we should do a really
heavy-handed automatic cleanup up the codebase and remove all silly
ASCII graphics delimiters around comment blocks, separating functions
etc.)

--tml
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

From 261c9db301640a79a620b3ee64a9d8b3f432c4bc Mon Sep 17 00:00:00 2001
From: Rob Snelders <programming@ertai.nl>
Date: Fri, 25 May 2012 17:31:11 +0200
Subject: [PATCH] fd0#35973 - [EasyHack] Remember the state of the sidebar
 pane in Impress

Change-Id: Ie287bc1c545bd8986ee3509181c878bdcd0d1942
---
 .../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          |   83 ++++
 svtools/source/config/slidesorterbaropt.cxx        |  496 ++++++++++++++++++++
 13 files changed, 711 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..ff44549 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..cb8c31a 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..9b7a224 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 139e632..3c9d785 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 0dfc219..6b86546 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..29e2b80
--- /dev/null
+++ b/svtools/inc/svtools/slidesorterbaropt.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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_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
+    @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*/
+         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.
+            @return     A reference to a static mutex member.*/
+        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..0d84ef7
--- /dev/null
+++ b/svtools/source/config/slidesorterbaropt.cxx
@@ -0,0 +1,496 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * 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 <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.*/
+
+        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 setting */
+        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*/
+        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:
+          /*@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.
+            @return     A list of needed configuration keys is returned.*/
+        static Sequence< OUString > GetPropertyNames();
+
+    protected:
+};
+
+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 );
+}
+
+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 );
+}
+
+void SvtSlideSorterBarOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
+{
+    Load( rPropertyNames );
+    CallListeners();
+}
+
+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 );
+}
+
+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 and run
+    const Sequence< OUString > seqPropertyNames( pProperties, SAL_N_ELEMENTS( pProperties ) );
+    return seqPropertyNames;
+}
+
+//  initialize static member, see definition for further information
+//  DON'T DO IT IN YOUR HEADER!
+SvtSlideSorterBarOptions_Impl* SvtSlideSorterBarOptions::m_pDataContainer    = NULL  ;
+sal_Int32                      SvtSlideSorterBarOptions::m_nRefCount = 0     ;
+
+SvtSlideSorterBarOptions::SvtSlideSorterBarOptions()
+{
+    // Global access, must be guarded (multithreading!).
+    MutexGuard aGuard( GetInitMutex() );
+    ++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;
+    }
+}
+
+SvtSlideSorterBarOptions::~SvtSlideSorterBarOptions()
+{
+    // Global access, must be guarded (multithreading!)
+    MutexGuard aGuard( GetInitMutex() );
+    --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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.