incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o..@apache.org
Subject svn commit: r1359268 - /incubator/ooo/trunk/main/sw/source/core/layout/tabfrm.cxx
Date Mon, 09 Jul 2012 16:43:44 GMT
Author: orw
Date: Mon Jul  9 16:43:44 2012
New Revision: 1359268

URL: http://svn.apache.org/viewvc?rev=1359268&view=rev
Log:
#120016# - method <SwTabFrm::MakeAll()> - refine condition for allowing split of a table
row:

           Found by: Yan Ji, Jian Hong Cheng
           Patch by: Oliver-Rainer Wittmann
           Review by: Jian Hong Cheng

Modified:
    incubator/ooo/trunk/main/sw/source/core/layout/tabfrm.cxx

Modified: incubator/ooo/trunk/main/sw/source/core/layout/tabfrm.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/layout/tabfrm.cxx?rev=1359268&r1=1359267&r2=1359268&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/layout/tabfrm.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/layout/tabfrm.cxx Mon Jul  9 16:43:44 2012
@@ -1875,6 +1875,22 @@ SwFrm* lcl_FormatNextCntntForKeep( SwTab
     return pNxt;
 }
 
+namespace {
+    bool AreAllRowsKeepWithNext( const SwRowFrm* pFirstRowFrm )
+    {
+        bool bRet = pFirstRowFrm != 0 &&
+                    pFirstRowFrm->ShouldRowKeepWithNext();
+
+        while ( bRet && pFirstRowFrm->GetNext() != 0 )
+        {
+            pFirstRowFrm = dynamic_cast<const SwRowFrm*>(pFirstRowFrm->GetNext());
+            bRet = pFirstRowFrm != 0 &&
+                   pFirstRowFrm->ShouldRowKeepWithNext();
+        }
+
+        return bRet;
+    }
+}
 void SwTabFrm::MakeAll()
 {
 	if ( IsJoinLocked() || StackHack::IsLocked() || StackHack::Count() > 50 )
@@ -2419,11 +2435,17 @@ void SwTabFrm::MakeAll()
         // 2. If this row wants to keep, we need an additional row
         // 3. The table is allowed to split or we do not have an pIndPrev:
         //
-		SwFrm* pIndPrev = GetIndPrev();
+        SwFrm* pIndPrev = GetIndPrev();
         const SwRowFrm* pFirstNonHeadlineRow = GetFirstNonHeadlineRow();
+        // #120016# if this row wants to keep, allow split in case that all rows want to
keep with next, 
+        // the table can not move forward as it is the first one and a split is in general
allowed.
+        const bool bAllowSplitOfRow = ( bTableRowKeep && 
+                                        AreAllRowsKeepWithNext( pFirstNonHeadlineRow ) )
&&
+                                      !pIndPrev && 
+                                      !bDontSplit;
 
         if ( pFirstNonHeadlineRow && nUnSplitted > 0 &&
-             ( !bTableRowKeep || pFirstNonHeadlineRow->GetNext() || !pFirstNonHeadlineRow->ShouldRowKeepWithNext()
) &&
+             ( !bTableRowKeep || pFirstNonHeadlineRow->GetNext() || !pFirstNonHeadlineRow->ShouldRowKeepWithNext()
|| bAllowSplitOfRow ) &&
              ( !bDontSplit || !pIndPrev ) )
         {
             // --> FME 2004-06-03 #i29438#
@@ -2442,7 +2464,7 @@ void SwTabFrm::MakeAll()
 
             // 1. Try: bTryToSplit = true  => Try to split the row.
             // 2. Try: bTryToSplit = false => Split the table between the rows.
-			if ( pFirstNonHeadlineRow->GetNext() || bTryToSplit )
+            if ( pFirstNonHeadlineRow->GetNext() || bTryToSplit )
             {
                 SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
                 if( IsInSct() || GetUpper()->IsInTab() ) // TABLE IN TABLE)
@@ -2515,11 +2537,15 @@ void SwTabFrm::MakeAll()
                     // An existing follow flow line has to be removed.
                     //
                     if ( HasFollowFlowLine() )
-						RemoveFollowFlowLine();
+                    {
+                        RemoveFollowFlowLine();
+                    }
 
-                    const bool bSplitError = !Split( nDeadLine, bTryToSplit, bTableRowKeep
);
-					if( !bTryToSplit && !bSplitError && nUnSplitted > 0 )
-						--nUnSplitted;
+                    const bool bSplitError = !Split( nDeadLine, bTryToSplit, ( bTableRowKeep
&& !bAllowSplitOfRow ) );
+                    if( !bTryToSplit && !bSplitError && nUnSplitted >
0 )
+                    {
+                        --nUnSplitted;
+                    }
 
                     // --> FME 2004-06-09 #i29771# Two tries to split the table:
                     // If an error occured during splitting. We start a second
@@ -2546,12 +2572,12 @@ void SwTabFrm::MakeAll()
                     {
                         lcl_RecalcRow( static_cast<SwRowFrm&>(*Lower()), LONG_MAX
);
                         bValidPos = sal_False;
-    					bTryToSplit = false;
+                        bTryToSplit = false;
                         continue;
                     }
                     // <--
 
-  					bTryToSplit = !bSplitError;
+                    bTryToSplit = !bSplitError;
 
                     //Damit es nicht zu Oszillationen kommt, muss der
                     //Follow gleich gueltig gemacht werden.
@@ -2636,11 +2662,13 @@ void SwTabFrm::MakeAll()
         // Set to false again as early as possible.
         bLastRowHasToMoveToFollow = false;
 
-		if( IsInSct() && bMovedFwd && bMakePage && GetUpper()->IsColBodyFrm()
&&
-			GetUpper()->GetUpper()->GetUpper()->IsSctFrm() &&
-			( GetUpper()->GetUpper()->GetPrev() || GetIndPrev() ) &&
-			((SwSectionFrm*)GetUpper()->GetUpper()->GetUpper())->MoveAllowed(this) )
-			bMovedFwd = sal_False;
+        if( IsInSct() && bMovedFwd && bMakePage && GetUpper()->IsColBodyFrm()
&&
+            GetUpper()->GetUpper()->GetUpper()->IsSctFrm() &&
+            ( GetUpper()->GetUpper()->GetPrev() || GetIndPrev() ) &&
+            ((SwSectionFrm*)GetUpper()->GetUpper()->GetUpper())->MoveAllowed(this)
)
+        {
+            bMovedFwd = sal_False;
+        }
 
         // --> FME 2004-06-09 #i29771# Reset bTryToSplit flag on change of upper
         const SwFrm* pOldUpper = GetUpper();



Mime
View raw message