ooo-build r14565 - in trunk: . patches/test



Author: kyoshida
Date: Fri Nov 21 05:03:12 2008
New Revision: 14565
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14565&view=rev

Log:
2008-11-21  Kohei Yoshida  <kyoshida novell com>

	* patches/test/calc-dp-custom-names.diff: Today's progress.  Calc now 
	supports editing of all editable names in datapilot table output.


Modified:
   trunk/ChangeLog
   trunk/patches/test/calc-dp-custom-names.diff

Modified: trunk/patches/test/calc-dp-custom-names.diff
==============================================================================
--- trunk/patches/test/calc-dp-custom-names.diff	(original)
+++ trunk/patches/test/calc-dp-custom-names.diff	Fri Nov 21 05:03:12 2008
@@ -1,21 +1,27 @@
 diff --git offapi/com/sun/star/sheet/MemberResultFlags.idl offapi/com/sun/star/sheet/MemberResultFlags.idl
-index 788673c..b9dbd61 100644
+index 788673c..943e9ac 100644
 --- offapi/com/sun/star/sheet/MemberResultFlags.idl
 +++ offapi/com/sun/star/sheet/MemberResultFlags.idl
-@@ -59,6 +59,11 @@ published constants MemberResultFlags
+@@ -59,6 +59,17 @@ published constants MemberResultFlags
  	 */
  	const long CONTINUE = 4;
  
 +    //-------------------------------------------------------------------------
 +
++    /** The element contains a grand total. 
++     */
++    const long GRANDTOTAL = 8;
++
++    //-------------------------------------------------------------------------
++
 +    /** The element is a numeric value.
 +     */
-+    const long NUMERIC = 8;
++    const long NUMERIC = 16;
  };
  
  //=============================================================================
 diff --git sc/inc/dpobject.hxx sc/inc/dpobject.hxx
-index cef08cb..8213193 100644
+index cef08cb..44c610f 100644
 --- sc/inc/dpobject.hxx
 +++ sc/inc/dpobject.hxx
 @@ -38,6 +38,8 @@
