diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2018-11-02 15:53:05 +0100 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2018-11-05 19:28:22 +0100 |
commit | cd7054b5e49f435349860d55bcff5a78d14a5f67 (patch) | |
tree | 3e07a4cf2894c09dfbe239493486c9e7763bbedc /drawinglayer | |
parent | 485efed71807ecee5ce69fa556db98dbc78a97e5 (diff) |
Added rotation support for DrawString and DrawDriverString
The EmfPlusDrawString record specifies text output with string formatting.
The EmfPlusDrawDriverString record specifies text output
with character positions.
Now both EMF+ records properly support rotation.
Change-Id: I15a7a6dd2b8a209cf2aac2af75d7dd89cedd1aeb
Reviewed-on: https://gerrit.libreoffice.org/62783
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 104 |
1 files changed, 42 insertions, 62 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index c7ccf3a67ba6..c9002681e6f5 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -33,6 +33,7 @@ #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/attribute/fontattribute.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <basegfx/polygon/b2dpolygonclipper.hxx> @@ -1366,7 +1367,8 @@ namespace emfplushelper } const basegfx::B2DHomMatrix transformMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix( - MapSize(font->emSize, font->emSize), Map(lx + stringAlignmentHorizontalOffset, ly + font->emSize)); + ::basegfx::B2DSize(font->emSize, font->emSize), + ::basegfx::B2DPoint(lx + stringAlignmentHorizontalOffset, ly + font->emSize)); const Color color = EMFPGetBrushColorOrARGBColor(flags, brushId); mrPropertyHolders.Current().setTextColor(color.getBColor()); @@ -1375,38 +1377,28 @@ namespace emfplushelper if (color.GetTransparency() < 255) { std::vector<double> emptyVector; - if (color.GetTransparency() == 0) + drawinglayer::primitive2d::Primitive2DReference aPrimitiveText( + new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + transformMatrix, + text, + 0, // text always starts at 0 + stringLength, + emptyVector, // EMF-PLUS has no DX-array + fontAttribute, + locale, + color.getBColor())); + + if (color.GetTransparency() != 0) { - // not transparent - mrTargetHolders.Current().append( - o3tl::make_unique<drawinglayer::primitive2d::TextSimplePortionPrimitive2D>( - transformMatrix, - text, - 0, // text always starts at 0 - stringLength, - emptyVector, // EMF-PLUS has no DX-array - fontAttribute, - locale, - color.getBColor())); + aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( + drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText }, + color.GetTransparency() / 255.0); } - else - { - const drawinglayer::primitive2d::Primitive2DReference aPrimitive( - new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( - transformMatrix, - text, - 0, // text always starts at 0 - stringLength, - emptyVector, // EMF-PLUS has no DX-array - fontAttribute, - locale, - color.getBColor())); - mrTargetHolders.Current().append( - o3tl::make_unique<drawinglayer::primitive2d::UnifiedTransparencePrimitive2D>( - drawinglayer::primitive2d::Primitive2DContainer { aPrimitive }, - color.GetTransparency() / 255.0)); - } + mrTargetHolders.Current().append( + o3tl::make_unique<drawinglayer::primitive2d::TransformPrimitive2D>( + maMapTransform, + drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText } )); } } else @@ -1794,45 +1786,33 @@ namespace emfplushelper // last entry aDXArray.push_back(0); - // prepare transform matrix basegfx::B2DHomMatrix transformMatrix = basegfx::utils::createScaleTranslateB2DHomMatrix( - MapSize(font->emSize,font->emSize),Map(charsPosX[pos],charsPosY[pos])); + ::basegfx::B2DSize(font->emSize, font->emSize), + ::basegfx::B2DPoint(charsPosX[pos], charsPosY[pos])); if (hasMatrix) transformMatrix *= transform; if (color.GetTransparency() < 255) { - if (color.GetTransparency() == 0) - { - // not transparent - mrTargetHolders.Current().append( - o3tl::make_unique<drawinglayer::primitive2d::TextSimplePortionPrimitive2D>( - transformMatrix, - text, - pos, // take character at current pos - aLength, // use determined length - aDXArray, // generated DXArray - fontAttribute, - Application::GetSettings().GetLanguageTag().getLocale(), - color.getBColor())); - } - else + drawinglayer::primitive2d::Primitive2DReference aPrimitiveText( + new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + transformMatrix, + text, + pos, // take character at current pos + aLength, // use determined length + aDXArray, // generated DXArray + fontAttribute, + Application::GetSettings().GetLanguageTag().getLocale(), + color.getBColor())); + if (color.GetTransparency() != 0) { - const drawinglayer::primitive2d::Primitive2DReference aPrimitive( - new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( - transformMatrix, - text, - pos, // take character at current pos - aLength, // use determined length - aDXArray, // generated DXArray - fontAttribute, - Application::GetSettings().GetLanguageTag().getLocale(), - color.getBColor())); - - mrTargetHolders.Current().append( - o3tl::make_unique<drawinglayer::primitive2d::UnifiedTransparencePrimitive2D>( - drawinglayer::primitive2d::Primitive2DContainer { aPrimitive }, - color.GetTransparency() / 255.0)); + aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( + drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText }, + color.GetTransparency() / 255.0); } + mrTargetHolders.Current().append( + o3tl::make_unique<drawinglayer::primitive2d::TransformPrimitive2D>( + maMapTransform, + drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText } )); } // update pos |