[Libreoffice-commits] .: 4 commits - sc/inc sc/qa sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Feb 24 21:46:32 PST 2012


 sc/inc/dpoutput.hxx              |   46 ++++-----
 sc/qa/unit/ucalc.cxx             |   14 --
 sc/source/core/data/dpobject.cxx |    4 
 sc/source/core/data/dpoutput.cxx |  196 +++++++++++++++++++--------------------
 sc/source/core/data/dptabsrc.cxx |   11 +-
 5 files changed, 140 insertions(+), 131 deletions(-)

New commits:
commit 1fb5aea16f11c90aaac23486e584a17e0655b621
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Sat Feb 25 00:42:02 2012 -0500

    Show column/row grand totals only when at least one column/row field exists.
    
    Otherwise the grand total would be just a duplicate of the data field
    area.

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 37a8ee7..89bc980 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1662,9 +1662,7 @@ void Test::testPivotTableFilters()
             { 0, 0 },
             { "Data", 0 },
             { "Sum - Val1", "8" },
-            { "Sum - Val2", "80" },
-            { "Total Sum - Val1", "8" },
-            { "Total Sum - Val2", "80" }
+            { "Sum - Val2", "80" }
         };
 
         bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, "DataPilot table output (unfiltered)");
@@ -1676,7 +1674,7 @@ void Test::testPivotTableFilters()
     ScAddress aFormulaAddr = aOutRange.aEnd;
     aFormulaAddr.IncRow(2);
     m_pDoc->SetString(aFormulaAddr.Col(), aFormulaAddr.Row(), aFormulaAddr.Tab(),
-                      rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=B8")));
+                      rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=B6")));
     double fTest = m_pDoc->GetValue(aFormulaAddr);
     CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 80.0);
 
@@ -1698,9 +1696,7 @@ void Test::testPivotTableFilters()
             { 0, 0 },
             { "Data", 0 },
             { "Sum - Val1", "4" },
-            { "Sum - Val2", "40" },
-            { "Total Sum - Val1", "4" },
-            { "Total Sum - Val2", "40" }
+            { "Sum - Val2", "40" }
         };
 
         bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, "DataPilot table output (filtered by page)");
@@ -1730,9 +1726,7 @@ void Test::testPivotTableFilters()
             { 0, 0 },
             { "Data", 0 },
             { "Sum - Val1", "2" },
-            { "Sum - Val2", "20" },
-            { "Total Sum - Val1", "2" },
-            { "Total Sum - Val2", "20" }
+            { "Sum - Val2", "20" }
         };
 
         bSuccess = checkDPTableOutput<2>(m_pDoc, aOutRange, aOutputCheck, "DataPilot table output (filtered by query)");
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 22f17ef..24dc55f 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -863,8 +863,15 @@ void ScDPSource::CreateRes_Impl()
             aInitState.AddMember( nPageDims[i], GetMemberId( nPageDims[i],  pDim->GetSelectedData() ) );
     }
 
-    pColResRoot = new ScDPResultMember( pResData, bColumnGrand );
-    pRowResRoot = new ScDPResultMember( pResData, bRowGrand );
+    // Show grand total columns only when the option is set *and* there is at
+    // least one column field.  Same for the grand total rows.
+    sal_uInt16 nDataLayoutOrient = GetDataLayoutOrientation();
+    long nColDimCount2 = nColDimCount - (nDataLayoutOrient == sheet::DataPilotFieldOrientation_COLUMN ? 1 : 0);
+    long nRowDimCount2 = nRowDimCount - (nDataLayoutOrient == sheet::DataPilotFieldOrientation_ROW ? 1 : 0);
+    bool bShowColGrand = bColumnGrand && nColDimCount2 > 0;
+    bool bShowRowGrand = bRowGrand && nRowDimCount2 > 0;
+    pColResRoot = new ScDPResultMember(pResData, bShowColGrand);
+    pRowResRoot = new ScDPResultMember(pResData, bShowRowGrand);
 
     FillCalcInfo(false, aInfo, bHasAutoShow);
     long nColLevelCount = aInfo.aColLevels.size();
commit 778a6993b971f13f4008491f54296e57b9026238
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Feb 24 22:03:15 2012 -0500

    boolean cleanup in ScDPOutput.

diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index 1aec7e7..24de356 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -81,7 +81,6 @@ private:
     com::sun::star::uno::Reference<
         com::sun::star::sheet::XDimensionsSupplier> xSource;
     ScAddress               aStartPos;
-    bool                    bDoFilter;
     ScDPOutLevelData*       pColFields;
     ScDPOutLevelData*       pRowFields;
     ScDPOutLevelData*       pPageFields;
@@ -91,8 +90,6 @@ private:
     com::sun::star::uno::Sequence<
         com::sun::star::uno::Sequence<
             com::sun::star::sheet::DataResult> > aData;
