1 /************************************************************************/
2 /* */
3 /* Read/Write paragraph 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 <docParaRulerAdmin.h>
16 # include "docRtfTags.h"
17
18 /************************************************************************/
19
docRtfSaveParaTableNesting(RtfWriter * rw,int nest)20 void docRtfSaveParaTableNesting( RtfWriter * rw,
21 int nest )
22 {
23 if ( rw->rwDeepestTableNesting < nest )
24 { rw->rwDeepestTableNesting= nest; }
25
26 if ( rw->rwDeepestTableNesting > 1 )
27 {
28 switch( nest )
29 {
30 case 0:
31 docRtfWriteArgTag( rw, "itap", nest );
32 break;
33 case 1:
34 default:
35 docRtfWriteArgTag( rw, "intbl\\itap", nest );
36 break;
37 }
38 }
39 else{
40 switch( nest )
41 {
42 case 0:
43 docRtfWriteArgTag( rw, "intbl", nest );
44 break;
45 case 1:
46 docRtfWriteTag( rw, "intbl" );
47 break;
48 default:
49 LLDEB(rw->rwDeepestTableNesting,nest);
50 docRtfWriteArgTag( rw, "intbl\\itap", nest );
51 break;
52 }
53 }
54
55 return;
56 }
57
58 /************************************************************************/
59 /* */
60 /* Save Paragraph Properties. */
61 /* */
62 /************************************************************************/
63
docRtfSaveParagraphProperties(RtfWriter * rw,const PropertyMask * updMask,const ParagraphProperties * pp)64 void docRtfSaveParagraphProperties(
65 RtfWriter * rw,
66 const PropertyMask * updMask,
67 const ParagraphProperties * pp )
68 {
69 const int anyway= 1;
70
71 if ( PROPmaskISSET( updMask, PPpropSTYLE ) )
72 { docRtfWriteArgTag( rw, "s", pp->ppStyle ); }
73
74 if ( PROPmaskISSET( updMask, PPpropLISTOVERRIDE ) )
75 { docRtfWriteArgTag( rw, "ls", pp->ppListOverride ); }
76 if ( PROPmaskISSET( updMask, PPpropLISTLEVEL ) )
77 { docRtfWriteArgTag( rw, "ilvl", pp->ppListLevel ); }
78
79 if ( PROPmaskISSET( updMask, PPpropTABLE_NESTING ) )
80 { docRtfSaveParaTableNesting( rw, pp->ppTableNesting ); }
81
82 if ( PROPmaskISSET( updMask, PPpropHYPHPAR ) )
83 { docRtfWriteFlagTag( rw, "hyphpar", pp->ppHyphenateParagraph ); }
84
85 if ( PROPmaskISSET( updMask, PPpropWIDCTLPAR ) )
86 {
87 docRtfWriteAltTag( rw, "widctlpar", "nowidctlpar", pp->ppWidowControl );
88 }
89
90 if ( PROPmaskISSET( updMask, PPpropRTOL ) )
91 {
92 docRtfWriteAltTag( rw, "rtlpar", "ltrpar", pp->ppRToL );
93 }
94
95 if ( PROPmaskISSET( updMask, PPpropKEEP ) )
96 { docRtfWriteFlagTag( rw, "keep", pp->ppKeepOnPage ); }
97
98 if ( PROPmaskISSET( updMask, PPpropKEEPN ) )
99 { docRtfWriteFlagTag( rw, "keepn", pp->ppKeepWithNext ); }
100
101 if ( PROPmaskISSET( updMask, PPpropOUTLINELEVEL ) )
102 { docRtfWriteArgTag( rw, "outlinelevel", pp->ppOutlineLevel ); }
103
104 if ( PROPmaskISSET( updMask, PPpropFIRST_INDENT ) )
105 { docRtfWriteArgTag( rw, "fi", pp->ppFirstIndentTwips ); }
106
107 if ( PROPmaskISSET( updMask, PPpropLEFT_INDENT ) )
108 { docRtfWriteArgTag( rw, "li", pp->ppLeftIndentTwips ); }
109
110 if ( PROPmaskISSET( updMask, PPpropRIGHT_INDENT ) )
111 { docRtfWriteArgTag( rw, "ri", pp->ppRightIndentTwips ); }
112
113 if ( PROPmaskISSET( updMask, PPpropSPACE_BEFORE ) )
114 { docRtfWriteArgTag( rw, "sb", pp->ppSpaceBeforeTwips ); }
115
116 if ( PROPmaskISSET( updMask, PPpropSPACE_AFTER ) )
117 { docRtfWriteArgTag( rw, "sa", pp->ppSpaceAfterTwips ); }
118
119 if ( PROPmaskISSET( updMask, PPpropLINE_SPACING_DIST ) ||
120 PROPmaskISSET( updMask, PPpropLINE_SPACING_MULT ) )
121 {
122 docRtfWriteArgTag( rw, "sl", pp->ppLineSpacingTwips );
123 docRtfWriteArgTag( rw, "slmult", pp->ppLineSpacingIsMultiple );
124 }
125
126 if ( PROPmaskISSET( updMask, PPpropALIGNMENT ) )
127 {
128 docRtfWriteEnumTag( rw, DOCrtf_ParaAlignTags,
129 pp->ppAlignment,
130 DOCrtf_ParaAlignTagCount, DOCtha_COUNT );
131 }
132
133 if ( PROPmaskISSET( updMask, PPpropTAB_STOPS ) &&
134 pp->ppTabStopListNumber >= 0 )
135 {
136 TabStopList tsl;
137
138 docGetTabStopListByNumber( &tsl, rw->rwDocument,
139 pp->ppTabStopListNumber );
140
141 docRtfSaveTabStopList( rw, &tsl );
142 }
143
144 if ( PROPmaskISSET( updMask, PPpropTOP_BORDER ) )
145 {
146 docRtfSaveBorderByNumber( rw, "brdrt",
147 pp->ppTopBorderNumber, anyway );
148 }
149
150 if ( PROPmaskISSET( updMask, PPpropBOTTOM_BORDER ) )
151 {
152 docRtfSaveBorderByNumber( rw, "brdrb",
153 pp->ppBottomBorderNumber, anyway );
154 }
155
156 if ( PROPmaskISSET( updMask, PPpropLEFT_BORDER ) )
157 {
158 docRtfSaveBorderByNumber( rw, "brdrl",
159 pp->ppLeftBorderNumber, anyway );
160 }
161
162 if ( PROPmaskISSET( updMask, PPpropRIGHT_BORDER ) )
163 {
164 docRtfSaveBorderByNumber( rw, "brdrr",
165 pp->ppRightBorderNumber, anyway );
166 }
167
168 if ( PROPmaskISSET( updMask, PPpropBETWEEN_BORDER ) )
169 {
170 docRtfSaveBorderByNumber( rw, "brdrbtw",
171 pp->ppBetweenBorderNumber, anyway );
172 }
173
174 if ( PROPmaskISSET( updMask, PPpropBAR_BORDER ) )
175 {
176 docRtfSaveBorderByNumber( rw, "brdrbar",
177 pp->ppBarNumber, anyway );
178 }
179
180 if ( PROPmaskISSET( updMask, PPpropFRAME ) )
181 {
182 FrameProperties fp;
183
184 docGetFramePropertiesByNumber( &fp, rw->rwDocument,
185 pp->ppFrameNumber );
186
187 if ( DOCisFRAME( &fp ) )
188 { docRtfSaveParaFrameProperties( rw, &fp ); }
189 }
190
191 if ( PROPmaskISSET( updMask, PPpropSHADING ) )
192 {
193 docRtfSaveShadingByNumber( rw, pp->ppShadingNumber,
194 DOCrtf_ParaShadingTags, DOCrtf_ParaShadingTagCount,
195 "cfpat", "cbpat", "shading" );
196 }
197
198 /* MUST be last, as DOCibkCOL results in a particule */
199 if ( PROPmaskISSET( updMask, PPpropBREAK_KIND ) )
200 {
201 docRtfWriteEnumTag( rw, DOCrtf_ParaBreakTags, pp->ppBreakKind,
202 DOCrtf_ParaBreakTagCount, DOCibkpara_COUNT );
203 }
204
205 return;
206 }
207
208