summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2019-01-22 18:50:23 -0900
committerJim Raykowski <raykowj@gmail.com>2019-03-02 03:41:30 +0100
commit222b5b5b9b0d0419e30961261c63ff8585550b81 (patch)
tree6c6c812a2cc0eef168d53b5821c5605eaea5b4f8 /cui
parent6d2014175122020f08b301f7213a228082f9c98a (diff)
tdf#122790 Improve background tab page for writer tables
This patch improves the new background tab page use for setting Writer table cell, row, and table backgrounds. Now cell, row, and table backgrounds fill tab page according to the fill style of each and can all be set in the same opening of a Table Properties dialog. This patch also makes the Reset reset background settings to initial settings of dialog opening. Change-Id: I567ef9229232f02d98b45a81309e920dca854bed Reviewed-on: https://gerrit.libreoffice.org/66844 Tested-by: Jenkins Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/inc/backgrnd.hxx6
-rw-r--r--cui/source/inc/cuitabarea.hxx5
-rw-r--r--cui/source/tabpages/backgrnd.cxx154
-rw-r--r--cui/source/tabpages/tparea.cxx10
4 files changed, 159 insertions, 16 deletions
diff --git a/cui/source/inc/backgrnd.hxx b/cui/source/inc/backgrnd.hxx
index 8f02659118b6..78c82a6448ac 100644
--- a/cui/source/inc/backgrnd.hxx
+++ b/cui/source/inc/backgrnd.hxx
@@ -160,6 +160,11 @@ class SvxBkgTabPage : public SvxAreaTabPage
bool bHighlighting : 1;
bool bCharBackColor : 1;
SfxItemSet maSet;
+ std::unique_ptr<SfxItemSet> m_pResetSet;
+
+ sal_Int32 m_nActPos = -1;
+
+ DECL_LINK(TblDestinationHdl_Impl, weld::ComboBox&, void);
public:
using SvxAreaTabPage::ActivatePage;
using SvxAreaTabPage::DeactivatePage;
@@ -173,6 +178,7 @@ public:
virtual void ActivatePage( const SfxItemSet& ) override;
virtual DeactivateRC DeactivatePage( SfxItemSet* pSet ) override;
virtual void PageCreated( const SfxAllItemSet& aSet ) override;
+ virtual void Reset( const SfxItemSet * ) override;
};
#endif // INCLUDED_CUI_SOURCE_INC_BACKGRND_HXX
diff --git a/cui/source/inc/cuitabarea.hxx b/cui/source/inc/cuitabarea.hxx
index 5344c69e73bf..b166e37d1c87 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -251,6 +251,9 @@ protected:
void SetOptimalSize(weld::DialogController* pController);
+ void SelectFillType( weld::ToggleButton& rButton, const SfxItemSet* _pSet = nullptr );
+ SfxTabPage* GetFillTabPage() { return m_pFillTabPage; }
+
private:
DECL_LINK(SelectFillTypeHdl_Impl, weld::ToggleButton&, void);
@@ -760,6 +763,8 @@ public:
void SetColorChgd( ChangeType* pIn ) { pnColorListState = pIn; }
+ void SetCtlPreviewOld( SfxItemSet& rAttrs ) { m_aCtlPreviewOld.SetAttributes( rAttrs ); }
+
virtual void FillUserData() override;
};
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 3bb47de0799f..86d39648b796 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -1345,6 +1345,26 @@ void SvxBackgroundTabPage::PageCreated(const SfxAllItemSet& aSet)
}
}
+static sal_uInt16 lcl_GetTableDestSlot(sal_Int32 nTblDest)
+{
+ switch (nTblDest)
+ {
+ default:
+ case TBL_DEST_CELL:
+ {
+ return SID_ATTR_BRUSH;
+ }
+ case TBL_DEST_ROW:
+ {
+ return SID_ATTR_BRUSH_ROW;
+ }
+ case TBL_DEST_TBL:
+ {
+ return SID_ATTR_BRUSH_TABLE;
+ }
+ }
+}
+
SvxBkgTabPage::SvxBkgTabPage(TabPageParent pParent, const SfxItemSet& rInAttrs)
: SvxAreaTabPage(pParent, rInAttrs),
bHighlighting(false),
@@ -1405,24 +1425,29 @@ DeactivateRC SvxBkgTabPage::DeactivatePage( SfxItemSet* _pSet )
return DeactivateRC::LeavePage;
}
-bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet )
+void SvxBkgTabPage::Reset( const SfxItemSet* )
{
- sal_uInt16 nSlot = SID_ATTR_BRUSH;
- if (m_xTblLBox && m_xTblLBox->get_visible())
+ maSet.Set( *m_pResetSet.get() );
+ if ( m_xTblLBox && m_xTblLBox->get_visible() )
{
- switch (m_xTblLBox->get_active())
+ m_nActPos = -1;
+ const SfxPoolItem* pItem;
+ if ( SfxItemState::SET == m_pResetSet->GetItemState( SID_BACKGRND_DESTINATION, false, &pItem ) )
{
- 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 nDestValue = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ m_xTblLBox->set_active( nDestValue );
+ TblDestinationHdl_Impl( *m_xTblLBox );
}
+ m_xTblLBox->save_value();
}
+ SvxAreaTabPage::Reset( &maSet );
+}
+
+bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet )
+{
+ sal_uInt16 nSlot = SID_ATTR_BRUSH;
+ if (m_xTblLBox && m_xTblLBox->get_visible())
+ nSlot = lcl_GetTableDestSlot(m_xTblLBox->get_active());
else if ( bHighlighting )
nSlot = SID_ATTR_BRUSH_CHAR;
else if( bCharBackColor )
@@ -1465,7 +1490,7 @@ bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet )
case drawing::FillStyle_BITMAP:
{
SvxBrushItem aBrushItem( getSvxBrushItemFromSourceSet( maSet, nWhich ) );
- if ( GraphicType::NONE != aBrushItem.GetGraphicObject()->GetType() ) // no selection so use current
+ if ( GraphicType::NONE != aBrushItem.GetGraphicObject()->GetType() )
rCoreSet->Put( aBrushItem );
break;
}
@@ -1473,6 +1498,42 @@ bool SvxBkgTabPage::FillItemSet( SfxItemSet* rCoreSet )
break;
}
+ if (m_xTblLBox && m_xTblLBox->get_visible())
+ {
+ if (nSlot != SID_ATTR_BRUSH)
+ {
+ nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH);
+ if (SfxItemState::SET == maSet.GetItemState(nWhich))
+ {
+ SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
+ rCoreSet->Put(aBrushItem);
+ }
+ }
+ if (nSlot != SID_ATTR_BRUSH_ROW)
+ {
+ nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_ROW);
+ if (SfxItemState::SET == maSet.GetItemState(nWhich))
+ {
+ SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
+ rCoreSet->Put(aBrushItem);
+ }
+ }
+ if (nSlot != SID_ATTR_BRUSH_TABLE)
+ {
+ nWhich = maSet.GetPool()->GetWhich(SID_ATTR_BRUSH_TABLE);
+ if (SfxItemState::SET == maSet.GetItemState(nWhich))
+ {
+ SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
+ rCoreSet->Put(aBrushItem);
+ }
+ }
+
+ if (m_xTblLBox->get_value_changed_from_saved())
+ {
+ rCoreSet->Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, m_xTblLBox->get_active()));
+ }
+ }
+
return true;
}
@@ -1493,7 +1554,7 @@ void SvxBkgTabPage::PageCreated(const SfxAllItemSet& aSet)
{
m_xBtnBitmap->show();
m_xTblLBox = m_xBuilder->weld_combo_box("tablelb");
- m_xTblLBox->set_active(0);
+ m_xTblLBox->connect_changed(LINK(this, SvxBkgTabPage, TblDestinationHdl_Impl));
m_xTblLBox->show();
}
if ((nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING) ||
@@ -1520,7 +1581,70 @@ void SvxBkgTabPage::PageCreated(const SfxAllItemSet& aSet)
setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet);
}
+ m_pResetSet = maSet.Clone();
+
SvxAreaTabPage::PageCreated(aSet);
}
+IMPL_LINK(SvxBkgTabPage, TblDestinationHdl_Impl, weld::ComboBox&, rBox, void)
+{
+ if (m_nActPos > -1)
+ {
+ // fill local item set with XATTR_FILL settings gathered from tab page
+ // and convert to SvxBrushItem and store in table destination slot Which
+ SvxAreaTabPage::FillItemSet(&maSet);
+ maSet.Put(getSvxBrushItemFromSourceSet(maSet, maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(m_nActPos))));
+ }
+
+ sal_Int32 nSelPos = rBox.get_active();
+ if (m_nActPos != nSelPos)
+ {
+ m_nActPos = nSelPos;
+
+ // fill local item set with XATTR_FILL created from SvxBushItem for table destination slot Which
+ sal_uInt16 nWhich = maSet.GetPool()->GetWhich(lcl_GetTableDestSlot(nSelPos));
+ if (SfxItemState::SET == maSet.GetItemState(nWhich))
+ {
+ SvxBrushItem aBrushItem(static_cast<const SvxBrushItem&>(maSet.Get(nWhich)));
+ setSvxBrushItemAsFillAttributesToTargetSet(aBrushItem, maSet);
+ }
+ else
+ {
+ SelectFillType(*m_xBtnNone, &maSet);
+ return;
+ }
+
+ // show tab page
+ drawing::FillStyle eXFS = drawing::FillStyle_NONE;
+ if (maSet.GetItemState(XATTR_FILLSTYLE) != SfxItemState::DONTCARE)
+ {
+ XFillStyleItem aFillStyleItem(static_cast<const XFillStyleItem&>(maSet.Get(GetWhich( XATTR_FILLSTYLE))));
+ eXFS = aFillStyleItem.GetValue();
+ }
+ switch(eXFS)
+ {
+ default:
+ case drawing::FillStyle_NONE:
+ {
+ SelectFillType(*m_xBtnNone, &maSet);
+ break;
+ }
+ case drawing::FillStyle_SOLID:
+ {
+ SelectFillType(*m_xBtnColor, &maSet);
+ // color tab page Active and New preview controls are same after SelectFillType
+ // hack to restore color tab page Active preview
+ setSvxBrushItemAsFillAttributesToTargetSet(static_cast<const SvxBrushItem&>(m_pResetSet->Get(nWhich)), *m_pResetSet);
+ static_cast<SvxColorTabPage*>(GetFillTabPage())->SetCtlPreviewOld(*m_pResetSet);
+ break;
+ }
+ case drawing::FillStyle_BITMAP:
+ {
+ SelectFillType(*m_xBtnBitmap, &maSet);
+ break;
+ }
+ }
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index a311becb2fe1..54615fdbbd56 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -369,8 +369,16 @@ VclPtr<SfxTabPage> lcl_CreateFillStyleTabPage(sal_uInt16 nId, TabPageParent pPar
IMPL_LINK(SvxAreaTabPage, SelectFillTypeHdl_Impl, weld::ToggleButton&, rButton, void)
{
+ SelectFillType(rButton);
+}
+
+void SvxAreaTabPage::SelectFillType(weld::ToggleButton& rButton, const SfxItemSet* _pSet)
+{
+ if (_pSet)
+ m_rXFSet.Set(*_pSet);
+
sal_Int32 nPos = maBox.GetButtonPos(&rButton);
- if(nPos != -1 && nPos != maBox.GetCurrentButtonPos())
+ if (nPos != -1 && (_pSet || nPos != maBox.GetCurrentButtonPos()))
{
maBox.SelectButton(&rButton);
FillType eFillType = static_cast<FillType>(maBox.GetCurrentButtonPos());