[Libreoffice-commits] core.git: drawinglayer/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 7 22:28:40 UTC 2018
drawinglayer/source/tools/emfphelperdata.cxx | 74 +++++++++++++++++++++------
1 file changed, 58 insertions(+), 16 deletions(-)
New commits:
commit 8d4da5429548ba6ef4d3ee4dd6062c25a77ba78b
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Sun Nov 4 02:39:09 2018 +0100
Commit: Bartosz Kosiorek <gang65 at poczta.onet.pl>
CommitDate: Wed Nov 7 23:27:00 2018 +0100
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 at tu-dresden.de>
Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
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(
More information about the Libreoffice-commits
mailing list