include/svx/svdograf.hxx | 3 - svx/source/sdr/properties/graphicproperties.cxx | 11 ---- svx/source/svdraw/svdograf.cxx | 54 +++++++++--------------- 3 files changed, 21 insertions(+), 47 deletions(-)
New commits: commit ce27c727294598eb99ac7b7e70e74a7dcecd87b3 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Oct 21 20:27:40 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Oct 22 11:44:10 2024 +0200 no need to cache GraphicAttr in SdrGrafObj just retrieve the data when we need it, avoids marking this object dirty unnecessarily Change-Id: Ic3455e782365e8f2d3b89d8e5052da9d7bdaba2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175371 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 88296f4a2629..fae28c0a72dc 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -78,9 +78,6 @@ private: SAL_DLLPRIVATE virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override; SAL_DLLPRIVATE virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override; - SAL_DLLPRIVATE void ImpSetAttrToGrafInfo(); // Copy values from the pool - GraphicAttr m_aGrafInfo; - OUString m_aFileName; // If it's a Link, the filename can be found in here OUString m_aFilterName; std::unique_ptr<GraphicObject> mpGraphicObject; // In order to speed up output of bitmaps, especially rotated ones diff --git a/svx/source/sdr/properties/graphicproperties.cxx b/svx/source/sdr/properties/graphicproperties.cxx index 90e7820f1200..0df3ee38bad1 100644 --- a/svx/source/sdr/properties/graphicproperties.cxx +++ b/svx/source/sdr/properties/graphicproperties.cxx @@ -101,14 +101,6 @@ namespace sdr::properties // local changes rObj.SetXPolyDirty(); - // #i29367# Update GraphicAttr, too. This was formerly - // triggered by SdrGrafObj::Notify, which is no longer - // called nowadays. BTW: strictly speaking, the whole - // ImpSetAttrToGrafInfostuff could - // be dumped, when SdrGrafObj::aGrafInfo is removed and - // always created on the fly for repaint. - rObj.ImpSetAttrToGrafInfo(); - // call parent RectangleProperties::ItemSetChanged(aChangedItems, nDeletedWhich, bAdjustTextFrameWidthAndHeight); } @@ -122,9 +114,6 @@ namespace sdr::properties // local changes SdrGrafObj& rObj = static_cast<SdrGrafObj&>(GetSdrObject()); rObj.SetXPolyDirty(); - - // local changes - rObj.ImpSetAttrToGrafInfo(); } void GraphicProperties::ForceDefaultAttributes() diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 57cb8780fef3..82a312c77d9c 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -252,8 +252,6 @@ SdrGrafObj::SdrGrafObj(SdrModel& rSdrModel, SdrGrafObj const & rSource) { SetGraphicLink( m_aFileName ); } - - ImpSetAttrToGrafInfo(); } SdrGrafObj::SdrGrafObj( @@ -412,12 +410,22 @@ GraphicAttr SdrGrafObj::GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlag const bool bRotate = bool( nTransformFlags & SdrGrafObjTransformsAttrs::ROTATE ) && (maGeo.m_nRotationAngle && maGeo.m_nRotationAngle != 18000_deg100); - // Need cropping info earlier - const_cast<SdrGrafObj*>(this)->ImpSetAttrToGrafInfo(); - // Actually transform the graphic only in this case. // Cropping always happens, though. - aActAttr = m_aGrafInfo; + const SfxItemSet& rSet = GetObjectItemSet(); + const sal_uInt16 nTrans = rSet.Get( SDRATTR_GRAFTRANSPARENCE ).GetValue(); + const SdrGrafCropItem& rCrop = rSet.Get( SDRATTR_GRAFCROP ); + + aActAttr.SetLuminance( rSet.Get( SDRATTR_GRAFLUMINANCE ).GetValue() ); + aActAttr.SetContrast( rSet.Get( SDRATTR_GRAFCONTRAST ).GetValue() ); + aActAttr.SetChannelR( rSet.Get( SDRATTR_GRAFRED ).GetValue() ); + aActAttr.SetChannelG( rSet.Get( SDRATTR_GRAFGREEN ).GetValue() ); + aActAttr.SetChannelB( rSet.Get( SDRATTR_GRAFBLUE ).GetValue() ); + aActAttr.SetGamma( rSet.Get( SDRATTR_GRAFGAMMA ).GetValue() * 0.01 ); + aActAttr.SetAlpha(255 - basegfx::fround<sal_uInt8>(nTrans * 2.55)); + aActAttr.SetInvert( rSet.Get( SDRATTR_GRAFINVERT ).GetValue() ); + aActAttr.SetDrawMode( rSet.Get( SDRATTR_GRAFMODE ).GetValue() ); + aActAttr.SetCrop( rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom() ); if( bMirror ) { @@ -481,12 +489,14 @@ Size SdrGrafObj::getOriginalSize() const else aSize = OutputDevice::LogicToLogic(aSize, GetGrafPrefMapMode(), MapMode(getSdrModelFromSdrObject().GetScaleUnit())); - if (m_aGrafInfo.IsCropped()) + const SfxItemSet& rSet = GetObjectItemSet(); + const SdrGrafCropItem& rCrop = rSet.Get( SDRATTR_GRAFCROP ); + if ( rCrop.GetLeft() != 0 || rCrop.GetTop() != 0 || rCrop.GetRight() != 0 || rCrop.GetBottom() != 0 ) // if is cropped { - const tools::Long aCroppedWidth(aSize.getWidth() - m_aGrafInfo.GetLeftCrop() - - m_aGrafInfo.GetRightCrop()); - const tools::Long aCroppedHeight(aSize.getHeight() - m_aGrafInfo.GetTopCrop() - - m_aGrafInfo.GetBottomCrop()); + const tools::Long aCroppedWidth(aSize.getWidth() - rCrop.GetLeft() + - rCrop.GetRight()); + const tools::Long aCroppedHeight(aSize.getHeight() - rCrop.GetTop() + - rCrop.GetBottom()); aSize = Size(aCroppedWidth, aCroppedHeight); } @@ -1018,7 +1028,6 @@ void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { SetXPolyDirty(); SdrRectObj::Notify( rBC, rHint ); - ImpSetAttrToGrafInfo(); } @@ -1027,27 +1036,6 @@ void SdrGrafObj::SetMirrored( bool _bMirrored ) m_bMirrored = _bMirrored; } -void SdrGrafObj::ImpSetAttrToGrafInfo() -{ - const SfxItemSet& rSet = GetObjectItemSet(); - const sal_uInt16 nTrans = rSet.Get( SDRATTR_GRAFTRANSPARENCE ).GetValue(); - const SdrGrafCropItem& rCrop = rSet.Get( SDRATTR_GRAFCROP ); - - m_aGrafInfo.SetLuminance( rSet.Get( SDRATTR_GRAFLUMINANCE ).GetValue() ); - m_aGrafInfo.SetContrast( rSet.Get( SDRATTR_GRAFCONTRAST ).GetValue() ); - m_aGrafInfo.SetChannelR( rSet.Get( SDRATTR_GRAFRED ).GetValue() ); - m_aGrafInfo.SetChannelG( rSet.Get( SDRATTR_GRAFGREEN ).GetValue() ); - m_aGrafInfo.SetChannelB( rSet.Get( SDRATTR_GRAFBLUE ).GetValue() ); - m_aGrafInfo.SetGamma( rSet.Get( SDRATTR_GRAFGAMMA ).GetValue() * 0.01 ); - m_aGrafInfo.SetAlpha(255 - basegfx::fround<sal_uInt8>(nTrans * 2.55)); - m_aGrafInfo.SetInvert( rSet.Get( SDRATTR_GRAFINVERT ).GetValue() ); - m_aGrafInfo.SetDrawMode( rSet.Get( SDRATTR_GRAFMODE ).GetValue() ); - m_aGrafInfo.SetCrop( rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom() ); - - SetXPolyDirty(); - SetBoundAndSnapRectsDirty(); -} - void SdrGrafObj::AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly ) { Size aSize;