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 /sw | |
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 'sw')
-rw-r--r-- | sw/source/core/bastyp/init.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/envelp/envfmt.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/app/docst.cxx | 6 | ||||
-rw-r--r-- | sw/source/uibase/inc/uitool.hxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/utlui/uitool.cxx | 92 |
6 files changed, 39 insertions, 81 deletions
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index 409b36f05984..aece5124d461 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -302,8 +302,8 @@ SfxItemInfo aSlotTab[] = { SID_ATTR_CHAR_HIDDEN, true }, // RES_CHRATR_HIDDEN { SID_ATTR_CHAR_OVERLINE, true }, // RES_CHRATR_OVERLINE { 0, true }, // RES_CHRATR_RSID - { 0, true }, // RES_CHRATR_BOX - { 0, true }, // RES_CHRATR_SHADOW + { SID_ATTR_CHAR_BOX, true }, // RES_CHRATR_BOX + { SID_ATTR_CHAR_SHADOW, true }, // RES_CHRATR_SHADOW { 0, true }, // RES_CHRATR_HIGHLIGHT { SID_ATTR_CHAR_GRABBAG, true }, // RES_CHRATR_GRABBAG { 0, true }, // RES_CHRATR_BIDIRTL diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index f4a90609cb3a..2b5cb4583d6c 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -276,7 +276,7 @@ IMPL_LINK( SwEnvFormatPage, EditHdl, MenuButton *, pButton, void ) // In order for the background color not to get ironed over: SfxAllItemSet aTmpSet(*pCollSet); - ::ConvertAttrCharToGen(aTmpSet, CONV_ATTR_ENV); + ::ConvertAttrCharToGen(aTmpSet); SwAbstractDialogFactory* pFact = swui::GetFactory(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); @@ -287,7 +287,7 @@ IMPL_LINK( SwEnvFormatPage, EditHdl, MenuButton *, pButton, void ) if (pDlg->Execute() == RET_OK) { SfxItemSet aOutputSet( *pDlg->GetOutputItemSet() ); - ::ConvertAttrGenToChar(aOutputSet, aTmpSet, CONV_ATTR_ENV); + ::ConvertAttrGenToChar(aOutputSet, aTmpSet); pCollSet->Put(aOutputSet); } } diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index ab91f5e13f26..9b785bf31c9a 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -601,7 +601,7 @@ IMPL_LINK_NOARG(ApplyStyle, ApplyHdl, LinkParamNone*, void) SfxItemSet aTmpSet( *m_pDlg->GetOutputItemSet() ); if( SfxStyleFamily::Char == m_nFamily ) { - ::ConvertAttrGenToChar(aTmpSet, m_xTmp->GetItemSet(), CONV_ATTR_STD); + ::ConvertAttrGenToChar(aTmpSet, m_xTmp->GetItemSet()); } m_xTmp->SetItemSet( aTmpSet ); @@ -784,7 +784,7 @@ void SwDocShell::Edit( } else if( SfxStyleFamily::Char == nFamily ) { - ::ConvertAttrCharToGen(xTmp->GetItemSet(), CONV_ATTR_STD); + ::ConvertAttrCharToGen(xTmp->GetItemSet()); } if(SfxStyleFamily::Page == nFamily || SfxStyleFamily::Para == nFamily) @@ -880,7 +880,7 @@ void SwDocShell::Edit( ::SfxToSwPageDescAttr( *GetWrtShell(), xTmp->GetItemSet() ); else { - ::ConvertAttrGenToChar(xTmp->GetItemSet(), xTmp->GetItemSet(), CONV_ATTR_STD); + ::ConvertAttrGenToChar(xTmp->GetItemSet(), xTmp->GetItemSet()); } if(SfxStyleFamily::Page == nFamily) m_pView->InvalidateRulerPos(); diff --git a/sw/source/uibase/inc/uitool.hxx b/sw/source/uibase/inc/uitool.hxx index 932c57ec0638..ec42b067593f 100644 --- a/sw/source/uibase/inc/uitool.hxx +++ b/sw/source/uibase/inc/uitool.hxx @@ -43,17 +43,12 @@ SW_DLLPUBLIC void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit); // fill BoxInfo attribute SW_DLLPUBLIC void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh); -// Modes for attribute conversion -#define CONV_ATTR_STD 1 // Standard character dialog -#define CONV_ATTR_ENV 2 // Character dialog opened from envelope dialog - /** * Convert character specific attributes to general ones used by tab pages. * * @param[in,out] rSet the set in which character attributes are stored - * @param[in] nMode specify the dialog which will be called after conversion **/ -SW_DLLPUBLIC void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode); +SW_DLLPUBLIC void ConvertAttrCharToGen(SfxItemSet& rSet); /** * Convert general attributes to the corresponding character attributes. @@ -61,9 +56,8 @@ SW_DLLPUBLIC void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode); * * @param[in,out] rSet the set in which character attributes are stored * @param[in] rOrigSet original itemset used as input for the dialog - * @param[in] nMode specify the dialog which was called before **/ -SW_DLLPUBLIC void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, const sal_uInt8 nMode); +SW_DLLPUBLIC void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet); // SfxItemSets <-> PageDesc void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc ); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 839326e70c34..4bf74057082c 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -164,7 +164,7 @@ void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const } pCoreSet->Put(SfxUInt16Item(SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, rWrtSh.GetScalingOfSelectedText())); - ::ConvertAttrCharToGen(*pCoreSet, CONV_ATTR_STD); + ::ConvertAttrCharToGen(*pCoreSet); // Setting the BoxInfo ::PrepareBoxInfo(*pCoreSet, rWrtSh); @@ -221,7 +221,7 @@ void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const static void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq) { SfxItemSet aTmpSet( *pSet ); - ::ConvertAttrGenToChar(aTmpSet, *pCoreSet, CONV_ATTR_STD); + ::ConvertAttrGenToChar(aTmpSet, *pCoreSet); const SfxPoolItem* pSelectionItem; bool bInsert = false; diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx index c8a8bfd49eca..04a175077474 100644 --- a/sw/source/uibase/utlui/uitool.cxx +++ b/sw/source/uibase/utlui/uitool.cxx @@ -122,7 +122,7 @@ void PrepareBoxInfo(SfxItemSet& rSet, const SwWrtShell& rSh) rSet.Put(aBoxInfo); } -void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode) +void ConvertAttrCharToGen(SfxItemSet& rSet) { // Background / highlight { @@ -139,79 +139,43 @@ void ConvertAttrCharToGen(SfxItemSet& rSet, const sal_uInt8 nMode) } } - if( nMode == CONV_ATTR_STD ) - { - // Border - const SfxPoolItem *pTmpItem; - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BOX, true, &pTmpItem ) ) - { - SvxBoxItem aTmpBox( *static_cast<const SvxBoxItem*>(pTmpItem) ); - aTmpBox.SetWhich( RES_BOX ); - rSet.Put( aTmpBox ); - } - else - rSet.ClearItem(RES_BOX); - - // Border shadow - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_SHADOW, false, &pTmpItem ) ) - { - SvxShadowItem aTmpShadow( *static_cast<const SvxShadowItem*>(pTmpItem) ); - aTmpShadow.SetWhich( RES_SHADOW ); - rSet.Put( aTmpShadow ); - } - else - rSet.ClearItem( RES_SHADOW ); - } + // Tell dialogs to use character-specific slots/whichIds + std::unique_ptr<SfxGrabBagItem> pGrabBag; + const SfxPoolItem *pTmpItem; + if (SfxItemState::SET == rSet.GetItemState(RES_CHRATR_GRABBAG, false, &pTmpItem)) + pGrabBag.reset(static_cast<SfxGrabBagItem*>(pTmpItem->Clone())); + else + pGrabBag.reset(new SfxGrabBagItem(RES_CHRATR_GRABBAG)); + pGrabBag->GetGrabBag()["DialogUseCharAttr"] <<= true; + rSet.Put(*pGrabBag); } -void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet, const sal_uInt8 nMode) +void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet) { // Background / highlighting + const SfxPoolItem *pTmpItem; + if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, false, &pTmpItem ) ) { - const SfxPoolItem *pTmpItem; - if( SfxItemState::SET == rSet.GetItemState( RES_CHRATR_BACKGROUND, false, &pTmpItem ) ) - { - // Highlight is an MS specific thing, so remove it at the first time when LO modifies - // this part of the imported document. - rSet.Put( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); + // Highlight is an MS specific thing, so remove it at the first time when LO modifies + // this part of the imported document. + rSet.Put( SvxBrushItem(RES_CHRATR_HIGHLIGHT) ); - // Remove shading marker - if( SfxItemState::SET == rOrigSet.GetItemState( RES_CHRATR_GRABBAG, false, &pTmpItem ) ) + // Remove shading marker + if( SfxItemState::SET == rOrigSet.GetItemState( RES_CHRATR_GRABBAG, false, &pTmpItem ) ) + { + SfxGrabBagItem aGrabBag(*static_cast<const SfxGrabBagItem*>(pTmpItem)); + std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag(); + auto aIterator = rMap.find("CharShadingMarker"); + if( aIterator != rMap.end() ) { - SfxGrabBagItem aGrabBag(*static_cast<const SfxGrabBagItem*>(pTmpItem)); - std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag(); - auto aIterator = rMap.find("CharShadingMarker"); - if( aIterator != rMap.end() ) - { - aIterator->second <<= false; - } - rSet.Put( aGrabBag ); + aIterator->second <<= false; } + // Remove temporary GrabBag entry before writing to destination set + rMap.erase("DialogUseCharAttr"); + rSet.Put( aGrabBag ); } - rSet.ClearItem( RES_BACKGROUND ); - } - - if( nMode == CONV_ATTR_STD ) - { - // Border - const SfxPoolItem *pTmpItem; - if( SfxItemState::SET == rSet.GetItemState( RES_BOX, false, &pTmpItem ) ) - { - SvxBoxItem aTmpBox( *static_cast<const SvxBoxItem*>(pTmpItem) ); - aTmpBox.SetWhich( RES_CHRATR_BOX ); - rSet.Put( aTmpBox ); - } - rSet.ClearItem( RES_BOX ); - - // Border shadow - if( SfxItemState::SET == rSet.GetItemState( RES_SHADOW, false, &pTmpItem ) ) - { - SvxShadowItem aTmpShadow( *static_cast<const SvxShadowItem*>(pTmpItem) ); - aTmpShadow.SetWhich( RES_CHRATR_SHADOW ); - rSet.Put( aTmpShadow ); - } - rSet.ClearItem( RES_SHADOW ); } + rSet.ClearItem( RES_BACKGROUND ); } // Fill header footer |