summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Thuswaldner <albert.thuswaldner@gmail.com>2012-01-30 12:56:37 +0000
committerNoel Power <noel.power@novell.com>2012-01-30 14:02:21 +0000
commit58ee2fad1ecb326f46795249b42fb23be3f8403e (patch)
treee86fe9eee42c2cb11c85a2a96ea0ec824df73ba0
parentallow unaligned memory accesses only on x86/x86_64 (diff)
downloadcore-58ee2fad1ecb326f46795249b42fb23be3f8403e.tar.gz
core-58ee2fad1ecb326f46795249b42fb23be3f8403e.zip
Option to set tab prefix for new worksheets
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Calc.xcs13
-rw-r--r--sc/inc/docoptio.hxx7
-rw-r--r--sc/source/core/data/document.cxx16
-rw-r--r--sc/source/core/tool/docoptio.cxx17
-rw-r--r--sc/source/ui/inc/optdlg.hrc2
-rw-r--r--sc/source/ui/inc/tpdefaults.hxx7
-rw-r--r--sc/source/ui/optdlg/tpdefaults.cxx46
-rw-r--r--sc/source/ui/src/optdlg.src13
8 files changed, 103 insertions, 18 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 3efc2e3456bb..700d7165d13e 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1610,11 +1610,11 @@
<info>
<desc>Contains various defaults settings.</desc>
</info>
- <group oor:name="Other">
+ <group oor:name="Sheet">
<info>
- <desc>Other Program defaults</desc>
+ <desc>Sheet defaults</desc>
</info>
- <prop oor:name="TabCount" oor:type="xs:int" oor:nillable="false">
+ <prop oor:name="SheetCount" oor:type="xs:int" oor:nillable="false">
<!-- UIHints: Tools - Options - Spreadsheet - Defaults -->
<info>
<author>Albert Thuswaldner</author>
@@ -1622,6 +1622,13 @@
</info>
<value>3</value>
</prop>
+ <prop oor:name="SheetPrefix" oor:type="xs:string">
+ <!-- UIHints: Tools - Options - Spreadsheet - Defaults -->
+ <info>
+ <author>Albert Thuswaldner</author>
+ <desc>Option to set the prefix name for new sheet tabs</desc>
+ </info>
+ </prop>
</group>
</group>
</component>
diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index 8557a821cdba..a960ec0f4764 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -42,7 +42,8 @@ class SC_DLLPUBLIC ScDocOptions
{
double fIterEps; // epsilon value dazu
sal_uInt16 nIterCount; // number
- SCTAB nInitTabCount; // number of Tabs for new Spreadssheet doc
+ 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
ScOptionsUtil::KeyBindingType eKeyBindingType;
sal_uInt16 nDay; // Null date:
@@ -83,6 +84,8 @@ public:
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; }
@@ -139,6 +142,7 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
bIsIter = rCpy.bIsIter;
nIterCount = rCpy.nIterCount;
nInitTabCount = rCpy.nInitTabCount;
+ aInitTabPrefix = rCpy.aInitTabPrefix;
fIterEps = rCpy.fIterEps;
nPrecStandardFormat = rCpy.nPrecStandardFormat;
eKeyBindingType = rCpy.eKeyBindingType;
@@ -168,6 +172,7 @@ inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
&& rOpt.bIsIter == bIsIter
&& rOpt.nIterCount == nIterCount
&& rOpt.nInitTabCount == nInitTabCount
+ && rOpt.aInitTabPrefix == aInitTabPrefix
&& rOpt.fIterEps == fIterEps
&& rOpt.nPrecStandardFormat == nPrecStandardFormat
&& rOpt.eKeyBindingType == eKeyBindingType
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index e5420cb5403e..02790bc5b8a3 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -95,6 +95,7 @@
#include "tabprotection.hxx"
#include "clipparam.hxx"
#include "stlalgorithm.hxx"
+#include "docoptio.hxx"
#include <map>
#include <limits>
@@ -142,7 +143,10 @@ void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck )
{
if ( ValidTab(nTab) && ( nTab >= static_cast<SCTAB>(maTabs.size()) ||!maTabs[nTab]) )
{
- rtl::OUString aString = ScGlobal::GetRscString(STR_TABLE_DEF); //"Table"
+ // Get Custom prefix
+ const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
+ rtl::OUString aString = rDocOpt.GetInitTabPrefix();
+
aString += rtl::OUString::valueOf(static_cast<sal_Int32>(nTab+1));
if ( _bNeedsNameCheck )
CreateValidTabName( aString ); // no doubles
@@ -308,7 +312,10 @@ void ScDocument::CreateValidTabName(rtl::OUString& rName) const
{
// Find new one
- const rtl::OUString aStrTable( ResId::toString(ScResId(SCSTR_TABLE)) );
+ // Get Custom prefix
+ const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
+ rtl::OUString aStrTable = rDocOpt.GetInitTabPrefix();
+
bool bOk = false;
// First test if the prefix is valid, if so only avoid doubles
@@ -353,7 +360,10 @@ void ScDocument::CreateValidTabNames(std::vector<rtl::OUString>& aNames, SCTAB n
{
aNames.clear();//ensure that the vector is empty
- const rtl::OUString aStrTable( ResId::toString(ScResId(SCSTR_TABLE)) );
+ // Get Custom prefix
+ const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
+ rtl::OUString aStrTable = rDocOpt.GetInitTabPrefix();
+
rtl::OUStringBuffer rName;
bool bOk = false;
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index 3247ecaa63b9..56b8871307d5 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -44,6 +44,7 @@
#include "sc.hrc"
#include "miscuno.hxx"
#include "global.hxx"
+#include "globstr.hrc"
using namespace utl;
using namespace com::sun::star::uno;
@@ -88,6 +89,7 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
: fIterEps( rCpy.fIterEps ),
nIterCount( rCpy.nIterCount ),
nInitTabCount( rCpy.nInitTabCount ),
+ aInitTabPrefix( rCpy.aInitTabPrefix ),
nPrecStandardFormat( rCpy.nPrecStandardFormat ),
eKeyBindingType( rCpy.eKeyBindingType ),
nDay( rCpy.nDay ),
@@ -124,6 +126,7 @@ void ScDocOptions::ResetDocOptions()
bIsIter = false;
nIterCount = 100;
nInitTabCount = 3;
+ aInitTabPrefix = ScGlobal::GetRscString(STR_TABLE_DEF); // Default Prefix "Sheet"
fIterEps = 1.0E-3;
nPrecStandardFormat = SvNumberFormatter::UNLIMITED_PRECISION;
eKeyBindingType = ScOptionsUtil::KEY_DEFAULT;
@@ -290,7 +293,8 @@ SfxPoolItem* ScTpCalcItem::Clone( SfxItemPool * ) const
#define CFGPATH_DEFAULTS "Office.Calc/Defaults"
#define SCDEFAULTSOPT_TAB_COUNT 0
-#define SCDEFAULTSOPT_COUNT 1
+#define SCDEFAULTSOPT_TAB_PREFIX 1
+#define SCDEFAULTSOPT_COUNT 2
Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
@@ -372,7 +376,8 @@ Sequence<OUString> ScDocCfg::GetDefaultsPropertyNames()
{
static const char* aPropNames[] =
{
- "Other/TabCount" // SCDEFAULTSOPT_COUNT_TAB_COUNT
+ "Sheet/SheetCount", // SCDEFAULTSOPT_TAB_COUNT
+ "Sheet/SheetPrefix" // SCDEFAULTSOPT_TAB_PREFIX
};
Sequence<OUString> aNames(SCDEFAULTSOPT_COUNT);
OUString* pNames = aNames.getArray();
@@ -595,6 +600,11 @@ ScDocCfg::ScDocCfg() :
if (pValues[nProp] >>= nIntVal)
SetInitTabCount( static_cast<SCTAB>(nIntVal) );
break;
+ case SCDEFAULTSOPT_TAB_PREFIX:
+ OUString aPrefix;
+ if (pValues[nProp] >>= aPrefix)
+ SetInitTabPrefix(aPrefix);
+ break;
}
}
}
@@ -756,6 +766,9 @@ IMPL_LINK( ScDocCfg, DefaultsCommitHdl, void *, EMPTYARG )
case SCDEFAULTSOPT_TAB_COUNT:
pValues[nProp] <<= static_cast<sal_Int32>(GetInitTabCount());
break;
+ case SCDEFAULTSOPT_TAB_PREFIX:
+ pValues[nProp] <<= GetInitTabPrefix();
+ break;
}
}
aDefaultsItem.PutProperties(aNames, aValues);
diff --git a/sc/source/ui/inc/optdlg.hrc b/sc/source/ui/inc/optdlg.hrc
index 15c32cf8d98a..5245bc6d69ad 100644
--- a/sc/source/ui/inc/optdlg.hrc
+++ b/sc/source/ui/inc/optdlg.hrc
@@ -198,3 +198,5 @@
#define FL_INIT_SPREADSHEET 1
#define FT_NSHEETS 2
#define ED_NSHEETS 3
+#define FT_SHEETPREFIX 4
+#define ED_SHEETPREFIX 5
diff --git a/sc/source/ui/inc/tpdefaults.hxx b/sc/source/ui/inc/tpdefaults.hxx
index 374d0bcc7151..606d174cdbb0 100644
--- a/sc/source/ui/inc/tpdefaults.hxx
+++ b/sc/source/ui/inc/tpdefaults.hxx
@@ -53,15 +53,20 @@ private:
virtual ~ScTpDefaultsOptions();
void CheckNumSheets();
+ void CheckPrefix();
DECL_LINK( NumModifiedHdl, NumericField* );
+ DECL_LINK( PrefixModifiedHdl, Edit* );
private:
FixedLine aFLInitSpreadSheet;
FixedText aFtNSheets;
NumericField aEdNSheets;
+ FixedText aFtSheetPrefix;
+ Edit aEdSheetPrefix;
- ::boost::shared_ptr<ScDocOptions> mpLocalOptions;
+ ::boost::shared_ptr<ScDocOptions> mpOldOptions;
+ ::boost::shared_ptr<ScDocOptions> mpNewOptions;
};
#endif
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx
index afced223420b..8c97c83eda5b 100644
--- a/sc/source/ui/optdlg/tpdefaults.cxx
+++ b/sc/source/ui/optdlg/tpdefaults.cxx
@@ -29,26 +29,36 @@
#undef SC_DLLIMPLEMENTATION
+#include <vcl/msgbox.hxx>
+
#include "tpdefaults.hxx"
#include "optdlg.hrc"
#include "scresid.hxx"
#include "scmod.hxx"
#include "docoptio.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),
aFLInitSpreadSheet ( this, ScResId( FL_INIT_SPREADSHEET ) ),
aFtNSheets ( this, ScResId( FT_NSHEETS ) ),
- aEdNSheets ( this, ScResId( ED_NSHEETS ) )
+ aEdNSheets ( this, ScResId( ED_NSHEETS ) ),
+ aFtSheetPrefix ( this, ScResId( FT_SHEETPREFIX ) ),
+ aEdSheetPrefix ( this, ScResId( ED_SHEETPREFIX ) )
{
FreeResource();
const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
- mpLocalOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
+ mpOldOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
+ mpNewOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
long nTxtW = aFtNSheets.GetCtrlTextWidth( aFtNSheets.GetText() );
long nCtrlW = aFtNSheets.GetSizePixel().Width();
@@ -62,6 +72,7 @@ ScTpDefaultsOptions::ScTpDefaultsOptions(Window *pParent, const SfxItemSet &rCor
aEdNSheets.SetPosPixel( aNewPoint );
}
aEdNSheets.SetModifyHdl( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) );
+ aEdSheetPrefix.SetModifyHdl( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) );
}
ScTpDefaultsOptions::~ScTpDefaultsOptions()
@@ -76,12 +87,14 @@ SfxTabPage* ScTpDefaultsOptions::Create(Window *pParent, const SfxItemSet &rCore
sal_Bool ScTpDefaultsOptions::FillItemSet(SfxItemSet &rCoreAttrs)
{
SCTAB nTabCount = static_cast<SCTAB>(aEdNSheets.GetValue());
+ OUString aSheetPrefix = aEdSheetPrefix.GetText();
- if (mpLocalOptions->GetInitTabCount() != nTabCount)
- {
- mpLocalOptions->SetInitTabCount( nTabCount );
+ mpNewOptions->SetInitTabCount( nTabCount );
+ mpNewOptions->SetInitTabPrefix( aSheetPrefix );
- rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpLocalOptions));
+ if (*mpNewOptions != *mpOldOptions)
+ {
+ rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
return sal_True;
}
else
@@ -90,8 +103,8 @@ sal_Bool ScTpDefaultsOptions::FillItemSet(SfxItemSet &rCoreAttrs)
void ScTpDefaultsOptions::Reset(const SfxItemSet& /*rCoreAttrs*/)
{
- aEdNSheets.SetValue( static_cast<sal_uInt16>(mpLocalOptions->GetInitTabCount()) );
- CheckNumSheets();
+ aEdNSheets.SetValue( static_cast<sal_uInt16>(mpOldOptions->GetInitTabCount()) );
+ aEdSheetPrefix.SetText( mpOldOptions->GetInitTabPrefix() );
}
int ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/)
@@ -108,10 +121,27 @@ void ScTpDefaultsOptions::CheckNumSheets()
aEdNSheets.SetValue(INIT_SHEETS_MIN);
}
+void ScTpDefaultsOptions::CheckPrefix()
+{
+ OUString aSheetPrefix = aEdSheetPrefix.GetText();
+
+ if ( !ScDocument::ValidTabName( aSheetPrefix ) )
+ {
+ ErrorBox(this,WinBits(WB_OK|WB_DEF_OK), ScGlobal::GetRscString(STR_INVALIDTABNAME) ).Execute();
+ }
+}
+
+
IMPL_LINK( ScTpDefaultsOptions, NumModifiedHdl, NumericField*, EMPTYARG )
{
CheckNumSheets();
return 0;
}
+IMPL_LINK( ScTpDefaultsOptions, PrefixModifiedHdl, Edit*, EMPTYARG )
+{
+ CheckPrefix();
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src
index 801262827576..edbf4b978a11 100644
--- a/sc/source/ui/src/optdlg.src
+++ b/sc/source/ui/src/optdlg.src
@@ -940,4 +940,17 @@ TabPage RID_SCPAGE_DEFAULTS
Spin = TRUE ;
Repeat = TRUE ;
};
+ FixedText FT_SHEETPREFIX
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 120 , 8 ) ;
+ Text [ en-US ] = "Prefix name for new worksheet";
+ };
+ Edit ED_SHEETPREFIX
+ {
+ HelpID = "sc:Edit:RID_SCPAGE_CALC:ED_SHEETPREFIX";
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 130 , 32 ) ;
+ Size = MAP_APPFONT ( 45 , 12 ) ;
+ };
};