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



Author: kyoshida
Date: Mon Nov 24 19:04:22 2008
New Revision: 14588
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14588&view=rev

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

	* patches/test/calc-dp-custom-names.diff: today's progress.


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	Mon Nov 24 19:04:22 2008
@@ -21,7 +21,7 @@
  
  //=============================================================================
 diff --git sc/inc/dpobject.hxx sc/inc/dpobject.hxx
-index cef08cb..44c610f 100644
+index cef08cb..052205e 100644
 --- sc/inc/dpobject.hxx
 +++ sc/inc/dpobject.hxx
 @@ -38,6 +38,8 @@
@@ -33,10 +33,11 @@
  //------------------------------------------------------------------
  
  namespace com { namespace sun { namespace star { namespace sheet {
-@@ -169,6 +171,15 @@ public:
+@@ -169,7 +171,16 @@ public:
  	void				SetTag(const String& rNew);
  	const String&		GetTag() const					{ return aTableTag; }
  
+-	BOOL				IsDimNameInUse( const String& rName ) 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
@@ -46,11 +47,12 @@
 +
 +    bool                IsGrandTotalCell(const ScAddress& rPos);
 +
- 	BOOL				IsDimNameInUse( const String& rName ) const;
++    bool                IsDimNameInUse(const ::rtl::OUString& rName) const;
  	String				GetDimName( long nDim, BOOL& rIsDataLayout );
      BOOL                IsDuplicated( long nDim );
+     long                GetDimCount();
 diff --git sc/inc/dpsave.hxx sc/inc/dpsave.hxx
-index 8a42ead..d7ab28a 100644
+index 8a42ead..c11f97c 100644
 --- sc/inc/dpsave.hxx
 +++ sc/inc/dpsave.hxx
 @@ -34,9 +34,11 @@
@@ -73,17 +75,18 @@
  	USHORT		nVisibleMode;
  	USHORT		nShowDetailsMode;
  
-@@ -79,6 +82,9 @@ public:
+@@ -79,6 +82,10 @@ public:
  
      void                    SetName( const String& rNew );  // used if the source member was renamed (groups)
  
 +    void                    SetLayoutName( const ::rtl::OUString& rName );
 +    const ::rtl::OUString*  GetLayoutName() const;
++    void                    RemoveLayoutName();
 +
  	void					WriteToSource( const com::sun::star::uno::Reference<
                                              com::sun::star::uno::XInterface>& xMember,
                                              sal_Int32 nPosition );
-@@ -87,12 +93,13 @@ public:
+@@ -87,12 +94,13 @@ public:
  };
  
  
@@ -99,7 +102,7 @@
  	BOOL		bIsDataLayout;
  	BOOL		bDupFlag;
  	USHORT		nOrientation;
-@@ -113,10 +120,12 @@ public:
+@@ -113,10 +121,12 @@ public:
  private:
      MemberHash maMemberHash;
      MemberList maMemberList;
@@ -113,7 +116,7 @@
  							~ScDPSaveDimension();
  
  	BOOL		 			operator== ( const ScDPSaveDimension& r ) const;
-@@ -143,9 +152,11 @@ public:
+@@ -143,9 +153,14 @@ public:
      USHORT                  GetFunction() const { return nFunction; }
  	void					SetUsedHierarchy(long nNew);
      long                    GetUsedHierarchy() const { return nUsedHierarchy; }
@@ -121,14 +124,17 @@
 -	const String&			GetLayoutName() const;
 -	BOOL					HasLayoutName() const;
 +
-+	void					SetLayoutName(const ::rtl::OUString& rName);
-+	const ::rtl::OUString*	GetLayoutName() const;
++    void                    SetLayoutName(const ::rtl::OUString& rName);
++    const ::rtl::OUString*  GetLayoutName() const;
++    void                    RemoveLayoutName();
 +    void                    SetSubtotalName(const ::rtl::OUString& rName);
 +    const ::rtl::OUString*  GetSubtotalName() const;
++
++    bool                    IsMemberNameInUse(const ::rtl::OUString& rName) const;
  
  	const ::com::sun::star::sheet::DataPilotFieldReference* GetReferenceValue() const	{ return pReferenceValue; }
  	void					SetReferenceValue(const ::com::sun::star::sheet::DataPilotFieldReference* pNew);
-@@ -187,6 +198,8 @@ private:
+@@ -187,6 +202,8 @@ private:
      BOOL        bFilterButton;      // not passed to DataPilotSource
      BOOL        bDrillDown;         // not passed to DataPilotSource
  
@@ -137,7 +143,7 @@
  public:
  							ScDPSaveData();
  							ScDPSaveData(const ScDPSaveData& r);
-@@ -196,11 +209,15 @@ public:
+@@ -196,11 +213,15 @@ public:
  
  	BOOL		 			operator== ( const ScDPSaveData& r ) const;
  
@@ -154,19 +160,16 @@
  
  	ScDPSaveDimension*		DuplicateDimension(const String& rName);
      ScDPSaveDimension&      DuplicateDimension(const ScDPSaveDimension& rDim);
-@@ -211,9 +228,9 @@ public:
+@@ -211,6 +232,7 @@ public:
      void                    RemoveDimensionByName(const String& rName);
  
      ScDPSaveDimension*      GetInnermostDimension(USHORT nOrientation);
 +    ScDPSaveDimension*      GetFirstDimension(::com::sun::star::sheet::DataPilotFieldOrientation eOrientation);
      long                    GetDataDimensionCount() 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
+index 3fb5ef8..60ad93e 100644
 --- sc/inc/dptabres.hxx
 +++ sc/inc/dptabres.hxx
 @@ -41,6 +41,7 @@
@@ -182,7 +185,7 @@
  	long				GetMeasureCount() const		{ return nMeasCount; }
  	ScSubTotalFunc		GetMeasureFunction(long nMeasure) const;
 -	String				GetMeasureString(long nMeasure, BOOL bForce, ScSubTotalFunc eForceFunc) const;
-+	String				GetMeasureString(long nMeasure, BOOL bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
++    String              GetMeasureString(long nMeasure, BOOL bForce, ScSubTotalFunc eForceFunc, bool& rbTotalResult) const;
  	String				GetMeasureDimensionName(long nMeasure) const;
  	const ::com::sun::star::sheet::DataPilotFieldReference& GetMeasureRefVal(long nMeasure) const;
  	USHORT				GetMeasureRefOrient(long nMeasure) const;
@@ -196,7 +199,7 @@
  
  
 diff --git sc/inc/dptabsrc.hxx sc/inc/dptabsrc.hxx
-index 1afed45..caa6e55 100644
+index 1afed45..9f696da 100644
 --- sc/inc/dptabsrc.hxx
 +++ sc/inc/dptabsrc.hxx
 @@ -33,6 +33,7 @@
@@ -216,7 +219,7 @@
 -private:
  	ScDPTableData*			pData;				// data source
 -	ScDPDimensions*			pDimensions;		// api objects
-+	ScDPDimensions*	pDimensions;		// api objects
++    ScDPDimensions*         pDimensions;        // api objects
  												// settings:
  	long					nColDims[SC_DAPI_MAXFIELDS];
  	long					nRowDims[SC_DAPI_MAXFIELDS];
@@ -306,7 +309,7 @@
  //  (preliminary:)
  #define SC_UNO_REFVALUE				"ReferenceValue"
 diff --git sc/source/core/data/dpobject.cxx sc/source/core/data/dpobject.cxx
-index 4f49665..4ad6d29 100644
+index 4f49665..17bf84c 100644
 --- sc/source/core/data/dpobject.cxx
 +++ sc/source/core/data/dpobject.cxx
 @@ -83,6 +83,7 @@ using ::com::sun::star::uno::UNO_QUERY;
@@ -355,10 +358,60 @@
  
 -			xSource = new ScDPSource( pData );
 +            ScDPSource* pSource = new ScDPSource( pData );
-+			xSource = pSource;
++            xSource = pSource;
  		}
  
  		if (pSaveData)
+@@ -673,23 +700,33 @@ void ScDPObject::GetDrillDownData(const ScAddress& rPos, Sequence< Sequence<Any>
+     rTableData = xDrillDownData->getDrillDownData(filters);
+ }
+ 
+-BOOL ScDPObject::IsDimNameInUse( const String& rName ) const
++bool ScDPObject::IsDimNameInUse(const OUString& rName) const
+ {
+-	if ( xSource.is() )
+-	{
+-		uno::Reference<container::XNameAccess> xDimsName = xSource->getDimensions();
+-		if ( xDimsName.is() )
+-		{
+-            rtl::OUString aCompare( rName );
+-            uno::Sequence<rtl::OUString> aNames = xDimsName->getElementNames();
+-            long nCount = aNames.getLength();
+-            const rtl::OUString* pArr = aNames.getConstArray();
+-            for (long nPos=0; nPos<nCount; nPos++)
+-                if ( pArr[nPos] == aCompare )            //! ignore case
+-                    return TRUE;
+-		}
+-	}
+-	return FALSE;   // not found
++    if (!xSource.is())
++        return false;
++
++    Reference<container::XNameAccess> xDims = xSource->getDimensions();
++    Sequence<OUString> aDimNames = xDims->getElementNames();
++    sal_Int32 n = aDimNames.getLength();
++    for (sal_Int32 i = 0; i < n; ++i)
++    {
++        const OUString& rDimName = aDimNames[i];
++        if (rDimName.equalsIgnoreAsciiCase(rName))
++            return true;
++
++        Reference<beans::XPropertySet> xPropSet(xDims->getByName(rDimName), UNO_QUERY);
++        if (!xPropSet.is())
++            continue;
++
++        Any any = xPropSet->getPropertyValue(OUString::createFromAscii(SC_UNO_LAYOUTNAME));
++        OUString aLayoutName;
++        if (any >>= aLayoutName)
++        {
++            if (aLayoutName.equalsIgnoreAsciiCase(rName))
++                return true;
++        }
++    }
++    return false;
+ }
+ 
+ String ScDPObject::GetDimName( long nDim, BOOL& rIsDataLayout )
 diff --git sc/source/core/data/dpoutput.cxx sc/source/core/data/dpoutput.cxx
 index 6683028..e7e3f71 100644
 --- sc/source/core/data/dpoutput.cxx
@@ -503,7 +556,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..32a909c 100644
+index dbcfe30..bde214a 100644
 --- sc/source/core/data/dpsave.cxx
 +++ sc/source/core/data/dpsave.cxx
 @@ -60,6 +60,7 @@
@@ -535,7 +588,7 @@
  }
  
  ScDPSaveMember::ScDPSaveMember(SvStream& rStream)
-@@ -186,6 +191,16 @@ void ScDPSaveMember::SetName( const String& rNew )
+@@ -186,6 +191,21 @@ void ScDPSaveMember::SetName( const String& rNew )
      aName = rNew;
  }
  
@@ -549,10 +602,15 @@
 +    return mpLayoutName.get();
 +}
 +
