[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - cui/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Mar 19 12:46:35 UTC 2019


 cui/source/inc/backgrnd.hxx      |    6 +
 cui/source/inc/cuitabarea.hxx    |    5 +
 cui/source/tabpages/backgrnd.cxx |  154 +++++++++++++++++++++++++++++++++++----
 cui/source/tabpages/tparea.cxx   |   10 ++
 4 files changed, 159 insertions(+), 16 deletions(-)

New commits:
commit 95355f66fdeddb4146f3ee14db899c70b09e54e7
Author:     Jim Raykowski <raykowj at gmail.com>
AuthorDate: Tue Jan 22 18:50:23 2019 -0900
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Mar 19 13:46:12 2019 +0100

    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 at gmail.com>
    (cherry picked from commit 222b5b5b9b0d0419e30961261c63ff8585550b81)
    Reviewed-on: https://gerrit.libreoffice.org/69168
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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 d23a5209a78a..f98a6acc9c6f 100644
--- a/cui/source/inc/cuitabarea.hxx
+++ b/cui/source/inc/cuitabarea.hxx
@@ -252,6 +252,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 efcc9d270be9..9c29a1ae725a 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) ||
@@ -1521,7 +1582,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 b29d8147889a..4705f95cf44e 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -370,8 +370,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());


More information about the Libreoffice-commits mailing list