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

matteocam matteo.campanelli at gmail.com
Thu Aug 14 09:01:54 PDT 2014


 editeng/source/editeng/impedit.hxx  |    2 +
 editeng/source/editeng/impedit3.cxx |   43 ++++++++++++++++++++----------------
 include/editeng/editstat.hxx        |   12 +++++-----
 svx/source/svdraw/svdotext.cxx      |    6 ++---
 4 files changed, 36 insertions(+), 27 deletions(-)

New commits:
commit b515d44b620f9f667a0fb172583a62d0300e5a21
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Aug 14 17:59:54 2014 +0200

    Fixed overflow and chaining in edit status
    
    Change-Id: I5c9c2f37056674090551dff1ccf90d306cc456f5

diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 19d2452..e299061 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -619,7 +619,6 @@ void ImpEditEngine::CheckPageOverflow()
         // which paragraph is the first to cause higher size of the box?
         UpdateOverflowingParaNum( nBoxHeight /*aPrevPaperSize.Height()*/ ); // XXX: currently only for horizontal text
         aStatus.SetPageOverflow(true);
-        aStatus.GetStatusWord() |= 0x00000100;
     } else
     {
         // No overflow if withing box boundaries
diff --git a/include/editeng/editstat.hxx b/include/editeng/editstat.hxx
index 0aadd3d..36a816d 100644
--- a/include/editeng/editstat.hxx
+++ b/include/editeng/editstat.hxx
@@ -71,6 +71,7 @@
 #define EE_STAT_TEXTWIDTHCHANGED    0x00000020
 #define EE_STAT_TEXTHEIGHTCHANGED   0x00000040
 #define EE_STAT_WRONGWORDCHANGED    0x00000080
+#define EE_STAT_CHAININGSET     0x00000100
 // #define EE_STAT_MODIFIED         0x00000100
 
 /*
@@ -91,14 +92,15 @@ protected:
     sal_uLong   nStatusBits;
     sal_uLong   nControlBits;
     sal_Int32   nPrevPara;                  // for EE_STAT_CRSRLEFTPARA
-
     bool        bIsPageOverflow;
 
 public:
-            EditStatus()                { nStatusBits = 0; nControlBits = 0;
-                                          nPrevPara = -1; bIsPageOverflow = false; }
+            EditStatus()                { nStatusBits = 0;
+                                          nControlBits = 0;
+                                          nPrevPara = -1;
+                                          bIsPageOverflow = false; }
 
-    void    Clear()                     { nStatusBits = 0; /*bIsPageOverflow = false;*/ }
+    void    Clear()                     { nStatusBits = 0; bIsPageOverflow = false; }
     void    SetControlBits( sal_uLong nMask, bool bOn )
                 { SetFlags( nControlBits, nMask, bOn ); }
 
@@ -112,7 +114,7 @@ public:
     sal_Int32&  GetPrevParagraph()          { return nPrevPara; }
 
     bool        IsPageOverflow() const      { return bIsPageOverflow; }
-    void        SetPageOverflow(bool isOverflow) { bIsPageOverflow = isOverflow; }
+    void        SetPageOverflow(bool isOverflow) { GetStatusWord() |= EE_STAT_CHAININGSET; bIsPageOverflow = isOverflow; }
 };
 
 #define SPELLCMD_IGNOREWORD         0x0001
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index ed6a201..a93d7bc 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1935,8 +1935,8 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
     const sal_uInt32 nStat = pEditStatus->GetStatusWord();
     const bool bGrowX=(nStat & EE_STAT_TEXTWIDTHCHANGED) !=0;
     const bool bGrowY=(nStat & EE_STAT_TEXTHEIGHTCHANGED) !=0;
