Moved ScDefaultsOptions from ScDocOptions to separate class

This commit is contained in:
Albert Thuswaldner
2012-04-12 21:20:58 +02:00
committed by Kohei Yoshida
parent d117d97418
commit be7cbf49c4
12 changed files with 397 additions and 134 deletions

View File

@@ -171,6 +171,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/tool/consoli \
sc/source/core/tool/dbdata \
sc/source/core/tool/ddelink \
sc/source/core/tool/defaultsoptions \
sc/source/core/tool/detdata \
sc/source/core/tool/detfunc \
sc/source/core/tool/docoptio \

104
sc/inc/defaultsoptions.hxx Normal file
View File

@@ -0,0 +1,104 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Albert Thuswaldner <albert.thuswaldner@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2012 the
* Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef SC_DEFAULTSOPT_HXX
#define SC_DEFAULTSOPT_HXX
#include <svl/poolitem.hxx>
#include <unotools/configitem.hxx>
#include "formula/grammar.hxx"
#include "scdllapi.h"
#include "global.hxx"
class SC_DLLPUBLIC ScDefaultsOptions
{
private:
SCTAB nInitTabCount; // number of Tabs for new Spreadsheet doc
::rtl::OUString aInitTabPrefix; // The Tab prefix name in new Spreadsheet doc
public:
ScDefaultsOptions();
ScDefaultsOptions( const ScDefaultsOptions& rCpy );
~ScDefaultsOptions();
void SetDefaults();
SCTAB GetInitTabCount() const { return nInitTabCount; }
void SetInitTabCount( SCTAB nTabs) { nInitTabCount = nTabs; }
void SetInitTabPrefix(const rtl::OUString& aPrefix) { aInitTabPrefix = aPrefix; }
::rtl::OUString GetInitTabPrefix() const { return aInitTabPrefix; }
ScDefaultsOptions& operator= ( const ScDefaultsOptions& rCpy );
bool operator== ( const ScDefaultsOptions& rOpt ) const;
bool operator!= ( const ScDefaultsOptions& rOpt ) const;
};
//==================================================================
// item for the dialog / options page
//==================================================================
class SC_DLLPUBLIC ScTpDefaultsItem : public SfxPoolItem
{
public:
TYPEINFO();
ScTpDefaultsItem( sal_uInt16 nWhich,
const ScDefaultsOptions& rOpt );
ScTpDefaultsItem( const ScTpDefaultsItem& rItem );
~ScTpDefaultsItem();
virtual String GetValueText() const;
virtual int operator==( const SfxPoolItem& ) const;
virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
const ScDefaultsOptions& GetDefaultsOptions() const { return theOptions; }
private:
ScDefaultsOptions theOptions;
};
//==================================================================
// config item
//==================================================================
class ScDefaultsCfg : public ScDefaultsOptions, public utl::ConfigItem
{
com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
public:
ScDefaultsCfg();
void SetOptions( const ScDefaultsOptions& rNew );
virtual void Commit();
virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -40,11 +40,9 @@
class SC_DLLPUBLIC ScDocOptions
{
double fIterEps; // epsilon value dazu
double fIterEps; // epsilon value dazu
sal_uInt16 nIterCount; // number
SCTAB nInitTabCount; // number of Tabs for new Spreadsheet doc
::rtl::OUString aInitTabPrefix; // The Tab prefix name in new Spreadsheet doc
sal_uInt16 nPrecStandardFormat; // precision for standard format
sal_uInt16 nPrecStandardFormat; // precision for standard format
sal_uInt16 nDay; // Null date:
sal_uInt16 nMonth;
sal_uInt16 nYear;
@@ -74,10 +72,6 @@ public:
void SetIter( sal_Bool bVal ) { bIsIter = bVal; }
sal_uInt16 GetIterCount() const { return nIterCount; }
void SetIterCount( sal_uInt16 nCount) { nIterCount = nCount; }
SCTAB GetInitTabCount() const { return nInitTabCount; }
void SetInitTabCount( SCTAB nTabs) { nInitTabCount = nTabs; }
void SetInitTabPrefix( ::rtl::OUString& aPrefix) { aInitTabPrefix = aPrefix; }
::rtl::OUString GetInitTabPrefix() const { return aInitTabPrefix; }
double GetIterEps() const { return fIterEps; }
void SetIterEps( double fEps ) { fIterEps = fEps; }
@@ -113,8 +107,6 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
bIsIgnoreCase = rCpy.bIsIgnoreCase;
bIsIter = rCpy.bIsIter;
nIterCount = rCpy.nIterCount;
nInitTabCount = rCpy.nInitTabCount;
aInitTabPrefix = rCpy.aInitTabPrefix;
fIterEps = rCpy.fIterEps;
nPrecStandardFormat = rCpy.nPrecStandardFormat;
nDay = rCpy.nDay;
@@ -137,8 +129,6 @@ inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
rOpt.bIsIgnoreCase == bIsIgnoreCase
&& rOpt.bIsIter == bIsIter
&& rOpt.nIterCount == nIterCount
&& rOpt.nInitTabCount == nInitTabCount
&& rOpt.aInitTabPrefix == aInitTabPrefix
&& rOpt.fIterEps == fIterEps
&& rOpt.nPrecStandardFormat == nPrecStandardFormat
&& rOpt.nDay == nDay
@@ -190,15 +180,12 @@ class ScDocCfg : public ScDocOptions
{
ScLinkConfigItem aCalcItem;
ScLinkConfigItem aLayoutItem;
ScLinkConfigItem aDefaultsItem;
DECL_LINK( CalcCommitHdl, void* );
DECL_LINK( LayoutCommitHdl, void* );
DECL_LINK( DefaultsCommitHdl, void* );
com::sun::star::uno::Sequence<rtl::OUString> GetCalcPropertyNames();
com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
com::sun::star::uno::Sequence<rtl::OUString> GetDefaultsPropertyNames();
public:
ScDocCfg();

View File

@@ -118,6 +118,7 @@
// Format options
#define SID_SCFORMULAOPTIONS (SC_VIEW_START + 20)
#define SID_SCDEFAULTSOPTIONS (SC_VIEW_START + 21)
// slot-IDs for attributes

View File

@@ -60,12 +60,14 @@ class ScDocument;
class ScViewCfg;
class ScDocCfg;
class ScAppCfg;
class ScDefaultsCfg;
class ScFormulaCfg;
class ScInputCfg;
class ScPrintCfg;
class ScViewOptions;
class ScDocOptions;
class ScAppOptions;
class ScDefaultsOptions;
class ScFormulaOptions;
class ScInputOptions;
class ScPrintOptions;
@@ -106,6 +108,7 @@ class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
ScViewCfg* pViewCfg;
ScDocCfg* pDocCfg;
ScAppCfg* pAppCfg;
ScDefaultsCfg* pDefaultsCfg;
ScFormulaCfg* pFormulaCfg;
ScInputCfg* pInputCfg;
ScPrintCfg* pPrintCfg;
@@ -179,12 +182,14 @@ public:
const ScViewOptions& GetViewOptions ();
SC_DLLPUBLIC const ScDocOptions& GetDocOptions ();
SC_DLLPUBLIC const ScAppOptions& GetAppOptions ();
const ScDefaultsOptions& GetDefaultsOptions ();
const ScFormulaOptions& GetFormulaOptions ();
const ScInputOptions& GetInputOptions ();
SC_DLLPUBLIC const ScPrintOptions& GetPrintOptions ();
void SetViewOptions ( const ScViewOptions& rOpt );
SC_DLLPUBLIC void SetDocOptions ( const ScDocOptions& rOpt );
SC_DLLPUBLIC void SetAppOptions ( const ScAppOptions& rOpt );
void SetDefaultsOptions ( const ScDefaultsOptions& rOpt );
void SetFormulaOptions ( const ScFormulaOptions& rOpt );
void SetInputOptions ( const ScInputOptions& rOpt );
void SetPrintOptions ( const ScPrintOptions& rOpt );

View File

@@ -95,7 +95,7 @@
#include "tabprotection.hxx"
#include "clipparam.hxx"
#include "stlalgorithm.hxx"
#include "docoptio.hxx"
#include "defaultsoptions.hxx"
#include <map>
#include <limits>
@@ -144,8 +144,8 @@ void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck )
if ( ValidTab(nTab) && ( nTab >= static_cast<SCTAB>(maTabs.size()) ||!maTabs[nTab]) )
{
// Get Custom prefix
const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
rtl::OUString aString = rDocOpt.GetInitTabPrefix();
const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
rtl::OUString aString = rOpt.GetInitTabPrefix();
aString += rtl::OUString::valueOf(static_cast<sal_Int32>(nTab+1));
if ( _bNeedsNameCheck )
@@ -313,8 +313,8 @@ void ScDocument::CreateValidTabName(rtl::OUString& rName) const
// Find new one
// Get Custom prefix
const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
rtl::OUString aStrTable = rDocOpt.GetInitTabPrefix();
const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
rtl::OUString aStrTable = rOpt.GetInitTabPrefix();
bool bOk = false;
@@ -361,8 +361,8 @@ void ScDocument::CreateValidTabNames(std::vector<rtl::OUString>& aNames, SCTAB n
aNames.clear();//ensure that the vector is empty
// Get Custom prefix
const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
rtl::OUString aStrTable = rDocOpt.GetInitTabPrefix();
const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
rtl::OUString aStrTable = rOpt.GetInitTabPrefix();
rtl::OUStringBuffer rName;
bool bOk = false;

View File

@@ -0,0 +1,209 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
* Albert Thuswaldner <albert.thuswaldner@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2012 the
* Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include "defaultsoptions.hxx"
#include "miscuno.hxx"
#include "global.hxx"
#include "globstr.hrc"
using namespace utl;
using namespace com::sun::star::uno;
using ::rtl::OUString;
// -----------------------------------------------------------------------
TYPEINIT1(ScTpDefaultsItem, SfxPoolItem);
// -----------------------------------------------------------------------
ScDefaultsOptions::ScDefaultsOptions()
{
SetDefaults();
}
ScDefaultsOptions::ScDefaultsOptions( const ScDefaultsOptions& rCpy ) :
nInitTabCount( rCpy.nInitTabCount ),
aInitTabPrefix( rCpy.aInitTabPrefix )
{
}
ScDefaultsOptions::~ScDefaultsOptions()
{
}
void ScDefaultsOptions::SetDefaults()
{
nInitTabCount = 3;
aInitTabPrefix = ScGlobal::GetRscString(STR_TABLE_DEF); // Default Prefix "Sheet"
}
ScDefaultsOptions& ScDefaultsOptions::operator=( const ScDefaultsOptions& rCpy )
{
nInitTabCount = rCpy.nInitTabCount;
aInitTabPrefix = rCpy.aInitTabPrefix;
return *this;
}
bool ScDefaultsOptions::operator==( const ScDefaultsOptions& rOpt ) const
{
return rOpt.nInitTabCount == nInitTabCount
&& rOpt.aInitTabPrefix == aInitTabPrefix;
}
bool ScDefaultsOptions::operator!=( const ScDefaultsOptions& rOpt ) const
{
return !(operator==(rOpt));
}
// -----------------------------------------------------------------------
ScTpDefaultsItem::ScTpDefaultsItem( sal_uInt16 nWhichP, const ScDefaultsOptions& rOpt ) :
SfxPoolItem ( nWhichP ),
theOptions ( rOpt )
{
}
ScTpDefaultsItem::ScTpDefaultsItem( const ScTpDefaultsItem& rItem ) :
SfxPoolItem ( rItem ),
theOptions ( rItem.theOptions )
{
}
ScTpDefaultsItem::~ScTpDefaultsItem()
{
}
String ScTpDefaultsItem::GetValueText() const
{
return String::CreateFromAscii( "ScTpDefaultsItem" );
}
int ScTpDefaultsItem::operator==( const SfxPoolItem& rItem ) const
{
OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
const ScTpDefaultsItem& rPItem = (const ScTpDefaultsItem&)rItem;
return ( theOptions == rPItem.theOptions );
}
SfxPoolItem* ScTpDefaultsItem::Clone( SfxItemPool * ) const
{
return new ScTpDefaultsItem( *this );
}
// -----------------------------------------------------------------------
#define CFGPATH_FORMULA "Office.Calc/Defaults"
#define SCDEFAULTSOPT_TAB_COUNT 0
#define SCDEFAULTSOPT_TAB_PREFIX 1
#define SCDEFAULTSOPT_COUNT 2
Sequence<OUString> ScDefaultsCfg::GetPropertyNames()
{
static const char* aPropNames[] =
{
"Sheet/SheetCount", // SCDEFAULTSOPT_TAB_COUNT
"Sheet/SheetPrefix" // SCDEFAULTSOPT_TAB_PREFIX
};
Sequence<OUString> aNames(SCDEFAULTSOPT_COUNT);
OUString* pNames = aNames.getArray();
for (int i = 0; i < SCDEFAULTSOPT_COUNT; ++i)
pNames[i] = OUString::createFromAscii(aPropNames[i]);
return aNames;
}
ScDefaultsCfg::ScDefaultsCfg() :
ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_FORMULA )) )
{
sal_Int32 nIntVal = 0;
OUString aPrefix;
Sequence<OUString> aNames = GetPropertyNames();
Sequence<Any> aValues = GetProperties(aNames);
const Any* pValues = aValues.getConstArray();
OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
if(aValues.getLength() == aNames.getLength())
{
for(int nProp = 0; nProp < aNames.getLength(); nProp++)
{
OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
if(pValues[nProp].hasValue())
{
switch (nProp)
{
case SCDEFAULTSOPT_TAB_COUNT:
if (pValues[nProp] >>= nIntVal)
SetInitTabCount( static_cast<SCTAB>(nIntVal) );
break;
case SCDEFAULTSOPT_TAB_PREFIX:
if (pValues[nProp] >>= aPrefix)
SetInitTabPrefix(aPrefix);
break;
}
}
}
}
}
void ScDefaultsCfg::Commit()
{
Sequence<OUString> aNames = GetPropertyNames();
Sequence<Any> aValues(aNames.getLength());
Any* pValues = aValues.getArray();
for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
{
switch(nProp)
{
case SCDEFAULTSOPT_TAB_COUNT:
pValues[nProp] <<= static_cast<sal_Int32>(GetInitTabCount());
break;
case SCDEFAULTSOPT_TAB_PREFIX:
pValues[nProp] <<= GetInitTabPrefix();
break;
}
}
PutProperties(aNames, aValues);
}
void ScDefaultsCfg::SetOptions( const ScDefaultsOptions& rNew )
{
*(ScDefaultsOptions*)this = rNew;
SetModified();
}
void ScDefaultsCfg::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -84,8 +84,6 @@ ScDocOptions::ScDocOptions()
ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
: fIterEps( rCpy.fIterEps ),
nIterCount( rCpy.nIterCount ),
nInitTabCount( rCpy.nInitTabCount ),
aInitTabPrefix( rCpy.aInitTabPrefix ),
nPrecStandardFormat( rCpy.nPrecStandardFormat ),
nDay( rCpy.nDay ),
nMonth( rCpy.nMonth ),
@@ -115,8 +113,6 @@ void ScDocOptions::ResetDocOptions()
bIsIgnoreCase = false;
bIsIter = false;
nIterCount = 100;
nInitTabCount = 3;
aInitTabPrefix = ScGlobal::GetRscString(STR_TABLE_DEF); // Default Prefix "Sheet"
fIterEps = 1.0E-3;
nPrecStandardFormat = SvNumberFormatter::UNLIMITED_PRECISION;
nDay = 30;
@@ -207,12 +203,6 @@ SfxPoolItem* ScTpCalcItem::Clone( SfxItemPool * ) const
#define SCDOCLAYOUTOPT_TABSTOP 0
#define SCDOCLAYOUTOPT_COUNT 1
#define CFGPATH_DEFAULTS "Office.Calc/Defaults"
#define SCDEFAULTSOPT_TAB_COUNT 0
#define SCDEFAULTSOPT_TAB_PREFIX 1
#define SCDEFAULTSOPT_COUNT 2
Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
{
static const char* aPropNames[] =
@@ -256,26 +246,9 @@ Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
return aNames;
}
Sequence<OUString> ScDocCfg::GetDefaultsPropertyNames()
{
static const char* aPropNames[] =
{
"Sheet/SheetCount", // SCDEFAULTSOPT_TAB_COUNT
"Sheet/SheetPrefix" // SCDEFAULTSOPT_TAB_PREFIX
};
Sequence<OUString> aNames(SCDEFAULTSOPT_COUNT);
OUString* pNames = aNames.getArray();
for (int i = 0; i < SCDEFAULTSOPT_COUNT; ++i)
pNames[i] = OUString::createFromAscii(aPropNames[i]);
return aNames;
}
ScDocCfg::ScDocCfg() :
aCalcItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_CALC )) ),
aLayoutItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DOCLAYOUT))),
aDefaultsItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DEFAULTS)))
aLayoutItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DOCLAYOUT)))
{
sal_Int32 nIntVal = 0;
@@ -370,32 +343,6 @@ ScDocCfg::ScDocCfg() :
}
}
aLayoutItem.SetCommitLink( LINK( this, ScDocCfg, LayoutCommitHdl ) );
aNames = GetDefaultsPropertyNames();
aValues = aDefaultsItem.GetProperties(aNames);
aDefaultsItem.EnableNotification(aNames);
pValues = aValues.getConstArray();
if (aValues.getLength() == aNames.getLength())
{
for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
{
switch (nProp)
{
case SCDEFAULTSOPT_TAB_COUNT:
nIntVal = 3; // 3 = 'Default'
if (pValues[nProp] >>= nIntVal)
SetInitTabCount( static_cast<SCTAB>(nIntVal) );
break;
case SCDEFAULTSOPT_TAB_PREFIX:
OUString aPrefix;
if (pValues[nProp] >>= aPrefix)
SetInitTabPrefix(aPrefix);
break;
}
}
}
aDefaultsItem.SetCommitLink( LINK(this, ScDocCfg, DefaultsCommitHdl) );
}
IMPL_LINK_NOARG(ScDocCfg, CalcCommitHdl)
@@ -477,35 +424,12 @@ IMPL_LINK_NOARG(ScDocCfg, LayoutCommitHdl)
return 0;
}
IMPL_LINK_NOARG(ScDocCfg, DefaultsCommitHdl)
{
Sequence<OUString> aNames = GetDefaultsPropertyNames();
Sequence<Any> aValues(aNames.getLength());
Any* pValues = aValues.getArray();
for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
{
switch(nProp)
{
case SCDEFAULTSOPT_TAB_COUNT:
pValues[nProp] <<= static_cast<sal_Int32>(GetInitTabCount());
break;
case SCDEFAULTSOPT_TAB_PREFIX:
pValues[nProp] <<= GetInitTabPrefix();
break;
}
}
aDefaultsItem.PutProperties(aNames, aValues);
return 0;
}
void ScDocCfg::SetOptions( const ScDocOptions& rNew )
{
*(ScDocOptions*)this = rNew;
aCalcItem.SetModified();
aLayoutItem.SetModified();
aDefaultsItem.SetModified();
}

