Hi Rob,

On Sat, May 28, 2011 at 01:01, Rob Snelders <programm...@ertai.nl> wrote:
> Hi Albert,
>
> I have worked on this bug before I heard that you had already worked on it.
> Did you work any further on it? Maybe we can callaborate on it?

Oh, how far did you come? I think I basically have done most of it by now.

> I have found the place where the number of sheets is set. This is in
> http://opengrok.libreoffice.org/xref/calc/sc/source/core/tool/appoptio.cxx#88

No I don't think that is where you set it. The methods:

SetTabCountInNewSpreadsheet
GetTabCountInNewSpreadsheet

are used by the vba scripting api to set/get the number of sheets. But
using these methods will not save the the number of sheets to the
configuration file. I did a failled implementation of that, see the
attached files:

tpinit.cxx.appoptio
tpinit.hxx.appoptio

That's at least what I have managed to figure out. So instead I have
basically implemented the same methods in docoptio.cxx/hxx though I
have some bugs to straighten out. Attached the diff on what I have
done so far.

/Albert


> Please let me know.
>
> Greetings,
> Rob Snelders
>
> On 18-05-11 08:39, Albert Thuswaldner wrote:
>>
>> Hi Kohei,
>> Thanks for your help.
>>
>> On Mon, May 9, 2011 at 21:19, Kohei Yoshida<kyosh...@novell.com>  wrote:
>>>
>>> On Sun, 2011-05-08 at 17:09 +0200, Albert Thuswaldner wrote:
>>>>
>>>> Dear List,
>>>> As a first attempt to contribute some code to LO, I've started hacking
>>>> on his:
>>>>
>>>> https://bugs.freedesktop.org/show_bug.cgi?id=33293
>>>>
>>>> I think I have come quite far with implementing the changes to the
>>>> configuration dialog (see the patch). Here there is still some things
>>>> to do, like figuring out why the contents of the tab page isn't
>>>> showing up. Any hints?
>>>
>>> So, when you say the contents of the tag page isn't showing up, do you
>>> mean the page entry is not in the tree on the left at all, or the entry
>>> is there but the page shows up empty?
>>
>> The page entry was in the tree but the tab page itself showed up
>> empty. However, I have solved this part now! :)
>> There was an additional place in the code that needed to be modified.
>>
>>>> Also why are many of the same resource id's defined both in
>>>> libs-core/svx/source/src/app.hrc and
>>>> libs-core/svx/inc/svx/dialogs.hrc?
>>>
>>> I have no clue about this.  Maybe it's a remnant of one of those code
>>> relocation efforts that took place awhile ago in the OOo code?
>>>
>>>> For the other part of problem i.e, how to actually set the number of
>>>> sheets for a new spreadsheet, I am completely lost. I haven't found
>>>> where in the code this should be done, (using opengrok.+ guessing).
>>>> Could someone please give me a hint on how to go about finding this?
>>>> How is a new spreadsheet generated? xml template? through using the
>>>> internal api?
>>>
>>> Check around the ScTable class.  That's the class that implements each
>>> sheet instance.  Especially pay close attention to its constructor, and
>>> assuming that it gets called three times during the startup of Calc, you
>>> can perhaps set a break point in there to see who instaniates it 3
>>> times, and trace back from there.
>>
>> I've mostly focused on the configuration part as of yet, now I will
>> focus on this part.
>> Thanks for the hint.
>>
>>> Great to see you working on this, BTW.
>>>
>>> Kohei
>>>
>>> --
>>> Kohei Yoshida, LibreOffice hacker, Calc
>>> <kyosh...@novell.com>
>>>
>>
>> /Albert
>> _______________________________________________
>> LibreOffice mailing list
>> LibreOffice@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>

Attachment: tpinit.cxx.appoptio
Description: Binary data

Attachment: tpinit.hxx.appoptio
Description: Binary data