@@ -27,29 +33,31 @@
  //------------------------------------------------------------------
  
  namespace com { namespace sun { namespace star { namespace sheet {
-@@ -98,6 +100,7 @@ private:
- 											// settings
- 	ScDPSaveData*			pSaveData;
- 	String					aTableName;
-+    ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
- 	String					aTableTag;
- 	ScRange					aOutRange;
- 	ScSheetSourceDesc*		pSheetDesc;		//	for sheet data
-@@ -168,6 +171,9 @@ public:
- 	const String&		GetName() const					{ return aTableName; }
+@@ -169,6 +171,15 @@ public:
  	void				SetTag(const String& rNew);
  	const String&		GetTag() const					{ return aTableTag; }
-+    void                SetGrandTotalName(const ::rtl::OUString& rName);
-+    const ::rtl::OUString* GetGrandTotalName() const;
-+
  
++    /** 
++     *  Data description cell displays the description of a data dimension if
++     *  and only if there is only one data dimension.  It's usually located at
++     *  the upper-left corner of the table output.
++     */
++    bool                IsDataDescriptionCell(const ScAddress& rPos);
++
++    bool                IsGrandTotalCell(const ScAddress& rPos);
++
  	BOOL				IsDimNameInUse( const String& rName ) const;
  	String				GetDimName( long nDim, BOOL& rIsDataLayout );
+     BOOL                IsDuplicated( long nDim );
 diff --git sc/inc/dpsave.hxx sc/inc/dpsave.hxx
-index 8a42ead..4128405 100644
+index 8a42ead..d7ab28a 100644
 --- sc/inc/dpsave.hxx
 +++ sc/inc/dpsave.hxx
-@@ -37,6 +37,7 @@
+@@ -34,9 +34,11 @@
+ #include <tools/string.hxx>
+ #include <tools/list.hxx>
+ #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
++#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
  #include "scdllapi.h"
  #include <hash_map>
  #include <list>
@@ -57,7 +65,7 @@
  
  namespace com { namespace sun { namespace star { namespace sheet {
      struct DataPilotFieldReference;
-@@ -58,6 +59,7 @@ class ScDPSaveMember
+@@ -58,6 +60,7 @@ class ScDPSaveMember
  {
  private:
  	String		aName;
@@ -65,7 +73,7 @@
  	USHORT		nVisibleMode;
  	USHORT		nShowDetailsMode;
  
-@@ -79,6 +81,9 @@ public:
+@@ -79,6 +82,9 @@ public:
  
      void                    SetName( const String& rNew );  // used if the source member was renamed (groups)
  
@@ -75,7 +83,7 @@
  	void					WriteToSource( const com::sun::star::uno::Reference<
                                              com::sun::star::uno::XInterface>& xMember,
                                              sal_Int32 nPosition );
-@@ -87,12 +92,13 @@ public:
+@@ -87,12 +93,13 @@ public:
  };
  
  
@@ -91,7 +99,7 @@
  	BOOL		bIsDataLayout;
  	BOOL		bDupFlag;
  	USHORT		nOrientation;
-@@ -113,10 +119,12 @@ public:
+@@ -113,10 +120,12 @@ public:
  private:
      MemberHash maMemberHash;
      MemberList maMemberList;
@@ -105,7 +113,7 @@
  							~ScDPSaveDimension();
  
  	BOOL		 			operator== ( const ScDPSaveDimension& r ) const;
-@@ -143,9 +151,11 @@ public:
+@@ -143,9 +152,11 @@ public:
      USHORT                  GetFunction() const { return nFunction; }
  	void					SetUsedHierarchy(long nNew);
      long                    GetUsedHierarchy() const { return nUsedHierarchy; }
@@ -120,32 +128,43 @@
  
  	const ::com::sun::star::sheet::DataPilotFieldReference* GetReferenceValue() const	{ return pReferenceValue; }
  	void					SetReferenceValue(const ::com::sun::star::sheet::DataPilotFieldReference* pNew);
-@@ -186,6 +196,7 @@ private:
- 	USHORT		nRepeatEmptyMode;
+@@ -187,6 +198,8 @@ private:
      BOOL        bFilterButton;      // not passed to DataPilotSource
      BOOL        bDrillDown;         // not passed to DataPilotSource
-+    ::std::auto_ptr<rtl::OUString> mpDataLayoutName;
  
++    ::std::auto_ptr<rtl::OUString> mpGrandTotalName;
++
  public:
  							ScDPSaveData();
-@@ -197,7 +208,7 @@ public:
+ 							ScDPSaveData(const ScDPSaveData& r);
+@@ -196,11 +209,15 @@ public:
+ 
  	BOOL		 			operator== ( const ScDPSaveData& r ) const;
  
++    void                    SetGrandTotalName(const ::rtl::OUString& rName);
++    const ::rtl::OUString*  GetGrandTotalName() const;
++
  	const List&				GetDimensions() const { return aDimList; }
 -	void					AddDimension(ScDPSaveDimension* pDim) { aDimList.Insert(pDim, LIST_APPEND); }
 +    void					AddDimension(ScDPSaveDimension* pDim) { aDimList.Insert(pDim, LIST_APPEND); }
  
  	ScDPSaveDimension*		GetDimensionByName(const String& rName);
  	ScDPSaveDimension*		GetDataLayoutDimension();
-@@ -213,6 +224,8 @@ public:
++    ScDPSaveDimension*      GetExistingDataLayoutDimension() const;
+ 
+ 	ScDPSaveDimension*		DuplicateDimension(const String& rName);
+     ScDPSaveDimension&      DuplicateDimension(const ScDPSaveDimension& rDim);
+@@ -211,9 +228,9 @@ public:
+     void                    RemoveDimensionByName(const String& rName);
+ 
      ScDPSaveDimension*      GetInnermostDimension(USHORT nOrientation);
++    ScDPSaveDimension*      GetFirstDimension(::com::sun::star::sheet::DataPilotFieldOrientation eOrientation);
      long                    GetDataDimensionCount() const;
  
-+    void                    SetDataLayoutName(const ::rtl::OUString& rName);
-+    const ::rtl::OUString*  GetDataLayoutName() const;
- 
+-
  	void					SetPosition( ScDPSaveDimension* pDim, long nNew );
  	void					SetColumnGrand( BOOL bSet );
+ 	BOOL					GetColumnGrand() const { return BOOL(nColumnGrandMode); }
 diff --git sc/inc/dptabres.hxx sc/inc/dptabres.hxx
 index 3fb5ef8..f4a60f9 100644
 --- sc/inc/dptabres.hxx
@@ -177,7 +196,7 @@
  
  
 diff --git sc/inc/dptabsrc.hxx sc/inc/dptabsrc.hxx
-index 1afed45..094744a 100644
+index 1afed45..caa6e55 100644
 --- sc/inc/dptabsrc.hxx
 +++ sc/inc/dptabsrc.hxx
 @@ -33,6 +33,7 @@
@@ -220,16 +239,13 @@
  
  	void					SetDupCount( long nNew );
  
-@@ -152,11 +159,18 @@ public:
+@@ -152,11 +159,15 @@ public:
  	ScDPTableData*			GetData()		{ return pData; }
  	const ScDPTableData*	GetData() const	{ return pData; }
  
 +    void                    SetGrandTotalName(const ::rtl::OUString& rName);
 +    const ::rtl::OUString*  GetGrandTotalName() const;
 +
-+    void                    SetDataName(const ::rtl::OUString& rName);
-+    const ::rtl::OUString*  GetDataName() const;
-+
  	USHORT					GetOrientation(long nColumn);
  	void					SetOrientation(long nColumn, USHORT nNew);
  	long					GetPosition(long nColumn);
@@ -239,7 +255,7 @@
  	String					GetDataDimName(long nIndex);
  	BOOL					IsDataLayoutDimension(long nDim);
  	USHORT					GetDataLayoutOrientation();
-@@ -323,6 +337,8 @@ private:
+@@ -323,6 +334,8 @@ private:
  	long				nUsedHier;
  	USHORT				nFunction;			// enum GeneralFunction
  	String				aName;				// if empty, take from source
@@ -248,7 +264,7 @@
  	long				nSourceDim;			// >=0 if dup'ed
      ::com::sun::star::sheet::DataPilotFieldReference
                          aReferenceValue;    // settings for "show data as" / "displayed value"
-@@ -340,6 +356,9 @@ public:
+@@ -340,6 +353,9 @@ public:
  	ScDPDimension*			CreateCloneObject();
  	ScDPHierarchies*		GetHierarchiesObject();
  
@@ -258,7 +274,7 @@
  							// XNamed
  	virtual ::rtl::OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
  	virtual void SAL_CALL	setName( const ::rtl::OUString& aName )
-@@ -726,7 +745,7 @@ private:
+@@ -726,7 +742,7 @@ private:
  	long			nLev;
  
  	ScDPItemData	maData;
@@ -267,7 +283,7 @@
  
      sal_Int32       nPosition;          // manual sorting
  	BOOL			bVisible;
-@@ -740,6 +759,7 @@ public:
+@@ -740,6 +756,7 @@ public:
  	BOOL					IsNamedItem( const ScDPItemData& r ) const;
  	String					GetNameStr() const;
  	void					FillItemData( ScDPItemData& rData ) const;
@@ -276,20 +292,21 @@
      sal_Int32               Compare( const ScDPMember& rOther ) const;      // visible order
  
 diff --git sc/inc/unonames.hxx sc/inc/unonames.hxx
-index 18c858b..7d1f03e 100644
+index 18c858b..8e573bb 100644
 --- sc/inc/unonames.hxx
 +++ sc/inc/unonames.hxx
-@@ -557,6 +557,8 @@
+@@ -557,6 +557,9 @@
  #define SC_UNO_ROWFIELDCOUNT        "RowFieldCount"
  #define SC_UNO_COLUMNFIELDCOUNT     "ColumnFieldCount"
  #define SC_UNO_DATAFIELDCOUNT       "DataFieldCount"
 +#define SC_UNO_LAYOUTNAME           "LayoutName"
 +#define SC_UNO_FIELD_SUBTOTALNAME   "FieldSubtotalName"
++#define SC_UNO_GRANDTOTAL_NAME      "GrandTotalName"
  
  //  (preliminary:)
  #define SC_UNO_REFVALUE				"ReferenceValue"
 diff --git sc/source/core/data/dpobject.cxx sc/source/core/data/dpobject.cxx
-index 4f49665..db28f1d 100644
+index 4f49665..4ad6d29 100644
 --- sc/source/core/data/dpobject.cxx
 +++ sc/source/core/data/dpobject.cxx
 @@ -83,6 +83,7 @@ using ::com::sun::star::uno::UNO_QUERY;
@@ -300,63 +317,50 @@
  
  // -----------------------------------------------------------------------
  
-@@ -156,6 +157,7 @@ USHORT lcl_GetDataGetOrientation( const uno::Reference<sheet::XDimensionsSupplie
- ScDPObject::ScDPObject( ScDocument* pD ) :
- 	pDoc( pD ),
- 	pSaveData( NULL ),
-+    mpGrandTotalName(NULL),
- 	pSheetDesc( NULL ),
- 	pImpDesc( NULL ),
- 	pServDesc( NULL ),
-@@ -174,6 +176,7 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
-     DataObject(),
- 	pDoc( r.pDoc ),
- 	pSaveData( NULL ),
-+    mpGrandTotalName(NULL),
- 	aTableName( r.aTableName ),
- 	aTableTag( r.aTableTag ),
- 	aOutRange( r.aOutRange ),
-@@ -191,6 +194,8 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
- {
- 	if (r.pSaveData)
- 		pSaveData = new ScDPSaveData(*r.pSaveData);
-+    if (r.mpGrandTotalName.get())
-+        mpGrandTotalName.reset(new rtl::OUString(*r.mpGrandTotalName));
- 	if (r.pSheetDesc)
- 		pSheetDesc = new ScSheetSourceDesc(*r.pSheetDesc);
- 	if (r.pImpDesc)
-@@ -339,6 +344,16 @@ void ScDPObject::SetTag(const String& rNew)
+@@ -339,6 +340,31 @@ void ScDPObject::SetTag(const String& rNew)
  	aTableTag = rNew;
  }
  
-+void ScDPObject::SetGrandTotalName(const ::rtl::OUString& rName)
++bool ScDPObject::IsDataDescriptionCell(const ScAddress& rPos)
 +{
-+    mpGrandTotalName.reset(new ::rtl::OUString(rName));
++    if (!pSaveData)
++        return false;
++
++    long nDataDimCount = pSaveData->GetDataDimensionCount();
++    if (nDataDimCount != 1)
++        // There has to be exactly one data dimension for the description to 
++        // appear at top-left corner.
++        return false;
++
++    CreateOutput();
++    ScRange aTabRange = pOutput->GetOutputRange(sheet::DataPilotOutputRangeType::TABLE);
++    return (rPos == aTabRange.aStart);
 +}
 +
-+const rtl::OUString* ScDPObject::GetGrandTotalName() const
++bool ScDPObject::IsGrandTotalCell(const ScAddress& rPos)
 +{
-+    return mpGrandTotalName.get();
++    if (!pSaveData)
++        return false;
++
++    long nDataDimCount = pSaveData->GetDataDimensionCount();
++    return false;
 +}
 +
  uno::Reference<sheet::XDimensionsSupplier> ScDPObject::GetSource()
  {
  	CreateObjects();
-@@ -429,7 +444,11 @@ void ScDPObject::CreateObjects()
+@@ -429,7 +455,8 @@ void ScDPObject::CreateObjects()
  			    pData = pGroupData;
  			}
  
 -			xSource = new ScDPSource( pData );
 +            ScDPSource* pSource = new ScDPSource( pData );
-+            if (mpGrandTotalName.get())
-+                pSource->SetGrandTotalName(*mpGrandTotalName);
-+
 +			xSource = pSource;
  		}
  
  		if (pSaveData)
 diff --git sc/source/core/data/dpoutput.cxx sc/source/core/data/dpoutput.cxx
-index 6683028..70c2502 100644
+index 6683028..e7e3f71 100644
 --- sc/source/core/data/dpoutput.cxx
 +++ sc/source/core/data/dpoutput.cxx
 @@ -81,6 +81,7 @@
@@ -367,40 +371,15 @@
  using ::com::sun::star::uno::Sequence;
  using ::com::sun::star::uno::UNO_QUERY;
  using ::com::sun::star::uno::Reference;
-@@ -90,6 +91,32 @@ using ::com::sun::star::uno::makeAny;
- using ::com::sun::star::uno::Any;
- using ::rtl::OUString;
- 
-+
-+#include <stdio.h>
-+#include <string>
-+
-+namespace {
-+
-+class StackPrinter
-+{
-+public:
-+    explicit StackPrinter(const char* msg) :
-+        msMsg(msg)
-+    {
-+        fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+    }
-+
-+    ~StackPrinter()
-+    {
-+        fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+    }
-+
-+private:
-+    ::std::string msMsg;
-+};
-+
-+}
-+
- // -----------------------------------------------------------------------
- 
- //!	move to a header file
-@@ -119,7 +146,8 @@ struct ScDPOutLevelData
+@@ -98,7 +99,6 @@ using ::rtl::OUString;
+ #define DP_PROP_ORIENTATION			"Orientation"
+ #define DP_PROP_POSITION			"Position"
+ #define DP_PROP_USEDHIERARCHY		"UsedHierarchy"
+-#define DP_PROP_DATADESCR			"DataDescription"
+ #define DP_PROP_ISDATALAYOUT		"IsDataLayoutDimension"
+ #define DP_PROP_NUMBERFORMAT		"NumberFormat"
+ #define DP_PROP_FILTER				"Filter"
+@@ -119,7 +119,8 @@ struct ScDPOutLevelData
  	long								nLevel;
  	long								nDimPos;
  	uno::Sequence<sheet::MemberResult>	aResult;
@@ -410,7 +389,7 @@
  
  	ScDPOutLevelData() { nDim = nHier = nLevel = nDimPos = -1; }
  
-@@ -444,7 +472,15 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -444,7 +445,15 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  									xLevel, uno::UNO_QUERY );
  							if ( xLevNam.is() && xLevRes.is() )
  							{
@@ -427,7 +406,7 @@
  								switch ( eDimOrient )
  								{
  									case sheet::DataPilotFieldOrientation_COLUMN:
-@@ -453,6 +489,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -453,6 +462,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  										pColFields[nColFieldCount].nLevel  = nLev;
  										pColFields[nColFieldCount].nDimPos = nDimPos;
  										pColFields[nColFieldCount].aResult = xLevRes->getResults();
@@ -435,7 +414,7 @@
  										pColFields[nColFieldCount].aCaption= aCaption;
  										if (!lcl_MemberEmpty(pColFields[nColFieldCount].aResult))
  											++nColFieldCount;
-@@ -463,6 +500,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -463,6 +473,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  										pRowFields[nRowFieldCount].nLevel  = nLev;
  										pRowFields[nRowFieldCount].nDimPos = nDimPos;
  										pRowFields[nRowFieldCount].aResult = xLevRes->getResults();
@@ -443,7 +422,7 @@
  										pRowFields[nRowFieldCount].aCaption= aCaption;
  										if (!lcl_MemberEmpty(pRowFields[nRowFieldCount].aResult))
  											++nRowFieldCount;
-@@ -473,6 +511,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -473,6 +484,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  										pPageFields[nPageFieldCount].nLevel  = nLev;
  										pPageFields[nPageFieldCount].nDimPos = nDimPos;
  										pPageFields[nPageFieldCount].aResult = lcl_GetSelectedPageAsResult(xDimProp);
@@ -451,7 +430,7 @@
  										pPageFields[nPageFieldCount].aCaption= aCaption;
  										// no check on results for page fields
  										++nPageFieldCount;
-@@ -529,7 +568,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -529,7 +541,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  		try
  		{
  			uno::Any aAny = xSrcProp->getPropertyValue(
@@ -460,7 +439,7 @@
  			rtl::OUString aUStr;
  			aAny >>= aUStr;
  			aDataDescription = String( aUStr );
-@@ -606,9 +645,16 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
+@@ -606,9 +618,16 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
  								const sheet::MemberResult& rData, BOOL bColHeader, long nLevel )
  {
  	long nFlags = rData.Flags;
@@ -478,7 +457,7 @@
  	}
  	else
  	{
-@@ -1151,7 +1197,7 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
+@@ -1151,7 +1170,7 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
      for (SCCOL nColField = 0; nColField < nColFieldCount && bFilterByCol; ++nColField)
      {
          sheet::DataPilotFieldFilter filter;
@@ -487,7 +466,7 @@
  
          const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nColField].aResult;
          const sheet::MemberResult* pArray = rSequence.getConstArray();
-@@ -1168,10 +1214,15 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
+@@ -1168,10 +1187,15 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
      }
  
      // row fields
@@ -504,7 +483,7 @@
  
          const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nRowField].aResult;
          const sheet::MemberResult* pArray = rSequence.getConstArray();
-@@ -1209,8 +1260,7 @@ bool lcl_IsNamedDataField( const ScDPGetPivotDataField& rTarget, const String& r
+@@ -1209,8 +1233,7 @@ bool lcl_IsNamedDataField( const ScDPGetPivotDataField& rTarget, const String& r
  
  bool lcl_IsNamedCategoryField( const ScDPGetPivotDataField& rFilter, const ScDPOutLevelData& rField )
  {
@@ -514,7 +493,7 @@
  }
  
  bool lcl_IsCondition( const sheet::MemberResult& rResultEntry, const ScDPGetPivotDataField& rFilter )
-@@ -1761,7 +1811,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, USHORT& rOrient )
+@@ -1761,7 +1784,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, USHORT& rOrient )
  
  	//	test for row header
  
@@ -524,7 +503,7 @@
  		rOrient = sheet::DataPilotFieldOrientation_ROW;
  		long nField = nCol - nTabStartCol;
 diff --git sc/source/core/data/dpsave.cxx sc/source/core/data/dpsave.cxx
-index dbcfe30..da51178 100644
+index dbcfe30..32a909c 100644
 --- sc/source/core/data/dpsave.cxx
 +++ sc/source/core/data/dpsave.cxx
 @@ -60,6 +60,7 @@
@@ -710,75 +689,139 @@
      bFilterButton( TRUE ),
 -    bDrillDown( TRUE )
 +    bDrillDown( TRUE ),
-+	mpDataLayoutName(NULL)
++    mpGrandTotalName(NULL)
  {
  }
  
-@@ -794,13 +835,17 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
+@@ -794,7 +835,8 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
  	nIgnoreEmptyMode( r.nIgnoreEmptyMode ),
  	nRepeatEmptyMode( r.nRepeatEmptyMode ),
      bFilterButton( r.bFilterButton ),
 -    bDrillDown( r.bDrillDown )
 +    bDrillDown( r.bDrillDown ),
-+	mpDataLayoutName(NULL)
++    mpGrandTotalName(NULL)
  {
      if ( r.pDimensionData )
          pDimensionData = new ScDPDimensionSaveData( *r.pDimensionData );
-     else
-         pDimensionData = NULL;
- 
-+	if (r.mpDataLayoutName.get())
-+		mpDataLayoutName.reset(new OUString(*r.mpDataLayoutName));
+@@ -807,6 +849,9 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
+ 		ScDPSaveDimension* pNew = new ScDPSaveDimension( *(ScDPSaveDimension*)r.aDimList.GetObject(i) );
+ 		aDimList.Insert( pNew, LIST_APPEND );
+ 	}
 +
- 	long nCount = r.aDimList.Count();
- 	for (long i=0; i<nCount; i++)
- 	{
-@@ -819,6 +864,9 @@ ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r )
-         else
-             pDimensionData = NULL;
++    if (r.mpGrandTotalName.get())
++        mpGrandTotalName.reset(new OUString(*r.mpGrandTotalName));
+ }
  
-+		if (r.mpDataLayoutName.get())
-+			mpDataLayoutName.reset(new OUString(*r.mpDataLayoutName));
+ ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r )
+@@ -843,6 +888,9 @@ ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r )
+ 				new ScDPSaveDimension( *(ScDPSaveDimension*)r.aDimList.GetObject(i) );
+ 			aDimList.Insert( pNew, LIST_APPEND );
+ 		}
 +
- 		nColumnGrandMode = r.nColumnGrandMode;
- 		nRowGrandMode    = r.nRowGrandMode;
- 		nIgnoreEmptyMode = r.nIgnoreEmptyMode;
-@@ -861,6 +909,16 @@ BOOL ScDPSaveData::operator== ( const ScDPSaveData& r ) const
-         if ( !pDimensionData || !r.pDimensionData || !( *pDimensionData == *r.pDimensionData ) )
-             return FALSE;
++        if (r.mpGrandTotalName.get())
++            mpGrandTotalName.reset(new OUString(*r.mpGrandTotalName));
+ 	}
+ 	return *this;
+ }
+@@ -870,6 +918,16 @@ BOOL ScDPSaveData::operator== ( const ScDPSaveData& r ) const
+ 				*(ScDPSaveDimension*)r.aDimList.GetObject(i) ) )
+ 			return FALSE;
  
-+	if (mpDataLayoutName.get())
-+	{
-+		if (!r.mpDataLayoutName.get())
-+			return false;
-+		if (!mpDataLayoutName->equals(*r.mpDataLayoutName))
-+			return false;
-+	}
-+	else if (r.mpDataLayoutName.get())
-+		return false;
++    if (mpGrandTotalName.get())
++    {
++        if (!r.mpGrandTotalName.get())
++            return false;
++        if (!mpGrandTotalName->equals(*r.mpGrandTotalName))
++            return false;
++    }
++    else if (r.mpGrandTotalName.get())
++        return false;
 +
- 	ULONG nCount = aDimList.Count();
- 	if ( nCount != r.aDimList.Count() )
- 		return FALSE;
-@@ -1003,6 +1061,16 @@ long ScDPSaveData::GetDataDimensionCount() const
-     return nDataCount;
+ 	return TRUE;
+ }
+ 
+@@ -883,6 +941,16 @@ ScDPSaveData::~ScDPSaveData()
+     delete pDimensionData;
  }
  