-    bool                    bResultsError;
-    bool                    mbHasDataLayout;
     rtl::OUString           aDataDescription;
 
     // Number format related parameters
@@ -103,12 +100,9 @@ private:
     sal_uInt32                  nSingleNumFmt;
 
     // Output geometry related parameters
-    bool                    bSizesValid;
-    bool                    bSizeOverflow;
     long                    nColCount;
     long                    nRowCount;
     long                    nHeaderSize;
-    bool                    mbHeaderLayout;  // sal_True : grid, sal_False : standard
     SCCOL                   nTabStartCol;
     SCROW                   nTabStartRow;
     SCCOL                   nMemberStartCol;
@@ -117,12 +111,18 @@ private:
     SCROW                   nDataStartRow;
     SCCOL                   nTabEndCol;
     SCROW                   nTabEndRow;
+    bool                    bDoFilter:1;
+    bool                    bResultsError:1;
+    bool                    mbHasDataLayout:1;
+    bool                    bSizesValid:1;
+    bool                    bSizeOverflow:1;
+    bool                    mbHeaderLayout:1;  // true : grid, false : standard
 
     void            DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                 const com::sun::star::sheet::DataResult& rData );
     void            HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                 const com::sun::star::sheet::MemberResult& rData,
-                                sal_Bool bColHeader, long nLevel );
+                                bool bColHeader, long nLevel );
 
     void FieldCell(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScDPOutLevelData& rData, bool bInTable);
 
@@ -153,13 +153,17 @@ public:
         field region. */
     bool            GetDataResultPositionData(::std::vector< ::com::sun::star::sheet::DataPilotFieldFilter >& rFilters, const ScAddress& rPos);
 
-    sal_Bool            GetPivotData( ScDPGetPivotDataField& rTarget, /* returns result */
-                                  const std::vector< ScDPGetPivotDataField >& rFilters );
+    /**
+     * @return true on success and stores the result in rTarget, or false if
+     *         rFilters or rTarget describe something that is not visible.
+     */
+    bool GetPivotData( ScDPGetPivotDataField& rTarget,
+                       const std::vector< ScDPGetPivotDataField >& rFilters );
     long            GetHeaderDim( const ScAddress& rPos, sal_uInt16& rOrient );
-    sal_Bool            GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft, sal_Bool bMouseTop,
-                                    long nDragDim,
-                                    Rectangle& rPosRect, sal_uInt16& rOrient, long& rDimPos );
-    sal_Bool            IsFilterButton( const ScAddress& rPos );
+    bool GetHeaderDrag(
+        const ScAddress& rPos, bool bMouseLeft, bool bMouseTop, long nDragDim,
+        Rectangle& rPosRect, sal_uInt16& rOrient, long& rDimPos );
+    bool IsFilterButton( const ScAddress& rPos );
 
     void GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension);
 
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index f53f8fa..f903f0d 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -283,7 +283,7 @@ void ScDPOutputImpl::OutputBlockFrame ( SCCOL nStartCol, SCROW nStartRow, SCCOL
     aBoxInfo.SetValid(VALID_VERT,false );
     if ( bHori )
     {
-        aBoxInfo.SetValid(VALID_HORI,sal_True);
+        aBoxInfo.SetValid(VALID_HORI,true);
         aBoxInfo.SetLine( &aLine, BOXINFO_LINE_HORI );
     }
     else
@@ -366,7 +366,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
         rtl::OUString aDataNames[SC_DPOUT_MAXLEVELS];
         sal_uInt32 nDataFormats[SC_DPOUT_MAXLEVELS];
         long nDataCount = 0;
-        sal_Bool bAnySet = false;
+        bool bAnySet = false;
 
         long nDimCount = xDims->getCount();
         for (long nDim=0; nDim<nDimCount; nDim++)
@@ -389,7 +389,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
                                             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)) );
                     nDataFormats[nDataCount] = nFormat;
                     if ( nFormat != 0 )
-                        bAnySet = sal_True;
+                        bAnySet = true;
                     ++nDataCount;
                 }
             }
@@ -472,7 +472,7 @@ void lcl_SortFields( ScDPOutLevelData* pFields, long nFieldCount )
     }
 }
 
-sal_Bool lcl_MemberEmpty( const uno::Sequence<sheet::MemberResult>& rSeq )
+bool lcl_MemberEmpty( const uno::Sequence<sheet::MemberResult>& rSeq )
 {
     //  used to skip levels that have no members
 
@@ -482,7 +482,7 @@ sal_Bool lcl_MemberEmpty( const uno::Sequence<sheet::MemberResult>& rSeq )
         if (pArray[i].Flags & sheet::MemberResultFlags::HASMEMBER)
             return false;
 
-    return sal_True;    // no member data -> empty
+    return true;    // no member data -> empty
 }
 
 uno::Sequence<sheet::MemberResult> lcl_GetSelectedPageAsResult( const uno::Reference<beans::XPropertySet>& xDimProp )
