cui/source/inc/cuitabarea.hxx   |    2 
 cui/source/tabpages/tpcolor.cxx |  140 ++++++++++++++++------------------------
 cui/uiconfig/ui/colorpage.ui    |   36 ----------
 3 files changed, 61 insertions(+), 117 deletions(-)

New commits:
commit 886c35539b3a6d4da974fb91a697097c346b0016
Author: Rishabh Kumar <kris.kr...@gmail.com>
Date:   Thu Jun 9 14:44:52 2016 +0530

    Remove color name field from color tab
    
    Click on 'Modify' button to change the color name
    
    Change-Id: I90397ae81edc3a9b5368f9fc2a9f2811a1e774e0
    Reviewed-on: https://gerrit.libreoffice.org/26090
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Katarina Behrens <katarina.behr...@cib.de>

diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index ef0e11c..f709766 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -664,7 +664,6 @@ private:
     void EnableSave( bool bCanSave );
 
     SvxColorTabPageShadow *pShadow;
-    VclPtr<Edit>               m_pEdtName;
     VclPtr<ColorLB>            m_pLbColor;
 
     VclPtr<SvxColorValueSet>   m_pValSetColorList;
@@ -743,6 +742,7 @@ private:
     void SetColorModel(ColorModel eModel);
     void ChangeColorModel();
     void UpdateColorValues();
+    sal_Int32 SearchColorList(OUString aColorName);
     DECL_LINK_TYPED( ModifiedHdl_Impl, Edit&, void );
 
     long CheckChanges_Impl();
diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx
index ddb2644..fd51e15 100644
--- a/cui/source/tabpages/tpcolor.cxx
+++ b/cui/source/tabpages/tpcolor.cxx
@@ -215,7 +215,7 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, ClickSaveHdl_Impl, 
Button*, void)
     while (nIndex >= 0);
 
     INetURLObject aFile(aLastDir);
-    DBG_ASSERT( aFile.GetProtocol() != INetProtocol::NotValid, "invalid URL" );
+    SAL_WARN_IF( aFile.GetProtocol() == INetProtocol::NotValid, 
"cui.tabpages", "invalid URL" );
 
     XPropertyListRef pList = GetList();
 
@@ -326,7 +326,6 @@ SvxColorTabPage::SvxColorTabPage(vcl::Window* pParent, 
const SfxItemSet& rInAttr
     get(m_pBtnSave, "save");
     get(m_pTableName, "colortableft");
 
-    get(m_pEdtName, "name");
     get(m_pLbColor, "colorlb");
     get(m_pValSetColorList, "colorset");
     Size aSize = LogicToPixel(Size(94 , 117), MAP_APPFONT);
@@ -434,7 +433,6 @@ void SvxColorTabPage::dispose()
     m_pBtnLoad.clear();
     m_pBtnSave.clear();
     m_pTableName.clear();
-    m_pEdtName.clear();
     m_pLbColor.clear();
     m_pValSetColorList.clear();
     m_pCtlPreviewOld.clear();
@@ -499,7 +497,6 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& )
             {
                 m_pLbColor->SelectEntryPos( *pPos );
                 m_pValSetColorList->SelectItem( 
m_pLbColor->GetSelectEntryPos() + 1 );
-                m_pEdtName->SetText( m_pLbColor->GetSelectEntry() );
                 XColorEntry* pEntry = pColorList->GetColor( *pPos );
                 aPreviousColor = pEntry->GetColor();
                 ChangeColor(pEntry->GetColor());
@@ -515,7 +512,6 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& )
                     aPreviousColor = static_cast<const 
XFillColorItem*>(pPoolItem)->GetColorValue();
                     ChangeColor( aPreviousColor );
 
-                    m_pEdtName->SetText( static_cast<const XFillColorItem*>( 
pPoolItem )->GetName() );
 
                     m_pRcustom->SetValue( ColorToPercent_Impl( 
aCurrentColor.GetRed() ) );
                     m_pGcustom->SetValue( ColorToPercent_Impl( 
aCurrentColor.GetGreen() ) );
@@ -557,15 +553,13 @@ long SvxColorTabPage::CheckChanges_Impl()
     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     {
         Color aColor = pColorList->GetColor( nPos )->GetColor();
-        OUString aString = m_pLbColor->GetSelectEntry();
 
         // aNewColor, because COL_USER != COL_something, even if RGB values 
are the same
         // Color aNewColor( aColor.GetRed(), aColor.GetGreen(), 
aColor.GetBlue() );
 
         if( ColorToPercent_Impl( aCurrentColor.GetRed() ) != 
ColorToPercent_Impl( aColor.GetRed() ) ||
             ColorToPercent_Impl( aCurrentColor.GetGreen() ) != 
ColorToPercent_Impl( aColor.GetGreen() ) ||
-            ColorToPercent_Impl( aCurrentColor.GetBlue() ) != 
ColorToPercent_Impl( aColor.GetBlue() ) ||
-            aString != m_pEdtName->GetText() )
+            ColorToPercent_Impl( aCurrentColor.GetBlue() ) != 
ColorToPercent_Impl( aColor.GetBlue() ) )
         {
             ResMgr& rMgr = CUI_MGR();
             Image aWarningBoxImage = WarningBox::GetStandardImage();
@@ -661,7 +655,6 @@ void SvxColorTabPage::Reset( const SfxItemSet* rSet )
         aNewColor = aColorItem.GetColorValue();
         m_pLbColor->SelectEntry(aNewColor);
         m_pValSetColorList->SelectItem( m_pLbColor->GetSelectEntryPos() + 1 );
-        m_pEdtName->SetText( m_pLbColor->GetSelectEntry() );
     }
 
     // set color model
