[Libreoffice-commits] .: Branch 'feature/dp-named-range-source' - sc/inc sc/qa sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Jan 21 11:59:53 PST 2011


 sc/inc/dpshttab.hxx                         |    8 ++++--
 sc/qa/unit/ucalc.cxx                        |    9 ++++---
 sc/source/core/data/dpobject.cxx            |   34 ++++++++++++++--------------
 sc/source/core/data/dpshttab.cxx            |    8 +++---
 sc/source/filter/excel/xepivot.cxx          |    4 +--
 sc/source/filter/excel/xipivot.cxx          |    2 -
 sc/source/filter/xml/XMLExportDataPilot.cxx |    2 -
 sc/source/filter/xml/xmldpimp.cxx           |    2 -
 sc/source/ui/dbgui/pvlaydlg.cxx             |    6 ++--
 sc/source/ui/docshell/dbdocfun.cxx          |    2 -
 sc/source/ui/docshell/docsh5.cxx            |    2 -
 sc/source/ui/unoobj/dapiuno.cxx             |    7 ++++-
 sc/source/ui/view/cellsh2.cxx               |    2 -
 sc/source/ui/view/gridwin2.cxx              |    2 -
 sc/source/ui/view/pivotsh.cxx               |    2 -
 15 files changed, 50 insertions(+), 42 deletions(-)

New commits:
commit 3c796bd3a6ae37a47a2bf81fffe9bab5c703f4ae
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Jan 21 14:59:06 2011 -0500

    Encapsulated access to aSourceRange.

diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 4b2d4df..9584e89 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -50,14 +50,16 @@ class ScDPItemData;
  * precedence over the source range when it's non-empty.</i>  When the range
  * name is empty, the source range gets used.
  */
