cui/source/dialogs/sdrcelldlg.cxx | 2 + cui/source/inc/cuitabarea.hxx | 8 ++++-- cui/source/inc/sdrcelldlg.hxx | 1 cui/source/tabpages/tparea.cxx | 1 cui/source/tabpages/tpcolor.cxx | 46 ++++++++++++++++---------------------- include/svx/xtable.hxx | 1 svx/source/xoutdev/xtabcolr.cxx | 13 ++++++++++ 7 files changed, 42 insertions(+), 30 deletions(-)
New commits: commit 54dc7b05c164f787eef0a03d8543af8f9f7647d5 Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Wed Feb 7 15:54:41 2018 +0100 tdf#115506: Crash when trying to set pattern fill for tables in Impress Setting pattern list was missed in this specific dialog. Change-Id: I9f47e9e0dd4f99bf5403c70685508b0f14a5bd61 Reviewed-on: https://gerrit.libreoffice.org/49361 Reviewed-by: Julien Nabet <serval2...@yahoo.fr> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit de8a1b4f6c8fcca9fc9cc5ad83c393ecd7292f76) Signed-off-by: Andras Timar <andras.ti...@collabora.com> diff --git a/cui/source/dialogs/sdrcelldlg.cxx b/cui/source/dialogs/sdrcelldlg.cxx index d6e9244cb738..160477c157b9 100644 --- a/cui/source/dialogs/sdrcelldlg.cxx +++ b/cui/source/dialogs/sdrcelldlg.cxx @@ -34,6 +34,7 @@ SvxFormatCellsDialog::SvxFormatCellsDialog( vcl::Window* pParent, const SfxItemS , mpGradientList(pModel->GetGradientList()) , mpHatchingList(pModel->GetHatchList()) , mpBitmapList(pModel->GetBitmapList()) + , mpPatternList(pModel->GetPatternList()) , m_nAreaPageId(0) { AddTabPage("name", RID_SVXPAGE_CHAR_NAME); @@ -51,6 +52,7 @@ void SvxFormatCellsDialog::PageCreated( sal_uInt16 nId, SfxTabPage &rPage ) rAreaPage.SetGradientList( mpGradientList ); rAreaPage.SetHatchingList( mpHatchingList ); rAreaPage.SetBitmapList( mpBitmapList ); + rAreaPage.SetPatternList( mpPatternList );; rAreaPage.ActivatePage( mrOutAttrs ); } else if (nId == m_nBorderPageId) diff --git a/cui/source/inc/sdrcelldlg.hxx b/cui/source/inc/sdrcelldlg.hxx index f5939979b96d..6b41e69fc8b3 100644 --- a/cui/source/inc/sdrcelldlg.hxx +++ b/cui/source/inc/sdrcelldlg.hxx @@ -34,6 +34,7 @@ private: XGradientListRef mpGradientList; XHatchListRef mpHatchingList; XBitmapListRef mpBitmapList; + XPatternListRef mpPatternList; sal_uInt16 m_nAreaPageId; sal_uInt16 m_nBorderPageId; commit 15c51b17dbe120ddc84bff7f72c7873214ffdcce Author: Katarina Behrens <katarina.behr...@cib.de> Date: Thu Feb 16 22:29:10 2017 +0100 tdf#103224: Get the initial colour right Change-Id: I59309f5b433eb7aa92d05ce7d373d69cb413b258 Reviewed-on: https://gerrit.libreoffice.org/34383 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Katarina Behrens <katarina.behr...@cib.de> (cherry picked from commit f35e6f2504384ad66b475d39849ed10987b2da53) Signed-off-by: Andras Timar <andras.ti...@collabora.com> diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index dd941f844e28..fd11015ad623 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -734,7 +734,6 @@ private: XColorListRef pColorList; ChangeType* pnColorListState; - sal_Int32* pPos; XFillStyleItem aXFStyleItem; XFillColorItem aXFillColorItem; @@ -754,6 +753,7 @@ private: void ImpColorCountChanged(); void FillPaletteLB(); + long FindColorInPalette(const OUString& rPaletteName) const; DECL_LINK( ClickAddHdl_Impl, Button*, void ); DECL_LINK( ClickWorkOnHdl_Impl, Button*, void ); @@ -766,11 +766,14 @@ private: void SetColorModel(ColorModel eModel); void ChangeColorModel(); void UpdateColorValues( bool bUpdatePreset = true ); - static sal_Int32 SearchColorList(OUString const & aColorName); DECL_LINK( ModifiedHdl_Impl, Edit&, void ); void UpdateModified(); css::uno::Reference< css::uno::XComponentContext > m_context; + + static sal_Int32 FindInCustomColors( OUString const & aColorName ); + sal_Int32 FindInPalette( const Color& rColor ); + public: SvxColorTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); virtual ~SvxColorTabPage() override; @@ -786,7 +789,6 @@ public: virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; void SetPropertyList( XPropertyListType t, const XPropertyListRef &xRef ); - void SetPos( sal_Int32* pInPos ) { pPos = pInPos; } void SetColorList( const XColorListRef& pColList ); diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx index f2a054df2e55..d2e358c21ef7 100644 --- a/cui/source/tabpages/tparea.cxx +++ b/cui/source/tabpages/tparea.cxx @@ -401,7 +401,6 @@ void SvxAreaTabPage::CreatePage( sal_Int32 nId, SfxTabPage* pTab ) if(nId == SOLID ) { static_cast<SvxColorTabPage*>(pTab)->SetColorList( m_pColorList ); - static_cast<SvxColorTabPage*>(pTab)->SetPos( &m_nPos ); static_cast<SvxColorTabPage*>(pTab)->SetColorChgd( m_pnColorListState ); static_cast<SvxColorTabPage*>(pTab)->Construct(); static_cast<SvxColorTabPage*>(pTab)->ActivatePage( m_rXFSet ); diff --git a/cui/source/tabpages/tpcolor.cxx b/cui/source/tabpages/tpcolor.cxx index e4545b497d6e..62a1515d3f5d 100644 --- a/cui/source/tabpages/tpcolor.cxx +++ b/cui/source/tabpages/tpcolor.cxx @@ -59,7 +59,6 @@ SvxColorTabPage::SvxColorTabPage(vcl::Window* pParent, const SfxItemSet& rInAttr , rOutAttrs ( rInAttrs ) // All the horrific pointers we store and should not , pnColorListState( nullptr ) - , pPos( nullptr ) , aXFStyleItem( drawing::FillStyle_SOLID ) , aXFillColorItem( OUString(), Color( COL_BLACK ) ) , aXFillAttr( rInAttrs.GetPool() ) @@ -239,38 +238,26 @@ void SvxColorTabPage::ActivatePage( const SfxItemSet& ) { if( pColorList.is() ) { - if( *pPos != LISTBOX_ENTRY_NOTFOUND ) + const SfxPoolItem* pPoolItem = nullptr; + if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) { - m_pValSetColorList->SelectItem( m_pValSetColorList->GetItemId( static_cast<size_t>(*pPos) ) ); - const XColorEntry* pEntry = pColorList->GetColor(*pPos); - aPreviousColor = pEntry->GetColor(); - ChangeColor(pEntry->GetColor()); - } - else if( *pPos == LISTBOX_ENTRY_NOTFOUND ) - { - const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) ) - { - SetColorModel( ColorModel::RGB ); - ChangeColorModel(); + SetColorModel( ColorModel::RGB ); + ChangeColorModel(); - aPreviousColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue(); - ChangeColor( aPreviousColor ); + const Color aColor = static_cast<const XFillColorItem*>(pPoolItem)->GetColorValue(); + ChangeColor( aColor ); + sal_Int32 nPos = FindInPalette( aColor ); - m_pRcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetRed() ) ); - m_pGcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetGreen() ) ); - m_pBcustom->SetValue( ColorToPercent_Impl( aCurrentColor.GetBlue() ) ); - m_pHexcustom->SetColor( aCurrentColor.GetColor() ); + if ( nPos != -1 ) + m_pValSetColorList->SelectItem( m_pValSetColorList->GetItemId( nPos ) ); + // else search in other palettes? - } } m_pCtlPreviewOld->SetAttributes( aXFillAttr.GetItemSet() ); m_pCtlPreviewOld->Invalidate(); SelectValSetHdl_Impl( m_pValSetColorList ); - - *pPos = LISTBOX_ENTRY_NOTFOUND; } } @@ -374,7 +361,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, Button*, void) while (!bValidColorName) { aName = aNewName + " " + OUString::number( j++ ); - bValidColorName = (SearchColorList(aName) == LISTBOX_ENTRY_NOTFOUND); + bValidColorName = (FindInCustomColors(aName) == LISTBOX_ENTRY_NOTFOUND); } SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); @@ -386,7 +373,7 @@ IMPL_LINK_NOARG(SvxColorTabPage, ClickAddHdl_Impl, Button*, void) { pDlg->GetName( aName ); - bValidColorName = (SearchColorList(aName) == LISTBOX_ENTRY_NOTFOUND); + bValidColorName = (FindInCustomColors(aName) == LISTBOX_ENTRY_NOTFOUND); if (bValidColorName) { nError = 0; @@ -662,7 +649,7 @@ void SvxColorTabPage::UpdateColorValues( bool bUpdatePreset ) } } -sal_Int32 SvxColorTabPage::SearchColorList(OUString const & aColorName) +sal_Int32 SvxColorTabPage::FindInCustomColors(OUString const & aColorName) { css::uno::Sequence< OUString > aCustomColorNameList(officecfg::Office::Common::UserColors::CustomColorName::get()); long nCount = aCustomColorNameList.getLength(); @@ -680,6 +667,13 @@ sal_Int32 SvxColorTabPage::SearchColorList(OUString const & aColorName) return nPos; } +sal_Int32 SvxColorTabPage::FindInPalette( const Color& rColor ) +{ + sal_Int32 nPos = pColorList->GetIndexOfColor( rColor ); + + return ( nPos == -1) ? LISTBOX_ENTRY_NOTFOUND : nPos; +} + // A RGB value is converted to a CMYK value - not in an ideal way as // R is converted into C, G into M and B into Y. The K value is held in an // extra variable. For further color models one should develop own diff --git a/include/svx/xtable.hxx b/include/svx/xtable.hxx index 1d781b970495..6039e151af3a 100644 --- a/include/svx/xtable.hxx +++ b/include/svx/xtable.hxx @@ -267,6 +267,7 @@ public: void Replace(long nIndex, std::unique_ptr<XColorEntry> pEntry); XColorEntry* GetColor(long nIndex) const; + long GetIndexOfColor( const Color& rColor) const; virtual css::uno::Reference< css::container::XNameContainer > createInstance() override; virtual bool Create() override; diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx index 374f6fc9a6cb..44f881403580 100644 --- a/svx/source/xoutdev/xtabcolr.cxx +++ b/svx/source/xoutdev/xtabcolr.cxx @@ -157,4 +157,17 @@ Bitmap XColorList::CreateBitmapForUI( long /*nIndex*/ ) return Bitmap(); } +long XColorList::GetIndexOfColor( const Color& rColor ) const +{ + for( long i = 0, n = maList.size(); i < n; ++i ) + { + const Color aColor = static_cast<XColorEntry*>( maList[i].get() )->GetColor(); + + if (aColor == rColor ) + return i; + } + + return -1; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits