summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2015-10-29 16:28:17 +0100
committerJan Holesovsky <kendy@collabora.com>2015-10-29 18:02:58 +0100
commita04092dfeb7272c25524d838a8e066f129fe2856 (patch)
tree93d3961676ecc30ba89235b9d693b7cdfa2d2432 /filter
parentf0a2c4219d4785f77c9cb1d8b91e22b6c2488b33 (diff)
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 0a4e913 (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/19672 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/svg/svgexport.cxx4
-rw-r--r--filter/source/svg/svgwriter.cxx135
2 files changed, 49 insertions, 90 deletions
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 5bf04d3228f8..64218dbebf45 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -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);
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 98e8484ff5c1..66113083f7cc 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -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();
}
}
}