This is an automated email from the ASF dual-hosted git repository. jimjag pushed a commit to branch odf-devel in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 7c10443cc3caa6a1ace9c6cb2e77475a4919c0fd Author: Jim Jagielski <[email protected]> AuthorDate: Thu Oct 29 08:47:04 2026 -0400 xmloff: write draw:transform for rotated Writer images in ODF 1.2 strict mode, read both --- main/xmloff/source/text/XMLTextFrameContext.cxx | 16 ++++++++++- main/xmloff/source/text/txtimp.cxx | 1 + main/xmloff/source/text/txtparae.cxx | 36 ++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/main/xmloff/source/text/XMLTextFrameContext.cxx b/main/xmloff/source/text/XMLTextFrameContext.cxx index 0cafd06099..7c7fb4064c 100644 --- a/main/xmloff/source/text/XMLTextFrameContext.cxx +++ b/main/xmloff/source/text/XMLTextFrameContext.cxx @@ -1067,7 +1067,21 @@ XMLTextFrameContext_Impl::XMLTextFrameContext_Impl( const OUString aRotate(GetXMLToken(XML_ROTATE)); const sal_Int32 nRotateLen(aRotate.getLength()); sal_Int32 nLen = sValue.getLength(); - if( nLen >= nRotateLen+3 && + if( XML_NAMESPACE_DRAW == nPrefix ) + { + // "translate (..) rotate (radians) translate (..)", only the angle is used + const sal_Int32 nPos = sValue.indexOf( aRotate ); + const sal_Int32 nOpen = nPos < 0 ? -1 : sValue.indexOf( (sal_Unicode)'(', nPos ); + const sal_Int32 nClose = nOpen < 0 ? -1 : sValue.indexOf( (sal_Unicode)')', nOpen ); + double fRad = 0.0; + if( nClose > 0 && SvXMLUnitConverter::convertDouble( fRad, + sValue.copy( nOpen+1, nClose-nOpen-1 ).trim() ) ) + { + const sal_Int32 nTenths = basegfx::fround( fmod( basegfx::rad2deg( fRad ), 360.0 ) * 10.0 ); + nRotation = (sal_Int16)( ( nTenths + 3600 ) % 3600 ); + } + } + else if( nLen >= nRotateLen+3 && 0 == sValue.compareTo( aRotate, nRotateLen ) && '(' == sValue[nRotateLen] && ')' == sValue[nLen-1] ) diff --git a/main/xmloff/source/text/txtimp.cxx b/main/xmloff/source/text/txtimp.cxx index 6e5efcd2c1..f49b7c859d 100644 --- a/main/xmloff/source/text/txtimp.cxx +++ b/main/xmloff/source/text/txtimp.cxx @@ -395,6 +395,7 @@ static __FAR_DATA SvXMLTokenMapEntry aTextFrameAttrTokenMap[] = { XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_TEXT_FRAME_FILTER_NAME }, { XML_NAMESPACE_DRAW, XML_ZINDEX, XML_TOK_TEXT_FRAME_Z_INDEX }, { XML_NAMESPACE_SVG, XML_TRANSFORM, XML_TOK_TEXT_FRAME_TRANSFORM }, + { XML_NAMESPACE_DRAW, XML_TRANSFORM, XML_TOK_TEXT_FRAME_TRANSFORM }, { XML_NAMESPACE_DRAW, XML_CLASS_ID, XML_TOK_TEXT_FRAME_CLASS_ID }, { XML_NAMESPACE_DRAW, XML_CODE, XML_TOK_TEXT_FRAME_CODE }, { XML_NAMESPACE_DRAW, XML_OBJECT, XML_TOK_TEXT_FRAME_OBJECT }, diff --git a/main/xmloff/source/text/txtparae.cxx b/main/xmloff/source/text/txtparae.cxx index 6192b2b4ea..dd5640e810 100644 --- a/main/xmloff/source/text/txtparae.cxx +++ b/main/xmloff/source/text/txtparae.cxx @@ -3046,7 +3046,41 @@ void XMLTextParagraphExport::_exportTextGraphic( // svg:transform sal_Int16 nVal = 0; rPropSet->getPropertyValue( sGraphicRotation ) >>= nVal; - if( nVal != 0 ) + if( nVal != 0 && GetExport().getDefaultVersion() == SvtSaveOptions::ODFVER_012 ) + { + // draw:transform, radians and counter-clockwise like GraphicRotation, about the frame centre + TextContentAnchorType eAnchor = TextContentAnchorType_AT_PARAGRAPH; + rPropSet->getPropertyValue( sAnchorType ) >>= eAnchor; + sal_Int16 nOrient = HoriOrientation::NONE; + sal_Int32 nX = 0, nY = 0, nW = 0, nH = 0; + rPropSet->getPropertyValue( sHoriOrient ) >>= nOrient; + if( HoriOrientation::NONE == nOrient && TextContentAnchorType_AS_CHARACTER != eAnchor ) + rPropSet->getPropertyValue( sHoriOrientPosition ) >>= nX; + nOrient = VertOrientation::NONE; + rPropSet->getPropertyValue( sVertOrient ) >>= nOrient; + if( VertOrientation::NONE == nOrient ) + rPropSet->getPropertyValue( sVertOrientPosition ) >>= nY; + rPropSet->getPropertyValue( sWidth ) >>= nW; + rPropSet->getPropertyValue( sHeight ) >>= nH; + const sal_Int32 nCX = nX + nW / 2; + const sal_Int32 nCY = nY + nH / 2; + SvXMLUnitConverter& rConv = GetExport().GetMM100UnitConverter(); + OUStringBuffer sRet; + sRet.appendAscii( "translate (" ); + rConv.convertMeasure( sRet, -nCX ); + sRet.append( (sal_Unicode)' ' ); + rConv.convertMeasure( sRet, -nCY ); + sRet.appendAscii( ") rotate (" ); + SvXMLUnitConverter::convertDouble( sRet, basegfx::deg2rad( nVal / 10.0 ) ); + sRet.appendAscii( ") translate (" ); + rConv.convertMeasure( sRet, nCX ); + sRet.append( (sal_Unicode)' ' ); + rConv.convertMeasure( sRet, nCY ); + sRet.append( (sal_Unicode)')' ); + GetExport().AddAttribute( XML_NAMESPACE_DRAW, XML_TRANSFORM, + sRet.makeStringAndClear() ); + } + else if( nVal != 0 ) { OUStringBuffer sRet( GetXMLToken(XML_ROTATE).getLength()+4 ); sRet.append( GetXMLToken(XML_ROTATE));