@@ -720,26 +713,15 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, ClickAddHdl_Impl, 
Button*, void)
 {
     OUString aNewName( SVX_RES( RID_SVXSTR_COLOR ) );
     OUString aDesc( CUI_RES( RID_SVXSTR_DESC_COLOR ) );
-    OUString aName( m_pEdtName->GetText() );
+    OUString aName;
 
-    long nCount = pColorList->Count();
     long j = 1;
-
+    bool bValidColorName = false;
     // check if name is already existing
-    while (true)
+    while (!bValidColorName)
     {
-        bool bDifferent = true;
-
-        for( long i = 0; i < nCount && bDifferent; i++ )
-            if ( aName == pColorList->GetColor( i )->GetName() )
-                bDifferent = false;
-
-        if (bDifferent)
-            break;
-
-        aName = aNewName;
-        aName += " ";
-        aName += OUString::number( j++ );
+        aName = aNewName + " " + OUString::number( j++ );
+        bValidColorName = (SearchColorList(aName) == LISTBOX_ENTRY_NOTFOUND);
     }
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
@@ -751,15 +733,8 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, ClickAddHdl_Impl, 
Button*, void)
     {
         pDlg->GetName( aName );
 
-        bool bDifferent = true;
-
-        for (long i = 0; i < nCount && bDifferent; ++i)
-        {
-            if( aName == pColorList->GetColor( i )->GetName() )
-                bDifferent = false;
-        }
-
-        if (bDifferent)
+        bValidColorName = (SearchColorList(aName) == LISTBOX_ENTRY_NOTFOUND);
+        if (bValidColorName)
         {
             nError = 0;
             break;
@@ -809,61 +784,47 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, 
ClickModifyHdl_Impl, Button*, void)
     {
         ResMgr& rMgr = CUI_MGR();
         OUString aDesc( ResId( RID_SVXSTR_DESC_COLOR, rMgr ) );
-        OUString aName( m_pEdtName->GetText() );
-        long nCount = pColorList->Count();
-        bool bDifferent = true;
+        OUString aName( m_pLbColor->GetSelectEntry() );
 
-        // check if name is already existing
-        for ( long i = 0; i < nCount && bDifferent; i++ )
-            if ( aName == pColorList->GetColor( i )->GetName() && nPos != i )
-                bDifferent = false;
+        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+        std::unique_ptr<AbstractSvxNameDialog> 
pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc ));
+        assert(pFact && "Dialog Creation Failed");
 
-        // if yes, it is repeated and a new name is demanded
-        if ( !bDifferent )
-        {
-            ScopedVclPtrInstance<MessageDialog> aWarningBox( GetParentDialog()
-                                                             
,"DuplicateNameDialog"
-                                                             
,"cui/ui/queryduplicatedialog.ui");
-            aWarningBox->Execute();
+        bool bLoop = true;
 
-            SvxAbstractDialogFactory* pFact = 
SvxAbstractDialogFactory::Create();
-            std::unique_ptr<AbstractSvxNameDialog> 
pDlg(pFact->CreateSvxNameDialog( GetParentDialog(), aName, aDesc ));
-            bool bLoop = true;
+        while( bLoop && pDlg->Execute() == RET_OK )
+        {
+            pDlg->GetName( aName );
+            sal_Int32 nColorPos = SearchColorList(aName);
+            bool bValidColorName = (nColorPos == nPos) || (nColorPos == 
LISTBOX_ENTRY_NOTFOUND);
 
-            while ( !bDifferent && bLoop && pDlg->Execute() == RET_OK )
+            if( bValidColorName )
             {
-                pDlg->GetName( aName );
-                bDifferent = true;
+                bLoop = false;
+                // #123497# Need to replace the existing entry with a new one 
(old returned needs to be deleted)
+                XColorEntry* pEntry = new XColorEntry(aCurrentColor, aName);
+                delete pColorList->Replace(pEntry, nPos);
 
-                for ( long i = 0; i < nCount && bDifferent; i++ )
-                    if( aName == pColorList->GetColor( i )->GetName() && nPos 
!= i )
-                        bDifferent = false;
-
-                if( bDifferent )
-                    bLoop = false;
-                else
-                    aWarningBox->Execute();
-            }
-        }
-
-        // if not existing the entry is entered
-        if( bDifferent )
-        {
-            // #123497# Need to replace the existing entry with a new one (old 
returned needs to be deleted)
-            XColorEntry* pEntry = new XColorEntry(aCurrentColor, aName);
-            delete pColorList->Replace(pEntry, nPos);
+                m_pLbColor->Modify( *pEntry, nPos );
+                m_pLbColor->SelectEntryPos( nPos );
 
-            m_pLbColor->Modify( *pEntry, nPos );
-            m_pLbColor->SelectEntryPos( nPos );
+                m_pValSetColorList->Clear();
+                m_pValSetColorList->addEntriesForXColorList( *pColorList );
+                m_pValSetColorList->SelectItem( nPos + 1 );
 
-            m_pValSetColorList->Clear();
-            m_pValSetColorList->addEntriesForXColorList( *pColorList );
-            m_pValSetColorList->SelectItem( nPos + 1 );
-            m_pEdtName->SetText( aName );
+                m_pCtlPreviewOld->Invalidate();
 
-            m_pCtlPreviewOld->Invalidate();
+                *pnColorListState |= ChangeType::MODIFIED;
+            }
 
