[Libreoffice-commits] core.git: cui/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 3 15:56:36 UTC 2018


 cui/source/tabpages/border.cxx |   63 +++++++++++++++++++++++++++++++++++------
 1 file changed, 54 insertions(+), 9 deletions(-)

New commits:
commit b094921089beeecb2333075e174c8b1fa6d1b812
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Sep 3 11:02:24 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Sep 3 17:56:14 2018 +0200

    expand CheckBox AddItemConnection
    
    Change-Id: I35e7f0e129186a863d0ddcc6ebcb86b81378ea78
    Reviewed-on: https://gerrit.libreoffice.org/59933
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 186c77a13827..d638e8657c62 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -333,6 +333,7 @@ SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCore
             }
         }
     }
+
     bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( nShadowSlot ) );
     if( bSupportsShadow )
         AddItemConnection( svx::CreateShadowConnection( nShadowSlot, rCoreAttrs, *m_pWndShadows, *m_pEdShadowSize, *m_pLbShadowColor ) );
@@ -345,13 +346,10 @@ SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCore
         AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_TLBR, *m_pFrameSel, svx::FrameBorderType::TLBR ) );
     if( m_pFrameSel->IsBorderEnabled( svx::FrameBorderType::BLTR ) )
         AddItemConnection( svx::CreateFrameLineConnection( SID_ATTR_BORDER_DIAG_BLTR, *m_pFrameSel, svx::FrameBorderType::BLTR ) );
-    // #i43593# - item connection doesn't work for Writer,
-    // because the Writer item sets contain these items
+
     // checkbox "Merge with next paragraph" only visible for Writer dialog format.paragraph
-    AddItemConnection( new sfx::CheckBoxConnection( SID_ATTR_BORDER_CONNECT, *m_pMergeWithNextCB, ItemConnFlags::NONE ) );
     m_pMergeWithNextCB->Hide();
     // checkbox "Merge adjacent line styles" only visible for Writer dialog format.table
-    AddItemConnection( new sfx::CheckBoxConnection( SID_SW_COLLAPSING_BORDERS, *m_pMergeAdjacentBordersCB, ItemConnFlags::NONE ) );
     m_pMergeAdjacentBordersCB->Hide();
 
     SfxObjectShell* pDocSh = SfxObjectShell::Current();
@@ -437,11 +435,27 @@ bool SvxBorderTabPage::IsBorderLineStyleAllowed( SvxBorderLineStyle nStyle ) con
     return maUsedBorderStyles.count(nStyle) > 0;
 }
 
-
 void SvxBorderTabPage::Reset( const SfxItemSet* rSet )
 {
     SfxTabPage::Reset( rSet );
 
+    SfxItemPool* pPool = rSet->GetPool();
+    sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
+    const SfxBoolItem *pMergeAdjacentBorders = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeAdjacentBordersId));
+    if (!pMergeAdjacentBorders)
+        m_pMergeAdjacentBordersCB->SetState(TRISTATE_INDET);
+    else
+        m_pMergeAdjacentBordersCB->Check(pMergeAdjacentBorders->GetValue());
+    m_pMergeAdjacentBordersCB->SaveValue();
+
+    sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
+    const SfxBoolItem *pMergeWithNext = static_cast<const SfxBoolItem*>(rSet->GetItem(nMergeWithNextId));
+    if (!pMergeWithNext)
+        m_pMergeWithNextCB->SetState(TRISTATE_INDET);
+    else
+        m_pMergeWithNextCB->Check(pMergeWithNext->GetValue());
+    m_pMergeWithNextCB->SaveValue();
+
     const SvxBoxItem*       pBoxItem;
     const SvxBoxInfoItem*   pBoxInfoItem;
     sal_uInt16              nWhichBox       = GetWhich(mnBoxSlot);
@@ -451,7 +465,7 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet )
 
     pBoxInfoItem = GetItem( *rSet, SID_ATTR_BORDER_INNER, false );
 
-    eCoreUnit = rSet->GetPool()->GetMetric( nWhichBox );
+    eCoreUnit = pPool->GetMetric( nWhichBox );
 
     if ( pBoxItem && pBoxInfoItem ) // -> Don't Care
     {
@@ -648,9 +662,10 @@ void SvxBorderTabPage::ChangesApplied()
     m_pRightMF->SaveValue();
     m_pTopMF->SaveValue();
     m_pBottomMF->SaveValue();
+    m_pMergeWithNextCB->SaveValue();
+    m_pMergeAdjacentBordersCB->SaveValue();
 }
 
-
 DeactivateRC SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
 {
     if ( _pSet )
@@ -659,14 +674,44 @@ DeactivateRC SvxBorderTabPage::DeactivatePage( SfxItemSet* _pSet )
     return DeactivateRC::LeavePage;
 }
 
-
 bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
 {
     bool bAttrsChanged = SfxTabPage::FillItemSet( rCoreAttrs );
 
+    SfxItemPool* pPool = rCoreAttrs->GetPool();
+    if (m_pMergeAdjacentBordersCB->IsValueChangedFromSaved())
+    {
+        sal_uInt16 nMergeAdjacentBordersId = pPool->GetWhich(SID_SW_COLLAPSING_BORDERS);
+        auto nState = m_pMergeAdjacentBordersCB->GetState();
+        if (nState == TRISTATE_INDET)
+            rCoreAttrs->ClearItem(nMergeAdjacentBordersId);
+        else
+        {
+            std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(rCoreAttrs->Get(nMergeAdjacentBordersId).Clone()));
+            xNewItem->SetValue(static_cast<bool>(nState));
+            rCoreAttrs->Put(*xNewItem);
+        }
+        bAttrsChanged = true;
+    }
+
+    if (m_pMergeWithNextCB->IsValueChangedFromSaved())
+    {
+        sal_uInt16 nMergeWithNextId = pPool->GetWhich(SID_ATTR_BORDER_CONNECT);
+        auto nState = m_pMergeWithNextCB->GetState();
+        if (nState == TRISTATE_INDET)
+            rCoreAttrs->ClearItem(nMergeWithNextId);
+        else
+        {
+            std::unique_ptr<SfxBoolItem> xNewItem(static_cast<SfxBoolItem*>(rCoreAttrs->Get(nMergeWithNextId).Clone()));
+            xNewItem->SetValue(static_cast<bool>(nState));
+            rCoreAttrs->Put(*xNewItem);
+        }
+        bAttrsChanged = true;
+    }
+
     bool                  bPut          = true;
     sal_uInt16            nBoxWhich     = GetWhich( mnBoxSlot );
-    sal_uInt16            nBoxInfoWhich = rCoreAttrs->GetPool()->GetWhich( SID_ATTR_BORDER_INNER, false );
+    sal_uInt16            nBoxInfoWhich = pPool->GetWhich( SID_ATTR_BORDER_INNER, false );
     const SfxItemSet&     rOldSet       = GetItemSet();
     SvxBoxItem            aBoxItem      ( nBoxWhich );
     SvxBoxInfoItem        aBoxInfoItem  ( nBoxInfoWhich );


More information about the Libreoffice-commits mailing list