Kaydet (Commit) a04092df authored tarafından Marco Cecchetti's avatar Marco Cecchetti Kaydeden (comit) Jan Holesovsky

tdf#95356 Now text decorations are applied correctly

Now the default for using the SVG tiny profile is false.
Now the default for use native text decoration is true.

Fixed the following issues:

1) Text decoration (underline, strike-out) was not exported.

2) Commit 0a4e9138 (tdf#56467: improve export of formulas to SVG) had a
side effect: all exported text portions have position attributes (x,y)
even if they are on the same line (y_old == y_new): this caused that
underlined text belonging to 2 different `tspan` element was not
underlined by a continuous line but there was a gap where a `tspan`
ended and the next `tspan` started.

3) In commit (tdf#37650: further improvement of svg export)
StartTextShape method is invoked even when positioned characters are
used but the `implWriteText` method always adds a `text` element by
itself so there is no need to call StartTextShape.
The changes for non-positioned characters have been embedded inside the
`WriteTextPortion` method.

Change-Id: Iee0d6a6816dcbd2d97f2fbdf969f012de678604e
Reviewed-on: https://gerrit.libreoffice.org/19672Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst f0a2c421
......@@ -333,7 +333,7 @@ SVGExport::SVGExport(
comphelper::SequenceAsHashMap aFilterDataHashMap = rFilterData;
// TinyProfile
mbIsUseTinyProfile = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_TINYPROFILE, true);
mbIsUseTinyProfile = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_TINYPROFILE, false);
// Font Embedding
comphelper::SequenceAsHashMap::const_iterator iter = aFilterDataHashMap.find(SVG_PROP_EMBEDFONTS);
......@@ -349,7 +349,7 @@ SVGExport::SVGExport(
}
// Native Decoration
mbIsUseNativeTextDecoration = !mbIsUseTinyProfile && aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_NATIVEDECORATION, false);
mbIsUseNativeTextDecoration = !mbIsUseTinyProfile && aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_NATIVEDECORATION, true);
// Tiny Opacity (supported from SVG Tiny 1.2)
mbIsUseOpacity = aFilterDataHashMap.getUnpackedValueOrDefault(SVG_PROP_OPACITY, true);
......
......@@ -797,32 +797,44 @@ void SVGTextWriter::addFontAttributes( bool bIsTextContainer )
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrFontWeight, OUString::number( nFontWeight ) );
}
if( bIsTextContainer )
maParentFont = maCurrentFont;
}
if( mrExport.IsUseNativeTextDecoration() )
{
FontUnderline eCurFontUnderline = maCurrentFont.GetUnderline();
FontStrikeout eCurFontStrikeout = maCurrentFont.GetStrikeout();
if( mrExport.IsUseNativeTextDecoration() )
{
FontUnderline eCurFontUnderline = maCurrentFont.GetUnderline();
FontStrikeout eCurFontStrikeout = maCurrentFont.GetStrikeout();
FontUnderline eParFontUnderline = maParentFont.GetUnderline();
FontStrikeout eParFontStrikeout = maParentFont.GetStrikeout();
FontUnderline eParFontUnderline = maParentFont.GetUnderline();
FontStrikeout eParFontStrikeout = maParentFont.GetStrikeout();
OUString sTextDecoration;
OUString sTextDecoration;
bool bIsDecorationChanged = false;
if( eCurFontUnderline != eParFontUnderline )
{
if( eCurFontUnderline != UNDERLINE_NONE )
sTextDecoration = "underline ";
bIsDecorationChanged = true;
}
if( eCurFontStrikeout != eParFontStrikeout )
{
if( eCurFontStrikeout != STRIKEOUT_NONE )
sTextDecoration += "line-through ";
bIsDecorationChanged = true;
}
if( eCurFontUnderline != eParFontUnderline )
{
if( eCurFontUnderline != UNDERLINE_NONE )
sTextDecoration = "underline ";
}
if( eCurFontStrikeout != eParFontStrikeout )
{
if( eCurFontStrikeout != STRIKEOUT_NONE )
sTextDecoration += "line-through ";
if( !sTextDecoration.isEmpty() )
{
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, sTextDecoration );
}
else if( bIsDecorationChanged )
{
sTextDecoration = "none";
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, sTextDecoration );
}
}
if( !sTextDecoration.isEmpty() )
mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTextDecoration, sTextDecoration );
if( bIsTextContainer )
maParentFont = maCurrentFont;
}
}
......@@ -1231,9 +1243,10 @@ void SVGTextWriter::startTextParagraph()
maParentFont = vcl::Font();
addFontAttributes( /* isTexTContainer: */ true );
mpTextParagraphElem = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemTspan, mbIWS, mbIWS );
if( !mbIsListLevelStyleImage )
{
startTextPosition();
mbPositioningNeeded = true;
}
}
......@@ -1458,6 +1471,13 @@ void SVGTextWriter::writeTextPortion( const Point& rPos,
if( rText.isEmpty() )
return;
bool bStandAloneTextPortion = false;
if( !this->isTextShapeStarted() )
{
bStandAloneTextPortion = true;
this->startTextShape();
}
mbLineBreak = false;
if( !mbIsNewListItem || mbIsListLevelStyleImage )
......@@ -1522,6 +1542,10 @@ void SVGTextWriter::writeTextPortion( const Point& rPos,
implWriteTextPortion( rPos, rText, mpVDev->GetTextColor(), bApplyMapping );
#endif
if( bStandAloneTextPortion )
{
this->endTextShape();
}
}
void SVGTextWriter::implWriteTextPortion( const Point& rPos,
......@@ -1544,7 +1568,7 @@ void SVGTextWriter::implWriteTextPortion( const Point& rPos,
else
aPos = rPos;
if( mbPositioningNeeded || bApplyMapping )
if( mbPositioningNeeded )
{
mbPositioningNeeded = false;
maTextPos.setX( aPos.X() );
......@@ -3439,28 +3463,12 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
if( mrExport.IsUsePositionedCharacters() )
{
vcl::Font aFont = ImplSetCorrectFontHeight();
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
mpContext->SetFontAttr( aFont );
ImplWriteText( pA->GetPoint(), aText, NULL, 0 );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
else
{
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
maTextWriter.writeTextPortion( pA->GetPoint(), aText );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
}
}
......@@ -3478,27 +3486,10 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
if( mrExport.IsUsePositionedCharacters() )
{
vcl::Font aFont = ImplSetCorrectFontHeight();
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
mpContext->SetFontAttr( aFont );
ImplWriteText( pA->GetRect().TopLeft(), pA->GetText(), NULL, 0 );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
maTextWriter.writeTextPortion( pA->GetRect().TopLeft(), pA->GetText() );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
}
}
......@@ -3517,28 +3508,12 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
if( mrExport.IsUsePositionedCharacters() )
{
vcl::Font aFont = ImplSetCorrectFontHeight();
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
mpContext->SetFontAttr( aFont );
ImplWriteText( pA->GetPoint(), aText, pA->GetDXArray(), 0 );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
else
{
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
maTextWriter.writeTextPortion( pA->GetPoint(), aText );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
}
}
......@@ -3558,28 +3533,12 @@ void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf,
if( mrExport.IsUsePositionedCharacters() )
{
vcl::Font aFont = ImplSetCorrectFontHeight();
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
mpContext->SetFontAttr( aFont );
ImplWriteText( pA->GetPoint(), aText, NULL, pA->GetWidth() );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
else
{
bool bTextShapeStarted=false;
if( !maTextWriter.isTextShapeStarted() )
{
bTextShapeStarted=true;
maTextWriter.startTextShape();
}
maTextWriter.writeTextPortion( pA->GetPoint(), aText );
if( bTextShapeStarted )
maTextWriter.endTextShape();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment