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

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Feb 27 20:48:37 PST 2012


 sc/inc/dputil.hxx                  |    3 +
 sc/source/core/data/dpsave.cxx     |    6 +--
 sc/source/filter/excel/xepivot.cxx |    7 ++--
 sc/source/filter/excel/xipivot.cxx |   62 ++++++++++++++++++-------------------
 4 files changed, 39 insertions(+), 39 deletions(-)

New commits:
commit 0c47d6c85b3845e8cf9782583ee17909c38dcca2
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Feb 27 23:43:20 2012 -0500

    Consolidate code that insert new dimensions.
    
    To make it easier to keep track of who inserts new dimensions.

diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index ec46604..15c377b 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -920,8 +920,7 @@ ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const ::rtl::OUString& rName
         return NULL;
 
     ScDPSaveDimension* pNew = new ScDPSaveDimension( *pOld );
-    CheckDuplicateName(*pNew);
-    aDimList.push_back(pNew);
+    AddDimension(pNew);
     return pNew;
 }
 
@@ -942,8 +941,7 @@ void ScDPSaveData::RemoveDimensionByName(const ::rtl::OUString& rName)
 ScDPSaveDimension& ScDPSaveData::DuplicateDimension( const ScDPSaveDimension& rDim )
 {
     ScDPSaveDimension* pNew = new ScDPSaveDimension( rDim );
-    CheckDuplicateName(*pNew);
-    aDimList.push_back(pNew);
+    AddDimension(pNew);
     return *pNew;
 }
 
commit de6b91f57b0c5621791bea7b7f24de5b7b40e666
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Feb 27 23:41:11 2012 -0500

    Correctly import ref type (aka display type) of data fields.

diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 7284ba1..0aff093 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1037,23 +1037,23 @@ void XclImpPTField::ConvertDataField( ScDPSaveData& rSaveData ) const
 {
     OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_DATA, "XclImpPTField::ConvertDataField - no data field" );
     OSL_ENSURE( !maDataInfoList.empty(), "XclImpPTField::ConvertDataField - no data field info" );
-    if( !maDataInfoList.empty() )
-    {
-        const String& rFieldName = GetFieldName();
-        if( rFieldName.Len() > 0 )
-        {
-            XclPTDataFieldInfoList::const_iterator aIt = maDataInfoList.begin(), aEnd = maDataInfoList.end();
+    if (maDataInfoList.empty())
+        return;
+
+    rtl::OUString aFieldName = GetFieldName();
+    if (aFieldName.isEmpty())
+        return;
 
-            ScDPSaveDimension& rSaveDim = *rSaveData.GetNewDimensionByName( rFieldName );
-            ConvertDataField( rSaveDim, *aIt );
+    XclPTDataFieldInfoList::const_iterator aIt = maDataInfoList.begin(), aEnd = maDataInfoList.end();
 
-            // multiple data fields -> clone dimension
-            for( ++aIt; aIt != aEnd; ++aIt )
-            {
-                ScDPSaveDimension& rDupDim = rSaveData.DuplicateDimension( rSaveDim );
-                ConvertDataFieldInfo( rDupDim, *aIt );
-            }
-        }
+    ScDPSaveDimension& rSaveDim = *rSaveData.GetNewDimensionByName(aFieldName);
+    ConvertDataField( rSaveDim, *aIt );
+
+    // multiple data fields -> clone dimension
+    for( ++aIt; aIt != aEnd; ++aIt )
+    {
+        ScDPSaveDimension& rDupDim = rSaveData.DuplicateDimension( rSaveDim );
+        ConvertDataFieldInfo( rDupDim, *aIt );
     }
 }
 
@@ -1163,31 +1163,31 @@ void XclImpPTField::ConvertDataField( ScDPSaveDimension& rSaveDim, const XclPTDa
 void XclImpPTField::ConvertDataFieldInfo( ScDPSaveDimension& rSaveDim, const XclPTDataFieldInfo& rDataInfo ) const
 {
     // visible name
-    if (const rtl::OUString* pVisName = rDataInfo.GetVisName())
-        if (!pVisName->isEmpty())
-            rSaveDim.SetLayoutName( *pVisName );
+    const rtl::OUString* pVisName = rDataInfo.GetVisName();
+    if (pVisName && !pVisName->isEmpty())
+        rSaveDim.SetLayoutName(*pVisName);
 
     // aggregation function
     rSaveDim.SetFunction( static_cast< sal_uInt16 >( rDataInfo.GetApiAggFunc() ) );
 
     // result field reference
     sal_Int32 nRefType = rDataInfo.GetApiRefType();
-    if( nRefType != ::com::sun::star::sheet::DataPilotFieldReferenceType::NONE )
+    DataPilotFieldReference aFieldRef;
+    aFieldRef.ReferenceType = nRefType;
+    const XclImpPTField* pRefField = mrPTable.GetField(rDataInfo.mnRefField);
+    if (pRefField)
     {
-        DataPilotFieldReference aFieldRef;
-        aFieldRef.ReferenceType = nRefType;
-
-        if( const XclImpPTField* pRefField = mrPTable.GetField( rDataInfo.mnRefField ) )
+        aFieldRef.ReferenceField = pRefField->GetFieldName();
+        aFieldRef.ReferenceItemType = rDataInfo.GetApiRefItemType();
+        if (aFieldRef.ReferenceItemType == sheet::DataPilotFieldReferenceItemType::NAMED)
         {
-            aFieldRef.ReferenceField = pRefField->GetFieldName();
-            aFieldRef.ReferenceItemType = rDataInfo.GetApiRefItemType();
-            if( aFieldRef.ReferenceItemType == ::com::sun::star::sheet::DataPilotFieldReferenceItemType::NAMED )
-                if (const rtl::OUString* pRefItemName = pRefField->GetItemName(rDataInfo.mnRefItem))
-                    aFieldRef.ReferenceItemName = *pRefItemName;
+            const rtl::OUString* pRefItemName = pRefField->GetItemName(rDataInfo.mnRefItem);
+            if (pRefItemName)
+                aFieldRef.ReferenceItemName = *pRefItemName;
         }
-
-        rSaveDim.SetReferenceValue( &aFieldRef );
     }
+
+    rSaveDim.SetReferenceValue(&aFieldRef);
 }
 
 void XclImpPTField::ConvertItems( ScDPSaveDimension& rSaveDim ) const
commit 5c699635cecc9877632de5f3dc07d1942c5b6416
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Feb 27 22:49:49 2012 -0500

    Import field as hidden field only when the axes type is 0.
    
    The old code would import data axis as hidden field too which makes
    no sense & generates unnecessary duplicate field for legitimate data
    field.

diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 4b51770..7284ba1 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1403,7 +1403,7 @@ void XclImpPivotTable::Convert()
     // hidden fields
     for( sal_uInt16 nField = 0, nCount = GetFieldCount(); nField < nCount; ++nField )
         if( const XclImpPTField* pField = GetField( nField ) )
-            if( (pField->GetAxes() & EXC_SXVD_AXIS_ROWCOLPAGE) == 0 )
+            if (!pField->GetAxes())
                 pField->ConvertHiddenField( aSaveData );
 
     // data fields
commit df0aab7f66ba227eda91a8a3568665036556bac0
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Feb 27 17:14:56 2012 -0500

    Fix exporting pivot tables to xls esp wrt exporting duplicate data fields.

diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx
index 46ffa6b..cf574c1 100644
--- a/sc/inc/dputil.hxx
+++ b/sc/inc/dputil.hxx
@@ -30,13 +30,14 @@
 #define __SC_DPUTIL_HXX__
 
 #include "rtl/ustring.hxx"
+#include "scdllapi.h"
 
 class ScDPUtil
 {
 public:
     static bool isDuplicateDimension(const rtl::OUString& rName);
 
-    static rtl::OUString getSourceDimensionName(const rtl::OUString& rName);
+    SC_DLLPUBLIC static rtl::OUString getSourceDimensionName(const rtl::OUString& rName);
 
     static rtl::OUString createDuplicateDimensionName(const rtl::OUString& rOriginal, size_t nDupCount);
 };
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 60e2166..e1a9ad1 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -49,6 +49,7 @@
 #include "fapihelper.hxx"
 #include "xestring.hxx"
 #include "xelink.hxx"
+#include "dputil.hxx"
 
 using namespace ::oox;
 
@@ -1294,7 +1295,7 @@ XclExpPivotTable::XclExpPivotTable( const XclExpRoot& rRoot, const ScDPObject& r
                 maFieldList.AppendNewRecord( new XclExpPTField( *this, nFieldIdx ) );
 
             boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
-            const boost::ptr_vector<ScDPSaveDimension>& rDimList = pSaveData->GetDimensions();
+            const ScDPSaveData::DimsType& rDimList = pSaveData->GetDimensions();
 
             /*  2)  First process all data dimensions, they are needed for extended
                     settings of row/column/page fields (sorting/auto show). */
@@ -1524,8 +1525,8 @@ XclExpPTField* XclExpPivotTable::GetFieldAcc( const ScDPSaveDimension& rSaveDim
         return &maDataOrientField;
 
     // a real dimension
-    String aFieldName( rSaveDim.GetName() );
-    return aFieldName.Len() ? GetFieldAcc( aFieldName ) : 0;
+    rtl::OUString aFieldName = ScDPUtil::getSourceDimensionName(rSaveDim.GetName());
+    return aFieldName.isEmpty() ? NULL : GetFieldAcc(aFieldName);
 }
 
 // fill data --------------------------------------------------------------


More information about the Libreoffice-commits mailing list