[Libreoffice-commits] core.git: sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Thu Feb 14 15:02:06 PST 2013


 sc/source/core/data/dptabres.cxx |  162 +++++++++++++++++++--------------------
 1 file changed, 80 insertions(+), 82 deletions(-)

New commits:
commit 1eb375177a7f0356e571a0d9c34cb64c649f2f45
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Feb 14 18:01:26 2013 -0500

    Caller should check the member visibility, not the callee.
    
    Just to be consistent...
    
    Change-Id: I8d36c438992751c6389c9481e5ff9ea198ccbba0

diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 5d80477..bae3831 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -1579,7 +1579,8 @@ void ScDPResultMember::FillDataResults( const ScDPResultMember* pRefMember,
                     OSL_ENSURE( rRow < rSequence.getLength(), "bumm" );
                     uno::Sequence<sheet::DataResult>& rSubSeq = rSequence.getArray()[rRow];
                     long nSeqCol = 0;
-                    pDataRoot->FillDataRow( pRefMember, rSubSeq, nSeqCol, nMemberMeasure, bHasChild, aSubState );
+                    if (pRefMember->IsVisible())
+                        pDataRoot->FillDataRow(pRefMember, rSubSeq, nSeqCol, nMemberMeasure, bHasChild, aSubState);
 
                     rRow += 1;
                 }