@@ -528,17 +528,17 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
     pDoc( pD ),
     xSource( xSrc ),
     aStartPos( rPos ),
-    bDoFilter( bFilter ),
-    bResultsError( false ),
-    mbHasDataLayout(false),
     pColNumFmt( NULL ),
     pRowNumFmt( NULL ),
     nColFmtCount( 0 ),
     nRowFmtCount( 0 ),
     nSingleNumFmt( 0 ),
-    bSizesValid( false ),
-    bSizeOverflow( false ),
-    mbHeaderLayout( false )
+    bDoFilter(bFilter),
+    bResultsError(false),
+    mbHasDataLayout(false),
+    bSizesValid(false),
+    bSizeOverflow(false),
+    mbHeaderLayout(false)
 {
     nTabStartCol = nMemberStartCol = nDataStartCol = nTabEndCol = 0;
     nTabStartRow = nMemberStartRow = nDataStartRow = nTabEndRow = 0;
@@ -782,7 +782,7 @@ void ScDPOutput::DataCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const sheet::Data
 }
 
 void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
-                                const sheet::MemberResult& rData, sal_Bool bColHeader, long nLevel )
+                             const sheet::MemberResult& rData, bool bColHeader, long nLevel )
 {
     long nFlags = rData.Flags;
 
@@ -1059,7 +1059,7 @@ void ScDPOutput::Output()
                     {
                         outputimp.AddCol( nColPos );
                         if ( nColPos + 1 == nEndColPos  )
-                            outputimp.OutputBlockFrame( nColPos,nRowPos, nEndColPos,nRowPos+1, sal_True );
+                            outputimp.OutputBlockFrame( nColPos,nRowPos, nEndColPos,nRowPos+1, true );
                     }
                     else
                         outputimp.OutputBlockFrame( nColPos,nRowPos, nEndColPos,nRowPos );
@@ -1077,7 +1077,7 @@ void ScDPOutput::Output()
     }
 
     //  output row headers:
-    std::vector<sal_Bool> vbSetBorder;
+    std::vector<bool> vbSetBorder;
     vbSetBorder.resize( nTabEndRow - nDataStartRow + 1, false );
     for (nField=0; nField<nRowFieldCount; nField++)
     {
@@ -1107,7 +1107,7 @@ void ScDPOutput::Output()
                     if ( vbSetBorder[ nRow ] == false )
                     {
                         outputimp.OutputBlockFrame( nColPos, nRowPos, nTabEndCol, nEndRowPos );
-                        vbSetBorder[ nRow ]  = sal_True;
+                        vbSetBorder[ nRow ]  = true;
                     }
                     outputimp.OutputBlockFrame( nColPos, nRowPos, nColPos, nEndRowPos );
 
@@ -1226,13 +1226,13 @@ void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, s
     rDataOrient = sheet::DataPilotFieldOrientation_HIDDEN;
 
     uno::Reference<beans::XPropertySet> xSrcProp( xSource, uno::UNO_QUERY );
-    sal_Bool bColGrand = ScUnoHelpFunctions::GetBoolProperty( xSrcProp,
-                                         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_COLGRAND)) );
+    bool bColGrand = ScUnoHelpFunctions::GetBoolProperty(
+        xSrcProp, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_COLGRAND)));
     if ( bColGrand )
         rGrandTotalCols = 1;    // default if data layout not in columns
 
-    sal_Bool bRowGrand = ScUnoHelpFunctions::GetBoolProperty( xSrcProp,
-                                         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ROWGRAND)) );
+    bool bRowGrand = ScUnoHelpFunctions::GetBoolProperty(
+        xSrcProp, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ROWGRAND)));
     if ( bRowGrand )
         rGrandTotalRows = 1;    // default if data layout not in rows
 