-+void ScDPSaveData::SetDataLayoutName(const OUString& rName)
++void ScDPSaveData::SetGrandTotalName(const OUString& rName)
 +{
-+	mpDataLayoutName.reset(new OUString(rName));
++    mpGrandTotalName.reset(new OUString(rName));
++}
++
++const OUString* ScDPSaveData::GetGrandTotalName() const
++{
++    return mpGrandTotalName.get();
 +}
 +
-+const OUString* ScDPSaveData::GetDataLayoutName() const
+ ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const String& rName)
+ {
+ 	long nCount = aDimList.Count();
+@@ -925,6 +993,17 @@ ScDPSaveDimension* ScDPSaveData::GetNewDimensionByName(const String& rName)
+ 
+ ScDPSaveDimension* ScDPSaveData::GetDataLayoutDimension()
+ {
++    ScDPSaveDimension* pDim = GetExistingDataLayoutDimension();
++    if (pDim)
++        return pDim;
++
++	ScDPSaveDimension* pNew = new ScDPSaveDimension( String(), TRUE );
++	aDimList.Insert( pNew, LIST_APPEND );
++	return pNew;
++}
++
++ScDPSaveDimension* ScDPSaveData::GetExistingDataLayoutDimension() const
++{
+ 	long nCount = aDimList.Count();
+ 	for (long i=0; i<nCount; i++)
+ 	{
+@@ -932,9 +1011,7 @@ ScDPSaveDimension* ScDPSaveData::GetDataLayoutDimension()
+ 		if ( pDim->IsDataLayout() )
+ 			return pDim;
+ 	}
+-	ScDPSaveDimension* pNew = new ScDPSaveDimension( String(), TRUE );
+-	aDimList.Insert( pNew, LIST_APPEND );
+-	return pNew;
++    return NULL;
+ }
+ 
+ ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const String& rName)
+@@ -988,6 +1065,18 @@ ScDPSaveDimension* ScDPSaveData::GetInnermostDimension(USHORT nOrientation)
+     return pInner;      // the last matching one
+ }
+ 
++ScDPSaveDimension* ScDPSaveData::GetFirstDimension(sheet::DataPilotFieldOrientation eOrientation)
 +{
-+	return mpDataLayoutName.get();
++    long nCount = aDimList.Count();
++    for (long i = 0; i < nCount; ++i)
++    {
++        ScDPSaveDimension* pDim = static_cast<ScDPSaveDimension*>(aDimList.GetObject(i));
++        if (pDim->GetOrientation() == eOrientation && !pDim->IsDataLayout())
++            return pDim;
++    }
++    return NULL;
 +}
 +