View File

@@ -79,6 +79,7 @@
#include "viewopti.hxx"
#include "docoptio.hxx"
#include "appoptio.hxx"
#include "defaultsoptions.hxx"
#include "formulaopt.hxx"
#include "inputopt.hxx"
#include "printopt.hxx"
@@ -142,6 +143,7 @@ ScModule::ScModule( SfxObjectFactory* pFact ) :
pViewCfg( NULL ),
pDocCfg( NULL ),
pAppCfg( NULL ),
pDefaultsCfg( NULL ),
pFormulaCfg( NULL ),
pInputCfg( NULL ),
pPrintCfg( NULL ),
@@ -344,6 +346,7 @@ void ScModule::DeleteCfg()
DELETEZ( pViewCfg ); // Speichern passiert vor Exit() automatisch
DELETEZ( pDocCfg );
DELETEZ( pAppCfg );
DELETEZ( pDefaultsCfg );
DELETEZ( pFormulaCfg );
DELETEZ( pInputCfg );
DELETEZ( pPrintCfg );
@@ -852,6 +855,22 @@ const ScAppOptions& ScModule::GetAppOptions()
return *pAppCfg;
}
void ScModule::SetDefaultsOptions( const ScDefaultsOptions& rOpt )
{
if ( !pDefaultsCfg )
pDefaultsCfg = new ScDefaultsCfg;
pDefaultsCfg->SetOptions( rOpt );
}
const ScDefaultsOptions& ScModule::GetDefaultsOptions()
{
if ( !pDefaultsCfg )
pDefaultsCfg = new ScDefaultsCfg;
return *pDefaultsCfg;
}
void ScModule::SetFormulaOptions( const ScFormulaOptions& rOpt )
{
if ( !pFormulaCfg )
@@ -1045,6 +1064,16 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
}
}
//============================================
// DefaultsOptions
//============================================
if (rOptSet.HasItem(SID_SCDEFAULTSOPTIONS, &pItem))
{
const ScDefaultsOptions& rOpt = ((const ScTpDefaultsItem*)pItem)->GetDefaultsOptions();
SetDefaultsOptions( rOpt );
}
//============================================
// FormulaOptions
//============================================
@@ -1959,6 +1988,8 @@ SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId )
SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
// TP_COMPATIBILITY
SID_SC_OPT_KEY_BINDING_COMPAT, SID_SC_OPT_KEY_BINDING_COMPAT,
// TP_DEFAULTS
SID_SCDEFAULTSOPTIONS, SID_SCDEFAULTSOPTIONS,
// TP_FORMULA
SID_SCFORMULAOPTIONS, SID_SCFORMULAOPTIONS,
0 );
@@ -2031,6 +2062,9 @@ SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId )
pRet->Put( SfxUInt16Item( SID_SC_OPT_KEY_BINDING_COMPAT,
rAppOpt.GetKeyBindingType() ) );
// TP_DEFAULTS
pRet->Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS, GetDefaultsOptions() ) );
// TP_FORMULA
pRet->Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, GetFormulaOptions() ) );
}

