summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Balland-Poirier <laurent.balland-poirier@laposte.net>2013-09-17 16:53:26 +0400
committerIvan Timofeev <timofeev.i.s@gmail.com>2013-09-17 17:02:49 +0400
commitc85506265c8d78a103a267489e498aeee9434853 (patch)
tree9695d3667c15b74e2a15f9a8654c63781675728c
parent95dfcdcf7710a2b384d3ef8a94443efee86eb701 (diff)
fdo#64455 Handle unknown color in color line
Change-Id: Ice4205056cc64ae50bd3c8136aeae6f648adbd0b Signed-off-by: Ivan Timofeev <timofeev.i.s@gmail.com>
-rw-r--r--svx/source/tbxctrls/itemwin.cxx38
1 files changed, 37 insertions, 1 deletions
diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx
index 7d26fdcb0a91..3058ca07935e 100644
--- a/svx/source/tbxctrls/itemwin.cxx
+++ b/svx/source/tbxctrls/itemwin.cxx
@@ -30,6 +30,9 @@
#include <svx/dialogs.hrc>
+#define TMP_STR_BEGIN '['
+#define TMP_STR_END ']'
+
#define DELAY_TIMEOUT 100
#include <svx/xlnclit.hxx>
@@ -299,7 +302,40 @@ SvxColorBox::~SvxColorBox()
void SvxColorBox::Update( const XLineColorItem* pItem )
{
if ( pItem )
- SelectEntry( pItem->GetColorValue() );
+ {
+ // fdo#64455
+ ::Color aColor = pItem->GetColorValue();
+ String aString( pItem->GetName() );
+ SelectEntry(aString);
+ if( GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND ||
+ GetSelectEntryColor() != aColor )
+ {
+ SelectEntry( aColor );
+ }
+ // Check if the entry is not in the list
+ if( GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND ||
+ GetSelectEntryColor() != aColor )
+ {
+ sal_uInt16 nCount = GetEntryCount();
+ String aTmpStr;
+ if( nCount > 0 )
+ {
+ // Last entry gets tested against temporary color
+ aTmpStr = GetEntry( nCount - 1 );
+ if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
+ aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
+ {
+ RemoveEntry( nCount - 1 );
+ }
+ }
+ aTmpStr = TMP_STR_BEGIN;
+ aTmpStr += aString;
+ aTmpStr += TMP_STR_END;
+
+ sal_uInt16 nPos = InsertEntry( aColor, aTmpStr );
+ SelectEntryPos( nPos );
+ }
+ }
else
SetNoSelection();
}