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

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Feb 14 14:18:57 PST 2012


 sc/inc/dpoutput.hxx                      |    5 -
 sc/inc/dpoutputgeometry.hxx              |   12 --
 sc/inc/dpsave.hxx                        |   25 ++++-
 sc/source/core/data/dpoutput.cxx         |   51 +++++------
 sc/source/core/data/dpoutputgeometry.cxx |   35 ++++---
 sc/source/core/data/dpsave.cxx           |   30 +++++-
 sc/source/filter/excel/xepivot.cxx       |   33 +++----
 sc/source/filter/excel/xipivot.cxx       |  139 ++++++++++++++-----------------
 sc/source/filter/excel/xlpivot.cxx       |   26 ++---
 sc/source/filter/inc/xepivot.hxx         |   22 ++--
 sc/source/filter/inc/xipivot.hxx         |   12 +-
 sc/source/filter/inc/xlpivot.hxx         |   31 +++---
 sc/source/filter/xml/xmldpimp.cxx        |  118 +++++++++++++++-----------
 sc/source/filter/xml/xmldpimp.hxx        |   33 ++-----
 sc/source/filter/xml/xmlfilti.cxx        |    9 --
 sc/source/filter/xml/xmlfilti.hxx        |   16 +--
 sc/source/ui/dbgui/pvlaydlg.cxx          |   21 ++++
 17 files changed, 328 insertions(+), 290 deletions(-)

New commits:
commit 3290664dd1d26f2f6bf4d99afdd1f6bccbccb7dd
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 17:16:58 2012 -0500

    String to rtl::OUString in the xls pivot table import code.

diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index afe46d8..60e2166 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -147,9 +147,9 @@ XclExpPCItem::XclExpPCItem( bool bValue ) :
 
 // ----------------------------------------------------------------------------
 
-bool XclExpPCItem::EqualsText( const String& rText ) const
+bool XclExpPCItem::EqualsText( const rtl::OUString& rText ) const
 {
-    return (rText.Len() == 0) ? IsEmpty() : (GetText() && (*GetText() == rText));
+    return rText.isEmpty() ? IsEmpty() : (GetText() && (*GetText() == rText));
 }
 
 bool XclExpPCItem::EqualsDouble( double fValue ) const
@@ -171,7 +171,7 @@ bool XclExpPCItem::EqualsBool( bool bValue ) const
 
 void XclExpPCItem::WriteBody( XclExpStream& rStrm )
 {
-    if( const String* pText = GetText() )
+    if( const rtl::OUString* pText = GetText() )
     {
         rStrm << XclExpString( *pText );
     }
@@ -291,7 +291,7 @@ const XclExpPCItem* XclExpPCField::GetItem( sal_uInt16 nItemIdx ) const
     return GetVisItemList().GetRecord( nItemIdx ).get();
 }
 
-sal_uInt16 XclExpPCField::GetItemIndex( const String& rItemName ) const
+sal_uInt16 XclExpPCField::GetItemIndex( const rtl::OUString& rItemName ) const
 {
     const XclExpPCItemList& rItemList = GetVisItemList();
     for( size_t nPos = 0, nSize = rItemList.GetSize(); nPos < nSize; ++nPos )
@@ -356,7 +356,8 @@ void XclExpPCField::InitStandardField( const ScRange& rRange )
     ScAddress aPos( rRange.aStart );
     rDoc.GetString( aPos.Col(), aPos.Row(), aPos.Tab(), maFieldInfo.maName );
     // #i76047# maximum field name length in pivot cache is 255
-    maFieldInfo.maName.Erase( ::std::min( maFieldInfo.maName.Len(), EXC_PC_MAXSTRLEN ) );
+    if (maFieldInfo.maName.getLength() > EXC_PC_MAXSTRLEN)
+        maFieldInfo.maName = maFieldInfo.maName.copy(0, EXC_PC_MAXSTRLEN);
 
     // loop over all cells, create pivot cache items
     for( aPos.IncRow(); (aPos.Row() <= rRange.aEnd.Row()) && (maOrigItemList.GetSize() < EXC_PC_MAXITEMCOUNT); aPos.IncRow() )
@@ -778,7 +779,7 @@ XclExpPCField* XclExpPivotCache::GetFieldAcc( sal_uInt16 nFieldIdx )
     return maFieldList.GetRecord( nFieldIdx ).get();
 }
 
