diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2016-11-18 12:36:21 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-11-23 12:39:42 +0000 |
commit | 71862564df1422f84340e421bbef9060c4e41a71 (patch) | |
tree | 401fafe5c093a2ab75b2fba1e3ab893e45d8bb15 /sc/source | |
parent | 14fc834aebdf4de9276a93e9f595b150a86ee16f (diff) |
OOXML: Write dimension range in full address notation
In every sheet.xml there is information about dimensions, like:
<dimension ref="A1:AMJ177"/>. During export by LibreOffice to .xlsx,
when row or column has maximum value, the dimension was
truncated. For example given "A1:AMJ177" it's saves <dimension ref="1:177"/>.
It was caused problems with Office 2007 import.
This patch is fixing that by always using full address notation
for dimension range, and allow open documents exported by LO
properly by MS Office.
Change-Id: Idda1455d1f9db08ade0871110fe40be2667c176c
Reviewed-on: https://gerrit.libreoffice.org/30960
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/address.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/excel/xestream.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/inc/xestream.hxx | 2 |
4 files changed, 14 insertions, 9 deletions
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx index bb2c9e20ebf9..0a7a2a9836a2 100644 --- a/sc/source/core/tool/address.cxx +++ b/sc/source/core/tool/address.cxx @@ -2197,7 +2197,7 @@ static inline bool lcl_RowAbsFlagDiffer(const ScRefFlags nFlags) } OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc, - const ScAddress::Details& rDetails ) const + const ScAddress::Details& rDetails, bool bFullAddressNotation ) const { if( !( nFlags & ScRefFlags::VALID ) ) { @@ -2232,14 +2232,14 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc, case formula::FormulaGrammar::CONV_XL_A1: case formula::FormulaGrammar::CONV_XL_OOX: lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails ); - if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL ) + if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL && !bFullAddressNotation ) { // Full col refs always require 2 rows (2:2) lcl_a1_append_r( r, aStart.Row(), (nFlags & ScRefFlags::ROW_ABS) != ScRefFlags::ZERO ); r.append(":"); lcl_a1_append_r( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != ScRefFlags::ZERO ); } - else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW ) + else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW && !bFullAddressNotation ) { // Full row refs always require 2 cols (A:A) lcl_a1_append_c( r, aStart.Col(), (nFlags & ScRefFlags::COL_ABS) != ScRefFlags::ZERO ); @@ -2263,7 +2263,7 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc, case formula::FormulaGrammar::CONV_XL_R1C1: lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails ); - if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL ) + if( aStart.Col() == 0 && aEnd.Col() >= MAXCOL && !bFullAddressNotation ) { lcl_r1c1_append_r( r, aStart.Row(), (nFlags & ScRefFlags::ROW_ABS) != ScRefFlags::ZERO, rDetails ); if( aStart.Row() != aEnd.Row() || @@ -2272,7 +2272,7 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc, lcl_r1c1_append_r( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != ScRefFlags::ZERO, rDetails ); } } - else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW ) + else if( aStart.Row() == 0 && aEnd.Row() >= MAXROW && !bFullAddressNotation ) { lcl_r1c1_append_c( r, aStart.Col(), (nFlags & ScRefFlags::COL_ABS) != ScRefFlags::ZERO, rDetails ); if( aStart.Col() != aEnd.Col() || diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx index d70bee34b43f..58d9c761f7af 100644 --- a/sc/source/filter/excel/xestream.cxx +++ b/sc/source/filter/excel/xestream.cxx @@ -726,9 +726,11 @@ OString XclXmlUtils::ToOString( const ScfUInt16Vec& rBuffer ) RTL_TEXTENCODING_UTF8); } -OString XclXmlUtils::ToOString( const ScRange& rRange ) +OString XclXmlUtils::ToOString( const ScRange& rRange, bool bFullAddressNotation ) { - OUString sRange(rRange.Format(ScRefFlags::VALID, nullptr, ScAddress::Details( FormulaGrammar::CONV_XL_A1))); + OUString sRange(rRange.Format( ScRefFlags::VALID, nullptr, + ScAddress::Details( FormulaGrammar::CONV_XL_A1 ), + bFullAddressNotation ) ); return ToOString( sRange ); } diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index f0c1096e90ee..3350389ac1c6 100644 --- a/sc/source/filter/excel/xetable.cxx +++ b/sc/source/filter/excel/xetable.cxx @@ -1538,7 +1538,10 @@ void XclExpDimensions::SaveXml( XclExpXmlStream& rStrm ) } rStrm.GetCurrentStream()->singleElement( XML_dimension, - XML_ref, XclXmlUtils::ToOString( aRange ).getStr(), + // To be compatible with MS Office 2007, + // we need full address notation format + // e.g. "A1:AMJ177" and not partial like: "1:177". + XML_ref, XclXmlUtils::ToOString( aRange, true ).getStr(), FSEND ); } diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx index 81c3f43c2f3a..600b1442903a 100644 --- a/sc/source/filter/inc/xestream.hxx +++ b/sc/source/filter/inc/xestream.hxx @@ -260,7 +260,7 @@ public: static OString ToOString( const OUString& s ); static OString ToOString( const ScfUInt16Vec& rBuffer ); static OStringBuffer& ToOString( OStringBuffer& s, const ScAddress& rRange ); - static OString ToOString( const ScRange& rRange ); + static OString ToOString( const ScRange& rRange, bool bFullAddressNotation = false ); static OString ToOString( const ScRangeList& rRangeList ); static OStringBuffer& ToOString( OStringBuffer& s, const XclAddress& rAddress ); static OString ToOString( const XclExpString& s ); |