diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2022-08-17 02:31:44 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-09-14 08:32:08 +0200 |
commit | c70ee4a6b9071468255e5d4fdb893e9c9bdf4fad (patch) | |
tree | 1df672814e562a42f0da889acbc9789322a67685 /svx/source/svdraw | |
parent | c97c60f70e9e6de594f7e0e0b85f17944c640dcf (diff) |
tdf#149551 use 'WritingMode' instead of TextPreRotateAngle
Commit 7e23cbdbb6ec0247a29ed8a8f744c01e10963ea0 changed the code so,
that TextPreRotateAngle is used to track ooxml vert attribute. This
patch changes it so, that the style attribute WritingMode is used.
Now text direction can be written in 'writing-mode' attribute in the
graphic properties in ODF, same for shapes as for frames.
The needed conversion from WritingMode BT-LR and TB_LR90 to
TextPreRotateAngle for rendering of text in custom shapes is now in
one place in class SdrObjectCustomshape. The shape edit engine
cannot yet render it itself.
Some unit tests are adapted to use WritingMode property instead of
TextPreRotateAngle.
The value text::WritingMode2::TB_RL90 is introduced, corresponding to
vert='vert' and textDirection='tbRl' or ='rl' in OOXML. It is used
for frames too, so that the original text direction is preserved and
vert='eaVert' can be distinguished from vert='vert'.
TextPreRotateAngle is currently still used in SmartArt import for
'upr' and 'grav' and in emulating 'upright' but no longer to
emulate text direction.
Change-Id: Idc4339bbfc3592fe90b154d75e2c404a1fa30856
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138813
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdoashp.cxx | 31 |
2 files changed, 31 insertions, 5 deletions
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index c0057b6aee70..86794dc92bfe 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -104,6 +104,7 @@ #include <sxsiitm.hxx> #include <sxsoitm.hxx> #include <sxtraitm.hxx> +#include <editeng/frmdiritem.hxx> #include <libxml/xmlwriter.h> using namespace ::com::sun::star; @@ -335,6 +336,8 @@ SdrItemPool::SdrItemPool( rPoolDefaults[SDRATTR_TEXTCOLUMNS_NUMBER - SDRATTR_START] = new SfxInt16Item(SDRATTR_TEXTCOLUMNS_NUMBER, 1); rPoolDefaults[SDRATTR_TEXTCOLUMNS_SPACING - SDRATTR_START] = new SdrMetricItem(SDRATTR_TEXTCOLUMNS_SPACING, 0); + rPoolDefaults[SDRATTR_WRITINGMODE2 - SDRATTR_START] = new SvxFrameDirectionItem(SvxFrameDirection::Horizontal_LR_TB, SDRATTR_WRITINGMODE2); + // set own ItemInfos mpLocalItemInfos[SDRATTR_SHADOW-SDRATTR_START]._nSID=SID_ATTR_FILL_SHADOW; mpLocalItemInfos[SDRATTR_SHADOWCOLOR-SDRATTR_START]._nSID=SID_ATTR_SHADOW_COLOR; @@ -359,6 +362,8 @@ SdrItemPool::SdrItemPool( mpLocalItemInfos[SDRATTR_TEXTCOLUMNS_NUMBER - SDRATTR_START]._nSID = 0 /*TODO*/; mpLocalItemInfos[SDRATTR_TEXTCOLUMNS_SPACING - SDRATTR_START]._nSID = 0 /*TODO*/; + mpLocalItemInfos[SDRATTR_WRITINGMODE2 - SDRATTR_START]._nSID = 0 /*TODO*/; + // it's my own creation level, set Defaults and ItemInfos SetDefaults(mpLocalPoolDefaults); SetItemInfos(mpLocalItemInfos.get()); diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 5993781186a7..30d959b865e9 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -86,6 +86,7 @@ #include <sal/log.hxx> #include <o3tl/string_view.hxx> #include "presetooxhandleadjustmentrelations.hxx" +#include <editeng/frmdiritem.hxx> using namespace ::com::sun::star; @@ -503,12 +504,32 @@ void SdrObjCustomShape::SetMirroredY( const bool bMirrorY ) double SdrObjCustomShape::GetExtraTextRotation( const bool bPreRotation ) const { - const uno::Any* pAny; - const SdrCustomShapeGeometryItem& rGeometryItem = GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); - pAny = rGeometryItem.GetPropertyValueByName( bPreRotation ? OUString( "TextPreRotateAngle" ) : OUString( "TextRotateAngle" ) ); double fExtraTextRotateAngle = 0.0; - if ( pAny ) - *pAny >>= fExtraTextRotateAngle; + if (bPreRotation) + { + // textPreRotateAngle might be set by macro or diagram (SmartArt) import + const uno::Any* pAny; + const SdrCustomShapeGeometryItem& rGeometryItem = GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); + pAny = rGeometryItem.GetPropertyValueByName(u"TextPreRotateAngle"); + if ( pAny ) + *pAny >>= fExtraTextRotateAngle; + + // As long as the edit engine is not able to rendere these text directions we + // emulate them by setting a suitable text pre-rotation. + const SvxFrameDirectionItem& rDirectionItem = GetMergedItem(SDRATTR_WRITINGMODE2); + if (rDirectionItem.GetValue() == SvxFrameDirection::Vertical_RL_TB90) + fExtraTextRotateAngle -= 90; + else if (rDirectionItem.GetValue() == SvxFrameDirection::Vertical_LR_BT) + fExtraTextRotateAngle -=270; + } + else + { + const uno::Any* pAny; + const SdrCustomShapeGeometryItem& rGeometryItem = GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ); + pAny = rGeometryItem.GetPropertyValueByName(u"TextRotateAngle"); + if ( pAny ) + *pAny >>= fExtraTextRotateAngle; + } return fExtraTextRotateAngle; } |