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



Author: kyoshida
Date: Thu Nov 20 05:54:56 2008
New Revision: 14553
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14553&view=rev

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

	* patches/test/calc-dp-custom-names.diff: Today's progress.  Now Calc
	allows in-place editing of field and field member names.  Editing of
	subtotal name is also allowed if there is only one data dimension.


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	Thu Nov 20 05:54:56 2008
@@ -1,3 +1,19 @@
+diff --git offapi/com/sun/star/sheet/MemberResultFlags.idl offapi/com/sun/star/sheet/MemberResultFlags.idl
+index 788673c..b9dbd61 100644
+--- offapi/com/sun/star/sheet/MemberResultFlags.idl
++++ offapi/com/sun/star/sheet/MemberResultFlags.idl
+@@ -59,6 +59,11 @@ published constants MemberResultFlags
+ 	 */
+ 	const long CONTINUE = 4;
+ 
++    //-------------------------------------------------------------------------
++
++    /** The element is a numeric value.
++     */
++    const long NUMERIC = 8;
+ };
+ 
+ //=============================================================================
 diff --git sc/inc/dpobject.hxx sc/inc/dpobject.hxx
 index cef08cb..8213193 100644
 --- sc/inc/dpobject.hxx
@@ -30,7 +46,7 @@
  	BOOL				IsDimNameInUse( const String& rName ) const;
  	String				GetDimName( long nDim, BOOL& rIsDataLayout );
 diff --git sc/inc/dpsave.hxx sc/inc/dpsave.hxx
-index 8a42ead..f979268 100644
+index 8a42ead..4128405 100644
 --- sc/inc/dpsave.hxx
 +++ sc/inc/dpsave.hxx
 @@ -37,6 +37,7 @@
@@ -130,15 +146,6 @@
  
  	void					SetPosition( ScDPSaveDimension* pDim, long nNew );
  	void					SetColumnGrand( BOOL bSet );
-@@ -237,6 +250,8 @@ public:
-     const ScDPDimensionSaveData* GetExistingDimensionData() const   { return pDimensionData; }
-     ScDPDimensionSaveData*  GetDimensionData();     // create if not there
-     void                    SetDimensionData( const ScDPDimensionSaveData* pNew );      // copied
-+
-+    void test();
- };
- 
- 
 diff --git sc/inc/dptabres.hxx sc/inc/dptabres.hxx
 index 3fb5ef8..f4a60f9 100644
 --- sc/inc/dptabres.hxx
@@ -349,7 +356,7 @@
  
  		if (pSaveData)
 diff --git sc/source/core/data/dpoutput.cxx sc/source/core/data/dpoutput.cxx
-index 6683028..4223a53 100644
+index 6683028..70c2502 100644
 --- sc/source/core/data/dpoutput.cxx
 +++ sc/source/core/data/dpoutput.cxx
 @@ -81,6 +81,7 @@
@@ -360,7 +367,40 @@
  using ::com::sun::star::uno::Sequence;
  using ::com::sun::star::uno::UNO_QUERY;
  using ::com::sun::star::uno::Reference;
-@@ -119,7 +120,8 @@ struct ScDPOutLevelData
+@@ -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
  	long								nLevel;
  	long								nDimPos;
  	uno::Sequence<sheet::MemberResult>	aResult;
@@ -370,7 +410,7 @@
  
  	ScDPOutLevelData() { nDim = nHier = nLevel = nDimPos = -1; }
  
-@@ -444,7 +446,15 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -444,7 +472,15 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  									xLevel, uno::UNO_QUERY );
  							if ( xLevNam.is() && xLevRes.is() )
  							{
@@ -387,7 +427,7 @@
  								switch ( eDimOrient )
  								{
  									case sheet::DataPilotFieldOrientation_COLUMN:
-@@ -453,6 +463,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -453,6 +489,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  										pColFields[nColFieldCount].nLevel  = nLev;
  										pColFields[nColFieldCount].nDimPos = nDimPos;
  										pColFields[nColFieldCount].aResult = xLevRes->getResults();
@@ -395,7 +435,7 @@
  										pColFields[nColFieldCount].aCaption= aCaption;
  										if (!lcl_MemberEmpty(pColFields[nColFieldCount].aResult))
  											++nColFieldCount;
-@@ -463,6 +474,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -463,6 +500,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  										pRowFields[nRowFieldCount].nLevel  = nLev;
  										pRowFields[nRowFieldCount].nDimPos = nDimPos;
  										pRowFields[nRowFieldCount].aResult = xLevRes->getResults();
@@ -403,7 +443,7 @@
  										pRowFields[nRowFieldCount].aCaption= aCaption;
  										if (!lcl_MemberEmpty(pRowFields[nRowFieldCount].aResult))
  											++nRowFieldCount;
-@@ -473,6 +485,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -473,6 +511,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  										pPageFields[nPageFieldCount].nLevel  = nLev;
  										pPageFields[nPageFieldCount].nDimPos = nDimPos;
  										pPageFields[nPageFieldCount].aResult = lcl_GetSelectedPageAsResult(xDimProp);
@@ -411,7 +451,7 @@
  										pPageFields[nPageFieldCount].aCaption= aCaption;
  										// no check on results for page fields
  										++nPageFieldCount;
-@@ -529,7 +542,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
+@@ -529,7 +568,7 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
  		try
  		{
  			uno::Any aAny = xSrcProp->getPropertyValue(
@@ -420,7 +460,25 @@
  			rtl::OUString aUStr;
  			aAny >>= aUStr;
  			aDataDescription = String( aUStr );
-@@ -1151,7 +1164,7 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
+@@ -606,9 +645,16 @@ void ScDPOutput::HeaderCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
+ 								const sheet::MemberResult& rData, BOOL bColHeader, long nLevel )
+ {
+ 	long nFlags = rData.Flags;
++
++    rtl::OUStringBuffer aCaptionBuf;
++    if (!(nFlags & sheet::MemberResultFlags::NUMERIC))
++        // This caption is not a number.  Make sure it won't get parsed as one.
++        aCaptionBuf.append(sal_Unicode('\''));
++    aCaptionBuf.append(rData.Caption);
++
+ 	if ( nFlags & sheet::MemberResultFlags::HASMEMBER )
+ 	{
+-		pDoc->SetString( nCol, nRow, nTab, rData.Caption );
++        pDoc->SetString( nCol, nRow, nTab, aCaptionBuf.makeStringAndClear() );
+ 	}
+ 	else
+ 	{
+@@ -1151,7 +1197,7 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
      for (SCCOL nColField = 0; nColField < nColFieldCount && bFilterByCol; ++nColField)
      {
          sheet::DataPilotFieldFilter filter;
@@ -429,7 +487,7 @@
  
          const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nColField].aResult;
          const sheet::MemberResult* pArray = rSequence.getConstArray();
-@@ -1168,10 +1181,15 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
+@@ -1168,10 +1214,15 @@ bool ScDPOutput::GetDataResultPositionData(vector<sheet::DataPilotFieldFilter>&
      }
  
      // row fields
@@ -446,7 +504,7 @@
  
          const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nRowField].aResult;
          const sheet::MemberResult* pArray = rSequence.getConstArray();
-@@ -1209,8 +1227,7 @@ bool lcl_IsNamedDataField( const ScDPGetPivotDataField& rTarget, const String& r
+@@ -1209,8 +1260,7 @@ bool lcl_IsNamedDataField( const ScDPGetPivotDataField& rTarget, const String& r
  
  bool lcl_IsNamedCategoryField( const ScDPGetPivotDataField& rFilter, const ScDPOutLevelData& rField )
  {
@@ -456,7 +514,7 @@
  }
  
  bool lcl_IsCondition( const sheet::MemberResult& rResultEntry, const ScDPGetPivotDataField& rFilter )
-@@ -1761,7 +1778,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, USHORT& rOrient )
+@@ -1761,7 +1811,7 @@ long ScDPOutput::GetHeaderDim( const ScAddress& rPos, USHORT& rOrient )
  
  	//	test for row header
  
@@ -466,7 +524,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..9563f85 100644
+index dbcfe30..da51178 100644
 --- sc/source/core/data/dpsave.cxx
 +++ sc/source/core/data/dpsave.cxx
 @@ -60,6 +60,7 @@
@@ -639,7 +697,7 @@
 +			const OUString* pSubTotalName = GetSubtotalName();
 +			if (pSubTotalName)
 +			{
-+				// Custon subtotal name, with '?' being replaced by the visible field name later.
++				// Custom subtotal name, with '?' being replaced by the visible field name later.
 +				aAny <<= *pSubTotalName;
 +				xDimProp->setPropertyValue(OUString::createFromAscii(SC_UNO_FIELD_SUBTOTALNAME), aAny);
 +			}
@@ -720,7 +778,7 @@
  {
  	//	position (nNew) is counted within dimensions of the same orientation
 diff --git sc/source/core/data/dptabres.cxx sc/source/core/data/dptabres.cxx
-index c52139c..23da8b8 100644
+index c52139c..bbf6847 100644
 --- sc/source/core/data/dptabres.cxx
 +++ sc/source/core/data/dptabres.cxx
 @@ -67,6 +67,7 @@ using ::std::vector;
@@ -778,7 +836,7 @@
  // -----------------------------------------------------------------------
  
  
-@@ -1204,6 +1217,13 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
+@@ -1204,17 +1217,25 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
      }
  
  	String aCaption = aName;
@@ -786,13 +844,31 @@
 +    {
 +        const OUString* pLayoutName = pMemberDesc->GetLayoutName();
 +        if (pLayoutName)
++        {
 +            aCaption = *pLayoutName;
++            bIsNumeric = false; // layout name is always non-numeric.
++        }
 +    }
 +
  	if ( pMemberCaption )					// use pMemberCaption if != NULL
  		aCaption = *pMemberCaption;
  	if (!aCaption.Len())
-@@ -1277,9 +1297,39 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
+ 		aCaption = ScGlobal::GetRscString(STR_EMPTYDATA);
+ 
+-    if ( !bIsNumeric )
+-    {
+-        // add a "'" character so a string isn't parsed as value in the output cell
+-        //! have a separate bit in Flags (MemberResultFlags) instead?
+-        aCaption.Insert( (sal_Unicode) '\'', 0 );
+-    }
++    if (bIsNumeric)
++        pArray[rPos].Flags |= sheet::MemberResultFlags::NUMERIC;
++    else
++        pArray[rPos].Flags &= ~sheet::MemberResultFlags::NUMERIC;
+ 
+ 	if ( nSize && !bRoot )					// root is overwritten by first dimension
+ 	{
+@@ -1277,9 +1298,39 @@ void ScDPResultMember::FillMemberResults( uno::Sequence<sheet::MemberResult>* pS
  				if (bHasChild)
  					eForce = lcl_GetForceFunc( pParentLevel, nUserPos );
  
@@ -834,7 +910,7 @@
  
  				pArray[rPos].Name    = rtl::OUString(aName);
  				pArray[rPos].Caption = rtl::OUString(aSubStr);
-@@ -2796,8 +2846,9 @@ void ScDPResultDimension::FillMemberResults( uno::Sequence<sheet::MemberResult>*
+@@ -2796,8 +2847,9 @@ void ScDPResultDimension::FillMemberResults( uno::Sequence<sheet::MemberResult>*
  		//	in data layout dimension, use first member with different measures/names
  		if ( bIsDataLayout )
  		{
@@ -1162,28 +1238,15 @@
  	{
  		DBG_ERROR("unknown property");
 diff --git sc/source/filter/excel/read.cxx sc/source/filter/excel/read.cxx
-index 34495e1..af1a672 100644
+index a868e17..27f0446 100644
 --- sc/source/filter/excel/read.cxx
 +++ sc/source/filter/excel/read.cxx
-@@ -1171,12 +1171,7 @@ FltError ImportExcel8::Read( void )
- 
-         pProgress.reset();
- 
--#if 0
--        // Excel documents look much better without this call; better in the
--        // sense that the row heights are identical to the original heights in
--        // Excel.
-         AdjustRowHeight();
--#endif
-         PostDocLoad();
- 
-         pD->CalcAfterLoad();
-@@ -1192,6 +1187,9 @@ FltError ImportExcel8::Read( void )
+@@ -1187,6 +1187,9 @@ FltError ImportExcel8::Read( void )
              eLastErr = SCWARN_IMPORT_ROW_OVERFLOW;
          else if( rAddrConv.IsColTruncated() )
              eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
 +
-+        if( GetBiff() == EXC_BIFF8 )
++        if( GetBiff() == EXC_BIFF8 )                         
 +            GetPivotTableManager().MaybeRefreshPivotTables();
      }
  
@@ -1399,10 +1462,10 @@
      SetStrLen( nCurrLen );
  
 diff --git sc/source/filter/excel/xipivot.cxx sc/source/filter/excel/xipivot.cxx
-index 6c7c378..49d35d1 100644
+index 22379de..90a5667 100644
 --- sc/source/filter/excel/xipivot.cxx
 +++ sc/source/filter/excel/xipivot.cxx
-@@ -848,6 +848,11 @@ void XclImpPivotCache::ReadPivotCacheStream( XclImpStream& rStrm )
+@@ -847,6 +847,11 @@ void XclImpPivotCache::ReadPivotCacheStream( XclImpStream& rStrm )
      }
  }
  
@@ -1414,7 +1477,7 @@
  // ============================================================================
  // Pivot table
  // ============================================================================
-@@ -883,6 +888,8 @@ void XclImpPTItem::ConvertItem( ScDPSaveDimension& rSaveDim ) const
+@@ -882,6 +887,8 @@ void XclImpPTItem::ConvertItem( ScDPSaveDimension& rSaveDim ) const
          ScDPSaveMember& rMember = *rSaveDim.GetMemberByName( *pItemName );
          rMember.SetIsVisible( !::get_flag( maItemInfo.mnFlags, EXC_SXVI_HIDDEN ) );
          rMember.SetShowDetails( !::get_flag( maItemInfo.mnFlags, EXC_SXVI_HIDEDETAIL ) );
@@ -1423,7 +1486,7 @@
      }
  }
  
-@@ -1044,7 +1051,7 @@ ScDPSaveDimension* XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) con
+@@ -1043,7 +1050,7 @@ ScDPSaveDimension* XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) con
      // visible name
      if( const String* pVisName = maFieldInfo.GetVisName() )
          if( pVisName->Len() > 0 )
@@ -1432,7 +1495,7 @@
  
      // subtotal function(s)
      XclPTSubtotalVec aSubtotalVec;
-@@ -1076,6 +1083,10 @@ ScDPSaveDimension* XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) con
+@@ -1075,6 +1082,10 @@ ScDPSaveDimension* XclImpPTField::ConvertRCPField( ScDPSaveData& rSaveData ) con
      // grouping info
      pCacheField->ConvertGroupField( rSaveData, mrPTable.GetVisFieldNames() );
  
@@ -1443,7 +1506,7 @@
      return &rSaveDim;
  }
  
-@@ -1100,7 +1111,7 @@ void XclImpPTField::ConvertDataFieldInfo( ScDPSaveDimension& rSaveDim, const Xcl
+@@ -1099,7 +1110,7 @@ void XclImpPTField::ConvertDataFieldInfo( ScDPSaveDimension& rSaveDim, const Xcl
      // visible name
      if( const String* pVisName = rDataInfo.GetVisName() )
          if( pVisName->Len() > 0 )
@@ -1452,7 +1515,7 @@
  
      // aggregation function
      rSaveDim.SetFunction( static_cast< USHORT >( rDataInfo.GetApiAggFunc() ) );
-@@ -1135,7 +1146,8 @@ void XclImpPTField::ConvertItems( ScDPSaveDimension& rSaveDim ) const
+@@ -1134,7 +1145,8 @@ void XclImpPTField::ConvertItems( ScDPSaveDimension& rSaveDim ) const
  
  XclImpPivotTable::XclImpPivotTable( const XclImpRoot& rRoot ) :
      XclImpRoot( rRoot ),
@@ -1462,7 +1525,7 @@
  {
  }
  
-@@ -1299,7 +1311,7 @@ void XclImpPivotTable::ReadSxex( XclImpStream& rStrm )
+@@ -1298,7 +1310,7 @@ void XclImpPivotTable::ReadSxex( XclImpStream& rStrm )
  
  void XclImpPivotTable::ReadSxViewEx9( XclImpStream& rStrm )
  {
@@ -1471,7 +1534,7 @@
  }
  
  // ----------------------------------------------------------------------------
-@@ -1337,11 +1349,14 @@ void XclImpPivotTable::Convert()
+@@ -1336,11 +1348,14 @@ void XclImpPivotTable::Convert()
          if( const XclImpPTField* pField = GetField( *aIt ) )
              pField->ConvertPageField( aSaveData );
  
@@ -1486,7 +1549,7 @@
  
      // data fields
      for( aIt = maFiltDataFields.begin(), aEnd = maFiltDataFields.end(); aIt != aEnd; ++aIt )
-@@ -1365,12 +1380,32 @@ void XclImpPivotTable::Convert()
+@@ -1364,12 +1379,32 @@ void XclImpPivotTable::Convert()
      // create the DataPilot
      ScDPObject* pDPObj = new ScDPObject( GetDocPtr() );
      pDPObj->SetName( maPTInfo.maTableName );
@@ -1520,7 +1583,7 @@
  }
  
  // ============================================================================
-@@ -1485,85 +1520,10 @@ void XclImpPivotTableManager::ConvertPivotTables()
+@@ -1484,85 +1519,10 @@ void XclImpPivotTableManager::ConvertPivotTables()
          (*aIt)->Convert();
  }
  
@@ -2106,3 +2169,243 @@
                  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
+--- sc/source/ui/view/dbfunc3.cxx
++++ sc/source/ui/view/dbfunc3.cxx
+@@ -91,8 +91,38 @@ 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;
++using ::com::sun::star::container::XNameAccess;
++using ::com::sun::star::sheet::XDimensionsSupplier;
++using ::rtl::OUString;
++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()
+     }
+ }
+ 
++OUString lcl_replaceMemberNameInSubtotal(const OUString& rSubtotal, const OUString& rMemberName)
++{
++    sal_Int32 n = rSubtotal.getLength();
++    const sal_Unicode* p = rSubtotal.getStr();
++    OUStringBuffer aBuf, aWordBuf;
++    for (sal_Int32 i = 0; i < n; ++i)
++    {
++        sal_Unicode c = p[i];
++        if (c == sal_Unicode(' '))
++        {
++            OUString aWord = aWordBuf.makeStringAndClear();
++            if (aWord.equals(rMemberName))
++                aBuf.append(sal_Unicode('?'));
++            else
++                aBuf.append(aWord);
++            aBuf.append(c);
++        }
++        else
++            aWordBuf.append(c);
++    }
++
++    if (aWordBuf.getLength() > 0)
++    {
++        OUString aWord = aWordBuf.makeStringAndClear();
++        if (aWord.equals(rMemberName))
++            aBuf.append(sal_Unicode('?'));
++        else
++            aBuf.append(aWord);
++    }
++
++    return aBuf.makeStringAndClear();
++}
++
+ 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 )
+         ScDPSaveData aData( *pDPObj->GetSaveData() );
+         BOOL bChange = FALSE;
+ 
+-        USHORT nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
++        USHORT nOrient = DataPilotFieldOrientation_HIDDEN;
+         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 )
+                         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");
++                }
++                else
++                {
++                    ScDPSaveDimension* pSaveDim = aData.GetDimensionByName(aDimName);
++                    if (pSaveDim)
++                    {
++                        pSaveDim->SetLayoutName(rString);
++                        bChange = true;
++                    }
++                }
++            }
+         }
+         else
+         {
+@@ -1436,11 +1534,10 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+ 
+             sheet::DataPilotTableHeaderData aPosData;
+             pDPObj->GetHeaderPositionData(rPos, aPosData);
+-            if ( ( aPosData.Flags & sheet::MemberResultFlags::HASMEMBER ) &&
+-                 ! ( aPosData.Flags & sheet::MemberResultFlags::SUBTOTAL ) &&
+-                 aOldText.Len() )
++
++            if ( (aPosData.Flags & sheet::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 )
+                             nErrorId = STR_INVALIDNAME;
+                     }
+                 }
++                else if (aPosData.Dimension >= 0 && aPosData.MemberName.getLength() > 0)
++                {
++                    BOOL bDataLayout = false;
++                    String aDimName = pDPObj->GetDimName(static_cast<long>(aPosData.Dimension), bDataLayout);
++                    if (bDataLayout)
++                    {
++                        // data dimension
++                        do
++                        {
++                            if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
++                                break;
++
++                            ScDPSaveDimension* pDim = aData.GetDimensionByName(aPosData.MemberName);
++                            if (!pDim)
++                                break;
++
++                            pDim->SetLayoutName(rString);
++                            bChange = true;
++                        }
++                        while (false);
++                    }
++                    else
++                    {
++                        // field member
++                        do
++                        {
++                            ScDPSaveDimension* pDim = aData.GetDimensionByName(aDimName);
++                            if (!pDim)
++                                break;
++    
++                            ScDPSaveMember* pMem = pDim->GetExistingMemberByName(aPosData.MemberName);
++                            if (!pMem)
++                                break;
++
++                            if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
++                            {
++                                // 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;
++                                else
++                                    aMemberName = aPosData.MemberName;
++
++                                String aNew = lcl_replaceMemberNameInSubtotal(rString, aMemberName);
++                                pDim->SetSubtotalName(aNew);
++                            }
++                            else
++                            {
++                                pMem->SetLayoutName(rString);
++                            }
++                            bChange = true;
++                        }
++                        while (false);
++                    }
++                }
+             }
+         }
+ 



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