[Libreoffice-commits] core.git: 4 commits - bin/convwatch.py vcl/README vcl/source

Michael Stahl mstahl at redhat.com
Wed Apr 2 03:39:58 PDT 2014


 bin/convwatch.py                  |    6 +++++-
 vcl/README                        |   36 ++++++++++++++++++++++++++++++++++++
 vcl/source/gdi/pdfwriter_impl.cxx |   19 ++++++++++---------
 vcl/source/gdi/pdfwriter_impl.hxx |    4 +++-
 4 files changed, 54 insertions(+), 11 deletions(-)

New commits:
commit e8062623355fcf3e65beae7f8f5e4d46384141f2
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

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index b37c880..6646c7b 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8656,9 +8656,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;
@@ -8695,14 +8698,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;
 }
@@ -10491,7 +10492,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();
@@ -10587,7 +10588,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 4fe749a..b94e4f4 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 );
commit d256f08c6a7279489440d081e31355f99bee88ae
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Apr 2 11:01:06 2014 +0200

    convwatch.py: decode bytes before printing
    
    Change-Id: Ic1b115583415ab9bd2bdb18fa55f61803efc8442

diff --git a/bin/convwatch.py b/bin/convwatch.py
index 283e67e..c60c0fa 100644
--- a/bin/convwatch.py
+++ b/bin/convwatch.py
@@ -327,7 +327,7 @@ def identify(imagefile):
     if process.wait() != 0:
         raise Exception("identify failed")
     if result.partition(b"\n")[0] != b"1":
-        print("identify result: " + result)
+        print("identify result: " + result.decode('utf-8'))
         print("DIFFERENCE in " + imagefile)
 
 def compose(refimagefile, imagefile, diffimagefile):
commit 8ac24de12f9ff6727fa0cc77e4ae180d7dc32a0b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Apr 1 22:43:32 2014 +0200

    convwatch.py: fix handling of loadComponentFromURL returning null
    
    Change-Id: Icc64d56a74be9e95fdf69204356f9c2405ce7cc8

diff --git a/bin/convwatch.py b/bin/convwatch.py
index bef3f9e..283e67e 100644
--- a/bin/convwatch.py
+++ b/bin/convwatch.py
@@ -240,8 +240,11 @@ def loadFromURL(xContext, url):
     xGEB = xContext.getValueByName(
         "/singletons/com.sun.star.frame.theGlobalEventBroadcaster")
     xGEB.addDocumentEventListener(xListener)
+    xDoc = None
     try:
         xDoc = xDesktop.loadComponentFromURL(url, "_blank", 0, loadProps)
+        if xDoc is None:
+            raise Exception("No document loaded?")
         time_ = 0
         while time_ < 30:
             if xListener.layoutFinished:
@@ -280,6 +283,7 @@ class LoadPrintFileTest:
         self.prtsuffix = prtsuffix
     def run(self, xContext):
         print("Loading document: " + self.file)
+        xDoc = None
         try:
             url = "file://" + quote(self.file)
             xDoc = loadFromURL(xContext, url)
commit 51ac74617a33f518d068dd6e1f86431ee805bfbc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Apr 1 13:41:13 2014 +0200

    vcl/README: some notes on debugging PDF export
    
    Change-Id: Ic48d6be35fd9308a28d9fa62b184cd34dd8f9f6b

diff --git a/vcl/README b/vcl/README
index 76ee2bb..65113a6 100644
--- a/vcl/README
+++ b/vcl/README
@@ -152,3 +152,39 @@ before running LibreOffice; it will give you lots of useful hints.
 You can also fallback to EMF (from EMF+) rendering via
 
 export EMF_PLUS_DISABLE=1
+
+
+== Printing/PDF export ==
+
+Printing from Writer works like this:
+
+1) individual pages print by passing an appropriate OutputDevice to XRenderable
+2) in drawinglayer, a VclMetafileProcessor2D is used to record everything on
+   the page (because the OutputDevice has been set up to record a MetaFile)
+3) the pages' MetaFiles are converted to PDF by the vcl::PDFWriter
+   in vcl/source/gdi/pdfwriter*
+
+Creating the ODF thumbnail for the first page works as above except step 3 is:
+
+3) the MetaFile is replayed to create the thumbnail
+
+On-screen display differs in step 1 and 2:
+
+1) the VCL Window gets invalidated somehow and paints itself
+2) in drawinglayer, a VclPixelProcessor2D is used to display the content
+
+
+=== Debugging PDF export ===
+
+Debugging the PDF export becomes much easier in higher debug-levels, where
+compression is disabled (so the PDF file is directly readable) and
+the MARK function puts comments into the PDF file about which method
+generated the following PDF content.
+
+touch vcl/source/gdi/pdfwriter* && make vcl dbglevel=3
+
+To de-compress the contents of a PDF file written by a release build or
+other programs, use the "pdfunzip" tool:
+
+LD_LIBRARY_PATH=$PWD/instdir/ure/lib workdir/LinkTarget/Executable/pdfunzip input.pdf output.pdf
+


More information about the Libreoffice-commits mailing list