1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
/************************************************************************/
/* */
/* Exchange text properties with an RTF file. */
/* */
/************************************************************************/
# include "tedConfig.h"
# include <stdlib.h>
# include <string.h>
# include <stdio.h>
# include <ctype.h>
# include <appDebugon.h>
# include "docRtf.h"
/************************************************************************/
/* */
/* Save a text attribute (change). */
/* */
/************************************************************************/
void docRtfSaveTextAttribute( SimpleOutputStream * sos,
int * pCol,
const PropertyMask * updMask,
const TextAttribute * ta )
{
if ( PROPmaskISSET( updMask, TApropFONTFAMILY ) )
{ docRtfWriteArgTag( "\\f", pCol, ta->taFontNumber, sos ); }
if ( PROPmaskISSET( updMask, TApropFONTSIZE ) )
{ docRtfWriteArgTag( "\\fs", pCol, ta->taFontSizeHalfPoints, sos ); }
if ( PROPmaskISSET( updMask, TApropFONTBOLD ) )
{
if ( ta->taFontIsBold )
{ docRtfWriteTag( "\\b", pCol, sos ); }
else{ docRtfWriteArgTag( "\\b", pCol, ta->taFontIsBold, sos ); }
}
if ( PROPmaskISSET( updMask, TApropFONTSLANTED ) )
{
if ( ta->taFontIsSlanted )
{ docRtfWriteTag( "\\i", pCol, sos ); }
else{ docRtfWriteArgTag( "\\i", pCol, ta->taFontIsSlanted, sos ); }
}
if ( PROPmaskISSET( updMask, TApropTEXTUNDERLINED ) )
{
if ( ta->taIsUnderlined )
{ docRtfWriteTag( "\\ul", pCol, sos ); }
else{ docRtfWriteArgTag( "\\ul", pCol, ta->taIsUnderlined, sos ); }
}
if ( PROPmaskISSET( updMask, TApropSUPERSUB ) )
{
switch( ta->taSuperSub )
{
case DOCfontREGULAR:
docRtfWriteTag( "\\nosupersub", pCol, sos );
break;
case DOCfontSUPERSCRIPT:
docRtfWriteTag( "\\super", pCol, sos );
break;
case DOCfontSUBSCRIPT:
docRtfWriteTag( "\\sub", pCol, sos );
break;
default:
LDEB(ta->taSuperSub);
}
}
if ( PROPmaskISSET( updMask, TApropSMALLCAPS ) )
{
if ( ta->taSmallCaps )
{ docRtfWriteTag( "\\scaps", pCol, sos ); }
else{ docRtfWriteArgTag( "\\scaps", pCol, ta->taSmallCaps, sos ); }
}
if ( PROPmaskISSET( updMask, TApropCAPITALS ) )
{
if ( ta->taCapitals )
{ docRtfWriteTag( "\\caps", pCol, sos ); }
else{ docRtfWriteArgTag( "\\caps", pCol, ta->taCapitals, sos ); }
}
if ( PROPmaskISSET( updMask, TApropSTRIKETHROUGH ) )
{
if ( ta->taHasStrikeThrough )
{ docRtfWriteTag( "\\strike", pCol, sos ); }
else{
docRtfWriteArgTag( "\\strike", pCol, ta->taHasStrikeThrough, sos );
}
}
return;
}
/************************************************************************/
/* */
/* Handle a text property when reading RTF. */
/* */
/************************************************************************/
int docRtfRememberTextProperty( SimpleInputStream * sis,
const RtfControlWord * rcw,
int arg,
RtfReadingContext * rrc )
{
switch( rcw->rcwId )
{
case TAprop_NONE:
docInitTextAttribute( &(rrc->rrcCurrentTextAttribute) );
if ( rrc->rrcBd )
{
rrc->rrcCurrentTextAttribute.taFontNumber=
rrc->rrcBd->bdProperties.dpDefaultFont;
}
rrc->rrcCurrentTextAttribute.taFontSizeHalfPoints= 24;
rrc->rrcInDeletedText= 0;
return 0;
case TApropFONTFAMILY:
rrc->rrcCurrentTextAttribute.taFontNumber= arg;
break;
case TApropFONTSIZE:
rrc->rrcCurrentTextAttribute.taFontSizeHalfPoints= arg;
break;
case TApropFONTBOLD:
rrc->rrcCurrentTextAttribute.taFontIsBold= arg != 0;
break;
case TApropFONTSLANTED:
rrc->rrcCurrentTextAttribute.taFontIsSlanted= arg != 0;
break;
case TApropTEXTUNDERLINED:
rrc->rrcCurrentTextAttribute.taIsUnderlined= arg != 0;
break;
case TApropSHOWASLINK:
SDEB(rcw->rcwWord);
return 0;
case TApropSUPERSUB:
rrc->rrcCurrentTextAttribute.taSuperSub= rcw->rcwEnumValue;
break;
case TApropSMALLCAPS:
rrc->rrcCurrentTextAttribute.taSmallCaps= arg != 0;
break;
case TApropCAPITALS:
rrc->rrcCurrentTextAttribute.taCapitals= arg != 0;
break;
case TApropSTRIKETHROUGH:
rrc->rrcCurrentTextAttribute.taHasStrikeThrough= arg != 0;
break;
default:
SDEB(rcw->rcwWord);
return 0;
}
PROPmaskADD( &(rrc->rrcStyle.dsTextMask), rcw->rcwId );
return 0;
}
|