[ooo-build-commit] Branch 'ooo-build-3-1' - patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Jul 28 07:02:43 PDT 2009


 patches/dev300/apply                                       |    3 
 patches/dev300/calc-xls-import-shared-formula-refwrap.diff |  352 +++++++++++++
 2 files changed, 355 insertions(+)

New commits:
commit c045d43228d163014ef4ffff1e77c95323880861
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jul 28 09:33:56 2009 -0400

    Set non-default max column and row size for range names.
    
    In Excel, relative references wrap when going beyond the grid size
    limit.  The problem is, Excel up to 2003 had a column size limit of
    256, while Calc now offers 1024 columns.  In light of this, when
    reference wraps over column size limits, the final position lands
    in a different cell depending on the column size limit of the
    current application.  We can work around this incompatibility issue
    by setting an explicit max column size to the range name. (n#522833)
    
    * patches/dev300/apply:
    * patches/dev300/calc-xls-import-shared-formula-refwrap.diff:

diff --git a/patches/dev300/apply b/patches/dev300/apply
index c339400..ac7fa8b 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3029,6 +3029,9 @@ calc-delete-note-cell-crasher.diff, n#517566, kohei
 
 calc-formula-externref-countif-fix.diff, n#521624, i#102750, kohei
 
+calc-xls-import-shared-formula-refwrap.diff, n#522833, kohei
+
+
 [ UbuntuHardyOnly ]
 # Add patch to only show local files needed when gnome-vfs/gio is disabled
 ubuntu-gnome-fpicker-local-only.diff
diff --git a/patches/dev300/calc-xls-import-shared-formula-refwrap.diff b/patches/dev300/calc-xls-import-shared-formula-refwrap.diff
new file mode 100644
index 0000000..3e14ae3
--- /dev/null
+++ b/patches/dev300/calc-xls-import-shared-formula-refwrap.diff
@@ -0,0 +1,352 @@
+diff --git sc/inc/compiler.hxx sc/inc/compiler.hxx
+index c41c15d..75da014 100644
+--- sc/inc/compiler.hxx
++++ sc/inc/compiler.hxx
+@@ -404,9 +404,9 @@ public:
+     const ScDocument* GetDoc() const { return pDoc; }
+     const ScAddress& GetPos() const { return aPos; }
+ 
+-    void MoveRelWrap();
+-    static void MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc,
+-                             const ScAddress& rPos );
++    void MoveRelWrap( SCCOL nMaxCol, SCROW nMaxRow );
++    static void MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddress& rPos, 
++                             SCCOL nMaxCol, SCROW nMaxRow );
+ 
+     BOOL UpdateNameReference( UpdateRefMode eUpdateRefMode,
+                               const ScRange&,
+diff --git sc/inc/rangenam.hxx sc/inc/rangenam.hxx
+index ece1609..59ca4f8 100644
+--- sc/inc/rangenam.hxx
++++ sc/inc/rangenam.hxx
+@@ -83,6 +83,11 @@ private:
+     USHORT			nIndex;
+     BOOL			bModified;			// wird bei UpdateReference gesetzt/geloescht
+ 
++    // max row and column to use for wrapping of references.  If -1 use the 
++    // application's default.
++    SCROW           mnMaxRow;
++    SCCOL           mnMaxCol;
++
+     friend class ScRangeName;
+     ScRangeData( USHORT nIndex );
+ public:
+@@ -158,6 +163,11 @@ public:
+ 
+     static void		MakeValidName( String& rName );
+     SC_DLLPUBLIC static BOOL		IsNameValid( const String& rName, ScDocument* pDoc );
++
++    SC_DLLPUBLIC void SetMaxRow(SCROW nRow);
++    SCROW GetMaxRow() const;
++    SC_DLLPUBLIC void SetMaxCol(SCCOL nCol);
++    SCCOL GetMaxCol() const;
+ };
+ 
+ inline BOOL ScRangeData::HasType( RangeType nType ) const
+diff --git sc/source/core/data/cell2.cxx sc/source/core/data/cell2.cxx
+index 4c38b39..58d154d 100644
+--- sc/source/core/data/cell2.cxx
++++ sc/source/core/data/cell2.cxx
+@@ -891,7 +891,7 @@ void ScFormulaCell::UpdateInsertTab(SCTAB nTable)
+             pCode = new ScTokenArray( *pRangeData->GetCode() );
+             ScCompiler aComp2(pDocument, aPos, *pCode);
+             aComp2.SetGrammar(pDocument->GetGrammar());
+-            aComp2.MoveRelWrap();
++            aComp2.MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
+             aComp2.UpdateInsertTab( nTable, FALSE );
+             // If the shared formula contained a named range/formula containing
+             // an absolute reference to a sheet, those have to be readjusted.
+@@ -927,7 +927,7 @@ BOOL ScFormulaCell::UpdateDeleteTab(SCTAB nTable, BOOL bIsMove)
+             ScCompiler aComp2(pDocument, aPos, *pCode);
+             aComp2.SetGrammar(pDocument->GetGrammar());
+             aComp2.CompileTokenArray();
+-            aComp2.MoveRelWrap();
++            aComp2.MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
+             aComp2.UpdateDeleteTab( nTable, FALSE, FALSE, bRefChanged );
+             // If the shared formula contained a named range/formula containing
+             // an absolute reference to a sheet, those have to be readjusted.
+@@ -964,7 +964,7 @@ void ScFormulaCell::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo )
+             ScCompiler aComp2(pDocument, aPos, *pCode);
+             aComp2.SetGrammar(pDocument->GetGrammar());
+             aComp2.CompileTokenArray();
+-            aComp2.MoveRelWrap();
++            aComp2.MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
+             aComp2.UpdateMoveTab( nOldPos, nNewPos, TRUE );
+             bCompile = TRUE;
+         }
+diff --git sc/source/core/inc/refupdat.hxx sc/source/core/inc/refupdat.hxx
+index c60cccc..1a4c66d 100644
+--- sc/source/core/inc/refupdat.hxx
++++ sc/source/core/inc/refupdat.hxx
+@@ -81,8 +81,8 @@ public:
+                                 SCsCOL nDx, SCsROW nDy, SCsTAB nDz,
+                                 ScComplexRefData& rRef, BOOL bWrap, BOOL bAbsolute );
+ 
+-    static void MoveRelWrap( ScDocument* pDoc, const ScAddress& rPos,
+-                                ScComplexRefData& rRef );
++    static void MoveRelWrap( ScDocument* pDoc, const ScAddress& rPos, 
++                             SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData& rRef );
+ 
+     /// Before calling, the absolute references must be up-to-date!
+     static ScRefUpdateRes UpdateTranspose( ScDocument* pDoc,
+diff --git sc/source/core/tool/compiler.cxx sc/source/core/tool/compiler.cxx
+index da0f296..c5cfce0 100644
+--- sc/source/core/tool/compiler.cxx
++++ sc/source/core/tool/compiler.cxx
+@@ -3809,7 +3809,7 @@ BOOL ScCompiler::HandleRange()
+             if( pRangeData->HasReferences() )
+             {
+                 SetRelNameReference();
+-                MoveRelWrap();
++                MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
+             }
+             pNew->Reset();
+             if ( bAddPair )
+@@ -3861,7 +3861,7 @@ BOOL ScCompiler::HandleExternalReference(const FormulaToken& _aToken)
+             if (pNew->GetNextReference() != NULL)
+             {
+                 SetRelNameReference();
+-                MoveRelWrap();
++                MoveRelWrap(MAXCOL, MAXROW);
+             }
+             pNew->Reset();
+             return GetToken();
+@@ -3956,33 +3956,33 @@ void ScCompiler::SetRelNameReference()
+ 
+ // Wrap-adjust relative references of a RangeName to current position,
+ // don't call for other token arrays!
+-void ScCompiler::MoveRelWrap()
++void ScCompiler::MoveRelWrap( SCCOL nMaxCol, SCROW nMaxRow )
+ {
+     pArr->Reset();
+     for( ScToken* t = static_cast<ScToken*>(pArr->GetNextReference()); t;
+                   t = static_cast<ScToken*>(pArr->GetNextReference()) )
+     {
+         if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef )
+-            ScRefUpdate::MoveRelWrap( pDoc, aPos, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() );
++            ScRefUpdate::MoveRelWrap( pDoc, aPos, nMaxCol, nMaxRow, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() );
+         else
+-            ScRefUpdate::MoveRelWrap( pDoc, aPos, t->GetDoubleRef() );
++            ScRefUpdate::MoveRelWrap( pDoc, aPos, nMaxCol, nMaxRow, t->GetDoubleRef() );
+     }
+ }
+ 
+ // static
+ // Wrap-adjust relative references of a RangeName to current position,
+ // don't call for other token arrays!
+-void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc,
+-            const ScAddress& rPos )
++void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddress& rPos,
++                              SCCOL nMaxCol, SCROW nMaxRow )
+ {
+     rArr.Reset();
+     for( ScToken* t = static_cast<ScToken*>(rArr.GetNextReference()); t;
+                   t = static_cast<ScToken*>(rArr.GetNextReference()) )
+     {
+         if ( t->GetType() == svSingleRef || t->GetType() == svExternalSingleRef )
+-            ScRefUpdate::MoveRelWrap( pDoc, rPos, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() );
++            ScRefUpdate::MoveRelWrap( pDoc, rPos, nMaxCol, nMaxRow, SingleDoubleRefModifier( t->GetSingleRef() ).Ref() );
+         else
+-            ScRefUpdate::MoveRelWrap( pDoc, rPos, t->GetDoubleRef() );
++            ScRefUpdate::MoveRelWrap( pDoc, rPos, nMaxCol, nMaxRow, t->GetDoubleRef() );
+     }
+ }
+ 
+@@ -4157,7 +4157,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
+                     SingleDoubleRefModifier aMod( rRef );
+                     if ( rRef.IsRelName() )
+                     {
+-                        ScRefUpdate::MoveRelWrap( pDoc, aPos, aMod.Ref() );
++                        ScRefUpdate::MoveRelWrap( pDoc, aPos, MAXCOL, MAXROW, aMod.Ref() );
+                         rChanged = TRUE;
+                     }
+                     else
+@@ -4187,7 +4187,7 @@ ScRangeData* ScCompiler::UpdateReference(UpdateRefMode eUpdateRefMode,
+                     SCTAB nTabs = rRef.Ref2.nTab - rRef.Ref1.nTab;
+                     if ( rRef.Ref1.IsRelName() || rRef.Ref2.IsRelName() )
+                     {
+-                        ScRefUpdate::MoveRelWrap( pDoc, aPos, rRef );
++                        ScRefUpdate::MoveRelWrap( pDoc, aPos, MAXCOL, MAXROW, rRef );
+                         rChanged = TRUE;
+                     }
+                     else
+diff --git sc/source/core/tool/rangenam.cxx sc/source/core/tool/rangenam.cxx
+index d30a3d5..d701b2a 100644
+--- sc/source/core/tool/rangenam.cxx
++++ sc/source/core/tool/rangenam.cxx
+@@ -60,7 +60,7 @@ using namespace formula;
+ // Interner ctor fuer das Suchen nach einem Index
+ 
+ ScRangeData::ScRangeData( USHORT n )
+-           : pCode( NULL ), nIndex( n ), bModified( FALSE )
++           : pCode( NULL ), nIndex( n ), bModified( FALSE ), mnMaxRow(-1), mnMaxCol(-1)
+ {}
+ 
+ ScRangeData::ScRangeData( ScDocument* pDok,
+@@ -76,7 +76,9 @@ ScRangeData::ScRangeData( ScDocument* pDok,
+                 eType		( nType ),
+                 pDoc		( pDok ),
+                 nIndex		( 0 ),
+-                bModified	( FALSE )
++                bModified	( FALSE ),
++                mnMaxRow    (-1),
++                mnMaxCol    (-1)
+ {
+     if (rSymbol.Len() > 0)
+     {
+@@ -122,7 +124,9 @@ ScRangeData::ScRangeData( ScDocument* pDok,
+                 eType		( nType ),
+                 pDoc		( pDok ),
+                 nIndex		( 0 ),
+-                bModified	( FALSE )
++                bModified	( FALSE ),
++                mnMaxRow    (-1),
++                mnMaxCol    (-1)
+ {
+     if( !pCode->GetCodeError() )
+     {
+@@ -157,7 +161,9 @@ ScRangeData::ScRangeData( ScDocument* pDok,
+                 eType		( RT_NAME ),
+                 pDoc		( pDok ),
+                 nIndex		( 0 ),
+-                bModified	( FALSE )
++                bModified	( FALSE ),
++                mnMaxRow    (-1),
++                mnMaxCol    (-1)
+ {
+     ScSingleRefData aRefData;
+     aRefData.InitAddress( rTarget );
+@@ -179,7 +185,9 @@ ScRangeData::ScRangeData(const ScRangeData& rScRangeData) :
+     eType		(rScRangeData.eType),
+     pDoc		(rScRangeData.pDoc),
+     nIndex   	(rScRangeData.nIndex),
+-    bModified	(rScRangeData.bModified)
++    bModified	(rScRangeData.bModified),
++    mnMaxRow    (rScRangeData.mnMaxRow),
++    mnMaxCol    (rScRangeData.mnMaxCol)
+ {}
+ 
+ ScRangeData::~ScRangeData()
+@@ -247,7 +255,7 @@ void ScRangeData::UpdateSymbol(	rtl::OUStringBuffer& rBuffer, const ScAddress& r
+     ::std::auto_ptr<ScTokenArray> pTemp( pCode->Clone() );
+     ScCompiler aComp( pDoc, rPos, *pTemp.get());
+     aComp.SetGrammar(eGrammar);
+-    aComp.MoveRelWrap();
++    aComp.MoveRelWrap(GetMaxCol(), GetMaxRow());
+     aComp.CreateStringFromTokenArray( rBuffer );
+ }
+ 
+@@ -393,7 +401,7 @@ BOOL ScRangeData::IsReference( ScRange& rRange, const ScAddress& rPos ) const
+         ::std::auto_ptr<ScTokenArray> pTemp( pCode->Clone() );
+         ScCompiler aComp( pDoc, rPos, *pTemp);
+         aComp.SetGrammar(pDoc->GetGrammar());
+-        aComp.MoveRelWrap();
++        aComp.MoveRelWrap(MAXCOL, MAXROW);
+         return pTemp->IsReference( rRange );
+     }
+ 
+@@ -520,6 +528,26 @@ BOOL ScRangeData::IsNameValid( const String& rName, ScDocument* pDoc )
+     return TRUE;
+ }
+ 
++void ScRangeData::SetMaxRow(SCROW nRow)
++{
++    mnMaxRow = nRow;
++}
++
++SCROW ScRangeData::GetMaxRow() const
++{
++    return mnMaxRow >= 0 ? mnMaxRow : MAXROW;
++}
++
++void ScRangeData::SetMaxCol(SCCOL nCol)
++{
++    mnMaxCol = nCol;
++}
++
++SCCOL ScRangeData::GetMaxCol() const
++{
++    return mnMaxCol >= 0 ? mnMaxCol : MAXCOL;
++}
++
+ 
+ USHORT ScRangeData::GetErrCode()
+ {
+diff --git sc/source/core/tool/refupdat.cxx sc/source/core/tool/refupdat.cxx
+index 0836979..461a1d7 100644
+--- sc/source/core/tool/refupdat.cxx
++++ sc/source/core/tool/refupdat.cxx
+@@ -820,28 +820,28 @@ ScRefUpdateRes ScRefUpdate::Move( ScDocument* pDoc, const ScAddress& rPos,
+     return eRet;
+ }
+ 
+-void ScRefUpdate::MoveRelWrap( ScDocument* pDoc, const ScAddress& rPos,
+-                                  ScComplexRefData& rRef )
++void ScRefUpdate::MoveRelWrap( ScDocument* pDoc, const ScAddress& rPos, 
++                               SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData& rRef )
+ {
+     if( rRef.Ref1.IsColRel() )
+     {
+         rRef.Ref1.nCol = rRef.Ref1.nRelCol + rPos.Col();
+-        lcl_MoveItWrap( rRef.Ref1.nCol, static_cast<SCsCOL>(0), MAXCOL );
++        lcl_MoveItWrap( rRef.Ref1.nCol, static_cast<SCsCOL>(0), nMaxCol );
+     }
+     if( rRef.Ref2.IsColRel() )
+     {
+         rRef.Ref2.nCol = rRef.Ref2.nRelCol + rPos.Col();
+-        lcl_MoveItWrap( rRef.Ref2.nCol, static_cast<SCsCOL>(0), MAXCOL );
++        lcl_MoveItWrap( rRef.Ref2.nCol, static_cast<SCsCOL>(0), nMaxCol );
+     }
+     if( rRef.Ref1.IsRowRel() )
+     {
+         rRef.Ref1.nRow = rRef.Ref1.nRelRow + rPos.Row();
+-        lcl_MoveItWrap( rRef.Ref1.nRow, static_cast<SCsROW>(0), MAXROW );
++        lcl_MoveItWrap( rRef.Ref1.nRow, static_cast<SCsROW>(0), nMaxRow );
+     }
+     if( rRef.Ref2.IsRowRel() )
+     {
+         rRef.Ref2.nRow = rRef.Ref2.nRelRow + rPos.Row();
+-        lcl_MoveItWrap( rRef.Ref2.nRow, static_cast<SCsROW>(0), MAXROW );
++        lcl_MoveItWrap( rRef.Ref2.nRow, static_cast<SCsROW>(0), nMaxRow );
+     }
+     SCsTAB nMaxTab = (SCsTAB) pDoc->GetTableCount() - 1;
+     if( rRef.Ref1.IsTabRel() )
+diff --git sc/source/filter/excel/namebuff.cxx sc/source/filter/excel/namebuff.cxx
+index f007482..3c71823 100644
+--- sc/source/filter/excel/namebuff.cxx
++++ sc/source/filter/excel/namebuff.cxx
+@@ -127,6 +127,8 @@ void ShrfmlaBuffer::Store( const ScRange& rRange, const ScTokenArray& rToken )
+     DBG_ASSERT( mnCurrIdx <= 0xFFFF, "*ShrfmlaBuffer::Store(): Gleich wird mir schlecht...!" );
+ 
+     ScRangeData* pData = new ScRangeData( pExcRoot->pIR->GetDocPtr(), aName, rToken, rRange.aStart, RT_SHARED );
++    pData->SetMaxCol(255);
++    pData->SetMaxRow(65535);
+     pData->SetIndex( static_cast< USHORT >( mnCurrIdx ) );
+     pExcRoot->pIR->GetNamedRanges().Insert( pData );
+     index_hash[rRange.aStart] = static_cast< USHORT >( mnCurrIdx );
+diff --git sc/source/filter/excel/xeformula.cxx sc/source/filter/excel/xeformula.cxx
+index 6767ad2..0611a63 100644
+--- sc/source/filter/excel/xeformula.cxx
++++ sc/source/filter/excel/xeformula.cxx
+@@ -619,7 +619,7 @@ void XclExpFmlaCompImpl::Init( XclFormulaType eType, const ScTokenArray& rScTokA
+             DBG_ASSERT( mbOk, "XclExpFmlaCompImpl::Init - missing cell address" );
+             // clone the passed token array, convert references relative to current cell position
+             mxOwnScTokArr.reset( rScTokArr.Clone() );
+-            ScCompiler::MoveRelWrap( *mxOwnScTokArr, GetDocPtr(), *pScBasePos );
++            ScCompiler::MoveRelWrap( *mxOwnScTokArr, GetDocPtr(), *pScBasePos, MAXCOL, MAXROW );
+             // don't remember pScBasePos in mpScBasePos, shared formulas use real relative refs
+         break;
+         default:;
+diff --git sc/source/filter/xlsx/xlsx-xeformula.cxx sc/source/filter/xlsx/xlsx-xeformula.cxx
+index 31af0f9..c1989b8 100644
+--- sc/source/filter/xlsx/xlsx-xeformula.cxx
++++ sc/source/filter/xlsx/xlsx-xeformula.cxx
+@@ -619,7 +619,7 @@ void XclExpFmlaCompImpl::Init( XclFormulaType eType, const ScTokenArray& rScTokA
+             DBG_ASSERT( mbOk, "XclExpFmlaCompImpl::Init - missing cell address" );
+             // clone the passed token array, convert references relative to current cell position
+             mxOwnScTokArr.reset( rScTokArr.Clone() );
+-            ScCompiler::MoveRelWrap( *mxOwnScTokArr, GetDocPtr(), *pScBasePos );
++            ScCompiler::MoveRelWrap( *mxOwnScTokArr, GetDocPtr(), *pScBasePos, MAXCOL, MAXROW );
+             // don't remember pScBasePos in mpScBasePos, shared formulas use real relative refs
+         break;
+         default:;


More information about the ooo-build-commit mailing list