++void ScDPSaveMember::RemoveLayoutName()
++{
++    mpLayoutName.reset(NULL);
++}
++
  void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMember, sal_Int32 nPosition )
  {
  	//	nothing to do?
-@@ -206,6 +221,18 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb
+@@ -206,6 +226,18 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb
  			lcl_SetBoolProperty( xMembProp,
  					rtl::OUString::createFromAscii(DP_PROP_SHOWDETAILS), (BOOL)nShowDetailsMode );
  
@@ -571,7 +629,7 @@
          if ( nPosition >= 0 )
          {
              try
-@@ -224,8 +251,9 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb
+@@ -224,8 +256,9 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb
  
  ScDPSaveDimension::ScDPSaveDimension(const String& rName, BOOL bDataLayout) :
  	aName( rName ),
@@ -582,7 +640,7 @@
  	bIsDataLayout( bDataLayout ),
  	bDupFlag( FALSE ),
  	nOrientation( sheet::DataPilotFieldOrientation_HIDDEN ),
-@@ -244,6 +272,8 @@ ScDPSaveDimension::ScDPSaveDimension(const String& rName, BOOL bDataLayout) :
+@@ -244,6 +277,8 @@ ScDPSaveDimension::ScDPSaveDimension(const String& rName, BOOL bDataLayout) :
  
  ScDPSaveDimension::ScDPSaveDimension(const ScDPSaveDimension& r) :
  	aName( r.aName ),
@@ -591,7 +649,7 @@
  	bIsDataLayout( r.bIsDataLayout ),
  	bDupFlag( r.bDupFlag ),
  	nOrientation( r.nOrientation ),
-@@ -284,14 +314,14 @@ ScDPSaveDimension::ScDPSaveDimension(const ScDPSaveDimension& r) :
+@@ -284,14 +319,14 @@ ScDPSaveDimension::ScDPSaveDimension(const ScDPSaveDimension& r) :
          pLayoutInfo = new sheet::DataPilotFieldLayoutInfo( *(r.pLayoutInfo) );
      else
          pLayoutInfo = NULL;
@@ -610,7 +668,7 @@
  }
  
  ScDPSaveDimension::ScDPSaveDimension(SvStream& rStream)
-@@ -334,7 +364,6 @@ ScDPSaveDimension::ScDPSaveDimension(SvStream& rStream)
+@@ -334,7 +369,6 @@ ScDPSaveDimension::ScDPSaveDimension(SvStream& rStream)
      pSortInfo = NULL;
      pAutoShowInfo = NULL;
      pLayoutInfo = NULL;
@@ -618,7 +676,7 @@
  	pSelectedPage = NULL;
  }
  
