filter/source/svg/svgexport.cxx |    4 -
 filter/source/svg/svgwriter.cxx |  135 +++++++++++++---------------------------
 2 files changed, 49 insertions(+), 90 deletions(-)

New commits:
commit a04092dfeb7272c25524d838a8e066f129fe2856
Author: Marco Cecchetti <marco.cecche...@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 <c...@libreoffice.org>
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 5bf04d3..64218db 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 98e8484..6611308 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();
                         }
                     }
                 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to