From 41f1a38b9e8b5e0567bf642d3e14a549e82ee0d9 Mon Sep 17 00:00:00 2001 From: Jim Raykowski Date: Sun, 28 Jan 2018 09:20:06 -0900 Subject: tdf#105225 A table properties background tab page Change-Id: I86be7b0d9850ffe46f1033beac342739b3289fa8 Reviewed-on: https://gerrit.libreoffice.org/48797 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- cui/source/factory/dlgfact.cxx | 2 + cui/source/inc/backgrnd.hxx | 18 ++++++ cui/source/inc/cuitabarea.hxx | 3 +- cui/source/tabpages/backgrnd.cxx | 130 +++++++++++++++++++++++++++++++++++++++ cui/uiconfig/ui/areatabpage.ui | 42 +++++++++---- 5 files changed, 181 insertions(+), 14 deletions(-) (limited to 'cui') diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index f4a57b475ce3..091c920b9c5a 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -1348,6 +1348,8 @@ CreateTabPage AbstractDialogFactory_Impl::GetTabPageCreatorFunc( sal_uInt16 nId { switch ( nId ) { + case RID_SVXPAGE_BKG : + return SvxBkgTabPage::Create; case RID_SVXPAGE_TEXTANIMATION : return SvxTextAnimationPage::Create; case RID_SVXPAGE_TRANSPARENCE : diff --git a/cui/source/inc/backgrnd.hxx b/cui/source/inc/backgrnd.hxx index d7e71a0ceec9..88131fa61b80 100644 --- a/cui/source/inc/backgrnd.hxx +++ b/cui/source/inc/backgrnd.hxx @@ -139,6 +139,24 @@ private: DECL_LINK( TblDestinationHdl_Impl, ListBox&, void ); }; +#include "cuitabarea.hxx" + +class SvxBkgTabPage : public SvxAreaTabPage +{ + VclPtr m_pTblLBox; +public: + using SvxAreaTabPage::DeactivatePage; + + SvxBkgTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~SvxBkgTabPage() override; + virtual void dispose() override; + + static VclPtr Create( vcl::Window*, const SfxItemSet* ); + virtual bool FillItemSet( SfxItemSet* ) override; + virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override; + virtual void PageCreated( const SfxAllItemSet& aSet ) override; +}; + #endif // INCLUDED_CUI_SOURCE_INC_BACKGRND_HXX diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx index 81fabd1fb934..ba2760d4fb26 100644 --- a/cui/source/inc/cuitabarea.hxx +++ b/cui/source/inc/cuitabarea.hxx @@ -215,7 +215,6 @@ public: class SvxAreaTabPage : public SvxTabPage { using TabPage::ActivatePage; - using TabPage::DeactivatePage; static const sal_uInt16 pAreaRanges[]; private: ScopedVclPtr m_pFillTabPage; @@ -258,6 +257,8 @@ private: template< typename TabPage > DeactivateRC DeactivatePage_Impl( SfxItemSet* pSet ); public: + using TabPage::DeactivatePage; + SvxAreaTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ); virtual ~SvxAreaTabPage() override; virtual void dispose() override; diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx index ebac89286d83..6ef959108360 100644 --- a/cui/source/tabpages/backgrnd.cxx +++ b/cui/source/tabpages/backgrnd.cxx @@ -1442,4 +1442,134 @@ void SvxBackgroundTabPage::PageCreated(const SfxAllItemSet& aSet) } } +#include + +SvxBkgTabPage::SvxBkgTabPage( vcl::Window* pParent, const SfxItemSet& rInAttrs ) : + SvxAreaTabPage( pParent, rInAttrs ), + m_pTblLBox(nullptr) +{ + VclPtr pBtn; + get(pBtn, "btngradient"); pBtn->Hide(); + get(pBtn, "btnhatch"); pBtn->Hide(); + get(pBtn, "btnbitmap"); pBtn->Hide(); + get(pBtn, "btnpattern"); pBtn->Hide(); + + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + const SfxPoolItem* pItem = nullptr; + + XColorListRef pColorTable = nullptr; + if ( pDocSh && ( nullptr != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) ) ) + { + pColorTable = static_cast(pItem)->GetColorList(); + } + + if ( !pColorTable.is() ) + pColorTable = XColorList::CreateStdColorList(); + + XBitmapListRef pBitmapList = nullptr; + if ( pDocSh && ( nullptr != ( pItem = pDocSh->GetItem( SID_BITMAP_LIST ) ) ) ) + { + pBitmapList = static_cast(pItem)->GetBitmapList(); + } + + SetColorList(pColorTable); + SetBitmapList(pBitmapList); +} + +SvxBkgTabPage::~SvxBkgTabPage() +{ + disposeOnce(); +} + +void SvxBkgTabPage::dispose() +{ + m_pTblLBox.clear(); + SvxAreaTabPage::dispose(); +} + +DeactivateRC SvxBkgTabPage::DeactivatePage( SfxItemSet* _pSet ) +{ + if ( DeactivateRC::KeepPage == SvxAreaTabPage::DeactivatePage( _pSet ) ) + return DeactivateRC::KeepPage; + + if ( _pSet ) + FillItemSet( _pSet ); + + return DeactivateRC::LeavePage; +} + +bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet ) +{ + sal_uInt16 nSlot = SID_ATTR_BRUSH; + if ( m_pTblLBox && m_pTblLBox->IsVisible() ) + { + switch( m_pTblLBox->GetSelectedEntryPos() ) + { + case TBL_DEST_CELL: + nSlot = SID_ATTR_BRUSH; + break; + case TBL_DEST_ROW: + nSlot = SID_ATTR_BRUSH_ROW; + break; + case TBL_DEST_TBL: + nSlot = SID_ATTR_BRUSH_TABLE; + break; + } + } + + sal_uInt16 nWhich = GetWhich(nSlot); + + drawing::FillStyle eFillType = rCoreSet->Get( XATTR_FILLSTYLE ).GetValue(); + switch( eFillType ) + { + case drawing::FillStyle_NONE: + { + rCoreSet->Put( SvxBrushItem( COL_TRANSPARENT, nWhich ) ); + break; + } + case drawing::FillStyle_SOLID: + { + XFillColorItem aColorItem( rCoreSet->Get( XATTR_FILLCOLOR ) ); + rCoreSet->Put( SvxBrushItem( aColorItem.GetColorValue(), nWhich ) ); + break; + } + case drawing::FillStyle_BITMAP: + { + SvxBrushItem aBrushItem( getSvxBrushItemFromSourceSet( *rCoreSet, nWhich ) ); + if ( GraphicType::NONE != aBrushItem.GetGraphicObject()->GetType() ) // no selection so use current + rCoreSet->Put( aBrushItem ); + break; + } + default: + break; + } + + return true; +} + +VclPtr SvxBkgTabPage::Create( vcl::Window* pWindow, + const SfxItemSet* rAttrs ) +{ + return VclPtr::Create( pWindow, *rAttrs ); +} + +void SvxBkgTabPage::PageCreated(const SfxAllItemSet& aSet) +{ + const SfxUInt32Item* pFlagItem = aSet.GetItem(SID_FLAG_TYPE, false); + if (pFlagItem) + { + SvxBackgroundTabFlags nFlags = static_cast(pFlagItem->GetValue()); + if ( nFlags & SvxBackgroundTabFlags::SHOW_TBLCTL ) + { + VclPtr pBtn; + get(pBtn, "btnbitmap"); + pBtn->Show(); + get(m_pTblLBox, "tablelb"); + m_pTblLBox->SelectEntryPos(0); + m_pTblLBox->Show(); + } + } + SvxAreaTabPage::PageCreated( aSet ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/uiconfig/ui/areatabpage.ui b/cui/uiconfig/ui/areatabpage.ui index 3e1b746a3815..f1165815fe4c 100644 --- a/cui/uiconfig/ui/areatabpage.ui +++ b/cui/uiconfig/ui/areatabpage.ui @@ -1,5 +1,5 @@ - + @@ -24,6 +24,22 @@ True 12 center + + + False + 0 + + Cell + Row + Table + + + + True + True + 0 + + None @@ -34,7 +50,7 @@ True True - 0 + 1 @@ -47,7 +63,7 @@ True True - 1 + 2 @@ -60,12 +76,12 @@ True True - 2 + 3 - - Hatch + + Bitmap True True True @@ -73,12 +89,12 @@ True True - 5 + 4 - - Bitmap + + Pattern True True True @@ -86,12 +102,12 @@ True True - 3 + 5 - - Pattern + + Hatch True True True @@ -99,7 +115,7 @@ True True - 4 + 6 -- cgit