- void ScDPSaveData::SetPosition( ScDPSaveDimension* pDim, long nNew )
+ long ScDPSaveData::GetDataDimensionCount() const
  {
- 	//	position (nNew) is counted within dimensions of the same orientation
+     long nDataCount = 0;
+@@ -1095,6 +1184,14 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
+ 			if ( nRepeatEmptyMode != SC_DPSAVEMODE_DONTKNOW )
+ 				lcl_SetBoolProperty( xSourceProp,
+ 					rtl::OUString::createFromAscii(DP_PROP_REPEATIFEMPTY), (BOOL)nRepeatEmptyMode );
++
++            const OUString* pGrandTotalName = GetGrandTotalName();
++            if (pGrandTotalName)
++            {
++                uno::Any any;
++                any <<= *pGrandTotalName;
++                xSourceProp->setPropertyValue(OUString::createFromAscii(SC_UNO_GRANDTOTAL_NAME), any);
++            }
+ 		}
+ 		catch(uno::Exception&)
+ 		{
 diff --git sc/source/core/data/dptabres.cxx sc/source/core/data/dptabres.cxx
-index c52139c..bbf6847 100644
+index c52139c..87d0698 100644
 --- sc/source/core/data/dptabres.cxx
 +++ sc/source/core/data/dptabres.cxx
 @@ -67,6 +67,7 @@ using ::std::vector;
@@ -836,7 +879,33 @@
  // -----------------------------------------------------------------------
  
  
-@@ -1204,17 +1217,25 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
+@@ -1172,6 +1185,25 @@ void ScDPResultMember::ProcessData( const vector<ScDPItemData>& aChildMembers, c
+     }
+ }
+ 
++/** 
++ * Parse subtotal string and replace all occurrences of '?' with the 
++ * caption string. 
++ */ 
++static String lcl_parseSubtotalName(const String& rSubStr, const String& rCaption)
++{
++    String aNewStr;
++    xub_StrLen n = rSubStr.Len();
++    for (xub_StrLen i = 0; i < n; ++i)
++    {
++        sal_Unicode c = rSubStr.GetChar(i);
++        if (c == sal_Unicode('?'))
++            aNewStr.Append(rCaption);
++        else
++            aNewStr.Append(c);
++    }
++    return aNewStr;
++}
++
+ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pSequences,
+ 											long& rPos, long nMeasure, BOOL bRoot,
+ 											const String* pMemberName,
+@@ -1204,17 +1236,25 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
      }
  
  	String aCaption = aName;
