diff options
-rw-r--r-- | sc/inc/address.hxx | 26 | ||||
-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 |
5 files changed, 38 insertions, 11 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index 63d8371d4c08..d801d0593752 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -542,8 +542,30 @@ public: const css::uno::Sequence<css::sheet::ExternalLinkInfo>* pExternalLinks = nullptr, const OUString* pErrRef = nullptr ); - SC_DLLPUBLIC OUString Format(ScRefFlags nFlags = ScRefFlags::ZERO, const ScDocument* pDocument = nullptr, - const ScAddress::Details& rDetails = ScAddress::detailsOOOa1) const; + /** Returns string with formatted cell range from aStart to aEnd, + according to provided address convention. + @param nFlags + Cell reference flags + @param pDocument + Pointer to document which is used for example to get tab names. + @param rDetails + Provide information about required address convention. + Supported address conventions are: + CONV_OOO 'doc'#sheet.A1:sheet2.B2 + CONV_XL_A1, [doc]sheet:sheet2!A1:B2 + CONV_XL_OOX, [#]sheet:sheet2!A1:B2 + CONV_XL_R1C1, [doc]sheet:sheet2!R1C1:R2C2 + @param bFullAddressNotation + If TRUE, the full address notation will be used. + For example in case all columns are used, "A1:AMJ177" is full address notation + and "1:177" is shortened address notation. + @returns + String contains formatted cell range in address convention + */ + SC_DLLPUBLIC OUString Format( ScRefFlags nFlags = ScRefFlags::ZERO, + const ScDocument* pDocument = nullptr, + const ScAddress::Details& rDetails = ScAddress::detailsOOOa1, + bool bFullAddressNotation = false ) const; inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const; 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 ); |