-@@ -376,7 +405,6 @@ ScDPSaveDimension::~ScDPSaveDimension()
+@@ -376,7 +410,6 @@ ScDPSaveDimension::~ScDPSaveDimension()
      delete pSortInfo;
      delete pAutoShowInfo;
      delete pLayoutInfo;
@@ -626,7 +684,7 @@
  	delete pSelectedPage;
      delete [] pSubTotalFuncs;
  }
-@@ -488,25 +516,24 @@ void ScDPSaveDimension::SetUsedHierarchy(long nNew)
+@@ -488,25 +521,45 @@ void ScDPSaveDimension::SetUsedHierarchy(long nNew)
  	nUsedHierarchy = nNew;
  }
  
@@ -646,24 +704,45 @@
 -	else
 -		pLayoutName = NULL;
 +	return mpSubtotalName.get();
-+}
-+
-+void ScDPSaveDimension::SetLayoutName(const OUString& rName)
-+{
-+	mpLayoutName.reset(new OUString(rName));
  }
  
 -const String& ScDPSaveDimension::GetLayoutName() const
-+const OUString* ScDPSaveDimension::GetLayoutName() const
++bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const
  {
 -	if (pLayoutName)
 -		return *pLayoutName;
 -	return aName;
++    MemberList::const_iterator itr = maMemberList.begin(), itrEnd = maMemberList.end();
++    for (; itr != itrEnd; ++itr)
++    {
++        const ScDPSaveMember* pMem = *itr;
++        if (rName.equalsIgnoreAsciiCase(pMem->GetName()))
++            return true;
++
++        const OUString* pLayoutName = pMem->GetLayoutName();
++        if (pLayoutName && rName.equalsIgnoreAsciiCase(*pLayoutName))
++            return true;
++    }
++    return false;
++}
++
++void ScDPSaveDimension::SetLayoutName(const OUString& rName)
++{
++    mpLayoutName.reset(new OUString(rName));
++}
++
++const OUString* ScDPSaveDimension::GetLayoutName() const
++{
 +	return mpLayoutName.get();
++}
++
++void ScDPSaveDimension::RemoveLayoutName()
++{
++    mpLayoutName.reset(NULL);
  }
  
  void ScDPSaveDimension::SetReferenceValue(const sheet::DataPilotFieldReference* pNew)
-@@ -642,6 +669,19 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
+@@ -642,6 +695,19 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
  		{
  			aAny <<= aFilter;
  			xDimProp->setPropertyValue( rtl::OUString::createFromAscii(DP_PROP_FILTER), aAny );
@@ -673,17 +752,17 @@
 +                xDimProp->setPropertyValue(rtl::OUString::createFromAscii(SC_UNO_LAYOUTNAME), aAny);
 +            }
 +
-+			const OUString* pSubTotalName = GetSubtotalName();
-+			if (pSubTotalName)
-+			{
-+				// Custom subtotal name, with '?' being replaced by the visible field name later.
-+				aAny <<= *pSubTotalName;
-+				xDimProp->setPropertyValue(OUString::createFromAscii(SC_UNO_FIELD_SUBTOTALNAME), aAny);
-+			}
++            const OUString* pSubTotalName = GetSubtotalName();
++            if (pSubTotalName)
++            {
++                // Custom subtotal name, with '?' being replaced by the visible field name later.
++                aAny <<= *pSubTotalName;
++                xDimProp->setPropertyValue(OUString::createFromAscii(SC_UNO_FIELD_SUBTOTALNAME), aAny);
++            }
  		}
  		catch ( beans::UnknownPropertyException& )
  		{
-@@ -784,7 +824,8 @@ ScDPSaveData::ScDPSaveData() :
+@@ -784,7 +850,8 @@ ScDPSaveData::ScDPSaveData() :
  	nIgnoreEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
      nRepeatEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
      bFilterButton( TRUE ),
@@ -693,7 +772,7 @@
  {
  }
  
-@@ -794,7 +835,8 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
+@@ -794,7 +861,8 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
  	nIgnoreEmptyMode( r.nIgnoreEmptyMode ),
  	nRepeatEmptyMode( r.nRepeatEmptyMode ),
      bFilterButton( r.bFilterButton ),
@@ -703,7 +782,7 @@
  {
      if ( r.pDimensionData )
          pDimensionData = new ScDPDimensionSaveData( *r.pDimensionData );
-@@ -807,6 +849,9 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
+@@ -807,6 +875,9 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
  		ScDPSaveDimension* pNew = new ScDPSaveDimension( *(ScDPSaveDimension*)r.aDimList.GetObject(i) );
  		aDimList.Insert( pNew, LIST_APPEND );
  	}
@@ -713,7 +792,7 @@
  }
  
  ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r )
-@@ -843,6 +888,9 @@ ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r )
+@@ -843,6 +914,9 @@ ScDPSaveData& ScDPSaveData::operator= ( const ScDPSaveData& r )
  				new ScDPSaveDimension( *(ScDPSaveDimension*)r.aDimList.GetObject(i) );
  			aDimList.Insert( pNew, LIST_APPEND );
  		}
@@ -723,7 +802,7 @@
  	}
  	return *this;
  }
-@@ -870,6 +918,16 @@ BOOL ScDPSaveData::operator== ( const ScDPSaveData& r ) const
+@@ -870,6 +944,16 @@ BOOL ScDPSaveData::operator== ( const ScDPSaveData& r ) const
  				*(ScDPSaveDimension*)r.aDimList.GetObject(i) ) )
  			return FALSE;
  
@@ -740,7 +819,7 @@
  	return TRUE;
  }
  
-@@ -883,6 +941,16 @@ ScDPSaveData::~ScDPSaveData()
+@@ -883,6 +967,16 @@ ScDPSaveData::~ScDPSaveData()
      delete pDimensionData;
  }
  
@@ -757,7 +836,7 @@
  ScDPSaveDimension* ScDPSaveData::GetDimensionByName(const String& rName)
  {
  	long nCount = aDimList.Count();
-@@ -925,6 +993,17 @@ ScDPSaveDimension* ScDPSaveData::GetNewDimensionByName(const String& rName)
+@@ -925,6 +1019,17 @@ ScDPSaveDimension* ScDPSaveData::GetNewDimensionByName(const String& rName)
  
  ScDPSaveDimension* ScDPSaveData::GetDataLayoutDimension()
  {
@@ -775,7 +854,7 @@
  	long nCount = aDimList.Count();
  	for (long i=0; i<nCount; i++)
  	{
-@@ -932,9 +1011,7 @@ ScDPSaveDimension* ScDPSaveData::GetDataLayoutDimension()
+@@ -932,9 +1037,7 @@ ScDPSaveDimension* ScDPSaveData::GetDataLayoutDimension()
  		if ( pDim->IsDataLayout() )
  			return pDim;
  	}
@@ -786,7 +865,7 @@
  }
  
  ScDPSaveDimension* ScDPSaveData::DuplicateDimension(const String& rName)
-@@ -988,6 +1065,18 @@ ScDPSaveDimension* ScDPSaveData::GetInnermostDimension(USHORT nOrientation)
+@@ -988,6 +1091,18 @@ ScDPSaveDimension* ScDPSaveData::GetInnermostDimension(USHORT nOrientation)
      return pInner;      // the last matching one
  }
  
@@ -805,7 +884,7 @@
  long ScDPSaveData::GetDataDimensionCount() const
  {
      long nDataCount = 0;
-@@ -1095,6 +1184,14 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
+@@ -1095,6 +1210,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 );
@@ -2288,7 +2367,7 @@
              }
          }
 diff --git sc/source/ui/view/dbfunc3.cxx sc/source/ui/view/dbfunc3.cxx
-index cc98745..5358a49 100644
+index cc98745..13a52c6 100644
 --- sc/source/ui/view/dbfunc3.cxx
 +++ sc/source/ui/view/dbfunc3.cxx
 @@ -91,6 +91,10 @@ using ::com::sun::star::uno::Sequence;
@@ -2302,7 +2381,7 @@
  using ::std::auto_ptr;
  
  // STATIC DATA -----------------------------------------------------------
-@@ -1377,8 +1381,43 @@ void ScDBFunc::UngroupDataPilot()
+@@ -1377,123 +1381,303 @@ void ScDBFunc::UngroupDataPilot()
      }
  }
  
@@ -2346,137 +2425,339 @@
      String aNewName( rString );
  
      ScDocument* pDoc = GetViewData()->GetDocument();
-@@ -1399,7 +1438,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
-         ScDPSaveData aData( *pDPObj->GetSaveData() );
-         BOOL bChange = FALSE;
+     ScDPObject* pDPObj = pDoc->GetDPAtCursor( rPos.Col(), rPos.Row(), rPos.Tab() );
+-    if ( pDPObj )
++    if (!pDPObj)
++        return;
++
++    String aOldText;
++    pDoc->GetString( rPos.Col(), rPos.Row(), rPos.Tab(), aOldText );
++
++    if ( aOldText == rString )
+     {
+-        String aOldText;
+-        pDoc->GetString( rPos.Col(), rPos.Row(), rPos.Tab(), aOldText );
++        // nothing to do: silently exit
++        return;
++    }
  
--        USHORT nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
-+        USHORT nOrient = DataPilotFieldOrientation_HIDDEN;
-         long nField = pDPObj->GetHeaderDim( rPos, nOrient );
-         if ( nField >= 0 )
+-        if ( aOldText == rString )
++    USHORT nErrorId = 0;
++
++    ScDPSaveData aData( *pDPObj->GetSaveData() );
++    BOOL bChange = FALSE;
++
++    USHORT nOrient = DataPilotFieldOrientation_HIDDEN;
++    long nField = pDPObj->GetHeaderDim( rPos, nOrient );
++    if ( nField >= 0 )
++    {
++        // changing a field title
++        if ( aData.GetExistingDimensionData() )
          {
-@@ -1428,19 +1467,47 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
-                         nErrorId = STR_INVALIDNAME;
-                 }
-             }
-+            else if (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW)
+-            // nothing to do: silently exit
+-            return;
+-        }
++            // only group dimensions can be renamed
+ 
+-        USHORT nErrorId = 0;
++            ScDPDimensionSaveData* pDimData = aData.GetDimensionData();
++            ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aOldText );
++            if ( pGroupDim )
 +            {
-+                BOOL bDataLayout = false;
-+                String aDimName = pDPObj->GetDimName(nField, bDataLayout);
-+
-+                if (bDataLayout)
++                // valid name: not empty, no existing dimension (group or other)
++                if ( rString.Len() && !pDPObj->IsDimNameInUse(rString) )
 +                {
-+                    aData.GetDataLayoutDimension()->SetLayoutName(rString);
-+                    bChange = true;
++                    pGroupDim->Rename( aNewName );
+ 
+-        ScDPSaveData aData( *pDPObj->GetSaveData() );
+-        BOOL bChange = FALSE;
++                    // also rename in SaveData to preserve the field settings
++                    ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aOldText );
++                    pSaveDim->SetName( aNewName );
+ 
+-        USHORT nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+-        long nField = pDPObj->GetHeaderDim( rPos, nOrient );
+-        if ( nField >= 0 )
++                    bChange = TRUE;
 +                }
 +                else
++                    nErrorId = STR_INVALIDNAME;
++            }
++        }
++        else if (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW)
+         {
+-            // changing a field title
++            BOOL bDataLayout = false;
++            String aDimName = pDPObj->GetDimName(nField, bDataLayout);
++            ScDPSaveDimension* pDim = bDataLayout ? aData.GetDataLayoutDimension() : aData.GetDimensionByName(aDimName);
++            if (pDim)
++            {
++                if (rString.Len())
 +                {
-+                    ScDPSaveDimension* pSaveDim = aData.GetDimensionByName(aDimName);
-+                    if (pSaveDim)
++                    if (rString.EqualsIgnoreCaseAscii(aDimName))
++                    {    
++                        pDim->RemoveLayoutName();
++                        bChange = true;
++                    }
++                    else if (!pDPObj->IsDimNameInUse(rString))
 +                    {
-+                        pSaveDim->SetLayoutName(rString);
++                        pDim->SetLayoutName(rString);
 +                        bChange = true;
 +                    }
++                    else
++                        nErrorId = STR_INVALIDNAME;
 +                }
++                else
++                    nErrorId = STR_INVALIDNAME;
 +            }
 +        }
