diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-02-25 21:00:07 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-02-26 09:49:53 +0100 |
commit | 074fc4a1499aac6eb67cd0b2dca00a51071cff0e (patch) | |
tree | d36569cff20ecfdea219578904e04c763ed6401f /cui/source/tabpages | |
parent | 8e157d2608715c0b871bffcb32d79d00ccb72061 (diff) |
tdf#116020: use actual whichIds in dialogs for character properties
... instead of converting back and forth between character-specific
whichIds and generic. This eliminates creating duplicate properties
in the set passed to dialog.
A temporary GrabBag entry "DialogUseCharAttr" is used to indicate
that dialogs should use character-specific Ids. This simplifies and
unifies preparation of the set for different dialogs.
Change-Id: I41b982ff05d54b0dfc283c07aef806f51c87209c
Reviewed-on: https://gerrit.libreoffice.org/50339
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cui/source/tabpages')
-rw-r--r-- | cui/source/tabpages/border.cxx | 32 | ||||
-rw-r--r-- | cui/source/tabpages/borderconn.cxx | 10 | ||||
-rw-r--r-- | cui/source/tabpages/borderconn.hxx | 2 |
3 files changed, 31 insertions, 13 deletions
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index 0ba63a11e4fa..0760e52d053d 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -39,6 +39,7 @@ #include <vcl/settings.hxx> #include <svx/flagsdef.hxx> #include <sfx2/request.hxx> +#include <svl/grabbagitem.hxx> #include <svl/intitem.hxx> #include <svl/ilstitem.hxx> #include <svl/int64item.hxx> @@ -96,6 +97,7 @@ SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCore : SfxTabPage(pParent, "BorderPage", "cui/ui/borderpage.ui", &rCoreAttrs) , nMinValue(0) , nSWMode(SwBorderModes::NONE) + , mnBoxSlot(SID_ATTR_BORDER_OUTER) , mbHorEnabled(false) , mbVerEnabled(false) , mbTLBREnabled(false) @@ -316,9 +318,25 @@ SvxBorderTabPage::SvxBorderTabPage(vcl::Window* pParent, const SfxItemSet& rCore FillLineListBox_Impl(); // connections - bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( SID_ATTR_BORDER_SHADOW ) ); + sal_uInt16 nShadowSlot = SID_ATTR_BORDER_SHADOW; + if (rCoreAttrs.HasItem(GetWhich(SID_ATTR_CHAR_GRABBAG), &pItem)) + { + const SfxGrabBagItem* pGrabBag = static_cast<const SfxGrabBagItem*>(pItem); + auto it = pGrabBag->GetGrabBag().find("DialogUseCharAttr"); + if (it != pGrabBag->GetGrabBag().end()) + { + bool bDialogUseCharAttr = false; + it->second >>= bDialogUseCharAttr; + if (bDialogUseCharAttr) + { + nShadowSlot = SID_ATTR_CHAR_SHADOW; + mnBoxSlot = SID_ATTR_CHAR_BOX; + } + } + } + bool bSupportsShadow = !SfxItemPool::IsSlot( GetWhich( nShadowSlot ) ); if( bSupportsShadow ) - AddItemConnection( svx::CreateShadowConnection( rCoreAttrs, *m_pWndShadows, *m_pEdShadowSize, *m_pLbShadowColor ) ); + AddItemConnection( svx::CreateShadowConnection( nShadowSlot, rCoreAttrs, *m_pWndShadows, *m_pEdShadowSize, *m_pLbShadowColor ) ); else HideShadowControls(); @@ -427,10 +445,10 @@ void SvxBorderTabPage::Reset( const SfxItemSet* rSet ) const SvxBoxItem* pBoxItem; const SvxBoxInfoItem* pBoxInfoItem; - sal_uInt16 nWhichBox = GetWhich(SID_ATTR_BORDER_OUTER); + sal_uInt16 nWhichBox = GetWhich(mnBoxSlot); MapUnit eCoreUnit; - pBoxItem = static_cast<const SvxBoxItem*>(GetItem( *rSet, SID_ATTR_BORDER_OUTER )); + pBoxItem = static_cast<const SvxBoxItem*>(GetItem( *rSet, mnBoxSlot )); pBoxInfoItem = GetItem( *rSet, SID_ATTR_BORDER_INNER, false ); @@ -648,12 +666,12 @@ bool SvxBorderTabPage::FillItemSet( SfxItemSet* rCoreAttrs ) bool bAttrsChanged = SfxTabPage::FillItemSet( rCoreAttrs ); bool bPut = true; - sal_uInt16 nBoxWhich = GetWhich( SID_ATTR_BORDER_OUTER ); + sal_uInt16 nBoxWhich = GetWhich( mnBoxSlot ); sal_uInt16 nBoxInfoWhich = rCoreAttrs->GetPool()->GetWhich( SID_ATTR_BORDER_INNER, false ); const SfxItemSet& rOldSet = GetItemSet(); SvxBoxItem aBoxItem ( nBoxWhich ); SvxBoxInfoItem aBoxInfoItem ( nBoxInfoWhich ); - const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( *rCoreAttrs, SID_ATTR_BORDER_OUTER )); + const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( *rCoreAttrs, mnBoxSlot )); MapUnit eCoreUnit = rOldSet.GetPool()->GetMetric( nBoxWhich ); @@ -1224,7 +1242,7 @@ void SvxBorderTabPage::UpdateRemoveAdjCellBorderCB( sal_uInt16 nPreset ) return; const SfxItemSet& rOldSet = GetItemSet(); const SvxBoxInfoItem* pOldBoxInfoItem = GetOldItem( rOldSet, SID_ATTR_BORDER_INNER ); - const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( rOldSet, SID_ATTR_BORDER_OUTER )); + const SvxBoxItem* pOldBoxItem = static_cast<const SvxBoxItem*>(GetOldItem( rOldSet, mnBoxSlot )); if( !pOldBoxInfoItem || !pOldBoxItem ) return; std::pair<svx::FrameBorderType, SvxBoxInfoItemValidFlags> eTypes1[] = { diff --git a/cui/source/tabpages/borderconn.cxx b/cui/source/tabpages/borderconn.cxx index 7b49f35022f1..78d2c3ba637e 100644 --- a/cui/source/tabpages/borderconn.cxx +++ b/cui/source/tabpages/borderconn.cxx @@ -254,13 +254,13 @@ void ShadowControlsWrapper::SetControlValue( SvxShadowItem aItem ) class ShadowConnection : public sfx::ItemControlConnection< ShadowItemWrapper, ShadowControlsWrapper > { public: - explicit ShadowConnection( const SfxItemSet& rItemSet, + explicit ShadowConnection( sal_uInt16 nSlot, const SfxItemSet& rItemSet, ValueSet& rVsPos, MetricField& rMfSize, SvxColorListBox& rLbColor ); }; -ShadowConnection::ShadowConnection( const SfxItemSet& rItemSet, +ShadowConnection::ShadowConnection( sal_uInt16 nSlot, const SfxItemSet& rItemSet, ValueSet& rVsPos, MetricField& rMfSize, SvxColorListBox& rLbColor ) : - ItemControlConnectionType( SID_ATTR_BORDER_SHADOW, new ShadowControlsWrapper( rVsPos, rMfSize, rLbColor ), ItemConnFlags::NONE ) + ItemControlConnectionType( nSlot, new ShadowControlsWrapper( rVsPos, rMfSize, rLbColor ), ItemConnFlags::NONE ) { mxCtrlWrp->SetDefaultValue( maItemWrp.GetDefaultItem( rItemSet ) ); } @@ -279,10 +279,10 @@ sfx::ItemConnectionBase* CreateMarginConnection( const SfxItemSet& rItemSet, return new MarginConnection( rItemSet, rMfLeft, rMfRight, rMfTop, rMfBottom ); } -sfx::ItemConnectionBase* CreateShadowConnection( const SfxItemSet& rItemSet, +sfx::ItemConnectionBase* CreateShadowConnection( sal_uInt16 nSlot, const SfxItemSet& rItemSet, ValueSet& rVsPos, MetricField& rMfSize, SvxColorListBox& rLbColor ) { - return new ShadowConnection( rItemSet, rVsPos, rMfSize, rLbColor ); + return new ShadowConnection( nSlot, rItemSet, rVsPos, rMfSize, rLbColor ); } diff --git a/cui/source/tabpages/borderconn.hxx b/cui/source/tabpages/borderconn.hxx index b04d4a8b0c1f..01b404667f49 100644 --- a/cui/source/tabpages/borderconn.hxx +++ b/cui/source/tabpages/borderconn.hxx @@ -46,7 +46,7 @@ sfx::ItemConnectionBase* CreateMarginConnection( const SfxItemSet& rItemSet, /** Creates an item connection object that connects an SvxShadowItem with the controls of the SvxBorderTabPage. */ -sfx::ItemConnectionBase* CreateShadowConnection( const SfxItemSet& rItemSet, +sfx::ItemConnectionBase* CreateShadowConnection( sal_uInt16 nSlot, const SfxItemSet& rItemSet, ValueSet& rVsPos, MetricField& rMfSize, SvxColorListBox& rLbColor ); |