@@ -868,7 +937,7 @@
  
  	if ( nSize && !bRoot )					// root is overwritten by first dimension
  	{
-@@ -1277,9 +1298,39 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
+@@ -1277,9 +1317,30 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
  				if (bHasChild)
  					eForce = lcl_GetForceFunc( pParentLevel, nUserPos );
  
@@ -886,31 +955,22 @@
 +                        // single data field layout.
 +                        const OUString* pSubtotalName = pParentDim->GetSubtotalName();
 +                        if (pSubtotalName)
-+                        {    
-+                            aSubStr = *pSubtotalName;
-+                            xub_StrLen nPos = aSubStr.Search('?');
-+                            if (nPos != STRING_NOTFOUND)
-+                            {
-+                                String aNew = aSubStr.Copy(0, nPos);
-+                                aNew += aCaption;
-+                                if (nPos+1 < aSubStr.Len())
-+                                    aNew += aSubStr.Copy(nPos+1);
-+                                aSubStr = aNew;
-+                            }
-+                        }
++                            aSubStr = lcl_parseSubtotalName(*pSubtotalName, aCaption);
++                        pArray[rPos].Flags &= ~sheet::MemberResultFlags::GRANDTOTAL;
 +                    }
 +                    else
 +                    {
-+                        // root member - subtotal for multi-data field layout.
++                        // root member - subtotal (grand total?) for multi-data field layout.
 +                        const rtl::OUString* pGrandTotalName = pResultData->GetSource()->GetGrandTotalName();
 +                        if (pGrandTotalName)
 +                            aSubStr = *pGrandTotalName;
++                        pArray[rPos].Flags |= sheet::MemberResultFlags::GRANDTOTAL;
 +                    }
 +                }
  
  				pArray[rPos].Name    = rtl::OUString(aName);
  				pArray[rPos].Caption = rtl::OUString(aSubStr);