diff --git a/sc/Library_scui.mk b/sc/Library_scui.mk
index 1e0ef6b..bc7bf48 100644
--- a/sc/Library_scui.mk
+++ b/sc/Library_scui.mk
@@ -103,6 +103,7 @@ $(eval $(call gb_Library_add_exception_objects,scui,\
     sc/source/ui/optdlg/tpcalc \
     sc/source/ui/optdlg/tpcompatibility \
     sc/source/ui/optdlg/tpformula \
+    sc/source/ui/optdlg/tpinit \
     sc/source/ui/optdlg/tpprint \
     sc/source/ui/optdlg/tpusrlst \
     sc/source/ui/optdlg/tpview \
diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index 9ca84eb..f06d6e7 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -41,6 +41,7 @@ class SC_DLLPUBLIC ScDocOptions
 {
     double fIterEps;				// epsilon value dazu
     sal_uInt16 nIterCount;				// number
+    sal_Int16 nInitSheet;				// number of Sheets for new Spreadssheet doc
     sal_uInt16 nPrecStandardFormat; // precision for standard format
     ScOptionsUtil::KeyBindingType eKeyBindingType;
     sal_uInt16 nDay;					// Null date:
@@ -79,6 +80,8 @@ public:
     void   SetIter( sal_Bool bVal )			{ bIsIter = bVal; }
     sal_uInt16 GetIterCount() const			{ return nIterCount; }
     void   SetIterCount( sal_uInt16 nCount) { nIterCount = nCount; }
+    sal_Int16 GetInitSheet() const			{ return nInitSheet; }
+    void   SetInitSheet( sal_Int16 nSheet) { nInitSheet = nSheet; }
     double GetIterEps() const			{ return fIterEps; }
     void   SetIterEps( double fEps )	{ fIterEps = fEps; }
 
@@ -221,6 +224,7 @@ class ScDocCfg : public ScDocOptions
     ScLinkConfigItem    aFormulaItem;
     ScLinkConfigItem	aLayoutItem;
     ScLinkConfigItem    aCompatItem;
+    ScLinkConfigItem    aInitItem;
 
     DECL_LINK( CalcCommitHdl, void* );
     DECL_LINK( FormulaCommitHdl, void* );
@@ -231,6 +235,7 @@ class ScDocCfg : public ScDocOptions
     com::sun::star::uno::Sequence<rtl::OUString> GetFormulaPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetCompatPropertyNames();
+    com::sun::star::uno::Sequence<rtl::OUString> GetInitPropertyNames();
 
 public:
             ScDocCfg();
diff --git a/sc/inc/helpids.h b/sc/inc/helpids.h
index de666a3..4853953 100644
--- a/sc/inc/helpids.h
+++ b/sc/inc/helpids.h
@@ -99,7 +99,7 @@
 #define HID_SCPAGE_COMPATIBILITY                                "SC_HID_SCPAGE_COMPATIBILITY"
 #define HID_SCPAGE_TABLE                                        "SC_HID_SCPAGE_TABLE"
 #define HID_SCPAGE_PRINT                                        "SC_HID_SCPAGE_PRINT"
-
+#define HID_SCPAGE_INIT                                         "SC_HID_SCPAGE_INIT"
 #define HID_SCPAGE_SUBT_GROUP1                                  "SC_HID_SCPAGE_SUBT_GROUP1"
 #define HID_SCPAGE_SUBT_GROUP2                                  "SC_HID_SCPAGE_SUBT_GROUP2"
 #define HID_SCPAGE_SUBT_GROUP3                                  "SC_HID_SCPAGE_SUBT_GROUP3"
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index ffaa64c..d182be3 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -1251,5 +1251,8 @@
 // compatibility options page
 #define RID_SCPAGE_COMPATIBILITY    (SC_OOO_BUILD_START + 9)
 
+// init option page
+#define RID_SCPAGE_INIT             (SC_OOO_BUILD_START + 10)
+
 #endif
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3e86a75..001d515 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -30,6 +30,7 @@
 #include "precompiled_sc.hxx"
 
 // INCLUDE ---------------------------------------------------------------
+#include <iostream>
 
 #define _ZFORLIST_DECLARE_TABLE
 #include "scitems.hxx"
@@ -138,6 +139,7 @@ typedef std::set<ScDefaultAttr, ScLessDefaultAttr>	ScDefaultAttrSet;
 
 void ScDocument::MakeTable( SCTAB nTab,bool _bNeedsNameCheck )
 {
+    std::cout << "MakeTable\n";
     if ( ValidTab(nTab) && !pTab[nTab] )
     {
         String aString = ScGlobal::GetRscString(STR_TABLE_DEF); //"Table"
@@ -340,6 +342,7 @@ sal_Bool ScDocument::InsertTab( SCTAB nPos, const String& rName,
 {
     SCTAB	nTabCount = GetTableCount();
     sal_Bool	bValid = ValidTab(nTabCount);
+    std::cout << "InsertTab\n";
     if ( !bExternalDocument )	// else test rName == "'Doc'!Tab" first
         bValid = (bValid && ValidNewTabName(rName));
     if (bValid)
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 779fcb7..befce2e 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -30,6 +30,7 @@
 #include "precompiled_sc.hxx"
 
 // INCLUDE ---------------------------------------------------------------
+#include <iostream>
 
 #include "scitems.hxx"
 #include <svx/algitem.hxx>
@@ -302,6 +303,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
     }
 
     ScDrawLayer* pDrawLayer = pDocument->GetDrawLayer();
+    std::cout << "ScTable\n";
     if (pDrawLayer)
     {
         if ( pDrawLayer->ScAddPage( nTab ) )    // sal_False (not inserted) during Undo
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index bfb0d42..87490c8 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -91,6 +91,7 @@ ScDocOptions::ScDocOptions()
 ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
         :   fIterEps( rCpy.fIterEps ),
             nIterCount( rCpy.nIterCount ),
+            nInitSheet( rCpy.nInitSheet ),
             nPrecStandardFormat( rCpy.nPrecStandardFormat ),
             eKeyBindingType( rCpy.eKeyBindingType ),
             nDay( rCpy.nDay ),
@@ -126,6 +127,7 @@ void ScDocOptions::ResetDocOptions()
     bIsIgnoreCase		= false;
     bIsIter				= false;
     nIterCount			= 100;
+    nInitSheet          = 3;
     fIterEps			= 1.0E-3;
     nPrecStandardFormat = SvNumberFormatter::UNLIMITED_PRECISION;
     eKeyBindingType     = ScOptionsUtil::KEY_DEFAULT;
@@ -290,6 +292,11 @@ SfxPoolItem* ScTpCalcItem::Clone( SfxItemPool * ) const
 #define SCCOMPATOPT_KEY_BINDING     0
 #define SCCOMPATOPT_COUNT           1
 
+#define CFGPATH_INIT         "Office.Calc/Initialize"
+#define SCINIT_SHEET_COUNT          0
+#define SCINITALIZE_COUNT           1
+
+
 Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
 {
     static const char* aPropNames[] =
@@ -355,7 +362,7 @@ Sequence<OUString> ScDocCfg::GetCompatPropertyNames()
 {
     static const char* aPropNames[] =
     {
-        "KeyBindings/BaseGroup"             // SCCOMPATOPT_KEY_BINDING
+        "KeyBindings/BaseGroup"             // SCINIT_SHEET_COUNT
     };
     Sequence<OUString> aNames(SCCOMPATOPT_COUNT);
     OUString* pNames = aNames.getArray();
@@ -365,11 +372,27 @@ Sequence<OUString> ScDocCfg::GetCompatPropertyNames()
     return aNames;
 }
 
+Sequence<OUString> ScDocCfg::GetInitPropertyNames()
+{
+    static const char* aPropNames[] =
+    {
+        "Other/TabCount"             // SCCOMPATOPT_KEY_BINDING
+    };
+    Sequence<OUString> aNames(SCINITALIZE_COUNT);
+    OUString* pNames = aNames.getArray();
+    for (int i = 0; i < SCINITALIZE_COUNT; ++i)
+        pNames[i] = OUString::createFromAscii(aPropNames[i]);
+
+    return aNames;
+}
+
+
 ScDocCfg::ScDocCfg() :
     aCalcItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_CALC )) ),
     aFormulaItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_FORMULA))),
     aLayoutItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DOCLAYOUT))),
