[ooo-build-commit] Branch 'ooo/OOO310' - sc/inc sc/source

Jan Holesovsky kendy at kemper.freedesktop.org
Wed Aug 5 17:16:18 PDT 2009


 sc/inc/compiler.hxx                  |    6 -
 sc/inc/rangenam.hxx                  |   10 ++
 sc/source/core/data/cell2.cxx        |    6 -
 sc/source/core/inc/refupdat.hxx      |    4 
 sc/source/core/tool/compiler.cxx     |   22 ++--
 sc/source/core/tool/rangenam.cxx     |   42 +++++++--
 sc/source/core/tool/refupdat.cxx     |   12 +-
 sc/source/filter/excel/namebuff.cxx  |    3 
 sc/source/filter/excel/xechart.cxx   |  162 ++++++++++++++++-------------------
 sc/source/filter/excel/xeformula.cxx |    2 
 10 files changed, 149 insertions(+), 120 deletions(-)

New commits:
commit 636891ab7a6e894e8552f8acbf65d7b6e10632b2
Author: Oliver Bolte <obo at openoffice.org>
Date:   Wed Aug 5 10:50:54 2009 +0000

    CWS-TOOLING: integrate CWS calcooo311
    2009-08-04 13:55:19 +0200 er  r274617 : #i102356# add patch flag for i18npool lib
    2009-08-03 17:29:15 +0200 dr  r274589 : #i103968# ported fix from DEV300, new pie charts lose point color
    2009-07-29 23:20:00 +0200 er  r274467 : #i103861# Shared formula and named range relative reference wrap with different grid sizes; patch from <kohei>

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 7133450..8f18f5a 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -405,9 +405,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 a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 8231cbd..e93bfda 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -81,6 +81,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:
@@ -153,6 +158,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 a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 0dffbde..f323920 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -792,7 +792,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.
@@ -828,7 +828,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.
@@ -865,7 +865,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 a/sc/source/core/inc/refupdat.hxx b/sc/source/core/inc/refupdat.hxx
index c60cccc..1a4c66d 100644
--- a/sc/source/core/inc/refupdat.hxx
+++ b/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 a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 8a1c4a1..564f6cb 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3838,7 +3838,7 @@ BOOL ScCompiler::HandleRange()
             if( pRangeData->HasReferences() )
             {
                 SetRelNameReference();
-                MoveRelWrap();
+                MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
             }
             pNew->Reset();
             if ( bAddPair )
@@ -3890,7 +3890,7 @@ BOOL ScCompiler::HandleExternalReference(const FormulaToken& _aToken)
             if (pNew->GetNextReference() != NULL)
             {
                 SetRelNameReference();
-                MoveRelWrap();
+                MoveRelWrap(MAXCOL, MAXROW);
             }
             pNew->Reset();
             return GetToken();
@@ -3985,33 +3985,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() );
     }
 }
 
@@ -4186,7 +4186,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
@@ -4216,7 +4216,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 a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 6029663..a249cc7 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/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 a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx
index 0836979..461a1d7 100644
--- a/sc/source/core/tool/refupdat.cxx
+++ b/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 a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx
index f007482..5ecea62 100644
--- a/sc/source/filter/excel/namebuff.cxx
+++ b/sc/source/filter/excel/namebuff.cxx
@@ -127,6 +127,9 @@ 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 );
+    const ScAddress& rMaxPos = pExcRoot->pIR->GetMaxPos();
+    pData->SetMaxCol(rMaxPos.Col());
+    pData->SetMaxRow(rMaxPos.Row());
     pData->SetIndex( static_cast< USHORT >( mnCurrIdx ) );
     pExcRoot->pIR->GetNamedRanges().Insert( pData );
     index_hash[rRange.aStart] = static_cast< USHORT >( mnCurrIdx );
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index 211aed3..792fd69 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -36,6 +36,8 @@
 #include <com/sun/star/i18n/XBreakIterator.hpp>
 #include <com/sun/star/i18n/ScriptType.hpp>
 #include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/chart/DataLabelPlacement.hpp>
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XDiagram.hpp>
 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
