summaryrefslogtreecommitdiff
path: root/sw/source/uibase/utlui/uitool.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-02-25 21:00:07 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-02-26 09:49:53 +0100
commit074fc4a1499aac6eb67cd0b2dca00a51071cff0e (patch)
treed36569cff20ecfdea219578904e04c763ed6401f /sw/source/uibase/utlui/uitool.cxx
parent8e157d2608715c0b871bffcb32d79d00ccb72061 (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/source/uibase/utlui/uitool.cxx')
-rw-r--r--sw/source/uibase/utlui/uitool.cxx92
1 files changed, 28 insertions, 64 deletions
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