1 /************************************************************************/
2 /*									*/
3 /*  Read/Write tab stops from/to rtf.					*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"docRtfConfig.h"
8 
9 #   include	<stdio.h>
10 #   include	<ctype.h>
11 
12 #   include	<appDebugon.h>
13 
14 #   include	"docRtfWriterImpl.h"
15 #   include	"docRtfReaderImpl.h"
16 #   include	"docRtfTags.h"
17 
18 /************************************************************************/
19 /*									*/
20 /*  Save a tab stop.							*/
21 /*									*/
22 /************************************************************************/
23 
docRtfSaveTabStopList(RtfWriter * rw,const TabStopList * tsl)24 void docRtfSaveTabStopList( 	RtfWriter *		rw,
25 				const TabStopList *	tsl )
26     {
27     int			i;
28     const TabStop *	ts;
29 
30     ts= tsl->tslTabStops;
31     for ( i= 0; i < tsl->tslTabStopCount; ts++, i++ )
32 	{
33 	if  ( rw->rwCol >= 65 )
34 	    { docRtfWriteNextLine( rw );	}
35 
36 	if  ( ts->tsAlignment != DOCtaLEFT )
37 	    {
38 	    docRtfWriteEnumTag( rw, DOCrtf_TabAlignTags, ts->tsAlignment,
39 				    DOCrtf_TabAlignTagCount, DOCta_COUNT );
40 	    }
41 
42 	if  ( ts->tsLeader != DOCtlNONE )
43 	    {
44 	    docRtfWriteEnumTag( rw, DOCrtf_TabLeaderTags, ts->tsLeader,
45 				    DOCrtf_TabLeaderTagCount, DOCtl_COUNT );
46 	    }
47 
48 	if  ( ts->tsFromStyleOrList )
49 	    { docRtfWriteTag( rw, "jclisttab" );	}
50 
51 	docRtfWriteArgTag( rw, "tx", ts->tsTwips );
52 	}
53 
54     return;
55     }
56 
57 /************************************************************************/
58 /*									*/
59 /*  Handle a tab stop property when reading RTF.			*/
60 /*									*/
61 /************************************************************************/
62 
docRtfRememberTabStopProperty(const RtfControlWord * rcw,int arg,RtfReader * rrc)63 int docRtfRememberTabStopProperty(	const RtfControlWord *	rcw,
64 					int			arg,
65 					RtfReader *		rrc )
66     {
67     RtfReadingState *	rrs= rrc->rrcState;
68     TabStop *		ts= &(rrc->rrcTabStop);
69 
70     if  ( docTabStopSetProperty( ts, rcw->rcwID, arg ) )
71 	{ SLDEB(rcw->rcwWord,arg); return 0;	}
72 
73     if  ( rcw->rcwID == TABpropX )
74 	{
75 	if  ( docAddTabToListTwips( &(rrs->rrsTabStopList), ts ) < 0 )
76 	    { SLDEB(rcw->rcwWord,arg); return -1;	}
77 
78 	docInitTabStop( ts );
79 
80 	PROPmaskADD( &(rrc->rrcStyle.dsParaMask), PPpropTAB_STOPS );
81 	}
82 
83     return 0;
84     }
85