[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - vcl/inc vcl/source writerfilter/source

Michael Stahl mst at kemper.freedesktop.org
Wed Apr 4 02:51:48 PDT 2012


 vcl/inc/graphite_layout.hxx                    |    4 +-
 vcl/source/glyphs/graphite_layout.cxx          |   46 +++++++++++++------------
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   18 ++-------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx |    2 -
 4 files changed, 32 insertions(+), 38 deletions(-)

New commits:
commit 5fa13451520a3e7e291611b47a151f770eaf3314
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Apr 4 11:04:45 2012 +0200

    fdo#48104 fix RTF import of \page in inner groups
    
    If we have a postponed page break and it's sent to dmapper during a new
    inner group, we'll still have the page break request after the parser
    state is popped, leading to duplicated page breaks. Instead of the
    earlier workaround, just send the proper token to the domain mapper, and
    it'll handle it properly.
    (backport of 7b58fc3dafc789aa55fff5ffef6ab83c3aa8b6e0)
    
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index ef4d3b8..9600414 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -304,7 +304,6 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     m_bFormField(false),
     m_bWasInFrame(false),
     m_bIsInFrame(false),
-    m_bHasPage(false),
     m_aUnicodeBuffer(),
     m_aHexBuffer()
 {
@@ -432,7 +431,6 @@ void RTFDocumentImpl::checkNeedPap()
             {
                 dispatchSymbol(RTF_PAR);
                 m_bNeedPap = false;
-                m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PFPageBreakBefore);
             }
             Mapper().props(pParagraphProperties);
             if (hasBreakBeforeFrame)
@@ -1377,12 +1375,6 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
                 m_bWasInFrame = inFrame();
                 if (!m_bWasInFrame)
                     m_bNeedPar = false;
-                if (m_bHasPage)
-                {
-                    // this has to be reset even without a pard, since it's a symbol in RTF terms
-                    m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PFPageBreakBefore);
-                    m_bHasPage = false;
-                }
             }
             break;
         case RTF_SECT:
@@ -1505,10 +1497,10 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
             break;
         case RTF_PAGE:
             {
-                RTFValue::Pointer_t pValue(new RTFValue(1));
-                dispatchSymbol(RTF_PAR);
-                m_aStates.top().aParagraphSprms->push_back(make_pair(NS_sprm::LN_PFPageBreakBefore, pValue));
-                m_bHasPage = true;
+                sal_uInt8 sBreak[] = { 0xc };
+                Mapper().text(sBreak, 1);
+                if (!m_bNeedPap)
+                    parBreak();
             }
             break;
         default:
@@ -1713,7 +1705,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
         case RTF_KEEP: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeep; break;
         case RTF_KEEPN: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeepFollow; break;
         case RTF_INTBL: m_pCurrentBuffer = &m_aTableBuffer; nParam = NS_sprm::LN_PFInTable; break;
-        case RTF_PAGEBB: nParam = NS_sprm::LN_PFPageBreakBefore; m_bHasPage = false; break;
+        case RTF_PAGEBB: nParam = NS_sprm::LN_PFPageBreakBefore; break;
         default: break;
     }
     if (nParam >= 0)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 3644375..4a28e62 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -450,8 +450,6 @@ namespace writerfilter {
                 bool m_bWasInFrame;
                 /// If a frame start token is already sent to dmapper (nesting them is not OK).
                 bool m_bIsInFrame;
-                /// If we should reset the page break property when we start the next paragraph.
-                bool m_bHasPage;
                 // Unicode characters are collected here so we don't have to send them one by one.
                 rtl::OUStringBuffer m_aUnicodeBuffer;
                 /// Same for hex characters.
commit 3c6b299634b7b08a54b203d984192e1f7bcf9cf3
Author: Martin Hosken <martin_hosken at sil.org>
Date:   Wed Apr 4 14:44:33 2012 +0700

    Fix cursor movement in graphite fonts
    (cherry picked from commit 9b6b1558a3654625ce9a5bef2bee5245db81ff88)
    
    Signed-off-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/inc/graphite_layout.hxx b/vcl/inc/graphite_layout.hxx
index c6c711d..838c32d 100644
--- a/vcl/inc/graphite_layout.hxx
+++ b/vcl/inc/graphite_layout.hxx
@@ -163,9 +163,9 @@ private:
     void expandOrCondense(ImplLayoutArgs &rArgs);
     void    fillFrom(gr_segment * rSeg, ImplLayoutArgs & rArgs, float fScaling);
 
-    void append(gr_segment * pSeg,
+    float append(gr_segment * pSeg,
                 ImplLayoutArgs & rArgs,
-                const gr_slot * pSlot,
+                const gr_slot * pSlot, float gOrigin,
                 float nextGlyphOrigin, float fScaling,
                 long & rDXOffset, bool bIsBase, int baseChar);
 };
diff --git a/vcl/source/glyphs/graphite_layout.cxx b/vcl/source/glyphs/graphite_layout.cxx
index e0898b2..7a240bf 100644
--- a/vcl/source/glyphs/graphite_layout.cxx
+++ b/vcl/source/glyphs/graphite_layout.cxx
@@ -40,6 +40,8 @@
 #undef NDEBUG
 #endif
 
+// #define GRLAYOUT_DEBUG 1
+
 // Header files
 //
 // Standard Library
@@ -270,7 +272,7 @@ GraphiteLayout::fillFrom(gr_segment * pSegment, ImplLayoutArgs &rArgs, float fSc
                     }
                     mvChar2BaseGlyph[mnSegCharOffset + nFirstCharInCluster - mnMinCharPos] = nBaseGlyphIndex;
                 }
