[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - vcl/source

Michael Stahl mstahl at redhat.com
Wed Apr 2 07:24:07 PDT 2014


 vcl/source/gdi/pdfwriter_impl.cxx |   19 ++++++++++---------
 vcl/source/gdi/pdfwriter_impl.hxx |    4 +++-
 2 files changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 7bea9683e14fcba98e2691fe7fb75f6f68ab0b29
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Apr 2 11:09:46 2014 +0200

    fdo#63786 rhbz#1081968: fix PDF export of cropped SVG
    
    When a META_FLOATTRANSPARENT_ACTION is exported, the
    beginTransparencyGroup()/endTransparencyGroup() will write something
    like "Q 0 0 0 rg" where the Q clears the previously set clipping region,
    which is then not restored.
    
    bdf75c7d9bce985ed10a9c41d03420f33ce82142 appears to be a fix for a
    previous related problem; this essentially reverts it since it
    introduced the current cropping problem.  (Particularly funny is the
    comment "force reemitting clip region" since the commit does the
    opposite.)
    
    It does not really make sense to me to write something to the page
    content stream from beginRedirect()/endRedirect(), because that does not
    actually have any effect on the _content_ of the substream, because the
    referencing of the substream is only written _after_ endRedirect()
    returns, so basically what is written can in the best case cancel itself
    out and in the worst case introduce bugs; the state manipulations there
    are just to modify the m_aCurrentPDFState following the push()/pop() (it
    is necessary to clear the clip region before starting the substream to
    avoid spurious "Q" at the beginning of the stream).
    
    Change-Id: I4a5f57b784068bd7d3ba187115444574f7418195
    (cherry picked from commit e8062623355fcf3e65beae7f8f5e4d46384141f2)
    Reviewed-on: https://gerrit.libreoffice.org/8813
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 8f86255..89355ad 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8662,9 +8662,12 @@ void PDFWriterImpl::beginRedirect( SvStream* pStream, const Rectangle& rTargetRe
 {
     push( PUSH_ALL );
 
-    // force reemitting clip region
+    // force reemitting clip region inside the new stream, and
+    // prevent emitting an unbalanced "Q" at the start
     clearClipRegion();
-    updateGraphicsState();
+    // this is needed to point m_aCurrentPDFState at the pushed state
+    // ... but it's pointless to actually write into the "outer" stream here!
+    updateGraphicsState(NOWRITE);
 
     m_aOutputStreams.push_front( StreamRedirect() );
     m_aOutputStreams.front().m_pStream = pStream;
@@ -8701,14 +8704,12 @@ SvStream* PDFWriterImpl::endRedirect()
     }
 
     pop();
-    // force reemitting colors and clip region
-    clearClipRegion();
-    m_aCurrentPDFState.m_bClipRegion = m_aGraphicsStack.front().m_bClipRegion;
-    m_aCurrentPDFState.m_aClipRegion = m_aGraphicsStack.front().m_aClipRegion;
+
     m_aCurrentPDFState.m_aLineColor = Color( COL_TRANSPARENT );
     m_aCurrentPDFState.m_aFillColor = Color( COL_TRANSPARENT );
 
-    updateGraphicsState();
+    // needed after pop() to set m_aCurrentPDFState
+    updateGraphicsState(NOWRITE);
 
     return pStream;
 }
@@ -10497,7 +10498,7 @@ void PDFWriterImpl::drawWallpaper( const Rectangle& rRect, const Wallpaper& rWal
     }
 }
 
-void PDFWriterImpl::updateGraphicsState()
+void PDFWriterImpl::updateGraphicsState(Mode const mode)
 {
     OStringBuffer aLine( 256 );
     GraphicsState& rNewState = m_aGraphicsStack.front();
@@ -10593,7 +10594,7 @@ void PDFWriterImpl::updateGraphicsState()
 
     // everything is up to date now
     m_aCurrentPDFState = m_aGraphicsStack.front();
-    if( !aLine.isEmpty() )
+    if ((mode != NOWRITE) &&  !aLine.isEmpty())
         writeBuffer( aLine.getStr(), aLine.getLength() );
 }
 
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 4602044..8e622fa 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -840,10 +840,12 @@ i12626
     void drawRelief( SalLayout& rLayout, const OUString& rText, bool bTextLines );
     void drawShadow( SalLayout& rLayout, const OUString& rText, bool bTextLines );
 
+    enum Mode { DEFAULT, NOWRITE };
+
     /*  writes differences between graphics stack and current real PDF
      *   state to the file
      */
-    void updateGraphicsState();
+    void updateGraphicsState(Mode mode = DEFAULT);
 
     /* writes a transparency group object */
     bool writeTransparentObject( TransparencyEmit& rObject );


More information about the Libreoffice-commits mailing list