Kaydet (Commit) a3416803 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: fdo#54024 color values not showing with custom colors

that are unknown in the palette

Change-Id: Icb80ad0d16f0315e21c14e748e91f505edd699c3
üst a5bcc75b
...@@ -722,7 +722,7 @@ private: ...@@ -722,7 +722,7 @@ private:
DECL_LINK( SelectColorLBHdl_Impl, void * ); DECL_LINK( SelectColorLBHdl_Impl, void * );
DECL_LINK( SelectValSetHdl_Impl, void * ); DECL_LINK( SelectValSetHdl_Impl, void * );
DECL_LINK( SelectColorModelHdl_Impl, void * ); DECL_LINK( SelectColorModelHdl_Impl, void * );
long ChangeColorHdl_Impl( void* p ); void ChangeColor(const Color &rNewColor);
DECL_LINK( ModifiedHdl_Impl, void * ); DECL_LINK( ModifiedHdl_Impl, void * );
long CheckChanges_Impl(); long CheckChanges_Impl();
......
...@@ -264,7 +264,12 @@ void SvxColorTabPage::Update(bool bLoaded) ...@@ -264,7 +264,12 @@ void SvxColorTabPage::Update(bool bLoaded)
else else
m_pLbColor->SelectEntryPos( m_pLbColor->GetSelectEntryPos() ); m_pLbColor->SelectEntryPos( m_pLbColor->GetSelectEntryPos() );
ChangeColorHdl_Impl( this ); sal_Int32 nPos = m_pLbColor->GetSelectEntryPos();
if( nPos != LISTBOX_ENTRY_NOTFOUND )
{
XColorEntry* pEntry = pColorList->GetColor( nPos );
ChangeColor(pEntry->GetColor());
}
SelectColorLBHdl_Impl( this ); SelectColorLBHdl_Impl( this );
} }
...@@ -431,8 +436,8 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) ...@@ -431,8 +436,8 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& )
m_pLbColor->SelectEntryPos( *pPos ); m_pLbColor->SelectEntryPos( *pPos );
m_pValSetColorList->SelectItem( m_pLbColor->GetSelectEntryPos() + 1 ); m_pValSetColorList->SelectItem( m_pLbColor->GetSelectEntryPos() + 1 );
m_pEdtName->SetText( m_pLbColor->GetSelectEntry() ); m_pEdtName->SetText( m_pLbColor->GetSelectEntry() );
XColorEntry* pEntry = pColorList->GetColor( *pPos );
ChangeColorHdl_Impl( this ); ChangeColor(pEntry->GetColor());
} }
else if( *pPageType == PT_COLOR && *pPos == LISTBOX_ENTRY_NOTFOUND ) else if( *pPageType == PT_COLOR && *pPos == LISTBOX_ENTRY_NOTFOUND )
{ {
...@@ -441,7 +446,7 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) ...@@ -441,7 +446,7 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& )
{ {
m_pLbColorModel->SelectEntryPos( CM_RGB ); m_pLbColorModel->SelectEntryPos( CM_RGB );
aCurrentColor.SetColor ( ( ( const XFillColorItem* ) pPoolItem )->GetColorValue().GetColor() ); ChangeColor(((const XFillColorItem*)pPoolItem)->GetColorValue());
m_pEdtName->SetText( ( ( const XFillColorItem* ) pPoolItem )->GetName() ); m_pEdtName->SetText( ( ( const XFillColorItem* ) pPoolItem )->GetName() );
...@@ -488,11 +493,6 @@ int SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet ) ...@@ -488,11 +493,6 @@ int SvxColorTabPage::DeactivatePage( SfxItemSet* _pSet )
long SvxColorTabPage::CheckChanges_Impl() long SvxColorTabPage::CheckChanges_Impl()
{ {
// used to NOT lose changes // used to NOT lose changes
Color aTmpColor (aCurrentColor);
if (eCM != CM_RGB)
ConvertColorValues (aTmpColor, CM_RGB);
sal_Int32 nPos = m_pLbColor->GetSelectEntryPos(); sal_Int32 nPos = m_pLbColor->GetSelectEntryPos();
if( nPos != LISTBOX_ENTRY_NOTFOUND ) if( nPos != LISTBOX_ENTRY_NOTFOUND )
{ {
...@@ -502,9 +502,9 @@ long SvxColorTabPage::CheckChanges_Impl() ...@@ -502,9 +502,9 @@ long SvxColorTabPage::CheckChanges_Impl()
// aNewColor, because COL_USER != COL_something, even if RGB values are the same // aNewColor, because COL_USER != COL_something, even if RGB values are the same
// Color aNewColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() ); // Color aNewColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
if( ColorToPercent_Impl( aTmpColor.GetRed() ) != ColorToPercent_Impl( aColor.GetRed() ) || if( ColorToPercent_Impl( aCurrentColor.GetRed() ) != ColorToPercent_Impl( aColor.GetRed() ) ||
ColorToPercent_Impl( aTmpColor.GetGreen() ) != ColorToPercent_Impl( aColor.GetGreen() ) || ColorToPercent_Impl( aCurrentColor.GetGreen() ) != ColorToPercent_Impl( aColor.GetGreen() ) ||
ColorToPercent_Impl( aTmpColor.GetBlue() ) != ColorToPercent_Impl( aColor.GetBlue() ) || ColorToPercent_Impl( aCurrentColor.GetBlue() ) != ColorToPercent_Impl( aColor.GetBlue() ) ||
aString != m_pEdtName->GetText() ) aString != m_pEdtName->GetText() )
{ {
ResMgr& rMgr = CUI_MGR(); ResMgr& rMgr = CUI_MGR();
...@@ -573,8 +573,6 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet& rSet ) ...@@ -573,8 +573,6 @@ bool SvxColorTabPage::FillItemSet( SfxItemSet& rSet )
else else
{ {
aColor.SetColor (aCurrentColor.GetColor()); aColor.SetColor (aCurrentColor.GetColor());
if (eCM != CM_RGB)
ConvertColorValues (aColor, CM_RGB);
} }
rSet.Put( XFillColorItem( aString, aColor ) ); rSet.Put( XFillColorItem( aString, aColor ) );
rSet.Put( XFillStyleItem( XFILL_SOLID ) ); rSet.Put( XFillStyleItem( XFILL_SOLID ) );
...@@ -598,10 +596,13 @@ void SvxColorTabPage::Reset( const SfxItemSet& rSet ) ...@@ -598,10 +596,13 @@ void SvxColorTabPage::Reset( const SfxItemSet& rSet )
{ {
sal_uInt16 nState = rSet.GetItemState( XATTR_FILLCOLOR ); sal_uInt16 nState = rSet.GetItemState( XATTR_FILLCOLOR );
Color aNewColor;
if ( nState >= SFX_ITEM_DEFAULT ) if ( nState >= SFX_ITEM_DEFAULT )
{ {
XFillColorItem aColorItem( (const XFillColorItem&)rSet.Get( XATTR_FILLCOLOR ) ); XFillColorItem aColorItem( (const XFillColorItem&)rSet.Get( XATTR_FILLCOLOR ) );
m_pLbColor->SelectEntry( aColorItem.GetColorValue() ); aNewColor = aColorItem.GetColorValue();
m_pLbColor->SelectEntry(aNewColor);
m_pValSetColorList->SelectItem( m_pLbColor->GetSelectEntryPos() + 1 ); m_pValSetColorList->SelectItem( m_pLbColor->GetSelectEntryPos() + 1 );
m_pEdtName->SetText( m_pLbColor->GetSelectEntry() ); m_pEdtName->SetText( m_pLbColor->GetSelectEntry() );
} }
...@@ -610,7 +611,7 @@ void SvxColorTabPage::Reset( const SfxItemSet& rSet ) ...@@ -610,7 +611,7 @@ void SvxColorTabPage::Reset( const SfxItemSet& rSet )
OUString aStr = GetUserData(); OUString aStr = GetUserData();
m_pLbColorModel->SelectEntryPos( aStr.toInt32() ); m_pLbColorModel->SelectEntryPos( aStr.toInt32() );
ChangeColorHdl_Impl( this ); ChangeColor(aNewColor);
SelectColorModelHdl_Impl( this ); SelectColorModelHdl_Impl( this );
m_pCtlPreviewOld->Invalidate(); m_pCtlPreviewOld->Invalidate();
...@@ -625,11 +626,7 @@ SfxTabPage* SvxColorTabPage::Create( Window* pWindow, ...@@ -625,11 +626,7 @@ SfxTabPage* SvxColorTabPage::Create( Window* pWindow,
return( new SvxColorTabPage( pWindow, rOutAttrs ) ); return( new SvxColorTabPage( pWindow, rOutAttrs ) );
} }
// is called when the content of the MtrFields is changed for color values // is called when the content of the MtrFields is changed for color values
IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl) IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl)
{ {
if (eCM == CM_RGB) if (eCM == CM_RGB)
...@@ -646,14 +643,10 @@ IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl) ...@@ -646,14 +643,10 @@ IMPL_LINK_NOARG(SvxColorTabPage, ModifiedHdl_Impl)
(sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pC->GetValue() ), (sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pC->GetValue() ),
(sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pY->GetValue() ), (sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pY->GetValue() ),
(sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pM->GetValue() ) ).GetColor() ); (sal_uInt8)PercentToColor_Impl( (sal_uInt16) m_pM->GetValue() ) ).GetColor() );
ConvertColorValues (aCurrentColor, CM_RGB);
} }
Color aTmpColor(aCurrentColor); rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) );
if (eCM != CM_RGB)
ConvertColorValues (aTmpColor, CM_RGB);
rXFSet.Put( XFillColorItem( OUString(), aTmpColor ) );
m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() ); m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() );
m_pCtlPreviewNew->Invalidate(); m_pCtlPreviewNew->Invalidate();
...@@ -717,8 +710,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl) ...@@ -717,8 +710,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl)
// if not existing the entry is entered // if not existing the entry is entered
if( bDifferent ) if( bDifferent )
{ {
if (eCM != CM_RGB)
ConvertColorValues (aCurrentColor, CM_RGB);
pEntry = new XColorEntry( aCurrentColor, aName ); pEntry = new XColorEntry( aCurrentColor, aName );
pColorList->Insert( pEntry, pColorList->Count() ); pColorList->Insert( pEntry, pColorList->Count() );
...@@ -789,13 +780,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickModifyHdl_Impl) ...@@ -789,13 +780,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickModifyHdl_Impl)
// if not existing the entry is entered // if not existing the entry is entered
if( bDifferent ) if( bDifferent )
{ {
Color aTmpColor (aCurrentColor);
if (eCM != CM_RGB)
ConvertColorValues (aTmpColor, CM_RGB);
// #123497# Need to replace the existing entry with a new one (old returned needs to be deleted) // #123497# Need to replace the existing entry with a new one (old returned needs to be deleted)
XColorEntry* pEntry = new XColorEntry(aTmpColor, aName); XColorEntry* pEntry = new XColorEntry(aCurrentColor, aName);
delete pColorList->Replace(pEntry, nPos); delete pColorList->Replace(pEntry, nPos);
m_pLbColor->Modify( *pEntry, nPos ); m_pLbColor->Modify( *pEntry, nPos );
...@@ -819,11 +805,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl) ...@@ -819,11 +805,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl)
{ {
SvColorDialog* pColorDlg = new SvColorDialog( GetParentDialog() ); SvColorDialog* pColorDlg = new SvColorDialog( GetParentDialog() );
Color aTmpColor (aCurrentColor); pColorDlg->SetColor (aCurrentColor);
if (eCM != CM_RGB)
ConvertColorValues (aTmpColor, CM_RGB);
pColorDlg->SetColor (aTmpColor);
pColorDlg->SetMode( svtools::ColorPickerMode_MODIFY ); pColorDlg->SetMode( svtools::ColorPickerMode_MODIFY );
if( pColorDlg->Execute() == RET_OK ) if( pColorDlg->Execute() == RET_OK )
...@@ -838,6 +820,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl) ...@@ -838,6 +820,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickWorkOnHdl_Impl)
m_pY->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); m_pY->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
m_pM->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); m_pM->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
m_pK->SetValue( ColorToPercent_Impl( nK ) ); m_pK->SetValue( ColorToPercent_Impl( nK ) );
ConvertColorValues (aCurrentColor, CM_RGB);
} }
else else
{ {
...@@ -913,7 +896,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorLBHdl_Impl) ...@@ -913,7 +896,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorLBHdl_Impl)
m_pCtlPreviewOld->Invalidate(); m_pCtlPreviewOld->Invalidate();
m_pCtlPreviewNew->Invalidate(); m_pCtlPreviewNew->Invalidate();
ChangeColorHdl_Impl( this ); XColorEntry* pEntry = pColorList->GetColor(nPos);
ChangeColor(pEntry->GetColor());
} }
return 0; return 0;
} }
...@@ -936,7 +920,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectValSetHdl_Impl) ...@@ -936,7 +920,8 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectValSetHdl_Impl)
m_pCtlPreviewOld->Invalidate(); m_pCtlPreviewOld->Invalidate();
m_pCtlPreviewNew->Invalidate(); m_pCtlPreviewNew->Invalidate();
ChangeColorHdl_Impl( this ); XColorEntry* pEntry = pColorList->GetColor(nPos-1);
ChangeColor(pEntry->GetColor());
} }
return 0; return 0;
} }
...@@ -969,11 +954,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl) ...@@ -969,11 +954,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl)
int nPos = m_pLbColorModel->GetSelectEntryPos(); int nPos = m_pLbColorModel->GetSelectEntryPos();
if( nPos != LISTBOX_ENTRY_NOTFOUND ) if( nPos != LISTBOX_ENTRY_NOTFOUND )
{ {
if (eCM != (ColorModel) nPos)
{
ConvertColorValues (aCurrentColor, (ColorModel) nPos);
}
eCM = (ColorModel) nPos; eCM = (ColorModel) nPos;
switch( eCM ) switch( eCM )
...@@ -983,10 +963,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl) ...@@ -983,10 +963,6 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl)
m_pRGB->Show(); m_pRGB->Show();
m_pCMYK->Hide(); m_pCMYK->Hide();
m_pR->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) );
m_pG->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
m_pB->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
} }
break; break;
...@@ -994,17 +970,11 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl) ...@@ -994,17 +970,11 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl)
{ {
m_pCMYK->Show(); m_pCMYK->Show();
m_pRGB->Hide(); m_pRGB->Hide();
m_pC->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) );
m_pY->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
m_pM->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
m_pK->SetValue( ColorToPercent_Impl( aCurrentColor.GetTransparency() ) );
} }
break; break;
} }
ChangeColorHdl_Impl( this ); ChangeColor(aCurrentColor);
} }
...@@ -1013,37 +983,31 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl) ...@@ -1013,37 +983,31 @@ IMPL_LINK_NOARG(SvxColorTabPage, SelectColorModelHdl_Impl)
long SvxColorTabPage::ChangeColorHdl_Impl( void* ) void SvxColorTabPage::ChangeColor(const Color &rNewColor)
{ {
int nPos = m_pLbColor->GetSelectEntryPos(); aCurrentColor = rNewColor;
if( nPos != LISTBOX_ENTRY_NOTFOUND ) if (eCM != CM_RGB)
{ {
XColorEntry* pEntry = pColorList->GetColor( nPos ); ConvertColorValues (aCurrentColor, eCM);
m_pC->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) );
aCurrentColor.SetColor ( pEntry->GetColor().GetColor() ); m_pY->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
if (eCM != CM_RGB) m_pM->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
{ m_pK->SetValue( ColorToPercent_Impl( aCurrentColor.GetTransparency() ) );
ConvertColorValues (aCurrentColor, eCM); ConvertColorValues (aCurrentColor, CM_RGB);
m_pC->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) ); }
m_pY->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); else
m_pM->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); {
m_pK->SetValue( ColorToPercent_Impl( aCurrentColor.GetTransparency() ) ); m_pR->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) );
} m_pG->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
else m_pB->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
{ }
m_pR->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) );
m_pG->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) );
m_pB->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) );
}
// fill ItemSet and pass it on to XOut // fill ItemSet and pass it on to XOut
rXFSet.Put( XFillColorItem( OUString(), pEntry->GetColor() ) ); rXFSet.Put( XFillColorItem( OUString(), aCurrentColor ) );
m_pCtlPreviewOld->SetAttributes( aXFillAttr.GetItemSet() ); m_pCtlPreviewOld->SetAttributes( aXFillAttr.GetItemSet() );
m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() ); m_pCtlPreviewNew->SetAttributes( aXFillAttr.GetItemSet() );
m_pCtlPreviewNew->Invalidate(); m_pCtlPreviewNew->Invalidate();
}
return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment