From 82edbbe8b797ad085008f3e148ef1b9bf3c6f802 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Wed, 15 Sep 2010 11:49:27 +0200 Subject: [PATCH] sc-xls-builtin-name-scope.diff: Print_Area/_Titles only for sheet local names n#191005, n#257422 --- sc/source/filter/excel/excform.cxx | 17 +++++++++-------- sc/source/filter/excel/excform8.cxx | 17 +++++++++-------- sc/source/filter/excel/frmbase.cxx | 26 ++++++++++++++++++-------- sc/source/filter/excel/xiname.cxx | 6 ++++-- sc/source/filter/inc/excform.hxx | 4 ++-- sc/source/filter/inc/formel.hxx | 6 +++--- 6 files changed, 45 insertions(+), 31 deletions(-) diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 0652363e8822..1157a9cc2cf6 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -898,7 +898,8 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s // stream seeks to first byte after -ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal_Size nFormulaLen, const FORMULA_TYPE eFT ) +ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal_Size nFormulaLen, + SCsTAB nTab, const FORMULA_TYPE eFT ) { RootData& rR = GetOldRoot(); BYTE nOp, nLen; @@ -1066,7 +1067,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName ); - rRangeList.Append( aSRD ); + rRangeList.Append( aSRD, nTab ); break; case 0x45: case 0x65: @@ -1093,7 +1094,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); } break; case 0x46: @@ -1130,7 +1131,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF ); - rRangeList.Append( aSRD ); + rRangeList.Append( aSRD, nTab ); } break; case 0x4D: @@ -1156,7 +1157,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); } break; case 0x49: @@ -1226,10 +1227,10 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal b3D = ( static_cast(nTabLast) != aEingPos.Tab() ); aCRD.Ref2.SetFlag3D( b3D ); aCRD.Ref2.SetTabRel( FALSE ); - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); } else - rRangeList.Append( aSRD ); + rRangeList.Append( aSRD, nTab ); } } @@ -1284,7 +1285,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); }//ENDE in aktuellem Workbook } break; diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx index 148b1542913a..3b07bf28b4e8 100644 --- a/sc/source/filter/excel/excform8.cxx +++ b/sc/source/filter/excel/excform8.cxx @@ -871,7 +871,8 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn, // stream seeks to first byte after -ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal_Size nFormulaLen, const FORMULA_TYPE eFT ) +ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal_Size nFormulaLen, + SCsTAB nTab, const FORMULA_TYPE eFT ) { BYTE nOp, nLen;//, nByte; BOOL bError = FALSE; @@ -1002,7 +1003,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa ExcRelToScRel8( nRow, nCol, aSRD, bRangeName ); - rRangeList.Append( aSRD ); + rRangeList.Append( aSRD, nTab ); } break; case 0x45: @@ -1030,7 +1031,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); } break; case 0x46: @@ -1074,7 +1075,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF ); - rRangeList.Append( aSRD ); + rRangeList.Append( aSRD, nTab ); } break; case 0x4D: @@ -1100,7 +1101,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa else if( IsComplRowRange( nRowFirst, nRowLast ) ) SetComplRow( aCRD ); - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); } break; case 0x4E: @@ -1142,10 +1143,10 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa aCRD.Ref2.nCol = aSRD.nCol; aCRD.Ref2.nRow = aSRD.nRow; aCRD.Ref2.nTab = nLastScTab; - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); } else - rRangeList.Append( aSRD ); + rRangeList.Append( aSRD, nTab ); } } break; @@ -1178,7 +1179,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa else if( IsComplRowRange( nRw1, nRw2 ) ) SetComplRow( aCRD ); - rRangeList.Append( aCRD ); + rRangeList.Append( aCRD, nTab ); } } break; diff --git a/sc/source/filter/excel/frmbase.cxx b/sc/source/filter/excel/frmbase.cxx index 78883b4a5c76..b550bfa92ef4 100644 --- a/sc/source/filter/excel/frmbase.cxx +++ b/sc/source/filter/excel/frmbase.cxx @@ -78,7 +78,7 @@ _ScRangeListTabs::~_ScRangeListTabs() } -void _ScRangeListTabs::Append( ScSingleRefData a, const BOOL b ) +void _ScRangeListTabs::Append( ScSingleRefData a, SCsTAB nTab, const BOOL b ) { if( b ) { @@ -98,19 +98,24 @@ void _ScRangeListTabs::Append( ScSingleRefData a, const BOOL b ) bHasRanges = TRUE; - if( a.nTab >= 0 ) + if( nTab == SCTAB_MAX) + return; + if( nTab < 0) + nTab = a.nTab; + + if( nTab >= 0 ) { - _ScRangeList* p = ppTabLists[ a.nTab ]; + _ScRangeList* p = ppTabLists[ nTab ]; if( !p ) - p = ppTabLists[ a.nTab ] = new _ScRangeList; + p = ppTabLists[ nTab ] = new _ScRangeList; p->Append( a ); } } -void _ScRangeListTabs::Append( ScComplexRefData a, const BOOL b ) +void _ScRangeListTabs::Append( ScComplexRefData a, SCsTAB nTab, const BOOL b ) { if( b ) { @@ -158,12 +163,17 @@ void _ScRangeListTabs::Append( ScComplexRefData a, const BOOL b ) bHasRanges = TRUE; - if( a.Ref1.nTab >= 0 ) + if( nTab == SCTAB_MAX) + return; + if( nTab < -1) + nTab = a.Ref1.nTab; + + if( nTab >= 0 ) { - _ScRangeList* p = ppTabLists[ a.Ref1.nTab ]; + _ScRangeList* p = ppTabLists[ nTab ]; if( !p ) - p = ppTabLists[ a.Ref1.nTab ] = new _ScRangeList; + p = ppTabLists[ nTab ] = new _ScRangeList; p->Append( a ); } diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx index 5d21d91c9f53..5c0eac63de92 100644 --- a/sc/source/filter/excel/xiname.cxx +++ b/sc/source/filter/excel/xiname.cxx @@ -158,16 +158,18 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) : } else if( bBuiltIn ) { + SCsTAB const nLocalTab = (nXclTab == EXC_NAME_GLOBAL) ? SCTAB_MAX : (nXclTab - 1); + // --- print ranges or title ranges --- rStrm.PushPosition(); switch( mcBuiltIn ) { case EXC_BUILTIN_PRINTAREA: - if( rFmlaConv.Convert( GetPrintAreaBuffer(), rStrm, nFmlaSize, FT_RangeName ) == ConvOK ) + if( rFmlaConv.Convert( GetPrintAreaBuffer(), rStrm, nFmlaSize, nLocalTab, FT_RangeName ) == ConvOK ) nNameType |= RT_PRINTAREA; break; case EXC_BUILTIN_PRINTTITLES: - if( rFmlaConv.Convert( GetTitleAreaBuffer(), rStrm, nFmlaSize, FT_RangeName ) == ConvOK ) + if( rFmlaConv.Convert( GetTitleAreaBuffer(), rStrm, nFmlaSize, nLocalTab, FT_RangeName ) == ConvOK ) nNameType |= RT_COLHEADER | RT_ROWHEADER; break; } diff --git a/sc/source/filter/inc/excform.hxx b/sc/source/filter/inc/excform.hxx index ed771637b704..5d6041923a37 100644 --- a/sc/source/filter/inc/excform.hxx +++ b/sc/source/filter/inc/excform.hxx @@ -61,7 +61,7 @@ public: virtual ConvErr Convert( const ScTokenArray*&, XclImpStream& rStrm, sal_Size nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula ); - virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, const FORMULA_TYPE eFT = FT_CellFormula ); + virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, SCsTAB nTab, const FORMULA_TYPE eFT = FT_CellFormula ); virtual ConvErr ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen, const String& rUrl, const ::std::vector& rTabNames ); @@ -137,7 +137,7 @@ public: virtual ConvErr Convert( const ScTokenArray*& rpTokArray, XclImpStream& rStrm, sal_Size nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula ); - virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, const FORMULA_TYPE eFT = FT_CellFormula ); + virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, SCsTAB nTab, const FORMULA_TYPE eFT = FT_CellFormula ); virtual ConvErr ConvertExternName( const ScTokenArray*& rpArray, XclImpStream& rStrm, sal_Size nFormulaLen, const String& rUrl, const ::std::vector& rTabNames ); diff --git a/sc/source/filter/inc/formel.hxx b/sc/source/filter/inc/formel.hxx index 6c7d4288c372..8ffb3857ec63 100644 --- a/sc/source/filter/inc/formel.hxx +++ b/sc/source/filter/inc/formel.hxx @@ -151,8 +151,8 @@ public: _ScRangeListTabs( void ); virtual ~_ScRangeListTabs(); - void Append( ScSingleRefData aSRD, const BOOL bLimit = TRUE ); - void Append( ScComplexRefData aCRD, const BOOL bLimit = TRUE ); + void Append( ScSingleRefData aSRD, SCsTAB nTab, const BOOL bLimit = TRUE ); + void Append( ScComplexRefData aCRD, SCsTAB nTab, const BOOL bLimit = TRUE ); inline BOOL HasRanges( void ) const; @@ -213,7 +213,7 @@ public: virtual ConvErr Convert( const ScTokenArray*& rpErg, XclImpStream& rStrm, sal_Size nFormulaLen, bool bAllowArrays, const FORMULA_TYPE eFT = FT_CellFormula ) = 0; - virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, + virtual ConvErr Convert( _ScRangeListTabs&, XclImpStream& rStrm, sal_Size nFormulaLen, SCsTAB nTab, const FORMULA_TYPE eFT = FT_CellFormula ) = 0; };