diff options
author | Frank Meies <fme@openoffice.org> | 2008-12-04 14:42:57 +0000 |
---|---|---|
committer | Frank Meies <fme@openoffice.org> | 2008-12-04 14:42:57 +0000 |
commit | d4b5c46129edaab43bc9e6bd471129952c62882e (patch) | |
tree | cbc0b7107a0a2d8282a64fadec4bcc144faa72ea /drawinglayer | |
parent | 7aa20ba1143aa87f72b7b80b4962d94c1f8a96bf (diff) |
#i5991# Overline support in drawing layer
Diffstat (limited to 'drawinglayer')
5 files changed, 325 insertions, 254 deletions
diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx index f91fb7aab2..a9f8e562b9 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx @@ -55,6 +55,7 @@ namespace drawinglayer { namespace primitive2d { + // This is used for both underline and overline enum FontUnderline { FONT_UNDERLINE_NONE, @@ -106,7 +107,9 @@ namespace drawinglayer class TextDecoratedPortionPrimitive2D : public TextSimplePortionPrimitive2D { private: + basegfx::BColor maOverlineColor; basegfx::BColor maTextlineColor; + FontUnderline meFontOverline; FontUnderline meFontUnderline; FontStrikeout meFontStrikeout; FontEmphasisMark meFontEmphasisMark; @@ -120,6 +123,16 @@ namespace drawinglayer unsigned mbShadow : 1; // helper methods + void impCreateTextLine( + std::vector< Primitive2DReference >& rTarget, + basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, + const basegfx::B2DHomMatrix &rUnscaledTransform, + FontUnderline eLineStyle, + double fLineOffset, + double fLineHeight, + double fLineWidth, + const basegfx::BColor& rLineColor) const; + void impCreateGeometryContent( std::vector< Primitive2DReference >& rTarget, basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, @@ -154,7 +167,9 @@ namespace drawinglayer const basegfx::BColor& rFontColor, // local parameters + const basegfx::BColor& rOverlineColor, const basegfx::BColor& rTextlineColor, + FontUnderline eFontOverline = FONT_UNDERLINE_NONE, FontUnderline eFontUnderline = FONT_UNDERLINE_NONE, bool bUnderlineAbove = false, FontStrikeout eFontStrikeout = FONT_STRIKEOUT_NONE, @@ -166,10 +181,12 @@ namespace drawinglayer bool bShadow = false); // get data + FontUnderline getFontOverline() const { return meFontOverline; } FontUnderline getFontUnderline() const { return meFontUnderline; } FontStrikeout getFontStrikeout() const { return meFontStrikeout; } FontEmphasisMark getFontEmphasisMark() const { return meFontEmphasisMark; } FontRelief getFontRelief() const { return meFontRelief; } + basegfx::BColor getOverlineColor() const { return maOverlineColor; } basegfx::BColor getTextlineColor() const { return maTextlineColor; } bool getUnderlineAbove() const { return mbUnderlineAbove; } diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx index 5f17411969..213cf2121f 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -79,6 +79,8 @@ namespace drawinglayer void setFontAttributes(const FontAttributes& rFontAttributes, double fFontScaleX, double fFontScaleY); double getTextHeight() const; + double getOverlineHeight() const; + double getOverlineOffset() const; double getUnderlineHeight() const; double getUnderlineOffset() const; double getStrikeoutOffset() const; diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index b321dac20d..b1fb336f3c 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -55,8 +55,214 @@ namespace drawinglayer { namespace primitive2d { + void TextDecoratedPortionPrimitive2D::impCreateTextLine( + std::vector< Primitive2DReference >& rTarget, + basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, + const basegfx::B2DHomMatrix &rUnscaledTransform, + FontUnderline eLineStyle, + double fLineOffset, + double fLineHeight, + double fLineWidth, + const basegfx::BColor& rLineColor) const + { + bool bDoubleLine(false); + bool bWaveLine(false); + bool bBoldLine(false); + const int* pDotDashArray(0); + basegfx::B2DLineJoin eLineJoin(basegfx::B2DLINEJOIN_NONE); + + static const int aDottedArray[] = { 1, 1, 0}; // DOTTED LINE + static const int aDotDashArray[] = { 1, 1, 4, 1, 0}; // DASHDOT + static const int aDashDotDotArray[] = { 1, 1, 1, 1, 4, 1, 0}; // DASHDOTDOT + static const int aDashedArray[] = { 5, 2, 0}; // DASHED LINE + static const int aLongDashArray[] = { 7, 2, 0}; // LONGDASH + + switch(eLineStyle) + { + default: // case FONT_UNDERLINE_SINGLE: + { + break; + } + case FONT_UNDERLINE_DOUBLE: + { + bDoubleLine = true; + break; + } + case FONT_UNDERLINE_DOTTED: + { + pDotDashArray = aDottedArray; + break; + } + case FONT_UNDERLINE_DASH: + { + pDotDashArray = aDashedArray; + break; + } + case FONT_UNDERLINE_LONGDASH: + { + pDotDashArray = aLongDashArray; + break; + } + case FONT_UNDERLINE_DASHDOT: + { + pDotDashArray = aDotDashArray; + break; + } + case FONT_UNDERLINE_DASHDOTDOT: + { + pDotDashArray = aDashDotDotArray; + break; + } + case FONT_UNDERLINE_SMALLWAVE: + { + bWaveLine = true; + break; + } + case FONT_UNDERLINE_WAVE: + { + bWaveLine = true; + break; + } + case FONT_UNDERLINE_DOUBLEWAVE: + { + bDoubleLine = true; + bWaveLine = true; + break; + } + case FONT_UNDERLINE_BOLD: + { + bBoldLine = true; + break; + } + case FONT_UNDERLINE_BOLDDOTTED: + { + bBoldLine = true; + pDotDashArray = aDottedArray; + break; + } + case FONT_UNDERLINE_BOLDDASH: + { + bBoldLine = true; + pDotDashArray = aDashedArray; + break; + } + case FONT_UNDERLINE_BOLDLONGDASH: + { + bBoldLine = true; + pDotDashArray = aLongDashArray; + break; + } + case FONT_UNDERLINE_BOLDDASHDOT: + { + bBoldLine = true; + pDotDashArray = aDotDashArray; + break; + } + case FONT_UNDERLINE_BOLDDASHDOTDOT: + { + bBoldLine = true; + pDotDashArray = aDashDotDotArray; + break; + } + case FONT_UNDERLINE_BOLDWAVE: + { + bWaveLine = true; + bBoldLine = true; + break; + } + } + + if(bBoldLine) + { + fLineHeight *= 2.0; + } + + if(bDoubleLine) + { + fLineOffset -= 0.50 * fLineHeight; + fLineHeight *= 0.64; + } + + if(bWaveLine) + { + eLineJoin = basegfx::B2DLINEJOIN_ROUND; + fLineHeight *= 0.5; + } + + // prepare Line and Stroke Attributes + const attribute::LineAttribute aLineAttribute(rLineColor, fLineHeight, eLineJoin); + attribute::StrokeAttribute aStrokeAttribute; + + if(pDotDashArray) + { + ::std::vector< double > aDoubleArray; + + for(const int* p = pDotDashArray; *p; ++p) + { + aDoubleArray.push_back((double)(*p) * fLineHeight); + } + + aStrokeAttribute = attribute::StrokeAttribute(aDoubleArray); + } + + // create base polygon and new primitive + basegfx::B2DPolygon aLine; + Primitive2DReference aNewPrimitive; + + aLine.append(basegfx::B2DPoint(0.0, fLineOffset)); + aLine.append(basegfx::B2DPoint(fLineWidth, fLineOffset)); + aLine.transform(rUnscaledTransform); + + if(bWaveLine) + { + double fWaveWidth(4.0 * fLineHeight); + + if(FONT_UNDERLINE_SMALLWAVE == eLineStyle) + { + fWaveWidth *= 0.7; + } + else if(FONT_UNDERLINE_WAVE == eLineStyle) + { + // extra multiply to get the same WaveWidth as with the bold version + fWaveWidth *= 2.0; + } + + aNewPrimitive = Primitive2DReference(new PolygonWavePrimitive2D(aLine, aLineAttribute, aStrokeAttribute, fWaveWidth, 0.5 * fWaveWidth)); + } + else + { + aNewPrimitive = Primitive2DReference(new PolygonStrokePrimitive2D(aLine, aLineAttribute, aStrokeAttribute)); + } + + // add primitive + rTarget.push_back(aNewPrimitive); + + if(bDoubleLine) + { + // double line, create 2nd primitive with offset using TransformPrimitive based on + // already created NewPrimitive + const double fLineDist((bWaveLine ? 3.0 : 2.0) * fLineHeight); + basegfx::B2DHomMatrix aTransform; + + // move base point of text to 0.0 and de-rotate + aTransform.translate(-rDecTrans.getTranslate().getX(), -rDecTrans.getTranslate().getY()); + aTransform.rotate(-rDecTrans.getRotate()); + + // translate in Y by offset + aTransform.translate(0.0, fLineDist); + + // move back and rotate + aTransform.rotate(rDecTrans.getRotate()); + aTransform.translate(rDecTrans.getTranslate().getX(), rDecTrans.getTranslate().getY()); + + // add transform primitive + const Primitive2DSequence aContent(&aNewPrimitive, 1); + rTarget.push_back(Primitive2DReference(new TransformPrimitive2D(aTransform, aContent))); + } + } + void TextDecoratedPortionPrimitive2D::impCreateGeometryContent( - std::vector< Primitive2DReference >& rTarget, + std::vector< Primitive2DReference >& rTarget, basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, const String& rText, xub_StrLen aTextPosition, @@ -66,31 +272,32 @@ namespace drawinglayer { // create the SimpleTextPrimitive needed in any case rTarget.push_back(Primitive2DReference(new TextSimplePortionPrimitive2D( - rDecTrans.getB2DHomMatrix(), - rText, + rDecTrans.getB2DHomMatrix(), + rText, aTextPosition, aTextLength, - rDXArray, - rFontAttributes, - getLocale(), + rDXArray, + rFontAttributes, + getLocale(), getFontColor()))); // see if something else needs to be done + const bool bOverlineUsed(FONT_UNDERLINE_NONE != getFontOverline()); const bool bUnderlineUsed(FONT_UNDERLINE_NONE != getFontUnderline()); const bool bStrikeoutUsed(FONT_STRIKEOUT_NONE != getFontStrikeout()); - if(bUnderlineUsed || bStrikeoutUsed) + if(bOverlineUsed || bUnderlineUsed || bStrikeoutUsed) { // common preparations basegfx::B2DHomMatrix aUnscaledTransform; TextLayouterDevice aTextLayouter; - + // unscaled is needed since scale contains already the font size aUnscaledTransform.shearX(rDecTrans.getShearX()); aUnscaledTransform.rotate(rDecTrans.getRotate()); aUnscaledTransform.translate(rDecTrans.getTranslate().getX(), rDecTrans.getTranslate().getY()); - // TextLayouterDevice is needed to get metrics for text decorations like + // TextLayouterDevice is needed to get metrics for text decorations like // underline/strikeout/emphasis marks from it. For setup, the font size is needed aTextLayouter.setFontAttributes(getFontAttributes(), rDecTrans.getScale().getX(), rDecTrans.getScale().getY()); @@ -106,205 +313,18 @@ namespace drawinglayer fTextWidth = rDXArray.back() * rDecTrans.getScale().getX(); } + if(bOverlineUsed) + { + // create primitive geometry for overline + impCreateTextLine(rTarget, rDecTrans, aUnscaledTransform, getFontOverline(), aTextLayouter.getOverlineOffset(), + aTextLayouter.getOverlineHeight(), fTextWidth, getOverlineColor()); + } + if(bUnderlineUsed) { // create primitive geometry for underline - bool bDoubleLine(false); - bool bWaveLine(false); - bool bBoldLine(false); - const int* pDotDashArray(0); - basegfx::B2DLineJoin eLineJoin(basegfx::B2DLINEJOIN_NONE); - double fUnderlineOffset(aTextLayouter.getUnderlineOffset()); - double fUnderlineHeight(aTextLayouter.getUnderlineHeight()); - - static const int aDottedArray[] = { 1, 1, 0}; // DOTTED LINE - static const int aDotDashArray[] = { 1, 1, 4, 1, 0}; // DASHDOT - static const int aDashDotDotArray[] = { 1, 1, 1, 1, 4, 1, 0}; // DASHDOTDOT - static const int aDashedArray[] = { 5, 2, 0}; // DASHED LINE - static const int aLongDashArray[] = { 7, 2, 0}; // LONGDASH - - switch(getFontUnderline()) - { - default: // case FONT_UNDERLINE_SINGLE: - { - break; - } - case FONT_UNDERLINE_DOUBLE: - { - bDoubleLine = true; - break; - } - case FONT_UNDERLINE_DOTTED: - { - pDotDashArray = aDottedArray; - break; - } - case FONT_UNDERLINE_DASH: - { - pDotDashArray = aDashedArray; - break; - } - case FONT_UNDERLINE_LONGDASH: - { - pDotDashArray = aLongDashArray; - break; - } - case FONT_UNDERLINE_DASHDOT: - { - pDotDashArray = aDotDashArray; - break; - } - case FONT_UNDERLINE_DASHDOTDOT: - { - pDotDashArray = aDashDotDotArray; - break; - } - case FONT_UNDERLINE_SMALLWAVE: - { - bWaveLine = true; - break; - } - case FONT_UNDERLINE_WAVE: - { - bWaveLine = true; - break; - } - case FONT_UNDERLINE_DOUBLEWAVE: - { - bDoubleLine = true; - bWaveLine = true; - break; - } - case FONT_UNDERLINE_BOLD: - { - bBoldLine = true; - break; - } - case FONT_UNDERLINE_BOLDDOTTED: - { - bBoldLine = true; - pDotDashArray = aDottedArray; - break; - } - case FONT_UNDERLINE_BOLDDASH: - { - bBoldLine = true; - pDotDashArray = aDashedArray; - break; - } - case FONT_UNDERLINE_BOLDLONGDASH: - { - bBoldLine = true; - pDotDashArray = aLongDashArray; - break; - } - case FONT_UNDERLINE_BOLDDASHDOT: - { - bBoldLine = true; - pDotDashArray = aDotDashArray; - break; - } - case FONT_UNDERLINE_BOLDDASHDOTDOT: - { - bBoldLine = true; - pDotDashArray = aDashDotDotArray; - break; - } - case FONT_UNDERLINE_BOLDWAVE: - { - bWaveLine = true; - bBoldLine = true; - break; - } - } - - if(bBoldLine) - { - fUnderlineHeight *= 2.0; - } - - if(bDoubleLine) - { - fUnderlineOffset -= 0.50 * fUnderlineHeight; - fUnderlineHeight *= 0.64; - } - - if(bWaveLine) - { - eLineJoin = basegfx::B2DLINEJOIN_ROUND; - fUnderlineHeight *= 0.5; - } - - // prepare Line and Stroke Attributes - const attribute::LineAttribute aLineAttribute(getTextlineColor(), fUnderlineHeight, eLineJoin); - attribute::StrokeAttribute aStrokeAttribute; - - if(pDotDashArray) - { - ::std::vector< double > aDoubleArray; - - for(const int* p = pDotDashArray; *p; ++p) - { - aDoubleArray.push_back((double)(*p) * fUnderlineHeight); - } - - aStrokeAttribute = attribute::StrokeAttribute(aDoubleArray); - } - - // create base polygon and new primitive - basegfx::B2DPolygon aUnderline; - Primitive2DReference aNewPrimitive; - - aUnderline.append(basegfx::B2DPoint(0.0, fUnderlineOffset)); - aUnderline.append(basegfx::B2DPoint(fTextWidth, fUnderlineOffset)); - aUnderline.transform(aUnscaledTransform); - - if(bWaveLine) - { - double fWaveWidth(4.0 * fUnderlineHeight); - - if(primitive2d::FONT_UNDERLINE_SMALLWAVE == getFontUnderline()) - { - fWaveWidth *= 0.7; - } - else if(primitive2d::FONT_UNDERLINE_WAVE == getFontUnderline()) - { - // extra multiply to get the same WaveWidth as with the bold version - fWaveWidth *= 2.0; - } - - aNewPrimitive = Primitive2DReference(new PolygonWavePrimitive2D(aUnderline, aLineAttribute, aStrokeAttribute, fWaveWidth, 0.5 * fWaveWidth)); - } - else - { - aNewPrimitive = Primitive2DReference(new PolygonStrokePrimitive2D(aUnderline, aLineAttribute, aStrokeAttribute)); - } - - // add primitive - rTarget.push_back(aNewPrimitive); - - if(bDoubleLine) - { - // double line, create 2nd primitive with offset using TransformPrimitive based on - // already created NewPrimitive - const double fLineDist((bWaveLine ? 3.0 : 2.0) * fUnderlineHeight); - basegfx::B2DHomMatrix aTransform; - - // move base point of text to 0.0 and de-rotate - aTransform.translate(-rDecTrans.getTranslate().getX(), -rDecTrans.getTranslate().getY()); - aTransform.rotate(-rDecTrans.getRotate()); - - // translate in Y by offset - aTransform.translate(0.0, fLineDist); - - // move back and rotate - aTransform.rotate(rDecTrans.getRotate()); - aTransform.translate(rDecTrans.getTranslate().getX(), rDecTrans.getTranslate().getY()); - - // add transform primitive - const Primitive2DSequence aContent(&aNewPrimitive, 1); - rTarget.push_back(Primitive2DReference(new TransformPrimitive2D(aTransform, aContent))); - } + impCreateTextLine(rTarget, rDecTrans, aUnscaledTransform, getFontUnderline(), aTextLayouter.getUnderlineOffset(), + aTextLayouter.getUnderlineHeight(), fTextWidth, getTextlineColor()); } if(bStrikeoutUsed) @@ -320,7 +340,7 @@ namespace drawinglayer const sal_uInt32 nStrikeCharCount(static_cast< sal_uInt32 >(fStrikeCharCount + 0.9)); const double fScaleX(rDecTrans.getScale().getX()); const double fStrikeCharWidthUnscaled(basegfx::fTools::equalZero(fScaleX) ? fStrikeCharWidth : fStrikeCharWidth/fScaleX); - + std::vector<double> aDXArray(nStrikeCharCount); String aStrikeoutString; @@ -329,15 +349,15 @@ namespace drawinglayer aStrikeoutString += aSingleCharString; aDXArray[a] = (a + 1) * fStrikeCharWidthUnscaled; } - + rTarget.push_back(Primitive2DReference(new TextSimplePortionPrimitive2D( - rDecTrans.getB2DHomMatrix(), - aStrikeoutString, + rDecTrans.getB2DHomMatrix(), + aStrikeoutString, 0, aStrikeoutString.Len(), - aDXArray, - rFontAttributes, - getLocale(), + aDXArray, + rFontAttributes, + getLocale(), getFontColor()))); } else @@ -378,7 +398,7 @@ namespace drawinglayer aStrikeoutLine.append(basegfx::B2DPoint(0.0, -fStrikeoutOffset)); aStrikeoutLine.append(basegfx::B2DPoint(fTextWidth, -fStrikeoutOffset)); aStrikeoutLine.transform(aUnscaledTransform); - + const attribute::LineAttribute aLineAttribute(getFontColor(), fStrikeoutHeight, basegfx::B2DLINEJOIN_NONE); Primitive2DReference aNewPrimitive(new PolygonStrokePrimitive2D(aStrikeoutLine, aLineAttribute)); @@ -507,7 +527,7 @@ namespace drawinglayer // prepare new DXArray for the single word ::std::vector< double > aNewDXArray( - getDXArray().begin() + static_cast< sal_uInt32 >(nNewTextStart - getTextPosition()), + getDXArray().begin() + static_cast< sal_uInt32 >(nNewTextStart - getTextPosition()), getDXArray().begin() + static_cast< sal_uInt32 >(nNewTextEnd - getTextPosition())); if(bNewStartIsNotOldStart) @@ -520,15 +540,15 @@ namespace drawinglayer aNewDXArray[a] -= fDistance; } } - + // create geometry content for the single word basegfx::DecomposedB2DHomMatrixContainer aDecTrans(aNewTransform); - impCreateGeometryContent(rTarget, aDecTrans, getText(), nNewTextStart, + impCreateGeometryContent(rTarget, aDecTrans, getText(), nNewTextStart, nNewTextEnd - nNewTextStart, aNewDXArray, aNewFontAttributes); // prepare next word and truncate to possibilities aNextWordBoundary = xLocalBreakIterator->nextWord( - getText(), aNextWordBoundary.endPos, getLocale(), + getText(), aNextWordBoundary.endPos, getLocale(), ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES); impCorrectTextBoundary(aNextWordBoundary); } @@ -542,7 +562,7 @@ namespace drawinglayer basegfx::DecomposedB2DHomMatrixContainer aDecTrans(getTextTransform()); Primitive2DSequence aRetval; - // create basic geometry such as SimpleTextPrimitive, Underline, + // create basic geometry such as SimpleTextPrimitive, Underline, // Strikeuot, etc... if(getWordLineMode()) { @@ -569,7 +589,7 @@ namespace drawinglayer // convert to Primitive2DSequence const sal_uInt32 nMemberCount(aNewPrimitives.size()); - + if(nMemberCount) { aRetval.realloc(nMemberCount); @@ -595,13 +615,13 @@ namespace drawinglayer if(bHasShadow) { // create shadow with current content (in aRetval). Text shadow - // is constant, relative to font size, rotated with the text and has a + // is constant, relative to font size, rotated with the text and has a // constant color. // shadow parameter values static double fFactor(1.0 / 24.0); const double fTextShadowOffset(aDecTrans.getScale().getY() * fFactor); static basegfx::BColor aShadowColor(0.3, 0.3, 0.3); - + // preapare shadow transform matrix basegfx::B2DHomMatrix aShadowTransform; aShadowTransform.translate(fTextShadowOffset, fTextShadowOffset); @@ -645,9 +665,9 @@ namespace drawinglayer } Primitive2DReference aNewTextEffect(new TextEffectPrimitive2D( - aRetval, + aRetval, aDecTrans.getTranslate(), - aDecTrans.getRotate(), + aDecTrans.getRotate(), aTextEffectStyle2D)); aRetval = Primitive2DSequence(&aNewTextEffect, 1); } @@ -656,9 +676,9 @@ namespace drawinglayer // create outline using an own helper primitive since this will // be view-dependent Primitive2DReference aNewTextEffect(new TextEffectPrimitive2D( - aRetval, - aDecTrans.getTranslate(), - aDecTrans.getRotate(), + aRetval, + aDecTrans.getTranslate(), + aDecTrans.getRotate(), TEXTEFFECTSTYLE2D_OUTLINE)); aRetval = Primitive2DSequence(&aNewTextEffect, 1); } @@ -681,7 +701,7 @@ namespace drawinglayer // TextSimplePortionPrimitive2D parameters const basegfx::B2DHomMatrix& rNewTransform, - const String& rText, + const String& rText, xub_StrLen aTextPosition, xub_StrLen aTextLength, const ::std::vector< double >& rDXArray, @@ -690,7 +710,9 @@ namespace drawinglayer const basegfx::BColor& rFontColor, // local parameters + const basegfx::BColor& rOverlineColor, const basegfx::BColor& rTextlineColor, + FontUnderline eFontOverline, FontUnderline eFontUnderline, bool bUnderlineAbove, FontStrikeout eFontStrikeout, @@ -701,7 +723,9 @@ namespace drawinglayer FontRelief eFontRelief, bool bShadow) : TextSimplePortionPrimitive2D(rNewTransform, rText, aTextPosition, aTextLength, rDXArray, rFontAttributes, rLocale, rFontColor), + maOverlineColor(rOverlineColor), maTextlineColor(rTextlineColor), + meFontOverline(eFontOverline), meFontUnderline(eFontUnderline), meFontStrikeout(eFontStrikeout), meFontEmphasisMark(eFontEmphasisMark), @@ -719,8 +743,10 @@ namespace drawinglayer if(TextSimplePortionPrimitive2D::operator==(rPrimitive)) { const TextDecoratedPortionPrimitive2D& rCompare = (TextDecoratedPortionPrimitive2D&)rPrimitive; - - return (getTextlineColor() == rCompare.getTextlineColor() + + return (getOverlineColor() == rCompare.getOverlineColor() + && getTextlineColor() == rCompare.getTextlineColor() + && getFontOverline() == rCompare.getFontOverline() && getFontUnderline() == rCompare.getFontUnderline() && getFontStrikeout() == rCompare.getFontStrikeout() && getFontEmphasisMark() == rCompare.getFontEmphasisMark() diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index 27eeeeabde..f02934a5e8 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -175,6 +175,13 @@ namespace drawinglayer setFont(getVclFontFromFontAttributes(rFontAttributes, fFontScaleX, fFontScaleY, 0.0, mrDevice)); } + double TextLayouterDevice::getOverlineOffset() const + { + const ::FontMetric& rMetric = mrDevice.GetFontMetric(); + double fRet = (rMetric.GetIntLeading() / 2.0) - rMetric.GetAscent(); + return fRet; + } + double TextLayouterDevice::getUnderlineOffset() const { const ::FontMetric& rMetric = mrDevice.GetFontMetric(); @@ -189,6 +196,13 @@ namespace drawinglayer return fRet; } + double TextLayouterDevice::getOverlineHeight() const + { + const ::FontMetric& rMetric = mrDevice.GetFontMetric(); + double fRet = rMetric.GetIntLeading() / 2.5; + return fRet; + } + double TextLayouterDevice::getUnderlineHeight() const { const ::FontMetric& rMetric = mrDevice.GetFontMetric(); diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index bcd4ad24d7..6e9459661f 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -102,6 +102,34 @@ namespace drawinglayer using ::com::sun::star::awt::XWindow; using ::com::sun::star::awt::PosSize::POSSIZE; + static FontUnderline mapTextLineStyle(primitive2d::FontUnderline eLineStyle) + { + switch(eLineStyle) + { + default: + DBG_WARNING1( "DrawingLayer: Unknown text line style attribute (%d)!", eLineStyle ); + // fall through + case primitive2d::FONT_UNDERLINE_NONE: return UNDERLINE_NONE; + case primitive2d::FONT_UNDERLINE_SINGLE: return UNDERLINE_SINGLE; + case primitive2d::FONT_UNDERLINE_DOUBLE: return UNDERLINE_DOUBLE; + case primitive2d::FONT_UNDERLINE_DOTTED: return UNDERLINE_DOTTED; + case primitive2d::FONT_UNDERLINE_DASH: return UNDERLINE_DASH; + case primitive2d::FONT_UNDERLINE_LONGDASH: return UNDERLINE_LONGDASH; + case primitive2d::FONT_UNDERLINE_DASHDOT: return UNDERLINE_DASHDOT; + case primitive2d::FONT_UNDERLINE_DASHDOTDOT: return UNDERLINE_DASHDOTDOT; + case primitive2d::FONT_UNDERLINE_SMALLWAVE: return UNDERLINE_SMALLWAVE; + case primitive2d::FONT_UNDERLINE_WAVE: return UNDERLINE_WAVE; + case primitive2d::FONT_UNDERLINE_DOUBLEWAVE: return UNDERLINE_DOUBLEWAVE; + case primitive2d::FONT_UNDERLINE_BOLD: return UNDERLINE_BOLD; + case primitive2d::FONT_UNDERLINE_BOLDDOTTED: return UNDERLINE_BOLDDOTTED; + case primitive2d::FONT_UNDERLINE_BOLDDASH: return UNDERLINE_BOLDDASH; + case primitive2d::FONT_UNDERLINE_BOLDLONGDASH: return UNDERLINE_LONGDASH; + case primitive2d::FONT_UNDERLINE_BOLDDASHDOT: return UNDERLINE_BOLDDASHDOT; + case primitive2d::FONT_UNDERLINE_BOLDDASHDOTDOT:return UNDERLINE_BOLDDASHDOT; + case primitive2d::FONT_UNDERLINE_BOLDWAVE: return UNDERLINE_BOLDWAVE; + } + } + ////////////////////////////////////////////////////////////////////////////// // rendering support @@ -140,33 +168,17 @@ namespace drawinglayer if( pTCPP != NULL ) { - // set Underline attribute - FontUnderline eFontUnderline = UNDERLINE_NONE; - switch( pTCPP->getFontUnderline() ) + // set Overline attribute + FontUnderline eFontOverline = mapTextLineStyle( pTCPP->getFontOverline() ); + if( eFontOverline != UNDERLINE_NONE ) { - default: - DBG_WARNING1( "DrawingLayer: Unknown underline attribute (%d)!", pTCPP->getFontUnderline() ); - // fall through - case primitive2d::FONT_UNDERLINE_NONE: eFontUnderline = UNDERLINE_NONE; break; - case primitive2d::FONT_UNDERLINE_SINGLE: eFontUnderline = UNDERLINE_SINGLE; break; - case primitive2d::FONT_UNDERLINE_DOUBLE: eFontUnderline = UNDERLINE_DOUBLE; break; - case primitive2d::FONT_UNDERLINE_DOTTED: eFontUnderline = UNDERLINE_DOTTED; break; - case primitive2d::FONT_UNDERLINE_DASH: eFontUnderline = UNDERLINE_DASH; break; - case primitive2d::FONT_UNDERLINE_LONGDASH: eFontUnderline = UNDERLINE_LONGDASH; break; - case primitive2d::FONT_UNDERLINE_DASHDOT: eFontUnderline = UNDERLINE_DASHDOT; break; - case primitive2d::FONT_UNDERLINE_DASHDOTDOT:eFontUnderline = UNDERLINE_DASHDOTDOT; break; - case primitive2d::FONT_UNDERLINE_SMALLWAVE: eFontUnderline = UNDERLINE_SMALLWAVE; break; - case primitive2d::FONT_UNDERLINE_WAVE: eFontUnderline = UNDERLINE_WAVE; break; - case primitive2d::FONT_UNDERLINE_DOUBLEWAVE:eFontUnderline = UNDERLINE_DOUBLEWAVE; break; - case primitive2d::FONT_UNDERLINE_BOLD: eFontUnderline = UNDERLINE_BOLD; break; - case primitive2d::FONT_UNDERLINE_BOLDDOTTED:eFontUnderline = UNDERLINE_BOLDDOTTED; break; - case primitive2d::FONT_UNDERLINE_BOLDDASH: eFontUnderline = UNDERLINE_BOLDDASH; break; - case primitive2d::FONT_UNDERLINE_BOLDLONGDASH:eFontUnderline = UNDERLINE_LONGDASH; break; - case primitive2d::FONT_UNDERLINE_BOLDDASHDOT:eFontUnderline = UNDERLINE_BOLDDASHDOT; break; - case primitive2d::FONT_UNDERLINE_BOLDDASHDOTDOT:eFontUnderline = UNDERLINE_BOLDDASHDOT; break; - case primitive2d::FONT_UNDERLINE_BOLDWAVE: eFontUnderline = UNDERLINE_BOLDWAVE; break; + aFont.SetOverline( eFontOverline ); + if( pTCPP->getWordLineMode() ) + aFont.SetWordLineMode( true ); } + // set Underline attribute + FontUnderline eFontUnderline = mapTextLineStyle( pTCPP->getFontUnderline() ); if( eFontUnderline != UNDERLINE_NONE ) { aFont.SetUnderline( eFontUnderline ); @@ -181,7 +193,7 @@ namespace drawinglayer switch( pTCPP->getFontStrikeout() ) { default: - DBG_WARNING1( "DrawingLayer: Unknown strikeout attribute (%d)!", pTCPP->getFontUnderline() ); + DBG_WARNING1( "DrawingLayer: Unknown strikeout attribute (%d)!", pTCPP->getFontStrikeout() ); // fall through case primitive2d::FONT_STRIKEOUT_NONE: eFontStrikeout = STRIKEOUT_NONE; break; case primitive2d::FONT_STRIKEOUT_SINGLE: eFontStrikeout = STRIKEOUT_SINGLE; break; |