summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-04-29 16:06:20 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-04-29 16:15:48 +0100
commit74706c4057e027898022ac42de210302cdc92d99 (patch)
tree373d4bbf472cc5de2cff20d0e9feaae3896b5ed8 /cui
parent7368b6ca3f61e750765f42e97d0a00e10fcac516 (diff)
on using 'add' color button, don't frighten with an error
that the name already exists if the user didn't use the edit entry yet. Just always, like the gradient one, put up the dialog to enter a name, use the entry text if that name isn't taken, and generate a new one if its is. Change-Id: Ibd3d37db73ecdbae7998884d3397cbc2bc6b7c3f
Diffstat (limited to 'cui')
-rw-r--r--cui/source/tabpages/tpcolor.cxx84
-rw-r--r--cui/source/tabpages/tpgradnt.cxx12
2 files changed, 55 insertions, 41 deletions
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 4347ab3d623a..3c3ecf215de1 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -685,55 +685,68 @@ IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl)
IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl)
{
- vcl::Window *pWindow = this;
- while( pWindow )
- {
- pWindow = pWindow->GetParent();
- }
-
- ResMgr& rMgr = CUI_MGR();
- OUString aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
+ OUString aNewName( SVX_RES( RID_SVXSTR_COLOR ) );
+ OUString aDesc( CUI_RES( RID_SVXSTR_DESC_COLOR ) );
OUString aName( m_pEdtName->GetText() );
+
long nCount = pColorList->Count();
- bool bDifferent = true;
+ long j = 1;
// check if name is already existing
- for ( long i = 0; i < nCount && bDifferent; i++ )
- if ( aName == pColorList->GetColor( i )->GetName() )
- bDifferent = false;
+ while (1)
+ {
+ bool bDifferent = true;
+
+ for( long i = 0; i < nCount && bDifferent; i++ )
+ if ( aName == pColorList->GetColor( i )->GetName() )
+ bDifferent = false;
+
+ if (bDifferent)
+ break;
- // if yes, it is repeated and a new name is demanded
- if ( !bDifferent )
+ aName = aNewName;
+ aName += " ";
+ aName += OUString::number( j++ );
+ }
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ boost::scoped_ptr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc ));
+ ScopedVclPtr<MessageDialog> pWarnBox;
+ sal_uInt16 nError = 1;
+
+ while (pDlg->Execute() == RET_OK)
{
- ScopedVclPtrInstance<MessageDialog> aWarningBox( GetParentDialog()
- ,"DuplicateNameDialog"
- ,"cui/ui/queryduplicatedialog.ui");
- aWarningBox->Execute();
+ pDlg->GetName( aName );
- SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- boost::scoped_ptr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc ));
- bool bLoop = true;
+ bool bDifferent = true;
- while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
+ for (long i = 0; i < nCount && bDifferent; ++i)
{
- pDlg->GetName( aName );
- bDifferent = true;
+ if( aName == pColorList->GetColor( i )->GetName() )
+ bDifferent = false;
+ }
- for( long i = 0; i < nCount && bDifferent; i++ )
- {
- if( aName == pColorList->GetColor( i )->GetName() )
- bDifferent = false;
- }
+ if (bDifferent)
+ {
+ nError = 0;
+ break;
+ }
- if( bDifferent )
- bLoop = false;
- else
- aWarningBox->Execute();
+ if( !pWarnBox )
+ {
+ pWarnBox.reset(new MessageDialog( GetParentDialog()
+ ,"DuplicateNameDialog"
+ ,"cui/ui/queryduplicatedialog.ui"));
}
+
+ if( pWarnBox->Execute() != RET_OK )
+ break;
}
- // if not existing the entry is entered
- if( bDifferent )
+ pDlg.reset();
+ pWarnBox.reset();
+
+ if (!nError)
{
XColorEntry* pEntry = new XColorEntry( aCurrentColor, aName );
@@ -749,6 +762,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl)
SelectColorLBHdl_Impl( this );
}
+
UpdateModified();
return 0;
diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx
index 6b832a263057..81ce6469117e 100644
--- a/cui/source/tabpages/tpgradnt.cxx
+++ b/cui/source/tabpages/tpgradnt.cxx
@@ -454,23 +454,23 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl)
}
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- DBG_ASSERT(pFact, "Dialog creation failed!");
boost::scoped_ptr<AbstractSvxNameDialog> pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc ));
- DBG_ASSERT(pDlg, "Dialog creation failed!");
ScopedVclPtr<MessageDialog> pWarnBox;
- sal_uInt16 nError = 1;
+ sal_uInt16 nError = 1;
- while( pDlg->Execute() == RET_OK )
+ while (pDlg->Execute() == RET_OK)
{
pDlg->GetName( aName );
bDifferent = true;
- for( long i = 0; i < nCount && bDifferent; i++ )
+ for (long i = 0; i < nCount && bDifferent; ++i)
+ {
if( aName == pGradientList->GetGradient( i )->GetName() )
bDifferent = false;
+ }
- if( bDifferent )
+ if (bDifferent)
{
nError = 0;
break;