1 /************************************************************************/
2 /*									*/
3 /*  Save a BufferDocument into an RTF file.				*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"docRtfConfig.h"
8 
9 #   include	<stdio.h>
10 #   include	<ctype.h>
11 
12 #   include	<appDebugon.h>
13 
14 #   include	<docObjectProperties.h>
15 #   include	<geoUnits.h>
16 #   include	"docRtfWriterImpl.h"
17 
18 /************************************************************************/
19 /*									*/
20 /*  Write the tags that describe the geometry of a picture object.	*/
21 /*									*/
22 /************************************************************************/
23 
docRtfSavePictureTags(RtfWriter * rwc,const PropertyMask * pipSetMask,const PictureProperties * pipSet)24 int docRtfSavePictureTags(	RtfWriter *			rwc,
25 				const PropertyMask *		pipSetMask,
26 				const PictureProperties *	pipSet )
27     {
28     if  ( PROPmaskISSET( pipSetMask, PIPpropTYPE ) )
29 	{
30 	switch( pipSet->pipType )
31 	    {
32 	    case DOCokPICTWMETAFILE:
33 		docRtfWriteArgTag( rwc, "wmetafile", pipSet->pipMapMode );
34 
35 		if  ( pipSet->pipMetafileIsBitmap )
36 		    {
37 		    if  ( pipSet->pipMetafileBitmapBpp > 0 )
38 			{
39 			docRtfWriteArgTag( rwc, "picbpp",
40 					    pipSet->pipMetafileBitmapBpp );
41 			}
42 		    }
43 		break;
44 
45 	    case DOCokMACPICT:
46 		docRtfWriteTag( rwc, "macpict" );
47 		break;
48 	    case DOCokPICTPNGBLIP:
49 		docRtfWriteTag( rwc, "pngblip" );
50 		break;
51 	    case DOCokPICTJPEGBLIP:
52 		docRtfWriteTag( rwc, "jpegblip" );
53 		break;
54 	    case DOCokPICTEMFBLIP:
55 		docRtfWriteTag( rwc, "emfblip" );
56 		break;
57 	    case DOCokDIBITMAP:
58 		docRtfWriteTag( rwc, "dibitmap" );
59 		break;
60 	    case DOCokWBITMAP:
61 		docRtfWriteTag( rwc, "wbitmap" );
62 		break;
63 	    case DOCokPMMETAFILE:
64 		docRtfWriteTag( rwc, "pmmetafile" );
65 		break;
66 
67 	    default:
68 		LDEB(pipSet->pipType);
69 		break;
70 	    }
71 	}
72 
73     if  ( PROPmaskISSET( pipSetMask, PIPpropPICX_WIN_EXT ) )
74 	{
75 	int	xExt= pipSet->pip_xWinExt;
76 
77 	if  ( xExt == 0 )
78 	    {
79 	    xExt= (int)( 100000.0* pipSet->pipTwipsWide )/
80 						    ( 20* POINTS_PER_M );
81 	    }
82 
83 	docRtfWriteArgTag( rwc, "picw", xExt );
84 	}
85 
86     if  ( PROPmaskISSET( pipSetMask, PIPpropPICY_WIN_EXT ) )
87 	{
88 	int	yExt= pipSet->pip_yWinExt;
89 
90 	if  ( yExt == 0 )
91 	    {
92 	    yExt= (int)( 100000.0* pipSet->pipTwipsHigh )/
93 						    ( 20* POINTS_PER_M );
94 	    }
95 
96 	docRtfWriteArgTag( rwc, "pich", yExt );
97 	}
98 
99     if  ( PROPmaskISSET( pipSetMask, PIPpropPICSCALE_X ) )
100 	{ docRtfWriteArgTag( rwc, "picscalex", pipSet->pipScaleXSet ); }
101     if  ( PROPmaskISSET( pipSetMask, PIPpropPICSCALE_Y ) )
102 	{ docRtfWriteArgTag( rwc, "picscaley", pipSet->pipScaleYSet ); }
103 
104     if  ( PROPmaskISSET( pipSetMask, PIPpropPICTWIPS_WIDE ) )
105 	{ docRtfWriteArgTag( rwc, "picwgoal", pipSet->pipTwipsWide );	}
106     if  ( PROPmaskISSET( pipSetMask, PIPpropPICTWIPS_HIGH ) )
107 	{ docRtfWriteArgTag( rwc, "pichgoal", pipSet->pipTwipsHigh );	}
108 
109     if  ( PROPmaskISSET( pipSetMask, PIPpropPICCROP_TOP ) )
110 	{ docRtfWriteArgTag( rwc, "piccropt", pipSet->pipTopCropTwips ); }
111     if  ( PROPmaskISSET( pipSetMask, PIPpropPICCROP_BOTTOM ) )
112 	{ docRtfWriteArgTag( rwc, "piccropb", pipSet->pipBottomCropTwips ); }
113     if  ( PROPmaskISSET( pipSetMask, PIPpropPICCROP_LEFT ) )
114 	{ docRtfWriteArgTag( rwc, "piccropl", pipSet->pipLeftCropTwips ); }
115     if  ( PROPmaskISSET( pipSetMask, PIPpropPICCROP_RIGHT ) )
116 	{ docRtfWriteArgTag( rwc, "piccropr", pipSet->pipRightCropTwips ); }
117 
118     if  ( PROPmaskISSET( pipSetMask, PIPpropBLIPTAG ) )
119 	{ docRtfWriteArgTag( rwc, "bliptag", pipSet->pipBliptag ); }
120 
121     if  ( PROPmaskISSET( pipSetMask, PIPpropWBMBITSPIXEL ) )
122 	{ docRtfWriteArgTag( rwc, "wbmbitspixel", pipSet->pipBmBitsPerPixel ); }
123     if  ( PROPmaskISSET( pipSetMask, PIPpropWBMPLANES ) )
124 	{ docRtfWriteArgTag( rwc, "wbmplanes", pipSet->pipBmPlanes );	}
125     if  ( PROPmaskISSET( pipSetMask, PIPpropWBMWIDTHBYTES ) )
126 	{ docRtfWriteArgTag( rwc, "wbmwidthbytes", pipSet->pipBmBytesPerRow ); }
127 
128     if  ( PROPmaskISSET( pipSetMask, PIPpropDEFSHP ) )
129 	{ docRtfWriteFlagTag( rwc, "defshp", pipSet->pipPictureIsWordArt ); }
130     if  ( PROPmaskISSET( pipSetMask, PIPpropPICSCALED ) )
131 	{ docRtfWriteFlagTag( rwc, "picscaled", pipSet->pipPictIsScaled ); }
132     if  ( PROPmaskISSET( pipSetMask, PIPpropPICBMP ) )
133 	{ docRtfWriteFlagTag( rwc, "picbmp", pipSet->pipMetafileIsBitmap ); }
134 
135     if  ( PROPmaskISSET( pipSetMask, PIPpropBLIPUPI ) )
136 	{ docRtfWriteArgTag( rwc, "blipupi", pipSet->pipBmUnitsPerInch ); }
137 
138     return 0;
139     }
140 
docRtfPicturePropertyMask(PropertyMask * pipSetMask,const PictureProperties * pipSet)141 int docRtfPicturePropertyMask(	PropertyMask *			pipSetMask,
142 				const PictureProperties *	pipSet )
143     {
144     int			rval= 0;
145     PictureProperties	pipDef;
146     PropertyMask	pipAllMask;
147 
148     utilPropMaskClear( pipSetMask );
149     utilPropMaskClear( &pipAllMask );
150     utilPropMaskFill( &pipAllMask, PIPprop_COUNT );
151 
152     docInitPictureProperties( &pipDef );
153 
154     if  ( docUpdPictureProperties( pipSetMask, &pipDef, &pipAllMask, pipSet ) )
155 	{ LDEB(1); rval= -1; goto ready;	}
156 
157   ready:
158 
159     /*docCleanPictureProperties( &pipDef );*/
160 
161     return rval;
162     }
163 
164