[Libreoffice-commits] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Nov 23 22:22:59 PST 2011
sc/source/core/data/document.cxx | 17 ++++++++++-------
sc/source/filter/xml/xmlsubti.cxx | 14 --------------
2 files changed, 10 insertions(+), 21 deletions(-)
New commits:
commit 5992e15796131f9814d9fb22cf807a2ee530d264
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Thu Nov 24 01:19:10 2011 -0500
i#97680, fdo#43152: Load this file without crashing.
The document contains invalid sheet names. We check it on load, sees
it invalid, decide not to append sheet. The next time the importer
tries to put cell data into it thinking the sheet has already been
created, the sheet instance is not there, and it crashes.
The solution I used is to go ahead and append new sheet with a default
name in case the supplied sheet name is invalid.
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 5a50aef..52dc4ce 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -334,14 +334,15 @@ void ScDocument::CreateValidTabName(rtl::OUString& rName) const
for ( SCTAB i = static_cast<SCTAB>(maTabs.size())+1; !bOk ; i++ )
{
- rName = aStrTable;
- rName += rtl::OUString::valueOf(static_cast<sal_Int32>(i));
+ rtl::OUStringBuffer aBuf;
+ aBuf.append(aStrTable);
+ aBuf.append(static_cast<sal_Int32>(i));
+ rName = aBuf.makeStringAndClear();
if (bPrefix)
bOk = ValidNewTabName( rName );
else
bOk = !GetTable( rName, nDummy );
}
-
}
else
{
@@ -398,11 +399,13 @@ void ScDocument::CreateValidTabNames(std::vector<rtl::OUString>& aNames, SCTAB n
void ScDocument::AppendTabOnLoad(const rtl::OUString& rName)
{
SCTAB nTabCount = static_cast<SCTAB>(maTabs.size());
+ if (!ValidTab(nTabCount))
+ // max table count reached. No more tables.
+ return;
- if (ValidTab(nTabCount) && ValidNewTabName(rName))
- {
- maTabs.push_back( new ScTable(this, nTabCount, rName) );
- }
+ rtl::OUString aName = rName;
+ CreateValidTabName(aName);
+ maTabs.push_back( new ScTable(this, nTabCount, aName) );
}
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index 315bf2b..3ea979f 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -648,20 +648,6 @@ void ScMyTables::DeleteTable()
pProtect->setOption(ScTableProtection::SELECT_UNLOCKED_CELLS, maProtectionData.mbSelectUnprotectedCells);
rImport.GetDocument()->SetTabProtection(nCurrentSheet, pProtect.get());
}
-
- //#95582#; find out whether it was possible to set the sheet name
- // test it here, because if it is a linked table the name is changed by importing
- // the linking informations
- uno::Reference < container::XNamed > xNamed(xCurrentSheet, uno::UNO_QUERY );
- if ( xNamed.is() )
- {
- rtl::OUString sCurrentName(xNamed->getName());
- if (sCurrentName != sCurrentSheetName && rImport.GetDocument())
- {
- rImport.GetDocument()->RenameTab( nCurrentSheet,
- sCurrentSheetName, false, true);
- }
- }
}
table::CellAddress ScMyTables::GetRealCellPos()
More information about the Libreoffice-commits
mailing list