diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-11-12 07:16:05 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-11-12 07:22:07 +0100 |
commit | eb240530443b964ea45bf80a5e3711e11a3f09c5 (patch) | |
tree | 5758fff3a7b509fce21477dc185b4e47e02805f6 /sc | |
parent | 51533c729fc57dea539163f45fb5152a864467f0 (diff) |
remove conditional formats withiout range after import, related fdo#56983
Change-Id: I9a8c02369c3e5a12310a46229bdc1671f75593ad
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/conditio.hxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 20 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.cxx | 11 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.hxx | 2 |
4 files changed, 35 insertions, 4 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index afcfd0138d62..d60da24db422 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -409,6 +409,12 @@ public: void InsertNew( ScConditionalFormat* pNew ) { maConditionalFormats.insert(pNew); } + /** + * Checks that all cond formats have a non empty range. + * Deletes empty cond formats. + * @return true if all cond formats were valid + */ + bool CheckAllEntries(); ScConditionalFormat* GetFormat( sal_uInt32 nKey ); diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index f164cc48aa40..ecece736a86a 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1975,20 +1975,32 @@ void ScConditionalFormatList::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos ) itr->UpdateMoveTab( nOldPos, nNewPos ); } -void ScConditionalFormatList::DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) +bool ScConditionalFormatList::CheckAllEntries() { - for( iterator itr = begin(); itr != end(); ++itr) - itr->DeleteArea( nCol1, nRow1, nCol2, nRow2 ); - + bool bValid = true; + // // need to check which must be deleted iterator itr = begin(); while(itr != end()) { if(itr->GetRange().empty()) + { + bValid = false; maConditionalFormats.erase(itr++); + } else ++itr; } + + return bValid; +} + +void ScConditionalFormatList::DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) +{ + for( iterator itr = begin(); itr != end(); ++itr) + itr->DeleteArea( nCol1, nRow1, nCol2, nRow2 ); + + CheckAllEntries(); } void ScConditionalFormatList::SourceChanged( const ScAddress& rAddr ) diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx index 5c9bbe430d5c..8b97a7883f90 100644 --- a/sc/source/filter/xml/xmlcondformat.cxx +++ b/sc/source/filter/xml/xmlcondformat.cxx @@ -65,6 +65,17 @@ SvXMLImportContext* ScXMLConditionalFormatsContext::CreateChildContext( sal_uInt return pContext; } +void ScXMLConditionalFormatsContext::EndElement() +{ + ScDocument* pDoc = GetScImport().GetDocument(); + + SCTAB nTab = GetScImport().GetTables().GetCurrentSheet(); + ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(nTab); + bool bDeleted = !pCondFormatList->CheckAllEntries(); + + SAL_WARN_IF(bDeleted, "sc", "conditional formats have been deleted because they contained empty range info"); +} + ScXMLConditionalFormatContext::ScXMLConditionalFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx, const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList): SvXMLImportContext( rImport, nPrfx, rLName ) diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx index 45513ce83d88..0ace1eb03ae9 100644 --- a/sc/source/filter/xml/xmlcondformat.hxx +++ b/sc/source/filter/xml/xmlcondformat.hxx @@ -51,6 +51,8 @@ public: const ::rtl::OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList ); + + virtual void EndElement(); }; class ScXMLConditionalFormatContext : public SvXMLImportContext |