@@ -1975,115 +1976,112 @@ void ScDPDataMember::FillDataRow( const ScDPResultMember* pRefMember,
 {
     OSL_ENSURE( pRefMember == pResultMember || !pResultMember, "bla" );
 
-    if ( pRefMember->IsVisible() )  //! here or in ScDPDataDimension::FillDataRow ???
-    {
-        long nStartCol = rCol;
+    long nStartCol = rCol;
 
-        const ScDPDataDimension* pDataChild = GetChildDimension();
-        const ScDPResultDimension* pRefChild = pRefMember->GetChildDimension();
+    const ScDPDataDimension* pDataChild = GetChildDimension();
+    const ScDPResultDimension* pRefChild = pRefMember->GetChildDimension();
 
-        const ScDPLevel* pRefParentLevel = const_cast<ScDPResultMember*>(pRefMember)->GetParentLevel();
+    const ScDPLevel* pRefParentLevel = const_cast<ScDPResultMember*>(pRefMember)->GetParentLevel();
 
-        long nExtraSpace = 0;
-        if ( pRefParentLevel && pRefParentLevel->IsAddEmpty() )
-            ++nExtraSpace;
+    long nExtraSpace = 0;
+    if ( pRefParentLevel && pRefParentLevel->IsAddEmpty() )
+        ++nExtraSpace;
 
-        bool bTitleLine = false;
-        if ( pRefParentLevel && pRefParentLevel->IsOutlineLayout() )
-            bTitleLine = true;
+    bool bTitleLine = false;
+    if ( pRefParentLevel && pRefParentLevel->IsOutlineLayout() )
+        bTitleLine = true;
 
-        bool bSubTotalInTitle = pRefMember->IsSubTotalInTitle( nMeasure );
+    bool bSubTotalInTitle = pRefMember->IsSubTotalInTitle( nMeasure );
 
-        //  leave space for children even if the DataMember hasn't been initialized
-        //  (pDataChild is null then, this happens when no values for it are in this row)
-        bool bHasChild = ( pRefChild != NULL );
+    //  leave space for children even if the DataMember hasn't been initialized
+    //  (pDataChild is null then, this happens when no values for it are in this row)
+    bool bHasChild = ( pRefChild != NULL );
 
-        if ( bHasChild )
-        {
-            if ( bTitleLine )           // in tabular layout the title is on a separate column
-                ++rCol;                 // -> fill child dimension one column below
+    if ( bHasChild )
+    {
+        if ( bTitleLine )           // in tabular layout the title is on a separate column
+            ++rCol;                 // -> fill child dimension one column below
 
-            if ( pDataChild )
-                pDataChild->FillDataRow( pRefChild, rSequence, rCol, nMeasure, bIsSubTotalRow, rSubState );
-            rCol += (sal_uInt16)pRefMember->GetSize( nMeasure );
+        if ( pDataChild )
+            pDataChild->FillDataRow( pRefChild, rSequence, rCol, nMeasure, bIsSubTotalRow, rSubState );
+        rCol += (sal_uInt16)pRefMember->GetSize( nMeasure );
 
-            if ( bTitleLine )           // title column is included in GetSize, so the following
-                --rCol;                 // positions are calculated with the normal values
+        if ( bTitleLine )           // title column is included in GetSize, so the following
+            --rCol;                 // positions are calculated with the normal values
+    }
+
+    long nUserSubStart;
+    long nUserSubCount = pRefMember->GetSubTotalCount(&nUserSubStart);
+    if ( nUserSubCount || !bHasChild )
+    {
+        // Calculate at least automatic if no subtotals are selected,
+        // show only own values if there's no child dimension (innermost).
+        if ( !nUserSubCount || !bHasChild )
+        {
+            nUserSubCount = 1;
+            nUserSubStart = 0;
         }
 
-        long nUserSubStart;
-        long nUserSubCount = pRefMember->GetSubTotalCount(&nUserSubStart);
-        if ( nUserSubCount || !bHasChild )
+        ScDPSubTotalState aLocalSubState(rSubState);        // keep row state, modify column
+
+        long nMemberMeasure = nMeasure;
+        long nSubSize = pResultData->GetCountForMeasure(nMeasure);
+        if (bHasChild)
         {
-            // Calculate at least automatic if no subtotals are selected,
-            // show only own values if there's no child dimension (innermost).
-            if ( !nUserSubCount || !bHasChild )
-            {
-                nUserSubCount = 1;
-                nUserSubStart = 0;
-            }
+            rCol -= nSubSize * ( nUserSubCount - nUserSubStart );   // GetSize includes space for SubTotal
+            rCol -= nExtraSpace;                                    // GetSize includes the empty line
+        }
 
-            ScDPSubTotalState aLocalSubState(rSubState);        // keep row state, modify column
+        long nMoveSubTotal = 0;
+        if ( bSubTotalInTitle )
+        {
+            nMoveSubTotal = rCol - nStartCol;   // force to first (title) column
+            rCol = nStartCol;
+        }
 
-            long nMemberMeasure = nMeasure;
-            long nSubSize = pResultData->GetCountForMeasure(nMeasure);
-            if (bHasChild)
+        for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
+        {
+            if ( pChildDimension && nUserSubCount > 1 )
             {
-                rCol -= nSubSize * ( nUserSubCount - nUserSubStart );   // GetSize includes space for SubTotal
-                rCol -= nExtraSpace;                                    // GetSize includes the empty line
+                const ScDPLevel* pForceLevel = pResultMember ? pResultMember->GetParentLevel() : NULL;
+                aLocalSubState.nColSubTotalFunc = nUserPos;
+                aLocalSubState.eColForce = lcl_GetForceFunc( pForceLevel, nUserPos );
             }
 
-            long nMoveSubTotal = 0;
-            if ( bSubTotalInTitle )
+            for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
             {
-                nMoveSubTotal = rCol - nStartCol;   // force to first (title) column
-                rCol = nStartCol;
-            }
+                if ( nMeasure == SC_DPMEASURE_ALL )
+                    nMemberMeasure = nSubCount;
 
-            for (long nUserPos=nUserSubStart; nUserPos<nUserSubCount; nUserPos++)
-            {
-                if ( pChildDimension && nUserSubCount > 1 )
-                {
-                    const ScDPLevel* pForceLevel = pResultMember ? pResultMember->GetParentLevel() : NULL;
-                    aLocalSubState.nColSubTotalFunc = nUserPos;
-                    aLocalSubState.eColForce = lcl_GetForceFunc( pForceLevel, nUserPos );
-                }
+                OSL_ENSURE( rCol < rSequence.getLength(), "bumm" );
+                sheet::DataResult& rRes = rSequence.getArray()[rCol];
 
-                for ( long nSubCount=0; nSubCount<nSubSize; nSubCount++ )
+                if ( HasData( nMemberMeasure, aLocalSubState ) )
                 {
-                    if ( nMeasure == SC_DPMEASURE_ALL )
-                        nMemberMeasure = nSubCount;
-
-                    OSL_ENSURE( rCol < rSequence.getLength(), "bumm" );
-                    sheet::DataResult& rRes = rSequence.getArray()[rCol];
-
-                    if ( HasData( nMemberMeasure, aLocalSubState ) )
+                    if ( HasError( nMemberMeasure, aLocalSubState ) )
                     {
-                        if ( HasError( nMemberMeasure, aLocalSubState ) )
-                        {
-                            rRes.Value = 0;
-                            rRes.Flags |= sheet::DataResultFlags::ERROR;
-                        }
-                        else
-                        {
-                            rRes.Value = GetAggregate( nMemberMeasure, aLocalSubState );
-                            rRes.Flags |= sheet::DataResultFlags::HASDATA;
-                        }
+                        rRes.Value = 0;
+                        rRes.Flags |= sheet::DataResultFlags::ERROR;
                     }
+                    else
+                    {
+                        rRes.Value = GetAggregate( nMemberMeasure, aLocalSubState );
+                        rRes.Flags |= sheet::DataResultFlags::HASDATA;
+                    }
+                }
 
-                    if ( bHasChild || bIsSubTotalRow )
-                        rRes.Flags |= sheet::DataResultFlags::SUBTOTAL;
+                if ( bHasChild || bIsSubTotalRow )
+                    rRes.Flags |= sheet::DataResultFlags::SUBTOTAL;
 
-                    rCol += 1;
-                }
+                rCol += 1;
             }
+        }
 
-            // add extra space again if subtracted from GetSize above,
-            // add to own size if no children
-            rCol += nExtraSpace;
+        // add extra space again if subtracted from GetSize above,
+        // add to own size if no children
+        rCol += nExtraSpace;
 
-            rCol += nMoveSubTotal;
-        }
+        rCol += nMoveSubTotal;
     }
 }
 


More information about the Libreoffice-commits mailing list