-    aCompatItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_COMPAT)))
+    aCompatItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_COMPAT))),
+    aInitItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_INIT)))
 {
     sal_Int32 nIntVal = 0;
 
@@ -711,6 +734,7 @@ void ScDocCfg::SetOptions( const ScDocOptions& rNew )
     aFormulaItem.SetModified();
     aLayoutItem.SetModified();
     aCompatItem.SetModified();
+    aInitItem.SetModified();
 }
 
 
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 097893f..9f8c2d2 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -100,13 +100,13 @@
 #include "dwfunctr.hxx"
 #include "formdata.hxx"
 #include "tpprint.hxx"
+#include "tpinit.hxx"
 #include "transobj.hxx"
 #include "detfunc.hxx"
 #include "preview.hxx"
 
 #include <svx/xmlsecctrl.hxx>
 
-
 #define ScModule
 #include "scslots.hxx"
 
@@ -2054,6 +2054,14 @@ SfxTabPage*	 ScModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const Sfx
                                         pRet = (*ScTpPrintOptionsCreate)( pParent, rSet);
                                 }
             break;
+        case RID_SC_TP_INIT:
+            {
+                ::CreateTabPage ScTpInitOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_INIT );
+                if ( ScTpInitOptionsCreate )
+                    pRet = (*ScTpInitOptionsCreate)( pParent, rSet);
+            }
+            break;
+
         case RID_OFA_TP_INTERNATIONAL:
         {
             SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index faf0f29..d562705 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -83,6 +83,7 @@
 #include "tpformula.hxx"
 #include "datafdlg.hxx"
 #include "tpcompatibility.hxx"
+#include "tpinit.hxx"
 
 // ause
 #include "editutil.hxx"
@@ -1608,6 +1609,8 @@ CreateTabPage ScAbstractDialogFactory_Impl::GetTabPageCreatorFunc( sal_uInt16 nI
             return ScTpFormulaOptions::Create;
         case RID_SCPAGE_COMPATIBILITY:
             return ScTpCompatOptions::Create;
+        case RID_SCPAGE_INIT:
+            return ScTpInitOptions::Create;
         case	RID_SCPAGE_PRINT :
             return ScTpPrintOptions::Create;
             //break;
diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx
index 0a163a7..acffa7f 100644
--- a/sc/source/ui/docshell/docsh2.cxx
+++ b/sc/source/ui/docshell/docsh2.cxx
@@ -27,6 +27,7 @@
  ************************************************************************/
 
 // MARKER(update_precomp.py): autogen include statement, do not remove
+#include <iostream>
 #include "precompiled_sc.hxx"
 
 
@@ -73,7 +74,7 @@ sal_Bool ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" );
 
     sal_Bool bRet = SfxObjectShell::InitNew( xStor );
-
+    std::cout << "InitNew\n";
     aDocument.MakeTable(0);
     //	zusaetzliche Tabellen werden von der ersten View angelegt,
     //	wenn bIsEmpty dann noch sal_True ist
diff --git a/sc/source/ui/inc/optdlg.hrc b/sc/source/ui/inc/optdlg.hrc
index d62819b..1e3e369 100644
--- a/sc/source/ui/inc/optdlg.hrc
+++ b/sc/source/ui/inc/optdlg.hrc
@@ -194,3 +194,8 @@
 #define FL_KEY_BINDINGS       1
 #define FT_KEY_BINDINGS       2
 #define LB_KEY_BINDINGS       3
+
+// TP_INIT
+#define FL_INIT_SPREADSHEET  1
+#define FT_NSHEETS           2
+#define ED_NSHEETS           3
diff --git a/sc/source/ui/inc/tpinit.hxx b/sc/source/ui/inc/tpinit.hxx
new file mode 100644
index 0000000..d8984c8
--- /dev/null
+++ b/sc/source/ui/inc/tpinit.hxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2010 Novell, Inc.
+ *
+ * LibreOffice - a multi-platform office productivity suite
+ *
+ * This file is part of LibreOffice.
+ *
+ * LibreOffice is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * LibreOffice is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with LibreOffice.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __SC_TPINIT_HXX__
+#define __SC_TPINIT_HXX__
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+class ScDocOptions;
+
+class ScTpInitOptions : public SfxTabPage
+{
+public:
+    using SfxTabPage::DeactivatePage;
+
+    static  SfxTabPage* Create (Window* pParent, const SfxItemSet& rCoreAttrs);
+
+    virtual sal_Bool FillItemSet(SfxItemSet& rCoreAttrs);
+    virtual void Reset(const SfxItemSet& rCoreAttrs);
+    virtual int DeactivatePage(SfxItemSet* pSet = NULL);
+
+private:
+    explicit ScTpInitOptions(Window* pParent, const SfxItemSet& rCoreAttrs);
+    virtual ~ScTpInitOptions();
+
+private:
+    FixedLine     aFLInitSpreadSheet;
+    FixedText     aFtNSheets;
+    NumericField  aEdNSheets;
+
+    ::boost::shared_ptr<ScDocOptions> mpLocalOptions;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpinit.cxx b/sc/source/ui/optdlg/tpinit.cxx
new file mode 100644
index 0000000..4d33315
--- /dev/null
+++ b/sc/source/ui/optdlg/tpinit.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2010 Novell, Inc.
+ *
+ * LibreOffice - a multi-platform office productivity suite
+ *
+ * This file is part of LibreOffice.
+ *
+ * LibreOffice is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * LibreOffice is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with LibreOffice.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <iostream>
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "tpinit.hxx"
+#include "optdlg.hrc"
+#include "scresid.hxx"
+#include "docoptio.hxx"
+
+// Default is three worksheets for a new spreadsheet
+static sal_Int16 nNSheets = 3;
+
+ScTpInitOptions::ScTpInitOptions(Window *pParent, const SfxItemSet &rCoreAttrs) :
+    SfxTabPage(pParent, ScResId(RID_SCPAGE_INIT), rCoreAttrs),
+    aFLInitSpreadSheet ( this, ScResId( FL_INIT_SPREADSHEET ) ),
+    aFtNSheets         ( this, ScResId( FT_NSHEETS ) ),
+    aEdNSheets 		   ( this, ScResId( ED_NSHEETS ) )
+{
+    FreeResource();
+
+    const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
+        rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
+    mpLocalOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
+}
+
+ScTpInitOptions::~ScTpInitOptions()
+{
+}
+
+SfxTabPage* ScTpInitOptions::Create(Window *pParent, const SfxItemSet &rCoreAttrs)
+{
+    return new ScTpInitOptions(pParent, rCoreAttrs);
+}
+
+sal_Bool ScTpInitOptions::FillItemSet(SfxItemSet &rCoreAttrs)
+{
+    sal_Int16 nNSheet = (sal_Int16) aEdNSheets.GetValue(); 
+
+    std::cout << nNSheet << "\n";
+
+    if ( mpLocalOptions->GetInitSheet() != nNSheet)
+     {
+         mpLocalOptions->SetInitSheet( nNSheet );
+
+         rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpLocalOptions));
+         std::cout << mpLocalOptions->GetInitSheet() << "\n";
+
+       return sal_True;
+     }
+    else
+     return sal_False;
+}
+
+void ScTpInitOptions::Reset(const SfxItemSet &/*rCoreAttrs*/)
+{
+    //    aEdNSheets.SetValue( mpNewOptions->GetInitSheet(), 3);
+    aEdNSheets.SetValue( (sal_uInt16) mpLocalOptions->GetInitSheet() );
+    //    aEdNSheets.SetValue(nNSheets);
+}
+
+int ScTpInitOptions::DeactivatePage(SfxItemSet* /*pSet*/)
+{
+    return KEEP_PAGE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src
index a73f582..e6bf41b 100644
--- a/sc/source/ui/src/optdlg.src
+++ b/sc/source/ui/src/optdlg.src
@@ -908,3 +908,35 @@ TabPage RID_SCPAGE_PRINT
         Text [ en-US ] = "~Print only selected sheets";
     };
 };
