[Libreoffice-commits] .: officecfg/registry sc/inc sc/source

Noel Power noelp at kemper.freedesktop.org
Mon Jan 30 06:01:49 PST 2012


 officecfg/registry/schema/org/openoffice/Office/Calc.xcs |   13 +++-
 sc/inc/docoptio.hxx                                      |    7 +-
 sc/source/core/data/document.cxx                         |   16 ++++-
 sc/source/core/tool/docoptio.cxx                         |   17 ++++-
 sc/source/ui/inc/optdlg.hrc                              |    2 
 sc/source/ui/inc/tpdefaults.hxx                          |    7 +-
 sc/source/ui/optdlg/tpdefaults.cxx                       |   46 ++++++++++++---
 sc/source/ui/src/optdlg.src                              |   13 ++++
 8 files changed, 103 insertions(+), 18 deletions(-)

New commits:
commit 58ee2fad1ecb326f46795249b42fb23be3f8403e
Author: Albert Thuswaldner <albert.thuswaldner at gmail.com>
Date:   Mon Jan 30 12:56:37 2012 +0000

    Option to set tab prefix for new worksheets

diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 3efc2e3..700d716 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 8557a82..a960ec0 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 e5420cb..02790bc 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 3247eca..56b8871 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 15c32cf..5245bc6 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 374d0bc..606d174 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 afced22..8c97c83 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 8012628..edbf4b9 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 ) ;
+    };
 };


More information about the Libreoffice-commits mailing list