[Libreoffice-commits] core.git: Branch 'feature/gsoc14-draw-chained-text-boxes' - editeng/source

matteocam matteo.campanelli at gmail.com
Fri Aug 8 06:51:58 PDT 2014


 editeng/source/editeng/impedit.hxx  |    2 +-
 editeng/source/editeng/impedit3.cxx |   32 +++++++++++++++++++-------------
 2 files changed, 20 insertions(+), 14 deletions(-)

New commits:
commit b082a055e9f2d40fc2840e4b3c6f8af373992aa5
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Fri Aug 8 15:43:12 2014 +0200

    Scanning paragraphs to find overflowing one
    
    Change-Id: Ib6769f663251f35fbd91eb43031ce60f555f897b

diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index de32cbd..2ed9175 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -1023,7 +1023,7 @@ public:
     sal_Int32 GetOverflowingParaNum() const { return mnOverflowingPara; }
     void SetOverflowingParaNum(sal_Int32 nPara) { mnOverflowingPara = nPara; }
     void ClearOverflowingParaNum() { mnOverflowingPara = -1; }
-    void UpdateOverflowingParaNum(sal_Int32);
+    void UpdateOverflowingParaNum();
 };
 
 inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM )
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 973ae96..98744b6 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -425,13 +425,6 @@ void ImpEditEngine::FormatDoc()
                 if ( IsCallParaInsertedOrDeleted() )
                     GetEditEnginePtr()->ParagraphHeightChanged( nPara );
                 pParaPortion->SetMustRepaint( false );
-
-                // FIXME(matteocam)
-                // set possible point for chaining
-
-                // XXX: This may not work all the time: imp. edit engine is a shared resource!!
-                        // Can it be that two boxes modify it before it's used?
-                UpdateOverflowingParaNum( nPara );
             }
 
             // InvalidRect set only once...
@@ -474,6 +467,10 @@ void ImpEditEngine::FormatDoc()
                 aInvalidRect.Left() = 0;
                 aInvalidRect.Right() = !IsVertical() ? aPaperSize.Width() : aPaperSize.Height();
             }
+        } else if ( nNewHeight > nCurTextHeight ) // possible page overflow // FIXME(matteocam)
+        {
+            // which paragraph is the first to cause higher size of the box?
+            UpdateOverflowingParaNum();
         }
 
         nCurTextHeight = nNewHeight;
@@ -4604,14 +4601,23 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion*
     }
 }
 
-void ImpEditEngine::UpdateOverflowingParaNum(sal_Int32 nPara)
+void ImpEditEngine::UpdateOverflowingParaNum()
 {
-    // update if not already updated
-    if ( mnOverflowingPara == -1 ) {
-        mnOverflowingPara = nPara;
-        fprintf(stderr, "[CHAINING] Setting first overflowing para: %d\n", nPara);
+    sal_uInt32 nY = 0;
+    sal_uInt32 nPH;
+
+    for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ ) {
+        ParaPortion* pPara = GetParaPortions()[nPara];
+        nPH = pPara->GetHeight();
+        nY += nPH;
+        if ( nY > nCurTextHeight ) // found first paragraph overflowing
+        {
+            SetOverflowingParaNum( nPara );
+            fprintf(stderr, "[CHAINING] Setting first overflowing para: %d\n", nPara);
+            return;
+        }
     }
-    // XXX: where is this reset?
+    fprintf(stderr, "[CHAINING] Warning: Overflowing paragraph not found\n");
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list