diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-02-25 21:00:07 +0300 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-25 22:10:43 +0200 |
commit | 207ea7c8637112f6fb0eaf8b45a32bb37d5d25be (patch) | |
tree | c427d2dc5976c93aa3f3b940fafade5acc75c7bf /cui | |
parent | f20471d81bb0d22e124e8d599005373490eb2a71 (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.
Reviewed-on: https://gerrit.libreoffice.org/50339
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 074fc4a1499aac6eb67cd0b2dca00a51071cff0e)
Change-Id: I41b982ff05d54b0dfc283c07aef806f51c87209c
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/inc/border.hxx | 1 | ||||
-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 |
4 files changed, 32 insertions, 13 deletions
diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx index 6502549ac6d7..b8fb44b4021e 100644 --- a/cui/source/inc/border.hxx +++ b/cui/source/inc/border.hxx @@ -107,6 +107,7 @@ private: long nMinValue; ///< minimum distance SwBorderModes nSWMode; ///< table, textframe, paragraph + sal_uInt16 mnBoxSlot; bool mbHorEnabled; ///< true = Inner horizontal border enabled. bool mbVerEnabled; ///< true = Inner vertical border enabled. diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx index ce41f82989e7..e1e3cbcad398 100644 --- a/cui/source/tabpages/border.cxx +++ b/cui/source/tabpages/border.cxx @@ -40,6 +40,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> @@ -97,6 +98,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) @@ -317,9 +319,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(); @@ -428,10 +446,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 = static_cast<const SvxBoxInfoItem*>(GetItem( *rSet, SID_ATTR_BORDER_INNER, false )); @@ -649,12 +667,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 ); @@ -1226,7 +1244,7 @@ void SvxBorderTabPage::UpdateRemoveAdjCellBorderCB( sal_uInt16 nPreset ) return; const SfxItemSet& rOldSet = GetItemSet(); const SvxBoxInfoItem* pOldBoxInfoItem = static_cast<const SvxBoxInfoItem*>(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 ); |