1 /************************************************************************/
2 /* */
3 /* Exchange between row properties and 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 "docRtfTags.h"
16
17 /************************************************************************/
18 /* */
19 /* Save row properties to RTF. */
20 /* */
21 /************************************************************************/
22
docRtfSaveRowProperties(RtfWriter * rw,const PropertyMask * rpSetMask,const RowProperties * rpSet,int col0,int col1)23 void docRtfSaveRowProperties( RtfWriter * rw,
24 const PropertyMask * rpSetMask,
25 const RowProperties * rpSet,
26 int col0,
27 int col1 )
28 {
29 const int anyway= 0;
30 FrameProperties fp;
31
32 const DocumentAttributeMap * const dam0= (const DocumentAttributeMap *)0;
33
34 if ( PROPmaskISSET( rpSetMask, RPpropROW_NUMBER ) )
35 { docRtfWriteArgTag( rw, "irow", rpSet->rpRowNumber ); }
36 if ( PROPmaskISSET( rpSetMask, RPpropROW_BAND_NUMBER ) )
37 { docRtfWriteArgTag( rw, "irowband", rpSet->rpRowBandNumber ); }
38 if ( PROPmaskISSET( rpSetMask, RPpropROW_STYLE ) )
39 { docRtfWriteArgTag( rw, "ts", rpSet->rpRowStyle ); }
40
41 if ( PROPmaskISSET( rpSetMask, RPpropRTOL ) )
42 {
43 docRtfWriteAltTag( rw, "rtlrow", "ltrrow", rpSet->rpRToL );
44 }
45
46 if ( PROPmaskISSET( rpSetMask, RPpropGAP_WIDTH ) )
47 { docRtfWriteArgTag( rw, "trgaph", rpSet->rpHalfGapWidthTwips ); }
48 if ( PROPmaskISSET( rpSetMask, RPpropLEFT_INDENT ) )
49 { docRtfWriteArgTag( rw, "trleft", rpSet->rpLeftIndentTwips ); }
50 if ( PROPmaskISSET( rpSetMask, RPpropHEIGHT ) )
51 { docRtfWriteArgTag( rw, "trrh", rpSet->rpHeightTwips ); }
52
53 if ( PROPmaskISSET( rpSetMask, RPpropIS_TABLE_HEADER ) )
54 { docRtfWriteFlagTag( rw, "trhdr", rpSet->rpIsTableHeader ); }
55 if ( PROPmaskISSET( rpSetMask, RPpropKEEP_ON_ONE_PAGE ) )
56 { docRtfWriteFlagTag( rw, "trkeep", rpSet->rpKeepOnOnePage ); }
57 if ( PROPmaskISSET( rpSetMask, RPprop_KEEPFOLLOW ) )
58 { docRtfWriteFlagTag( rw, "trkeepfollow", rpSet->rp_Keepfollow ); }
59 if ( PROPmaskISSET( rpSetMask, RPpropAUTOFIT ) )
60 { docRtfWriteArgTag( rw, "trautofit", rpSet->rpAutofit ); }
61
62 docRtfWriteNextLine( rw );
63
64 if ( PROPmaskISSET( rpSetMask, RPpropTOP_BORDER ) )
65 {
66 docRtfSaveBorderByNumber( rw, "trbrdrt",
67 rpSet->rpTopBorderNumber, anyway );
68 }
69 if ( PROPmaskISSET( rpSetMask, RPpropLEFT_BORDER ) )
70 {
71 docRtfSaveBorderByNumber( rw, "trbrdrl",
72 rpSet->rpLeftBorderNumber, anyway );
73 }
74 if ( PROPmaskISSET( rpSetMask, RPpropRIGHT_BORDER ) )
75 {
76 docRtfSaveBorderByNumber( rw, "trbrdrr",
77 rpSet->rpRightBorderNumber, anyway );
78 }
79 if ( PROPmaskISSET( rpSetMask, RPpropBOTTOM_BORDER ) )
80 {
81 docRtfSaveBorderByNumber( rw, "trbrdrb",
82 rpSet->rpBottomBorderNumber, anyway );
83 }
84 if ( PROPmaskISSET( rpSetMask, RPpropVERT_BORDER ) )
85 {
86 docRtfSaveBorderByNumber( rw, "trbrdrv",
87 rpSet->rpVerticalBorderNumber, anyway );
88 }
89 if ( PROPmaskISSET( rpSetMask, RPpropHORIZ_BORDER ) )
90 {
91 docRtfSaveBorderByNumber( rw, "trbrdrh",
92 rpSet->rpHorizontalBorderNumber, anyway );
93 }
94
95 /**/
96 if ( PROPmaskISSET( rpSetMask, RPpropSHADING ) )
97 {
98 docRtfSaveShadingByNumber( rw, rpSet->rpShadingNumber,
99 DOCrtf_RowShadingTags, DOCrtf_RowShadingTagCount,
100 "trcfpat", "trcbpat", "trshdng" );
101 }
102
103 /**/
104 if ( PROPmaskISSET( rpSetMask, RPpropFRAME ) )
105 {
106 docGetFramePropertiesByNumber( &fp,
107 rw->rwDocument, rpSet->rpFrameNumber );
108 if ( DOCisFRAME( &fp ) )
109 { docRtfSaveRowFrameProperties( rw, &fp ); }
110 }
111
112 /**/
113 if ( PROPmaskISSET( rpSetMask, RPpropTRFTS_WIDTH ) ||
114 PROPmaskISSET( rpSetMask, RPpropTRW_WIDTH ) )
115 {
116 docRtfSaveAutoSpace( rw,
117 "trftsWidth", rpSet->rpPreferredWidthUnit,
118 "trwWidth", rpSet->rpPreferredWidth );
119 }
120
121 /**/
122 if ( PROPmaskISSET( rpSetMask, RPpropTRSPDFL ) ||
123 PROPmaskISSET( rpSetMask, RPpropTRSPDL ) )
124 {
125 docRtfSaveAutoSpace( rw,
126 "trspdfl", rpSet->rpLeftDefaultCellSpacingUnit,
127 "trspdl", rpSet->rpLeftDefaultCellSpacing );
128 }
129
130 if ( PROPmaskISSET( rpSetMask, RPpropTRSPDFR ) ||
131 PROPmaskISSET( rpSetMask, RPpropTRSPDR ) )
132 {
133 docRtfSaveAutoSpace( rw,
134 "trspdfr", rpSet->rpRightDefaultCellSpacingUnit,
135 "trspdr", rpSet->rpRightDefaultCellSpacing );
136 }
137
138 if ( PROPmaskISSET( rpSetMask, RPpropTRSPDFT ) ||
139 PROPmaskISSET( rpSetMask, RPpropTRSPDT ) )
140 {
141 docRtfSaveAutoSpace( rw,
142 "trspdft", rpSet->rpTopDefaultCellSpacingUnit,
143 "trspdt", rpSet->rpTopDefaultCellSpacing );
144 }
145
146 if ( PROPmaskISSET( rpSetMask, RPpropTRSPDFB ) ||
147 PROPmaskISSET( rpSetMask, RPpropTRSPDB ) )
148 {
149 docRtfSaveAutoSpace( rw,
150 "trspdfb", rpSet->rpBottomDefaultCellSpacingUnit,
151 "trspdb", rpSet->rpBottomDefaultCellSpacing );
152 }
153
154 /**/
155 if ( PROPmaskISSET( rpSetMask, RPpropTRPADDFL ) ||
156 PROPmaskISSET( rpSetMask, RPpropTRPADDL ) )
157 {
158 docRtfSaveAutoSpace( rw,
159 "trpaddfl", rpSet->rpLeftCellPaddingUnit,
160 "trpaddl", rpSet->rpLeftCellPadding );
161 }
162
163 if ( PROPmaskISSET( rpSetMask, RPpropTRPADDFR ) ||
164 PROPmaskISSET( rpSetMask, RPpropTRPADDR ) )
165 {
166 docRtfSaveAutoSpace( rw,
167 "trpaddfr", rpSet->rpRightCellPaddingUnit,
168 "trpaddr", rpSet->rpRightCellPadding );
169 }
170
171 if ( PROPmaskISSET( rpSetMask, RPpropTRPADDFT ) ||
172 PROPmaskISSET( rpSetMask, RPpropTRPADDT ) )
173 {
174 docRtfSaveAutoSpace( rw,
175 "trpaddft", rpSet->rpTopCellPaddingUnit,
176 "trpaddt", rpSet->rpTopCellPadding );
177 }
178
179 if ( PROPmaskISSET( rpSetMask, RPpropTRPADDFB ) ||
180 PROPmaskISSET( rpSetMask, RPpropTRPADDB ) )
181 {
182 docRtfSaveAutoSpace( rw,
183 "trpaddfb", rpSet->rpBottomCellPaddingUnit,
184 "trpaddb", rpSet->rpBottomCellPadding );
185 }
186
187 /**/
188 if ( PROPmaskISSET( rpSetMask, RPpropTRFTS_WIDTHB ) ||
189 PROPmaskISSET( rpSetMask, RPpropTRW_WIDTHB ) )
190 {
191 docRtfSaveAutoSpace( rw,
192 "trftsWidthB", rpSet->rpCellWidthBeforeUnit,
193 "trwWidthB", rpSet->rpCellWidthBefore );
194 }
195
196 if ( PROPmaskISSET( rpSetMask, RPpropTRFTS_WIDTHA ) ||
197 PROPmaskISSET( rpSetMask, RPpropTRW_WIDTHA ) )
198 {
199 docRtfSaveAutoSpace( rw,
200 "trftsWidthA", rpSet->rpCellWidthAfterUnit,
201 "trwWidthA", rpSet->rpCellWidthAfter );
202 }
203
204 /**/
205 if ( PROPmaskISSET( rpSetMask, RPpropCELL_LAYOUT ) ||
206 PROPmaskISSET( rpSetMask, RPpropCELL_PROPS ) )
207 {
208 int shiftLeft= 0;
209 PropertyMask cpAllMask;
210 const CellProperties * cp= rpSet->rpCells;
211 int col;
212 CellProperties cpRef;
213
214 docInitCellProperties( &cpRef );
215
216 docRowMaskToCellMask( &cpAllMask, rpSetMask );
217 if ( rw->rwCpExtraMask )
218 { utilPropMaskOr( &cpAllMask, &cpAllMask, rw->rwCpExtraMask ); }
219
220 if ( col0 > 0 )
221 {
222 shiftLeft= docColumnLeft( rpSet, col0 )- docColumnLeft( rpSet, 0 );
223 }
224
225 for ( col= 0; col < rpSet->rpCellCount; cp++, col++ )
226 {
227 if ( ( col0 < 0 || col >= col0 ) &&
228 ( col1 < 0 || col <= col1 ) )
229 {
230 PropertyMask cpSetMask;
231
232 utilPropMaskClear( &cpSetMask );
233
234 docCellPropertyDifference( &cpSetMask, &cpRef, &cpAllMask,
235 cp, dam0 );
236
237 docRtfSaveCellProperties( rw, &cpSetMask, cp, shiftLeft );
238 }
239 }
240
241 docCleanCellProperties( &cpRef );
242 }
243
244 return;
245 }
246
247