diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2018-11-04 02:39:09 +0100 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2018-11-07 23:27:00 +0100 |
commit | 8d4da5429548ba6ef4d3ee4dd6062c25a77ba78b (patch) | |
tree | a4a95c79542df61a82c76560aebbad73697ba8c6 /drawinglayer | |
parent | 2e4d92dd0662956da4570ac53d50ad7bffe70873 (diff) |
tdf#55058 tdf#106084 EMF+ Add support for Underline and Strikeout
Add support of Underline and Strikeout for DrawString and
DrawDriverString EMF+ records
Change-Id: I24c47e0d7524dabc13edd04c6b68aec69fa35e7b
Reviewed-on: https://gerrit.libreoffice.org/62827
Tested-by: Jenkins
Reviewed-by: Patrick Jaap <patrick.jaap@tu-dresden.de>
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 74 |
1 files changed, 58 insertions, 16 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index c9002681e6f5..dd95f2fb6027 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -30,6 +30,7 @@ #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx> +#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> @@ -1321,10 +1322,6 @@ namespace emfplushelper mrPropertyHolders.Current().setFont(vcl::Font(font->family, Size(font->emSize, font->emSize))); // done reading - // transform to TextSimplePortionPrimitive2D - // TODO add more decorations: underline, strikeout, etc - // and create a TextDecoratedPortionPrimitive2D - const OUString emptyString; drawinglayer::attribute::FontAttribute fontAttribute( font->family, // font family @@ -1377,8 +1374,10 @@ namespace emfplushelper if (color.GetTransparency() < 255) { std::vector<double> emptyVector; - drawinglayer::primitive2d::Primitive2DReference aPrimitiveText( - new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + drawinglayer::primitive2d::BasePrimitive2D* pBaseText = nullptr; + if (font->Underline() || font->Strikeout()) + { + pBaseText = new drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D( transformMatrix, text, 0, // text always starts at 0 @@ -1386,8 +1385,28 @@ namespace emfplushelper emptyVector, // EMF-PLUS has no DX-array fontAttribute, locale, - color.getBColor())); - + color.getBColor(), + COL_TRANSPARENT, + color.getBColor(), + color.getBColor(), + drawinglayer::primitive2d::TEXT_LINE_NONE, + font->Underline() ? drawinglayer::primitive2d::TEXT_LINE_SINGLE : drawinglayer::primitive2d::TEXT_LINE_NONE, + false, + font->Strikeout() ? drawinglayer::primitive2d::TEXT_STRIKEOUT_SINGLE : drawinglayer::primitive2d::TEXT_STRIKEOUT_NONE); + } + else + { + pBaseText = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + transformMatrix, + text, + 0, // text always starts at 0 + stringLength, + emptyVector, // EMF-PLUS has no DX-array + fontAttribute, + locale, + color.getBColor()); + } + drawinglayer::primitive2d::Primitive2DReference aPrimitiveText(pBaseText); if (color.GetTransparency() != 0) { aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( @@ -1766,8 +1785,8 @@ namespace emfplushelper const Color color = EMFPGetBrushColorOrARGBColor(flags, brushIndexOrColor); std::vector<double> aDXArray; // dummy for DX array (not used) - // generate TextSimplePortionPrimitive2Ds for all portions of text with - // the same charsPosY values + // generate TextSimplePortionPrimitive2Ds or TextDecoratedPortionPrimitive2D + // for all portions of text with the same charsPosY values sal_uInt32 pos = 0; while (pos < glyphsCount) { @@ -1778,10 +1797,10 @@ namespace emfplushelper // generate the DX-Array aDXArray.clear(); - double mappedPosX = Map(charsPosX[pos],charsPosY[pos]).getX(); - for (size_t i=0; i<aLength-1; i++) + double mappedPosX = Map(charsPosX[pos], charsPosY[pos]).getX(); + for (size_t i = 0; i < aLength-1; i++) { - aDXArray.push_back(Map(charsPosX[pos+i+1],charsPosY[pos+i+1]).getX() - mappedPosX); + aDXArray.push_back(Map(charsPosX[pos + i + 1], charsPosY[pos + i + 1]).getX() - mappedPosX); } // last entry aDXArray.push_back(0); @@ -1793,8 +1812,29 @@ namespace emfplushelper transformMatrix *= transform; if (color.GetTransparency() < 255) { - drawinglayer::primitive2d::Primitive2DReference aPrimitiveText( - new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + drawinglayer::primitive2d::BasePrimitive2D* pBaseText = nullptr; + if (font->Underline() || font->Strikeout()) + { + pBaseText = new drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D( + transformMatrix, + text, + pos, // take character at current pos + aLength, // use determined length + aDXArray, // generated DXArray + fontAttribute, + Application::GetSettings().GetLanguageTag().getLocale(), + color.getBColor(), + COL_TRANSPARENT, + color.getBColor(), + color.getBColor(), + drawinglayer::primitive2d::TEXT_LINE_NONE, + font->Underline() ? drawinglayer::primitive2d::TEXT_LINE_SINGLE : drawinglayer::primitive2d::TEXT_LINE_NONE, + false, + font->Strikeout() ? drawinglayer::primitive2d::TEXT_STRIKEOUT_SINGLE : drawinglayer::primitive2d::TEXT_STRIKEOUT_NONE); + } + else + { + pBaseText = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( transformMatrix, text, pos, // take character at current pos @@ -1802,7 +1842,9 @@ namespace emfplushelper aDXArray, // generated DXArray fontAttribute, Application::GetSettings().GetLanguageTag().getLocale(), - color.getBColor())); + color.getBColor()); + } + drawinglayer::primitive2d::Primitive2DReference aPrimitiveText(pBaseText); if (color.GetTransparency() != 0) { aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( |