diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-24 01:19:10 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-24 01:19:10 -0500 |
commit | 5992e15796131f9814d9fb22cf807a2ee530d264 (patch) | |
tree | b9baeaf6214a9cc7aa4f9fb8da7b00826ce70851 /sc | |
parent | 92e03b82880ab1c83a1bfd59e179e3fb9f565257 (diff) |
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.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/data/document.cxx | 17 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlsubti.cxx | 14 |
2 files changed, 10 insertions, 21 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 5a50aef4ac52..52dc4cee7ab7 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 315bf2ba631c..3ea979fe59c6 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() |