View File

@@ -33,23 +33,19 @@
#include <vcl/fixed.hxx>
#include <vcl/field.hxx>
#include <boost/shared_ptr.hpp>
class ScDocOptions;
class ScTpDefaultsOptions : public SfxTabPage
{
public:
using SfxTabPage::DeactivatePage;
static SfxTabPage* Create (Window* pParent, const SfxItemSet& rCoreAttrs);
static SfxTabPage* Create (Window* pParent, const SfxItemSet& rCoreSet);
virtual sal_Bool FillItemSet(SfxItemSet& rCoreAttrs);
virtual void Reset(const SfxItemSet& rCoreAttrs);
virtual sal_Bool FillItemSet(SfxItemSet& rCoreSet);
virtual void Reset(const SfxItemSet& rCoreSet);
virtual int DeactivatePage(SfxItemSet* pSet = NULL);
private:
explicit ScTpDefaultsOptions(Window* pParent, const SfxItemSet& rCoreAttrs);
explicit ScTpDefaultsOptions(Window* pParent, const SfxItemSet& rCoreSet);
virtual ~ScTpDefaultsOptions();
void CheckNumSheets();
@@ -69,9 +65,6 @@ private:
// Stores old Sheet Prefix
::rtl::OUString maOldPrefixValue;
::boost::shared_ptr<ScDocOptions> mpOldOptions;
::boost::shared_ptr<ScDocOptions> mpNewOptions;
};
#endif