-@@ -2796,8 +2847,9 @@ void ScDPResultDimension::FillMemberResults( uno::Sequence<sheet::MemberResult>*
+@@ -2796,8 +2857,9 @@ void ScDPResultDimension::FillMemberResults( uno::Sequence<sheet::MemberResult>*
  		//	in data layout dimension, use first member with different measures/names
  		if ( bIsDataLayout )
  		{
@@ -922,7 +982,7 @@
  		}
  		else if ( pMember->IsVisible() )
 diff --git sc/source/core/data/dptabsrc.cxx sc/source/core/data/dptabsrc.cxx
-index 600eb7b..c5f254e 100644
+index 600eb7b..0f9add4 100644
 --- sc/source/core/data/dptabsrc.cxx
 +++ sc/source/core/data/dptabsrc.cxx
 @@ -83,6 +83,7 @@ using ::com::sun::star::uno::Reference;
@@ -1088,7 +1148,51 @@
              aInfo.aPageDims.reserve(nPageDimCount);
              for (i = 0; i < nPageDimCount; ++i)
                  aInfo.aPageDims.push_back(nPageDims[i]);
-@@ -1270,6 +1318,8 @@ ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) :
+@@ -1065,6 +1113,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPSource::getPropertySetInfo(
+ 														throw(uno::RuntimeException)
+ {
+ 	ScUnoGuard aGuard;
++    using beans::PropertyAttribute::READONLY;
+ 
+ 	static SfxItemPropertyMap aDPSourceMap_Impl[] =
+ 	{
+@@ -1073,6 +1122,10 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPSource::getPropertySetInfo(
+ 		{MAP_CHAR_LEN(SC_UNO_IGNOREEM),	0,	&getBooleanCppuType(),				0, 0 },		// for sheet data only
+ 		{MAP_CHAR_LEN(SC_UNO_REPEATIF),	0,	&getBooleanCppuType(),				0, 0 },		// for sheet data only
+ 		{MAP_CHAR_LEN(SC_UNO_ROWGRAND),	0,	&getBooleanCppuType(),				0, 0 },
++        {MAP_CHAR_LEN(SC_UNO_ROWFIELDCOUNT),    0, &getCppuType(static_cast<sal_Int32*>(0)), READONLY, 0 },
++        {MAP_CHAR_LEN(SC_UNO_COLUMNFIELDCOUNT), 0, &getCppuType(static_cast<sal_Int32*>(0)), READONLY, 0 },
++        {MAP_CHAR_LEN(SC_UNO_DATAFIELDCOUNT),   0, &getCppuType(static_cast<sal_Int32*>(0)), READONLY, 0 },
++        {MAP_CHAR_LEN(SC_UNO_GRANDTOTAL_NAME),  0, &getCppuType(static_cast<OUString*>(0)), 0, 0 },
+         {0,0,0,0,0,0}
+ 	};
+ 	static uno::Reference<beans::XPropertySetInfo> aRef =
+@@ -1094,6 +1147,12 @@ void SAL_CALL ScDPSource::setPropertyValue( const rtl::OUString& aPropertyName,
+ 		setIgnoreEmptyRows( lcl_GetBoolFromAny( aValue ) );
+ 	else if ( aNameStr.EqualsAscii( SC_UNO_REPEATIF ) )
+ 		setRepeatIfEmpty( lcl_GetBoolFromAny( aValue ) );
++    else if (aNameStr.EqualsAscii(SC_UNO_GRANDTOTAL_NAME))
++    {
++        OUString aName;
++        if (aValue >>= aName)
++            mpGrandTotalName.reset(new OUString(aName));
++    }
+ 	else
+ 	{
+ 		DBG_ERROR("unknown property");
+@@ -1123,6 +1182,11 @@ uno::Any SAL_CALL ScDPSource::getPropertyValue( const rtl::OUString& aPropertyNa
+         aRet <<= static_cast<sal_Int32>(nColDimCount);
+     else if ( aNameStr.EqualsAscii( SC_UNO_DATAFIELDCOUNT ) )       // read-only
+         aRet <<= static_cast<sal_Int32>(nDataDimCount);
++    else if (aNameStr.EqualsAscii(SC_UNO_GRANDTOTAL_NAME))
++    {
++        if (mpGrandTotalName.get())
++            aRet <<= *mpGrandTotalName;
++    }
+ 	else
+ 	{
+ 		DBG_ERROR("unknown property");
+@@ -1270,6 +1334,8 @@ ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) :
  	pHierarchies( NULL ),
  	nUsedHier( 0 ),
  	nFunction( SUBTOTAL_FUNC_SUM ),		// sum is default
@@ -1097,7 +1201,7 @@
  	nSourceDim( -1 ),
  	bHasSelectedPage( FALSE ),
  	pSelectedData( NULL )
-@@ -1297,6 +1347,16 @@ ScDPHierarchies* ScDPDimension::GetHierarchiesObject()
+@@ -1297,6 +1363,16 @@ ScDPHierarchies* ScDPDimension::GetHierarchiesObject()
  	return pHierarchies;
  }
  
@@ -1114,7 +1218,7 @@
  uno::Reference<container::XNameAccess> SAL_CALL ScDPDimension::getHierarchies()
  													throw(uno::RuntimeException)
  {
-@@ -1456,6 +1516,8 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetIn
+@@ -1456,6 +1532,8 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPDimension::getPropertySetIn
  		{MAP_CHAR_LEN(SC_UNO_POSITION),	0,	&getCppuType((sal_Int32*)0),				0, 0 },
  		{MAP_CHAR_LEN(SC_UNO_REFVALUE),	0,	&getCppuType((sheet::DataPilotFieldReference*)0), 0, 0 },
  		{MAP_CHAR_LEN(SC_UNO_USEDHIER),	0,	&getCppuType((sal_Int32*)0),				0, 0 },
@@ -1123,7 +1227,7 @@
          {0,0,0,0,0,0}
  	};
  	static uno::Reference<beans::XPropertySetInfo> aRef =
-@@ -1526,6 +1588,18 @@ void SAL_CALL ScDPDimension::setPropertyValue( const rtl::OUString& aPropertyNam
+@@ -1526,6 +1604,18 @@ void SAL_CALL ScDPDimension::setPropertyValue( const rtl::OUString& aPropertyNam
  		}
  		DELETEZ( pSelectedData );		// invalid after changing aSelectedPage
  	}
@@ -1142,7 +1246,7 @@
  	else
  	{
  		DBG_ERROR("unknown property");
-@@ -1585,6 +1659,10 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const rtl::OUString& aPropert
+@@ -1585,6 +1675,10 @@ uno::Any SAL_CALL ScDPDimension::getPropertyValue( const rtl::OUString& aPropert
  		else
  			aRet <<= uno::Sequence<sheet::TableFilterField>(0);
  	}
@@ -1153,7 +1257,7 @@
  	else
  	{
  		DBG_ERROR("unknown property");
-@@ -2085,7 +2163,11 @@ uno::Sequence<sheet::MemberResult> SAL_CALL ScDPLevel::getResults() throw(uno::R
+@@ -2085,7 +2179,11 @@ uno::Sequence<sheet::MemberResult> SAL_CALL ScDPLevel::getResults() throw(uno::R
  			return aRet;
  	}
  
@@ -1166,7 +1270,7 @@
  }
  
  void SAL_CALL ScDPLevel::setName( const ::rtl::OUString& /* rNewName */ ) throw(uno::RuntimeException)
-@@ -2188,6 +2270,20 @@ uno::Any SAL_CALL ScDPLevel::getPropertyValue( const rtl::OUString& aPropertyNam
+@@ -2188,6 +2286,20 @@ uno::Any SAL_CALL ScDPLevel::getPropertyValue( const rtl::OUString& aPropertyNam
  	    aRet <<= aAutoShowInfo;
  	else if ( aNameStr.EqualsAscii( SC_UNO_LAYOUT ) )
  	    aRet <<= aLayoutInfo;
@@ -1187,7 +1291,7 @@
  	else
  	{
  		DBG_ERROR("unknown property");
-@@ -2480,6 +2576,7 @@ ScDPMember::ScDPMember( ScDPSource* pSrc, long nD, long nH, long nL,
+@@ -2480,6 +2592,7 @@ ScDPMember::ScDPMember( ScDPSource* pSrc, long nD, long nH, long nL,
  	nHier( nH ),
  	nLev( nL ),
  	maData( rN, fV, bHV ),
@@ -1195,7 +1299,7 @@
      nPosition( -1 ),
  	bVisible( TRUE ),
  	bShowDet( TRUE )
-@@ -2540,6 +2637,11 @@ void ScDPMember::FillItemData( ScDPItemData& rData ) const
+@@ -2540,6 +2653,11 @@ void ScDPMember::FillItemData( ScDPItemData& rData ) const
  	rData = maData;
  }
  
@@ -1207,7 +1311,7 @@
  String ScDPMember::GetNameStr() const
  {
  	return maData.aString;
-@@ -2599,6 +2701,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPMember::getPropertySetInfo(
+@@ -2599,6 +2717,7 @@ uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDPMember::getPropertySetInfo(
  		{MAP_CHAR_LEN(SC_UNO_ISVISIBL),	0,	&getBooleanCppuType(),				0, 0 },
          {MAP_CHAR_LEN(SC_UNO_POSITION), 0,  &getCppuType((sal_Int32*)0),        0, 0 },
  		{MAP_CHAR_LEN(SC_UNO_SHOWDETA),	0,	&getBooleanCppuType(),				0, 0 },
@@ -1215,7 +1319,7 @@
          {0,0,0,0,0,0}
  	};
  	static uno::Reference<beans::XPropertySetInfo> aRef =
-@@ -2622,6 +2725,12 @@ void SAL_CALL ScDPMember::setPropertyValue( const rtl::OUString& aPropertyName,
+@@ -2622,6 +2741,12 @@ void SAL_CALL ScDPMember::setPropertyValue( const rtl::OUString& aPropertyName,
          if (aValue >>= nInt)
              setPosition( nInt );
  	}
@@ -1228,7 +1332,7 @@
  	else
  	{
  		DBG_ERROR("unknown property");
-@@ -2641,6 +2750,8 @@ uno::Any SAL_CALL ScDPMember::getPropertyValue( const rtl::OUString& aPropertyNa
+@@ -2641,6 +2766,8 @@ uno::Any SAL_CALL ScDPMember::getPropertyValue( const rtl::OUString& aPropertyNa
  		lcl_SetBoolInAny( aRet, getShowDetails() );
      else if ( aNameStr.EqualsAscii( SC_UNO_POSITION ) )
          aRet <<= (sal_Int32) getPosition();
@@ -1252,7 +1356,7 @@
  
  	return eLastErr;
 diff --git sc/source/filter/excel/xepivot.cxx sc/source/filter/excel/xepivot.cxx
-index 2a4994a..1a65747 100644
+index 2a4994a..824ea9b 100644
 --- sc/source/filter/excel/xepivot.cxx
 +++ sc/source/filter/excel/xepivot.cxx
 @@ -64,6 +64,7 @@ using ::com::sun::star::sheet::DataPilotFieldSortInfo;
@@ -1329,11 +1433,15 @@
      }
  }
  
-@@ -1306,6 +1322,11 @@ void XclExpPivotTable::SetPropertiesFromDP( const ScDPSaveData& rSaveData )
+@@ -1306,6 +1322,15 @@ void XclExpPivotTable::SetPropertiesFromDP( const ScDPSaveData& rSaveData )
      ::set_flag( maPTInfo.mnFlags, EXC_SXVIEW_COLGRAND, rSaveData.GetColumnGrand() );
      ::set_flag( maPTExtInfo.mnFlags, EXC_SXEX_DRILLDOWN, rSaveData.GetDrillDown() );
      mbFilterBtn = rSaveData.GetFilterButton();
-+    const rtl::OUString* pLayoutName = rSaveData.GetDataLayoutName();
++    const ScDPSaveDimension* pDim = rSaveData.GetExistingDataLayoutDimension();
++    if (!pDim)
++        return;
++
++    const rtl::OUString* pLayoutName = pDim->GetLayoutName();
 +    if (pLayoutName)
 +        maPTInfo.maDataName = *pLayoutName;
 +    else
@@ -1341,7 +1449,7 @@
  }
  
  void XclExpPivotTable::SetFieldPropertiesFromDim( const ScDPSaveDimension& rSaveDim )
-@@ -1413,17 +1434,21 @@ void XclExpPivotTable::Finalize()
+@@ -1413,17 +1438,21 @@ void XclExpPivotTable::Finalize()
      rnDataXclRow = rnXclRow1 + maPTInfo.mnColFields + 1;
      if( maDataFields.empty() )
          ++rnDataXclRow;
@@ -1367,7 +1475,7 @@
  }
  
  // records ----------------------------------------------------------------
-@@ -1499,14 +1524,68 @@ void XclExpPivotTable::WriteSxex( XclExpStream& rStrm ) const
+@@ -1499,14 +1528,68 @@ void XclExpPivotTable::WriteSxex( XclExpStream& rStrm ) const
      rStrm.EndRecord();
  }
  
@@ -1462,7 +1570,7 @@
      SetStrLen( nCurrLen );
  
 diff --git sc/source/filter/excel/xipivot.cxx sc/source/filter/excel/xipivot.cxx
-index 22379de..90a5667 100644
+index 22379de..74b42b1 100644
 --- sc/source/filter/excel/xipivot.cxx
 +++ sc/source/filter/excel/xipivot.cxx
 @@ -847,6 +847,11 @@ void XclImpPivotCache::ReadPivotCacheStream( XclImpStream& rStrm )
@@ -1549,15 +1657,15 @@
  
      // data fields
      for( aIt = maFiltDataFields.begin(), aEnd = maFiltDataFields.end(); aIt != aEnd; ++aIt )
-@@ -1364,12 +1379,32 @@ void XclImpPivotTable::Convert()
+@@ -1364,12 +1379,30 @@ void XclImpPivotTable::Convert()
      // create the DataPilot
      ScDPObject* pDPObj = new ScDPObject( GetDocPtr() );
      pDPObj->SetName( maPTInfo.maTableName );
 +    if (maPTInfo.maDataName.Len() > 0)
-+    {
-+        aSaveData.SetDataLayoutName(maPTInfo.maDataName);
 +        aSaveData.GetDataLayoutDimension()->SetLayoutName(maPTInfo.maDataName);
-+    }
++
++    if (maPTViewEx9Info.maGrandTotalName.Len() > 0)
++        aSaveData.SetGrandTotalName(maPTViewEx9Info.maGrandTotalName);
 +
      pDPObj->SetSaveData( aSaveData );
      pDPObj->SetSheetDesc( aDesc );
@@ -1565,8 +1673,6 @@
      pDPObj->SetAlive( TRUE );
 -    pDPObj->SetHeaderLayout( maPTAutoFormat.mnGridLayout == 0 );
 +    pDPObj->SetHeaderLayout( maPTViewEx9Info.mnGridLayout == 0 );
-+    if (maPTViewEx9Info.maGrandTotalName.Len() > 0)
-+        pDPObj->SetGrandTotalName(maPTViewEx9Info.maGrandTotalName);
 +
      GetDoc().GetDPCollection()->Insert( pDPObj );
 +    mpDPObj = pDPObj;
@@ -1583,7 +1689,7 @@
  }
  
  // ============================================================================
-@@ -1484,85 +1519,10 @@ void XclImpPivotTableManager::ConvertPivotTables()
+@@ -1484,85 +1517,10 @@ void XclImpPivotTableManager::ConvertPivotTables()
          (*aIt)->Convert();
  }
  
@@ -1673,10 +1779,18 @@
  
  // ============================================================================
 diff --git sc/source/filter/excel/xlpivot.cxx sc/source/filter/excel/xlpivot.cxx
-index c7aa590..31f33e2 100644
+index c7aa590..002f290 100644
 --- sc/source/filter/excel/xlpivot.cxx
 +++ sc/source/filter/excel/xlpivot.cxx
-@@ -579,7 +579,9 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldInfo& rInfo )
+@@ -32,6 +32,7 @@
+ #include "precompiled_sc.hxx"
+ #include "xlpivot.hxx"
+ #include "dpgroup.hxx"
++#include "dpsave.hxx"
+ #include "xistream.hxx"
+ #include "xestream.hxx"
+ #include "xestring.hxx"
+@@ -579,7 +580,9 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldInfo& rInfo )
  XclPTFieldExtInfo::XclPTFieldExtInfo() :
      mnFlags( EXC_SXVDEX_DEFAULTFLAGS ),
      mnSortField( EXC_SXVDEX_SORT_OWN ),
@@ -1687,7 +1801,7 @@
  {
  }
  
-@@ -639,10 +641,19 @@ void XclPTFieldExtInfo::SetApiLayoutMode( sal_Int32 nLayoutMode )
+@@ -639,10 +642,19 @@ void XclPTFieldExtInfo::SetApiLayoutMode( sal_Int32 nLayoutMode )
  
  XclImpStream& operator>>( XclImpStream& rStrm, XclPTFieldExtInfo& rInfo )
  {
@@ -1711,7 +1825,7 @@
  }
  
  XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldExtInfo& rInfo )
-@@ -650,9 +661,23 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldExtInfo& rInfo )
+@@ -650,9 +662,23 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTFieldExtInfo& rInfo )
      rStrm   << rInfo.mnFlags
              << rInfo.mnSortField
              << rInfo.mnShowField
@@ -1738,7 +1852,7 @@
      return rStrm;
  }
  
-@@ -923,3 +948,82 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTExtInfo& rInfo )
+@@ -923,3 +949,86 @@ XclExpStream& operator<<( XclExpStream& rStrm, const XclPTExtInfo& rInfo )
  
  // ============================================================================
  
@@ -1794,9 +1908,13 @@
 +        mnGridLayout = 0x10;
 +    }
 +
-+    const rtl::OUString* pGrandTotal = rDPObj.GetGrandTotalName();
-+    if (pGrandTotal)
-+        maGrandTotalName = *pGrandTotal;
++    const ScDPSaveData* pData = rDPObj.GetSaveData();
++    if (pData)
++    {
++        const rtl::OUString* pGrandTotal = pData->GetGrandTotalName();
++        if (pGrandTotal)
++            maGrandTotalName = *pGrandTotal;
++    }
 +}
 +
 +XclImpStream& operator>>( XclImpStream& rStrm, XclPTViewEx9Info& rInfo )
@@ -2169,23 +2287,11 @@
                  pParent->SetDPObject(pDPObj);
              }
          }