-XclExpPCField* XclExpPivotCache::GetFieldAcc( const String& rFieldName )
+XclExpPCField* XclExpPivotCache::GetFieldAcc( const rtl::OUString& rFieldName )
 {
     XclExpPCField* pField = 0;
     for( size_t nPos = 0, nSize = maFieldList.GetSize(); !pField && (nPos < nSize); ++nPos )
@@ -984,9 +985,9 @@ XclExpPTItem::XclExpPTItem( sal_uInt16 nItemType, sal_uInt16 nCacheIdx, bool bUs
     maItemInfo.maVisName.mbUseCache = bUseCache;
 }
 
-const String& XclExpPTItem::GetItemName() const
+rtl::OUString XclExpPTItem::GetItemName() const
 {
-    return mpCacheItem ? mpCacheItem->ConvertToText() : EMPTY_STRING;
+    return mpCacheItem ? mpCacheItem->ConvertToText() : rtl::OUString();
 }
 
 void XclExpPTItem::SetPropertiesFromMember( const ScDPSaveMember& rSaveMem )
@@ -1024,9 +1025,9 @@ XclExpPTField::XclExpPTField( const XclExpPivotTable& rPTable, sal_uInt16 nCache
 
 // data access ----------------------------------------------------------------
 
-const String& XclExpPTField::GetFieldName() const
+rtl::OUString XclExpPTField::GetFieldName() const
 {
-    return mpCacheField ? mpCacheField->GetFieldName() : EMPTY_STRING;
+    return mpCacheField ? mpCacheField->GetFieldName() : rtl::OUString();
 }
 
 sal_uInt16 XclExpPTField::GetFieldIndex() const
@@ -1042,7 +1043,7 @@ sal_uInt16 XclExpPTField::GetLastDataInfoIndex() const
     return static_cast< sal_uInt16 >( maDataInfoVec.size() - 1 );
 }
 
-sal_uInt16 XclExpPTField::GetItemIndex( const String& rName, sal_uInt16 nDefaultIdx ) const
+sal_uInt16 XclExpPTField::GetItemIndex( const rtl::OUString& rName, sal_uInt16 nDefaultIdx ) const
 {
     for( size_t nPos = 0, nSize = maItemList.GetSize(); nPos < nSize; ++nPos )
         if( maItemList.GetRecord( nPos )->GetItemName() == rName )
@@ -1230,7 +1231,7 @@ void XclExpPTField::Save( XclExpStream& rStrm )
 
 // private --------------------------------------------------------------------
 
-XclExpPTItem* XclExpPTField::GetItemAcc( const String& rName )
+XclExpPTItem* XclExpPTField::GetItemAcc( const rtl::OUString& rName )
 {
     XclExpPTItem* pItem = 0;
     for( size_t nPos = 0, nSize = maItemList.GetSize(); !pItem && (nPos < nSize); ++nPos )
@@ -1324,12 +1325,12 @@ const XclExpPTField* XclExpPivotTable::GetField( sal_uInt16 nFieldIdx ) const
     return (nFieldIdx == EXC_SXIVD_DATA) ? &maDataOrientField : maFieldList.GetRecord( nFieldIdx ).get();
 }
 
-const XclExpPTField* XclExpPivotTable::GetField( const String& rName ) const
+const XclExpPTField* XclExpPivotTable::GetField( const rtl::OUString& rName ) const
 {
     return const_cast< XclExpPivotTable* >( this )->GetFieldAcc( rName );
 }
 
-sal_uInt16 XclExpPivotTable::GetDataFieldIndex( const String& rName, sal_uInt16 nDefaultIdx ) const
+sal_uInt16 XclExpPivotTable::GetDataFieldIndex( const rtl::OUString& rName, sal_uInt16 nDefaultIdx ) const
 {
     for( XclPTDataFieldPosVec::const_iterator aIt = maDataFields.begin(), aEnd = maDataFields.end(); aIt != aEnd; ++aIt )
         if( const XclExpPTField* pField = GetField( aIt->first ) )
@@ -1507,7 +1508,7 @@ void XclExpPivotTable::SaveXml( XclExpXmlStream& rStrm )
 
 // private --------------------------------------------------------------------
 
-XclExpPTField* XclExpPivotTable::GetFieldAcc( const String& rName )
+XclExpPTField* XclExpPivotTable::GetFieldAcc( const rtl::OUString& rName )
 {
     XclExpPTField* pField = 0;
     for( size_t nPos = 0, nSize = maFieldList.GetSize(); !pField && (nPos < nSize); ++nPos )
@@ -1672,7 +1673,7 @@ void XclExpPivotTable::Finalize()
 
 void XclExpPivotTable::WriteSxview( XclExpStream& rStrm ) const
 {
-    rStrm.StartRecord( EXC_ID_SXVIEW, 46 + maPTInfo.maTableName.Len() + maPTInfo.maDataName.Len() );
+    rStrm.StartRecord( EXC_ID_SXVIEW, 46 + maPTInfo.maTableName.getLength() + maPTInfo.maDataName.getLength() );
     rStrm << maPTInfo;
     rStrm.EndRecord();
 }
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 8946581..4b51770 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -106,7 +106,7 @@ void lclSetValue( const XclImpRoot& rRoot, const ScAddress& rScPos, double fValu
 void XclImpPCItem::WriteToSource( const XclImpRoot& rRoot, const ScAddress& rScPos ) const
 {
     ScDocument& rDoc = rRoot.GetDoc();
-    if( const String* pText = GetText() )
+    if( const rtl::OUString* pText = GetText() )
         rDoc.SetString( rScPos.Col(), rScPos.Row(), rScPos.Tab(), *pText );
     else if( const double* pfValue = GetDouble() )
         rDoc.SetValue( rScPos.Col(), rScPos.Row(), rScPos.Tab(), *pfValue );
@@ -199,12 +199,12 @@ XclImpPCField::~XclImpPCField()
 
 // general field/item access --------------------------------------------------
 
-const String& XclImpPCField::GetFieldName( const ScfStringVec& rVisNames ) const
+const rtl::OUString& XclImpPCField::GetFieldName( const ScfStringVec& rVisNames ) const
 {
     if( IsGroupChildField() && (mnFieldIdx < rVisNames.size()) )
     {
-        const String& rVisName = rVisNames[ mnFieldIdx ];
-        if( rVisName.Len() > 0 )
+        const rtl::OUString& rVisName = rVisNames[ mnFieldIdx ];
+        if (!rVisName.isEmpty())
             return rVisName;
     }
     return maFieldInfo.maName;
@@ -398,7 +398,7 @@ void XclImpPCField::ReadSxgroupinfo( XclImpStream& rStrm )
 
 void XclImpPCField::ConvertGroupField( ScDPSaveData& rSaveData, const ScfStringVec& rVisNames ) const
 {
-    if( GetFieldName( rVisNames ).Len() > 0 )
+    if (!GetFieldName(rVisNames).isEmpty())
     {
         if( IsStdGroupField() )
             ConvertStdGroupField( rSaveData, rVisNames );
@@ -898,12 +898,12 @@ XclImpPTItem::XclImpPTItem( const XclImpPCField* pCacheField ) :
 {
 }
 
-const String* XclImpPTItem::GetItemName() const
+const rtl::OUString* XclImpPTItem::GetItemName() const
 {
     if( mpCacheField )
         if( const XclImpPCItem* pCacheItem = mpCacheField->GetItem( maItemInfo.mnCacheIdx ) )
             //! TODO: use XclImpPCItem::ConvertToText(), if all conversions are available
-            return pCacheItem->IsEmpty() ? &String::EmptyString() : pCacheItem->GetText();
+            return pCacheItem->IsEmpty() ? NULL : pCacheItem->GetText();
     return 0;
 }
 
@@ -914,7 +914,7 @@ void XclImpPTItem::ReadSxvi( XclImpStream& rStrm )
 
 void XclImpPTItem::ConvertItem( ScDPSaveDimension& rSaveDim ) const
 {
-    if( const String* pItemName = GetItemName() )
+    if (const rtl::OUString* pItemName = GetItemName())
     {
         ScDPSaveMember& rMember = *rSaveDim.GetMemberByName( *pItemName );
         rMember.SetIsVisible( !::get_flag( maItemInfo.mnFlags, EXC_SXVI_HIDDEN ) );
@@ -940,16 +940,16 @@ const XclImpPCField* XclImpPTField::GetCacheField() const
     return xPCache ? xPCache->GetField( maFieldInfo.mnCacheIdx ) : 0;
 }
 
-const String& XclImpPTField::GetFieldName() const
+rtl::OUString XclImpPTField::GetFieldName() const
 {
     const XclImpPCField* pField = GetCacheField();
-    return pField ? pField->GetFieldName( mrPTable.GetVisFieldNames() ) : String::EmptyString();
+    return pField ? pField->GetFieldName( mrPTable.GetVisFieldNames() ) : rtl::OUString();
 }
 
-const String& XclImpPTField::GetVisFieldName() const
+rtl::OUString XclImpPTField::GetVisFieldName() const
 {
-    const String* pVisName = maFieldInfo.GetVisName();
-    return pVisName ? *pVisName : String::EmptyString();
+    const rtl::OUString* pVisName = maFieldInfo.GetVisName();
+    return pVisName ? *pVisName : rtl::OUString();
 }
 
 const XclImpPTItem* XclImpPTField::GetItem( sal_uInt16 nItemIdx ) const
@@ -957,7 +957,7 @@ const XclImpPTItem* XclImpPTField::GetItem( sal_uInt16 nItemIdx ) const
     return (nItemIdx < maItems.size()) ? maItems[ nItemIdx ].get() : 0;
 }
 
-const String* XclImpPTField::GetItemName( sal_uInt16 nItemIdx ) const
+const rtl::OUString* XclImpPTField::GetItemName( sal_uInt16 nItemIdx ) const
 {
     const XclImpPTItem* pItem = GetItem( nItemIdx );
     return pItem ? pItem->GetItemName() : 0;
@@ -1006,12 +1006,9 @@ void XclImpPTField::ConvertPageField( ScDPSaveData& rSaveData ) const
     OSL_ENSURE( maFieldInfo.mnAxes & EXC_SXVD_AXIS_PAGE, "XclImpPTField::ConvertPageField - no page field" );
     if( ScDPSaveDimension* pSaveDim = ConvertRCPField( rSaveData ) )
     {
-        const String* pName = GetItemName( maPageInfo.mnSelItem );
+        const rtl::OUString* pName = GetItemName( maPageInfo.mnSelItem );
         if (pName)
-        {
-            const OUString aName(*pName);
-            pSaveDim->SetCurrentPage(&aName);
-        }
+            pSaveDim->SetCurrentPage(pName);
     }
 }
 
@@ -1103,8 +1100,8 @@ ScDPSaveDimension* XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) con
     ConvertFieldInfo( rSaveDim );
 
     // visible name
-    if( const String* pVisName = maFieldInfo.GetVisName() )
-        if( pVisName->Len() > 0 )
+    if (const rtl::OUString* pVisName = maFieldInfo.GetVisName())
+        if (!pVisName->isEmpty())
             rSaveDim.SetLayoutName( *pVisName );
 
     // subtotal function(s)
@@ -1166,8 +1163,8 @@ void XclImpPTField::ConvertDataField( ScDPSaveDimension& rSaveDim, const XclPTDa
 void XclImpPTField::ConvertDataFieldInfo( ScDPSaveDimension& rSaveDim, const XclPTDataFieldInfo& rDataInfo ) const
 {
     // visible name
-    if( const String* pVisName = rDataInfo.GetVisName() )
-        if( pVisName->Len() > 0 )
+    if (const rtl::OUString* pVisName = rDataInfo.GetVisName())
+        if (!pVisName->isEmpty())
             rSaveDim.SetLayoutName( *pVisName );
 
     // aggregation function
@@ -1185,7 +1182,7 @@ void XclImpPTField::ConvertDataFieldInfo( ScDPSaveDimension& rSaveDim, const Xcl
             aFieldRef.ReferenceField = pRefField->GetFieldName();
             aFieldRef.ReferenceItemType = rDataInfo.GetApiRefItemType();
             if( aFieldRef.ReferenceItemType == ::com::sun::star::sheet::DataPilotFieldReferenceItemType::NAMED )
-                if( const String* pRefItemName = pRefField->GetItemName( rDataInfo.mnRefItem ) )
+                if (const rtl::OUString* pRefItemName = pRefField->GetItemName(rDataInfo.mnRefItem))
                     aFieldRef.ReferenceItemName = *pRefItemName;
         }
 
@@ -1238,11 +1235,11 @@ const XclImpPTField* XclImpPivotTable::GetDataField( sal_uInt16 nDataFieldIdx )
     return 0;
 }
 
-const String& XclImpPivotTable::GetDataFieldName( sal_uInt16 nDataFieldIdx ) const
+rtl::OUString XclImpPivotTable::GetDataFieldName( sal_uInt16 nDataFieldIdx ) const
 {
     if( const XclImpPTField* pField = GetDataField( nDataFieldIdx ) )
         return pField->GetFieldName();
-    return EMPTY_STRING;
+    return rtl::OUString();
 }
 
 // records --------------------------------------------------------------------
@@ -1437,10 +1434,10 @@ void XclImpPivotTable::Convert()
     // create the DataPilot
     ScDPObject* pDPObj = new ScDPObject( GetDocPtr() );
     pDPObj->SetName( maPTInfo.maTableName );
-    if (maPTInfo.maDataName.Len() > 0)
+    if (!maPTInfo.maDataName.isEmpty())
         aSaveData.GetDataLayoutDimension()->SetLayoutName(maPTInfo.maDataName);
 
-    if (maPTViewEx9Info.maGrandTotalName.Len() > 0)
+    if (!maPTViewEx9Info.maGrandTotalName.isEmpty())
         aSaveData.SetGrandTotalName(maPTViewEx9Info.maGrandTotalName);
 
     pDPObj->SetSaveData( aSaveData );
diff --git a/sc/source/filter/excel/xlpivot.cxx b/sc/source/filter/excel/xlpivot.cxx
index 5d2c4fe..854c580 100644
--- a/sc/source/filter/excel/xlpivot.cxx
+++ b/sc/source/filter/excel/xlpivot.cxx
@@ -60,10 +60,10 @@ XclPCItem::~XclPCItem()
 void XclPCItem::SetEmpty()
 {
     meType = EXC_PCITEM_EMPTY;
-    maText.Erase();
+    maText = rtl::OUString();
 }
 
-void XclPCItem::SetText( const String& rText )
+void XclPCItem::SetText( const rtl::OUString& rText )
 {
     meType = EXC_PCITEM_TEXT;
     maText = rText;
@@ -73,7 +73,7 @@ void XclPCItem::SetDouble( double fValue )
 {
     meType = EXC_PCITEM_DOUBLE;
     //! TODO convert double to string
-    maText.Erase();
+    maText = rtl::OUString();
     mfValue = fValue;
 }
 
@@ -81,14 +81,14 @@ void XclPCItem::SetDateTime( const DateTime& rDateTime )
 {
     meType = EXC_PCITEM_DATETIME;
     //! TODO convert date to string
-    maText.Erase();
+    maText = rtl::OUString();
     maDateTime = rDateTime;
 }
 
 void XclPCItem::SetInteger( sal_Int16 nValue )
 {
     meType = EXC_PCITEM_INTEGER;
-    maText = String::CreateFromInt32( nValue );
+    maText = rtl::OUString::valueOf(static_cast<sal_Int32>(nValue));
     mnValue = nValue;
 }
 
@@ -96,7 +96,7 @@ void XclPCItem::SetError( sal_uInt16 nError )
 {
     meType = EXC_PCITEM_ERROR;
     //! TODO convert error to string
-    maText.Erase();
+    maText = rtl::OUString();
     mnError = nError;
 }
 
@@ -104,7 +104,7 @@ void XclPCItem::SetBool( bool bValue )
 {
     meType = EXC_PCITEM_BOOL;
     //! TODO convert boolean to string
-    maText.Erase();
+    maText = rtl::OUString();
     mbValue = bValue;
 }
 
@@ -132,7 +132,7 @@ bool XclPCItem::IsEmpty() const
     return meType == EXC_PCITEM_EMPTY;
 }
 
-const String* XclPCItem::GetText() const
+const rtl::OUString* XclPCItem::GetText() const
 {
     return (meType == EXC_PCITEM_TEXT) ? &maText : 0;
 }
@@ -187,7 +187,7 @@ XclImpStream& operator>>( XclImpStream& rStrm, XclPCFieldInfo& rInfo )
     if( rStrm.GetRecLeft() >= 3 )
         rInfo.maName = rStrm.ReadUniString();
     else
-        rInfo.maName.Erase();
+        rInfo.maName = rtl::OUString();
     return rStrm;
 }
 
@@ -402,7 +402,7 @@ XclImpStream& operator>>( XclImpStream& rStrm, XclPTCachedName& rCachedName )
     rStrm >> nStrLen;
     rCachedName.mbUseCache = nStrLen == EXC_PT_NOSTRING;
     if( rCachedName.mbUseCache )
-        rCachedName.maName.Erase();
+        rCachedName.maName = rtl::OUString();
     else
         rCachedName.maName = rStrm.ReadUniString( nStrLen );
     return rStrm;
@@ -419,15 +419,15 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTCachedName& rCachedNam
 
 // ----------------------------------------------------------------------------
 
-const String* XclPTVisNameInfo::GetVisName() const
+const rtl::OUString* XclPTVisNameInfo::GetVisName() const
 {
     return HasVisName() ? &maVisName.maName : 0;
 }
 
-void XclPTVisNameInfo::SetVisName( const String& rName )
+void XclPTVisNameInfo::SetVisName( const rtl::OUString& rName )
 {
     maVisName.maName = rName;
-    maVisName.mbUseCache = rName.Len() == 0;
+    maVisName.mbUseCache = rName.isEmpty();
 }
 
 // Field item settings ========================================================
diff --git a/sc/source/filter/inc/xepivot.hxx b/sc/source/filter/inc/xepivot.hxx
index b25609a..a3472bc 100644
--- a/sc/source/filter/inc/xepivot.hxx
+++ b/sc/source/filter/inc/xepivot.hxx
@@ -59,7 +59,7 @@ public:
 
     inline sal_uInt16   GetTypeFlag() const { return mnTypeFlag; }
 
-    bool                EqualsText( const String& rText ) const;
+    bool                EqualsText( const rtl::OUString& rText ) const;
     bool                EqualsDouble( double fValue ) const;
     bool                EqualsDateTime( const DateTime& rDateTime ) const;
     bool                EqualsBool( bool bValue ) const;
@@ -95,14 +95,14 @@ public:
     void                ConvertToNumGroup( const ScDPObject& rDPObj, const ScDPSaveNumGroupDimension& rNumGroupDim );
 
     /** Returns the name of this cache field. */
-    inline const String& GetFieldName() const { return maFieldInfo.maName; }
+    inline const rtl::OUString& GetFieldName() const { return maFieldInfo.maName; }
 
     /** Returns the number of visible items of this field. */
     sal_uInt16          GetItemCount() const;
     /** Returns the specified pivot cache item (returns visible items in groupings). */
     const XclExpPCItem* GetItem( sal_uInt16 nItemIdx ) const;
     /** Returns the index of a pivot cache item, or EXC_PC_NOITEM on error. */
-    sal_uInt16          GetItemIndex( const String& rItemName ) const;
+    sal_uInt16          GetItemIndex( const rtl::OUString& rItemName ) const;
 
     /** Returns the size an item index needs to write out. */
     sal_Size            GetIndexSize() const;
@@ -210,7 +210,7 @@ private:
     /** Returns read/write access to a pivot cache field. */
     XclExpPCField*      GetFieldAcc( sal_uInt16 nFieldIdx );
     /** Returns read/write access to a pivot cache field. */
-    XclExpPCField*      GetFieldAcc( const String& rFieldName );
+    XclExpPCField*      GetFieldAcc( const rtl::OUString& rFieldName );
 
     /** Adds all pivot cache fields. */
     void                AddFields( const ScDPObject& rDPObj );
@@ -269,7 +269,7 @@ public:
     explicit            XclExpPTItem( sal_uInt16 nItemType, sal_uInt16 nCacheIdx, bool bUseCache );
 
     /** Returns the internal name of this item. */
-    const String&       GetItemName() const;
+    rtl::OUString       GetItemName() const;
 
     /** Fills this item with properties from the passed save member. */
     void                SetPropertiesFromMember( const ScDPSaveMember& rSaveMem );
@@ -293,7 +293,7 @@ public:
     // data access ------------------------------------------------------------
 
     /** Returns the name of this field. */
-    const String&       GetFieldName() const;
+    rtl::OUString       GetFieldName() const;
     /** Returns the pivot table field list index of this field. */
     sal_uInt16          GetFieldIndex() const;
 
@@ -302,7 +302,7 @@ public:
 
     /** Returns the list index of an item by its name.
         @param nDefaultIdx  This value will be returned, if the item could not be found. */
-    sal_uInt16          GetItemIndex( const String& rName, sal_uInt16 nDefaultIdx ) const;
+    sal_uInt16          GetItemIndex( const rtl::OUString& rName, sal_uInt16 nDefaultIdx ) const;
 
     // fill data --------------------------------------------------------------
 
@@ -327,7 +327,7 @@ public:
     // ------------------------------------------------------------------------
 private:
     /** Returns an item by its name. */
-    XclExpPTItem*       GetItemAcc( const String& rName );
+    XclExpPTItem*       GetItemAcc( const rtl::OUString& rName );
 
     /** Appends a special item describing a field subtotal entry. */
     void                AppendSubtotalItem( sal_uInt16 nItemType );
@@ -367,11 +367,11 @@ public:
     /** Returns a pivot table field by its name. */
     const XclExpPTField* GetField( sal_uInt16 nFieldIdx ) const;
     /** Returns a pivot table field by its name. */
-    const XclExpPTField* GetField( const String& rName ) const;
+    const XclExpPTField* GetField( const rtl::OUString& rName ) const;
 
     /** Returns the data-field-only index of the first data field with the passed name.
         @param nDefaultIdx  This value will be returned, if the field could not be found. */
-    sal_uInt16          GetDataFieldIndex( const String& rName, sal_uInt16 nDefaultIdx ) const;
+    sal_uInt16          GetDataFieldIndex( const rtl::OUString& rName, sal_uInt16 nDefaultIdx ) const;
 
     /** Writes the entire pivot table. */
     virtual void        Save( XclExpStream& rStrm );
@@ -380,7 +380,7 @@ public:
     // ------------------------------------------------------------------------
 private:
     /** Returns a pivot table field by its name. */
-    XclExpPTField*      GetFieldAcc( const String& rName );
+    XclExpPTField*      GetFieldAcc( const rtl::OUString& rName );
     /** Returns a pivot table field corresponding to the passed save dimension. */
     XclExpPTField*      GetFieldAcc( const ScDPSaveDimension& rSaveDim );
 
diff --git a/sc/source/filter/inc/xipivot.hxx b/sc/source/filter/inc/xipivot.hxx
index ee5d03b..edbe193 100644
--- a/sc/source/filter/inc/xipivot.hxx
+++ b/sc/source/filter/inc/xipivot.hxx
@@ -86,7 +86,7 @@ public:
     // general field/item access ----------------------------------------------
 
     /** Returns the name of the field, uses the passed visible name if supported. */
-    const String&       GetFieldName( const ScfStringVec& rVisNames ) const;
+    const rtl::OUString& GetFieldName( const ScfStringVec& rVisNames ) const;
 
     /** Returns the base field if this is a grouping field. */
     const XclImpPCField* GetGroupBaseField() const;
@@ -224,7 +224,7 @@ public:
     explicit            XclImpPTItem( const XclImpPCField* pCacheField );
 
     /** Returns the internal name of the item or 0, if no name could be found. */
-    const String*       GetItemName() const;
+    const rtl::OUString* GetItemName() const;
 
     /** Reads an SXVI record containing data of this item. */
     void                ReadSxvi( XclImpStream& rStrm );
@@ -251,14 +251,14 @@ public:
     /** Returns the corresponding pivot cache field of this field. */
     const XclImpPCField* GetCacheField() const;
     /** Returns the name of this field that is used to create the Calc dimensions. */
-    const String&       GetFieldName() const;
+    rtl::OUString        GetFieldName() const;
     /** Returns the internally set visible name of this field. */
-    const String&       GetVisFieldName() const;
+    rtl::OUString        GetVisFieldName() const;
 
     /** Returns the specified item. */
     const XclImpPTItem* GetItem( sal_uInt16 nItemIdx ) const;
     /** Returns the internal name of the specified item. */
-    const String*       GetItemName( sal_uInt16 nItemIdx ) const;
+    const rtl::OUString* GetItemName( sal_uInt16 nItemIdx ) const;
 
     /** Returns the flags of the axes this field is part of. */
     inline sal_uInt16   GetAxes() const { return maFieldInfo.mnAxes; }
@@ -335,7 +335,7 @@ public:
     const String&       GetFieldName( sal_uInt16 nFieldIdx ) const;
 
     const XclImpPTField* GetDataField( sal_uInt16 nDataFieldIdx ) const;
-    const String&       GetDataFieldName( sal_uInt16 nDataFieldIdx ) const;
+    rtl::OUString GetDataFieldName( sal_uInt16 nDataFieldIdx ) const;
 
     // records ----------------------------------------------------------------
 
diff --git a/sc/source/filter/inc/xlpivot.hxx b/sc/source/filter/inc/xlpivot.hxx
index bed377d..1a88868 100644
--- a/sc/source/filter/inc/xlpivot.hxx
+++ b/sc/source/filter/inc/xlpivot.hxx
@@ -387,7 +387,7 @@ public:
     /** Sets the item to 'empty' type. */
     void                SetEmpty();
     /** Sets the item to 'text' type and adds the passed text. */
-    void                SetText( const String& rText );
+    void                SetText( const rtl::OUString& rText );
     /** Sets the item to 'double' type and adds the passed value. */
     void                SetDouble( double fValue );
     /** Sets the item to 'date/time' type and adds the passed date. */
@@ -402,7 +402,7 @@ public:
     /** Returns the current item type. */
     inline XclPCItemType GetType() const { return meType; }
     /** Returns the text representation of the item. */
-    inline const String& ConvertToText() const { return maText; }
+    inline const rtl::OUString& ConvertToText() const { return maText; }
 
     /** Returns true, if the passed iterm equals this item. */
     bool                IsEqual( const XclPCItem& rItem ) const;
@@ -410,7 +410,7 @@ public:
     /** Returns true, if the item type is 'empty'. */
     bool                IsEmpty() const;
     /** Returns pointer to text, if the item type is 'text', otherwise 0. */
-    const String*       GetText() const;
+    const rtl::OUString* GetText() const;
     /** Returns pointer to value, if the item type is 'double', otherwise 0. */
     const double*       GetDouble() const;
     /** Returns pointer to date, if the item type is 'date/time', otherwise 0. */
@@ -424,7 +424,7 @@ public:
 
 private:
     XclPCItemType       meType;         /// Type of the item.
-    String              maText;         /// Text representation of the item.
+    rtl::OUString       maText;         /// Text representation of the item.
     DateTime            maDateTime;     /// Value of a date/time item.
     union
     {
@@ -443,7 +443,7 @@ inline bool operator!=( const XclPCItem& rLeft, const XclPCItem& rRight ) { retu
 /** Contains data for a pivot cache field (SXFIELD record). */
 struct XclPCFieldInfo
 {
-    String              maName;         /// Name of the pivot cache field.
+    rtl::OUString       maName;         /// Name of the pivot cache field.
     sal_uInt16          mnFlags;        /// Various flags.
     sal_uInt16          mnGroupChild;   /// Field containing grouping info for this field.
     sal_uInt16          mnGroupBase;    /// Base field if this field contains grouping info.
@@ -542,7 +542,7 @@ struct XclPCInfo
     sal_uInt16          mnStdFields;    /// Number of standard pivot cache fields.
     sal_uInt16          mnTotalFields;  /// Number of all fields (standard, grouped, calculated).
     sal_uInt16          mnSrcType;      /// Database type.
-    String              maUserName;     /// Name of user who last modified the cache.
+    rtl::OUString       maUserName;     /// Name of user who last modified the cache.
 
     explicit            XclPCInfo();
 };
@@ -559,7 +559,7 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPCInfo& rInfo );
 /** A name for various pivot table info structs. Includes 'use cache' state. */
 struct XclPTCachedName
 {
-    String              maName;         /// The visible name, if used.
+    rtl::OUString       maName;         /// The visible name, if used.
     bool                mbUseCache;     /// true = Use name in cache instead of maName.
 
     inline explicit     XclPTCachedName() : mbUseCache( true ) {}
@@ -578,9 +578,9 @@ struct XclPTVisNameInfo
     /** Returns true, if the name is set explicitly (maVisName.mbUseCache is false). */
     inline bool         HasVisName() const { return !maVisName.mbUseCache; }
     /** Returns the name, if set explicitly (maVisName.mbUseCache is false). */
-    const String*       GetVisName() const;
+    const rtl::OUString* GetVisName() const;
     /** Sets the visible name and enables usage of cache if name is empty. */
-    void                SetVisName( const String& rName );
+    void                SetVisName( const rtl::OUString& rName );
 };
 
 // Field item settings ========================================================
@@ -719,8 +719,8 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTDataFieldInfo& rInfo )
 /** Contains data for a pivot table (SXVIEW record). */
 struct XclPTInfo
 {
-    String              maTableName;        /// The name of the pivot table.
-    String              maDataName;         /// The visible name of the data field.
+    rtl::OUString       maTableName;        /// The name of the pivot table.
+    rtl::OUString       maDataName;         /// The visible name of the data field.
     XclRange            maOutXclRange;      /// Output range.
     XclAddress          maDataXclPos;       /// First cell containing data.
     sal_uInt16          mnFirstHeadRow;     /// First heading row.
@@ -770,7 +770,7 @@ struct XclPTViewEx9Info
     sal_uInt32          mbReport;           /// 2 for report* fmts ?
     sal_uInt8           mnAutoFormat;       /// AutoFormat ID
     sal_uInt8           mnGridLayout;       /// 0 == gridlayout, 0x10 == modern
-    String              maGrandTotalName;
+    rtl::OUString       maGrandTotalName;
 
     explicit            XclPTViewEx9Info();
     void                Init( const ScDPObject& rDPObj );
commit 8bbfedd199deedb8dc7f196efba60c8cefb8da67
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 16:23:38 2012 -0500

    auto_ptr to scoped_ptr.

diff --git a/sc/source/filter/inc/xlpivot.hxx b/sc/source/filter/inc/xlpivot.hxx
index f162f8f..bed377d 100644
--- a/sc/source/filter/inc/xlpivot.hxx
+++ b/sc/source/filter/inc/xlpivot.hxx
@@ -41,7 +41,8 @@
 #include "xladdress.hxx"
 #include "dpobject.hxx"
 
-#include <memory>
+#include <boost/noncopyable.hpp>
+#include <boost/scoped_ptr.hpp>
 
 class XclImpStream;
 class XclExpStream;
@@ -637,9 +638,7 @@ struct XclPTFieldExtInfo
     sal_uInt16          mnSortField;    /// Index to data field sorting bases on.
     sal_uInt16          mnShowField;    /// Index to data field AutoShow bases on.
     sal_uInt16          mnNumFmt;
-    SAL_WNODEPRECATED_DECLARATIONS_PUSH
-    ::std::auto_ptr<rtl::OUString> mpFieldTotalName;
-    SAL_WNODEPRECATED_DECLARATIONS_POP
+    boost::scoped_ptr<rtl::OUString> mpFieldTotalName;
 
     explicit            XclPTFieldExtInfo();
 
commit fe7b2a4bec8bf4d3b07a156e019a82f8ba9cf68e
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 16:14:23 2012 -0500

    More, boolean-related cleanup. Removed unused data members.

diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 73b1c67..86bf12b 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -134,13 +134,13 @@ ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
     mnColFieldCount(0),
     mnPageFieldCount(0),
     mnDataFieldCount(0),
-    bIsNative(sal_True),
+    bIsNative(true),
     bIgnoreEmptyRows(false),
     bIdentifyCategories(false),
     bTargetRangeAddress(false),
     bSourceCellRange(false),
-    bShowFilter(sal_True),
-    bDrillDown(sal_True),
+    bShowFilter(true),
+    bDrillDown(true),
     bHeaderGridLayout(false)
 {
     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 31e3c9f..20ba107 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -114,18 +114,14 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext
     sal_uInt32      mnColFieldCount;
     sal_uInt32      mnPageFieldCount;
     sal_uInt32      mnDataFieldCount;
-    sal_Bool        bIsNative;
-    sal_Bool        bIgnoreEmptyRows;
-    sal_Bool        bIdentifyCategories;
-    sal_Bool        bUseRegularExpression;
-    sal_Bool        bIsCaseSensitive;
-    sal_Bool        bSkipDuplicates;
-    sal_Bool        bFilterCopyOutputData;
-    sal_Bool        bTargetRangeAddress;
-    sal_Bool        bSourceCellRange;
-    sal_Bool        bShowFilter;
-    sal_Bool        bDrillDown;
-    sal_Bool        bHeaderGridLayout;
+    bool            bIsNative:1;
+    bool            bIgnoreEmptyRows:1;
+    bool            bIdentifyCategories:1;
+    bool            bTargetRangeAddress:1;
+    bool            bSourceCellRange:1;
+    bool            bShowFilter:1;
+    bool            bDrillDown;
+    bool            bHeaderGridLayout:1;
 
     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
@@ -149,17 +145,16 @@ public:
     void SetGrandTotal(::xmloff::token::XMLTokenEnum eOrientation, bool bVisible, const ::rtl::OUString& rDisplayName);
     void SetDatabaseName(const rtl::OUString& sValue) { sDatabaseName = sValue; }
     void SetSourceObject(const rtl::OUString& sValue) { sSourceObject = sValue; }
-    void SetNative(const sal_Bool bValue) { bIsNative = bValue; }
+    void SetNative(bool bValue) { bIsNative = bValue; }
     void SetServiceName(const rtl::OUString& sValue) { sServiceName = sValue; }
     void SetServiceSourceName(const rtl::OUString& sValue) { sServiceSourceName = sValue; }
     void SetServiceSourceObject(const rtl::OUString& sValue) { sServiceSourceObject = sValue; }
     void SetServiceUsername(const rtl::OUString& sValue) { sServiceUsername = sValue; }
     void SetServicePassword(const rtl::OUString& sValue) { sServicePassword = sValue; }
     void SetSourceRangeName(const rtl::OUString& sValue) { sSourceRangeName = sValue; bSourceCellRange = true; }
-    void SetSourceCellRangeAddress(const ScRange& aValue) { aSourceCellRangeAddress = aValue; bSourceCellRange = sal_True; }
+    void SetSourceCellRangeAddress(const ScRange& aValue) { aSourceCellRangeAddress = aValue; bSourceCellRange = true; }
     void SetSourceQueryParam(const ScQueryParam& aValue) { aSourceQueryParam = aValue; }
     void SetFilterOutputPosition(const ScAddress& aValue) { aFilterOutputPosition = aValue; }
-    void SetFilterCopyOutputData(const sal_Bool bValue) { bFilterCopyOutputData = bValue; }
     void SetFilterSourceRange(const ScRange& aValue) { aFilterSourceRange = aValue; }
     void AddDimension(ScDPSaveDimension* pDim);
     void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim);
diff --git a/sc/source/filter/xml/xmlfilti.cxx b/sc/source/filter/xml/xmlfilti.cxx
index a680370..65c9420 100644
--- a/sc/source/filter/xml/xmlfilti.cxx
+++ b/sc/source/filter/xml/xmlfilti.cxx
@@ -641,16 +641,9 @@ void ScXMLDPFilterContext::EndElement()
     aFilterFields.bRegExp = bUseRegularExpressions;
     aFilterFields.bCaseSens = bIsCaseSensitive;
     aFilterFields.bDuplicate = !bSkipDuplicates;
-//  pDataPilotTable->SetFilterUseRegularExpressions(bUseRegularExpressions);
     if (bCopyOutputData)
-    {
         pDataPilotTable->SetFilterOutputPosition(aOutputPosition);
-        pDataPilotTable->SetFilterCopyOutputData(bCopyOutputData);
-    }
-    else
-        pDataPilotTable->SetFilterCopyOutputData(false);
-//  pDataPilotTable->SetFilterIsCaseSensitive(bIsCaseSensitive);
-//  pDataPilotTable->SetFilterSkipDuplicates(bSkipDuplicates);
+
     pDataPilotTable->SetSourceQueryParam(aFilterFields);
     if (bConditionSourceRange)
         pDataPilotTable->SetFilterSourceRange(aConditionSourceRangeAddress);
diff --git a/sc/source/filter/xml/xmlfilti.hxx b/sc/source/filter/xml/xmlfilti.hxx
index 952b705..8a9715d 100644
--- a/sc/source/filter/xml/xmlfilti.hxx
+++ b/sc/source/filter/xml/xmlfilti.hxx
@@ -217,14 +217,14 @@ class ScXMLDPFilterContext : public SvXMLImportContext
     ScRange         aConditionSourceRangeAddress;
     sal_uInt8   nFilterFieldCount;
     sal_Int16   nUserListIndex;
-    bool        bSkipDuplicates;
-    bool        bCopyOutputData;
-    bool        bUseRegularExpressions;
-    bool        bIsCaseSensitive;
-    bool        bEnabledUserList;
-    bool        bConnectionOr;
-    bool        bNextConnectionOr;
-    bool        bConditionSourceRange;
+    bool        bSkipDuplicates:1;
+    bool        bCopyOutputData:1;
+    bool        bUseRegularExpressions:1;
+    bool        bIsCaseSensitive:1;
+    bool        bEnabledUserList:1;
+    bool        bConnectionOr:1;
+    bool        bNextConnectionOr:1;
+    bool        bConditionSourceRange:1;
     ::std::stack<bool>  aConnectionOrStack;
 
     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
commit c9cf2a669237f8e253c7d4e8f8c4d022b804e020
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 16:04:00 2012 -0500

    Removed code that's no longer relevant.

diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 91d19cf..73b1c67 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -372,7 +372,7 @@ void ScXMLDataPilotTableContext::SetButtons()
         pDPObject->RefreshAfterLoad();
 }
 
-void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim, bool bHasHiddenMember)
+void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim)
 {
     if (pDPSave)
     {
@@ -401,17 +401,6 @@ void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim, bool bHas
                 ;
         }
 
-        if (bHasHiddenMember)
-        {
-            // the layout name takes priority over the original name,
-            // since this data is used against cell values.
-            const OUString* pLayoutName = pDim->GetLayoutName();
-            if (pLayoutName)
-                maHiddenMemberFields.insert(*pLayoutName);
-            else
-                maHiddenMemberFields.insert(pDim->GetName());
-        }
-
         pDPSave->AddDimension(pDim);
     }
 }
@@ -1080,7 +1069,7 @@ void ScXMLDataPilotFieldContext::EndElement()
         {
             pDim->SetCurrentPage(&sSelectedPage);
         }
-        pDataPilotTable->AddDimension(pDim, mbHasHiddenMember);
+        pDataPilotTable->AddDimension(pDim);
         if (bIsGroupField)
         {
             ScDPNumGroupInfo aInfo;
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 3ea89be..31e3c9f 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -80,9 +80,6 @@ public:
 
 class ScXMLDataPilotTableContext : public SvXMLImportContext
 {
-    typedef ::boost::unordered_set< ::rtl::OUString, ::rtl::OUStringHash > StringSet;
-    StringSet       maHiddenMemberFields;
-
     struct GrandTotalItem
     {
         ::rtl::OUString maDisplayName;
@@ -161,13 +158,10 @@ public:
     void SetSourceRangeName(const rtl::OUString& sValue) { sSourceRangeName = sValue; bSourceCellRange = true; }
     void SetSourceCellRangeAddress(const ScRange& aValue) { aSourceCellRangeAddress = aValue; bSourceCellRange = sal_True; }
     void SetSourceQueryParam(const ScQueryParam& aValue) { aSourceQueryParam = aValue; }
-//  void SetFilterUseRegularExpressions(const sal_Bool bValue) { aSourceQueryParam.bRegExp = bValue; }
     void SetFilterOutputPosition(const ScAddress& aValue) { aFilterOutputPosition = aValue; }
     void SetFilterCopyOutputData(const sal_Bool bValue) { bFilterCopyOutputData = bValue; }
     void SetFilterSourceRange(const ScRange& aValue) { aFilterSourceRange = aValue; }
-//  void SetFilterIsCaseSensitive(const sal_Bool bValue) { aSourceQueryParam.bCaseSens = bValue; }
-//  void SetFilterSkipDuplicates(const sal_Bool bValue) { aSourceQueryParam.bDuplicate = !bValue; }
-    void AddDimension(ScDPSaveDimension* pDim, bool bHasHiddenMember);
+    void AddDimension(ScDPSaveDimension* pDim);
     void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim);
     void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim);
     void SetButtons();
commit 9d4b32ef3f1866fa586394c6cceed4dc4a17ca38
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 16:00:49 2012 -0500

    Fixed ODS import filter to correctly identify data layout dimension.
    
    And cleaned up the code a bit.  The new code should be much more
    robust.

diff --git a/sc/inc/dpoutputgeometry.hxx b/sc/inc/dpoutputgeometry.hxx
index e0a5a87..f031ec1 100644
--- a/sc/inc/dpoutputgeometry.hxx
+++ b/sc/inc/dpoutputgeometry.hxx
@@ -38,9 +38,8 @@ class SC_DLLPUBLIC ScDPOutputGeometry
 {
 public:
     enum FieldType { Column, Row, Page, Data, None };
-    enum ImportType { ODF, XLS };
 
-    ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter, ImportType eImportType);
+    ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter);
     ~ScDPOutputGeometry();
 
     /**
@@ -57,7 +56,7 @@ public:
 
     SCROW getRowFieldHeaderRow() const;
 
-    FieldType getFieldButtonType(const ScAddress& rPos) const;
+    std::pair<FieldType, size_t> getFieldButtonType(const ScAddress& rPos) const;
 
 private:
     ScDPOutputGeometry(); // disabled
@@ -69,8 +68,6 @@ private:
     sal_uInt32  mnPageFields;
     sal_uInt32  mnDataFields;
 
-    ImportType  meImportType;
-
     bool        mbShowFilter;
 };
 
diff --git a/sc/source/core/data/dpoutputgeometry.cxx b/sc/source/core/data/dpoutputgeometry.cxx
index 2defc5a..83a998f 100644
--- a/sc/source/core/data/dpoutputgeometry.cxx
+++ b/sc/source/core/data/dpoutputgeometry.cxx
@@ -38,13 +38,12 @@
 
 using ::std::vector;
 
-ScDPOutputGeometry::ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter, ImportType eImportType) :
+ScDPOutputGeometry::ScDPOutputGeometry(const ScRange& rOutRange, bool bShowFilter) :
     maOutRange(rOutRange),
     mnRowFields(0),
     mnColumnFields(0),
     mnPageFields(0),
     mnDataFields(0),
-    meImportType(eImportType),
     mbShowFilter(bShowFilter)
 {
 }
@@ -163,13 +162,11 @@ SCROW ScDPOutputGeometry::getRowFieldHeaderRow() const
     return nCurRow;
 }
 
-ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAddress& rPos) const
+std::pair<ScDPOutputGeometry::FieldType, size_t>
+ScDPOutputGeometry::getFieldButtonType(const ScAddress& rPos) const
 {
     // We will ignore the table position for now.
 
-    bool bExtraTitleRow = (mnColumnFields == 0 && meImportType == ScDPOutputGeometry::XLS);
-    bool bDataLayout = mnDataFields > 1;
-
     SCROW nCurRow = maOutRange.aStart.Row();
 
     if (mnPageFields)
@@ -178,7 +175,10 @@ ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAdd
         SCROW nRowStart = maOutRange.aStart.Row() + mbShowFilter;
         SCROW nRowEnd   = nRowStart + static_cast<SCCOL>(mnPageFields-1);
         if (rPos.Col() == nCol && nRowStart <= rPos.Row() && rPos.Row() <= nRowEnd)
-            return Page;
+        {
+            size_t nPos = static_cast<size_t>(rPos.Row() - nRowStart);
+            return std::pair<FieldType, size_t>(Page, nPos);
+        }
 
         nCurRow = nRowEnd + 2;
     }
@@ -188,15 +188,17 @@ ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAdd
     if (mnColumnFields)
     {
         SCROW nRow = nCurRow;
-        SCCOL nColStart = static_cast<SCCOL>(maOutRange.aStart.Col() + mnRowFields + (bDataLayout ? 1 : 0));
+        SCCOL nColStart = static_cast<SCCOL>(maOutRange.aStart.Col() + mnRowFields);
         SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnColumnFields-1);
         if (rPos.Row() == nRow && nColStart <= rPos.Col() && rPos.Col() <= nColEnd)
-            return Column;
+        {
+            size_t nPos = static_cast<size_t>(rPos.Col() - nColStart);
+            return std::pair<FieldType, size_t>(Column, nPos);
+        }
 
         nCurRow += static_cast<SCROW>(mnColumnFields);
     }
-
-    if (bExtraTitleRow)
+    else
         ++nCurRow;
 
     if (mnRowFields)
@@ -204,10 +206,13 @@ ScDPOutputGeometry::FieldType ScDPOutputGeometry::getFieldButtonType(const ScAdd
         SCCOL nColStart = maOutRange.aStart.Col();
         SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnRowFields-1);
         if (rPos.Row() == nCurRow && nColStart <= rPos.Col() && rPos.Col() <= nColEnd)
-            return Row;
+        {
+            size_t nPos = static_cast<size_t>(rPos.Col() - nColStart);
+            return std::pair<FieldType, size_t>(Row, nPos);
+        }
     }
 
-    return None;
+    return std::pair<FieldType, size_t>(None, 0);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 6cd0f48..8946581 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1470,7 +1470,7 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
 {
     // Apply merge flags for varoius datapilot controls.
 
-    ScDPOutputGeometry aGeometry(rOutRange, false, ScDPOutputGeometry::XLS);
+    ScDPOutputGeometry aGeometry(rOutRange, false);
     aGeometry.setColumnFieldCount(maPTInfo.mnColFields);
     aGeometry.setPageFieldCount(maPTInfo.mnPageFields);
     aGeometry.setDataFieldCount(maPTInfo.mnDataFields);
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 4d48946..91d19cf 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -230,7 +230,7 @@ ScXMLDataPilotTableContext::ScXMLDataPilotTableContext( ScXMLImport& rImport,
     }
 
     pDPObject = new ScDPObject(pDoc);
-     pDPSave = new ScDPSaveData();
+    pDPSave = new ScDPSaveData();
 }
 
 ScXMLDataPilotTableContext::~ScXMLDataPilotTableContext()
@@ -295,14 +295,49 @@ SvXMLImportContext *ScXMLDataPilotTableContext::CreateChildContext( sal_uInt16 n
     return pContext;
 }
 
+namespace {
+
+const ScDPSaveDimension* getDimension(
+    const std::vector<const ScDPSaveDimension*>& rRowDims,
+    const std::vector<const ScDPSaveDimension*>& rColDims,
+    ScDPOutputGeometry::FieldType eType, size_t nPos)
+{
+    switch (eType)
+    {
+        case ScDPOutputGeometry::Column:
+        {
+            if (rColDims.size() <= nPos)
+                return NULL;
+
+            return rColDims[nPos];
+        }
+        case ScDPOutputGeometry::Row:
+        {
+            if (rRowDims.size() <= nPos)
+                return NULL;
+
+            return rRowDims[nPos];
+        }
+        default:
+            ;
+    }
+    return NULL;
+}
+
+}
+
 void ScXMLDataPilotTableContext::SetButtons()
 {
-    ScDPOutputGeometry aGeometry(aTargetRangeAddress, bShowFilter, ScDPOutputGeometry::ODF);
+    ScDPOutputGeometry aGeometry(aTargetRangeAddress, bShowFilter);
     aGeometry.setColumnFieldCount(mnColFieldCount);
     aGeometry.setRowFieldCount(mnRowFieldCount);
     aGeometry.setPageFieldCount(mnPageFieldCount);
     aGeometry.setDataFieldCount(mnDataFieldCount);
 
+    std::vector<const ScDPSaveDimension*> aRowDims, aColDims, aPageDims;
+    pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aRowDims);
+    pDPSave->GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aColDims);
+
     OUString sAddress;
     sal_Int32 nOffset = 0;
     while( nOffset >= 0 )
@@ -314,20 +349,20 @@ void ScXMLDataPilotTableContext::SetButtons()
             sal_Int32 nAddrOffset(0);
             if (pDoc && ScRangeStringConverter::GetAddressFromString( aScAddress, sAddress, pDoc, ::formula::FormulaGrammar::CONV_OOO, nAddrOffset ))
             {
-                ScDPOutputGeometry::FieldType eType = aGeometry.getFieldButtonType(aScAddress);
+                std::pair<ScDPOutputGeometry::FieldType, size_t> aBtnType = aGeometry.getFieldButtonType(aScAddress);
+                const ScDPSaveDimension* pDim = getDimension(
+                    aRowDims, aColDims, aBtnType.first, aBtnType.second);
 
-                sal_Int16 nMFlag = SC_MF_BUTTON;
-                if (eType == ScDPOutputGeometry::Column || eType == ScDPOutputGeometry::Row)
-                    nMFlag |= SC_MF_BUTTON_POPUP;
+                bool bDataLayout = pDim && pDim->IsDataLayout();
+                bool bHasHidden = pDim && pDim->HasInvisibleMember();
 
-                // Use the cell's string value to see if this field contains a
-                // hidden member.  Isn't there a better way?  GetString() is
-                // quite expensive...
-                String aCellStr;
-                pDoc->GetString(aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), aCellStr);
-                if (maHiddenMemberFields.count(aCellStr))
+                sal_Int16 nMFlag = SC_MF_BUTTON;
+                if (bHasHidden)
                     nMFlag |= SC_MF_HIDDEN_MEMBER;
 
+                if (!bDataLayout)
+                    nMFlag |= SC_MF_BUTTON_POPUP;
+
                 pDoc->ApplyFlagsTab(aScAddress.Col(), aScAddress.Row(), aScAddress.Col(), aScAddress.Row(), aScAddress.Tab(), nMFlag);
             }
         }
@@ -345,40 +380,38 @@ void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim, bool bHas
         //  mark the new one as duplicate
         if ( !pDim->IsDataLayout() &&
                 pDPSave->GetExistingDimensionByName(pDim->GetName()) )
-            pDim->SetDupFlag( sal_True );
+            pDim->SetDupFlag(true);
 
-        if (!pDim->IsDataLayout())
+        switch (pDim->GetOrientation())
         {
-            switch (pDim->GetOrientation())
-            {
-                case sheet::DataPilotFieldOrientation_ROW:
-                    ++mnRowFieldCount;
-                break;
-                case sheet::DataPilotFieldOrientation_COLUMN:
-                    ++mnColFieldCount;
-                break;
-                case sheet::DataPilotFieldOrientation_PAGE:
-                    ++mnPageFieldCount;
-                break;
-                case sheet::DataPilotFieldOrientation_DATA:
-                    ++mnDataFieldCount;
-                break;
-                case sheet::DataPilotFieldOrientation_HIDDEN:
-                default:
-                    ;
-            }
+            case sheet::DataPilotFieldOrientation_ROW:
+                ++mnRowFieldCount;
+            break;
+            case sheet::DataPilotFieldOrientation_COLUMN:
+                ++mnColFieldCount;
+            break;
+            case sheet::DataPilotFieldOrientation_PAGE:
+                ++mnPageFieldCount;
+            break;
+            case sheet::DataPilotFieldOrientation_DATA:
+                ++mnDataFieldCount;
+            break;
+            case sheet::DataPilotFieldOrientation_HIDDEN:
+            default:
+                ;
+        }
 
-            if (bHasHiddenMember)
-            {
-                // the layout name takes priority over the original name,
-                // since this data is used against cell values.
-                const OUString* pLayoutName = pDim->GetLayoutName();
-                if (pLayoutName)
-                    maHiddenMemberFields.insert(*pLayoutName);
-                else
-                    maHiddenMemberFields.insert(pDim->GetName());
-            }
+        if (bHasHiddenMember)
+        {
+            // the layout name takes priority over the original name,
+            // since this data is used against cell values.
+            const OUString* pLayoutName = pDim->GetLayoutName();
+            if (pLayoutName)
+                maHiddenMemberFields.insert(*pLayoutName);
+            else
+                maHiddenMemberFields.insert(pDim->GetName());
         }
+
         pDPSave->AddDimension(pDim);
     }
 }
commit 75d807f7b1cc9aa2ef3cf41d6f572aa5a56583a7
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 14:46:59 2012 -0500

    Try to preserve the orientation of data layout dimension.

diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 8b83f6b..2c27c1a 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -1447,14 +1447,31 @@ bool ScDPLayoutDlg::GetPivotArrays(
     vector<PivotField> aColFields;
     for_each(aColArr.begin(), aColArr.end(), PivotFieldInserter(aColFields, aColArr.size()));
 
-    // default data pilot table always has an extra row field as a data layout field.
     vector<PivotField> aRowFields;
     for_each(aRowArr.begin(), aRowArr.end(), PivotFieldInserter(aRowFields, aRowArr.size()+1));
-    aRowFields.push_back(PivotField(PIVOT_DATA_FIELD, 0));
 
     vector<PivotField> aDataFields;
     for_each(aDataArr.begin(), aDataArr.end(), PivotFieldInserter(aDataFields, aDataArr.size()));
 
+    sheet::DataPilotFieldOrientation eOrientDataLayout = sheet::DataPilotFieldOrientation_ROW;
+    ScDPSaveData* pSaveData = xDlgDPObject->GetSaveData();
+    if (pSaveData)
+    {
+        const ScDPSaveDimension* p = pSaveData->GetExistingDataLayoutDimension();
+        if (p)
+            // Try to preserve the orientation of existing data layout dimension.
+            eOrientDataLayout = static_cast<sheet::DataPilotFieldOrientation>(p->GetOrientation());
+    }
+    switch (eOrientDataLayout)
+    {
+        case sheet::DataPilotFieldOrientation_COLUMN:
+            aColFields.push_back(PivotField(PIVOT_DATA_FIELD, 0));
+        break;
+        default:
+            // data layout dimension can only be row or column.
+            aRowFields.push_back(PivotField(PIVOT_DATA_FIELD, 0));
+    }
+
     rPageFields.swap(aPageFields);
     rColFields.swap(aColFields);
     rRowFields.swap(aRowFields);
commit 7cec5493cebfb0833389ea79cb83fbc677c6751c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 13:57:48 2012 -0500

    Remove std::auto_ptr in favor of boost::scoped_ptr.

diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 08b5c76..89f34a2 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -30,10 +30,10 @@
 #define SC_DPSAVE_HXX
 
 #include <list>
-#include <memory>
 
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/unordered_map.hpp>
+#include <boost/scoped_ptr.hpp>
 
 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
@@ -256,9 +256,7 @@ private:
      *  created. */
     bool mbDimensionMembersBuilt;
 
-    SAL_WNODEPRECATED_DECLARATIONS_PUSH
-    ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
-    SAL_WNODEPRECATED_DECLARATIONS_POP
+    boost::scoped_ptr<rtl::OUString> mpGrandTotalName;
 
 public:
     SC_DLLPUBLIC ScDPSaveData();
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 287c6b6..2c23783 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -755,7 +755,7 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
 
     aDimList = r.aDimList.clone();
 
-    if (r.mpGrandTotalName.get())
+    if (r.mpGrandTotalName)
         mpGrandTotalName.reset(new OUString(*r.mpGrandTotalName));
 }
 
@@ -790,14 +790,14 @@ bool ScDPSaveData::operator== ( const ScDPSaveData& r ) const
     if (aDimList != r.aDimList)
         return false;
 
-    if (mpGrandTotalName.get())
+    if (mpGrandTotalName)
     {
-        if (!r.mpGrandTotalName.get())
+        if (!r.mpGrandTotalName)
             return false;
         if (!mpGrandTotalName->equals(*r.mpGrandTotalName))
             return false;
     }
-    else if (r.mpGrandTotalName.get())
+    else if (r.mpGrandTotalName)
         return false;
 
     return true;
commit 8f38e6a4cc492d2ac978ff11376f568f010b82cb
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 13:41:24 2012 -0500

    Handle painting of data layout dimension button correctly during refresh.
    
    Data layout dimension can be anywhere in the row/column fields.  Use the
    appropriate boolean property to determine if the field is data layout.

diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index 97f931e..4a02647 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -124,8 +124,9 @@ private:
     void            HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                 const com::sun::star::sheet::MemberResult& rData,
                                 sal_Bool bColHeader, long nLevel );
-    void            FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption,
-                               bool bInTable, bool bPopup, bool bHasHiddenMember );
+
+    void FieldCell(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScDPOutLevelData& rData, bool bInTable);
+
     void            CalcSizes();
 
     /** Query which sub-area of the table the cell is in. See
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 78ef4e6..690d5b6 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -93,17 +93,16 @@ struct ScDPOutLevelData
     long                                nLevel;
     long                                nDimPos;
     uno::Sequence<sheet::MemberResult>  aResult;
-    String                              maName;   /// Name is the internal field name.
-    String                              aCaption; /// Caption is the name visible in the output table.
-    bool                                mbHasHiddenMember;
+    rtl::OUString                       maName;   /// Name is the internal field name.
+    rtl::OUString                       maCaption; /// Caption is the name visible in the output table.
+    bool                                mbHasHiddenMember:1;
+    bool                                mbDataLayout:1;
 
-    ScDPOutLevelData()
-    {
-        nDim = nHier = nLevel = nDimPos = -1;
-        mbHasHiddenMember = false;
-    }
+    ScDPOutLevelData() :
+        nDim(-1), nHier(-1), nLevel(-1), nDimPos(-1), mbHasHiddenMember(false), mbDataLayout(false)
+    {}
 
-    sal_Bool operator<(const ScDPOutLevelData& r) const
+    bool operator<(const ScDPOutLevelData& r) const
         { return nDimPos<r.nDimPos || ( nDimPos==r.nDimPos && nHier<r.nHier ) ||
             ( nDimPos==r.nDimPos && nHier==r.nHier && nLevel<r.nLevel ); }
 
@@ -572,9 +571,8 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                         sheet::DataPilotFieldOrientation_HIDDEN );
                 long nDimPos = ScUnoHelpFunctions::GetLongProperty( xDimProp,
                         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_POSITION)) );
-                sal_Bool bIsDataLayout = ScUnoHelpFunctions::GetBoolProperty(
-                                                xDimProp,
-                                                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ISDATALAYOUT)) );
+                bool bIsDataLayout = ScUnoHelpFunctions::GetBoolProperty(
+                    xDimProp, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_ISDATALAYOUT)));
                 bool bHasHiddenMember = ScUnoHelpFunctions::GetBoolProperty(
                     xDimProp, OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_DP_HAS_HIDDEN_MEMBER)));
 
@@ -607,7 +605,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                                     xLevel, uno::UNO_QUERY );
                             if ( xLevNam.is() && xLevRes.is() )
                             {
-                                String aName = xLevNam->getName();
+                                rtl::OUString aName = xLevNam->getName();
                                 Reference<XPropertySet> xPropSet(xLevel, UNO_QUERY);
                                 // Caption equals the field name by default.
                                 // #i108948# use ScUnoHelpFunctions::GetStringProperty, because
@@ -625,8 +623,9 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                                         pColFields[nColFieldCount].nDimPos = nDimPos;
                                         pColFields[nColFieldCount].aResult = xLevRes->getResults();
                                         pColFields[nColFieldCount].maName  = aName;
-                                        pColFields[nColFieldCount].aCaption= aCaption;
+                                        pColFields[nColFieldCount].maCaption= aCaption;
                                         pColFields[nColFieldCount].mbHasHiddenMember = bHasHiddenMember;
+                                        pColFields[nColFieldCount].mbDataLayout = bIsDataLayout;
                                         if (!lcl_MemberEmpty(pColFields[nColFieldCount].aResult))
                                             ++nColFieldCount;
                                         break;
@@ -637,8 +636,9 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                                         pRowFields[nRowFieldCount].nDimPos = nDimPos;
                                         pRowFields[nRowFieldCount].aResult = xLevRes->getResults();
                                         pRowFields[nRowFieldCount].maName  = aName;
-                                        pRowFields[nRowFieldCount].aCaption= aCaption;
+                                        pRowFields[nRowFieldCount].maCaption= aCaption;
                                         pRowFields[nRowFieldCount].mbHasHiddenMember = bHasHiddenMember;
+                                        pRowFields[nRowFieldCount].mbDataLayout = bIsDataLayout;
                                         if (!lcl_MemberEmpty(pRowFields[nRowFieldCount].aResult))
                                         {
                                             ++nRowFieldCount;
@@ -652,7 +652,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
                                         pPageFields[nPageFieldCount].nDimPos = nDimPos;
                                         pPageFields[nPageFieldCount].aResult = lcl_GetSelectedPageAsResult(xDimProp);
                                         pPageFields[nPageFieldCount].maName  = aName;
-                                        pPageFields[nPageFieldCount].aCaption= aCaption;
+                                        pPageFields[nPageFieldCount].maCaption= aCaption;
                                         pPageFields[nPageFieldCount].mbHasHiddenMember = bHasHiddenMember;
                                         // no check on results for page fields
                                         ++nPageFieldCount;
@@ -828,23 +828,23 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
     }
 }
 
-void ScDPOutput::FieldCell( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rCaption,
-                            bool bInTable, bool bPopup, bool bHasHiddenMember )
+void ScDPOutput::FieldCell(
+    SCCOL nCol, SCROW nRow, SCTAB nTab, const ScDPOutLevelData& rData, bool bInTable)
 {
     // Avoid unwanted automatic format detection.
     ScSetStringParam aParam;
     aParam.mbDetectNumberFormat = false;
     aParam.mbSetTextCellFormat = true;
-    pDoc->SetString(nCol, nRow, nTab, rCaption, &aParam);
+    pDoc->SetString(nCol, nRow, nTab, rData.maCaption, &aParam);
 
     if (bInTable)
         lcl_SetFrame( pDoc,nTab, nCol,nRow, nCol,nRow, 20 );
 
     //  Button
     sal_uInt16 nMergeFlag = SC_MF_BUTTON;
-    if (bPopup)
+    if (!rData.mbDataLayout)
         nMergeFlag |= SC_MF_BUTTON_POPUP;
-    if (bHasHiddenMember)
+    if (rData.mbHasHiddenMember)
         nMergeFlag |= SC_MF_HIDDEN_MEMBER;
     pDoc->ApplyFlagsTab(nCol, nRow, nCol, nRow, nTab, nMergeFlag);
 
@@ -994,7 +994,7 @@ void ScDPOutput::Output()
         SCCOL nHdrCol = aStartPos.Col();
         SCROW nHdrRow = aStartPos.Row() + nField + ( bDoFilter ? 1 : 0 );
         // draw without frame for consistency with filter button:
-        FieldCell( nHdrCol, nHdrRow, nTab, pPageFields[nField].aCaption, false, false, pPageFields[nField].mbHasHiddenMember );
+        FieldCell(nHdrCol, nHdrRow, nTab, pPageFields[nField], false);
         SCCOL nFldCol = nHdrCol + 1;
 
         String aPageValue;
@@ -1035,7 +1035,7 @@ void ScDPOutput::Output()
     for (nField=0; nField<nColFieldCount; nField++)
     {
         SCCOL nHdrCol = nDataStartCol + (SCCOL)nField;              //! check for overflow
-        FieldCell( nHdrCol, nTabStartRow, nTab, pColFields[nField].aCaption, true, true, pColFields[nField].mbHasHiddenMember );
+        FieldCell(nHdrCol, nTabStartRow, nTab, pColFields[nField], true);
 
         SCROW nRowPos = nMemberStartRow + (SCROW)nField;                //! check for overflow
         const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nField].aResult;
@@ -1081,12 +1081,9 @@ void ScDPOutput::Output()
     vbSetBorder.resize( nTabEndRow - nDataStartRow + 1, false );
     for (nField=0; nField<nRowFieldCount; nField++)
     {
-        bool bDataLayout = mbHasDataLayout && (nField == nRowFieldCount-1);
-
         SCCOL nHdrCol = nTabStartCol + (SCCOL)nField;                   //! check for overflow
         SCROW nHdrRow = nDataStartRow - 1;
-        FieldCell( nHdrCol, nHdrRow, nTab, pRowFields[nField].aCaption, true, !bDataLayout,
-                   pRowFields[nField].mbHasHiddenMember );
+        FieldCell(nHdrCol, nHdrRow, nTab, pRowFields[nField], true);
 
         SCCOL nColPos = nMemberStartCol + (SCCOL)nField;                //! check for overflow
         const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nField].aResult;
commit 4eedf5dc54ab19af39d7033462421082d1abb86d
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 12:06:21 2012 -0500

    Correctly set pivot's popup flag when importing from Excel docs.

diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index ee2fd6d..08b5c76 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -240,8 +240,10 @@ public:
 
 class ScDPSaveData
 {
+public:
+    typedef boost::ptr_vector<ScDPSaveDimension> DimsType;
 private:
-    boost::ptr_vector<ScDPSaveDimension> aDimList;
+    DimsType aDimList;
     ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions
     sal_uInt16 nColumnGrandMode;
     sal_uInt16 nRowGrandMode;
@@ -270,8 +272,19 @@ public:
     SC_DLLPUBLIC void SetGrandTotalName(const ::rtl::OUString& rName);
     SC_DLLPUBLIC const ::rtl::OUString* GetGrandTotalName() const;
 
-    const boost::ptr_vector<ScDPSaveDimension>& GetDimensions() const
-        { return aDimList; }
+    SC_DLLPUBLIC const DimsType& GetDimensions() const;
+
+    /**
+     * Get all dimensions in a given orientation.  The order represents the
+     * actual order of occurrence.  The returned list also includes data
+     * layout dimension.
+     *
+     * @param eOrientation orientation
+     * @param rDims (out) list of dimensions for specified orientation
+     */
+    SC_DLLPUBLIC void GetAllDimensionsByOrientation(
+        com::sun::star::sheet::DataPilotFieldOrientation eOrientation,
+        std::vector<const ScDPSaveDimension*>& rDims) const;
 
     void AddDimension(ScDPSaveDimension* pDim)
         { aDimList.push_back(pDim); }
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index e27ef45..287c6b6 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -818,6 +818,28 @@ const OUString* ScDPSaveData::GetGrandTotalName() const
     return mpGrandTotalName.get();
 }
 
+const ScDPSaveData::DimsType& ScDPSaveData::GetDimensions() const
+{
+    return aDimList;
+}
+
+void ScDPSaveData::GetAllDimensionsByOrientation(
+    sheet::DataPilotFieldOrientation eOrientation, std::vector<const ScDPSaveDimension*>& rDims) const
+{
+    std::vector<const ScDPSaveDimension*> aDims;
+    DimsType::const_iterator it = aDimList.begin(), itEnd = aDimList.end();
+    for (; it != itEnd; ++it)
+    {
+        const ScDPSaveDimension& rDim = *it;
+        if (rDim.GetOrientation() != static_cast<sal_uInt16>(eOrientation))
+            continue;
+
+        aDims.push_back(&rDim);
+    }
+
+    rDims.swap(aDims);
+}
+
 ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const ::rtl::OUString& rName)
 {
     boost::ptr_vector<ScDPSaveDimension>::const_iterator iter;
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 7e93dff..6cd0f48 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -60,6 +60,8 @@
 
 #include <vector>
 
+using namespace com::sun::star;
+
 using ::rtl::OUString;
 using ::rtl::OUStringBuffer;
 using ::com::sun::star::sheet::DataPilotFieldOrientation;
@@ -1476,9 +1478,11 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
 
     ScDocument& rDoc = GetDoc();
 
-    vector<ScAddress> aPageBtns;
-    aGeometry.getPageFieldPositions(aPageBtns);
-    vector<ScAddress>::const_iterator itr = aPageBtns.begin(), itrEnd = aPageBtns.end();
+    vector<const ScDPSaveDimension*> aFieldDims;
+    vector<ScAddress> aFieldBtns;
+
+    aGeometry.getPageFieldPositions(aFieldBtns);
+    vector<ScAddress>::const_iterator itr = aFieldBtns.begin(), itrEnd = aFieldBtns.end();
     for (; itr != itrEnd; ++itr)
     {
         sal_uInt16 nMFlag = SC_MF_BUTTON;
@@ -1491,32 +1495,42 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
         rDoc.ApplyFlagsTab(itr->Col()+1, itr->Row(), itr->Col()+1, itr->Row(), itr->Tab(), SC_MF_AUTO);
     }
 
-    vector<ScAddress> aColBtns;
-    aGeometry.getColumnFieldPositions(aColBtns);
-    itr    = aColBtns.begin();
-    itrEnd = aColBtns.end();
-    for (; itr != itrEnd; ++itr)
+    aGeometry.getColumnFieldPositions(aFieldBtns);
+    rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_COLUMN, aFieldDims);
+    if (aFieldBtns.size() == aFieldDims.size())
     {
-        sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP;
-        rtl::OUString aName;
-        rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
-        if (rSaveData.HasInvisibleMember(aName))
-            nMFlag |= SC_MF_HIDDEN_MEMBER;
-        rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
+        itr    = aFieldBtns.begin();
+        itrEnd = aFieldBtns.end();
+        vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
+        for (; itr != itrEnd; ++itr, ++itDim)
+        {
+            sal_Int16 nMFlag = SC_MF_BUTTON;
+            const ScDPSaveDimension* pDim = *itDim;
+            if (pDim->HasInvisibleMember())
+                nMFlag |= SC_MF_HIDDEN_MEMBER;
+            if (!pDim->IsDataLayout())
+                nMFlag |= SC_MF_BUTTON_POPUP;
+            rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
+        }
     }
 
