32TQDomElement Tabulator::createElement(Data &data)
const
34 TQDomElement element = data.createElement(
"TABULATOR");
35 element.setAttribute(
"type", alignment);
36 element.setAttribute(
"ptpos", pos);
37 element.setAttribute(
"filling", filling);
38 if ( alignment==Character )
39 element.setAttribute(
"alignchar", TQString(alignmentChar));
45 : type(
Body), firstIndent(0), leftIndent(0), align(AlignLeft)
48Paragraph::Paragraph(TextLine *first, uint nbLines)
49 : type(
Body), firstIndent(0), leftIndent(0), align(AlignLeft)
52 TextLine *line = first;
53 for (uint i=0; i<nbLines; i++) {
60 TQValueList<TextLine *>::const_iterator it;
61 for (it = _lines.begin(); it!=_lines.end(); ++it)
62 for (TextBlock *block = (*it)->blocks; block; block = block->next) {
63 DRect br(block->xMin, block->xMax, block->yMin, block->yMax);
68int Paragraph::findTab(
double xMin,
const TextLine *line)
const
70 double epsilon = 0.1 * (line->yMax - line->yMin);
71 double dx = xMin - (isFirst(line) ? firstIndent : leftIndent);
72 if ( fabs(dx)<epsilon )
return -2;
73 for (uint i=0; i<tabs.size(); i++)
74 if ( fabs(xMin-tabs[i].pos)<epsilon )
return i;
78uint Paragraph::findNbTabs(uint i,
double prevXMax)
const
81 for (; k<tabs.size(); k++)
82 if ( tabs[k].pos>prevXMax )
break;
87int Paragraph::charFromEnd(uint dec, uint &bi)
const
90 for (uint i=blocks.size(); i>0; i--) {
91 for (uint j=blocks[i-1].text.length(); j>0; j--) {
103String::String(GfxState *state,
double x0,
double y0,
104 double fontSize, uint frameIndex)
105 : TextString(state, x0, y0, fontSize), link(0), _frameIndex(frameIndex)
107 _font = Font(state, fontSize);
110void String::addChar(GfxState *state,
double x,
double y,
111 double dx,
double dy, Unicode u)
113 Unicode res[MaxLigatureLength];
114 uint nb = checkLigature(u, res);
116 if ( nb>1 ) sdebug =
"found ligature ";
117 double ddx = dx / nb;
118 for (uint i=0; i<nb; i++) {
119 TextString::addChar(state, x + ddx*i, y, ddx, dy, res[i]);
120 if ( nb>1 ) sdebug += TQChar(res[i]);
122 if ( nb>1 ) kdDebug(30516) << sdebug << endl;
123 else checkCombination(
this);
126bool String::checkCombination(TextString *str)
128 if ( len<1 || str->len<1 )
return false;
129 if ( str==
this && len<2 )
return false;
136 CharData letter, accent;
137 letter.i = (str==
this ? len-1 : 0);
138 letter.u = str->text[letter.i];
139 accent.i = (str==
this ? len-2 : len-1);
140 accent.u = text[accent.i];
141 Unicode res = checkCombi(letter.u, accent.u);
142 if ( res==0 )
return false;
144 letter.r.setLeft(letter.i==0 ? str->xMin : str->xRight[letter.i-1]);
145 letter.r.setRight(str->xRight[letter.i]);
146 letter.r.setTop(str->yMin);
147 letter.r.setBottom(str->yMax);
148 accent.r.setLeft(accent.i==0 ? xMin : xRight[accent.i-1]);
149 accent.r.setRight(xRight[accent.i]);
150 accent.r.setTop(yMin);
151 accent.r.setBottom(yMax);
152 bool ok = ( more(accent.r.left(), letter.r.left(), 0.005)
153 && less(accent.r.right(), letter.r.right(), 0.005) );
162 if ( !ok )
return false;
174 text[accent.i] = res;
175 xMax = letter.r.right();
176 if ( accent.i==0 ) xMin = letter.r.left();
177 else xRight[accent.i-1] = letter.r.left();
178 yMin = kMin(yMin, str->yMin);
179 yMax = kMax(yMax, str->yMax);
184 for (
int k=letter.i+1; k<str->len; k++) {
185 xRight[k-1] = xRight[k];
189 for (
int k=letter.i+1; k<str->len; k++)
190 TextString::addChar(0, str->xRight[k-1], 0,
191 str->xRight[k] - str->xRight[k-1], 0,