diff options
author | Andreas Schlüns <as@openoffice.org> | 2001-10-19 07:16:30 +0000 |
---|---|---|
committer | Andreas Schlüns <as@openoffice.org> | 2001-10-19 07:16:30 +0000 |
commit | b08043ab9dec3bd7ddbce9dbdbf1f5cf0bb61db6 (patch) | |
tree | 58e97cf5b5d42916157759e7bfe9fb23f2a5c88c | |
parent | 13ecfc0cd4455c6f6918e0482bdfee67de508cb9 (diff) |
#92162#, #93355# new compact view format; write-trough-cache
-rw-r--r-- | svtools/source/config/viewoptions.cxx | 1496 |
1 files changed, 652 insertions, 844 deletions
diff --git a/svtools/source/config/viewoptions.cxx b/svtools/source/config/viewoptions.cxx index 1410e468c861..8c87fd13f3fb 100644 --- a/svtools/source/config/viewoptions.cxx +++ b/svtools/source/config/viewoptions.cxx @@ -2,9 +2,9 @@ * * $RCSfile: viewoptions.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: kz $ $Date: 2001-10-17 13:38:49 $ + * last change: $Author: as $ $Date: 2001-10-19 08:16:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,22 +79,19 @@ #include <com/sun/star/beans/PropertyValue.hpp> #endif -/* -#ifdef TF_OLDVIEW - #ifndef _RTL_USTRBUF_HXX_ - #include <rtl/ustrbuf.hxx> - #endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> #endif -*/ + +#ifndef UNOTOOLS_CONFIGPATHES_HXX_INCLUDED +#include <unotools/configpathes.hxx> +#endif + //_________________________________________________________________________________________________________________ // namespaces //_________________________________________________________________________________________________________________ -#ifdef css - #error "Who define css before! I use it as namespace replacement ..." -#else - #define css ::com::sun::star -#endif +namespace css = ::com::sun::star; //_________________________________________________________________________________________________________________ // const @@ -103,7 +100,7 @@ #ifdef CONST_ASCII #error "Who define CONST_ASCII before! I use it to create const ascii strings ..." #else - #define CONST_ASCII( _SASCIIVALUE_ ) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(_SASCIIVALUE_)) + #define CONST_ASCII(SASCIIVALUE) ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SASCIIVALUE)) #endif #define PATHSEPERATOR CONST_ASCII("/" ) @@ -118,23 +115,26 @@ #define PROPERTY_VISIBLE CONST_ASCII("Visible" ) #define PROPERTY_USERDATA CONST_ASCII("UserData" ) -#define PREFIX CONST_ASCII("v_" ) -#define PREFIXLENGTH 2 - -#define CHANGED_WINDOWSTATE 0x00000001 -#define CHANGED_PAGEID 0x00000002 -#define CHANGED_VISIBLE 0x00000004 -#define CHANGED_USERDATA 0x00000008 +#define PROPCOUNT_DIALOGS 1 +#define PROPCOUNT_TABDIALOGS 2 +#define PROPCOUNT_TABPAGES 1 +#define PROPCOUNT_WINDOWS 2 #define DEFAULT_WINDOWSTATE ::rtl::OUString() -#define DEFAULT_PAGEID 0 -#define DEFAULT_VISIBLE sal_True #define DEFAULT_USERDATA css::uno::Sequence< css::beans::NamedValue >() +#define DEFAULT_PAGEID 0 +#define DEFAULT_VISIBLE sal_False -#define PROPCOUNT_DIALOGS 2 -#define PROPCOUNT_TABDIALOGS 3 -#define PROPCOUNT_TABPAGES 2 -#define PROPCOUNT_WINDOWS 3 +#define DEBUG_VIEWOPTIONS + +#ifdef DEBUG_VIEWOPTIONS + #define _LOG_COUNTER_( _SVIEW_, _NREAD_, _NWRITE_ ) \ + { \ + FILE* pFile = fopen( "viewdbg.txt", "a" ); \ + fprintf( pFile, "%s[%d, %d]\n", ::rtl::OUStringToOString(_SVIEW_, RTL_TEXTENCODING_UTF8).getStr(), _NREAD_, _NWRITE_ ); \ + fclose( pFile ); \ + } +#endif // DEBUG_VIEWOPTIONS //_________________________________________________________________________________________________________________ // initialization! @@ -154,173 +154,146 @@ sal_Int32 SvtViewOptions::m_nRefCount_Windows = 0 //_________________________________________________________________________________________________________________ /*-************************************************************************************************************//** - @descr We define different a structure which present the format of a list item of right view type. - @attention Not all member are used for all special view type entries! + @descr declare one configuration item + These struct hold information about one view item. But not all member are used for all entries! + User must decide which information are usefull and which not. We are a container iztem only and doesnt + know anything about the context. + But; we support a feature: + decision between items with default values (should not realy exist in configuration!) + and items with real values - changed by user. So user can suppress saving of realy unused items + to disk - because; defaulted items could be restored on runtime without reading from disk!!! + And if only items with valid information was written to cfg - we mustn't read so much and save time. + So we start with an member m_bDefault=True and reset it to False after first set-call. + Deficiencies of these solution - we cant allow direct read/write access to our member. We must + support it by set/get-methods ... *//*-*************************************************************************************************************/ - -//***************************************************************************************************************** class IMPL_TViewData { public: //--------------------------------------------------------------------------------------------------------- + // create "default" item IMPL_TViewData() - : m_nChangedMask( 0 ) - , m_sWindowState( DEFAULT_WINDOWSTATE ) - , m_lUserData ( DEFAULT_USERDATA ) - , m_nPageID ( DEFAULT_PAGEID ) - , m_bVisible ( DEFAULT_PAGEID ) { - } - - //--------------------------------------------------------------------------------------------------------- - void SetWindowState( const ::rtl::OUString& sValue , - sal_Bool bTouch ) - { - if( m_sWindowState != sValue ) - { - m_sWindowState = sValue; - if( bTouch == sal_True ) - m_nChangedMask |= CHANGED_WINDOWSTATE; - } - } + m_sWindowState = DEFAULT_WINDOWSTATE ; + m_lUserData = DEFAULT_USERDATA ; + m_nPageID = DEFAULT_PAGEID ; + m_bVisible = DEFAULT_VISIBLE ; - //--------------------------------------------------------------------------------------------------------- - void SetUserData( const css::uno::Sequence< css::beans::NamedValue >& lValue , - sal_Bool bTouch ) - { - if( m_lUserData != lValue ) - { - m_lUserData = lValue; - if( bTouch == sal_True ) - m_nChangedMask |= CHANGED_USERDATA; - } + m_bDefault = sal_True ; } //--------------------------------------------------------------------------------------------------------- - void SetPageID( sal_Int32 nValue , - sal_Bool bTouch ) + // write access - with reseting of default state + void setWindowState( const ::rtl::OUString& sValue ) { - if( m_nPageID != nValue ) - { - m_nPageID = nValue; - if( bTouch == sal_True ) - m_nChangedMask |= CHANGED_PAGEID; - } + m_bDefault = ( + ( m_bDefault == sal_True ) && + ( sValue == DEFAULT_WINDOWSTATE ) + ); + m_sWindowState = sValue; } //--------------------------------------------------------------------------------------------------------- - void SetVisible( sal_Bool bValue , - sal_Bool bTouch ) + void setUserData( const css::uno::Sequence< css::beans::NamedValue >& lValue ) { - if( m_bVisible != bValue ) - { - m_bVisible = bValue; - if( bTouch == sal_True ) - m_nChangedMask |= CHANGED_VISIBLE; - } + m_bDefault = ( + ( m_bDefault == sal_True ) && + ( lValue == DEFAULT_USERDATA ) + ); + m_lUserData = lValue; } //--------------------------------------------------------------------------------------------------------- - ::rtl::OUString GetWindowState() const + void setPageID( sal_Int32 nValue ) { - return m_sWindowState; + m_bDefault = ( + ( m_bDefault == sal_True ) && + ( nValue == DEFAULT_PAGEID ) + ); + m_nPageID = nValue; } //--------------------------------------------------------------------------------------------------------- - css::uno::Sequence< css::beans::NamedValue > GetUserData() const + void setVisible( sal_Bool bValue ) { - return m_lUserData; + m_bDefault = ( + ( m_bDefault == sal_True ) && + ( bValue == DEFAULT_VISIBLE ) + ); + m_bVisible = bValue; } //--------------------------------------------------------------------------------------------------------- - sal_Int32 GetPageID() const - { - return m_nPageID; - } + // read access + ::rtl::OUString getWindowState() { return m_sWindowState; } + css::uno::Sequence< css::beans::NamedValue > getUserData () { return m_lUserData ; } + sal_Int32 getPageID () { return m_nPageID ; } + sal_Bool getVisible () { return m_bVisible ; } //--------------------------------------------------------------------------------------------------------- - sal_Bool GetVisible() const + // special operation for easy access on user data + void setUserItem( const ::rtl::OUString& sName , + const css::uno::Any& aValue ) { - return m_bVisible; - } + // we change UserData in every case! + // a) we change already existing item + // or b) we add a new one + m_bDefault = sal_False; - //--------------------------------------------------------------------------------------------------------- - void AddOrReplaceUserItem( const ::rtl::OUString& sName , - const css::uno::Any& aValue , - sal_Bool bTouch ) - { + sal_Bool bExist = sal_False; sal_Int32 nCount = m_lUserData.getLength(); - sal_Bool bFound = sal_False; + + // change it, if it already exist ... for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) { if( m_lUserData[nStep].Name == sName ) { m_lUserData[nStep].Value = aValue ; - bFound = sal_True; + bExist = sal_True; break; } } - if( bFound == sal_False ) + + // ... or create new list item + if( bExist == sal_False ) { m_lUserData.realloc( nCount+1 ); m_lUserData[nCount].Name = sName ; m_lUserData[nCount].Value = aValue ; } - if( bTouch == sal_True ) - { - m_nChangedMask |= CHANGED_USERDATA; - } } //--------------------------------------------------------------------------------------------------------- - void RemoveUserItem( const ::rtl::OUString& sName , - sal_Bool bTouch ) + css::uno::Any getUserItem( const ::rtl::OUString& sName ) { + // default value - if item not exist! + css::uno::Any aValue; + sal_Int32 nCount = m_lUserData.getLength(); for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) { if( m_lUserData[nStep].Name == sName ) { - // if it is the last item - delete it by resizing! - if( nStep == nCount-1 ) - { - m_lUserData.realloc( nCount-1 ); - } - // otherwise copy last item to current position - // (delete by override!) and resize list - else - { - m_lUserData[nStep] = m_lUserData[nCount-1]; - m_lUserData.realloc( nCount-1 ); - } + aValue = m_lUserData[nStep].Value; break; } } - if( bTouch == sal_True ) - { - m_nChangedMask |= CHANGED_USERDATA; - } + return aValue; } //--------------------------------------------------------------------------------------------------------- - sal_Bool IsChanged( sal_Int32 nCheckMask ) const - { - return(( m_nChangedMask & nCheckMask ) == nCheckMask ); - } + // check for default items + sal_Bool isDefault() { return m_bDefault; } - //------------------------------------------------------------------------------------------------------------- private: ::rtl::OUString m_sWindowState ; css::uno::Sequence< css::beans::NamedValue > m_lUserData ; sal_Int32 m_nPageID ; sal_Bool m_bVisible ; - sal_Int32 m_nChangedMask ; + sal_Bool m_bDefault ; }; -/*-************************************************************************************************************//** - @descr Define hash list to hold the view type data. -*//*-*************************************************************************************************************/ struct IMPL_TStringHashCode { size_t operator()(const ::rtl::OUString& sString) const @@ -329,148 +302,21 @@ struct IMPL_TStringHashCode } }; -typedef ::std::vector< ::rtl::OUString > IMPL_TStringList; - typedef ::std::hash_map< ::rtl::OUString , IMPL_TViewData , IMPL_TStringHashCode , ::std::equal_to< ::rtl::OUString > > IMPL_TViewHash; -class IMPL_TViewList -{ - public: - //--------------------------------------------------------------------------------------------------------- - void Add( const ::rtl::OUString& sName , - const IMPL_TViewData& rData ) - { - // Do nothing, if item already exist! - IMPL_TViewHash::iterator pItem = m_aList.find( sName ); - if( pItem == m_aList.end() ) - { - // Otherwise add it to list. - m_aList[sName] = rData; - // Set his name in "Added" list for later flushing of data! - m_lAdded.push_back( sName ); - // Don't forget to search it in "Deleted" list! - // We must correct it and remove this entry there. - IMPL_TStringList::iterator pDeleted = ::std::find( m_lDeleted.begin(), m_lDeleted.end(), sName ); - if( pDeleted != m_lDeleted.end() ) - { - m_lDeleted.erase( pDeleted ); - } - } - } - - //--------------------------------------------------------------------------------------------------------- - void Remove( const ::rtl::OUString& sName ) - { - // If item exist in list ... - IMPL_TViewHash::iterator pItem = m_aList.find( sName ); - if( pItem != m_aList.end() ) - { - // ... remove it. - // Mark it as "deleted". - m_aList.erase( pItem ); - m_lDeleted.push_back( sName ); - // But don't forget to unset it as "added", - // if it exist in these list too! - IMPL_TStringList::iterator pAdded = ::std::find( m_lAdded.begin(), m_lAdded.end(), sName ); - if( pAdded != m_lAdded.end() ) - { - m_lAdded.erase( pAdded ); - } - } - } - - //--------------------------------------------------------------------------------------------------------- - void Change( const ::rtl::OUString& sName , - const IMPL_TViewData& rData , - sal_Int32 nMask , - sal_Bool bTouch ) - { - // If item exist in list ... - IMPL_TViewHash::iterator pItem = m_aList.find( sName ); - if( pItem != m_aList.end() ) - { - if( nMask & CHANGED_WINDOWSTATE ) - m_aList[sName].SetWindowState( rData.GetWindowState(), bTouch ); - if( nMask & CHANGED_USERDATA ) - m_aList[sName].SetUserData( rData.GetUserData(), bTouch ); - if( nMask & CHANGED_PAGEID ) - m_aList[sName].SetPageID( rData.GetPageID(), bTouch ); - if( nMask & CHANGED_VISIBLE ) - m_aList[sName].SetVisible( rData.GetVisible(), bTouch ); - if( - ( bTouch == sal_True ) && - ( nMask != 0 ) - ) - { - m_lChanged.push_back( sName ); - } - } - } - - //--------------------------------------------------------------------------------------------------------- - sal_Bool Find( const ::rtl::OUString& sName , - IMPL_TViewData& rData ) const - { - sal_Bool bFound = sal_False; - IMPL_TViewHash::const_iterator pItem = m_aList.find( sName ); - if( pItem != m_aList.end() ) - { - rData = pItem->second; - bFound = sal_True; - } - return bFound; - } - - //--------------------------------------------------------------------------------------------------------- - sal_Bool Exists( const ::rtl::OUString& sName ) const - { - IMPL_TViewHash::const_iterator pItem = m_aList.find( sName ); - return( pItem != m_aList.end() ); - } - - //--------------------------------------------------------------------------------------------------------- - void CreateIfNotExist( const ::rtl::OUString& sName ) - { - IMPL_TViewHash::iterator pItem = m_aList.find( sName ); - if( pItem == m_aList.end() ) - { - IMPL_TViewData aData; - Add( sName, aData ); - // Don't work on list "m_lAdded/m_lChanged ..."! - - // Add() do it automaticly for us! - } - } - - //--------------------------------------------------------------------------------------------------------- - void Free() - { - IMPL_TViewHash().swap ( m_aList ); - IMPL_TStringList().swap( m_lAdded ); - IMPL_TStringList().swap( m_lChanged ); - IMPL_TStringList().swap( m_lDeleted ); - } - - //--------------------------------------------------------------------------------------------------------- - const IMPL_TStringList& GetAddedList () const { return m_lAdded ; } - const IMPL_TStringList& GetChangedList() const { return m_lChanged; } - const IMPL_TStringList& GetDeletedList() const { return m_lDeleted; } - - private: - IMPL_TViewHash m_aList ; - IMPL_TStringList m_lAdded ; - IMPL_TStringList m_lChanged ; - IMPL_TStringList m_lDeleted ; -}; - /*-************************************************************************************************************//** - @descr Implement base data container for view options elements. - Every item knows "OwnData", "UserData" and "AnyData". So - we can implement last two topics in baseclass .. and first one - in different superclasses of them in a special case. + @descr Implement base data container for view options elements. + Every item support ALL possible configuration informations. + But not every superclass should use them! Because some view types don't + have it realy. + + @attention We implement a write-througt-cache! We use it for reading - but write all changes directly to + configuration. (changes are made on internal cache too!). So it's easier to distinguish + between added/changed/removed elements without any complex mask or bool flag informations. + Caches from configuration and our own one are synchronized every time - if we do so. *//*-*************************************************************************************************************/ class SvtViewOptionsBase_Impl : public ::utl::ConfigItem { @@ -480,7 +326,7 @@ class SvtViewOptionsBase_Impl : public ::utl::ConfigItem virtual ~SvtViewOptionsBase_Impl ( ); virtual void Notify ( const css::uno::Sequence< ::rtl::OUString >& lNames ); virtual void Commit ( ); - sal_Bool Exists ( const ::rtl::OUString& sName ) const; + sal_Bool Exists ( const ::rtl::OUString& sName ); sal_Bool Delete ( const ::rtl::OUString& sName ); ::rtl::OUString GetWindowState ( const ::rtl::OUString& sName ); void SetWindowState ( const ::rtl::OUString& sName , @@ -494,18 +340,29 @@ class SvtViewOptionsBase_Impl : public ::utl::ConfigItem sal_Bool GetVisible ( const ::rtl::OUString& sName ); void SetVisible ( const ::rtl::OUString& sName , sal_Bool bVisible ); - css::uno::Any GetUserItem ( const ::rtl::OUString& sName ) const; + css::uno::Any GetUserItem ( const ::rtl::OUString& sName , + const ::rtl::OUString& sItem ); void SetUserItem ( const ::rtl::OUString& sName , + const ::rtl::OUString& sItem , const css::uno::Any& aValue ); //------------------------------------------------------------------------------------------------------------- private: - void impl_ReadWholeList(); + void impl_ReadWholeList ( ); // fill internal cache with saved information from configuration + void impl_createEmptySetNode( const ::rtl::OUString& sNode ); // create an empty view item on disk + void impl_writeDirectProp ( const ::rtl::OUString& sNode , // change one property of specified view item on disk + const ::rtl::OUString& sProp , + const void* pValue ); //------------------------------------------------------------------------------------------------------------- private: - IMPL_TViewList m_aList ; - ::rtl::OUString m_sListName ; + IMPL_TViewHash m_aList ; + ::rtl::OUString m_sListName ; + + #ifdef DEBUG_VIEWOPTIONS + sal_Int32 m_nReadCount ; + sal_Int32 m_nWriteCount ; + #endif }; /*-************************************************************************************************************//** @@ -513,30 +370,36 @@ class SvtViewOptionsBase_Impl : public ::utl::ConfigItem *//*-*************************************************************************************************************/ /*-************************************************************************************************************//** - @short ctor - @descr We use it to open right configuration file and let configuration objects fill her caches. - Then we read all existing entries from right list and cached it inside our object too. - Normaly we should enable notifications for changes on these values too ... but these feature - isn't full implemented in the moment. + @short ctor + @descr We use it to open right configuration file and let configuration objects fill her caches. + Then we read all existing entries from right list and cached it inside our object too. + Normaly we should enable notifications for changes on these values too ... but these feature + isn't full implemented in the moment. + + @seealso baseclass ::utl::ConfigItem + @seealso method Notify() - @seealso baseclass ::utl::ConfigItem - @seealso method Notify() + @param - + @return - - @param - - @return - + @last change 19.10.2001 07:54 *//*-*************************************************************************************************************/ SvtViewOptionsBase_Impl::SvtViewOptionsBase_Impl( const ::rtl::OUString& sList ) - : ConfigItem ( sList ) // open right configuration file - , m_sListName( sList ) + : ConfigItem ( sList ) // open right configuration file + , m_sListName ( sList ) // we must know, which view type we must support + #ifdef DEBUG_VIEWOPTIONS + , m_nReadCount ( 0 ) + , m_nWriteCount( 0 ) + #endif { // Read complete list from configuration. impl_ReadWholeList(); +/* // Enable notification for our whole set tree! // use "/" to do that! // Attention: If you use current existing entry names to do that - you never get a notification // for new created items!!! -/* css::uno::Sequence< ::rtl::OUString > lNotifyList(1); lNotifyList[0] = ROOTNODE_DIALOGS; ConfigItem::EnableNotification( lNotifyList ); @@ -544,43 +407,52 @@ SvtViewOptionsBase_Impl::SvtViewOptionsBase_Impl( const ::rtl::OUString& sList ) } /*-************************************************************************************************************//** - @short dtor - @descr If something was changed on our internal cached values - baselcass can tell us that by return value - of method "IsModified()". So we should flush these changes by calling "Commit()" of our own instance. - It's an auto-save. Normaly user of these object should do that explicitly! + @short dtor + @descr If something was changed on our internal cached values - baselcass can tell us that by return value + of method "IsModified()". So we should flush these changes by calling "Commit()" of our own instance. + It's an auto-save. Normaly user of these object should do that explicitly! - @attention Don't forget to call "SetModified()" method of baseclass, if any interface methods of these object - change internal values. Otherwise nothing will be written to configuration! + @attention We implement a write through cache! So we mustn't do it realy. All changes was written to cfg directly. + Commit isn't neccessary then. - @seealso baseclass ::utl::ConfigItem - @seealso method IsModified() - @seealso method SetModified() - @seealso method Commit() + @seealso baseclass ::utl::ConfigItem + @seealso method IsModified() + @seealso method SetModified() + @seealso method Commit() - @param - - @return - + @param - + @return - + + @last change 19.10.2001 08:02 *//*-*************************************************************************************************************/ SvtViewOptionsBase_Impl::~SvtViewOptionsBase_Impl() { + #ifdef DEBUG_VIEWOPTIONS + _LOG_COUNTER_( m_sListName, m_nReadCount, m_nWriteCount ) + #endif // DEBUG_VIEWOPTIONS +/* if( ConfigItem::IsModified() == sal_True ) { Commit(); } +*/ } /*-************************************************************************************************************//** - @short configuration use it to notify external changes on our interessted values - @descr If anywhere change configuration values otside these class - configuration tell it us by calling - these method. To use these mechanism - we must enable it during our own ctor. See there for further - informations. + @short configuration use it to notify external changes on our interessted values + @descr If anywhere change configuration values otside these class - configuration tell it us by calling + these method. To use these mechanism - we must enable it during our own ctor. See there for further + informations. + + @attention Not supported in the moment! - @attention Not supported in the moment! + @seealso ctor + @seealso method EnableNotification() - @seealso ctor - @seealso method EnableNotification() + @param "lNames", names of all changed configuration entries or her subnodes + @return - - @param "lNames", names of all changed configuration entries or her subnodes - @return - + @last change 19.10.2001 08:02 *//*-*************************************************************************************************************/ void SvtViewOptionsBase_Impl::Notify( const css::uno::Sequence< ::rtl::OUString >& lNames ) { @@ -588,461 +460,579 @@ void SvtViewOptionsBase_Impl::Notify( const css::uno::Sequence< ::rtl::OUString } /*-************************************************************************************************************//** - @short write changed internal values to configuration - @descr If our internal values are changed - we should flush it to configuration file. + @short write changed internal values to configuration + @descr If our internal values are changed - we should flush it to configuration file. + But - we implement a write-through-cache ... so we mustn't do anything here! + + @seealso dtor + @seealso method IsModified() - @seealso dtor - @seealso method IsModified() + @param - + @return - - @param - - @return - + @last change 19.10.2001 08:02 *//*-*************************************************************************************************************/ void SvtViewOptionsBase_Impl::Commit() { - /* - const IMPL_TStringList& rAddedList = m_aList.GetAddedList (); - const IMPL_TStringList& rChangedList = m_aList.GetChangedList(); - const IMPL_TStringList& rDeletedList = m_aList.GetDeletedList(); - - IMPL_TStringList::const_iterator pItem ; - sal_Int32 nStep = 0; - ::rtl::OUString sPath ; - IMPL_TViewData aItem ; - - // delete some items - if( rDeletedList.size() > 0 ) - { - css::uno::Sequence< ::rtl::OUString > lDeleted( rDeletedList.size() ); - nStep = 0; - for( pItem=rDeletedList.begin(); pItem!=rDeletedList.end(); ++pItem ) - { - lDeleted[nStep] = PATHSEPERATOR; - lDeleted[nStep] += PREFIX; - lDeleted[nStep] += *pItem; - ++nStep; - } - ClearNodeElements( ::rtl::OUString(), lDeleted ); - } - - // add some items - if( rAddedList.size() > 0 ) - { - css::uno::Sequence< css::beans::PropertyValue > lAdded; - nStep = 0; - for( pItem=rAddedList.begin(); pItem!=rAddedList.end(); ++pItem ) - { - sPath = PATHSEPERATOR ; - sPath += PREFIX ; - sPath += *pItem ; - sPath += PATHSEPERATOR ; - - m_aList.Find( *pItem, aItem ); - - lAdded.realloc( lAdded.getLength()+1 ); - lAdded[nStep].Name = sPath + PROPERTY_WINDOWSTATE; - lAdded[nStep].Value <<= aItem.GetWindowState(); - ++nStep; - - if( m_sListName == LIST_TABDIALOGS ) - { - lAdded.realloc( lAdded.getLength()+1 ); - lAdded[nStep].Name = sPath + PROPERTY_PAGEID; - lAdded[nStep].Value <<= aItem.GetPageID(); - ++nStep; - } - - if( m_sListName == LIST_WINDOWS ) - { - lAdded.realloc( lAdded.getLength()+1 ); - lAdded[nStep].Name = sPath + PROPERTY_VISIBLE; - lAdded[nStep].Value <<= aItem.GetVisible(); - ++nStep; - } - - css::uno::Sequence< css::beans::NamedValue > lUserData = aItem.GetUserData(); - sal_Int32 nUserCount = lUserData.getLength(); - if( nUserCount > 0 ) - { - lAdded.realloc( lAdded.getLength()+nUserCount ); - } - for( sal_Int32 nUserStep=0; nUserStep<nUserCount; ++nUserStep ) - { - lAdded[nStep].Name = sPath + lUserData[nUserStep].Name ; - lAdded[nStep].Value = lUserData[nUserStep].Value ; - ++nStep; - } - } - ConfigItem::SetSetProperties( ::rtl::OUString(), lAdded ); - } - - // change some items - if( rChangedList.size() > 0 ) - { - css::uno::Sequence< css::beans::PropertyValue > lChanged; - nStep = 0; - for( pItem=rChangedList.begin(); pItem!=rChangedList.end(); ++pItem ) - { - sPath = PATHSEPERATOR ; - sPath += PREFIX ; - sPath += *pItem ; - sPath += PATHSEPERATOR ; - - m_aList.Find( *pItem, aItem ); - - if( aItem.IsChanged( CHANGED_WINDOWSTATE ) == sal_True ) - { - lChanged.realloc( lChanged.getLength()+1 ); - lChanged[nStep].Name = sPath + PROPERTY_WINDOWSTATE; - lChanged[nStep].Value <<= aItem.GetWindowState(); - ++nStep; - } - - if( - ( m_sListName == LIST_TABDIALOGS ) && - ( aItem.IsChanged( CHANGED_PAGEID ) == sal_True ) - ) - { - lChanged.realloc( lChanged.getLength()+1 ); - lChanged[nStep].Name = sPath + PROPERTY_PAGEID; - lChanged[nStep].Value <<= aItem.GetPageID(); - ++nStep; - } - - if( - ( m_sListName == LIST_WINDOWS ) && - ( aItem.IsChanged( CHANGED_VISIBLE ) == sal_True ) - ) - { - lChanged.realloc( lChanged.getLength()+1 ); - lChanged[nStep].Name = sPath + PROPERTY_VISIBLE; - lChanged[nStep].Value <<= aItem.GetVisible(); - ++nStep; - } - - if( aItem.IsChanged( CHANGED_USERDATA ) == sal_True ) - { - css::uno::Sequence< css::beans::NamedValue > lUserData = aItem.GetUserData(); - sal_Int32 nUserCount = lUserData.getLength(); - for( sal_Int32 nUserStep=0; nUserStep<nUserCount; ++nUserStep ) - { - lChanged.realloc( lChanged.getLength()+1 ); - lChanged[nStep].Name = sPath + lUserData[nUserStep].Name ; - lChanged[nStep].Value = lUserData[nUserStep].Value ; - ++nStep; - } - } - } - ConfigItem::SetSetProperties( ::rtl::OUString(), lChanged ); - } - */ } /*-************************************************************************************************************//** - @short checks for already existing entries - @descr If user don't know, if an entry already exist - he can get this information by calling this method. - Otherwhise access (read access is enough!) will create it with default values! + @short checks for already existing entries + @descr If user don't know, if an entry already exist - he can get this information by calling this method. + Otherwhise access (read access is enough!) will create it with default values! + But these default items exist at runtime in our cache only. They are written to disk only, if + user change her values realy. + + @seealso member m_aList - @seealso member m_aList + @param "sName", name of entry to check exist state + @return true , if item exist + false, otherwise - @param "sName", name of entry to check exist state - @return true , if item exist - false, otherwise + @last change 19.10.2001 08:02 *//*-*************************************************************************************************************/ -sal_Bool SvtViewOptionsBase_Impl::Exists( const ::rtl::OUString& sName ) const +sal_Bool SvtViewOptionsBase_Impl::Exists( const ::rtl::OUString& sName ) { - return( m_aList.Exists( sName ) ); + return( m_aList.find(sName) != m_aList.end() ); } /*-************************************************************************************************************//** - @short delete entry - @descr Use it to delete set entry by given name. + @short delete entry + @descr Use it to delete set entry by given name. - @seealso member m_aList + @seealso member m_aList - @param "sName", name of entry to delete it - @return true , if item not exist(!) or could be deleted - false, otherwise + @param "sName", name of entry to delete it + @return true , if item not exist(!) or could be deleted (should be the same!) + false, otherwise + + @last change 19.10.2001 08:05 *//*-*************************************************************************************************************/ sal_Bool SvtViewOptionsBase_Impl::Delete( const ::rtl::OUString& sName ) { - // Set default return value to "element no longer exist"! - // It doesnt matter for user if element not exist or was deleted! - // Not exist is not exist is ... - sal_Bool bDeleteState = sal_True; + #ifdef DEBUG_VIEWOPTIONS + ++m_nWriteCount; + #endif - if( m_aList.Exists( sName ) == sal_True ) + IMPL_TViewHash::iterator pItem = m_aList.find(sName); + if( pItem != m_aList.end() ) { - bDeleteState = ConfigItem::ClearNodeSet( sName ); - if( bDeleteState == sal_True ) - { - m_aList.Remove( sName ); - ConfigItem::SetModified(); - } + m_aList.erase( pItem ); + ConfigItem::ClearNodeSet( ::utl::wrapConfigurationElementName(sName) ); } - return bDeleteState; + return sal_True; } /*-************************************************************************************************************//** - @short - - @descr - + @short read/write access to cache view items and her properties + @descr Follow methods support read/write access to all cache view items. + If an entry doesnt exist - we create a new one with default values in memory ... not in disk! + If user change values of it - we take into our internal cache AND write it to configuration + instandly! + + @seealso member m_sList - @seealso - + @param - + @return - - @param - - @return - + @last change 19.10.2001 08:33 *//*-*************************************************************************************************************/ ::rtl::OUString SvtViewOptionsBase_Impl::GetWindowState( const ::rtl::OUString& sName ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - m_aList.Find( sName, aData ); - return aData.GetWindowState(); -} - -/*-************************************************************************************************************//** - @short - - @descr - + #ifdef DEBUG_VIEWOPTIONS + ++m_nReadCount; + #endif - @seealso - + return m_aList[sName].getWindowState(); +} - @param - - @return - -*//*-*************************************************************************************************************/ +//***************************************************************************************************************** void SvtViewOptionsBase_Impl::SetWindowState( const ::rtl::OUString& sName , const ::rtl::OUString& sState ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - aData.SetWindowState( sState, sal_True ); - m_aList.Change( sName, aData, CHANGED_WINDOWSTATE, sal_True ); - ConfigItem::SetModified(); -} - -/*-************************************************************************************************************//** - @short returns user data list - @descr These method returns the user data list. If entry given by "sName" doesn't already exist - we create - a new one with default values! - So it could be neccessary to call "Exist()" before. + #ifdef DEBUG_VIEWOPTIONS + ++m_nWriteCount; + #endif - @seealso method impl_CreateIfNotExist() - @seealso member m_aList + if( m_aList[sName].getWindowState() != sState ) + { + m_aList[sName].setWindowState( sState ); + impl_writeDirectProp( sName, PROPERTY_WINDOWSTATE, (void*)&sState ); + } +} - @param "sName", name of entry which include property "UserData" - @return Valid or empty list as default! -*//*-*************************************************************************************************************/ +//***************************************************************************************************************** css::uno::Sequence< css::beans::NamedValue > SvtViewOptionsBase_Impl::GetUserData( const ::rtl::OUString& sName ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - m_aList.Find( sName, aData ); - return aData.GetUserData(); -} - -/*-************************************************************************************************************//** - @short set new user data list - @descr These method set the new user data list. If entry given by "sName" doesn't already exist - we create - a new one with default values! - So it could be neccessary to call "Exist()" before. + #ifdef DEBUG_VIEWOPTIONS + ++m_nReadCount; + #endif - @seealso method impl_CreateIfNotExist() - @seealso member m_aList + return m_aList[sName].getUserData(); +} - @param "sName", name of entry which include property "UserData" - @param "lData", new value of property - @return - -*//*-*************************************************************************************************************/ +//***************************************************************************************************************** void SvtViewOptionsBase_Impl::SetUserData( const ::rtl::OUString& sName , const css::uno::Sequence< css::beans::NamedValue >& lData ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - aData.SetUserData( lData, sal_True ); - m_aList.Change( sName, aData, CHANGED_USERDATA, sal_True ); - ConfigItem::SetModified(); + #ifdef DEBUG_VIEWOPTIONS + ++m_nWriteCount; + #endif + + if( m_aList[sName].getUserData() != lData ) + { + m_aList[sName].setUserData( lData ); + + // User data are special properties of a view item. + // They are a subset of a set entry in configuration. + // Normaly a set entry is FULL created with default values, + // if any fixed property of them is written. But subsets + // couldnt be created so easy. That's why we must + // check for default items ( they shouldnt exist on disk ... !) + // but they must be created, if we whish to set new real value on + // UserData!!! + if( m_aList[sName].isDefault() == sal_False ) + { + impl_createEmptySetNode( sName ); + } + + impl_writeDirectProp( sName, PROPERTY_USERDATA, &lData ); + } } -css::uno::Any SvtViewOptionsBase_Impl::GetUserItem( const ::rtl::OUString& sName ) const +//***************************************************************************************************************** +css::uno::Any SvtViewOptionsBase_Impl::GetUserItem( const ::rtl::OUString& sName , + const ::rtl::OUString& sItem ) { - return css::uno::Any(); + #ifdef DEBUG_VIEWOPTIONS + ++m_nReadCount; + #endif + + return m_aList[sName].getUserItem(sItem); } +//***************************************************************************************************************** void SvtViewOptionsBase_Impl::SetUserItem( const ::rtl::OUString& sName , + const ::rtl::OUString& sItem , const css::uno::Any& aValue ) { + #ifdef DEBUG_VIEWOPTIONS + ++m_nWriteCount; + #endif + + if( m_aList[sName].getUserItem(sItem) != aValue ) + { + // User data are special properties of a view item. + // They are a subset of a set entry in configuration. + // Normaly a set entry is FULL created with default values, + // if any fixed property of them is written. But subsets + // couldnt be created so easy. That's why we must + // check for default items ( they shouldnt exist on disk ... !) + // but they must be created, if we whish to set new real value on + // UserData!!! + if( m_aList[sName].isDefault() == sal_True ) + { + impl_createEmptySetNode( sName ); + } + + m_aList[sName].setUserItem(sItem, aValue); + const css::uno::Sequence< css::beans::NamedValue > lData = m_aList[sName].getUserData(); + impl_writeDirectProp( sName, PROPERTY_USERDATA, &lData ); + } } +//***************************************************************************************************************** sal_Int32 SvtViewOptionsBase_Impl::GetPageID( const ::rtl::OUString& sName ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - m_aList.Find( sName, aData ); - return aData.GetPageID(); + #ifdef DEBUG_VIEWOPTIONS + ++m_nReadCount; + #endif + + return m_aList[sName].getPageID(); } +//***************************************************************************************************************** void SvtViewOptionsBase_Impl::SetPageID( const ::rtl::OUString& sName , sal_Int32 nID ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - aData.SetPageID( nID, sal_True ); - m_aList.Change( sName, aData, CHANGED_PAGEID, sal_True ); - ConfigItem::SetModified(); + #ifdef DEBUG_VIEWOPTIONS + ++m_nWriteCount; + #endif + + if( m_aList[sName].getPageID() != nID ) + { + m_aList[sName].setPageID( nID ); + impl_writeDirectProp( sName, PROPERTY_PAGEID, &nID ); + } } +//***************************************************************************************************************** sal_Bool SvtViewOptionsBase_Impl::GetVisible( const ::rtl::OUString& sName ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - m_aList.Find( sName, aData ); - return aData.GetVisible(); + #ifdef DEBUG_VIEWOPTIONS + ++m_nReadCount; + #endif + + return m_aList[sName].getVisible(); } +//***************************************************************************************************************** void SvtViewOptionsBase_Impl::SetVisible( const ::rtl::OUString& sName , sal_Bool bVisible ) { - m_aList.CreateIfNotExist( sName ); - IMPL_TViewData aData; - aData.SetVisible( bVisible, sal_True ); - m_aList.Change( sName, aData, CHANGED_VISIBLE, sal_True ); - ConfigItem::SetModified(); + #ifdef DEBUG_VIEWOPTIONS + ++m_nWriteCount; + #endif + + if( m_aList[sName].getVisible() != bVisible ) + { + m_aList[sName].setVisible( bVisible ); + impl_writeDirectProp( sName, PROPERTY_VISIBLE, &bVisible ); + } } /*-************************************************************************************************************//** - @short read complete configuration list - @descr These methods try to get all entries of right configuration list and fill it in our internal - structures. To support reading of unknown properties (which are additional ones by superclass!) - we call pure virtual function. Programmer can override it to add his own entry names. + @short read complete configuration list + @descr These methods try to get all entries of right configuration list and fill it in our internal + cache. - @seealso impl_AddOwnProperties() + @seealso member m_aList + @seealso baseclass ConfigItem - @param - - @return - + @param - + @return - + + @last change 19.10.2001 08:34 *//*-*************************************************************************************************************/ void SvtViewOptionsBase_Impl::impl_ReadWholeList() { - /* - // Clear internal cache - m_aList.Free(); + // Clear internal cache first! + // This is the only way to clear all memory realy! + IMPL_TViewHash().swap( m_aList ); + + sal_Bool bBreaked = sal_False; // We check some invalid operation states during execution of these method. + // If we found anyone - we set this value to TRUE. On the end we react + // to this state by freeing internal cached values and warn programmer ... - css::uno::Sequence< ::rtl::OUString > lNames = ConfigItem::GetNodeNames( ::rtl::OUString() ); + css::uno::Sequence< ::rtl::OUString > lNames = ConfigItem::GetNodeNames( ::rtl::OUString(), ::utl::CONFIG_NAME_LOCAL_PATH ); sal_Int32 nNameCount = lNames.getLength(); sal_Int32 nAllCount = 0; - if( m_sListName == LIST_DIALOGS ) - nAllCount = nNameCount*PROPCOUNT_DIALOGS; - else - if( m_sListName == LIST_TABDIALOGS ) - nAllCount = nNameCount*PROPCOUNT_TABDIALOGS; - else - if( m_sListName == LIST_TABPAGES ) - nAllCount = nNameCount*PROPCOUNT_TABPAGES; - else - if( m_sListName == LIST_WINDOWS ) - nAllCount = nNameCount*PROPCOUNT_WINDOWS; - - css::uno::Sequence< ::rtl::OUString > lAllNames( nAllCount ); - sal_Int32 nAllStep = 0 ; - ::rtl::OUString sPath ; - - for( sal_Int32 nNameStep=0; nNameStep<nNameCount; ++nNameStep ) + // Do nothing for empty lists! + if( nNameCount > 0 ) { - sPath = lNames[nNameStep] ; - sPath += PATHSEPERATOR ; + // Calculate count of fix properties for current list entries. + // So we save time by suppress reallocating of name sequence! + if( m_sListName == LIST_DIALOGS ) + nAllCount = nNameCount*PROPCOUNT_DIALOGS; + else + if( m_sListName == LIST_TABDIALOGS ) + nAllCount = nNameCount*PROPCOUNT_TABDIALOGS; + else + if( m_sListName == LIST_TABPAGES ) + nAllCount = nNameCount*PROPCOUNT_TABPAGES; + else + if( m_sListName == LIST_WINDOWS ) + nAllCount = nNameCount*PROPCOUNT_WINDOWS; - lAllNames[nAllStep] = sPath + PROPERTY_WINDOWSTATE; - ++nAllStep; + css::uno::Sequence< ::rtl::OUString > lAllNames( nAllCount ); + sal_Int32 nAllStep = 0 ; + ::rtl::OUString sPath ; - if( m_sListName == LIST_TABDIALOGS ) + for( sal_Int32 nNameStep=0; nNameStep<nNameCount; ++nNameStep ) { - lAllNames[nAllStep] = sPath + PROPERTY_PAGEID; - ++nAllStep; - } + // sPath = "*[xxx]/" + sPath = lNames[nNameStep] ; + sPath += PATHSEPERATOR ; - if( m_sListName == LIST_WINDOWS ) - { - lAllNames[nAllStep] = sPath + PROPERTY_VISIBLE; + // sPath = "*[xxx]/" + // lAllNames = "*[xxx]/WindowState" + lAllNames[nAllStep] = sPath + PROPERTY_WINDOWSTATE; ++nAllStep; - } - sPath += PROPERTY_USERDATA; - css::uno::Sequence< ::rtl::OUString > lUserNames = ConfigItem::GetNodeNames( sPath ); - sal_Int32 nUserCount = lUserNames.getLength(); - sPath += PATHSEPERATOR; - for( sal_Int32 nUserStep=0; nUserStep<nUserCount; ++nUserStep ) - { - lAllNames[nAllStep] = sPath + lUserNames[nUserStep]; - ++nAllStep; - } - } + if( m_sListName == LIST_TABDIALOGS ) + { + // sPath = "*[xxx]/" + // lAllNames = "*[xxx]/PageID" + lAllNames[nAllStep] = sPath + PROPERTY_PAGEID; + ++nAllStep; + } + + if( m_sListName == LIST_WINDOWS ) + { + // sPath = "*[xxx]/" + // lAllNames = "*[xxx]/Visible" + lAllNames[nAllStep] = sPath + PROPERTY_VISIBLE; + ++nAllStep; + } - css::uno::Sequence< css::uno::Any > lAllValues = ConfigItem::GetProperties( lAllNames ); + // Handle "UserData" in a variable way. The could exist - but the must'nt! + // sPath = "*[xxx]/UserData" + sPath += PROPERTY_USERDATA; + css::uno::Sequence< ::rtl::OUString > lUserNames = ConfigItem::GetNodeNames( sPath, ::utl::CONFIG_NAME_LOCAL_PATH ); + sal_Int32 nUserCount = lUserNames.getLength(); + // sPath = "*[xxx]/UserData/" + sPath += PATHSEPERATOR; - // Safe impossible cases. - // We have asked for ALL our subtree keys and we would get all his values. - // It's important for next loop and our index using! - OSL_ENSURE( !(lAllNames.getLength()!=lAllValues.getLength()), "SvtViewDialogOptions_Impl::impl_ReadWholeList()\nMiss some configuration values for view set!\n" ); - - // step over both lists (name and value) and insert corresponding pairs into internal cache - ::rtl::OUString sEntryName ; - ::rtl::OUString sPropertyName ; - ::rtl::OUString sUserName ; - ::rtl::OUString sTemp ; - sal_Int32 nToken ; - IMPL_TViewData aEntry ; - nAllStep = 0; - - while( nAllStep<nAllCount ) - { - nToken = 0; - sEntryName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); - sEntryName = sEntryName.copy( PREFIXLENGTH ); - sPropertyName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); + // Reallocate name sequence, if any usre data was found and actualize nAllCount too! + // These value is neccessary to find end of name and corresponding value list after reading values from configuration. + if( nUserCount > 0 ) + { + nAllCount += nUserCount; + lAllNames.realloc( nAllCount ); + } - if( sPropertyName == PROPERTY_WINDOWSTATE ) - { - ::rtl::OUString sValue = DEFAULT_WINDOWSTATE; - lAllValues[nAllStep] >>= sValue; - ++nAllStep; - aEntry.SetWindowState( sValue, sal_False ); - } - else - if( sPropertyName == PROPERTY_PAGEID ) - { - sal_Int32 nValue = DEFAULT_PAGEID; - lAllValues[nAllStep] >>= nValue; - ++nAllStep; - aEntry.SetPageID( nValue, sal_False ); + for( sal_Int32 nUserStep=0; nUserStep<nUserCount; ++nUserStep ) + { + // sPath = "v_xxx/UserData/" + // lAllNames = "v_xxx/UserData/<userprop>" + lAllNames[nAllStep] = sPath + lUserNames[nUserStep]; + ++nAllStep; + } } - else - if( sPropertyName == PROPERTY_VISIBLE ) + + // Use builded list of full qualified names to get her values in corresponding list. + css::uno::Sequence< css::uno::Any > lAllValues = ConfigItem::GetProperties( lAllNames ); + + // Safe impossible cases. + // We have asked for ALL our subtree keys and we would get all his values. + // It's important for next loop and our index using! + if( lAllNames.getLength()!=lAllValues.getLength() ) { - sal_Bool bValue = DEFAULT_VISIBLE; - lAllValues[nAllStep] >>= bValue; - ++nAllStep; - aEntry.SetVisible( bValue, sal_False ); + bBreaked = sal_True; } else - if( sPropertyName == PROPERTY_USERDATA ) { - css::uno::Sequence< css::beans::NamedValue > lData; - while( sPropertyName == PROPERTY_USERDATA ) + // step over both lists (name and value) and insert corresponding pairs into internal cache + ::rtl::OUString sEntryName ; + ::rtl::OUString sPropertyName ; + ::rtl::OUString sUserName ; + ::rtl::OUString sTemp ; + sal_Int32 nToken ; + IMPL_TViewData aEntry ; + nAllStep = 0; + + while( nAllStep<nAllCount ) { - sUserName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); - css::uno::Any aUserValue; - lAllValues[nAllStep] >>= aUserValue; - aEntry.AddOrReplaceUserItem( sUserName, aUserValue, sal_False ); - - ++nAllStep; - nToken = 0; + // lAllNames = "v_<entryname>/<propertyname[/<username>]>" + // ... get "v_<entryname>" from lAllNames + // ... extract "<entryname>" from sEntryName sEntryName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); + sEntryName = ::utl::extractFirstFromConfigurationPath(sEntryName); + + if( + ( nToken < 0 ) || // nToken must be different from -1 ... because we search for sPropertyName in next line! + ( sEntryName.getLength() < 1 ) // An entry name is neccessary! We can't work with nothing. + ) + { + bBreaked = sal_True; + break; + } + + // ... get "<propertyname>" from lAllNames sPropertyName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); + + if( sPropertyName.getLength() < 1 ) + { + // We must have a valid propertyname ... Otherwise we search value for "nothing"! + // Don't check nToken here - he could be -1 for fix properties ... but he could + // be >0 for UserData! Then exist some subnodes which should be readed! + bBreaked = sal_True; + break; + } + + if( sPropertyName == PROPERTY_WINDOWSTATE ) + { + ::rtl::OUString sTemp; + lAllValues[nAllStep] >>= sTemp; + aEntry.setWindowState( sTemp ); + ++nAllStep; + + } + else + if( sPropertyName == PROPERTY_PAGEID ) + { + sal_Int32 nTemp; + lAllValues[nAllStep] >>= nTemp; + aEntry.setPageID( nTemp ); + ++nAllStep; + } + else + if( sPropertyName == PROPERTY_VISIBLE ) + { + sal_Bool bTemp; + lAllValues[nAllStep] >>= bTemp; + aEntry.setVisible(bTemp); + ++nAllStep; + } + else + if( sPropertyName == PROPERTY_USERDATA ) + { + while( sPropertyName == PROPERTY_USERDATA ) + { + // ... extract "<username>" from sEntryName! + sUserName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); + sUserName = ::utl::extractFirstFromConfigurationPath(sUserName); + aEntry.setUserItem( sUserName, lAllValues[nAllStep] ); + + ++nAllStep; + + if( nAllStep >= nAllCount ) + break; + + // starte new search for entry and property names. + // a) + // If next entry in lAllNames is a fix property - these search will be superflous but + // not dangerous. Because we start search on the beginning of these while-construct again. + // But don't change nAllStep AFTER these lines. You must use SAME entry there! + // b) + // If next entry is an UserData node - we get sPropertyName==PROPERTY_USERDATA! + // So these "sub-while-construct" starts again to read next UserData entry ... + nToken = 0; + sEntryName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); + sEntryName = ::utl::extractFirstFromConfigurationPath(sEntryName); + sPropertyName = lAllNames[nAllStep].getToken( 0, (sal_Unicode)'/', nToken ); + } + } + else + { + // There exist any unknown subnode as fix property. + // We can't handle these case ... so we should break operation! + bBreaked = sal_True; + break; + } + + m_aList[sEntryName] = aEntry; + } + } + } + + // If read operation was cancelled by any error - show a message for programmer and + // clear internal caches. We can't decide between incomplete, wrong or right values. + // So we should start with empty lists! + if( bBreaked == sal_True ) + { + OSL_ENSURE( sal_False, "SvtViewOptionsBase_Impl::impl_ReadWholeList()\nBreak reading completly. Unsupported configuration format found!\n" ); + IMPL_TViewHash().swap( m_aList ); + // A possible solution: SELF REPAIR! + // Delete configuration entries in file too ... + // It's hard - but could solve many problems. + // Otherwhise these errors occure again and again and ... + ConfigItem::ClearNodeSet( ::rtl::OUString() ); + } +} + +/*-************************************************************************************************************//** + @short create new set node with default values on disk + @descr To create a new UserData item - the super node of these property must already exist! + You can call this method to create these new entry with default values and change UserData then. + + @seealso method impl_writeDirectProp() + + @param "sNode", name of new entry + @return - + + @last change 19.10.2001 08:42 +*//*-*************************************************************************************************************/ +void SvtViewOptionsBase_Impl::impl_createEmptySetNode( const ::rtl::OUString& sNode ) +{ + css::uno::Sequence< css::beans::PropertyValue > lProps(1); + ::rtl::OUString sPath ; + + sPath += ::utl::wrapConfigurationElementName(sNode); + sPath += PATHSEPERATOR ; + + lProps[0].Name = sPath + PROPERTY_WINDOWSTATE; + lProps[0].Value <<= DEFAULT_WINDOWSTATE ; + + if( m_sListName == LIST_TABDIALOGS ) + { + lProps.realloc( lProps.getLength()+1 ); + lProps[lProps.getLength()-1].Name = sPath + PROPERTY_PAGEID ; + lProps[lProps.getLength()-1].Value <<= (sal_Int32)DEFAULT_PAGEID; + } + + if( m_sListName == LIST_WINDOWS ) + { + lProps.realloc( lProps.getLength()+1 ); + lProps[lProps.getLength()-1].Name = sPath + PROPERTY_VISIBLE ; + lProps[lProps.getLength()-1].Value <<= DEFAULT_VISIBLE ; + } + + ConfigItem::SetSetProperties( ::rtl::OUString(), lProps ); +} + +/*-************************************************************************************************************//** + @short write one property of a view entry in cfg + @descr These write direct to configuration and change value of a view property. + + @seealso method impl_createEmptySetNode() + + @param "sNode" , name of new entry + @param "sProp" , name of property to change + @param "pValue", value of these property (real type depends on given property name) + @return - + + @last change 19.10.2001 08:44 +*//*-*************************************************************************************************************/ +void SvtViewOptionsBase_Impl::impl_writeDirectProp( const ::rtl::OUString& sNode , + const ::rtl::OUString& sProp , + const void* pValue ) +{ + ::rtl::OUStringBuffer sPath(100); + sPath.append( ::utl::wrapConfigurationElementName(sNode)); + sPath.append( PATHSEPERATOR ); + sPath.append( sProp ); + + css::uno::Sequence< css::beans::PropertyValue > lProp(1); + if( sProp == PROPERTY_WINDOWSTATE ) + { + lProp[0].Name = sPath.makeStringAndClear(); + lProp[0].Value <<= *((const ::rtl::OUString*)pValue); + ConfigItem::SetSetProperties( ::rtl::OUString(), lProp ); + } + else + if( sProp == PROPERTY_PAGEID ) + { + lProp[0].Name = sPath.makeStringAndClear(); + lProp[0].Value <<= *((const sal_Int32*)pValue); + ConfigItem::SetSetProperties( ::rtl::OUString(), lProp ); + } + else + if( sProp == PROPERTY_VISIBLE ) + { + lProp[0].Name = sPath.makeStringAndClear(); + lProp[0].Value <<= *((const sal_Bool*)pValue); + ConfigItem::SetSetProperties( ::rtl::OUString(), lProp ); + } + else + if( sProp == PROPERTY_USERDATA ) + { + ::rtl::OUString sBasePath = sPath.makeStringAndClear(); + + const css::uno::Sequence< css::beans::NamedValue>* pData = (css::uno::Sequence< css::beans::NamedValue>*)pValue; + sal_Int32 nCount = pData->getLength(); + sal_Int32 nStep = 0; + lProp.realloc(nCount); + while( nStep<nCount ) + { + if( (*pData)[nStep].Value.hasValue() == sal_False ) + { + OSL_ENSURE( sal_False, "SvtViewOptionsBase_Impl::impl_writeDirectProp()\nCan't write UserData item with void-any as value!!! Item will be ignored ...\n" ); + --nCount; + lProp.realloc(nCount); + } + else + { + lProp[nStep].Name = sBasePath + PATHSEPERATOR + ::utl::wrapConfigurationElementName( (*pData)[nStep].Name ); + lProp[nStep].Value = (*pData)[nStep].Value; + ++nStep; } } - m_aList.Add( sEntryName, aEntry ); + ConfigItem::ReplaceSetProperties( sBasePath, lProp ); } - */ } //_________________________________________________________________________________________________________________ @@ -1377,16 +1367,8 @@ void SvtViewOptions::SetVisible( sal_Bool bState ) } //***************************************************************************************************************** -/* -#ifdef TF_OLDVIEW -css::uno::Sequence< css::beans::NamedValue > SvtViewOptions::GetUserData( sal_Bool bMakeItDifferent ) const -{ - OSL_ENSURE( !(bMakeItDifferent==sal_False), "SvtViewOptions::GetUserData()\nYour code isn't compatible! You use a default parameter without any reason ...\n" ); -#else -*/ css::uno::Sequence< css::beans::NamedValue > SvtViewOptions::GetUserData() const { -//#endif // Ready for multithreading ::osl::MutexGuard aGuard( GetOwnStaticMutex() ); @@ -1443,235 +1425,61 @@ void SvtViewOptions::SetUserData( const css::uno::Sequence< css::beans::NamedVal //***************************************************************************************************************** css::uno::Any SvtViewOptions::GetUserItem( const ::rtl::OUString& sName ) const { - return css::uno::Any(); -} - -//***************************************************************************************************************** -void SvtViewOptions::SetUserItem( const ::rtl::OUString& sName , - const css::uno::Any& aValue ) -{ -} - -/*#ifdef TF_OLDVIEW -//***************************************************************************************************************** -void SvtViewOptions::GetPosition( sal_Int32& nX, sal_Int32& nY ) const -{ + // Ready for multithreading ::osl::MutexGuard aGuard( GetOwnStaticMutex() ); - ::rtl::OUString sWindowState; - + css::uno::Any aItem; switch( m_eViewType ) { case E_DIALOG : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + aItem = m_pDataContainer_Dialogs->GetUserItem( m_sViewName, sName ); } break; case E_TABDIALOG : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + aItem = m_pDataContainer_TabDialogs->GetUserItem( m_sViewName, sName ); } break; case E_TABPAGE : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + aItem = m_pDataContainer_TabPages->GetUserItem( m_sViewName, sName ); } break; case E_WINDOW : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + aItem = m_pDataContainer_Windows->GetUserItem( m_sViewName, sName ); } break; } - - sal_Int32 nToken = 0; - - nX = sWindowState.getToken( 0, (sal_Unicode)',', nToken ).toInt32(); - nY = 0; - if( nToken > 0 ) - { - nY = sWindowState.getToken( 0, (sal_Unicode)',', nToken ).toInt32(); - } + return aItem; } //***************************************************************************************************************** -void SvtViewOptions::SetPosition( sal_Int32 nX, sal_Int32 nY ) -{ - // Not supported ... -} - -//***************************************************************************************************************** -void SvtViewOptions::GetSize( sal_Int32& nWidth, sal_Int32& nHeight ) const +void SvtViewOptions::SetUserItem( const ::rtl::OUString& sName , + const css::uno::Any& aValue ) { + // Ready for multithreading ::osl::MutexGuard aGuard( GetOwnStaticMutex() ); - ::rtl::OUString sWindowState; - switch( m_eViewType ) { case E_DIALOG : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + m_pDataContainer_Dialogs->SetUserItem( m_sViewName, sName, aValue ); } break; case E_TABDIALOG : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + m_pDataContainer_TabDialogs->SetUserItem( m_sViewName, sName, aValue ); } break; case E_TABPAGE : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + m_pDataContainer_TabPages->SetUserItem( m_sViewName, sName, aValue ); } break; case E_WINDOW : { - sWindowState = m_pDataContainer_Dialogs->GetWindowState( m_sViewName ); + m_pDataContainer_Windows->SetUserItem( m_sViewName, sName, aValue ); } break; } - - sal_Int32 nToken = 0; - ::rtl::OUString sTemp ; - - nWidth = 0; - nHeight = 0; - - sTemp = sWindowState.getToken( 0, (sal_Unicode)',', nToken ); - if( nToken > 0 ) - { - sTemp = sWindowState.getToken( 0, (sal_Unicode)',', nToken ); - if( nToken > 0 ) - { - nWidth = sWindowState.getToken( 0, (sal_Unicode)',', nToken ).toInt32(); - if( nToken > 0 ) - { - nHeight = sWindowState.getToken( 0, (sal_Unicode)',', nToken ).toInt32(); - } - } - } -} - -//***************************************************************************************************************** -void SvtViewOptions::SetSize( sal_Int32 nWidth, sal_Int32 nHeight ) -{ - // Not supported ... } //***************************************************************************************************************** -::rtl::OUString SvtViewOptions::GetUserData() const -{ - ::osl::MutexGuard aGuard( GetOwnStaticMutex() ); - css::uno::Sequence< css::beans::NamedValue > lData = GetUserData( sal_True ); - ::rtl::OUString sData; - sal_Int32 nCount = lData.getLength(); - for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) - { - if( lData[nStep].Name == CONST_ASCII("compatibleUserData") ) - { - lData[nStep].Value >>= sData; - break; - } - } - - return sData; -} - -//***************************************************************************************************************** -void SvtViewOptions::SetUserData( const ::rtl::OUString& sData ) -{ - ::osl::MutexGuard aGuard( GetOwnStaticMutex() ); - css::uno::Sequence< css::beans::NamedValue > lData = GetUserData( sal_True ); - sal_Int32 nCount = lData.getLength(); - sal_Bool bFound = sal_False; - for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) - { - if( lData[nStep].Name == CONST_ASCII("compatibleUserData") ) - { - bFound = sal_True; - lData[nStep].Value <<= sData; - break; - } - } - if( bFound == sal_False ) - { - lData.realloc(nCount+1); - lData[nCount].Name = CONST_ASCII("compatibleUserData"); - lData[nCount].Value <<= sData; - } - - SetUserData( lData ); -} -//***************************************************************************************************************** -css::uno::Sequence< ::rtl::OUString > SvtViewOptions::SeperateUserData( const ::rtl::OUString& sData, sal_Unicode cSeperator ) -{ - css::uno::Sequence< ::rtl::OUString > seqToken; - - sal_Int32 nLength = sData.getLength() ; - sal_Int32 nStart = 0 ; - sal_Int32 nEnd = 0 ; - sal_Int32 nToken = 0 ; - - while ( - nStart < nLength - ) - { - nEnd = sData.indexOf( cSeperator, nStart ); - if( nEnd != -1 ) - { - seqToken[nToken] = sData.copy( nStart, nEnd-nStart ); - nStart = nEnd; - } - else - if( nStart < nLength ) - { - seqToken[nToken] = sData.copy( nStart, nLength-nStart ); - nStart = nLength; - } - ++nToken; - } - - return seqToken; -} - -//***************************************************************************************************************** -::rtl::OUString SvtViewOptions::GenerateUserData( const css::uno::Sequence< ::rtl::OUString >& seqData, sal_Unicode cSeperator ) -{ - ::rtl::OUStringBuffer sUserData( 1000 ); - sal_Int32 nCount = seqData.getLength(); - for( sal_Int32 nToken=0; nToken<nCount; ++nToken ) - { - sUserData.append( seqData[nToken] ); - if( nToken < nCount ) - { - sUserData.append( cSeperator ); - } - } - return sUserData.makeStringAndClear(); -} - -//***************************************************************************************************************** -::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SvtViewOptions::GetAnyData() const -{ - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lSource = GetUserData( sal_True ); - sal_Int32 nCount = lSource.getLength(); - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > lDestination( nCount ); - for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) - { - lDestination[nStep].Name = lSource[nStep].Name ; - lDestination[nStep].Value = lSource[nStep].Value; - } - return lDestination; -} - -//***************************************************************************************************************** -void SvtViewOptions::SetAnyData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lData ) -{ - sal_Int32 nCount = lData.getLength(); - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lDestination( nCount ); - for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) - { - lDestination[nStep].Name = lData[nStep].Name ; - lDestination[nStep].Value = lData[nStep].Value; - } - SetUserData( lDestination ); -} -#endif -*/ - -//***************************************************************************************************************** // private method //***************************************************************************************************************** ::osl::Mutex& SvtViewOptions::GetOwnStaticMutex() |