-    vector<ScAddress> aRowBtns;
-    aGeometry.getRowFieldPositions(aRowBtns);
-    itr    = aRowBtns.begin();
-    itrEnd = aRowBtns.end();
-    for (; itr != itrEnd; ++itr)
+    aGeometry.getRowFieldPositions(aFieldBtns);
+    rSaveData.GetAllDimensionsByOrientation(sheet::DataPilotFieldOrientation_ROW, aFieldDims);
+    if (aFieldBtns.size() == aFieldDims.size())
     {
-        sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP;
-        rtl::OUString aName;
-        rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
-        if (rSaveData.HasInvisibleMember(aName))
-            nMFlag |= SC_MF_HIDDEN_MEMBER;
-        rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
+        itr    = aFieldBtns.begin();
+        itrEnd = aFieldBtns.end();
+        vector<const ScDPSaveDimension*>::const_iterator itDim = aFieldDims.begin();
+        for (; itr != itrEnd; ++itr, ++itDim)
+        {
+            sal_Int16 nMFlag = SC_MF_BUTTON;
+            const ScDPSaveDimension* pDim = *itDim;
+            if (pDim->HasInvisibleMember())
+                nMFlag |= SC_MF_HIDDEN_MEMBER;
+            if (!pDim->IsDataLayout())
+                nMFlag |= SC_MF_BUTTON_POPUP;
+            rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
+        }
     }
 }
 
