Kaydet (Commit) 8d86abbc authored tarafından Kohei Yoshida's avatar Kohei Yoshida

We need to set the current cell range object regardless of style name.

Otherwise we would fail to import the cell contents of those documents
that don't include table styles at all.  Some hand-crafted ods documents
don't provide table styles, which 3.4 imported just fine.
üst 2419d3c2
......@@ -170,6 +170,29 @@ ScMyTables::~ScMyTables()
{
}
namespace {
uno::Reference<sheet::XSpreadsheet> getCurrentSheet(const uno::Reference<frame::XModel>& xModel, SCTAB nSheet)
{
uno::Reference<sheet::XSpreadsheet> xSheet;
uno::Reference<sheet::XSpreadsheetDocument> xSpreadDoc(xModel, uno::UNO_QUERY);
if (!xSpreadDoc.is())
return xSheet;
uno::Reference <sheet::XSpreadsheets> xSheets(xSpreadDoc->getSheets());
if (!xSheets.is())
return xSheet;
uno::Reference <container::XIndexAccess> xIndex(xSheets, uno::UNO_QUERY);
if (!xIndex.is())
return xSheet;
xSheet.set(xIndex->getByIndex(nSheet), uno::UNO_QUERY);
return xSheet;
}
}
void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString& sStyleName,
const ScXMLTabProtectionData& rProtectData)
{
......@@ -192,7 +215,14 @@ void ScMyTables::NewSheet(const rtl::OUString& sTableName, const rtl::OUString&
pDoc->SetTabNameOnLoad(nCurrentSheet, sTableName);
rImport.SetTableStyle(sStyleName);
SetTableStyle(sStyleName);
xCurrentSheet = getCurrentSheet(rImport.GetModel(), nCurrentSheet);
if (xCurrentSheet.is())
{
// We need to set the current cell range here regardless of
// presence of style name.
xCurrentCellRange.set(xCurrentSheet, uno::UNO_QUERY);
SetTableStyle(sStyleName);
}
}
NewTable(1);
......@@ -212,37 +242,23 @@ void ScMyTables::SetTableStyle(const rtl::OUString& sStyleName)
// 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() )
if ( xCurrentSheet.is() )
{
uno::Reference <sheet::XSpreadsheets> xSheets(xSpreadDoc->getSheets());
if ( xSheets.is() )
xCurrentCellRange.set(xCurrentSheet, uno::UNO_QUERY);
uno::Reference <beans::XPropertySet> xProperties(xCurrentSheet, uno::UNO_QUERY);
if ( xProperties.is() )
{
uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
if ( xIndex.is() )
XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rImport.GetAutoStyles();
if ( pStyles )
{
xCurrentSheet.set(xIndex->getByIndex(nCurrentSheet), uno::UNO_QUERY);
if ( xCurrentSheet.is() )
XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext(
XML_STYLE_FAMILY_TABLE_TABLE, sStyleName, true);
if ( pStyle )
{
xCurrentCellRange.set(xCurrentSheet, uno::UNO_QUERY);
uno::Reference <beans::XPropertySet> xProperties(xCurrentSheet, uno::UNO_QUERY);
if ( xProperties.is() )
{
XMLTableStylesContext *pStyles = (XMLTableStylesContext *)rImport.GetAutoStyles();
if ( pStyles )
{
XMLTableStyleContext* pStyle = (XMLTableStyleContext *)pStyles->FindStyleChildContext(
XML_STYLE_FAMILY_TABLE_TABLE, sStyleName, true);
if ( pStyle )
{
pStyle->FillPropertySet(xProperties);
ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData();
pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, nCurrentSheet ) );
}
}
}
pStyle->FillPropertySet(xProperties);
ScSheetSaveData* pSheetData = ScModelObj::getImplementation(rImport.GetModel())->GetSheetSaveData();
pSheetData->AddTableStyle( sStyleName, ScAddress( 0, 0, nCurrentSheet ) );
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment