diff options
-rw-r--r-- | sc/inc/appoptio.hxx | 47 | ||||
-rw-r--r-- | sc/inc/docoptio.hxx | 34 | ||||
-rw-r--r-- | sc/inc/unitconv.hxx | 8 | ||||
-rw-r--r-- | sc/source/core/tool/appoptio.cxx | 510 | ||||
-rw-r--r-- | sc/source/core/tool/docoptio.cxx | 274 | ||||
-rw-r--r-- | sc/source/core/tool/unitconv.cxx | 181 |
6 files changed, 843 insertions, 211 deletions
diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx index b5e279c23b7e..f466dffde306 100644 --- a/sc/inc/appoptio.hxx +++ b/sc/inc/appoptio.hxx @@ -2,9 +2,9 @@ * * $RCSfile: appoptio.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:44:47 $ + * last change: $Author: nn $ $Date: 2000-09-22 07:55:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,14 +71,19 @@ #include <svx/zoomitem.hxx> #endif -#ifndef _SFXCFGITEM_HXX //autogen -#include <sfx2/cfgitem.hxx> +#ifndef _UTL_CONFIGITEM_HXX_ +#include <unotools/configitem.hxx> #endif #ifndef SC_SCGLOB_HXX #include "global.hxx" #endif +#ifndef SC_VIEWOPTI_HXX +#include "viewopti.hxx" //! move ScLinkConfigItem to separate header! +#endif + + class ScAppOptions { public: @@ -140,21 +145,37 @@ private: //================================================================== -// CfgItem fuer App-Optionen +// Config Item containing app options //================================================================== -class ScAppCfg : public ScAppOptions, - public SfxConfigItem +class ScAppCfg : public ScAppOptions { + // spread about 5 config paths + //! split ScAppOptions into different classes + + ScLinkConfigItem aLayoutItem; + ScLinkConfigItem aInputItem; + ScLinkConfigItem aRevisionItem; + ScLinkConfigItem aContentItem; + ScLinkConfigItem aSortListItem; + + DECL_LINK( LayoutCommitHdl, void* ); + DECL_LINK( InputCommitHdl, void* ); + DECL_LINK( RevisionCommitHdl, void* ); + DECL_LINK( ContentCommitHdl, void* ); + DECL_LINK( SortListCommitHdl, void* ); + + com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames(); + com::sun::star::uno::Sequence<rtl::OUString> GetInputPropertyNames(); + com::sun::star::uno::Sequence<rtl::OUString> GetRevisionPropertyNames(); + com::sun::star::uno::Sequence<rtl::OUString> GetContentPropertyNames(); + com::sun::star::uno::Sequence<rtl::OUString> GetSortListPropertyNames(); + public: ScAppCfg(); - virtual String GetName() const; - -protected: - virtual int Load (SvStream& rStream); - virtual BOOL Store (SvStream& rStream); - virtual void UseDefault (); + void SetOptions( const ScAppOptions& rNew ); + void OptionsChanged(); // after direct access to ScAppOptions base class }; diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx index e200e4f24132..5a3c0349f0d9 100644 --- a/sc/inc/docoptio.hxx +++ b/sc/inc/docoptio.hxx @@ -2,9 +2,9 @@ * * $RCSfile: docoptio.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:44:48 $ + * last change: $Author: nn $ $Date: 2000-09-22 07:55:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,14 +63,19 @@ #define SC_DOCOPTIO_HXX -#ifndef _SFXCFGITEM_HXX //autogen -#include <sfx2/cfgitem.hxx> +#ifndef _UTL_CONFIGITEM_HXX_ +#include <unotools/configitem.hxx> #endif #ifndef _SFXPOOLITEM_HXX //autogen #include <svtools/poolitem.hxx> #endif +#ifndef SC_VIEWOPTI_HXX +#include "viewopti.hxx" //! move ScLinkConfigItem to separate header! +#endif + + class ScDocOptions { @@ -224,21 +229,24 @@ private: }; //================================================================== -// CfgItem fuer Doc-Optionen +// Config Item containing document options //================================================================== -class ScDocCfg : public ScDocOptions, - public SfxConfigItem +class ScDocCfg : public ScDocOptions { + ScLinkConfigItem aCalcItem; + ScLinkConfigItem aLayoutItem; + + DECL_LINK( CalcCommitHdl, void* ); + DECL_LINK( LayoutCommitHdl, void* ); + + com::sun::star::uno::Sequence<rtl::OUString> GetCalcPropertyNames(); + com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames(); + public: ScDocCfg(); - virtual String GetName() const; - -protected: - virtual int Load (SvStream& rStream); - virtual BOOL Store (SvStream& rStream); - virtual void UseDefault (); + void SetOptions( const ScDocOptions& rNew ); }; diff --git a/sc/inc/unitconv.hxx b/sc/inc/unitconv.hxx index efa5c963f62c..b5ace3554870 100644 --- a/sc/inc/unitconv.hxx +++ b/sc/inc/unitconv.hxx @@ -2,9 +2,9 @@ * * $RCSfile: unitconv.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-18 16:44:50 $ + * last change: $Author: nn $ $Date: 2000-09-22 07:55:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,9 +92,6 @@ class International; class ScUnitConverter : public StrCollection { - void ReadIniFiles(); - void ReadIniFile( const String& rFileName, International& rIntl ); - // not implemented ScUnitConverter( const ScUnitConverter& ); ScUnitConverter& operator=( const ScUnitConverter& ); @@ -109,3 +106,4 @@ public: #endif + diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx index 1184e4701735..d34a5b0d127f 100644 --- a/sc/source/core/tool/appoptio.cxx +++ b/sc/source/core/tool/appoptio.cxx @@ -2,9 +2,9 @@ * * $RCSfile: appoptio.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-19 00:16:17 $ + * last change: $Author: nn $ $Date: 2000-09-22 07:56:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,9 @@ #include <vcl/svapp.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> + #include "cfgids.hxx" #include "appoptio.hxx" #include "rechead.hxx" @@ -77,6 +80,11 @@ #include "userlist.hxx" #include "sc.hrc" #include "compiler.hrc" +#include "miscuno.hxx" + +using namespace utl; +using namespace rtl; +using namespace com::sun::star::uno; // STATIC DATA ----------------------------------------------------------- @@ -288,56 +296,506 @@ void ScAppOptions::SetLRUFuncList( const USHORT* pList, const USHORT nCount ) } //================================================================== -// CfgItem fuer App-Optionen +// Config Item containing app options //================================================================== -ScAppCfg::ScAppCfg() : SfxConfigItem( SCCFG_APP ) +void lcl_SetLastFunctions( ScAppOptions& rOpt, const Any& rValue ) { + Sequence<sal_Int32> aSeq; + if ( rValue >>= aSeq ) + { + long nCount = aSeq.getLength(); + if ( nCount < USHRT_MAX ) + { + const sal_Int32* pArray = aSeq.getConstArray(); + USHORT* pUShorts = new USHORT[nCount]; + for (long i=0; i<nCount; i++) + pUShorts[i] = (USHORT) pArray[i]; + + rOpt.SetLRUFuncList( pUShorts, nCount ); + + delete[] pUShorts; + } + } } -//------------------------------------------------------------------------ +void lcl_GetLastFunctions( Any& rDest, const ScAppOptions& rOpt ) +{ + long nCount = rOpt.GetLRUFuncListCount(); + USHORT* pUShorts = rOpt.GetLRUFuncList(); + if ( nCount && pUShorts ) + { + Sequence<sal_Int32> aSeq( nCount ); + sal_Int32* pArray = aSeq.getArray(); + for (long i=0; i<nCount; i++) + pArray[i] = pUShorts[i]; + rDest <<= aSeq; + } + else + rDest <<= Sequence<sal_Int32>(0); // empty +} -int __EXPORT ScAppCfg::Load( SvStream& rStream ) +void lcl_SetSortList( const Any& rValue ) { - USHORT nVersion; + Sequence<OUString> aSeq; + if ( rValue >>= aSeq ) + { + long nCount = aSeq.getLength(); + const OUString* pArray = aSeq.getConstArray(); + ScUserList aList; + + // if setting is "default", keep default values from ScUserList ctor + //! mark "default" in a safe way + BOOL bDefault = ( nCount == 1 && + pArray[0].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "NULL" ) ) ); + + if (!bDefault) + { + aList.FreeAll(); + + for (long i=0; i<nCount; i++) + { + ScUserListData* pNew = new ScUserListData( pArray[i] ); + if ( !aList.Insert(pNew) ) + delete pNew; + } + } + + ScGlobal::SetUserList( &aList ); + } +} + +void lcl_GetSortList( Any& rDest ) +{ + const ScUserList* pUserList = ScGlobal::GetUserList(); + if (pUserList) + { + long nCount = pUserList->GetCount(); + Sequence<OUString> aSeq( nCount ); + OUString* pArray = aSeq.getArray(); + for (long i=0; i<nCount; i++) + pArray[i] = (*pUserList)[i]->GetString(); + rDest <<= aSeq; + } + else + rDest <<= Sequence<OUString>(0); // empty +} + +//------------------------------------------------------------------ + +#define CFGPATH_LAYOUT "Office.Calc/Layout" + +#define SCLAYOUTOPT_MEASURE 0 +#define SCLAYOUTOPT_STATUSBAR 1 +#define SCLAYOUTOPT_ZOOMVAL 2 +#define SCLAYOUTOPT_ZOOMTYPE 3 +#define SCLAYOUTOPT_COUNT 4 - rStream >> nVersion; - rStream >> (ScAppOptions&)*this; +#define CFGPATH_INPUT "Office.Calc/Input" - SetDefault( FALSE ); +#define SCINPUTOPT_LASTFUNCS 0 +#define SCINPUTOPT_AUTOINPUT 1 +#define SCINPUTOPT_DET_AUTO 2 +#define SCINPUTOPT_COUNT 3 - return ( nVersion == SC_VERSION ) - ? SfxConfigItem::ERR_OK - : SfxConfigItem::WARNING_VERSION; +#define CFGPATH_REVISION "Office.Calc/Revision/Color" + +#define SCREVISOPT_CHANGE 0 +#define SCREVISOPT_INSERTION 1 +#define SCREVISOPT_DELETION 2 +#define SCREVISOPT_MOVEDENTRY 3 +#define SCREVISOPT_COUNT 4 + +#define CFGPATH_CONTENT "Office.Calc/Content/Update" + +#define SCCONTENTOPT_LINK 0 +#define SCCONTENTOPT_COUNT 1 + +#define CFGPATH_SORTLIST "Office.Calc/SortList" + +#define SCSORTLISTOPT_LIST 0 +#define SCSORTLISTOPT_COUNT 1 + + +Sequence<OUString> ScAppCfg::GetLayoutPropertyNames() +{ + static const char* aPropNames[] = + { + "Other/MeasureUnit", // SCLAYOUTOPT_MEASURE + "Other/StatusbarFunction", // SCLAYOUTOPT_STATUSBAR + "Zoom/Value", // SCLAYOUTOPT_ZOOMVAL + "Zoom/Type" // SCLAYOUTOPT_ZOOMTYPE + }; + Sequence<OUString> aNames(SCLAYOUTOPT_COUNT); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < SCLAYOUTOPT_COUNT; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + + return aNames; } -//------------------------------------------------------------------------ +Sequence<OUString> ScAppCfg::GetInputPropertyNames() +{ + static const char* aPropNames[] = + { + "LastFunctions", // SCINPUTOPT_LASTFUNCS + "AutoInput", // SCINPUTOPT_AUTOINPUT + "DetectiveAuto" // SCINPUTOPT_DET_AUTO + }; + Sequence<OUString> aNames(SCINPUTOPT_COUNT); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < SCINPUTOPT_COUNT; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + + return aNames; +} -BOOL __EXPORT ScAppCfg::Store( SvStream& rStream) +Sequence<OUString> ScAppCfg::GetRevisionPropertyNames() { - rStream << SC_VERSION; - rStream << *this; + static const char* aPropNames[] = + { + "Change", // SCREVISOPT_CHANGE + "Insertion", // SCREVISOPT_INSERTION + "Deletion", // SCREVISOPT_DELETION + "MovedEntry" // SCREVISOPT_MOVEDENTRY + }; + Sequence<OUString> aNames(SCREVISOPT_COUNT); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < SCREVISOPT_COUNT; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + + return aNames; +} - SetDefault( FALSE ); +Sequence<OUString> ScAppCfg::GetContentPropertyNames() +{ + static const char* aPropNames[] = + { + "Link" // SCCONTENTOPT_LINK + }; + Sequence<OUString> aNames(SCCONTENTOPT_COUNT); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < SCCONTENTOPT_COUNT; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + + return aNames; +} - return SfxConfigItem::ERR_OK; +Sequence<OUString> ScAppCfg::GetSortListPropertyNames() +{ + static const char* aPropNames[] = + { + "List" // SCSORTLISTOPT_LIST + }; + Sequence<OUString> aNames(SCSORTLISTOPT_COUNT); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < SCSORTLISTOPT_COUNT; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + + return aNames; } -//------------------------------------------------------------------------ -void __EXPORT ScAppCfg::UseDefault() +ScAppCfg::ScAppCfg() : + aLayoutItem( OUString::createFromAscii( CFGPATH_LAYOUT ) ), + aInputItem( OUString::createFromAscii( CFGPATH_INPUT ) ), + aRevisionItem( OUString::createFromAscii( CFGPATH_REVISION ) ), + aContentItem( OUString::createFromAscii( CFGPATH_CONTENT ) ), + aSortListItem( OUString::createFromAscii( CFGPATH_SORTLIST ) ) { - SetDefaults(); - SetDefault( TRUE ); + sal_Int32 nIntVal; + + Sequence<OUString> aNames; + Sequence<Any> aValues; + const Any* pValues = NULL; + + aNames = GetLayoutPropertyNames(); + aValues = aLayoutItem.GetProperties(aNames); + aLayoutItem.EnableNotification(aNames); + pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed") + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + DBG_ASSERT(pValues[nProp].hasValue(), "property value missing") + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case SCLAYOUTOPT_MEASURE: + if (pValues[nProp] >>= nIntVal) SetAppMetric( (FieldUnit) nIntVal ); + break; + case SCLAYOUTOPT_STATUSBAR: + if (pValues[nProp] >>= nIntVal) SetStatusFunc( (USHORT) nIntVal ); + break; + case SCLAYOUTOPT_ZOOMVAL: + if (pValues[nProp] >>= nIntVal) SetZoom( (USHORT) nIntVal ); + break; + case SCLAYOUTOPT_ZOOMTYPE: + if (pValues[nProp] >>= nIntVal) SetZoomType( (SvxZoomType) nIntVal ); + break; + } + } + } + } + aLayoutItem.SetCommitLink( LINK( this, ScAppCfg, LayoutCommitHdl ) ); + + aNames = GetInputPropertyNames(); + aValues = aInputItem.GetProperties(aNames); + aInputItem.EnableNotification(aNames); + pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed") + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + DBG_ASSERT(pValues[nProp].hasValue(), "property value missing") + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case SCINPUTOPT_LASTFUNCS: + lcl_SetLastFunctions( *this, pValues[nProp] ); + break; + case SCINPUTOPT_AUTOINPUT: + SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCINPUTOPT_DET_AUTO: + SetDetectiveAuto( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + } + } + } + } + aInputItem.SetCommitLink( LINK( this, ScAppCfg, InputCommitHdl ) ); + + aNames = GetRevisionPropertyNames(); + aValues = aRevisionItem.GetProperties(aNames); + aRevisionItem.EnableNotification(aNames); + pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed") + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + DBG_ASSERT(pValues[nProp].hasValue(), "property value missing") + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case SCREVISOPT_CHANGE: + if (pValues[nProp] >>= nIntVal) SetTrackContentColor( (ULONG) nIntVal ); + break; + case SCREVISOPT_INSERTION: + if (pValues[nProp] >>= nIntVal) SetTrackInsertColor( (ULONG) nIntVal ); + break; + case SCREVISOPT_DELETION: + if (pValues[nProp] >>= nIntVal) SetTrackDeleteColor( (ULONG) nIntVal ); + break; + case SCREVISOPT_MOVEDENTRY: + if (pValues[nProp] >>= nIntVal) SetTrackMoveColor( (ULONG) nIntVal ); + break; + } + } + } + } + aRevisionItem.SetCommitLink( LINK( this, ScAppCfg, RevisionCommitHdl ) ); + + aNames = GetContentPropertyNames(); + aValues = aContentItem.GetProperties(aNames); + aContentItem.EnableNotification(aNames); + pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed") + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + DBG_ASSERT(pValues[nProp].hasValue(), "property value missing") + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case SCCONTENTOPT_LINK: + if (pValues[nProp] >>= nIntVal) SetLinkMode( (ScLkUpdMode) nIntVal ); + break; + } + } + } + } + aContentItem.SetCommitLink( LINK( this, ScAppCfg, ContentCommitHdl ) ); + + aNames = GetSortListPropertyNames(); + aValues = aSortListItem.GetProperties(aNames); + aSortListItem.EnableNotification(aNames); + pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed") + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + DBG_ASSERT(pValues[nProp].hasValue(), "property value missing") + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case SCSORTLISTOPT_LIST: + lcl_SetSortList( pValues[nProp] ); + break; + } + } + } + } + aSortListItem.SetCommitLink( LINK( this, ScAppCfg, SortListCommitHdl ) ); } +IMPL_LINK( ScAppCfg, LayoutCommitHdl, void *, EMPTYARG ) +{ + Sequence<OUString> aNames = GetLayoutPropertyNames(); + OUString* pNames = aNames.getArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); -//------------------------------------------------------------------------ + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case SCLAYOUTOPT_MEASURE: + pValues[nProp] <<= (sal_Int32) GetAppMetric(); + break; + case SCLAYOUTOPT_STATUSBAR: + pValues[nProp] <<= (sal_Int32) GetStatusFunc(); + break; + case SCLAYOUTOPT_ZOOMVAL: + pValues[nProp] <<= (sal_Int32) GetZoom(); + break; + case SCLAYOUTOPT_ZOOMTYPE: + pValues[nProp] <<= (sal_Int32) GetZoomType(); + break; + } + } + aLayoutItem.PutProperties(aNames, aValues); + + return 0; +} -String __EXPORT ScAppCfg::GetName() const +IMPL_LINK( ScAppCfg, InputCommitHdl, void *, EMPTYARG ) { - return String( ScResId( SCSTR_CFG_APP ) ); + Sequence<OUString> aNames = GetInputPropertyNames(); + OUString* pNames = aNames.getArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case SCINPUTOPT_LASTFUNCS: + lcl_GetLastFunctions( pValues[nProp], *this ); + break; + case SCINPUTOPT_AUTOINPUT: + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetAutoComplete() ); + break; + case SCINPUTOPT_DET_AUTO: + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], GetDetectiveAuto() ); + break; + } + } + aInputItem.PutProperties(aNames, aValues); + + return 0; } +IMPL_LINK( ScAppCfg, RevisionCommitHdl, void *, EMPTYARG ) +{ + Sequence<OUString> aNames = GetRevisionPropertyNames(); + OUString* pNames = aNames.getArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case SCREVISOPT_CHANGE: + pValues[nProp] <<= (sal_Int32) GetTrackContentColor(); + break; + case SCREVISOPT_INSERTION: + pValues[nProp] <<= (sal_Int32) GetTrackInsertColor(); + break; + case SCREVISOPT_DELETION: + pValues[nProp] <<= (sal_Int32) GetTrackDeleteColor(); + break; + case SCREVISOPT_MOVEDENTRY: + pValues[nProp] <<= (sal_Int32) GetTrackMoveColor(); + break; + } + } + aRevisionItem.PutProperties(aNames, aValues); + + return 0; +} + +IMPL_LINK( ScAppCfg, ContentCommitHdl, void *, EMPTYARG ) +{ + Sequence<OUString> aNames = GetContentPropertyNames(); + OUString* pNames = aNames.getArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case SCCONTENTOPT_LINK: + pValues[nProp] <<= (sal_Int32) GetLinkMode(); + break; + } + } + aContentItem.PutProperties(aNames, aValues); + + return 0; +} + +IMPL_LINK( ScAppCfg, SortListCommitHdl, void *, EMPTYARG ) +{ + Sequence<OUString> aNames = GetSortListPropertyNames(); + OUString* pNames = aNames.getArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case SCSORTLISTOPT_LIST: + lcl_GetSortList( pValues[nProp] ); + break; + } + } + aSortListItem.PutProperties(aNames, aValues); + + return 0; +} + +void ScAppCfg::SetOptions( const ScAppOptions& rNew ) +{ + *(ScAppOptions*)this = rNew; + OptionsChanged(); +} + +void ScAppCfg::OptionsChanged() +{ + aLayoutItem.SetModified(); + aInputItem.SetModified(); + aRevisionItem.SetModified(); + aContentItem.SetModified(); + aSortListItem.SetModified(); +} diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx index f0f5a9a59271..eb95665d229c 100644 --- a/sc/source/core/tool/docoptio.cxx +++ b/sc/source/core/tool/docoptio.cxx @@ -2,9 +2,9 @@ * * $RCSfile: docoptio.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-19 00:16:17 $ + * last change: $Author: nn $ $Date: 2000-09-22 07:56:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,11 +68,19 @@ #include <vcl/svapp.hxx> #include <svtools/zforlist.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> + #include "cfgids.hxx" #include "docoptio.hxx" #include "rechead.hxx" #include "scresid.hxx" #include "sc.hrc" +#include "miscuno.hxx" + +using namespace utl; +using namespace rtl; +using namespace com::sun::star::uno; //------------------------------------------------------------------------ @@ -82,6 +90,14 @@ TYPEINIT1(ScTpCalcItem, SfxPoolItem); //------------------------------------------------------------------------ +//! these functions should be moved to some header file +inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; } +inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; } + +inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; } + +//------------------------------------------------------------------------ + USHORT lcl_GetDefaultTabDist() { MeasurementSystem eSys = Application::GetAppInternational().GetMeasurementSystem(); @@ -280,58 +296,252 @@ SfxPoolItem* __EXPORT ScTpCalcItem::Clone( SfxItemPool * ) const } //================================================================== -// CfgItem fuer Doc-Optionen +// Config Item containing document options //================================================================== -ScDocCfg::ScDocCfg() : SfxConfigItem( SCCFG_DOC ) +#define CFGPATH_CALC "Office.Calc/Calculate" + +#define SCCALCOPT_ITER_ITER 0 +#define SCCALCOPT_ITER_STEPS 1 +#define SCCALCOPT_ITER_MINCHG 2 +#define SCCALCOPT_DATE_DAY 3 +#define SCCALCOPT_DATE_MONTH 4 +#define SCCALCOPT_DATE_YEAR 5 +#define SCCALCOPT_DECIMALS 6 +#define SCCALCOPT_CASESENSITIVE 7 +#define SCCALCOPT_PRECISION 8 +#define SCCALCOPT_SEARCHCRIT 9 +#define SCCALCOPT_FINDLABEL 10 +#define SCCALCOPT_COUNT 11 + +#define CFGPATH_DOCLAYOUT "Office.Calc/Layout/Other" + +#define SCDOCLAYOUTOPT_TABSTOP 0 +#define SCDOCLAYOUTOPT_COUNT 1 + + +Sequence<OUString> ScDocCfg::GetCalcPropertyNames() { + static const char* aPropNames[] = + { + "IterativeReference/Iteration", // SCCALCOPT_ITER_ITER + "IterativeReference/Steps", // SCCALCOPT_ITER_STEPS + "IterativeReference/MinimumChange", // SCCALCOPT_ITER_MINCHG + "Other/Date/DD", // SCCALCOPT_DATE_DAY + "Other/Date/MM", // SCCALCOPT_DATE_MONTH + "Other/Date/YY", // SCCALCOPT_DATE_YEAR + "Other/DecimalPlaces", // SCCALCOPT_DECIMALS + "Other/CaseSensitive", // SCCALCOPT_CASESENSITIVE + "Other/Precision", // SCCALCOPT_PRECISION + "Other/SearchCriteria", // SCCALCOPT_SEARCHCRIT + "Other/FindLabel" // SCCALCOPT_FINDLABEL + }; + Sequence<OUString> aNames(SCCALCOPT_COUNT); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < SCCALCOPT_COUNT; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + + return aNames; } -//------------------------------------------------------------------------ - -int __EXPORT ScDocCfg::Load( SvStream& rStream ) +Sequence<OUString> ScDocCfg::GetLayoutPropertyNames() { - USHORT nVersion; + static const char* aPropNames[] = + { + "TabStop" // SCDOCLAYOUTOPT_TABSTOP + }; + Sequence<OUString> aNames(SCDOCLAYOUTOPT_COUNT); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < SCDOCLAYOUTOPT_COUNT; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + + return aNames; +} - rStream >> nVersion; - ScDocOptions::Load( rStream ); +ScDocCfg::ScDocCfg() : + aCalcItem( OUString::createFromAscii( CFGPATH_CALC ) ), + aLayoutItem( OUString::createFromAscii( CFGPATH_DOCLAYOUT ) ) +{ + sal_Int32 nIntVal; + double fDoubleVal; + + Sequence<OUString> aNames; + Sequence<Any> aValues; + const Any* pValues = NULL; + + USHORT nDateDay, nDateMonth, nDateYear; + GetDate( nDateDay, nDateMonth, nDateYear ); + + aNames = GetCalcPropertyNames(); + aValues = aCalcItem.GetProperties(aNames); + aCalcItem.EnableNotification(aNames); + pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed") + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + DBG_ASSERT(pValues[nProp].hasValue(), "property value missing") + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case SCCALCOPT_ITER_ITER: + SetIter( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCCALCOPT_ITER_STEPS: + if (pValues[nProp] >>= nIntVal) SetIterCount( (USHORT) nIntVal ); + break; + case SCCALCOPT_ITER_MINCHG: + if (pValues[nProp] >>= fDoubleVal) SetIterEps( fDoubleVal ); + break; + case SCCALCOPT_DATE_DAY: + if (pValues[nProp] >>= nIntVal) nDateDay = (USHORT) nIntVal; + break; + case SCCALCOPT_DATE_MONTH: + if (pValues[nProp] >>= nIntVal) nDateMonth = (USHORT) nIntVal; + break; + case SCCALCOPT_DATE_YEAR: + if (pValues[nProp] >>= nIntVal) nDateYear = (USHORT) nIntVal; + break; + case SCCALCOPT_DECIMALS: + if (pValues[nProp] >>= nIntVal) SetStdPrecision( (USHORT) nIntVal ); + break; + case SCCALCOPT_CASESENSITIVE: + // content is reversed + SetIgnoreCase( !ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCCALCOPT_PRECISION: + SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCCALCOPT_SEARCHCRIT: + SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + case SCCALCOPT_FINDLABEL: + SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( pValues[nProp] ) ); + break; + } + } + } + } + aCalcItem.SetCommitLink( LINK( this, ScDocCfg, CalcCommitHdl ) ); - SetDefault( FALSE ); + SetDate( nDateDay, nDateMonth, nDateYear ); - return ( nVersion == SC_VERSION ) - ? SfxConfigItem::ERR_OK - : SfxConfigItem::WARNING_VERSION; + aNames = GetLayoutPropertyNames(); + aValues = aLayoutItem.GetProperties(aNames); + aLayoutItem.EnableNotification(aNames); + pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed") + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + DBG_ASSERT(pValues[nProp].hasValue(), "property value missing") + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case SCDOCLAYOUTOPT_TABSTOP: + // TabDistance in ScDocOptions is in twips + if (pValues[nProp] >>= nIntVal) + SetTabDistance( (USHORT) HMMToTwips( nIntVal ) ); + break; + } + } + } + } + aLayoutItem.SetCommitLink( LINK( this, ScDocCfg, LayoutCommitHdl ) ); } -//------------------------------------------------------------------------ - -BOOL __EXPORT ScDocCfg::Store( SvStream& rStream) +IMPL_LINK( ScDocCfg, CalcCommitHdl, void *, EMPTYARG ) { - // TRUE = alles speichern, unabhaengig von der Stream-Version - // (am Config-Stream ist noch SOFFICE_FILEFORMAT_40 eingestellt) + Sequence<OUString> aNames = GetCalcPropertyNames(); + OUString* pNames = aNames.getArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); - rStream << SC_VERSION; - ScDocOptions::Save( rStream, TRUE ); + USHORT nDateDay, nDateMonth, nDateYear; + GetDate( nDateDay, nDateMonth, nDateYear ); - SetDefault( FALSE ); + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case SCCALCOPT_ITER_ITER: + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsIter() ); + break; + case SCCALCOPT_ITER_STEPS: + pValues[nProp] <<= (sal_Int32) GetIterCount(); + break; + case SCCALCOPT_ITER_MINCHG: + pValues[nProp] <<= (double) GetIterEps(); + break; + case SCCALCOPT_DATE_DAY: + pValues[nProp] <<= (sal_Int32) nDateDay; + break; + case SCCALCOPT_DATE_MONTH: + pValues[nProp] <<= (sal_Int32) nDateMonth; + break; + case SCCALCOPT_DATE_YEAR: + pValues[nProp] <<= (sal_Int32) nDateYear; + break; + case SCCALCOPT_DECIMALS: + pValues[nProp] <<= (sal_Int32) GetStdPrecision(); + break; + case SCCALCOPT_CASESENSITIVE: + // content is reversed + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], !IsIgnoreCase() ); + break; + case SCCALCOPT_PRECISION: + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsCalcAsShown() ); + break; + case SCCALCOPT_SEARCHCRIT: + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsMatchWholeCell() ); + break; + case SCCALCOPT_FINDLABEL: + ScUnoHelpFunctions::SetBoolInAny( pValues[nProp], IsLookUpColRowNames() ); + break; + } + } + aCalcItem.PutProperties(aNames, aValues); - return SfxConfigItem::ERR_OK; + return 0; } -//------------------------------------------------------------------------ - -void __EXPORT ScDocCfg::UseDefault() +IMPL_LINK( ScDocCfg, LayoutCommitHdl, void *, EMPTYARG ) { - ResetDocOptions(); - SetDefault( TRUE ); + Sequence<OUString> aNames = GetLayoutPropertyNames(); + OUString* pNames = aNames.getArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case SCDOCLAYOUTOPT_TABSTOP: + // TabDistance in ScDocOptions is in twips + // use only even numbers, so defaults don't get changed + // by modifying other settings in the same config item + pValues[nProp] <<= (sal_Int32) TwipsToEvenHMM( GetTabDistance() ); + break; + } + } + aLayoutItem.PutProperties(aNames, aValues); + + return 0; } -//------------------------------------------------------------------------ -String __EXPORT ScDocCfg::GetName() const +void ScDocCfg::SetOptions( const ScDocOptions& rNew ) { - return String( ScResId( SCSTR_CFG_DOC ) ); -} + *(ScDocOptions*)this = rNew; + aCalcItem.SetModified(); + aLayoutItem.SetModified(); +} diff --git a/sc/source/core/tool/unitconv.cxx b/sc/source/core/tool/unitconv.cxx index 4b27bc704d60..226226a449d9 100644 --- a/sc/source/core/tool/unitconv.cxx +++ b/sc/source/core/tool/unitconv.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unitconv.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: hr $ $Date: 2000-09-19 00:16:19 $ + * last change: $Author: nn $ $Date: 2000-09-22 07:56:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,33 +65,18 @@ #pragma hdrstop -#ifndef SC_UNITCONV_HXX +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> + #include "unitconv.hxx" -#endif -#ifndef SC_SCGLOB_HXX #include "global.hxx" -#endif -#ifndef _SFXDOCFILE_HXX -#include <sfx2/docfile.hxx> -#endif -#ifndef _SFX_INIMGR_HXX //autogen -#include <sfx2/inimgr.hxx> -#endif -#ifndef _SFXINIMGR_HXX //autogen -#include <svtools/iniman.hxx> -#endif -#ifndef _TOOLS_SOLMATH_HXX //autogen wg. SolarMath -#include <tools/solmath.hxx> -#endif -#ifndef _TOOLS_INTN_HXX //autogen wg. International -#include <tools/intn.hxx> -#endif -#ifndef _STREAM_HXX //autogen -#include <tools/stream.hxx> -#endif -#ifndef _URLOBJ_HXX -#include <tools/urlobj.hxx> -#endif +#include "viewopti.hxx" //! move ScLinkConfigItem to separate header! + +using namespace utl; +using namespace rtl; +using namespace com::sun::star::uno; + +// -------------------------------------------------------------------- const sal_Unicode cDelim = 0x01; // Delimiter zwischen From und To @@ -147,117 +132,69 @@ void ScUnitConverterData::BuildIndexString( String& rStr, // --- ScUnitConverter ------------------------------------------------ -ScUnitConverter::ScUnitConverter( USHORT nInit, USHORT nDelta ) - : +#define CFGPATH_UNIT "Office.Calc/UnitConversion" +#define CFGSTR_UNIT_FROM "FromUnit" +#define CFGSTR_UNIT_TO "ToUnit" +#define CFGSTR_UNIT_FACTOR "Factor" + +ScUnitConverter::ScUnitConverter( USHORT nInit, USHORT nDelta ) : StrCollection( nInit, nDelta, FALSE ) { - ReadIniFiles(); -} - + // read from configuration - "convert.ini" is no longer used + //! config item as member to allow change of values -inline const sal_Unicode* SkipWhite( const sal_Unicode* p ) -{ - while ( *p == ' ' || *p == '\t' ) - p++; - return p; -} + ScLinkConfigItem aConfigItem( OUString::createFromAscii( CFGPATH_UNIT ) ); + // empty node name -> use the config item's path itself + Sequence<OUString> aNodeNames = aConfigItem.GetNodeNames( OUString() ); -void ScUnitConverter::ReadIniFiles() -{ - International aIntl( LANGUAGE_ENGLISH_US ); - String aName( RTL_CONSTASCII_USTRINGPARAM("convert.ini") ); - INetURLObject aURL; - - // share/config/convert.ini first, global definitions - String aPath( SFX_INIMANAGER()->Get( SFX_KEY_CONFIG_DIR ) ); - if ( aPath.Len() > 0 ) + long nNodeCount = aNodeNames.getLength(); + if ( nNodeCount ) { - aURL.SetSmartURL( aPath ); - aURL.setFinalSlash(); - aURL.Append( aName ); - ReadIniFile( aURL.GetMainURL(), aIntl ); - } + const OUString* pNodeArray = aNodeNames.getConstArray(); + Sequence<OUString> aValNames( nNodeCount * 3 ); + OUString* pValNameArray = aValNames.getArray(); + const OUString sSlash('/'); - // user/config/convert.ini may NOT overwrite globals (StrCollecion no dupes) - aPath = SFX_INIMANAGER()->Get( SFX_KEY_USERCONFIG_PATH ); - if ( aPath.Len() > 0 ) - { - aURL.SetSmartURL( aPath ); - aURL.setFinalSlash(); - aURL.Append( aName ); - ReadIniFile( aURL.GetMainURL(), aIntl ); - } -} + long nIndex = 0; + for (long i=0; i<nNodeCount; i++) + { + OUString sPrefix = pNodeArray[i]; + sPrefix += sSlash; + + pValNameArray[nIndex] = sPrefix; + pValNameArray[nIndex++] += OUString::createFromAscii( CFGSTR_UNIT_FROM ); + pValNameArray[nIndex] = sPrefix; + pValNameArray[nIndex++] += OUString::createFromAscii( CFGSTR_UNIT_TO ); + pValNameArray[nIndex] = sPrefix; + pValNameArray[nIndex++] += OUString::createFromAscii( CFGSTR_UNIT_FACTOR ); + } + Sequence<Any> aProperties = aConfigItem.GetProperties(aValNames); -void ScUnitConverter::ReadIniFile( const String& rFileName, International& rIntl ) -{ - SfxMedium aMedium( rFileName, - STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE, TRUE ); - SvStream* pStream = aMedium.GetInStream(); - if ( !pStream || pStream->GetError() != 0 ) - return ; - SvStream& rStream = *pStream; - - ByteString aByteLine; - BOOL bIsConv = FALSE; - while ( !bIsConv && rStream.ReadLine( aByteLine ) ) - { - aByteLine.EraseAllChars( ' ' ); - bIsConv = aByteLine.Equals( "[UnitConversion]" ); - } - - while ( bIsConv && rStream.ReadLine( aByteLine ) ) - { - String aLine( aByteLine, osl_getThreadTextEncoding() ); - const sal_Unicode* const pBeg = aLine.GetBuffer(); - register const sal_Unicode* p = SkipWhite( pBeg ); - // Format: "FromUnit";"ToUnit";1.23 ;evtl. Kommentar - if ( *p == '"' ) + if (aProperties.getLength() == aValNames.getLength()) { - //! keine '"' in Unit - const sal_Unicode* const p1 = ++p; - while ( *p != '"' ) - p++; - String aFromUnit( aLine.Copy( p1 - pBeg, p - p1 ) ); - p = SkipWhite( ++p ); - if ( *p == ';' ) + const Any* pProperties = aProperties.getConstArray(); + + OUString sFromUnit; + OUString sToUnit; + double fFactor; + + nIndex = 0; + for (long i=0; i<nNodeCount; i++) { - p = SkipWhite( ++p ); - if ( *p == '"' ) - { - //! keine '"' in Unit - const sal_Unicode* const p1 = ++p; - while ( *p != '"' ) - p++; - String aToUnit( aLine.Copy( p1 - pBeg, p - p1 ) ); - p = SkipWhite( ++p ); - if ( *p == ';' ) - { - p = SkipWhite( ++p ); - int nErrno; - const sal_Unicode* pEnd; - double fValue = SolarMath::StringToDouble( - p, rIntl, nErrno, &pEnd ); - if ( !nErrno && pEnd > p ) - { - ScUnitConverterData* pData = - new ScUnitConverterData( aFromUnit, aToUnit, - fValue ); - if ( !Insert( pData ) ) - delete pData; - } - } - } + pProperties[nIndex++] >>= sFromUnit; + pProperties[nIndex++] >>= sToUnit; + pProperties[nIndex++] >>= fFactor; + + ScUnitConverterData* pNew = new ScUnitConverterData( sFromUnit, sToUnit, fFactor ); + if ( !Insert( pNew ) ) + delete pNew; } } - else if ( *p == '[' && ScGlobal::UnicodeStrChr( p+1, ']' ) ) - bIsConv = FALSE; // neue [Section] } } - BOOL ScUnitConverter::GetValue( double& fValue, const String& rFromUnit, const String& rToUnit ) const { |