diff options
author | Laurent Godard <oooconv@free.fr> | 2011-11-04 15:24:53 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-11-04 15:46:51 +0100 |
commit | c9c98ab207fba4df35261c66b3753b9ce5e997ba (patch) | |
tree | 76fa0ec093d2ce49f52922763bca2e3da06855b8 /sc | |
parent | fbc8aa7f49abc4481fb8f74856eb6b5b298a36a7 (diff) |
calc big doc : ScMyTables::NewSheet method cleaning
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/xml/xmlsubti.cxx | 93 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlsubti.hxx | 2 |
2 files changed, 42 insertions, 53 deletions
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx index 04f9a8e5daac..2bc5b7c1ed93 100644 --- a/sc/source/filter/xml/xmlsubti.cxx +++ b/sc/source/filter/xml/xmlsubti.cxx @@ -184,17 +184,41 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& ++nCurrentSheet; maProtectionData = rProtectData; + ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); + + if (nCurrentSheet > 0) + { + pDoc->AppendTabOnLoad(sTableName); + } + + rImport.SetTableStyle(sStyleName); + SetTableStyle(sStyleName); + } + + NewTable(1); +} + +void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName) +{ + //these uno calls are a bit difficult to remove, XMLTableStyleContext::FillPropertySet uses + //SvXMLImportPropertyMapper::FillPropertySet + if ( sStyleName.getLength() ) + { + // #i57869# All table style properties for all sheets are now applied here, + // before importing the contents. + // This is needed for the background color. + // Sheet visibility has special handling in ScDocFunc::SetTableVisible to + // allow hiding the first sheet. + // RTL layout is only remembered, not actually applied, so the shapes can + // be loaded before mirroring. + uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( rImport.GetModel(), uno::UNO_QUERY ); + if ( xSpreadDoc.is() ) { uno::Reference <sheet::XSpreadsheets> xSheets(xSpreadDoc->getSheets()); - if (xSheets.is()) + if ( xSheets.is() ) { - if (nCurrentSheet > 0) - { - ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); - pDoc->AppendTabOnLoad(sTableName); - } uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY ); if ( xIndex.is() ) { @@ -202,65 +226,28 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& if ( xCurrentSheet.is() ) { xCurrentCellRange.set(xCurrentSheet, uno::UNO_QUERY); - if (!(nCurrentSheet > 0)) + uno::Reference <beans::XPropertySet> xProperties(xCurrentSheet, uno::UNO_QUERY); + if ( xProperties.is() ) { - uno::Reference < container::XNamed > xNamed(xCurrentSheet, uno::UNO_QUERY ); - if ( xNamed.is() ) - try - { - xNamed->setName(sTableName); - } - catch ( uno::RuntimeException& ) - { - ScDocument *pDoc = ScXMLConverter::GetScDocument(rImport.GetModel()); - if (pDoc) - { - ScXMLImport::MutexGuard aGuard(rImport); - String sTabName(String::CreateFromAscii("Table")); - pDoc->CreateValidTabName(sTabName); - rtl::OUString sOUTabName(sTabName); - xNamed->setName(sOUTabName); - } - } - } - rImport.SetTableStyle(sStyleName); - - if ( sStyleName.getLength() ) - { - // #i57869# All table style properties for all sheets are now applied here, - // before importing the contents. - // This is needed for the background color. - // Sheet visibility has special handling in ScDocFunc::SetTableVisible to - // allow hiding the first sheet. - // RTL layout is only remembered, not actually applied, so the shapes can - // be loaded before mirroring. - - uno::Reference <beans::XPropertySet> xProperties(xCurrentSheet, uno::UNO_QUERY); - if (xProperties.is()) + XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rImport.GetAutoStyles(); + if ( pStyles ) { - XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rImport.GetAutoStyles(); - if (pStyles) - { - XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext( + XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext( XML_STYLE_FAMILY_TABLE_TABLE, sStyleName, true); - if (pStyle) - { - pStyle->FillPropertySet(xProperties); + if ( pStyle ) + { + pStyle->FillPropertySet(xProperties); - ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData(); - pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, nCurrentSheet ) ); - } + ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData(); + pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, nCurrentSheet ) ); } } } } - } } } } - - NewTable(1); } bool ScMyTables::IsMerged (const uno::Reference <table::XCellRange>& xCellRange, const sal_Int32 nCol, const sal_Int32 nRow, diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx index e3955e40cd50..cf37bcfc8896 100644 --- a/sc/source/filter/xml/xmlsubti.hxx +++ b/sc/source/filter/xml/xmlsubti.hxx @@ -154,6 +154,8 @@ private: void NewRow(); void InsertColumn(); void NewColumn(bool bIsCovered); + + void SetTableStyle(const rtl::OUString& sStyleName); public: ScMyTables(ScXMLImport& rImport); ~ScMyTables(); |