Kaydet (Commit) b843d905 authored tarafından Rob Snelders's avatar Rob Snelders Kaydeden (comit) Cédric Bosdonnat

code cleanup

Change-Id: Ib154cd53253e4d802d13a024a20f6c34d499e672
üst d72568fc
...@@ -27,68 +27,76 @@ ...@@ -27,68 +27,76 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <unotools/options.hxx> #include <unotools/options.hxx>
/*@short forward declaration to our private date container implementation /** 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 We use these class as internal member to support small memory requirements.
is faster and smaller then a complete implementation!*/ 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 SvtSlideSorterBarOptions_Impl;
class Link; class Link;
/*@short collect informations about sidebar group /** collect informations about sidebar group
@ATTENTION This class is partially threadsafe.
@devstatus ready to use*/ \attention This class is partially threadsafe.
*/
class SVT_DLLPUBLIC SvtSlideSorterBarOptions: public utl::detail::Options class SVT_DLLPUBLIC SvtSlideSorterBarOptions: public utl::detail::Options
{ {
public: public:
/*@short standard constructor and destructor /** 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 This will initialize an instance with default values.
at create and decrease it at delete time - but all instances use the same data container! We implement these class with a refcount mechanism! Every instance of this class increase it
He is implemented as a static member ... at create and decrease it at delete time - but all instances use the same data container!
@seealso member m_nRefCount He is implemented as a static member ...
@seealso member m_pDataContainer*/
SvtSlideSorterBarOptions(); \sa member m_nRefCount
\sa member m_pDataContainer
*/
SvtSlideSorterBarOptions();
virtual ~SvtSlideSorterBarOptions(); virtual ~SvtSlideSorterBarOptions();
void AddListenerLink( const Link& rLink ); void AddListenerLink( const Link& rLink );
void RemoveListenerLink( const Link& rLink ); void RemoveListenerLink( const Link& rLink );
sal_Bool GetVisibleImpressView() const; bool GetVisibleImpressView() const;
void SetVisibleImpressView( sal_Bool bVisible ); void SetVisibleImpressView( bool bVisible );
sal_Bool GetVisibleOutlineView() const; bool GetVisibleOutlineView() const;
void SetVisibleOutlineView( sal_Bool bVisible ); void SetVisibleOutlineView( bool bVisible );
sal_Bool GetVisibleNotesView() const; bool GetVisibleNotesView() const;
void SetVisibleNotesView( sal_Bool bVisible ); void SetVisibleNotesView( bool bVisible );
sal_Bool GetVisibleHandoutView() const; bool GetVisibleHandoutView() const;
void SetVisibleHandoutView( sal_Bool bVisible ); void SetVisibleHandoutView( bool bVisible );
sal_Bool GetVisibleSlideSorterView() const; bool GetVisibleSlideSorterView() const;
void SetVisibleSlideSorterView( sal_Bool bVisible ); void SetVisibleSlideSorterView( bool bVisible );
sal_Bool GetVisibleDrawView() const; bool GetVisibleDrawView() const;
void SetVisibleDrawView( sal_Bool bVisible ); void SetVisibleDrawView( bool bVisible );
private: private:
/*@short return a reference to a static mutex /** return a reference to a static mutex
@descr These class is partially threadsafe (for de-/initialization only).
All access methods are'nt safe! These class is partially threadsafe (for de-/initialization only).
We create a static mutex only for one ime and use at different times. All access methods are'nt safe!
@return A reference to a static mutex member.*/ 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(); SVT_DLLPRIVATE static ::osl::Mutex& GetInitMutex();
private: private:
/*Attention /**
\attention
Don't initialize these static member in these header! Don't initialize these static member in these header!
a) Double dfined symbols will be detected ... \li Double defined symbols will be detected ...
b) and unresolved externals exist at linking time. \li and unresolved externals exist at linking time.
Do it in your source only. Do it in your source only.
*/ */
static SvtSlideSorterBarOptions_Impl* m_pDataContainer ; /// impl. data container as dynamic pointer for smaller memory requirements! static SvtSlideSorterBarOptions_Impl* m_pDataContainer ; ///< impl. data container as dynamic pointer for smaller memory requirements!
static sal_Int32 m_nRefCount ; /// internal ref count mechanism static sal_Int32 m_nRefCount ; ///< internal ref count mechanism
}; // class SvtSlideSorterBarOptions };
#endif // #ifndef INCLUDED_SVTOOLS_SLIDESORTERBAROPT_HXX #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -34,26 +34,25 @@ ...@@ -34,26 +34,25 @@
#include <list> #include <list>
using namespace ::utl ; using namespace ::utl;
using namespace ::rtl ; using namespace ::rtl;
using namespace ::osl ; using namespace ::osl;
using namespace ::com::sun::star::uno ; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star; using namespace ::com::sun::star;
#define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) ) #define ROOTNODE_SLIDESORTERBAR OUString("Office.Impress/MultiPaneGUI/SlideSorterBar/Visible")
#define ROOTNODE_SLIDESORTERBAR ASCII_STR("Office.Impress/MultiPaneGUI/SlideSorterBar/Visible")
#define PROPERTYNAME_VISIBLE_IMPRESSVIEW ASCII_STR("ImpressView") #define PROPERTYNAME_VISIBLE_IMPRESSVIEW OUString("ImpressView")
#define PROPERTYHANDLE_VISIBLE_IMPRESSVIEW 0 #define PROPERTYHANDLE_VISIBLE_IMPRESSVIEW 0
#define PROPERTYNAME_VISIBLE_OUTLINEVIEW ASCII_STR("OutlineView") #define PROPERTYNAME_VISIBLE_OUTLINEVIEW OUString("OutlineView")
#define PROPERTYHANDLE_VISIBLE_OUTLINEVIEW 1 #define PROPERTYHANDLE_VISIBLE_OUTLINEVIEW 1
#define PROPERTYNAME_VISIBLE_NOTESVIEW ASCII_STR("NotesView") #define PROPERTYNAME_VISIBLE_NOTESVIEW OUString("NotesView")
#define PROPERTYHANDLE_VISIBLE_NOTESVIEW 2 #define PROPERTYHANDLE_VISIBLE_NOTESVIEW 2
#define PROPERTYNAME_VISIBLE_HANDOUTVIEW ASCII_STR("HandoutView") #define PROPERTYNAME_VISIBLE_HANDOUTVIEW OUString("HandoutView")
#define PROPERTYHANDLE_VISIBLE_HANDOUTVIEW 3 #define PROPERTYHANDLE_VISIBLE_HANDOUTVIEW 3
#define PROPERTYNAME_VISIBLE_SLIDESORTERVIEW ASCII_STR("SlideSorterView") #define PROPERTYNAME_VISIBLE_SLIDESORTERVIEW OUString("SlideSorterView")
#define PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW 4 #define PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW 4
#define PROPERTYNAME_VISIBLE_DRAWVIEW ASCII_STR("DrawView") #define PROPERTYNAME_VISIBLE_DRAWVIEW OUString("DrawView")
#define PROPERTYHANDLE_VISIBLE_DRAWVIEW 5 #define PROPERTYHANDLE_VISIBLE_DRAWVIEW 5
#define PROPERTYCOUNT 6 #define PROPERTYCOUNT 6
...@@ -62,83 +61,59 @@ class SvtSlideSorterBarOptions_Impl : public ConfigItem ...@@ -62,83 +61,59 @@ class SvtSlideSorterBarOptions_Impl : public ConfigItem
{ {
private: private:
::std::list<Link> aList; ::std::list<Link> aList;
sal_Bool m_bVisibleImpressView; Sequence< OUString > m_seqPropertyNames;
sal_Bool m_bVisibleOutlineView;
sal_Bool m_bVisibleNotesView;
sal_Bool m_bVisibleHandoutView;
sal_Bool m_bVisibleSlideSorterView;
sal_Bool m_bVisibleDrawView;
public: public:
SvtSlideSorterBarOptions_Impl(); SvtSlideSorterBarOptions_Impl();
~SvtSlideSorterBarOptions_Impl(); ~SvtSlideSorterBarOptions_Impl();
/*@short called for notify of configmanager /** 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.*/
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.
\sa baseclass ConfigItem
\param[in,out] seqPropertyNames is the list of properties which should be updated.
*/
virtual void Notify( const Sequence< OUString >& seqPropertyNames ); 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 */ 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 ); void Load( const Sequence< OUString >& rPropertyNames );
/*@short write changes to configuration /** 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 These method writes the changed values into the sub tree
{ return m_bVisibleHandoutView; } and should always called in our destructor to guarantee consistency of config data.
void SetVisibleSlideSorterView( sal_Bool bSet ) \sa baseclass ConfigItem
{ m_bVisibleSlideSorterView = bSet; SetModified(); } */
virtual void Commit();
sal_Bool GetVisibleSlideSorterView() const
{ return m_bVisibleSlideSorterView; }
void SetVisibleDrawView( sal_Bool bSet )
{ m_bVisibleDrawView = bSet; SetModified(); }
sal_Bool GetVisibleDrawView() const // public interface
{ return m_bVisibleDrawView; } bool m_bVisibleImpressView;
bool m_bVisibleOutlineView;
bool m_bVisibleNotesView;
bool m_bVisibleHandoutView;
bool m_bVisibleSlideSorterView;
bool m_bVisibleDrawView;
void AddListenerLink( const Link& rLink ); void AddListenerLink( const Link& rLink );
void RemoveListenerLink( const Link& rLink ); void RemoveListenerLink( const Link& rLink );
void CallListeners(); void CallListeners();
private: private:
/*@short return list of key names of our configuration management which represent oue module tree /** 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. These methods return a static const list of key names. We need it to get needed values from our
@return A list of needed configuration keys is returned.*/ configuration management.
\return A list of needed configuration keys is returned.
*/
static Sequence< OUString > GetPropertyNames(); static Sequence< OUString > GetPropertyNames();
protected: protected:
...@@ -148,28 +123,27 @@ SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl() ...@@ -148,28 +123,27 @@ SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()
// Init baseclasses first // Init baseclasses first
: ConfigItem( ROOTNODE_SLIDESORTERBAR ) : ConfigItem( ROOTNODE_SLIDESORTERBAR )
, m_bVisibleImpressView( sal_False ) , m_bVisibleImpressView( false )
, m_bVisibleOutlineView( sal_False ) , m_bVisibleOutlineView( false )
, m_bVisibleNotesView( sal_False ) , m_bVisibleNotesView( false )
, m_bVisibleHandoutView( sal_False ) , m_bVisibleHandoutView( false )
, m_bVisibleSlideSorterView( sal_False ) , m_bVisibleSlideSorterView( false )
, m_bVisibleDrawView( sal_False ) , m_bVisibleDrawView( false )
{ {
m_seqPropertyNames = GetPropertyNames( );
// Use our static list of configuration keys to get his values. // Use our static list of configuration keys to get his values.
Sequence< OUString > seqNames = GetPropertyNames ( ); Sequence< Any > seqValues = GetProperties( m_seqPropertyNames );
Load( seqNames );
Sequence< Any > seqValues = GetProperties ( seqNames );
Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
// Safe impossible cases. // Safe impossible cases.
// We need values from ALL configuration keys. // We need values from ALL configuration keys.
// Follow assignment use order of values in relation to our list of key names! // 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" ); DBG_ASSERT( !(m_seqPropertyNames.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. // Copy values from list in right order to our internal member.
sal_Int32 nPropertyCount = seqValues.getLength(); for( sal_Int32 nProperty=0; nProperty<seqValues.getLength(); ++nProperty )
for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
{ {
if (seqValues[nProperty].hasValue()==sal_False) if (seqValues[nProperty].hasValue()==sal_False)
continue; continue;
...@@ -216,16 +190,12 @@ SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl() ...@@ -216,16 +190,12 @@ SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()
// Enable notification mechanism of our baseclass. // Enable notification mechanism of our baseclass.
// We need it to get information about changes outside these class on our used configuration keys! // We need it to get information about changes outside these class on our used configuration keys!
EnableNotification( seqNames ); EnableNotification( m_seqPropertyNames );
} }
SvtSlideSorterBarOptions_Impl::~SvtSlideSorterBarOptions_Impl() SvtSlideSorterBarOptions_Impl::~SvtSlideSorterBarOptions_Impl()
{ {
// We must save our current values .. if user forgets it! Commit();
if( IsModified() == sal_True )
{
Commit();
}
} }
static int lcl_MapPropertyName( const ::rtl::OUString rCompare, static int lcl_MapPropertyName( const ::rtl::OUString rCompare,
...@@ -247,11 +217,11 @@ void SvtSlideSorterBarOptions_Impl::Load( const Sequence< OUString >& rPropertyN ...@@ -247,11 +217,11 @@ void SvtSlideSorterBarOptions_Impl::Load( const Sequence< OUString >& rPropertyN
// Safe impossible cases. // Safe impossible cases.
// We need values from ALL configuration keys. // We need values from ALL configuration keys.
// Follow assignment use order of values in relation to our list of key names! // 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" ); 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. // Copy values from list in right order to our internal member.
sal_Int32 nPropertyCount = seqValues.getLength(); for( sal_Int32 nProperty=0; nProperty<seqValues.getLength(); ++nProperty )
for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
{ {
if (seqValues[nProperty].hasValue()==sal_False) if (seqValues[nProperty].hasValue()==sal_False)
continue; continue;
...@@ -330,8 +300,7 @@ void SvtSlideSorterBarOptions_Impl::Notify( const Sequence< OUString >& rPropert ...@@ -330,8 +300,7 @@ void SvtSlideSorterBarOptions_Impl::Notify( const Sequence< OUString >& rPropert
void SvtSlideSorterBarOptions_Impl::Commit() void SvtSlideSorterBarOptions_Impl::Commit()
{ {
// Get names of supported properties, create a list for values and copy current values to it. // Get names of supported properties, create a list for values and copy current values to it.
Sequence< OUString > seqNames = GetPropertyNames (); sal_Int32 nCount = m_seqPropertyNames.getLength();
sal_Int32 nCount = seqNames.getLength();
Sequence< Any > seqValues ( nCount ); Sequence< Any > seqValues ( nCount );
for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
{ {
...@@ -371,13 +340,13 @@ void SvtSlideSorterBarOptions_Impl::Commit() ...@@ -371,13 +340,13 @@ void SvtSlideSorterBarOptions_Impl::Commit()
} }
} }
// Set properties in configuration. // Set properties in configuration.
PutProperties( seqNames, seqValues ); PutProperties( m_seqPropertyNames, seqValues );
} }
Sequence< OUString > SvtSlideSorterBarOptions_Impl::GetPropertyNames() Sequence< OUString > SvtSlideSorterBarOptions_Impl::GetPropertyNames()
{ {
// Build list of configuration key names. // Build list of configuration key names.
const OUString pProperties[] = OUString pProperties[] =
{ {
PROPERTYNAME_VISIBLE_IMPRESSVIEW, PROPERTYNAME_VISIBLE_IMPRESSVIEW,
PROPERTYNAME_VISIBLE_OUTLINEVIEW, PROPERTYNAME_VISIBLE_OUTLINEVIEW,
...@@ -388,8 +357,7 @@ Sequence< OUString > SvtSlideSorterBarOptions_Impl::GetPropertyNames() ...@@ -388,8 +357,7 @@ Sequence< OUString > SvtSlideSorterBarOptions_Impl::GetPropertyNames()
}; };
// Initialize return sequence with these list and run // Initialize return sequence with these list and run
const Sequence< OUString > seqPropertyNames( pProperties, SAL_N_ELEMENTS( pProperties ) ); return Sequence< OUString >( pProperties, SAL_N_ELEMENTS( pProperties ) );
return seqPropertyNames;
} }
// initialize static member, see definition for further information // initialize static member, see definition for further information
...@@ -423,64 +391,64 @@ SvtSlideSorterBarOptions::~SvtSlideSorterBarOptions() ...@@ -423,64 +391,64 @@ SvtSlideSorterBarOptions::~SvtSlideSorterBarOptions()
} }
} }
sal_Bool SvtSlideSorterBarOptions::GetVisibleImpressView() const bool SvtSlideSorterBarOptions::GetVisibleImpressView() const
{ {
return m_pDataContainer->GetVisibleImpressView(); return m_pDataContainer->m_bVisibleImpressView;
} }
void SvtSlideSorterBarOptions::SetVisibleImpressView(sal_Bool bVisible) void SvtSlideSorterBarOptions::SetVisibleImpressView(bool bVisible)
{ {
return m_pDataContainer->SetVisibleImpressView(bVisible); m_pDataContainer->m_bVisibleImpressView = bVisible;
} }
sal_Bool SvtSlideSorterBarOptions::GetVisibleOutlineView() const bool SvtSlideSorterBarOptions::GetVisibleOutlineView() const
{ {
return m_pDataContainer->GetVisibleOutlineView(); return m_pDataContainer->m_bVisibleOutlineView;
} }
void SvtSlideSorterBarOptions::SetVisibleOutlineView(sal_Bool bVisible) void SvtSlideSorterBarOptions::SetVisibleOutlineView(bool bVisible)
{ {
return m_pDataContainer->SetVisibleOutlineView(bVisible); m_pDataContainer->m_bVisibleOutlineView = bVisible;
} }
sal_Bool SvtSlideSorterBarOptions::GetVisibleNotesView() const bool SvtSlideSorterBarOptions::GetVisibleNotesView() const
{ {
return m_pDataContainer->GetVisibleNotesView(); return m_pDataContainer->m_bVisibleNotesView;
} }
void SvtSlideSorterBarOptions::SetVisibleNotesView(sal_Bool bVisible) void SvtSlideSorterBarOptions::SetVisibleNotesView(bool bVisible)
{ {
return m_pDataContainer->SetVisibleNotesView(bVisible); m_pDataContainer->m_bVisibleNotesView = bVisible;
} }
sal_Bool SvtSlideSorterBarOptions::GetVisibleHandoutView() const bool SvtSlideSorterBarOptions::GetVisibleHandoutView() const
{ {
return m_pDataContainer->GetVisibleHandoutView(); return m_pDataContainer->m_bVisibleHandoutView;
} }
void SvtSlideSorterBarOptions::SetVisibleHandoutView(sal_Bool bVisible) void SvtSlideSorterBarOptions::SetVisibleHandoutView(bool bVisible)
{ {
return m_pDataContainer->SetVisibleHandoutView(bVisible); m_pDataContainer->m_bVisibleHandoutView = bVisible;
} }
sal_Bool SvtSlideSorterBarOptions::GetVisibleSlideSorterView() const bool SvtSlideSorterBarOptions::GetVisibleSlideSorterView() const
{ {
return m_pDataContainer->GetVisibleSlideSorterView(); return m_pDataContainer->m_bVisibleSlideSorterView;
} }
void SvtSlideSorterBarOptions::SetVisibleSlideSorterView(sal_Bool bVisible) void SvtSlideSorterBarOptions::SetVisibleSlideSorterView(bool bVisible)
{ {
return m_pDataContainer->SetVisibleSlideSorterView(bVisible); m_pDataContainer->m_bVisibleSlideSorterView = bVisible;
} }
sal_Bool SvtSlideSorterBarOptions::GetVisibleDrawView() const bool SvtSlideSorterBarOptions::GetVisibleDrawView() const
{ {
return m_pDataContainer->GetVisibleDrawView(); return m_pDataContainer->m_bVisibleDrawView;
} }
void SvtSlideSorterBarOptions::SetVisibleDrawView(sal_Bool bVisible) void SvtSlideSorterBarOptions::SetVisibleDrawView(bool bVisible)
{ {
return m_pDataContainer->SetVisibleDrawView(bVisible); m_pDataContainer->m_bVisibleDrawView = bVisible;
} }
namespace namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment