summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-16 21:29:26 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-22 14:02:00 -0500
commit8cf371314ae1d664b4a749865cfe5ed31398b3ed (patch)
tree7dbf362485d9491c71242d21fac61d2715225d79 /sc
parentc5f0c11604bc64a0e6c4dbcdd7a4e077f834f407 (diff)
Don't up the duplicate count when launching the options dialog.
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/dbgui/fieldwnd.cxx3
-rw-r--r--sc/source/ui/dbgui/pvlaydlg.cxx41
-rw-r--r--sc/source/ui/inc/fieldwnd.hxx2
-rw-r--r--sc/source/ui/inc/pvlaydlg.hxx2
4 files changed, 39 insertions, 9 deletions
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx
index 4607b2c9f1e8..f68dd87f5d6c 100644
--- a/sc/source/ui/dbgui/fieldwnd.cxx
+++ b/sc/source/ui/dbgui/fieldwnd.cxx
@@ -289,11 +289,10 @@ void ScDPFieldControlBase::ClearFields()
maFieldNames.clear();
}
-void ScDPFieldControlBase::SetFieldText( const rtl::OUString& rText, size_t nIndex )
+void ScDPFieldControlBase::SetFieldText(const rtl::OUString& rText, size_t nIndex, sal_uInt8 nDupCount)
{
if( IsExistingIndex( nIndex ) )
{
- sal_uInt8 nDupCount = GetNextDupCount(rText);
maFieldNames[nIndex] = FieldName(rText, true, nDupCount);
Redraw();
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
index 16cb5311f007..2a4cbd9bb127 100644
--- a/sc/source/ui/dbgui/pvlaydlg.cxx
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -1027,24 +1027,30 @@ void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
case TYPE_DATA:
{
+ ScDPFuncData& rFuncData = *aDataArr[nFieldIndex];
AbstractScDPFunctionDlg* pDlg = pFact->CreateScDPFunctionDlg(
this, RID_SCDLG_DPDATAFIELD,
- aLabelDataArr, *pData, *(*pArr)[nFieldIndex] );
+ aLabelDataArr, *pData, rFuncData);
if ( pDlg->Execute() == RET_OK )
{
- (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask = pDlg->GetFuncMask();
- (*pArr)[nFieldIndex]->maFieldRef = pDlg->GetFieldRef();
+ bool bFuncChanged = rFuncData.mnFuncMask != pDlg->GetFuncMask();
+ rFuncData.mnFuncMask = pData->mnFuncMask = pDlg->GetFuncMask();
+ rFuncData.maFieldRef = pDlg->GetFieldRef();
- ScDPLabelData* p = GetLabelData(aDataArr[nFieldIndex]->mnCol);
+ if (bFuncChanged)
+ // Get the new duplicate count since the function has changed.
+ rFuncData.mnDupCount = GetNextDupCount(aDataArr, rFuncData, nFieldIndex);
+
+ ScDPLabelData* p = GetLabelData(rFuncData.mnCol);
OUString aStr = p->maLayoutName;
if (aStr.isEmpty())
{
// Layout name is not available. Use default name.
- aStr = GetFuncString (aDataArr[nFieldIndex]->mnFuncMask);
+ aStr = GetFuncString (rFuncData.mnFuncMask);
aStr += p->maName;
}
- aWndData.SetFieldText( aStr, nFieldIndex );
+ aWndData.SetFieldText(aStr, nFieldIndex, rFuncData.mnDupCount);
}
delete pDlg;
}
@@ -1657,6 +1663,29 @@ void ScDPLayoutDlg::GetOtherDataArrays(
}
}
+sal_uInt8 ScDPLayoutDlg::GetNextDupCount(
+ const ScDPFuncDataVec& rArr, const ScDPFuncData& rData, size_t nDataIndex) const
+{
+ sal_uInt8 nDupCount = 0;
+ bool bFound = false;
+ for (size_t i = 0, n = rArr.size(); i < n; ++i)
+ {
+ const ScDPFuncData& r = *rArr[i];
+ if (i == nDataIndex)
+ // Skip itself.
+ continue;
+
+ if (r.mnCol != rData.mnCol || r.mnFuncMask != rData.mnFuncMask)
+ continue;
+
+ bFound = true;
+ if (r.mnDupCount > nDupCount)
+ nDupCount = r.mnDupCount;
+ }
+
+ return bFound ? nDupCount + 1 : 0;
+}
+
//----------------------------------------------------------------------------
void ScDPLayoutDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
diff --git a/sc/source/ui/inc/fieldwnd.hxx b/sc/source/ui/inc/fieldwnd.hxx
index d8d50a827b95..9c7d704f11e3 100644
--- a/sc/source/ui/inc/fieldwnd.hxx
+++ b/sc/source/ui/inc/fieldwnd.hxx
@@ -152,7 +152,7 @@ public:
/** Removes all fields. */
void ClearFields();
/** Changes the text on an existing field. */
- void SetFieldText( const rtl::OUString& rText, size_t nIndex );
+ void SetFieldText(const rtl::OUString& rText, size_t nIndex, sal_uInt8 nDupCount);
/** Returns the text of an existing field. */
rtl::OUString GetFieldText( size_t nIndex ) const;
diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx
index f79f6f140c93..b44db8e63484 100644
--- a/sc/source/ui/inc/pvlaydlg.hxx
+++ b/sc/source/ui/inc/pvlaydlg.hxx
@@ -240,6 +240,8 @@ private:
void GetOtherDataArrays(
ScDPFieldType eType, ScDPFuncDataVec*& rpArr1, ScDPFuncDataVec*& rpArr2);
+ sal_uInt8 GetNextDupCount(const ScDPFuncDataVec& rArr, const ScDPFuncData& rData, size_t nDataIndex) const;
+
// Handler
DECL_LINK( ClickHdl, PushButton * );
DECL_LINK( SelAreaHdl, ListBox * );