-            *pnColorListState |= ChangeType::MODIFIED;
+            // if yes, it is repeated and a new name is demanded
+            else
+            {
+                ScopedVclPtrInstance<MessageDialog> aWarningBox( 
GetParentDialog()
+                                                                 
,"DuplicateNameDialog"
+                                                                 
,"cui/ui/queryduplicatedialog.ui");
+                aWarningBox->Execute();
+            }
         }
     }
 }
@@ -902,7 +863,7 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, ClickDeleteHdl_Impl, 
Button*, void)
         if( aQueryBox->Execute() == RET_YES )
         {
             XColorEntry* pEntry = pColorList->Remove( nPos );
-            DBG_ASSERT( pEntry, "ColorEntry not found !" );
+            assert( pEntry && "ColorEntry not found !" );
             delete pEntry;
 
             // update Listbox and ValueSet
@@ -941,7 +902,6 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, 
SelectColorLBHdl_Impl, ListBox&, void)
     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     {
         m_pValSetColorList->SelectItem( nPos + 1 );
-        m_pEdtName->SetText( m_pLbColor->GetSelectEntry() );
 
         rXFSet.Put( XFillColorItem( OUString(),
                                     m_pLbColor->GetSelectEntryColor() ) );
@@ -960,7 +920,6 @@ IMPL_LINK_NOARG_TYPED(SvxColorTabPage, 
SelectValSetHdl_Impl, ValueSet*, void)
     if( nPos != LISTBOX_ENTRY_NOTFOUND )
     {
         m_pLbColor->SelectEntryPos( nPos - 1 );
-        m_pEdtName->SetText( m_pLbColor->GetSelectEntry() );
 
         rXFSet.Put( XFillColorItem( OUString(),
                                     m_pLbColor->GetSelectEntryColor() ) );
@@ -1079,6 +1038,23 @@ void SvxColorTabPage::UpdateColorValues()
     }
 }
 
+sal_Int32 SvxColorTabPage::SearchColorList(OUString aColorName)
+{
+    long nCount = pColorList->Count();
+    bool bValidColorName = true;
+    sal_Int32 nPos = LISTBOX_ENTRY_NOTFOUND;
+
+    for(long i = 0;i < nCount && bValidColorName;i++)
+    {
+        if(aColorName == pColorList->GetColor( i )->GetName())
+        {
+            nPos = i;
+            bValidColorName = false;
+        }
+    }
+    return nPos;
+}
+
 //void SvxColorTabPage::FillValueSet_Impl( ValueSet& rVs )
 //{
 //    long nCount = pColorList->Count();
diff --git a/cui/uiconfig/ui/colorpage.ui b/cui/uiconfig/ui/colorpage.ui
index b90d3be..bb9823f5 100644
--- a/cui/uiconfig/ui/colorpage.ui
+++ b/cui/uiconfig/ui/colorpage.ui
@@ -61,47 +61,15 @@
                     <property name="row_spacing">6</property>
                     <property name="column_spacing">12</property>
                     <child>
-                      <object class="GtkLabel" id="label5">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="xalign">0</property>
-                        <property name="label" 
translatable="yes">_Name:</property>
-                        <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">name</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
                       <object class="GtkLabel" id="label6">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="xalign">0</property>
                         <property name="label" 
translatable="yes">C_olor:</property>
                         <property name="use_underline">True</property>
-                        <property name="mnemonic_widget">colorlb</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkEntry" id="name">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="valign">center</property>
-                        <property name="invisible_char">•</property>
-                        <property name="width_chars">22</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
                         <property name="top_attach">0</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
@@ -115,7 +83,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">1</property>
+                        <property name="top_attach">0</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
@@ -157,7 +125,7 @@
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">2</property>
+                        <property name="top_attach">1</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to