commit 691f2451c86348239d3b9735ee81b8ecd3209161
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Tue Feb 14 11:23:44 2012 -0500

    Removed the incorrect assumption about the data layout field.
    
    The Excel import filter code assumed that the data layout field be
    always the last row field, which is totally wrong.  The data layout
    field can be at any column/row field position in fact.

diff --git a/sc/inc/dpoutputgeometry.hxx b/sc/inc/dpoutputgeometry.hxx
index c5c6519..e0a5a87 100644
--- a/sc/inc/dpoutputgeometry.hxx
+++ b/sc/inc/dpoutputgeometry.hxx
@@ -44,8 +44,7 @@ public:
     ~ScDPOutputGeometry();
 
     /**
-     * @param nCount number of row fields, <b>excluding the data layout
-     *               field if exists</b>.
+     * @param nCount number of row fields.
      */
     void setRowFieldCount(sal_uInt32 nCount);
     void setColumnFieldCount(sal_uInt32 nCount);
@@ -65,7 +64,7 @@ private:
 
 private:
     ScRange     maOutRange;
-    sal_uInt32  mnRowFields;    /// number of row fields (data layout field NOT included!)
+    sal_uInt32  mnRowFields;    /// number of row fields
     sal_uInt32  mnColumnFields;
     sal_uInt32  mnPageFields;
     sal_uInt32  mnDataFields;
