You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ms...@apache.org on 2023/01/07 10:44:23 UTC
[openoffice] branch AOO42X updated: When rows and cells lack the "r" attribute used to specify their location, use the location of the most recently added row or cell + 1.
This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO42X by this push:
new a60f0fbf67 When rows and cells lack the "r" attribute used to specify their location, use the location of the most recently added row or cell + 1.
a60f0fbf67 is described below
commit a60f0fbf670431e75ec883bbb8aa1ffb7dbe4cb4
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Fri Jan 6 19:16:14 2023 +0200
When rows and cells lack the "r" attribute used to specify their location,
use the location of the most recently added row or cell + 1.
Fixes: #127672 - Xlsx with omitted cell references opens with empty cells
Patch by: me
(cherry picked from commit 9c741048d2a06db94d9507ba978d3aecd557e7e9)
---
main/oox/inc/oox/xls/sheetdatacontext.hxx | 2 ++
main/oox/source/xls/sheetdatacontext.cxx | 22 +++++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/main/oox/inc/oox/xls/sheetdatacontext.hxx b/main/oox/inc/oox/xls/sheetdatacontext.hxx
index c4d14b47c0..e2fc812551 100644
--- a/main/oox/inc/oox/xls/sheetdatacontext.hxx
+++ b/main/oox/inc/oox/xls/sheetdatacontext.hxx
@@ -44,6 +44,8 @@ struct SheetDataContextBase
CellModel maCellData; /// Position, contents, formatting of current imported cell.
CellFormulaModel maFmlaData; /// Settings for a cell formula.
sal_Int16 mnSheet; /// Index of the current sheet.
+ ::com::sun::star::table::CellAddress
+ maLastCellAddress; /// The address of the most recently populated cell.
explicit SheetDataContextBase( const WorksheetHelper& rHelper );
virtual ~SheetDataContextBase();
diff --git a/main/oox/source/xls/sheetdatacontext.cxx b/main/oox/source/xls/sheetdatacontext.cxx
index 214f1c479a..f986992fd2 100644
--- a/main/oox/source/xls/sheetdatacontext.cxx
+++ b/main/oox/source/xls/sheetdatacontext.cxx
@@ -103,6 +103,8 @@ SheetDataContextBase::SheetDataContextBase( const WorksheetHelper& rHelper ) :
mrSheetData( rHelper.getSheetData() ),
mnSheet( rHelper.getSheetIndex() )
{
+ maLastCellAddress.Sheet = rHelper.getSheetIndex();
+ maLastCellAddress.Row = SAL_MAX_UINT32; // wraps around to 0 when incremented
}
SheetDataContextBase::~SheetDataContextBase()
@@ -284,6 +286,11 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
{
RowModel aModel;
aModel.mnRow = rAttribs.getInteger( XML_r, -1 );
+ if ( aModel.mnRow == -1 )
+ aModel.mnRow = ++maLastCellAddress.Row;
+ else
+ maLastCellAddress.Row = aModel.mnRow - 1;
+ maLastCellAddress.Column = SAL_MAX_UINT32; // wraps around to 0 when incremented
aModel.mfHeight = rAttribs.getDouble( XML_ht, -1.0 );
aModel.mnXfId = rAttribs.getInteger( XML_s, -1 );
aModel.mnLevel = rAttribs.getInteger( XML_outlineLevel, 0 );
@@ -317,9 +324,22 @@ void SheetDataContext::importRow( const AttributeList& rAttribs )
bool SheetDataContext::importCell( const AttributeList& rAttribs )
{
- bool bValidAddr = mrAddressConv.convertToCellAddress( maCellData.maCellAddr, rAttribs.getString( XML_r, OUString() ), mnSheet, true );
+ OUString r = rAttribs.getString( XML_r, OUString() );
+ bool bValidAddr;
+ if ( r.getLength() > 0 )
+ bValidAddr = mrAddressConv.convertToCellAddress( maCellData.maCellAddr, rAttribs.getString( XML_r, OUString() ), mnSheet, true );
+ else
+ {
+ maCellData.maCellAddr.Column = ++maLastCellAddress.Column;
+ maCellData.maCellAddr.Row = maLastCellAddress.Row;
+ maCellData.maCellAddr.Sheet = maLastCellAddress.Sheet;
+ bValidAddr = true;
+ }
if( bValidAddr )
{
+ maLastCellAddress.Column = maCellData.maCellAddr.Column;
+ maLastCellAddress.Row = maCellData.maCellAddr.Row;
+ maLastCellAddress.Sheet = maCellData.maCellAddr.Sheet;
maCellData.mnCellType = rAttribs.getToken( XML_t, XML_n );
maCellData.mnXfId = rAttribs.getInteger( XML_s, -1 );
maCellData.mbShowPhonetic = rAttribs.getBool( XML_ph, false );