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
|
/************************************************************************/
/* */
/* Change the font of stretches of text. */
/* */
/************************************************************************/
# include "tedConfig.h"
# include <stdlib.h>
# include <string.h>
# include <stdio.h>
# include <appDebugon.h>
# include <appUnit.h>
# include "docBuf.h"
# include "docEdit.h"
/************************************************************************/
/* */
/* Change the TextAttributes E.G. the font of a stretch of text */
/* particules. */
/* */
/************************************************************************/
int docChangeParticuleAttributes( PropertyMask * pTaAllMask,
BufferDocument * bd,
BufferItem * bi,
int part,
int partUpto,
const TextAttribute * taSet,
const PropertyMask * taSetMask )
{
TextParticule * tp;
int i;
tp= bi->biParaParticules+ part;
for ( i= part; i < partUpto; tp++, i++ )
{
TextAttribute ta;
int attributeNumber= tp->tpTextAttributeNumber;
PropertyMask doneMask;
PROPmaskCLEAR( &doneMask );
utilGetTextAttributeByNumber( &ta, &(bd->bdTextAttributeList),
tp->tpTextAttributeNumber );
utilUpdateTextAttribute( &doneMask, &ta, taSet, taSetMask );
if ( ! PROPmaskISEMPTY( &doneMask ) ||
attributeNumber < 0 )
{
if ( pTaAllMask )
{ utilPropMaskOr( pTaAllMask, pTaAllMask, &doneMask ); }
attributeNumber= utilTextAttributeNumber(
&(bd->bdTextAttributeList), &ta );
if ( attributeNumber < 0 )
{ LDEB(attributeNumber); return -1; }
tp->tpTextAttributeNumber= attributeNumber;
}
}
return 0;
}
/************************************************************************/
/* */
/* Map text attribute numbers from one document to another document. */
/* */
/************************************************************************/
int docMapTextAttributeNumber( DocumentCopyJob * dcj,
int attributeNumberFrom )
{
TextAttribute taTo;
TextAttribute taFrom;
int attributeNumberTo;
if ( dcj->dcjBdTo == dcj->dcjBdFrom )
{ return attributeNumberFrom; }
if ( attributeNumberFrom == dcj->dcjCurrentTextAttributeNumberFrom )
{ return dcj->dcjCurrentTextAttributeNumberTo; }
utilGetTextAttributeByNumber( &taFrom,
&(dcj->dcjBdFrom->bdTextAttributeList),
attributeNumberFrom );
taTo= taFrom;
if ( dcj->dcjBdTo != dcj->dcjBdFrom )
{
DocumentProperties * dpTo= &(dcj->dcjBdTo->bdProperties);
DocumentFontList * dflTo= &(dpTo->dpFontList);
taTo.taFontNumber= dcj->dcjFontMap[taFrom.taFontNumber];
if ( taTo.taFontNumber >= 0 &&
taTo.taFontNumber < dflTo->dflFontCount )
{ dflTo->dflFonts[taTo.taFontNumber].dfUsed= 1; }
if ( taFrom.taTextColorNumber > 0 )
{
taTo.taTextColorNumber= dcj->dcjColorMap[taFrom.taTextColorNumber];
}
}
attributeNumberTo= utilTextAttributeNumber(
&(dcj->dcjBdTo->bdTextAttributeList), &taTo );
if ( attributeNumberTo < 0 )
{ LDEB(attributeNumberTo); }
dcj->dcjCurrentTextAttributeNumberFrom= attributeNumberFrom;
dcj->dcjCurrentTextAttributeNumberTo= attributeNumberTo;
return attributeNumberTo;
}
|