-    const bool bOverflow = (nStat & 0x00000100) != 0;
-    if(bTextFrame && (bGrowX || bGrowY || bOverflow))
+    const bool bChainingSet = (nStat & EE_STAT_CHAININGSET) != 0;
+    if(bTextFrame && (bGrowX || bGrowY || bChainingSet))
     {
         if ((bGrowX && IsAutoGrowWidth()) || (bGrowY && IsAutoGrowHeight()))
         {
@@ -1953,7 +1953,7 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
             ImpAutoFitText(*pEdtOutl);
             mbInDownScale = false;
         }
-        else if ( GetNextLinkInChain() != NULL && bOverflow ) // do it only if it is a call explicitly for chaining (status word already cleared)
+        else if ( GetNextLinkInChain() != NULL )
         {
             // set the need for chaining
             SetToBeChained( pEditStatus->IsPageOverflow() );
commit 9f7ebc397fbc6602ac3787f77a61cd05d1716bf0
Author: matteocam <matteo.campanelli at gmail.com>
Date:   Thu Aug 14 17:08:34 2014 +0200

    Overflow detection coupled with handler. Using status word for overflow
    
    Change-Id: I01abba89b4e14016d3c21103410963ead2cd097b

diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index ac95eaa..e8ede1b 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -552,6 +552,8 @@ private:
     void                RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont );
     void                CheckAutoPageSize();
 
+    void                CheckPageOverflow();
+
     void                ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_Int32 nPortionStart, long nRemainingWidth, bool bCanHyphenate );
     void                ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, long nRemainingSpace );
     EditPaM             ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, bool bBackward = false );
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index b0db341..19d2452 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -512,12 +512,14 @@ void ImpEditEngine::FormatDoc()
 
 void ImpEditEngine::CallStatusHdlChaining()
 {
+    // only if it's the right ImpEditEngine (with right info on changes in text)
     if ( aStatusHdlLinkChaining.IsSet() /* && aStatus.GetStatusWord() */)
     {
+        CheckPageOverflow();
         // The Status has to be reset before the Call,
         // since other Flags might be set in the handler...
         EditStatus aTmpStatus( aStatus );
-        //aStatus.Clear(); // No need for this with chaining. It does not affect it either way.
+        aStatus.Clear();
         aStatusHdlLinkChaining.Call( &aTmpStatus );
         aStatusTimer.Stop();    // If called by hand ...
     }
@@ -559,24 +561,6 @@ void ImpEditEngine::CheckAutoPageSize()
 
     SetValidPaperSize( aPaperSize );    // consider Min, Max
 
-    // FIXME(matteocam)
-    /* fprintf( stderr, IsPageOverflow(aPaperSize, aPrevPaperSize)
-                        ? "YES Overflow!\n"  : "NO Overflow!\n" ); */
-    // setting overflow status
-    sal_uInt32 nBoxHeight = 1783; // XXX: hard coded for testing
-    //if ( IsPageOverflow( aPaperSize, aPrevPaperSize ) ) {
-    if (CalcTextHeight(NULL) > nBoxHeight) // XXX: CalcTextHeight here??
-    {
-        // which paragraph is the first to cause higher size of the box?
-        UpdateOverflowingParaNum( nBoxHeight /*aPrevPaperSize.Height()*/ ); // XXX: currently only for horizontal text
-        aStatus.SetPageOverflow(true);
-        aStatus.GetStatusWord() |= 0x00000100;
-    } else
-    {
-        // No overflow if withing box boundaries
-        aStatus.SetPageOverflow(false);
-    }
-
     if ( aPaperSize != aPrevPaperSize )
     {
         if ( ( !IsVertical() && ( aPaperSize.Width() != aPrevPaperSize.Width() ) )
@@ -622,6 +606,28 @@ void ImpEditEngine::CheckAutoPageSize()
     }
 }
 
+void ImpEditEngine::CheckPageOverflow()
+{
+    // FIXME(matteocam)
+    /* fprintf( stderr, IsPageOverflow(aPaperSize, aPrevPaperSize)
+                        ? "YES Overflow!\n"  : "NO Overflow!\n" ); */
+    // setting overflow status
+    sal_uInt32 nBoxHeight = 1783; // XXX: hard coded for testing
+    //if ( IsPageOverflow( aPaperSize, aPrevPaperSize ) ) {
+    if (CalcTextHeight(NULL) > nBoxHeight) // XXX: CalcTextHeight here??
+    {
+        // which paragraph is the first to cause higher size of the box?
+        UpdateOverflowingParaNum( nBoxHeight /*aPrevPaperSize.Height()*/ ); // XXX: currently only for horizontal text
+        aStatus.SetPageOverflow(true);
+        aStatus.GetStatusWord() |= 0x00000100;
+    } else
+    {
+        // No overflow if withing box boundaries
+        aStatus.SetPageOverflow(false);
+    }
+
+}
+
 static sal_Int32 ImplCalculateFontIndependentLineSpacing( const sal_Int32 nFontHeight )
 {
     return ( nFontHeight * 12 ) / 10;   // + 20%
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index dd16447..ed6a201 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1936,7 +1936,7 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
     const bool bGrowX=(nStat & EE_STAT_TEXTWIDTHCHANGED) !=0;
     const bool bGrowY=(nStat & EE_STAT_TEXTHEIGHTCHANGED) !=0;
     const bool bOverflow = (nStat & 0x00000100) != 0;
-    if(bTextFrame && (bGrowX || bGrowY || !nStat))
+    if(bTextFrame && (bGrowX || bGrowY || bOverflow))
     {
         if ((bGrowX && IsAutoGrowWidth()) || (bGrowY && IsAutoGrowHeight()))
         {
@@ -1953,7 +1953,7 @@ void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
             ImpAutoFitText(*pEdtOutl);
             mbInDownScale = false;
         }
-        else if ( GetNextLinkInChain() != NULL && !nStat ) // do it only if it is a call explicitly for chaining (status word already cleared)
+        else if ( GetNextLinkInChain() != NULL && bOverflow ) // do it only if it is a call explicitly for chaining (status word already cleared)
         {
             // set the need for chaining
             SetToBeChained( pEditStatus->IsPageOverflow() );


More information about the Libreoffice-commits mailing list