Howdy,

The use of tabs in right justified paragraphs causes assertion 
failures.  I had a chance to test the behavior of tabs under
Microsoft Word earlier this evening.  From what I saw, it appears 
that Word behaves as though the tab stop line begins at the first
character in the line.  

Here are some examples to clarify what I mean.  The plus signs
represent tab stops, and the bar is the end of line:

Text<TAB>

       +       +       +       +       +       +       +       |
                                                       Text
               +       +       +       +       +       +       |
                                               Text

More<TAB>Text<TAB>

       +       +       +       +       +       +       +       |
                                               More    Text
               +       +       +       +       +       +       |
                                       More            Text

Given this behavior, should AbiWord try to replicate it, or would 
some other scheme be better?  For instance, another approach would
be to treat this as the inverse of left justified text.  That is,
by default the tab stops should be right tabs, and the above 
examples would become


Text<TAB>

       +       +       +       +       +       +       +       |
                                                    Text
       +       +       +       +       +       +               |
                                            Text

More<TAB>Text<TAB>

       +       +       +       +       +       +       +       |
                                            More    Text
       +       +       +       +       +       +               |
                                    More    Text

Does anyone have any use cases where tabs are used in right 
justified text?  For these, would one approach be better than the 
other?

I have appended a patch to make it work the Microsoft way, although I 
don't know that this is really the best solution (both in terms of 
user interface, and in terms of the patch).  Also, I don't know how to 
insert Right, Center, or Decimal tabs so I haven't been able to test 
those changes.  It does eliminate the assert of 443.  Please let me 
know if some other way is better, and I'll give it a shot instead.

Yours,
 Matt
=== cd /home/kraai/src/abiword/abi/src/text/fmt/xp/
=== /usr/bin/cvs diff -u fp_Line.cpp

Index: fp_Line.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fp_Line.cpp,v
retrieving revision 1.66
diff -u -r1.66 fp_Line.cpp
--- fp_Line.cpp 2000/02/01 10:32:24     1.66
+++ fp_Line.cpp 2000/03/30 07:30:53
@@ -538,10 +538,11 @@
 
        UT_uint32 iCountRuns = m_vecRuns.getItemCount();
        UT_sint32 iX = 0;
+       UT_sint32 iStartX;
        UT_uint32 i;
        UT_Bool bLineErased = UT_FALSE;
 
-       iX = pAlignment->getStartPosition();
+       iStartX = iX = pAlignment->getStartPosition();
        
        for (i=0; i<iCountRuns; i++)            // TODO do we need to do this if 
iMoveOver is zero ??
        {
@@ -563,7 +564,7 @@
                        UT_sint32 iPos;
                        unsigned char iTabType;
 
-                       UT_Bool bRes = findNextTabStop(iX, iPos, iTabType);
+                       UT_Bool bRes = findNextTabStop(iX - iStartX, iPos, iTabType);
                        UT_ASSERT(bRes);
 
                        fp_TabRun* pTabRun = static_cast<fp_TabRun*>(pRun);
@@ -574,8 +575,8 @@
                        switch ( iTabType )
                        {
                        case FL_TAB_LEFT:
-                               pTabRun->setWidth(iPos - iX);
-                               iX = iPos;
+                               pTabRun->setWidth(iPos - (iX - iStartX));
+                               iX = iPos + iStartX;
                                break;
 
                        case FL_TAB_CENTER:
@@ -586,11 +587,11 @@
                                        iScanWidth += pScanRun->getWidth();
                                }
        
-                               if ( iScanWidth / 2 > iPos - iX )
+                               if ( iScanWidth / 2 > iPos - (iX - iStartX) )
                                        pTabRun->setWidth(0);
                                else
                                {
-                                       int tabWidth = iPos - iX - iScanWidth / 2 ;
+                                       int tabWidth = iPos - (iX - iStartX) - 
+iScanWidth / 2 ;
                                        pTabRun->setWidth( tabWidth );
                                        iX += tabWidth;
                                }
@@ -605,11 +606,11 @@
                                        iScanWidth += pScanRun->getWidth();
                                }
                
-                               if ( iScanWidth > iPos - iX )
+                               if ( iScanWidth > iPos - (iX - iStartX) )
                                        pTabRun->setWidth(0);
                                else
                                {
-                                       int tabWidth = iPos - iX - iScanWidth ;
+                                       int tabWidth = iPos - (iX - iStartX) - 
+iScanWidth ;
                                        pTabRun->setWidth( tabWidth );
                                        iX += tabWidth;
                                }
@@ -667,9 +668,9 @@
                                }
                        
                                UT_DEBUGMSG((" tabrun iX=%d iPos=%d iScanWidth=%d 
tabwidth=%d newX=%d\n", 
-                                                                         iX,   iPos,  
 iScanWidth,   iPos-iX-iScanWidth,iPos-iScanWidth));     
-                               pTabRun->setWidth(iPos - iX - iScanWidth);
-                               iX = iPos - iScanWidth;
+                                                                         iX,   iPos,  
+ iScanWidth,   iPos-(iX-iStartX)-iScanWidth,iPos-iScanWidth));   
+                               pTabRun->setWidth(iPos - (iX - iStartX) - iScanWidth);
+                               iX = iPos - iScanWidth + iStartX;
                        
                                FREEP(pDecimalStr);     
                                break;
=== Exit status: 1


Reply via email to