-struct ScSheetSourceDesc
+class ScSheetSourceDesc
 {
+private:
     ScRange         aSourceRange;
+public:
     ::rtl::OUString maRangeName;
     ScQueryParam    aQueryParam;
 
-    void SetSourceRange(const ScRange& rRange);
-    const ScRange& GetSourceRange() const;
+    SC_DLLPUBLIC void SetSourceRange(const ScRange& rRange);
+    SC_DLLPUBLIC const ScRange& GetSourceRange() const;
     void SetRangeName(const ::rtl::OUString& rName);
     const ::rtl::OUString& GetRangeName() const;
     void SetQueryParam(const ScQueryParam& rParam);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3f8510c..8132392 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -570,7 +570,7 @@ void Test::testDataPilot()
     printer.clear();
 
     ScSheetSourceDesc aSheetDesc;
-    aSheetDesc.aSourceRange = ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
+    aSheetDesc.SetSourceRange(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
     ScDPObject* pDPObj = new ScDPObject(m_pDoc);
     pDPObj->SetSheetDesc(aSheetDesc);
     pDPObj->SetOutRange(ScAddress(0, 0, 1));
@@ -592,9 +592,10 @@ void Test::testDataPilot()
     aSaveData.SetDrillDown(true);
 
     // Check the sanity of the source range.
-    nCol1 = aSheetDesc.aSourceRange.aStart.Col();
-    nRow1 = aSheetDesc.aSourceRange.aStart.Row();
-    nRow2 = aSheetDesc.aSourceRange.aEnd.Row();
+    const ScRange& rSrcRange = aSheetDesc.GetSourceRange();
+    nCol1 = rSrcRange.aStart.Col();
+    nRow1 = rSrcRange.aStart.Row();
+    nRow2 = rSrcRange.aEnd.Row();
     CPPUNIT_ASSERT_MESSAGE("source range contains no data!", nRow2 - nRow1 > 1);
 
     // Set the dimension information.
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index d5d7a3a..36c5aac 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -276,10 +276,11 @@ void ScDPObject::SetSheetDesc(const ScSheetSourceDesc& rDesc)
 
     //	make valid QueryParam
 
-    pSheetDesc->aQueryParam.nCol1 = pSheetDesc->aSourceRange.aStart.Col();
-    pSheetDesc->aQueryParam.nRow1 = pSheetDesc->aSourceRange.aStart.Row();
-    pSheetDesc->aQueryParam.nCol2 = pSheetDesc->aSourceRange.aEnd.Col();
-    pSheetDesc->aQueryParam.nRow2 = pSheetDesc->aSourceRange.aEnd.Row();;
+    const ScRange& rSrcRange = pSheetDesc->GetSourceRange();
+    pSheetDesc->aQueryParam.nCol1 = rSrcRange.aStart.Col();
+    pSheetDesc->aQueryParam.nRow1 = rSrcRange.aStart.Row();
+    pSheetDesc->aQueryParam.nCol2 = rSrcRange.aEnd.Col();
+    pSheetDesc->aQueryParam.nRow2 = rSrcRange.aEnd.Row();;
     pSheetDesc->aQueryParam.bHasHeader = TRUE;
 
     InvalidateSource();		// new source must be created
@@ -695,12 +696,13 @@ void ScDPObject::UpdateReference( UpdateRefMode eUpdateRefMode,
 
     if ( pSheetDesc )
     {
-        nCol1 = pSheetDesc->aSourceRange.aStart.Col();
-        nRow1 = pSheetDesc->aSourceRange.aStart.Row();
-        nTab1 = pSheetDesc->aSourceRange.aStart.Tab();
-        nCol2 = pSheetDesc->aSourceRange.aEnd.Col();
-        nRow2 = pSheetDesc->aSourceRange.aEnd.Row();
-        nTab2 = pSheetDesc->aSourceRange.aEnd.Tab();
+        const ScRange& rSrcRange = pSheetDesc->GetSourceRange();
+        nCol1 = rSrcRange.aStart.Col();
+        nRow1 = rSrcRange.aStart.Row();
+        nTab1 = rSrcRange.aStart.Tab();
+        nCol2 = rSrcRange.aEnd.Col();
+        nRow2 = rSrcRange.aEnd.Row();
+        nTab2 = rSrcRange.aEnd.Tab();
 
         eRes = ScRefUpdate::Update( pDoc, eUpdateRefMode,
                 rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
@@ -709,10 +711,10 @@ void ScDPObject::UpdateReference( UpdateRefMode eUpdateRefMode,
         if ( eRes != UR_NOTHING )
         {
             ScSheetSourceDesc aNewDesc;
-            aNewDesc.aSourceRange = ScRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+            aNewDesc.SetSourceRange(ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2));
 
-            SCsCOL nDiffX = nCol1 - (SCsCOL) pSheetDesc->aSourceRange.aStart.Col();
-            SCsROW nDiffY = nRow1 - (SCsROW) pSheetDesc->aSourceRange.aStart.Row();
+            SCsCOL nDiffX = nCol1 - (SCsCOL) pSheetDesc->GetSourceRange().aStart.Col();
+            SCsROW nDiffY = nRow1 - (SCsROW) pSheetDesc->GetSourceRange().aStart.Row();
 
             aNewDesc.aQueryParam = pSheetDesc->aQueryParam;
             aNewDesc.aQueryParam.nCol1 = sal::static_int_cast<SCCOL>( aNewDesc.aQueryParam.nCol1 + nDiffX );
@@ -736,7 +738,7 @@ BOOL ScDPObject::RefsEqual( const ScDPObject& r ) const
 
     if ( pSheetDesc && r.pSheetDesc )
     {
-        if ( pSheetDesc->aSourceRange != r.pSheetDesc->aSourceRange )
+        if ( pSheetDesc->GetSourceRange() != r.pSheetDesc->GetSourceRange() )
             return FALSE;
     }
     else if ( pSheetDesc || r.pSheetDesc )
@@ -1859,7 +1861,7 @@ BOOL ScDPObject::FillOldParam(ScPivotParam& rParam, BOOL bForFile) const
         // in old file format, columns are within document, not within source range
 
         DBG_ASSERT( pSheetDesc, "FillOldParam: bForFile, !pSheetDesc" );
-        nColAdd = pSheetDesc->aSourceRange.aStart.Col();
+        nColAdd = pSheetDesc->GetSourceRange().aStart.Col();
     }
 
     bool bAddData = ( lcl_GetDataGetOrientation( xSource ) == sheet::DataPilotFieldOrientation_HIDDEN );
@@ -2691,7 +2693,7 @@ ScDPTableDataCache* ScDPCollection::GetUsedDPObjectCache ( const ScRange& rRange
     for (size_t i=maTables.size(); i > 0 ; --i)
     {
         if ( const ScSheetSourceDesc* pUsedSheetDesc = maTables[i-1].GetSheetDesc() )
-            if ( rRange == pUsedSheetDesc->aSourceRange )
+            if ( rRange == pUsedSheetDesc->GetSourceRange() )
             {
                 long nID = maTables[i-1].GetCacheId();
                 if ( nID >= 0 )
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index dbb6cd2..176f917 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -284,7 +284,7 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID
         {
             pCache = new ScDPTableDataCache( pDoc );
 
-            pCache->InitFromDoc( pDoc, aSourceRange );
+            pCache->InitFromDoc( pDoc, GetSourceRange() );
             pCache->SetId( nID );
             pDoc->GetDPCollection()->AddDPObjectCache( pCache );
 
@@ -299,7 +299,7 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID
 
 ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache ( ScDocument* pDoc  ) const
 {
-    return pDoc->GetDPCollection()->GetUsedDPObjectCache( aSourceRange );
+    return pDoc->GetDPCollection()->GetUsedDPObjectCache( GetSourceRange() );
 }
 
 ScDPTableDataCache* ScSheetSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
@@ -327,8 +327,8 @@ ULONG ScSheetSourceDesc::CheckSourceRange( ScDocument* pDoc ) const
     if (!pDoc)
         return STR_ERR_DATAPILOTSOURCE;
 
-    const ScAddress& s = aSrcRange.aStart();
-    const ScAddress& e = aSrcRange.aEnd();
+    const ScAddress& s = aSrcRange.aStart;
+    const ScAddress& e = aSrcRange.aEnd;
     for (SCCOL nCol = aSrcRange.aStart.Col(); nCol <= e.Col(); ++nCol)
     {
         if (pDoc->IsBlockEmpty(s.Tab(), nCol, s.Row(), nCol, s.Row()))
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 6b7f741..11e679f 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -640,7 +640,7 @@ XclExpPivotCache::XclExpPivotCache( const XclExpRoot& rRoot, const ScDPObject& r
             maDocSrcRange: Range used to get source data from Calc document.
                 This range may be shorter than maExpSrcRange to improve export
                 performance (#i22541#). */
-        maOrigSrcRange = maExpSrcRange = maDocSrcRange = pSrcDesc->aSourceRange;
+        maOrigSrcRange = maExpSrcRange = maDocSrcRange = pSrcDesc->GetSourceRange();
 
         // internal sheet data only
         SCTAB nScTab = maExpSrcRange.aStart.Tab();
@@ -717,7 +717,7 @@ bool XclExpPivotCache::HasEqualDataSource( const ScDPObject& rDPObj ) const
         compare the ScSheetSourceDesc. Later, there should be done more complicated
         comparisons regarding the source type of rDPObj and this cache. */
     if( const ScSheetSourceDesc* pSrcDesc = rDPObj.GetSheetDesc() )
-        return pSrcDesc->aSourceRange == maOrigSrcRange;
+        return pSrcDesc->GetSourceRange() == maOrigSrcRange;
     return false;
 }
 
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index dc63f7e..daa19bd 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1396,7 +1396,7 @@ void XclImpPivotTable::Convert()
 
     // create source descriptor
     ScSheetSourceDesc aDesc;
-    aDesc.aSourceRange = mxPCache->GetSourceRange();
+    aDesc.SetSourceRange(mxPCache->GetSourceRange());
 
     // adjust output range to include the page fields
     ScRange aOutRange( maOutScRange );
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index 42f0e31..4eab2ba 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -841,7 +841,7 @@ void ScXMLExportDataPilot::WriteDataPilots(const uno::Reference <sheet::XSpreads
                         {
                             const ScSheetSourceDesc* pSheetSource = (*pDPs)[i]->GetSheetDesc();
                             rtl::OUString sCellRangeAddress;
-                            ScRangeStringConverter::GetStringFromRange( sCellRangeAddress, pSheetSource->aSourceRange, pDoc, ::formula::FormulaGrammar::CONV_OOO );
+                            ScRangeStringConverter::GetStringFromRange( sCellRangeAddress, pSheetSource->GetSourceRange(), pDoc, ::formula::FormulaGrammar::CONV_OOO );
                             rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CELL_RANGE_ADDRESS, sCellRangeAddress);
                             SvXMLElementExport aElemSCR(rExport, XML_NAMESPACE_TABLE, XML_SOURCE_CELL_RANGE, sal_True, sal_True);
                             rExport.CheckAttrList();
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 774e622..1a746ce 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -446,7 +446,7 @@ void ScXMLDataPilotTableContext::EndElement()
                 if (bSourceCellRange)
                 {
                     ScSheetSourceDesc aSheetDesc;
-                    aSheetDesc.aSourceRange = aSourceCellRangeAddress;
+                    aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
                     aSheetDesc.SetQueryParam(aSourceQueryParam);
                     pDPObject->SetSheetDesc(aSheetDesc);
                 }
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 77dab61..e15a40d 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -248,7 +248,7 @@ void ScDPLayoutDlg::Init(bool bNewOutput)
     {
         aEdInPos.Enable();
         aRbInPos.Enable();
-        aOldRange = xDlgDPObject->GetSheetDesc()->aSourceRange;
+        aOldRange = xDlgDPObject->GetSheetDesc()->GetSourceRange();
         aOldRange.Format( inString, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
         aEdInPos.SetText(inString);
     }
@@ -1466,12 +1466,12 @@ void ScDPLayoutDlg::UpdateSrcRange()
     aBtnOk.Enable();
     ScSheetSourceDesc inSheet = *xDlgDPObject->GetSheetDesc();
 
-    if (inSheet.aSourceRange == aNewRange)
+    if (inSheet.GetSourceRange() == aNewRange)
         // new range is identical to the current range.  Nothing to do.
         return;
 
     ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
-    inSheet.aSourceRange = aNewRange;
+    inSheet.SetSourceRange(aNewRange);
     xDlgDPObject->SetSheetDesc(inSheet);
     xDlgDPObject->FillOldParam( thePivotData, FALSE );
     xDlgDPObject->FillLabelData(thePivotData);
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index fe930d0..76206e2 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -1355,7 +1355,7 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
                 if( pOldObj )
                 {   
                     const ScSheetSourceDesc* pSheetDesc = pOldObj->GetSheetDesc();
-                    if( pSheetDesc && pSheetDesc->aSourceRange.Intersects( aNewOut ) )
+                    if( pSheetDesc && pSheetDesc->GetSourceRange().Intersects( aNewOut ) )
                     {
                         ScRange aOldRange = pOldObj->GetOutRange();
                         SCsROW nDiff = aOldRange.aStart.Row()-aNewOut.aStart.Row();
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 2bdad7c..0ac2822 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -486,7 +486,7 @@ void ScDocShell::RefreshPivotTables( const ScRange& rSource )
             if ( pOld )
             {
                 const ScSheetSourceDesc* pSheetDesc = pOld->GetSheetDesc();
-                if ( pSheetDesc && pSheetDesc->aSourceRange.Intersects( rSource ) )
+                if ( pSheetDesc && pSheetDesc->GetSourceRange().Intersects( rSource ) )
                 {
                     ScDPObject* pNew = new ScDPObject( *pOld );
                     ScDBDocFunc aFunc( *this );
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 819a840..76ef5b4 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -707,7 +707,7 @@ CellRangeAddress SAL_CALL ScDataPilotDescriptorBase::getSourceRange()
 
     CellRangeAddress aRet;
     if (pDPObject->IsSheetData())
-        ScUnoConversion::FillApiRange( aRet, pDPObject->GetSheetDesc()->aSourceRange );
+        ScUnoConversion::FillApiRange( aRet, pDPObject->GetSheetDesc()->GetSourceRange() );
     return aRet;
 }
 
@@ -722,7 +722,10 @@ void SAL_CALL ScDataPilotDescriptorBase::setSourceRange( const CellRangeAddress&
     ScSheetSourceDesc aSheetDesc;
     if (pDPObject->IsSheetData())
         aSheetDesc = *pDPObject->GetSheetDesc();
-    ScUnoConversion::FillScRange( aSheetDesc.aSourceRange, aSourceRange );
+
+    ScRange aRange;
+    ScUnoConversion::FillScRange(aRange, aSourceRange);
+    aSheetDesc.SetSourceRange(aRange);
     pDPObject->SetSheetDesc( aSheetDesc );
     SetDPObject( pDPObject );
 }
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index bb4aea2..9d3db62 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -850,7 +850,7 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
                                 if (bOK)
                                 {
                                     ScSheetSourceDesc aShtDesc;
-                                    aShtDesc.aSourceRange = aRange;
+                                    aShtDesc.SetSourceRange(aRange);
                                     pNewDPObject = new ScDPObject( pDoc );
                                     pNewDPObject->SetSheetDesc( aShtDesc );
 
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 1c018e2..aceda30 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -211,7 +211,7 @@ void ScGridWindow::DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt
             if (pDesc)
             {
                 aQueryParam = pDesc->GetQueryParam();
-                nSrcTab = pDesc->aSourceRange.aStart.Tab();
+                nSrcTab = pDesc->GetSourceRange().aStart.Tab();
             }
 
             SfxItemSet aArgSet( pViewData->GetViewShell()->GetPool(),
diff --git a/sc/source/ui/view/pivotsh.cxx b/sc/source/ui/view/pivotsh.cxx
index 9381b3a..c9d42a9 100644
--- a/sc/source/ui/view/pivotsh.cxx
+++ b/sc/source/ui/view/pivotsh.cxx
@@ -116,7 +116,7 @@ void ScPivotShell::Execute( SfxRequest& rReq )
                 if( pDesc )
                 {
                     aQueryParam = pDesc->GetQueryParam();
-                    nSrcTab = pDesc->aSourceRange.aStart.Tab();
+                    nSrcTab = pDesc->GetSourceRange().aStart.Tab();
                 }
 
                 ScViewData* pViewData = pViewShell->GetViewData();


More information about the Libreoffice-commits mailing list