+
+TabPage RID_SCPAGE_INIT
+{
+    HelpId = HID_SCPAGE_INIT ;
+    SVLook = TRUE ;
+    Hide = TRUE ;
+    Pos = MAP_APPFONT ( 0 , 0 ) ;
+    Size = MAP_APPFONT ( 260 , 185 ) ;
+    FixedLine FL_INIT_SPREADSHEET
+    {
+        Pos = MAP_APPFONT ( 6 , 3 ) ;
+        Size = MAP_APPFONT ( 248 , 8 ) ;
+        Text [ en-US ] = "New Spreadsheet";
+    };
+    FixedText FT_NSHEETS
+    {
+        Pos = MAP_APPFONT ( 12 , 32 ) ;
+        Size = MAP_APPFONT ( 60 , 8 ) ;
+        Text [ en-US ] = "Number of worksheets in new document";
+    };
+    NumericField ED_NSHEETS
+    {
+        HelpID = "sc:NumericField:RID_SCPAGE_CALC:ED_NSHEETS";
+        Border = TRUE ;
+        Pos = MAP_APPFONT ( 80 , 32 ) ;
+        Size = MAP_APPFONT ( 25 , 12 ) ;
+        Minimum = 1 ;
+        Maximum = 1024 ;
+        Spin = TRUE ;
+        Repeat = TRUE ;
+    };
+};
\ No newline at end of file
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 856b2dc..1e10d5a 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -30,7 +30,7 @@
 #include "precompiled_sc.hxx"
 
 // System - Includes -----------------------------------------------------
