1 /************************************************************************/
2 /* */
3 /* Read/Write border properties to/from 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 border definition. */
21 /* */
22 /************************************************************************/
23
docRtfSaveBorder(RtfWriter * rw,const char * tag,const BorderProperties * bp)24 static void docRtfSaveBorder( RtfWriter * rw,
25 const char * tag,
26 const BorderProperties * bp )
27 {
28 docRtfWriteTag( rw, tag );
29
30 docRtfWriteEnumTag( rw, DOCrtf_BorderStyleTags, bp->bpStyle,
31 DOCrtf_BorderStyleTagCount, DOCbs_COUNT );
32
33 if ( bp->bpArt != 0 )
34 { docRtfWriteArgTag( rw, "brdrart", bp->bpColor ); }
35
36 if ( bp->bpColor != 0 )
37 { docRtfWriteArgTag( rw, "brdrcf", bp->bpColor ); }
38
39 if ( bp->bpPenWideTwips != 0 )
40 { docRtfWriteArgTag( rw, "brdrw", bp->bpPenWideTwips ); }
41
42 if ( bp->bpSpacingTwips != 0 )
43 { docRtfWriteArgTag( rw, "brsp", bp->bpSpacingTwips ); }
44
45 docRtfWriteNextLine( rw );
46
47 return;
48 }
49
docRtfSaveBorderByNumber(RtfWriter * rwc,const char * tag,int num,int anyway)50 void docRtfSaveBorderByNumber( RtfWriter * rwc,
51 const char * tag,
52 int num,
53 int anyway )
54 {
55 const BufferDocument * bd= rwc->rwDocument;
56
57 BorderProperties bp;
58
59 docGetBorderPropertiesByNumber( &bp, bd, num );
60
61 if ( ! anyway && bp.bpStyle == DOCbsNONE )
62 { return; }
63
64 docRtfSaveBorder( rwc, tag, &bp );
65 }
66
docRtfBeginBorder(const RtfControlWord * rcw,int arg,RtfReader * rr)67 int docRtfBeginBorder( const RtfControlWord * rcw,
68 int arg,
69 RtfReader * rr )
70 {
71 docInitBorderProperties( &(rr->rrcBorderProperties) );
72 rr->rrcBorderProperties.bpStyle= DOCbsS;
73 return 0;
74 }
75
docRtfReadGetBorderNumber(RtfReader * rr)76 int docRtfReadGetBorderNumber( RtfReader * rr )
77 {
78 int rval= docBorderPropertiesNumber( rr->rrDocument,
79 &(rr->rrcBorderProperties) );
80
81 docInitBorderProperties( &(rr->rrcBorderProperties) );
82
83 return rval;
84 }
85
docRtfBrdrProperty(const RtfControlWord * rcw,int arg,RtfReader * rr)86 int docRtfBrdrProperty( const RtfControlWord * rcw,
87 int arg,
88 RtfReader * rr )
89 {
90 if ( docSetBorderProperty( &(rr->rrcBorderProperties),
91 rcw->rcwID, arg ) < 0 )
92 { SLLDEB(rcw->rcwWord,rcw->rcwID,arg); return -1; }
93
94 return 0;
95 }
96
97