Dear Friends

Here is a new version of my "Show Paragraph" patch. It is still incomplete
and basicly with the same features/drawbacks as my first version. Sorry
for this, I had exams the last 5 weeks. 
The patch is cleaned up, conform to the abiword-coding-guidlines and stores
the "ShowParagraph" bool on a per-frame basis. But still no nice "P" at the
end of the lines. I am still not sure how to implement this. I played around
with a new Run (showParagraphRun() ), but without much success. If someone
is interessed in helping, I would be more than happy (I am a bit short in
time, currently).

best regards
 Michael


-- 
GPG Fingerprint = EA71 B296 4597 4D8B 343E  821E 9624 83E1 5662 C734
 /"\                                     o
 \ /     ASCII RIBBON CAMPAIGN          /|\
  X        AGAINST HTML MAIL             >>
 / \                                     o
diff -u -r abi-0.7.8.orig/src/text/fmt/xp/fp_Run.cpp 
abi-0.7.8/src/text/fmt/xp/fp_Run.cpp
--- abi-0.7.8.orig/src/text/fmt/xp/fp_Run.cpp   Fri Jan  7 10:51:40 2000
+++ abi-0.7.8/src/text/fmt/xp/fp_Run.cpp        Fri Mar 17 15:35:26 2000
@@ -376,6 +376,7 @@
        
        UT_RGBColor clrSelBackground(192, 192, 192);
        UT_RGBColor clrNormalBackground(255,255,255);
+       UT_RGBColor clrTabColor(128,128,128);
 
        UT_sint32 iFillHeight = m_pLine->getHeight();
        UT_sint32 iFillTop = pDA->yoff - m_pLine->getAscent();
@@ -386,6 +387,8 @@
 
        UT_uint32 iSel1 = UT_MIN(iSelAnchor, iPoint);
        UT_uint32 iSel2 = UT_MAX(iSelAnchor, iPoint);
+
+       UT_UCSChar chTab = 0xBB; //FIXME: char ">>" in latin1
        
        UT_ASSERT(iSel1 <= iSel2);
        
@@ -402,6 +405,11 @@
        {
                m_pG->fillRect(clrNormalBackground, pDA->xoff, iFillTop, m_iWidth, 
iFillHeight);
        }
+       if( pView->getShowPara() ) 
+       {
+               m_pG->setColor(clrTabColor);
+               m_pG->drawChars(&chTab, 0, 1, pDA->xoff, iFillTop);
+       }
 }
 
 //////////////////////////////////////////////////////////////////
@@ -1070,10 +1078,37 @@
 {
        UT_ASSERT(!m_bDirty);
        UT_ASSERT(m_pG->queryProperties(GR_Graphics::DGP_SCREEN));
+
+       UT_sint32 xoff=0, yoff=0;
+       UT_sint32 iLineHeight = m_pLine->getHeight();
+
+       FV_View* pView = m_pBL->getDocLayout()->getView();
+       UT_sint32 iXStart = pView->getPageViewLeftMargin() + 1; 
+       UT_sint32 iXEnd   = pView->getWindowWidth() + iXStart;
+
+       m_pLine->getScreenOffsets(this, xoff, yoff);
+       //fprintf(stderr, "iXStart: %i, iXEnd: %i \n",iXStart, iXEnd);
+       //FIXME: clear always? or just if( pView->getShowPara() == true ) ?
+       m_pG->clearArea(iXStart, yoff, iXEnd, iLineHeight);
 }
 
 void fp_ForcedPageBreakRun::_draw(dg_DrawArgs* pDA)
 {
        UT_ASSERT(pDA->pG == m_pG);
+       
+       FV_View* pView = m_pBL->getDocLayout()->getView();
+       UT_ASSERT(pView != NULL);
+       if( pView->getShowPara() ) 
+       {
+               UT_RGBColor clrPageBreak(128,128,128);
+               UT_sint32 iLineHeight = m_pLine->getHeight();
+               UT_sint32 iXStart = pView->getPageViewLeftMargin() + 1; 
+               UT_sint32 iXEnd   = pView->getWindowWidth() + iXStart;
+               // FIXME: sometimes iXEnd is far too big (2*regular iXEnd) Why?
+               // fprintf(stderr, "iXStart: %i, iXEnd: %i \n",iXStart, iXEnd);
+               m_pG->setColor(clrPageBreak);
+               m_pG->drawLine(iXStart, pDA->yoff - (iLineHeight/2) , 
+                              iXEnd, pDA->yoff - (iLineHeight/2));
+       }
 }
 