-
+#include <iostream>
 
 
 // INCLUDE ---------------------------------------------------------------
@@ -1457,6 +1457,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
 
         ScDocument* pDoc = aViewData.GetDocument();
 
+        std::cout << "SetTabNo\n";
         pDoc->MakeTable( nTab );
 
         // Update pending row heights before switching the sheet, so Reschedule from the progress bar
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index fdc39f5..17d64fb 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -97,6 +97,7 @@
 #include "sc.hrc"
 #include "scabstdlg.hxx"
 #include "externalrefmgr.hxx"
+#include "docoptio.hxx"
 
 void ActivateOlk( ScViewData* pViewData );
 void DeActivateOlk( ScViewData* pViewData );
@@ -1596,8 +1597,15 @@ void ScTabViewShell::Construct( sal_uInt8 nForceDesignMode )
             // append additional sheets (not for OLE object)
             if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
             {
-                SCTAB nInitTabCount = 3;							//!	konfigurierbar !!!
-                // Get the customized initial tab count, we only can set the count by VBA API currently.
+                SCTAB nInitTabCount = 3;
+
+                // Get the customized initial tab count...
+
+                // ... from option dialog.
+                const ScDocOptions& rDocOpt = SC_MOD()->GetDocOptions();
+                //SCTAB nNewTabCount = rDocOpt.GetInitSheet();
+                nInitTabCount = rDocOpt.GetInitSheet();
+                // ... by VBA API.
                 const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
                 SCTAB nNewTabCount = rAppOpt.GetTabCountInNewSpreadsheet();
                 if ( nNewTabCount >= 1 && nNewTabCount <= MAXTAB )
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index e84eedb..c449ae6 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -438,6 +438,7 @@ static OptionsMapping_Impl const OptionsMap_Impl[] =
     { "Math",               "Settings",             SID_SM_TP_PRINTOPTIONS },
     { "Calc",               NULL,                   SID_SC_EDITOPTIONS },
     { "Calc",               "General",              SID_SC_TP_LAYOUT },
+    { "Calc",               "Initialize",           RID_SC_TP_INIT },
     { "Calc",               "View",                 SID_SC_TP_CONTENT },
     { "Calc",               "International",        RID_OFA_TP_INTERNATIONAL },
     { "Calc",               "Calculate",            SID_SC_TP_CALC },
diff --git a/cui/source/options/treeopt.src b/cui/source/options/treeopt.src
index a1924ad..2159bd0 100644
--- a/cui/source/options/treeopt.src
+++ b/cui/source/options/treeopt.src
@@ -237,6 +237,7 @@ Resource RID_OFADLG_OPTIONS_TREE_PAGES
         {
             < "%PRODUCTNAME Calc" ; 0; > ;
             < "General" ;			SID_SC_TP_LAYOUT			;> ;
+            < "Initialize" ;	        RID_SC_TP_INIT			;> ;
             < "View" ;			SID_SC_TP_CONTENT			;> ;
             < "International" ;		RID_OFA_TP_INTERNATIONAL	;> ;
             < "Calculate" ;			SID_SC_TP_CALC				;> ;
diff --git a/helpcontent2/helpers/help_hid.lst b/helpcontent2/helpers/help_hid.lst
index 3164a82..5cc067c 100644
--- a/helpcontent2/helpers/help_hid.lst
+++ b/helpcontent2/helpers/help_hid.lst
@@ -3520,6 +3520,7 @@ HID_SCPAGE_SUBT_GROUP2,58886,
 HID_SCPAGE_SUBT_GROUP3,58887,
 HID_SCPAGE_SUBT_OPTIONS,58875,
 HID_SCPAGE_TABLE,58883,
+HID_SCPAGE_TABLE,58894,
 HID_SCPAGE_USERLISTS,58880,
 HID_SCRIPTORG_DIALOG,39987,
 HID_SCRIPTSBOX,40011,
diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc
index 4a30eb4..643b8c5 100755
--- a/svx/inc/svx/dialogs.hrc
+++ b/svx/inc/svx/dialogs.hrc
@@ -166,6 +166,7 @@
 #define	RID_OFA_TP_INTERNATIONAL_SD		(RID_OFA_START + 253)
 #define	RID_OFA_TP_INTERNATIONAL_IMPR	(RID_OFA_START + 254)
 #define	RID_OFA_TP_INTERNATIONAL		(RID_OFA_START + 252) // calc
+#define RID_SC_TP_INIT         		(RID_OFA_START + 253)
 
 //---------------------------------------------------------------------
 // ResId's fuer die Zeichen-TabPages
diff --git a/svx/source/src/app.hrc b/svx/source/src/app.hrc
index 69f5766..75c1d96 100755
--- a/svx/source/src/app.hrc
+++ b/svx/source/src/app.hrc
@@ -199,6 +199,7 @@
 #define RID_SW_TP_OPTCAPTION_PAGE       (RID_OFA_START + 256)
 #define SID_SC_TP_FORMULA               (RID_OFA_START + 257)
 #define SID_SC_TP_COMPATIBILITY         (RID_OFA_START + 258)
+#define RID_SC_TP_INIT         		(RID_OFA_START + 259)
 
 // Strings ------------------------------------------
 
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to