[Libreoffice-commits] core.git: filter/source
Marco Cecchetti
marco.cecchetti at collabora.com
Thu Oct 29 10:02:15 PDT 2015
filter/source/svg/svgexport.cxx | 4 -
filter/source/svg/svgwriter.cxx | 135 +++++++++++++---------------------------
2 files changed, 49 insertions(+), 90 deletions(-)
New commits:
commit e428786dbf73d49af611762cf08d64602c3276c9
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
Date: Thu Oct 29 16:28:17 2015 +0100
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 at libreoffice.org>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 73a5e04..f04f169 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 426521a..9c6a3f5 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -794,32 +794,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;
+
}
}
@@ -1228,9 +1240,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;
}
}
@@ -1455,6 +1468,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 )
@@ -1519,6 +1539,10 @@ void SVGTextWriter::writeTextPortion( const Point& rPos,
implWriteTextPortion( rPos, rText, mpVDev->GetTextColor(), bApplyMapping );
#endif
+ if( bStandAloneTextPortion )
+ {
+ this->endTextShape();
+ }
}
void SVGTextWriter::implWriteTextPortion( const Point& rPos,
@@ -1541,7 +1565,7 @@ void SVGTextWriter::implWriteTextPortion( const Point& rPos,
else
aPos = rPos;
- if( mbPositioningNeeded || bApplyMapping )
+ if( mbPositioningNeeded )
{
mbPositioningNeeded = false;
maTextPos.setX( aPos.X() );
@@ -3436,28 +3460,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();
}
}
}
@@ -3475,27 +3483,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();
}
}
}
@@ -3514,28 +3505,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();
}
}
}
@@ -3555,28 +3530,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();
}
}
}
More information about the Libreoffice-commits
mailing list