diff --git a/sc/source/core/data/dpoutputgeometry.cxx b/sc/source/core/data/dpoutputgeometry.cxx
index f3d7e82..2defc5a 100644
--- a/sc/source/core/data/dpoutputgeometry.cxx
+++ b/sc/source/core/data/dpoutputgeometry.cxx
@@ -82,8 +82,6 @@ void ScDPOutputGeometry::getColumnFieldPositions(vector<ScAddress>& rAddrs) cons
         return;
     }
 
-    bool bDataLayout = mnDataFields > 1;
-
     SCROW nCurRow = maOutRange.aStart.Row();
 
     if (mnPageFields)
@@ -97,7 +95,7 @@ void ScDPOutputGeometry::getColumnFieldPositions(vector<ScAddress>& rAddrs) cons
 
     SCROW nRow = nCurRow;
     SCTAB nTab = maOutRange.aStart.Tab();
-    SCCOL nColStart = static_cast<SCCOL>(maOutRange.aStart.Col() + mnRowFields + (bDataLayout ? 1 : 0));
+    SCCOL nColStart = static_cast<SCCOL>(maOutRange.aStart.Col() + mnRowFields);
     SCCOL nColEnd = nColStart + static_cast<SCCOL>(mnColumnFields-1);
 
     for (SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx
index 8cbd721..7e93dff 100644
--- a/sc/source/filter/excel/xipivot.cxx
+++ b/sc/source/filter/excel/xipivot.cxx
@@ -1444,7 +1444,7 @@ void XclImpPivotTable::Convert()
     pDPObj->SetSaveData( aSaveData );
     pDPObj->SetSheetDesc( aDesc );
     pDPObj->SetOutRange( aOutRange );
-    pDPObj->SetAlive( sal_True );
+    pDPObj->SetAlive(true);
     pDPObj->SetHeaderLayout( maPTViewEx9Info.mnGridLayout == 0 );
 
     GetDoc().GetDPCollection()->InsertNewTable(pDPObj);
@@ -1472,11 +1472,7 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
     aGeometry.setColumnFieldCount(maPTInfo.mnColFields);
     aGeometry.setPageFieldCount(maPTInfo.mnPageFields);
     aGeometry.setDataFieldCount(maPTInfo.mnDataFields);
-
-    // Excel includes data layout field in the row field count.  We need to
-    // subtract it.
-    bool bDataLayout = maPTInfo.mnDataFields > 1;
-    aGeometry.setRowFieldCount(maPTInfo.mnRowFields - static_cast<sal_uInt32>(bDataLayout));
+    aGeometry.setRowFieldCount(maPTInfo.mnRowFields);
 
     ScDocument& rDoc = GetDoc();
 
@@ -1486,7 +1482,7 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
     for (; itr != itrEnd; ++itr)
     {
         sal_uInt16 nMFlag = SC_MF_BUTTON;
-        String aName;
+        rtl::OUString aName;
         rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
         if (rSaveData.HasInvisibleMember(aName))
             nMFlag |= SC_MF_HIDDEN_MEMBER;
@@ -1502,7 +1498,7 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
     for (; itr != itrEnd; ++itr)
     {
         sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP;
-        String aName;
+        rtl::OUString aName;
         rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
         if (rSaveData.HasInvisibleMember(aName))
             nMFlag |= SC_MF_HIDDEN_MEMBER;
@@ -1511,40 +1507,20 @@ void XclImpPivotTable::ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveD
 
     vector<ScAddress> aRowBtns;
     aGeometry.getRowFieldPositions(aRowBtns);
-    if (aRowBtns.empty())
-    {
-        if (bDataLayout)
-        {
-            // No row fields, but the data layout button exists.
-            SCROW nRow = aGeometry.getRowFieldHeaderRow();
-            SCCOL nCol = rOutRange.aStart.Col();
-            SCTAB nTab = rOutRange.aStart.Tab();
-            rDoc.ApplyFlagsTab(nCol, nRow, nCol, nRow, nTab, SC_MF_BUTTON);
-        }
-    }
-    else
+    itr    = aRowBtns.begin();
+    itrEnd = aRowBtns.end();
+    for (; itr != itrEnd; ++itr)
     {
-        itr    = aRowBtns.begin();
-        itrEnd = aRowBtns.end();
-        for (; itr != itrEnd; ++itr)
-        {
-            sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP;
-            String aName;
-            rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
-            if (rSaveData.HasInvisibleMember(aName))
-                nMFlag |= SC_MF_HIDDEN_MEMBER;
-            rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
-        }
-        if (bDataLayout)
-        {
-            --itr; // move back to the last row field position.
-            rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), SC_MF_BUTTON);
-        }
+        sal_Int16 nMFlag = SC_MF_BUTTON | SC_MF_BUTTON_POPUP;
+        rtl::OUString aName;
+        rDoc.GetString(itr->Col(), itr->Row(), itr->Tab(), aName);
+        if (rSaveData.HasInvisibleMember(aName))
+            nMFlag |= SC_MF_HIDDEN_MEMBER;
+        rDoc.ApplyFlagsTab(itr->Col(), itr->Row(), itr->Col(), itr->Row(), itr->Tab(), nMFlag);
     }
 }
 
 // ============================================================================
-// ============================================================================
 
 XclImpPivotTableManager::XclImpPivotTableManager( const XclImpRoot& rRoot ) :
     XclImpRoot( rRoot )


More information about the Libreoffice-commits mailing list