[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/inc sw/source xmloff/source
Armin Le Grand (CIB)
Armin.Le.Grand at cib.de
Mon Feb 19 13:47:01 UTC 2018
sw/inc/grfatr.hxx | 10 +++++++---
sw/source/core/graphic/grfatr.cxx | 28 +++++++++++++++++++++++++++-
xmloff/source/text/XMLTextFrameContext.cxx | 8 ++++++++
xmloff/source/text/txtparae.cxx | 11 +++++++++++
4 files changed, 53 insertions(+), 4 deletions(-)
New commits:
commit 58607318bf39053d2f20d47ae8e3e69e6b3eeb04
Author: Armin Le Grand <Armin.Le.Grand at cib.de (CIB)>
Date: Thu Feb 15 15:41:50 2018 +0100
tdf#115519: Handle rotation for WriterFlyFrames correctly
Adapted due to no transformation is written here, but still
controlling the values of persistent data is a good thing.
Change-Id: I5f29b3640eaf24d63c64edfecd6732f336582640
Reviewed-on: https://gerrit.libreoffice.org/49826
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>
Reviewed-on: https://gerrit.libreoffice.org/49897
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/inc/grfatr.hxx b/sw/inc/grfatr.hxx
index d4aa180dcddc..9d3d52f57985 100644
--- a/sw/inc/grfatr.hxx
+++ b/sw/inc/grfatr.hxx
@@ -92,14 +92,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( sal_Int16 nVal = 0 )
: SfxUInt16Item( RES_GRFATR_ROTATION, nVal )
{}
- 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 71cf98283d6b..163a5bcb600f 100644
--- a/sw/source/core/graphic/grfatr.cxx
+++ b/sw/source/core/graphic/grfatr.cxx
@@ -158,6 +158,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( GetValue(), aUnrotatedSize );
@@ -185,7 +210,8 @@ bool SwRotationGrf::PutValue( const uno::Any& rVal, sal_uInt8 )
if (rVal >>= nValue)
{
// sal_uInt16 argument needed
- SetValue( (sal_uInt16) nValue );
+ // tdf#15529 check and evtl. correct value
+ SetValue(static_cast<sal_uInt16>(checkAndCorrectValue(nValue)));
return true;
}
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index e7f81a6e6d27..2e0a50bb3f6b 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -1058,6 +1058,14 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
{
// RotGrfFlyFrame: is in 10th degrees
nRotation = (sal_Int16)(nVal % 3600 );
+
+ // tdf#115519 may be negative, with the above modulo maximal -3599, so
+ // no loop needed here. nRotation is used in setPropertyValue("GraphicRotation")
+ // and *has* to be in the range [0 .. 3600[
+ if(nRotation < 0)
+ {
+ nRotation += 3600;
+ }
}
}
}
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 41bd0d503898..763058f270b7 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3092,6 +3092,17 @@ void XMLTextParagraphExport::_exportTextGraphic(
rPropSet->getPropertyValue( sGraphicRotation ) >>= nVal;
if( nVal != 0 )
{
+ // tdf#115519 may be bigger 3600 or negative,
+ // correct to range [0 .. 3600[
+ if(nVal > 0)
+ {
+ nVal %= 3600;
+ }
+ else if(nVal < 0)
+ {
+ nVal = (nVal % 3600) + 3600;
+ }
+
OUStringBuffer sRet( GetXMLToken(XML_ROTATE).getLength()+4 );
sRet.append( GetXMLToken(XML_ROTATE));
sRet.append( '(' );
More information about the Libreoffice-commits
mailing list