@@ -1506,14 +1506,14 @@ bool lcl_IsCondition( const sheet::MemberResult& rResultEntry, const ScDPGetPivo
 }
 
 bool lcl_CheckPageField( const ScDPOutLevelData& rField,
-                        const std::vector< ScDPGetPivotDataField >& rFilters,
-                        std::vector< sal_Bool >& rFilterUsed )
+                         const std::vector< ScDPGetPivotDataField >& rFilters,
+                         std::vector<bool>& rFilterUsed )
 {
     for (SCSIZE nFilterPos = 0; nFilterPos < rFilters.size(); ++nFilterPos)
     {
         if ( lcl_IsNamedCategoryField( rFilters[nFilterPos], rField ) )
         {
-            rFilterUsed[nFilterPos] = sal_True;
+            rFilterUsed[nFilterPos] = true;
 
             // page field result is empty or the selection as single entry (see lcl_GetSelectedPageAsResult)
             if ( rField.aResult.getLength() == 1 &&
@@ -1591,10 +1591,10 @@ uno::Sequence<sheet::GeneralFunction> lcl_GetSubTotals(
     return aSubTotals;
 }
 
-void lcl_FilterInclude( std::vector< sal_Bool >& rResult, std::vector< sal_Int32 >& rSubtotal,
+void lcl_FilterInclude( std::vector<bool>& rResult, std::vector< sal_Int32 >& rSubtotal,
                         const ScDPOutLevelData& rField,
                         const std::vector< ScDPGetPivotDataField >& rFilters,
-                        std::vector< sal_Bool >& rFilterUsed,
+                        std::vector<bool>& rFilterUsed,
                         bool& rBeforeDataLayout,
                         sal_Int32 nGrandTotals, sal_Int32 nDataLayoutIndex,
                         const std::vector<rtl::OUString>& rDataNames, const std::vector<rtl::OUString>& rGivenNames,
@@ -1617,7 +1617,7 @@ void lcl_FilterInclude( std::vector< sal_Bool >& rResult, std::vector< sal_Int32
             if ( lcl_IsNamedCategoryField( rFilters[nFilterPos], rField ) )
             {
                 aFilter = rFilters[nFilterPos];
-                rFilterUsed[nFilterPos] = sal_True;
+                rFilterUsed[nFilterPos] = true;
                 bHasFilter = true;
             }
         }
@@ -1768,7 +1768,7 @@ void lcl_FilterInclude( std::vector< sal_Bool >& rResult, std::vector< sal_Int32
     }
 }
 
-void lcl_StripSubTotals( std::vector< sal_Bool >& rResult, const std::vector< sal_Int32 >& rSubtotal )
+void lcl_StripSubTotals( std::vector<bool>& rResult, const std::vector<sal_Int32>& rSubtotal )
 {
     sal_Int32 nSize = rResult.size();
     OSL_ENSURE( (sal_Int32)rSubtotal.size() == nSize, "sizes don't match" );
@@ -1840,9 +1840,7 @@ void ScDPOutput::GetDataDimensionNames(
     }
 }
 
-// Returns sal_True on success and stores the result in rTarget
-// Returns sal_False if rFilters or rTarget describes something that is not visible
-sal_Bool ScDPOutput::GetPivotData( ScDPGetPivotDataField& rTarget,
+bool ScDPOutput::GetPivotData( ScDPGetPivotDataField& rTarget,
                                const std::vector< ScDPGetPivotDataField >& rFilters )
 {
     CalcSizes();
@@ -1868,12 +1866,12 @@ sal_Bool ScDPOutput::GetPivotData( ScDPGetPivotDataField& rTarget,
             return false;
     }
 
-    std::vector< sal_Bool > aIncludeCol( nColCount, sal_True );
+    std::vector<bool> aIncludeCol(nColCount, true);
     std::vector< sal_Int32 > aSubtotalCol( nColCount, 0 );
-    std::vector< sal_Bool > aIncludeRow( nRowCount, sal_True );
+    std::vector<bool> aIncludeRow(nRowCount, true);
     std::vector< sal_Int32 > aSubtotalRow( nRowCount, 0 );
 
-    std::vector< sal_Bool > aFilterUsed( rFilters.size(), false );
+    std::vector<bool> aFilterUsed(rFilters.size(), false);
 
     long nField;
     long nCol;
@@ -1940,10 +1938,10 @@ sal_Bool ScDPOutput::GetPivotData( ScDPGetPivotDataField& rTarget,
     rTarget.mbValIsStr = false;
     rTarget.mnValNum = rResult.Value;
 
-    return sal_True;
+    return true;
 }
 
-sal_Bool ScDPOutput::IsFilterButton( const ScAddress& rPos )
+bool ScDPOutput::IsFilterButton( const ScAddress& rPos )
 {
     SCCOL nCol = rPos.Col();
     SCROW nRow = rPos.Row();
@@ -2001,7 +1999,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, sal_uInt16& rOrient )
     return -1;      // invalid
 }
 
-sal_Bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft, sal_Bool bMouseTop,
+bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMouseTop,
                                 long nDragDim,
                                 Rectangle& rPosRect, sal_uInt16& rOrient, long& rDimPos )
 {
@@ -2026,25 +2024,25 @@ sal_Bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft,
         if (nField < 0)
         {
             nField = 0;
-            bMouseTop = sal_True;
+            bMouseTop = true;
         }
         //! find start of dimension
 
         rPosRect = Rectangle( nDataStartCol, nMemberStartRow + nField,
                               nTabEndCol, nMemberStartRow + nField -1 );
 
-        sal_Bool bFound = false;            // is this within the same orientation?
-        sal_Bool bBeforeDrag = false;
-        sal_Bool bAfterDrag = false;
+        bool bFound = false;            // is this within the same orientation?
+        bool bBeforeDrag = false;
+        bool bAfterDrag = false;
         for (long nPos=0; nPos<nColFieldCount && !bFound; nPos++)
         {
             if (pColFields[nPos].nDim == nDragDim)
             {
-                bFound = sal_True;
+                bFound = true;
                 if ( nField < nPos )
-                    bBeforeDrag = sal_True;
+                    bBeforeDrag = true;
                 else if ( nField > nPos )
-                    bAfterDrag = sal_True;
+                    bAfterDrag = true;
             }
         }
 
@@ -2069,13 +2067,13 @@ sal_Bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft,
 
         rOrient = sheet::DataPilotFieldOrientation_COLUMN;
         rDimPos = nField;                       //!...
-        return sal_True;
+        return true;
     }
 
     //  test for row header
 
     //  special case if no row fields
-    sal_Bool bSpecial = ( nRow+1 >= nDataStartRow && nRow <= nTabEndRow &&
+    bool bSpecial = ( nRow+1 >= nDataStartRow && nRow <= nTabEndRow &&
                         nRowFieldCount == 0 && nCol == nTabStartCol && bMouseLeft );
 
     if ( bSpecial || ( nRow+1 >= nDataStartRow && nRow <= nTabEndRow &&
@@ -2087,18 +2085,18 @@ sal_Bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft,
         rPosRect = Rectangle( nTabStartCol + nField, nDataStartRow - 1,
                               nTabStartCol + nField - 1, nTabEndRow );
 
-        sal_Bool bFound = false;            // is this within the same orientation?
-        sal_Bool bBeforeDrag = false;
-        sal_Bool bAfterDrag = false;
+        bool bFound = false;            // is this within the same orientation?
+        bool bBeforeDrag = false;
+        bool bAfterDrag = false;
         for (long nPos=0; nPos<nRowFieldCount && !bFound; nPos++)
         {
             if (pRowFields[nPos].nDim == nDragDim)
             {
-                bFound = sal_True;
+                bFound = true;
                 if ( nField < nPos )
-                    bBeforeDrag = sal_True;
+                    bBeforeDrag = true;
                 else if ( nField > nPos )
-                    bAfterDrag = sal_True;
+                    bAfterDrag = true;
             }
         }
 
@@ -2123,7 +2121,7 @@ sal_Bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft,
 
         rOrient = sheet::DataPilotFieldOrientation_ROW;
         rDimPos = nField;                       //!...
-        return sal_True;
+        return true;
     }
 
     //  test for page fields
@@ -2136,25 +2134,25 @@ sal_Bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft,
         if (nField < 0)
         {
             nField = 0;
-            bMouseTop = sal_True;
+            bMouseTop = true;
         }
         //! find start of dimension
 
         rPosRect = Rectangle( aStartPos.Col(), nPageStartRow + nField,
                               nTabEndCol, nPageStartRow + nField - 1 );
 
-        sal_Bool bFound = false;            // is this within the same orientation?
-        sal_Bool bBeforeDrag = false;
-        sal_Bool bAfterDrag = false;
+        bool bFound = false;            // is this within the same orientation?
+        bool bBeforeDrag = false;
+        bool bAfterDrag = false;
         for (long nPos=0; nPos<nPageFieldCount && !bFound; nPos++)
         {
             if (pPageFields[nPos].nDim == nDragDim)
             {
-                bFound = sal_True;
+                bFound = true;
                 if ( nField < nPos )
-                    bBeforeDrag = sal_True;
+                    bBeforeDrag = true;
                 else if ( nField > nPos )
-                    bAfterDrag = sal_True;
+                    bAfterDrag = true;
             }
         }
 
@@ -2179,7 +2177,7 @@ sal_Bool ScDPOutput::GetHeaderDrag( const ScAddress& rPos, sal_Bool bMouseLeft,
 
         rOrient = sheet::DataPilotFieldOrientation_PAGE;
         rDimPos = nField;                       //!...
-        return sal_True;
+        return true;
     }
 
     return false;
commit 397e5668b7269e19d66705cbed5b577db0510a9f
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Feb 24 21:40:58 2012 -0500

    ScDPOutput is now String-free.

diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index 4a02647..1aec7e7 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -57,11 +57,11 @@ struct ScDPOutLevelData;
 
 struct ScDPGetPivotDataField
 {
-    String maFieldName;
+    rtl::OUString maFieldName;
     com::sun::star::sheet::GeneralFunction meFunction;
 
     bool   mbValIsStr;
-    String maValStr;
+    rtl::OUString maValStr;
     double mnValNum;
 
         ScDPGetPivotDataField() :
@@ -74,10 +74,9 @@ struct ScDPGetPivotDataField
 
 
 
-class ScDPOutput            //! name???
+class ScDPOutput
 {
 private:
-    //! use impl-object?
     ScDocument*             pDoc;
     com::sun::star::uno::Reference<
         com::sun::star::sheet::XDimensionsSupplier> xSource;
@@ -94,7 +93,7 @@ private:
             com::sun::star::sheet::DataResult> > aData;
     bool                    bResultsError;
     bool                    mbHasDataLayout;
-    String                  aDataDescription;
+    rtl::OUString           aDataDescription;
 
     // Number format related parameters
     sal_uInt32*                 pColNumFmt;
@@ -167,9 +166,10 @@ public:
     void            SetHeaderLayout(bool bUseGrid);
     bool            GetHeaderLayout() const;
 
-    static void     GetDataDimensionNames( String& rSourceName, String& rGivenName,
-                                           const com::sun::star::uno::Reference<
-                                               com::sun::star::uno::XInterface>& xDim );
+    static void GetDataDimensionNames(
+        rtl::OUString& rSourceName, rtl::OUString& rGivenName,
+        const com::sun::star::uno::Reference<
+            com::sun::star::uno::XInterface>& xDim );
 };
 
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index bd28f39..a042a45 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1353,8 +1353,8 @@ bool ScDPObject::ParseFilters( ScDPGetPivotDataField& rTarget,
         {
             if ( nOrient == sheet::DataPilotFieldOrientation_DATA )
             {
-                String aSourceName;
-                String aGivenName;
+                rtl::OUString aSourceName;
+                rtl::OUString aGivenName;
                 ScDPOutput::GetDataDimensionNames( aSourceName, aGivenName, xIntDim );
                 aDataNames.push_back( aSourceName );
                 aGivenNames.push_back( aGivenName );
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 392b99a..f53f8fa 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -305,7 +305,7 @@ void lcl_SetStyleById( ScDocument* pDoc, SCTAB nTab,
         return;
     }
 
-    String aStyleName = ScGlobal::GetRscString( nStrId );
+    rtl::OUString aStyleName = ScGlobal::GetRscString( nStrId );
     ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool();
     ScStyleSheet* pStyle = (ScStyleSheet*) pStlPool->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
     if (!pStyle)
@@ -363,7 +363,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
         //  get names/formats for all data dimensions
         //! merge this with the loop to collect ScDPOutLevelData?
 
-        String aDataNames[SC_DPOUT_MAXLEVELS];
+        rtl::OUString aDataNames[SC_DPOUT_MAXLEVELS];
         sal_uInt32 nDataFormats[SC_DPOUT_MAXLEVELS];
         long nDataCount = 0;
         sal_Bool bAnySet = false;
@@ -383,7 +383,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
                         sheet::DataPilotFieldOrientation_HIDDEN );
                 if ( eDimOrient == sheet::DataPilotFieldOrientation_DATA )
                 {
-                    aDataNames[nDataCount] = String( xDimName->getName() );
+                    aDataNames[nDataCount] = xDimName->getName();
                     long nFormat = ScUnoHelpFunctions::GetLongProperty(
                                             xDimProp,
                                             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_NUMFMT)) );
@@ -399,7 +399,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
         {
             const sheet::MemberResult* pArray = aResult.getConstArray();
 
-            String aName;
+            rtl::OUString aName;
             sal_uInt32* pNumFmt = new sal_uInt32[nSize];
             if (nDataCount == 1)
             {
@@ -415,7 +415,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
                     //  if CONTINUE bit is set, keep previous name
                     //! keep number format instead!
                     if ( !(pArray[nPos].Flags & sheet::MemberResultFlags::CONTINUE) )
-                        aName = String( pArray[nPos].Name );
+                        aName = pArray[nPos].Name;
 
                     sal_uInt32 nFormat = 0;
                     for (long i=0; i<nDataCount; i++)
@@ -716,7 +716,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                     rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_DATADESC)) );
             rtl::OUString aUStr;
             aAny >>= aUStr;
-            aDataDescription = String( aUStr );
+            aDataDescription = aUStr;
         }
         catch(uno::Exception&)
         {
@@ -998,11 +998,11 @@ void ScDPOutput::Output()
         FieldCell(nHdrCol, nHdrRow, nTab, pPageFields[nField], false);
         SCCOL nFldCol = nHdrCol + 1;
 
-        String aPageValue;
+        rtl::OUString aPageValue;
         if ( pPageFields[nField].aResult.getLength() == 1 )
             aPageValue = pPageFields[nField].aResult[0].Caption;
         else
-            aPageValue = String( ScResId( SCSTR_ALL ) );        //! separate string?
+            aPageValue = ScResId::toString(ScResId(SCSTR_ALL));        //! separate string?
 
         pDoc->SetString( nFldCol, nHdrRow, nTab, aPageValue );
 
@@ -1014,12 +1014,11 @@ void ScDPOutput::Output()
     //  data description
     //  (may get overwritten by first row field)
 
-    String aDesc = aDataDescription;
-    if ( !aDesc.Len() )
+    if (aDataDescription.isEmpty())
     {
         //! use default string ("result") ?
     }
-    pDoc->SetString( nTabStartCol, nTabStartRow, nTab, aDesc );
+    pDoc->SetString(nTabStartCol, nTabStartRow, nTab, aDataDescription);
 
     //  set STR_PIVOT_STYLE_INNER for whole data area (subtotals are overwritten)
 
@@ -1217,9 +1216,9 @@ bool ScDPOutput::GetHeaderLayout() const
 namespace {
 
 void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, sal_Int32& rDataLayoutIndex,
-                             std::vector<String>& rDataNames, std::vector<String>& rGivenNames,
-                             sheet::DataPilotFieldOrientation& rDataOrient,
-                             const uno::Reference<sheet::XDimensionsSupplier>& xSource )
+                       std::vector<rtl::OUString>& rDataNames, std::vector<rtl::OUString>& rGivenNames,
+                       sheet::DataPilotFieldOrientation& rDataOrient,
+                       const uno::Reference<sheet::XDimensionsSupplier>& xSource )
 {
     rDataLayoutIndex = -1;  // invalid
     rGrandTotalCols = 0;
@@ -1264,8 +1263,8 @@ void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, s
                 }
                 if ( eDimOrient == sheet::DataPilotFieldOrientation_DATA )
                 {
-                    String aSourceName;
-                    String aGivenName;
+                    rtl::OUString aSourceName;
+                    rtl::OUString aGivenName;
                     ScDPOutput::GetDataDimensionNames( aSourceName, aGivenName, xDim );
                     rDataNames.push_back( aSourceName );
                     rGivenNames.push_back( aGivenName );
@@ -1408,8 +1407,8 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
     sal_Int32 nGrandTotalCols;
     sal_Int32 nGrandTotalRows;
     sal_Int32 nDataLayoutIndex;
-    std::vector<String> aDataNames;
-    std::vector<String> aGivenNames;
+    std::vector<rtl::OUString> aDataNames;
+    std::vector<rtl::OUString> aGivenNames;
     sheet::DataPilotFieldOrientation eDataOrient;
     lcl_GetTableVars( nGrandTotalCols, nGrandTotalRows, nDataLayoutIndex, aDataNames, aGivenNames, eDataOrient, xSource );
 
@@ -1482,6 +1481,8 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
     return true;
 }
 
+namespace {
+
 //
 //  helper functions for ScDPOutput::GetPivotData
 //
@@ -1596,7 +1597,7 @@ void lcl_FilterInclude( std::vector< sal_Bool >& rResult, std::vector< sal_Int32
                         std::vector< sal_Bool >& rFilterUsed,
                         bool& rBeforeDataLayout,
                         sal_Int32 nGrandTotals, sal_Int32 nDataLayoutIndex,
-                        const std::vector<String>& rDataNames, const std::vector<String>& rGivenNames,
+                        const std::vector<rtl::OUString>& rDataNames, const std::vector<rtl::OUString>& rGivenNames,
                         const ScDPGetPivotDataField& rTarget, const uno::Reference<sheet::XDimensionsSupplier>& xSource )
 {
     // returns true if a filter was given for the field
@@ -1664,8 +1665,8 @@ void lcl_FilterInclude( std::vector< sal_Bool >& rResult, std::vector< sal_Int32
                     // grand total is always automatic
                     sal_Int32 nDataPos = j - ( nSize - nGrandTotals );
                     OSL_ENSURE( nDataPos < (sal_Int32)rDataNames.size(), "wrong data count" );
-                    String aSourceName( rDataNames[nDataPos] );     // vector contains source names
-                    String aGivenName( rGivenNames[nDataPos] );
+                    rtl::OUString aSourceName( rDataNames[nDataPos] );     // vector contains source names
+                    rtl::OUString aGivenName( rGivenNames[nDataPos] );
 
                     rResult[j] = lcl_IsNamedDataField( rTarget, aSourceName, aGivenName );
                 }
@@ -1700,8 +1701,8 @@ void lcl_FilterInclude( std::vector< sal_Bool >& rResult, std::vector< sal_Int32
                         sal_Int32 nFuncPos = nSubTotalCount / nDataCount;       // outer order: subtotal functions
                         sal_Int32 nDataPos = nSubTotalCount % nDataCount;       // inner order: data fields
 
-                        String aSourceName( rDataNames[nDataPos] );             // vector contains source names
-                        String aGivenName( rGivenNames[nDataPos] );
+                        rtl::OUString aSourceName( rDataNames[nDataPos] );             // vector contains source names
+                        rtl::OUString aGivenName( rGivenNames[nDataPos] );
 
                         OSL_ENSURE( nFuncPos < aSubTotals.getLength(), "wrong subtotal count" );
                         rResult[j] = lcl_IsNamedDataField( rTarget, aSourceName, aGivenName ) &&
@@ -1720,8 +1721,8 @@ void lcl_FilterInclude( std::vector< sal_Bool >& rResult, std::vector< sal_Int32
                     if ( rBeforeDataLayout )
                     {
                         OSL_ENSURE( nSubTotalCount < (sal_Int32)rDataNames.size(), "wrong data count" );
-                        String aSourceName( rDataNames[nSubTotalCount] );       // vector contains source names
-                        String aGivenName( rGivenNames[nSubTotalCount] );
+                        rtl::OUString aSourceName( rDataNames[nSubTotalCount] );       // vector contains source names
+                        rtl::OUString aGivenName( rGivenNames[nSubTotalCount] );
 
                         rResult[j] = lcl_IsNamedDataField( rTarget, aSourceName, aGivenName );
                     }
@@ -1784,7 +1785,7 @@ void lcl_StripSubTotals( std::vector< sal_Bool >& rResult, const std::vector< sa
         }
 }
 
-String lcl_GetDataFieldName( const String& rSourceName, sheet::GeneralFunction eFunc )
+rtl::OUString lcl_GetDataFieldName( const rtl::OUString& rSourceName, sheet::GeneralFunction eFunc )
 {
     sal_uInt16 nStrId = 0;
     switch ( eFunc )
@@ -1808,16 +1809,18 @@ String lcl_GetDataFieldName( const String& rSourceName, sheet::GeneralFunction e
         }
     }
     if ( !nStrId )
-        return String();
+        return rtl::OUString();
+
+    rtl::OUStringBuffer aRet( ScGlobal::GetRscString( nStrId ) );
+    aRet.appendAscii(RTL_CONSTASCII_STRINGPARAM(" - "));
+    aRet.append(rSourceName);
+    return aRet.makeStringAndClear();
+}
 
-    String aRet( ScGlobal::GetRscString( nStrId ) );
-    aRet.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
-    aRet.Append( rSourceName );
-    return aRet;
 }
 
-void ScDPOutput::GetDataDimensionNames( String& rSourceName, String& rGivenName,
-                                        const uno::Reference<uno::XInterface>& xDim )
+void ScDPOutput::GetDataDimensionNames(
+    rtl::OUString& rSourceName, rtl::OUString& rGivenName, const uno::Reference<uno::XInterface>& xDim )
 {
     uno::Reference<beans::XPropertySet> xDimProp( xDim, uno::UNO_QUERY );
     uno::Reference<container::XNamed> xDimName( xDim, uno::UNO_QUERY );
@@ -1825,8 +1828,7 @@ void ScDPOutput::GetDataDimensionNames( String& rSourceName, String& rGivenName,
     {
         // Asterisks are added in ScDPSaveData::WriteToSource to create unique names.
         //! preserve original name there?
-        rSourceName = xDimName->getName();
-        rSourceName.EraseTrailingChars( '*' );
+        rSourceName = ScDPUtil::getSourceDimensionName(xDimName->getName());
 
         // Generate "given name" the same way as in dptabres.
         //! Should use a stored name when available
@@ -1849,8 +1851,8 @@ sal_Bool ScDPOutput::GetPivotData( ScDPGetPivotDataField& rTarget,
     sal_Int32 nGrandTotalCols;
     sal_Int32 nGrandTotalRows;
     sal_Int32 nDataLayoutIndex;
-    std::vector<String> aDataNames;
-    std::vector<String> aGivenNames;
+    std::vector<rtl::OUString> aDataNames;
+    std::vector<rtl::OUString> aGivenNames;
     sheet::DataPilotFieldOrientation eDataOrient;
     lcl_GetTableVars( nGrandTotalCols, nGrandTotalRows, nDataLayoutIndex, aDataNames, aGivenNames, eDataOrient, xSource );
 
commit e7cd45417957fa1c57ca63fc6de2428647639f25
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Feb 24 21:21:29 2012 -0500

    File scope local method in anonymous namespace.

diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 37f0970..392b99a 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -1214,6 +1214,8 @@ bool ScDPOutput::GetHeaderLayout() const
     return mbHeaderLayout;
 }
 
+namespace {
+
 void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, sal_Int32& rDataLayoutIndex,
                              std::vector<String>& rDataNames, std::vector<String>& rGivenNames,
                              sheet::DataPilotFieldOrientation& rDataOrient,
@@ -1280,6 +1282,8 @@ void lcl_GetTableVars( sal_Int32& rGrandTotalCols, sal_Int32& rGrandTotalRows, s
     }
 }
 
+}
+
 void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionData& rPosData)
 {
     using namespace ::com::sun::star::sheet;


More information about the Libreoffice-commits mailing list