View File

@@ -33,18 +33,16 @@
#include "optdlg.hrc"
#include "scresid.hxx"
#include "scmod.hxx"
#include "docoptio.hxx"
#include "defaultsoptions.hxx"
#include "document.hxx"
#include "global.hxx"
#include "globstr.hrc"
#define INIT_SHEETS_MIN 1
#define INIT_SHEETS_MAX 1024
using ::rtl::OUString;
ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCoreAttrs) :
SfxTabPage(pParent, ScResId(RID_SCPAGE_DEFAULTS), rCoreAttrs),
ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCoreSet) :
SfxTabPage(pParent, ScResId(RID_SCPAGE_DEFAULTS), rCoreSet),
aFLInitSpreadSheet ( this, ScResId( FL_INIT_SPREADSHEET ) ),
aFtNSheets ( this, ScResId( FT_NSHEETS ) ),
aEdNSheets ( this, ScResId( ED_NSHEETS ) ),
@@ -53,11 +51,6 @@ ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCor
{
FreeResource();
const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
mpOldOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
mpNewOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
long nTxtW = aFtNSheets.GetCtrlTextWidth( aFtNSheets.GetText() );
long nCtrlW = aFtNSheets.GetSizePixel().Width();
if ( nTxtW >= nCtrlW )
@@ -83,27 +76,39 @@ SfxTabPage* ScTpDefaultsOptions::Create(Window *pParent, const SfxItemSet &rCore
return new ScTpDefaultsOptions(pParent, rCoreAttrs);
}
sal_Bool ScTpDefaultsOptions::FillItemSet(SfxItemSet &rCoreAttrs)
sal_Bool ScTpDefaultsOptions::FillItemSet(SfxItemSet &rCoreSet)
{
sal_Bool bRet = false;
ScDefaultsOptions aOpt;
SCTAB nTabCount = static_cast<SCTAB>(aEdNSheets.GetValue());
OUString aSheetPrefix = aEdSheetPrefix.GetText();
mpNewOptions->SetInitTabCount( nTabCount );
mpNewOptions->SetInitTabPrefix( aSheetPrefix );
if (*mpNewOptions != *mpOldOptions)
if ( aEdNSheets.GetSavedValue() != aEdNSheets.GetText()
|| static_cast<OUString>(aEdSheetPrefix.GetSavedValue()) != aSheetPrefix )
{
rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
return sal_True;
aOpt.SetInitTabCount( nTabCount );
aOpt.SetInitTabPrefix( aSheetPrefix );
rCoreSet.Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS, aOpt ) );
bRet = true;
}
else
return sal_False;
return bRet;
}
void ScTpDefaultsOptions::Reset(const SfxItemSet& /*rCoreAttrs*/)
void ScTpDefaultsOptions::Reset(const SfxItemSet& rCoreSet)
{
aEdNSheets.SetValue( static_cast<sal_uInt16>(mpOldOptions->GetInitTabCount()) );
aEdSheetPrefix.SetText( mpOldOptions->GetInitTabPrefix() );
ScDefaultsOptions aOpt;
const SfxPoolItem* pItem = NULL;
if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCDEFAULTSOPTIONS, false , &pItem))
aOpt = ((const ScTpDefaultsItem*)pItem)->GetDefaultsOptions();
aEdNSheets.SetValue( static_cast<sal_uInt16>( aOpt.GetInitTabCount()) );
aEdSheetPrefix.SetText( aOpt.GetInitTabPrefix() );
aEdNSheets.SaveValue();
aEdSheetPrefix.SaveValue();
}
int ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/)

View File

@@ -91,7 +91,7 @@
#include "navsett.hxx"
#include "scabstdlg.hxx"
#include "externalrefmgr.hxx"
#include "docoptio.hxx"
#include "defaultsoptions.hxx"
#include "markdata.hxx"
#include "preview.hxx"
@@ -1608,8 +1608,8 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
// Get the customized initial tab count...
// ... from option dialog.
const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
SCTAB nInitTabCount = rDocOpt.GetInitTabCount();
const ScDefaultsOptions& rOpt = SC_MOD()->GetDefaultsOptions();
SCTAB nInitTabCount = rOpt.GetInitTabCount();
// ... by VBA API.
const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();