include/svl/itemset.hxx | 6 --- sd/source/ui/annotations/annotationwindow.cxx | 31 ++++++++++++++++-- sd/uiconfig/simpress/ui/annotation.ui | 9 ++++- svl/source/items/itemset.cxx | 22 +++++-------- sw/inc/swatrset.hxx | 14 +------- sw/source/core/attr/swatrset.cxx | 44 +------------------------- 6 files changed, 50 insertions(+), 76 deletions(-)
New commits: commit 25bd91293cd3ac7bf24f491e8eab254aa78d9fcb Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sun Jun 16 21:21:45 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Jun 17 09:39:55 2024 +0200 Resolves: tdf#160681 draw impress comment similarly to how writer does it so we get the same filled MenuButton in both applications Change-Id: Iea41a17285287ec2794e4cdce6eaae0906fff291 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168969 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx index a0bfe018023f..b3d8778fe780 100644 --- a/sd/source/ui/annotations/annotationwindow.cxx +++ b/sd/source/ui/annotations/annotationwindow.cxx @@ -40,11 +40,13 @@ #include <vcl/commandevent.hxx> #include <vcl/commandinfoprovider.hxx> +#include <vcl/decoview.hxx> #include <vcl/vclenum.hxx> #include <vcl/svapp.hxx> #include <vcl/gradient.hxx> #include <vcl/settings.hxx> #include <vcl/ptrstyle.hxx> +#include <vcl/virdev.hxx> #include <strings.hrc> #include "annotationwindow.hxx" @@ -274,10 +276,7 @@ void AnnotationWindow::InitControls() if (mbReadonly) mxMenuButton->hide(); else - { - mxMenuButton->set_size_request(METABUTTON_WIDTH, METABUTTON_HEIGHT); mxMenuButton->connect_selected(LINK(this, AnnotationWindow, MenuItemSelectedHdl)); - } EEControlBits nCntrl = mpOutliner->GetControlWord(); nCntrl |= EEControlBits::PASTESPECIAL | EEControlBits::AUTOCORRECT | EEControlBits::USECHARATTRIBS | EEControlBits::NOCOLORS; @@ -553,6 +552,32 @@ void AnnotationWindow::SetColor() mxPopover->set_background(maColor); mxMenuButton->set_background(maColor); + ScopedVclPtrInstance<VirtualDevice> xVirDev; + xVirDev->SetLineColor(); + xVirDev->SetFillColor(maColor); + + Size aSize(METABUTTON_WIDTH, METABUTTON_HEIGHT); + ::tools::Rectangle aRect(Point(0, 0), aSize); + xVirDev->SetOutputSizePixel(aSize); + xVirDev->DrawRect(aRect); + + ::tools::Rectangle aSymbolRect(aRect); + // 25% distance to the left and right button border + const ::tools::Long nBorderDistanceLeftAndRight = ((aSymbolRect.GetWidth() * 250) + 500) / 1000; + aSymbolRect.AdjustLeft(nBorderDistanceLeftAndRight ); + aSymbolRect.AdjustRight( -nBorderDistanceLeftAndRight ); + // 40% distance to the top button border + const ::tools::Long nBorderDistanceTop = ((aSymbolRect.GetHeight() * 400) + 500) / 1000; + aSymbolRect.AdjustTop(nBorderDistanceTop ); + // 15% distance to the bottom button border + const ::tools::Long nBorderDistanceBottom = ((aSymbolRect.GetHeight() * 150) + 500) / 1000; + aSymbolRect.AdjustBottom( -nBorderDistanceBottom ); + DecorationView aDecoView(xVirDev.get()); + aDecoView.DrawSymbol(aSymbolRect, SymbolType::SPIN_DOWN, COL_BLACK, + DrawSymbolFlags::NONE); + mxMenuButton->set_image(xVirDev); + mxMenuButton->set_size_request(aSize.Width() + 4, aSize.Height() + 4); + mxMeta->set_font_color(bHighContrast ? maColorLight : maColorDark); mxVScrollbar->customize_scrollbars(maColorLight, diff --git a/sd/uiconfig/simpress/ui/annotation.ui b/sd/uiconfig/simpress/ui/annotation.ui index 49a8a300e335..dcebff0f95d6 100644 --- a/sd/uiconfig/simpress/ui/annotation.ui +++ b/sd/uiconfig/simpress/ui/annotation.ui @@ -2,6 +2,12 @@ <!-- Generated with glade 3.38.2 --> <interface domain="sd"> <requires lib="gtk+" version="3.20"/> + <object class="GtkImage" id="image7"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">open-menu-symbolic</property> + <property name="icon_size">2</property> + </object> <object class="GtkMenu" id="menu"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -140,8 +146,9 @@ <property name="valign">start</property> <property name="margin-end">10</property> <property name="margin-top">5</property> + <property name="image">image7</property> <property name="relief">none</property> - <property name="draw-indicator">True</property> + <property name="always-show-image">True</property> <property name="popup">menu</property> <child> <placeholder/> commit 15cf55b0a6a504772b051d957a51e7c3bc2d2b38 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sun Jun 16 20:33:37 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Jun 17 09:39:47 2024 +0200 cid#1603617 Big parameter passed by value and ~20 of similar warning The current size of SfxItemSet is 144 bytes, and std::function is 32 bytes of that. If we reintroduce Changed as a virtual method we can avoid the need for this callback. All of the calculation work that was originally unconditionally done, and then thrown away, was moved into the specific SwAttrSet case of this so the other normal cases don't do any wasted work anymore. Change-Id: Ieec90f6d28dad8a6bf1cf8f402042812bd81c331 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168967 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index 2a3ba3c915fa..3626ac54388b 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -101,17 +101,13 @@ class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet // the set SfxPoolItems, indexed by WhichID PoolItemMap m_aPoolItemMap; - // Notification-Callback mechanism for SwAttrSet in SW, functionPtr for callback - std::function<void(const SfxPoolItem*, const SfxPoolItem*)> m_aCallback; - // helpers to keep m_nRegister up-to-date void checkRemovePoolRegistration(const SfxPoolItem* pItem); void checkAddPoolRegistration(const SfxPoolItem* pItem); protected: // Notification-Callback mechanism for SwAttrSet in SW - void setCallback(const std::function<void(const SfxPoolItem*, const SfxPoolItem*)> &func) { m_aCallback = func; } - void clearCallback() { m_aCallback = nullptr; } + virtual void Changed(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const; virtual const SfxPoolItem* PutImpl( const SfxPoolItem&, bool bPassingOwnership ); const SfxPoolItem* PutImplAsTargetWhich( const SfxPoolItem&, sal_uInt16 nTargetWhich, bool bPassingOwnership ); diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 47831c009b85..251194194d11 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -271,7 +271,6 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool) #endif , m_aWhichRanges(rPool.GetMergedIdRanges()) , m_aPoolItemMap() -, m_aCallback() { #ifdef DBG_UTIL nAllocatedSfxItemSetCount++; @@ -289,7 +288,6 @@ SfxItemSet::SfxItemSet(SfxItemPool& pool, WhichRangesContainer wids) #endif , m_aWhichRanges(std::move(wids)) , m_aPoolItemMap() -, m_aCallback() { #ifdef DBG_UTIL nAllocatedSfxItemSetCount++; @@ -308,7 +306,6 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet ) #endif , m_aWhichRanges( rASet.m_aWhichRanges ) , m_aPoolItemMap() -, m_aCallback(rASet.m_aCallback) { #ifdef DBG_UTIL nAllocatedSfxItemSetCount++; @@ -334,7 +331,6 @@ SfxItemSet::SfxItemSet(SfxItemSet&& rASet) noexcept #endif , m_aWhichRanges( std::move(rASet.m_aWhichRanges) ) , m_aPoolItemMap( std::move(rASet.m_aPoolItemMap) ) -, m_aCallback(rASet.m_aCallback) { #ifdef DBG_UTIL nAllocatedSfxItemSetCount++; @@ -354,7 +350,6 @@ SfxItemSet::SfxItemSet(SfxItemSet&& rASet) noexcept rASet.m_pParent = nullptr; rASet.m_nRegister = 0; rASet.m_aWhichRanges.reset(); - rASet.m_aCallback = nullptr; assert(m_aWhichRanges.validRanges2()); } @@ -768,10 +763,7 @@ void SfxItemSet::ClearSingleItem_PrepareRemove(const SfxPoolItem* pItem) return; // Notification-Callback - if(m_aCallback) - { - m_aCallback(pItem, nullptr); - } + Changed(pItem, nullptr); // check register for remove checkRemovePoolRegistration(pItem); @@ -1000,10 +992,7 @@ const SfxPoolItem* SfxItemSet::PutImpl(const SfxPoolItem& rItem, bool bPassingOw const SfxPoolItem* pNew(implCreateItemEntry(*GetPool(), &rItem, bPassingOwnership)); // Notification-Callback - if(m_aCallback) - { - m_aCallback(pEntry, pNew); - } + Changed(pEntry, pNew); // check register for add/remove. add first so that unregister/register // is avoided when an Item is replaced (increase, decrease, do not reach 0) @@ -1329,6 +1318,13 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const return GetPool()->GetUserOrPoolDefaultItem(nWhich); } +/** + * Notification callback + */ +void SfxItemSet::Changed(const SfxPoolItem*, const SfxPoolItem*) const +{ +} + /** * Only retain the Items that are also present in rSet * (nevermind their value). diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx index b729ac14aaac..78f3d42f9c4a 100644 --- a/sw/inc/swatrset.hxx +++ b/sw/inc/swatrset.hxx @@ -165,19 +165,9 @@ class SW_DLLPUBLIC SwAttrSet final : public SfxItemSet SwAttrSet *m_pOldSet; SwAttrSet *m_pNewSet; - // helper class for change callback & local instance - // needed to forward the processing call to the correct instance - class callbackHolder final - { - private: - SwAttrSet* m_Set; - public: - callbackHolder(SwAttrSet* pSet) : m_Set(pSet) {} - void operator () (const SfxPoolItem* pOld, const SfxPoolItem* pNew) { m_Set->changeCallback(pOld, pNew); } - } m_aCallbackHolder; - // processor for change callback - void changeCallback(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const; + virtual void Changed(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const override; + public: SwAttrSet( SwAttrPool&, sal_uInt16 nWhich1, sal_uInt16 nWhich2 ); SwAttrSet( SwAttrPool&, const WhichRangesContainer& nWhichPairTable ); diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx index d43e0fc65113..1c940aee9089 100644 --- a/sw/source/core/attr/swatrset.cxx +++ b/sw/source/core/attr/swatrset.cxx @@ -88,9 +88,9 @@ SwAttrPool::~SwAttrPool() } /// Notification callback -void SwAttrSet::changeCallback(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const +void SwAttrSet::Changed(const SfxPoolItem* pOld, const SfxPoolItem* pNew) const { - // will have no effect, return + // when neither pOld nor pNew is set, no need to do anything so return if (nullptr == m_pOldSet && nullptr == m_pNewSet) return; @@ -168,7 +168,6 @@ SwAttrSet::SwAttrSet( SwAttrPool& rPool, sal_uInt16 nWh1, sal_uInt16 nWh2 ) : SfxItemSet( rPool, nWh1, nWh2 ) , m_pOldSet( nullptr ) , m_pNewSet( nullptr ) - , m_aCallbackHolder(this) { } @@ -176,7 +175,6 @@ SwAttrSet::SwAttrSet( SwAttrPool& rPool, const WhichRangesContainer& nWhichPairT : SfxItemSet( rPool, nWhichPairTable ) , m_pOldSet( nullptr ) , m_pNewSet( nullptr ) - , m_aCallbackHolder(this) { } @@ -184,7 +182,6 @@ SwAttrSet::SwAttrSet( const SwAttrSet& rSet ) : SfxItemSet( rSet ) , m_pOldSet( nullptr ) , m_pNewSet( nullptr ) - , m_aCallbackHolder(this) { } @@ -232,15 +229,9 @@ SwAttrSet SwAttrSet::CloneAsValue( bool bItems ) const bool SwAttrSet::Put_BC( const SfxPoolItem& rAttr, SwAttrSet* pOld, SwAttrSet* pNew ) { - // direct call when neither pOld nor pNew is set, no need for callback - if (nullptr == pOld && nullptr == pNew) - return nullptr != SfxItemSet::Put( rAttr ); - m_pNewSet = pNew; m_pOldSet = pOld; - setCallback(m_aCallbackHolder); bool bRet = nullptr != SfxItemSet::Put( rAttr ); - clearCallback(); m_pOldSet = m_pNewSet = nullptr; return bRet; } @@ -248,15 +239,9 @@ bool SwAttrSet::Put_BC( const SfxPoolItem& rAttr, bool SwAttrSet::Put_BC( const SfxItemSet& rSet, SwAttrSet* pOld, SwAttrSet* pNew ) { - // direct call when neither pOld nor pNew is set, no need for callback - if (nullptr == pOld && nullptr == pNew) - return SfxItemSet::Put( rSet ); - m_pNewSet = pNew; m_pOldSet = pOld; - setCallback(m_aCallbackHolder); bool bRet = SfxItemSet::Put( rSet ); - clearCallback(); m_pOldSet = m_pNewSet = nullptr; return bRet; } @@ -264,15 +249,9 @@ bool SwAttrSet::Put_BC( const SfxItemSet& rSet, sal_uInt16 SwAttrSet::ClearItem_BC( sal_uInt16 nWhich, SwAttrSet* pOld, SwAttrSet* pNew ) { - // direct call when neither pOld nor pNew is set, no need for callback - if (nullptr == pOld && nullptr == pNew) - return SfxItemSet::ClearItem( nWhich ); - m_pNewSet = pNew; m_pOldSet = pOld; - setCallback(m_aCallbackHolder); sal_uInt16 nRet = SfxItemSet::ClearItem( nWhich ); - clearCallback(); m_pOldSet = m_pNewSet = nullptr; return nRet; } @@ -283,20 +262,10 @@ sal_uInt16 SwAttrSet::ClearItem_BC( sal_uInt16 nWhich1, sal_uInt16 nWhich2, OSL_ENSURE( nWhich1 <= nWhich2, "no valid range" ); sal_uInt16 nRet = 0; - // direct call when neither pOld nor pNew is set, no need for callback - if (nullptr == pOld && nullptr == pNew) - { - for( ; nWhich1 <= nWhich2; ++nWhich1 ) - nRet = nRet + SfxItemSet::ClearItem( nWhich1 ); - return nRet; - } - m_pNewSet = pNew; m_pOldSet = pOld; - setCallback(m_aCallbackHolder); for( ; nWhich1 <= nWhich2; ++nWhich1 ) nRet = nRet + SfxItemSet::ClearItem( nWhich1 ); - clearCallback(); m_pOldSet = m_pNewSet = nullptr; return nRet; } @@ -304,18 +273,9 @@ sal_uInt16 SwAttrSet::ClearItem_BC( sal_uInt16 nWhich1, sal_uInt16 nWhich2, int SwAttrSet::Intersect_BC( const SfxItemSet& rSet, SwAttrSet* pOld, SwAttrSet* pNew ) { - // direct call when neither pOld nor pNew is set, no need for callback - if (nullptr == pOld && nullptr == pNew) - { - SfxItemSet::Intersect( rSet ); - return 0; // as below when neither pOld nor pNew is set - } - m_pNewSet = pNew; m_pOldSet = pOld; - setCallback(m_aCallbackHolder); SfxItemSet::Intersect( rSet ); - clearCallback(); m_pOldSet = m_pNewSet = nullptr; return pNew ? pNew->Count() : pOld->Count(); }