-+        else if (pDPObj->IsDataDescriptionCell(rPos))
++    }
++    else if (pDPObj->IsDataDescriptionCell(rPos))
++    {
++        // There is only one data dimension.
++        ScDPSaveDimension* pDim = aData.GetFirstDimension(sheet::DataPilotFieldOrientation_DATA);
++        if (pDim)
 +        {
-+            // There is only one data dimension.
-+            ScDPSaveDimension* pDim = aData.GetFirstDimension(sheet::DataPilotFieldOrientation_DATA);
-+            if (pDim)
++            if (rString.Len())
 +            {
-+                pDim->SetLayoutName(rString);
-+                bChange = true;
++                if (rString.EqualsIgnoreCaseAscii(pDim->GetName()))
++                {
++                    pDim->RemoveLayoutName();
++                    bChange = true;
++                }
++                else if (!pDPObj->IsDimNameInUse(rString))
++                {
++                    pDim->SetLayoutName(rString);
++                    bChange = true;
++                }
++                else
++                    nErrorId = STR_INVALIDNAME;
 +            }
-         }
-         else
-         {
++            else
++                nErrorId = STR_INVALIDNAME;
++        }
++    }
++    else
++    {
++        // This is not a field header.
++        sheet::DataPilotTableHeaderData aPosData;
++        pDPObj->GetHeaderPositionData(rPos, aPosData);
+ 
+-            if ( aData.GetExistingDimensionData() )
++        if ( (aPosData.Flags & MemberResultFlags::HASMEMBER) && aOldText.Len() )
++        {
++            if ( aData.GetExistingDimensionData() && !(aPosData.Flags & MemberResultFlags::SUBTOTAL))
+             {
+-                // only group dimensions can be renamed
++                BOOL bIsDataLayout;
++                String aDimName = pDPObj->GetDimName( aPosData.Dimension, bIsDataLayout );
+ 
+                 ScDPDimensionSaveData* pDimData = aData.GetDimensionData();
+-                ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aOldText );
++                ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aDimName );
+                 if ( pGroupDim )
+                 {
+-                    // valid name: not empty, no existing dimension (group or other)
+-                    if ( aNewName.Len() && !pDPObj->IsDimNameInUse( aNewName ) )
++                    // valid name: not empty, no existing group in this dimension
++                    //! ignore case?
++                    if ( aNewName.Len() && !pGroupDim->GetNamedGroup( aNewName ) )
+                     {
+-                        pGroupDim->Rename( aNewName );
++                        ScDPSaveGroupItem* pGroup = pGroupDim->GetNamedGroupAcc( aOldText );
++                        if ( pGroup )
++                            pGroup->Rename( aNewName );     // rename the existing group
++                        else
++                        {
++                            // create a new group to replace the automatic group
++                            ScDPSaveGroupItem aGroup( aNewName );
++                            aGroup.AddElement( aOldText );
++                            pGroupDim->AddGroupItem( aGroup );
++                        }
+ 
+-                        // also rename in SaveData to preserve the field settings
+-                        ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aOldText );
+-                        pSaveDim->SetName( aNewName );
++                        // in both cases also adjust savedata, to preserve member settings (show details)
++                        ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aDimName );
++                        ScDPSaveMember* pSaveMember = pSaveDim->GetExistingMemberByName( aOldText );
++                        if ( pSaveMember )
++                            pSaveMember->SetName( aNewName );
+ 
+                         bChange = TRUE;
+                     }
+                     else
+                         nErrorId = STR_INVALIDNAME;
+-                }
++                 }
+             }
+-        }
+-        else
+-        {
 -            // 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);
+-
+-            sheet::DataPilotTableHeaderData aPosData;
+-            pDPObj->GetHeaderPositionData(rPos, aPosData);
 -            if ( ( aPosData.Flags & sheet::MemberResultFlags::HASMEMBER ) &&
 -                 ! ( aPosData.Flags & sheet::MemberResultFlags::SUBTOTAL ) &&
 -                 aOldText.Len() )
-+
-+            if ( (aPosData.Flags & MemberResultFlags::HASMEMBER) && aOldText.Len() )
++            else if ((aPosData.Flags & MemberResultFlags::GRANDTOTAL))
              {
 -                if ( aData.GetExistingDimensionData() )
-+                if ( aData.GetExistingDimensionData() && !(aPosData.Flags & MemberResultFlags::SUBTOTAL))
++                aData.SetGrandTotalName(rString);
++                bChange = true;
++            }
++            else if (aPosData.Dimension >= 0 && aPosData.MemberName.getLength() > 0)
++            {
++                BOOL bDataLayout = false;
++                String aDimName = pDPObj->GetDimName(static_cast<long>(aPosData.Dimension), bDataLayout);
++                if (bDataLayout)
                  {
-                     BOOL bIsDataLayout;
-                     String aDimName = pDPObj->GetDimName( aPosData.Dimension, bIsDataLayout );
-@@ -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;
-+                    String aDimName = pDPObj->GetDimName(static_cast<long>(aPosData.Dimension), bDataLayout);
-+                    if (bDataLayout)
+-                    BOOL bIsDataLayout;
+-                    String aDimName = pDPObj->GetDimName( aPosData.Dimension, bIsDataLayout );
++                    // data dimension
++                    do
 +                    {
-+                        // data dimension
-+                        do
-+                        {
-+                            if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
-+                                break;
++                        if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
++                            break;
 +
-+                            ScDPSaveDimension* pDim = aData.GetDimensionByName(aPosData.MemberName);
-+                            if (!pDim)
-+                                break;
++                        ScDPSaveDimension* pDim = aData.GetDimensionByName(aPosData.MemberName);
++                        if (!pDim)
++                            break;
+ 
+-                    ScDPDimensionSaveData* pDimData = aData.GetDimensionData();
+-                    ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aDimName );
+-                    if ( pGroupDim )
++                        if (!rString.Len())
++                        {
++                            nErrorId = STR_INVALIDNAME;
++                            break;
++                        }
 +
++                        if (aPosData.MemberName.equalsIgnoreAsciiCase(rString))
++                        {
++                            pDim->RemoveLayoutName();
++                            bChange = true;
++                        }
++                        else if (!pDPObj->IsDimNameInUse(rString))
++                        {
 +                            pDim->SetLayoutName(rString);
 +                            bChange = true;
 +                        }
-+                        while (false);
++                        else
++                            nErrorId = STR_INVALIDNAME;
 +                    }
-+                    else
-+                    {
-+                        // field member
-+                        do
-+                        {
-+                            ScDPSaveDimension* pDim = aData.GetDimensionByName(aDimName);
-+                            if (!pDim)
-+                                break;
-+    
-+                            ScDPSaveMember* pMem = pDim->GetExistingMemberByName(aPosData.MemberName);
-+                            if (!pMem)
++                    while (false);
++                }
++                else
++                {
++                    // field member
++                    do
+                     {
+-                        // valid name: not empty, no existing group in this dimension
+-                        //! ignore case?
+-                        if ( aNewName.Len() && !pGroupDim->GetNamedGroup( aNewName ) )
++                        ScDPSaveDimension* pDim = aData.GetDimensionByName(aDimName);
++                        if (!pDim)
++                            break;
++
++                        ScDPSaveMember* pMem = pDim->GetExistingMemberByName(aPosData.MemberName);
++                        if (!pMem)
++                            break;
++
++                        if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
+                         {
+-                            ScDPSaveGroupItem* pGroup = pGroupDim->GetNamedGroupAcc( aOldText );
+-                            if ( pGroup )
+-                                pGroup->Rename( aNewName );     // rename the existing group
++                            // Change subtotal only when the table has one data dimension.
++                            if (aData.GetDataDimensionCount() > 1)
 +                                break;
 +
-+                            if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
++                            const OUString* pLayoutName = pMem->GetLayoutName();
++                            String aMemberName;
++                            if (pLayoutName)
++                                aMemberName = *pLayoutName;
+                             else
+-                            {
+-                                // create a new group to replace the automatic group
+-                                ScDPSaveGroupItem aGroup( aNewName );
+-                                aGroup.AddElement( aOldText );
+-                                pGroupDim->AddGroupItem( aGroup );
+-                            }
++                                aMemberName = aPosData.MemberName;
+ 
+-                            // in both cases also adjust savedata, to preserve member settings (show details)
+-                            ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aDimName );
+-                            ScDPSaveMember* pSaveMember = pSaveDim->GetExistingMemberByName( aOldText );
+-                            if ( pSaveMember )
+-                                pSaveMember->SetName( aNewName );
+-
+-                            bChange = TRUE;
++                            String aNew = lcl_replaceMemberNameInSubtotal(rString, aMemberName);
++                            pDim->SetSubtotalName(aNew);
++                            bChange = true;
+                         }
+                         else
+-                            nErrorId = STR_INVALIDNAME;
++                        {
++                            // Check to make sure the member name isn't
++                            // already used.
++                            if (rString.Len())
 +                            {
-+                                // Change subtotal only when the table has one data dimension.
-+                                if (aData.GetDataDimensionCount() > 1)
-+                                    break;
-+
-+                                const OUString* pLayoutName = pMem->GetLayoutName();
-+                                String aMemberName;
-+                                if (pLayoutName)
-+                                    aMemberName = *pLayoutName;
++                                if (rString.EqualsIgnoreCaseAscii(pMem->GetName()))
++                                {
++                                    pMem->RemoveLayoutName();
++                                    bChange = true;
++                                }
++                                else if (!pDim->IsMemberNameInUse(rString))
++                                {
++                                    pMem->SetLayoutName(rString);
++                                    bChange = true;
++                                }
 +                                else
-+                                    aMemberName = aPosData.MemberName;
-+
-+                                String aNew = lcl_replaceMemberNameInSubtotal(rString, aMemberName);
-+                                pDim->SetSubtotalName(aNew);
++                                    nErrorId = STR_INVALIDNAME;
 +                            }
 +                            else
-+                            {
-+                                pMem->SetLayoutName(rString);
-+                            }
-+                            bChange = true;
++                                nErrorId = STR_INVALIDNAME;
 +                        }
-+                        while (false);
-+                    }
-+                }
+                     }
++                    while (false);
+                 }
              }
          }
++    }
+ 
+-        if ( bChange )
+-        {
+-            // apply changes
+-            ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+-            ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+-            pNewObj->SetSaveData( aData );
+-            aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
+-            delete pNewObj;
+-        }
+-        else
+-        {
+-            if ( !nErrorId )
+-                nErrorId = STR_ERR_DATAPILOT_INPUT;
+-            ErrorMessage( nErrorId );
+-        }
++    if ( bChange )
++    {
++        // apply changes
++        ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
++        ScDPObject* pNewObj = new ScDPObject( *pDPObj );
++        pNewObj->SetSaveData( aData );
++        aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
++        delete pNewObj;
++    }
++    else
++    {
++        if ( !nErrorId )
++            nErrorId = STR_ERR_DATAPILOT_INPUT;
++        ErrorMessage( nErrorId );
+     }
+ }
  



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