-diff --git sc/source/ui/view/cellsh3.cxx sc/source/ui/view/cellsh3.cxx
-index 507599f..f562ad5 100644
---- sc/source/ui/view/cellsh3.cxx
-+++ sc/source/ui/view/cellsh3.cxx
-@@ -188,6 +188,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
- 
- 		case SID_ENTER_STRING:
- 			{
-+                fprintf(stdout, "ScCellShell::Execute:   SID_ENTER_STRING\n");
- 				if ( pReqArgs )
- 				{
- 					String aStr( ((const SfxStringItem&)pReqArgs->
 diff --git sc/source/ui/view/dbfunc3.cxx sc/source/ui/view/dbfunc3.cxx
-index cc98745..63f25a8 100644
+index cc98745..5358a49 100644
 --- sc/source/ui/view/dbfunc3.cxx
 +++ sc/source/ui/view/dbfunc3.cxx
-@@ -91,8 +91,38 @@ using ::com::sun::star::uno::Sequence;
+@@ -91,6 +91,10 @@ using ::com::sun::star::uno::Sequence;
  using ::com::sun::star::uno::Reference;
  using ::com::sun::star::uno::UNO_QUERY;
  using ::com::sun::star::beans::XPropertySet;
@@ -2195,36 +2301,8 @@
 +using ::rtl::OUStringBuffer;
  using ::std::auto_ptr;
  
-+
-+#include <stdio.h>
-+#include <string>
-+
-+namespace {
-+
-+class StackPrinter
-+{
-+public:
-+    explicit StackPrinter(const char* msg) :
-+        msMsg(msg)
-+    {
-+        fprintf(stdout, "%s: --begin\n", msMsg.c_str());
-+    }
-+
-+    ~StackPrinter()
-+    {
-+        fprintf(stdout, "%s: --end\n", msMsg.c_str());
-+    }
-+
-+private:
-+    ::std::string msMsg;
-+};
-+
-+}
-+
  // STATIC DATA -----------------------------------------------------------
- 
- 
-@@ -1377,8 +1407,50 @@ void ScDBFunc::UngroupDataPilot()
+@@ -1377,8 +1381,43 @@ void ScDBFunc::UngroupDataPilot()
      }
  }
  
@@ -2263,28 +2341,12 @@
 +
  void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
  {
-+    StackPrinter __stack_printer__("ScDBFunc::DataPilotInput");
-+    String aPosStr;
-+    rPos.Format(aPosStr, SCA_VALID);
-+    fprintf(stdout, "ScDBFunc::DataPilotInput:   pos = '%s'  string = '%s'\n",
-+            rtl::OUStringToOString(aPosStr, RTL_TEXTENCODING_UTF8).getStr(),
-+            rtl::OUStringToOString(rString, RTL_TEXTENCODING_UTF8).getStr());
-+
 +    using namespace ::com::sun::star::sheet;
 +
      String aNewName( rString );
  
      ScDocument* pDoc = GetViewData()->GetDocument();
-@@ -1387,6 +1459,8 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
-     {
-         String aOldText;
-         pDoc->GetString( rPos.Col(), rPos.Row(), rPos.Tab(), aOldText );
-+        fprintf(stdout, "ScDBFunc::DataPilotInput:   old text = '%s'\n",
-+                rtl::OUStringToOString(aOldText, RTL_TEXTENCODING_UTF8).getStr());
- 
-         if ( aOldText == rString )
-         {
-@@ -1399,11 +1473,13 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+@@ -1399,7 +1438,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
          ScDPSaveData aData( *pDPObj->GetSaveData() );
          BOOL bChange = FALSE;
  
@@ -2293,27 +2355,19 @@
          long nField = pDPObj->GetHeaderDim( rPos, nOrient );
          if ( nField >= 0 )
          {
-             // changing a field title
-+            fprintf(stdout, "ScDBFunc::DataPilotInput:   chaning a field title (field = %ld; existing dim data = %p)\n", 
-+                    nField, aData.GetExistingDimensionData());
- 
-             if ( aData.GetExistingDimensionData() )
-             {
-@@ -1428,6 +1504,28 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+@@ -1428,19 +1467,47 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
                          nErrorId = STR_INVALIDNAME;
                  }
              }
 +            else if (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW)
 +            {
-+                fprintf(stdout, "ScDBFunc::DataPilotInput:   column or row field\n");
 +                BOOL bDataLayout = false;
 +                String aDimName = pDPObj->GetDimName(nField, bDataLayout);
-+                fprintf(stdout, "ScDBFunc::DataPilotInput:   field name = '%s'  data layout? (%d)\n",
-+                        rtl::OUStringToOString(aDimName, RTL_TEXTENCODING_UTF8).getStr(), bDataLayout);
 +
 +                if (bDataLayout)
 +                {
-+                    fprintf(stdout, "ScDBFunc::DataPilotInput:   data layout dimension header\n");
++                    aData.GetDataLayoutDimension()->SetLayoutName(rString);
++                    bChange = true;
 +                }
 +                else
 +                {
@@ -2325,10 +2379,22 @@
 +                    }
 +                }
 +            }
++        }
++        else if (pDPObj->IsDataDescriptionCell(rPos))
++        {
++            // There is only one data dimension.
++            ScDPSaveDimension* pDim = aData.GetFirstDimension(sheet::DataPilotFieldOrientation_DATA);
++            if (pDim)
++            {
++                pDim->SetLayoutName(rString);
++                bChange = true;
++            }
          }
          else
          {
-@@ -1436,11 +1534,10 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+-            // renaming a group (item)?
+-            // allow only on the item name itself - not on empty cells, not on subtotals
++            // This is not a field header.
  
              sheet::DataPilotTableHeaderData aPosData;
              pDPObj->GetHeaderPositionData(rPos, aPosData);
@@ -2336,17 +2402,22 @@
 -                 ! ( aPosData.Flags & sheet::MemberResultFlags::SUBTOTAL ) &&
 -                 aOldText.Len() )
 +
-+            if ( (aPosData.Flags & sheet::MemberResultFlags::HASMEMBER) && aOldText.Len() )
++            if ( (aPosData.Flags & MemberResultFlags::HASMEMBER) && aOldText.Len() )
              {
 -                if ( aData.GetExistingDimensionData() )
 +                if ( aData.GetExistingDimensionData() && !(aPosData.Flags & MemberResultFlags::SUBTOTAL))
                  {
                      BOOL bIsDataLayout;
                      String aDimName = pDPObj->GetDimName( aPosData.Dimension, bIsDataLayout );
-@@ -1476,6 +1573,65 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+@@ -1476,6 +1543,70 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
                              nErrorId = STR_INVALIDNAME;
                      }
                  }
++                else if ((aPosData.Flags & MemberResultFlags::GRANDTOTAL))
++                {
++                    aData.SetGrandTotalName(rString);
++                    bChange = true;
++                }
 +                else if (aPosData.Dimension >= 0 && aPosData.MemberName.getLength() > 0)
 +                {
 +                    BOOL bDataLayout = false;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]