@@ -51,8 +53,6 @@
 #include <com/sun/star/chart2/DataPointLabel.hpp>
 #include <com/sun/star/chart2/StackingDirection.hpp>
 #include <com/sun/star/chart2/TickmarkStyle.hpp>
-#include <com/sun/star/chart/DataLabelPlacement.hpp>
-#include <com/sun/star/chart/ErrorBarStyle.hpp>
 
 #include <vcl/outdev.hxx>
 #include <svx/escherex.hxx>
@@ -60,13 +60,13 @@
 #include "document.hxx"
 #include "rangelst.hxx"
 #include "rangeutl.hxx"
+#include "compiler.hxx"
+#include "tokenarray.hxx"
+#include "token.hxx"
 #include "xeformula.hxx"
 #include "xehelper.hxx"
 #include "xepage.hxx"
 #include "xestyle.hxx"
-#include "compiler.hxx"
-#include "tokenarray.hxx"
-#include "token.hxx"
 
 using ::rtl::OUString;
 using ::com::sun::star::uno::Any;
@@ -102,6 +102,9 @@ using ::com::sun::star::chart2::data::XDataSource;
 using ::com::sun::star::chart2::data::XLabeledDataSequence;
 using ::com::sun::star::chart2::data::XDataSequence;
 
+using ::formula::FormulaGrammar;
+using ::formula::FormulaToken;
+
 // Helpers ====================================================================
 
 namespace {
@@ -648,43 +651,41 @@ XclExpChFrameRef lclCreateFrame( const XclExpChRoot& rRoot,
     return xFrame;
 }
 
-void lclAddDoubleRefData(ScTokenArray& rArray, const ::formula::FormulaToken& rToken,
-                         SCsTAB nTab1, SCsTAB nTab2, SCsCOL nCol1, SCsCOL nCol2, SCsROW nRow1, SCsROW nRow2)
-{
-    using namespace ::formula;
-
-    StackVar eType = rToken.GetType();
-    bool bExternal = (eType == svExternalDoubleRef);
-    DBG_ASSERT(eType == svDoubleRef || eType == svExternalDoubleRef, "not a double ref token!");
-
-    ScComplexRefData aData;
+} // namespace
 
-    aData.InitFlags();
-    aData.Ref1.SetFlag3D(true);
-    aData.Ref1.SetTabRel(false);
-    aData.Ref1.SetColRel(false);
-    aData.Ref1.SetRowRel(false);
-    aData.Ref2.SetFlag3D(false);
-    aData.Ref2.SetTabRel(false);
-    aData.Ref2.SetColRel(false);
-    aData.Ref2.SetRowRel(false);
+// Source links ===============================================================
 
-    aData.Ref1.nTab = nTab1;
-    aData.Ref1.nCol = nCol1;
-    aData.Ref1.nRow = nRow1;
-    aData.Ref2.nTab = nTab2;
-    aData.Ref2.nCol = nCol2;
-    aData.Ref2.nRow = nRow2;
+namespace {
 
-    if (bExternal)
-        rArray.AddExternalDoubleReference(rToken.GetIndex(), rToken.GetString(), aData);
+void lclAddDoubleRefData(
+        ScTokenArray& orArray, const FormulaToken& rToken,
+        SCsTAB nScTab1, SCsCOL nScCol1, SCsROW nScRow1,
+        SCsTAB nScTab2, SCsCOL nScCol2, SCsROW nScRow2 )
+{
+    ScComplexRefData aComplexRef;
+    aComplexRef.InitFlags();
+    aComplexRef.Ref1.SetFlag3D( true );
+    aComplexRef.Ref1.nTab = nScTab1;
+    aComplexRef.Ref1.nCol = nScCol1;
+    aComplexRef.Ref1.nRow = nScRow1;
+    aComplexRef.Ref2.nTab = nScTab2;
+    aComplexRef.Ref2.nCol = nScCol2;
+    aComplexRef.Ref2.nRow = nScRow2;
+
+    if( orArray.GetLen() > 0 )
+        orArray.AddOpCode( ocUnion );
+
+    DBG_ASSERT( (rToken.GetType() == ::formula::svDoubleRef) || (rToken.GetType() == ::formula::svExternalDoubleRef),
+        "lclAddDoubleRefData - double reference token expected");
+    if( rToken.GetType() == ::formula::svExternalDoubleRef )
+        orArray.AddExternalDoubleReference( rToken.GetIndex(), rToken.GetString(), aComplexRef );
     else
-        rArray.AddDoubleReference(aData);
+        orArray.AddDoubleReference( aComplexRef );
 }
 
 } // namespace
 
-// Source links ===============================================================
+// ----------------------------------------------------------------------------
 
 XclExpChSourceLink::XclExpChSourceLink( const XclExpChRoot& rRoot, sal_uInt8 nDestType ) :
     XclExpRecord( EXC_ID_CHSOURCELINK ),
@@ -696,80 +697,67 @@ XclExpChSourceLink::XclExpChSourceLink( const XclExpChRoot& rRoot, sal_uInt8 nDe
 
 sal_uInt16 XclExpChSourceLink::ConvertDataSequence( Reference< XDataSequence > xDataSeq, bool bSplitToColumns, sal_uInt16 nDefCount )
 {
-    using namespace ::formula;
-
     mxLinkFmla.reset();
     maData.mnLinkType = EXC_CHSRCLINK_DEFAULT;
-    sal_uInt16 nValueCount = nDefCount;
 
-    if (!xDataSeq.is())
-        return nValueCount;
+    if( !xDataSeq.is() )
+        return nDefCount;
 
-    // Compile the range representation string into token array.
+    // compile the range representation string into token array
     OUString aRangeRepr = xDataSeq->getSourceRangeRepresentation();
-    ScRangeList aScRanges;
-    ScCompiler aComp(GetDocPtr(), ScAddress());
-    aComp.SetGrammar(FormulaGrammar::GRAM_ENGLISH);
-    ScTokenArray* pArray = aComp.CompileString(aRangeRepr);
-    if (!pArray)
-        return nValueCount;
+    ScCompiler aComp( GetDocPtr(), ScAddress() );
+    aComp.SetGrammar( FormulaGrammar::GRAM_ENGLISH );
+    ScTokenArray* pArray = aComp.CompileString( aRangeRepr );
+    if( !pArray )
+        return nDefCount;
 
     ScTokenArray aArray;
+    sal_uInt32 nValueCount = 0;
     pArray->Reset();
-    bool bFirst = true;
-    for (const FormulaToken* p = pArray->First(); p; p = pArray->Next())
+    for( const FormulaToken* pToken = pArray->First(); pToken; pToken = pArray->Next() )
     {
-        StackVar eType = p->GetType();
-        if (eType == svSingleRef || eType == svExternalSingleRef)
+        switch( pToken->GetType() )
         {
-            // For a single ref token, just add it to the new token array as is.
-            if (bFirst)
-                bFirst = false;
-            else
-                aArray.AddOpCode(ocUnion);
-
-            aArray.AddToken(*p);
-        }
-
-        if (eType != svDoubleRef && eType != svExternalDoubleRef)
-            continue;
+            case ::formula::svSingleRef:
+            case ::formula::svExternalSingleRef:
+                // for a single ref token, just add it to the new token array as is
+                if( aArray.GetLen() > 0 )
+                    aArray.AddOpCode( ocUnion );
+                aArray.AddToken( *pToken );
+                ++nValueCount;
+            break;
 
-        // split 3-dimensional ranges into single sheets.
-        const ScComplexRefData& r = static_cast<const ScToken*>(p)->GetDoubleRef();
-        const ScSingleRefData& s = r.Ref1;
-        const ScSingleRefData& e = r.Ref2;
-        for (SCsTAB nTab = s.nTab; nTab <= e.nTab; ++nTab)
-        {
-            if (bSplitToColumns && (s.nRow != e.nRow))
+            case ::formula::svDoubleRef:
+            case ::formula::svExternalDoubleRef:
             {
-                // split 2-dimensional ranges into single columns.
-                for (SCsCOL nCol = s.nCol; nCol <= e.nCol; ++nCol)
+                // split 3-dimensional ranges into single sheets
+                const ScComplexRefData& rComplexRef = static_cast< const ScToken* >( pToken )->GetDoubleRef();
+                const ScSingleRefData& rRef1 = rComplexRef.Ref1;
+                const ScSingleRefData& rRef2 = rComplexRef.Ref2;
+                for( SCsTAB nScTab = rRef1.nTab; nScTab <= rRef2.nTab; ++nScTab )
                 {
-                    if (bFirst)
-                        bFirst = false;
+                    // split 2-dimensional ranges into single columns
+                    if( bSplitToColumns && (rRef1.nCol < rRef2.nCol) && (rRef1.nRow < rRef2.nRow) )
+                        for( SCsCOL nScCol = rRef1.nCol; nScCol <= rRef2.nCol; ++nScCol )
+                            lclAddDoubleRefData( aArray, *pToken, nScTab, nScCol, rRef1.nRow, nScTab, nScCol, rRef2.nRow );
                     else
-                        aArray.AddOpCode(ocUnion);
-
-                    lclAddDoubleRefData(aArray, *p, nTab, nTab, nCol, nCol, s.nRow, e.nRow);
+                        lclAddDoubleRefData( aArray, *pToken, nScTab, rRef1.nCol, rRef1.nRow, nScTab, rRef2.nCol, rRef2.nRow );
                 }
+                sal_uInt32 nTabs = static_cast< sal_uInt32 >( rRef2.nTab - rRef1.nTab + 1 );
+                sal_uInt32 nCols = static_cast< sal_uInt32 >( rRef2.nCol - rRef1.nCol + 1 );
+                sal_uInt32 nRows = static_cast< sal_uInt32 >( rRef2.nRow - rRef1.nRow + 1 );
+                nValueCount += nCols * nRows * nTabs;
             }
-            else
-            {
-                if (bFirst)
-                    bFirst = false;
-                else
-                    aArray.AddOpCode(ocUnion);
+            break;
 
-                lclAddDoubleRefData(aArray, *p, nTab, nTab, s.nCol, e.nCol, s.nRow, e.nRow);
-            }
+            default:;
         }
     }
 
-    const ScAddress aBaseCell(0,0,0);
-    mxLinkFmla = GetFormulaCompiler().CreateFormula(EXC_FMLATYPE_CHART, aArray, &aBaseCell);
+    const ScAddress aBaseCell;
+    mxLinkFmla = GetFormulaCompiler().CreateFormula( EXC_FMLATYPE_CHART, aArray, &aBaseCell );
     maData.mnLinkType = EXC_CHSRCLINK_WORKSHEET;
-    nValueCount = ulimit_cast< sal_uInt16 >( aScRanges.GetCellCount(), EXC_CHDATAFORMAT_MAXPOINTCOUNT );
-    return nValueCount;
+    return ulimit_cast< sal_uInt16 >( nValueCount, EXC_CHDATAFORMAT_MAXPOINTCOUNT );
 }
 
 sal_uInt16 XclExpChSourceLink::ConvertStringSequence( const Sequence< Reference< XFormattedString > >& rStringSeq )
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index 6767ad2..0611a63 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/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:;


More information about the ooo-build-commit mailing list