diff -u -r abi-0.7.8.orig/src/text/fmt/xp/fp_TextRun.cpp 
abi-0.7.8/src/text/fmt/xp/fp_TextRun.cpp
--- abi-0.7.8.orig/src/text/fmt/xp/fp_TextRun.cpp       Fri Jan 28 14:51:34 2000
+++ abi-0.7.8/src/text/fmt/xp/fp_TextRun.cpp    Fri Mar 17 20:31:37 2000
@@ -809,7 +809,10 @@
                        _drawPart(pDA->xoff, yTopOfRun, iSel2 - iBase, m_iLen - (iSel2 
- iRunBase), pgbCharWidths);
                }
        }
-
+       if( pView->getShowPara() )
+       {
+               _drawSpaces(pDA->xoff, yTopOfRun, m_iOffsetFirst, m_iLen, 
+pgbCharWidths); 
+       }
        _drawDecors(pDA->xoff, yTopOfRun);
 
        // TODO: draw this underneath (ie, before) the text and decorations
@@ -880,6 +883,72 @@
                pRect->width += pCharWidths[i];
        }
 }
+
+void fp_TextRun::_drawSpaces(UT_sint32 xoff,
+                             UT_sint32 yoff,
+                             UT_uint32 iStart,
+                             UT_uint32 iLen,
+                             const UT_GrowBuf * pgbCharWidths)
+{
+        const UT_UCSChar* pSpan;
+        UT_uint32 lenSpan;
+        UT_uint32 offset = iStart;
+        UT_uint32 len = iLen;
+        UT_Bool bContinue = UT_TRUE;
+
+       UT_UCSChar chSpaceDot = 0xB7; // FIXME: latin1 "." 
+        UT_RGBColor clrSpaceDot(128,128,128);
+       
+       m_pG->setColor(clrSpaceDot);
+       // don't even try to draw a zero-length run
+       if (m_iLen == 0)
+        {
+               return;
+        }
+        UT_ASSERT(offset >= m_iOffsetFirst);
+        UT_ASSERT(offset + len <= m_iOffsetFirst + m_iLen);
+
+        UT_uint32 iLeftWidth = 0;
+        const UT_uint16 * pCharWidths = pgbCharWidths->getPointer(0);
+
+        UT_uint32 i;
+        for (i=m_iOffsetFirst; i<iStart; i++)
+        {
+                iLeftWidth += pCharWidths[i];
+        }
+
+        while (bContinue)
+        {
+                bContinue = m_pBL->getSpanPtr(offset, &pSpan, &lenSpan);
+                UT_ASSERT(lenSpan>0);
+               
+                if (len <= lenSpan)
+                {
+                       for(int i=0; i<len;i++) 
+                       {
+                              if(pSpan[i] == UCS_SPACE) 
+                                      m_pG->drawChars(&chSpaceDot, 0, 1, xoff + 
+iLeftWidth, yoff);
+                              iLeftWidth += pCharWidths[offset + i]; 
+                       }
+                       bContinue = UT_FALSE;
+                }
+                else
+                {
+                       for(int i=0; i<lenSpan;i++) 
+                       {
+                              if(pSpan[i] == UCS_SPACE) 
+                                      m_pG->drawChars(&chSpaceDot, 0, 1, xoff + 
+iLeftWidth, yoff);
+                              iLeftWidth += pCharWidths[offset + i];
+                       }  
+                       offset += lenSpan;
+                       len -= lenSpan;
+
+                       UT_ASSERT(offset >= m_iOffsetFirst);
+                       UT_ASSERT(offset + len <= m_iOffsetFirst + m_iLen);
+                }
+        }
+}
+
 
 void fp_TextRun::_drawPart(UT_sint32 xoff,
                                                   UT_sint32 yoff,
diff -u -r abi-0.7.8.orig/src/text/fmt/xp/fp_TextRun.h 
abi-0.7.8/src/text/fmt/xp/fp_TextRun.h
--- abi-0.7.8.orig/src/text/fmt/xp/fp_TextRun.h Sat Jan 29 02:07:13 2000
+++ abi-0.7.8/src/text/fmt/xp/fp_TextRun.h      Fri Mar 17 20:32:45 2000
@@ -103,6 +103,12 @@
                                                                          UT_uint32 
iLen,
                                                                          const 
UT_GrowBuf * pgbCharWidths);
 