-                append(pSegment, rArgs, baseSlot, rightBoundary, fScaling,
+                append(pSegment, rArgs, baseSlot, gr_slot_origin_X(baseSlot), rightBoundary, fScaling,
                        nDxOffset, bCluster, mnSegCharOffset + firstChar);
             }
             if (mnSegCharOffset + nLastCharInCluster < mnMinCharPos)
@@ -349,7 +351,7 @@ GraphiteLayout::fillFrom(gr_segment * pSegment, ImplLayoutArgs &rArgs, float fSc
                     // only set mvChar2BaseGlyph for first character of cluster
                     mvChar2BaseGlyph[mnSegCharOffset + bFirstChar - mnMinCharPos] = nBaseGlyphIndex;
                 }
-                append(pSegment, rArgs, baseSlot, rightBoundary, fScaling,
+                append(pSegment, rArgs, baseSlot, gr_slot_origin_X(baseSlot), rightBoundary, fScaling,
                        nDxOffset, true, mnSegCharOffset + firstChar);
             }
             if (mnSegCharOffset + bFirstChar >= mnEndCharPos)
@@ -405,13 +407,13 @@ GraphiteLayout::fillFrom(gr_segment * pSegment, ImplLayoutArgs &rArgs, float fSc
 
 // append walks an attachment tree, flattening it, and converting it into a
 // sequence of GlyphItem objects which we can later manipulate.
-void
+float
 GraphiteLayout::append(gr_segment *pSeg, ImplLayoutArgs &rArgs,
-    const gr_slot * gi, float nextGlyphOrigin, float scaling, long & rDXOffset,
+    const gr_slot * gi, float gOrigin, float nextGlyphOrigin, float scaling, long & rDXOffset,
     bool bIsBase, int baseChar)
 {
     bool bRtl = (rArgs.mnFlags & SAL_LAYOUT_BIDI_RTL);
-    float nextOrigin = nextGlyphOrigin;
+    float nextOrigin;
     assert(gi);
     assert(gr_slot_before(gi) <= gr_slot_after(gi));
     int firstChar = gr_slot_before(gi) + mnSegCharOffset;
@@ -420,16 +422,22 @@ GraphiteLayout::append(gr_segment *pSeg, ImplLayoutArgs &rArgs,
     // is the next glyph attached or in the next cluster?
     //glyph_set_range_t iAttached = gi.attachedClusterGlyphs();
     const gr_slot * pFirstAttached = gr_slot_first_attachment(gi);
+    const gr_slot * pNextSibling = gr_slot_next_sibling_attachment(gi);
     if (pFirstAttached)
-    {
         nextOrigin = gr_slot_origin_X(pFirstAttached);
-    }
+    else if (!bIsBase && pNextSibling)
+        nextOrigin = gr_slot_origin_X(pNextSibling);
+    else
+        nextOrigin = nextGlyphOrigin;
     long glyphId = gr_slot_gid(gi);
     long deltaOffset = 0;
     int scaledGlyphPos = round(gr_slot_origin_X(gi) * scaling);
-    int glyphWidth = round(nextOrigin * scaling) - scaledGlyphPos;
-    if (glyphWidth < 0)
-        glyphWidth = 0;
+    int glyphWidth = round((nextOrigin - gOrigin) * scaling);
+//    if (glyphWidth < 0)
+//    {
+//        nextOrigin = gOrigin;
+//        glyphWidth = 0;
+//    }
 #ifdef GRLAYOUT_DEBUG
     fprintf(grLog(),"c%d g%ld,X%d W%d nX%f ", firstChar, glyphId,
         (int)(gr_slot_origin_X(gi) * scaling), glyphWidth, nextOrigin * scaling);
@@ -477,16 +485,11 @@ GraphiteLayout::append(gr_segment *pSeg, ImplLayoutArgs &rArgs,
     rDXOffset += deltaOffset;
 
     // Recursively append all the attached glyphs.
-    for (const gr_slot * agi = gr_slot_first_attachment(gi); agi != NULL;
-         agi = gr_slot_next_sibling_attachment(agi))
-    {
-        if (gr_slot_next_sibling_attachment(agi) == NULL)
-            append(pSeg, rArgs, agi, nextGlyphOrigin, scaling, rDXOffset,
-                   false, baseChar);
-        else
-            append(pSeg, rArgs, agi, gr_slot_origin_X(gr_slot_next_sibling_attachment(agi)),
-                   scaling, rDXOffset, false, baseChar);
-    }
+    float cOrigin = nextOrigin;
+    for (const gr_slot * agi = gr_slot_first_attachment(gi); agi != NULL; agi = gr_slot_next_sibling_attachment(agi))
+        cOrigin = append(pSeg, rArgs, agi, cOrigin, nextGlyphOrigin, scaling, rDXOffset, false, baseChar);
+
+    return cOrigin;
 }
 
 //
@@ -596,7 +599,8 @@ gr_segment * GraphiteLayout::CreateSegment(ImplLayoutArgs& rArgs)
                     nSegCharLimit - rArgs.mnEndCharPos, bRtl);
             }
         }
-        size_t numchars = gr_count_unicode_characters(gr_utf16, rArgs.mpStr + mnSegCharOffset, rArgs.mpStr + limit, NULL);
+        size_t numchars = gr_count_unicode_characters(gr_utf16, rArgs.mpStr + mnSegCharOffset,
+                rArgs.mpStr + (rArgs.mnLength > limit + 64 ? limit + 64 : rArgs.mnLength), NULL);
         if (mpFeatures)
             pSegment = gr_make_seg(mpFont, mpFace, 0, mpFeatures->values(), gr_utf16,
                                         rArgs.mpStr + mnSegCharOffset, numchars, bRtl);


More information about the Libreoffice-commits mailing list