[Libreoffice-commits] core.git: cui/source
Caolán McNamara
caolanm at redhat.com
Wed Apr 29 08:16:16 PDT 2015
cui/source/tabpages/tpcolor.cxx | 84 ++++++++++++++++++++++-----------------
cui/source/tabpages/tpgradnt.cxx | 12 ++---
2 files changed, 55 insertions(+), 41 deletions(-)
New commits:
commit 74706c4057e027898022ac42de210302cdc92d99
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Apr 29 16:06:20 2015 +0100
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
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index 4347ab3..3c3ecf2 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 6b832a2..81ce646 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;
More information about the Libreoffice-commits
mailing list