+       void                                    _drawSpaces(UT_sint32 xoff,
+                                                                         UT_sint32 
+yoff,
+                                                                         UT_uint32 
+iStart,
+                                                                         UT_uint32 
+iLen,
+                                                                         const 
+UT_GrowBuf * pgbCharWidths);
+
        void                                    _fillRect(UT_RGBColor& clr,
                                                                          UT_sint32 
xoff,
                                                                          UT_sint32 
yoff,
diff -u -r abi-0.7.8.orig/src/text/fmt/xp/fv_View.cpp 
abi-0.7.8/src/text/fmt/xp/fv_View.cpp
--- abi-0.7.8.orig/src/text/fmt/xp/fv_View.cpp  Tue Feb  1 11:34:39 2000
+++ abi-0.7.8/src/text/fmt/xp/fv_View.cpp       Fri Mar 17 16:06:43 2000
@@ -30,6 +30,7 @@
 #include "ut_timer.h"
 
 #include "xav_View.h"
+#include "xap_Frame.h"
 #include "fv_View.h"
 #include "fl_DocLayout.h"
 #include "fl_BlockLayout.h"
@@ -51,6 +52,7 @@
 #include "xap_Clipboard.h"
 #include "ap_TopRuler.h"
 #include "ap_LeftRuler.h"
+#include "ap_FrameData.h"
 #include "ap_Prefs.h"
 
 #include "sp_spell.h"
@@ -106,6 +108,14 @@
        m_chg.propsChar = NULL;
        m_chg.propsBlock = NULL;
        m_chg.propsSection = NULL;
+
+       // make sure, that showPara is in sync with the Frame
+       XAP_Frame * pFrame = (XAP_Frame *) this->getParentData();
+       UT_ASSERT(pFrame);
+       
+       AP_FrameData *pFrameData = (AP_FrameData *)pFrame->getFrameData();
+       UT_ASSERT(pFrameData);
+       this->setShowPara( pFrameData->m_bShowPara );
 
        pLayout->setView(this);
                
diff -u -r abi-0.7.8.orig/src/text/fmt/xp/fv_View.h abi-0.7.8/src/text/fmt/xp/fv_View.h
--- abi-0.7.8.orig/src/text/fmt/xp/fv_View.h    Tue Feb  1 11:34:39 2000
+++ abi-0.7.8/src/text/fmt/xp/fv_View.h Fri Mar 17 15:09:55 2000
@@ -156,6 +156,9 @@
        void insertParagraphBreak(void);
        void insertSectionBreak(void);
 
+       UT_Bool getShowPara(void) { return m_bShowPara; };
+       void setShowPara(UT_Bool bShowPara) { m_bShowPara = bShowPara; };
+
 // ----------------------
        UT_Bool                 isLeftMargin(UT_sint32 xPos, UT_sint32 yPos);
        void                    cmdSelect(UT_sint32 xPos, UT_sint32 yPos, FV_DocPos 
dpBeg, FV_DocPos dpEnd);
@@ -316,6 +319,9 @@
        UT_Bool                         m_bCursorBlink;
        
        fv_ChangeState          m_chg;
+
+       // show Paragraphs
+       UT_Bool                 m_bShowPara;
 
        // find and replace stuff
        UT_Bool                         m_wrappedEnd;
diff -u -r abi-0.7.8.orig/src/wp/ap/xp/ap_EditMethods.cpp 
abi-0.7.8/src/wp/ap/xp/ap_EditMethods.cpp
--- abi-0.7.8.orig/src/wp/ap/xp/ap_EditMethods.cpp      Tue Feb  1 11:34:40 2000
+++ abi-0.7.8/src/wp/ap/xp/ap_EditMethods.cpp   Fri Mar 17 16:03:11 2000
@@ -3871,9 +3871,19 @@
 {
        XAP_Frame * pFrame = (XAP_Frame *) pAV_View->getParentData();
        UT_ASSERT(pFrame);
+       
+       AP_FrameData *pFrameData = (AP_FrameData *)pFrame->getFrameData();
+       UT_ASSERT(pFrameData);
+
+       // toggle the "Show Paragraph" bit
+       pFrameData->m_bShowPara = ! pFrameData->m_bShowPara;
+
+       // actually do the dirty work
+       ABIWORD_VIEW;
+       pView->setShowPara( pFrameData->m_bShowPara );
+       pView->draw();
+       // FIXME: save this value in the prefence-file? or in the document?
 
-       // TODO: synch this implementation with ap_GetState_View
-       s_TellNotImplemented(pFrame, "Show/Hide Paragraphs", __LINE__);
        return UT_TRUE;
 }
 
diff -u -r abi-0.7.8.orig/src/wp/ap/xp/ap_FrameData.cpp 
abi-0.7.8/src/wp/ap/xp/ap_FrameData.cpp
--- abi-0.7.8.orig/src/wp/ap/xp/ap_FrameData.cpp        Thu Dec  2 00:51:03 1999
+++ abi-0.7.8/src/wp/ap/xp/ap_FrameData.cpp     Fri Mar 17 16:07:53 2000
@@ -32,6 +32,7 @@
        m_pDocLayout = NULL;
        m_pG = NULL;
        m_bShowRuler = UT_TRUE;         // TODO : change to Prefs
+       m_bShowPara  = UT_FALSE;
        m_pTopRuler = NULL;
        m_pLeftRuler = NULL;
        m_pStatusBar = NULL;
diff -u -r abi-0.7.8.orig/src/wp/ap/xp/ap_FrameData.h 
abi-0.7.8/src/wp/ap/xp/ap_FrameData.h
--- abi-0.7.8.orig/src/wp/ap/xp/ap_FrameData.h  Thu Dec  2 00:51:03 1999
+++ abi-0.7.8/src/wp/ap/xp/ap_FrameData.h       Fri Mar 17 15:20:26 2000
@@ -46,6 +46,7 @@
        GR_Graphics *           m_pG;
 
        UT_Bool                         m_bShowRuler;
+       UT_Bool                 m_bShowPara;
        AP_TopRuler *           m_pTopRuler;
        AP_LeftRuler *          m_pLeftRuler;
 
diff -u -r abi-0.7.8.orig/src/wp/ap/xp/ap_Menu_Functions.cpp 
abi-0.7.8/src/wp/ap/xp/ap_Menu_Functions.cpp
--- abi-0.7.8.orig/src/wp/ap/xp/ap_Menu_Functions.cpp   Mon Jan 10 20:32:37 2000
+++ abi-0.7.8/src/wp/ap/xp/ap_Menu_Functions.cpp        Fri Mar 17 15:18:36 2000
@@ -535,6 +535,12 @@
                break;
 
        case AP_MENU_ID_VIEW_SHOWPARA:
+               if( pFrameData->m_bShowPara )
+                       s = EV_MIS_Toggled;
+               else
+                       s = EV_MIS_ZERO;
+               break;
+                 
        case AP_MENU_ID_VIEW_HEADFOOT:
                // TODO: implement view methods to check, toggle state
                s = EV_MIS_Gray;

Reply via email to