summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-09-03 11:02:24 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-09-03 17:56:14 +0200
commitb094921089beeecb2333075e174c8b1fa6d1b812 (patch)
tree03685375533b917743f9a7a0d6bb89070d37cca6
parentf7c37579e6c348ec8d48ddbfb26e08ac09a8eeba (diff)
expand CheckBox AddItemConnection
Change-Id: I35e7f0e129186a863d0ddcc6ebcb86b81378ea78 Reviewed-on: https://gerrit.libreoffice.org/59933 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--cui/source/tabpages/border.cxx63
1 files changed, 54 insertions, 9 deletions
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 );