diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de (CIB)> | 2018-02-15 15:41:50 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-02-16 10:36:51 +0100 |
commit | 0e687595295e210e6275eda57a253ca66e8249ce (patch) | |
tree | 1cdccbea4a0b9feb2de8f0ec257adbe588e88f57 /sw | |
parent | 3b93b176572971f00845e268c12eef94190d03bc (diff) |
tdf#115519: Handle rotation for WriterFlyFrames correctly
Change-Id: I5f29b3640eaf24d63c64edfecd6732f336582640
Reviewed-on: https://gerrit.libreoffice.org/49826
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/grfatr.hxx | 10 | ||||
-rw-r--r-- | sw/source/core/graphic/grfatr.cxx | 28 |
2 files changed, 34 insertions, 4 deletions
diff --git a/sw/inc/grfatr.hxx b/sw/inc/grfatr.hxx index 175bdcd480e3..f9e46068642a 100644 --- a/sw/inc/grfatr.hxx +++ b/sw/inc/grfatr.hxx @@ -87,14 +87,18 @@ public: class SwRotationGrf : public SfxUInt16Item { +private: Size aUnrotatedSize; + + // tdf#15529 check and evtl. correct value, it is in 10th + // degrees and *has* to be in the range [0 .. 3600[ + sal_Int16 checkAndCorrectValue(sal_Int16 nValue); + public: SwRotationGrf() : SfxUInt16Item( RES_GRFATR_ROTATION, 0 ) {} - SwRotationGrf( sal_Int16 nVal, const Size& rSz ) - : SfxUInt16Item( RES_GRFATR_ROTATION, nVal ), aUnrotatedSize( rSz ) - {} + SwRotationGrf( sal_Int16 nVal, const Size& rSz ); // pure virtual methods from SfxInt16Item virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override; diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx index 16565fe405e3..7300f574a26f 100644 --- a/sw/source/core/graphic/grfatr.cxx +++ b/sw/source/core/graphic/grfatr.cxx @@ -147,6 +147,31 @@ SfxPoolItem* SwCropGrf::Clone( SfxItemPool* ) const return new SwCropGrf( *this ); } +sal_Int16 SwRotationGrf::checkAndCorrectValue(sal_Int16 nValue) +{ + if(nValue < 0) + { + // smaller zero, modulo (will keep negative) and add one range + DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)"); + return 3600 + (nValue % 3600); + } + else if (nValue > 3600) + { + // bigger range, use modulo + DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)"); + return nValue % 3600; + } + + return nValue; +} + +SwRotationGrf::SwRotationGrf( sal_Int16 nVal, const Size& rSz ) + // tdf#15529 check and evtl. correct value +: SfxUInt16Item( RES_GRFATR_ROTATION, checkAndCorrectValue(nVal) ), + aUnrotatedSize( rSz ) +{ +} + SfxPoolItem* SwRotationGrf::Clone( SfxItemPool * ) const { return new SwRotationGrf( *this ); @@ -174,7 +199,8 @@ bool SwRotationGrf::PutValue( const uno::Any& rVal, sal_uInt8 ) if (rVal >>= nValue) { // sal_uInt16 argument needed - SetValue( static_cast<sal_uInt16>(nValue) ); + // tdf#15529 check and evtl. correct value + SetValue(static_cast<sal_uInt16>(checkAndCorrectValue(nValue))); return true; } |