ReactOS 0.4.16-dev-981-g80eb313
writer.c
Go to the documentation of this file.
1/*
2 * RichEdit - RTF writer module
3 *
4 * Copyright 2005 by Phil Krylov
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define NONAMELESSUNION
22
23#include "editor.h"
24#include "rtf.h"
25
27
28#define STREAMOUT_BUFFER_SIZE 4096
29#define STREAMOUT_FONTTBL_SIZE 8192
30#define STREAMOUT_COLORTBL_SIZE 1024
31
32typedef struct tagME_OutStream
33{
44 /* nNestingLevel = 0 means we aren't in a cell, 1 means we are in a cell,
45 * an greater numbers mean we are in a cell nested within a cell. */
47 CHARFORMAT2W cur_fmt; /* current character format */
49
50static BOOL
51ME_StreamOutRTFText(ME_OutStream *pStream, const WCHAR *text, LONG nChars);
52
53
54static ME_OutStream*
56{
57 ME_OutStream *pStream = heap_alloc_zero(sizeof(*pStream));
58
59 pStream->stream = stream;
60 pStream->stream->dwError = 0;
61 pStream->nColorTblLen = 1;
64 return pStream;
65}
66
67
68static BOOL
70{
71 LONG nWritten = 0;
72 EDITSTREAM *stream = pStream->stream;
73
74 if (pStream->pos) {
75 TRACE("sending %u bytes\n", pStream->pos);
76 nWritten = pStream->pos;
77 stream->dwError = stream->pfnCallback(stream->dwCookie, (LPBYTE)pStream->buffer,
78 pStream->pos, &nWritten);
79 TRACE("error=%u written=%u\n", stream->dwError, nWritten);
80 if (nWritten == 0 || stream->dwError)
81 return FALSE;
82 /* Don't resend partial chunks if nWritten < pStream->pos */
83 }
84 if (nWritten == pStream->pos)
85 pStream->written += nWritten;
86 pStream->pos = 0;
87 return TRUE;
88}
89
90
91static LONG
93{
94 LONG written = pStream->written;
95 TRACE("total length = %u\n", written);
96
97 heap_free(pStream);
98 return written;
99}
100
101
102static BOOL
103ME_StreamOutMove(ME_OutStream *pStream, const char *buffer, int len)
104{
105 while (len) {
106 int space = STREAMOUT_BUFFER_SIZE - pStream->pos;
107 int fit = min(space, len);
108
109 TRACE("%u:%u:%s\n", pStream->pos, fit, debugstr_an(buffer,fit));
110 memmove(pStream->buffer + pStream->pos, buffer, fit);
111 len -= fit;
112 buffer += fit;
113 pStream->pos += fit;
114 if (pStream->pos == STREAMOUT_BUFFER_SIZE) {
115 if (!ME_StreamOutFlush(pStream))
116 return FALSE;
117 }
118 }
119 return TRUE;
120}
121
122
123static BOOL WINAPIV
124ME_StreamOutPrint(ME_OutStream *pStream, const char *format, ...)
125{
126 char string[STREAMOUT_BUFFER_SIZE]; /* This is going to be enough */
127 int len;
129
131 len = vsnprintf(string, sizeof(string), format, valist);
133
134 return ME_StreamOutMove(pStream, string, len);
135}
136
137#define HEX_BYTES_PER_LINE 40
138
139static BOOL
141{
142
143 char line[HEX_BYTES_PER_LINE * 2 + 1];
144 UINT size, i;
145 static const char hex[] = "0123456789abcdef";
146
147 while (len)
148 {
150 for (i = 0; i < size; i++)
151 {
152 line[i * 2] = hex[(*data >> 4) & 0xf];
153 line[i * 2 + 1] = hex[*data & 0xf];
154 data++;
155 }
156 line[size * 2] = '\n';
157 if (!ME_StreamOutMove( stream, line, size * 2 + 1 ))
158 return FALSE;
159 len -= size;
160 }
161 return TRUE;
162}
163
164static BOOL
165ME_StreamOutRTFHeader(ME_OutStream *pStream, int dwFormat)
166{
167 const char *cCharSet = NULL;
168 UINT nCodePage;
169 LANGID language;
171
172 if (dwFormat & SF_USECODEPAGE) {
174
175 switch (HIWORD(dwFormat)) {
176 case CP_ACP:
177 cCharSet = "ansi";
178 nCodePage = GetACP();
179 break;
180 case CP_OEMCP:
181 nCodePage = GetOEMCP();
182 if (nCodePage == 437)
183 cCharSet = "pc";
184 else if (nCodePage == 850)
185 cCharSet = "pca";
186 else
187 cCharSet = "ansi";
188 break;
189 case CP_UTF8:
190 nCodePage = CP_UTF8;
191 break;
192 default:
193 if (HIWORD(dwFormat) == CP_MACCP) {
194 cCharSet = "mac";
195 nCodePage = 10000; /* MacRoman */
196 } else {
197 cCharSet = "ansi";
198 nCodePage = 1252; /* Latin-1 */
199 }
200 if (GetCPInfoExW(HIWORD(dwFormat), 0, &info))
201 nCodePage = info.CodePage;
202 }
203 } else {
204 cCharSet = "ansi";
205 /* TODO: If the original document contained an \ansicpg value, retain it.
206 * Otherwise, M$ richedit emits a codepage number determined from the
207 * charset of the default font here. Anyway, this value is not used by
208 * the reader... */
209 nCodePage = GetACP();
210 }
211 if (nCodePage == CP_UTF8)
212 success = ME_StreamOutPrint(pStream, "{\\urtf");
213 else
214 success = ME_StreamOutPrint(pStream, "{\\rtf1\\%s\\ansicpg%u\\uc1", cCharSet, nCodePage);
215
216 if (!success)
217 return FALSE;
218
219 pStream->nDefaultCodePage = nCodePage;
220
221 /* FIXME: This should be a document property */
222 /* TODO: handle SFF_PLAINRTF */
223 language = GetUserDefaultLangID();
224 if (!ME_StreamOutPrint(pStream, "\\deff0\\deflang%u\\deflangfe%u", language, language))
225 return FALSE;
226
227 /* FIXME: This should be a document property */
228 pStream->nDefaultFont = 0;
229
230 return TRUE;
231}
232
234{
235 ME_FontTableItem *table = stream->fonttbl;
236 CHARFORMAT2W *fmt = &style->fmt;
237 WCHAR *face = fmt->szFaceName;
238 BYTE charset = (fmt->dwMask & CFM_CHARSET) ? fmt->bCharSet : DEFAULT_CHARSET;
239 int i;
240
241 if (fmt->dwMask & CFM_FACE)
242 {
243 for (i = 0; i < stream->nFontTblLen; i++)
244 if (table[i].bCharSet == charset
245 && (table[i].szFaceName == face || !wcscmp(table[i].szFaceName, face)))
246 break;
247
248 if (i == stream->nFontTblLen && i < STREAMOUT_FONTTBL_SIZE)
249 {
250 table[i].bCharSet = charset;
251 table[i].szFaceName = face;
252 stream->nFontTblLen++;
253 }
254 }
255}
256
258{
259 WCHAR *facename;
260 int i;
261
262 *idx = 0;
263 if (fmt->dwMask & CFM_FACE)
264 facename = fmt->szFaceName;
265 else
266 facename = stream->fonttbl[0].szFaceName;
267 for (i = 0; i < stream->nFontTblLen; i++)
268 {
269 if (facename == stream->fonttbl[i].szFaceName
270 || !wcscmp(facename, stream->fonttbl[i].szFaceName))
271 if (!(fmt->dwMask & CFM_CHARSET)
272 || fmt->bCharSet == stream->fonttbl[i].bCharSet)
273 {
274 *idx = i;
275 break;
276 }
277 }
278
279 return i < stream->nFontTblLen;
280}
281
283{
284 int i;
285
286 for (i = 1; i < stream->nColorTblLen; i++)
287 if (stream->colortbl[i] == color)
288 break;
289
290 if (i == stream->nColorTblLen && i < STREAMOUT_COLORTBL_SIZE)
291 {
292 stream->colortbl[i] = color;
293 stream->nColorTblLen++;
294 }
295}
296
298{
299 int i;
300
301 *idx = 0;
302 for (i = 1; i < stream->nColorTblLen; i++)
303 {
304 if (stream->colortbl[i] == color)
305 {
306 *idx = i;
307 break;
308 }
309 }
310
311 return i < stream->nFontTblLen;
312}
313
315{
316 ME_Run *run = first;
317 ME_FontTableItem *table = pStream->fonttbl;
318 unsigned int i;
319 ME_Cell *cell = NULL;
320 ME_Paragraph *prev_para = NULL;
321
322 do
323 {
324 CHARFORMAT2W *fmt = &run->style->fmt;
325
326 add_font_to_fonttbl( pStream, run->style );
327
328 if (fmt->dwMask & CFM_COLOR && !(fmt->dwEffects & CFE_AUTOCOLOR))
329 add_color_to_colortbl( pStream, fmt->crTextColor );
330 if (fmt->dwMask & CFM_BACKCOLOR && !(fmt->dwEffects & CFE_AUTOBACKCOLOR))
331 add_color_to_colortbl( pStream, fmt->crBackColor );
332
333 if (run->para != prev_para)
334 {
335 /* check for any para numbering text */
336 if (run->para->fmt.wNumbering)
337 add_font_to_fonttbl( pStream, run->para->para_num.style );
338
339 if ((cell = para_cell( run->para )))
340 {
341 ME_Border* borders[4] = { &cell->border.top, &cell->border.left,
342 &cell->border.bottom, &cell->border.right };
343 for (i = 0; i < 4; i++)
344 if (borders[i]->width > 0)
345 add_color_to_colortbl( pStream, borders[i]->colorRef );
346 }
347
348 prev_para = run->para;
349 }
350
351 if (run == last) break;
352 run = run_next_all_paras( run );
353 } while (run);
354
355 if (!ME_StreamOutPrint(pStream, "{\\fonttbl"))
356 return FALSE;
357
358 for (i = 0; i < pStream->nFontTblLen; i++) {
359 if (table[i].bCharSet != DEFAULT_CHARSET) {
360 if (!ME_StreamOutPrint(pStream, "{\\f%u\\fcharset%u ", i, table[i].bCharSet))
361 return FALSE;
362 } else {
363 if (!ME_StreamOutPrint(pStream, "{\\f%u ", i))
364 return FALSE;
365 }
366 if (!ME_StreamOutRTFText(pStream, table[i].szFaceName, -1))
367 return FALSE;
368 if (!ME_StreamOutPrint(pStream, ";}"))
369 return FALSE;
370 }
371 if (!ME_StreamOutPrint(pStream, "}\r\n"))
372 return FALSE;
373
374 /* Output the color table */
375 if (!ME_StreamOutPrint(pStream, "{\\colortbl;")) return FALSE; /* first entry is auto-color */
376 for (i = 1; i < pStream->nColorTblLen; i++)
377 {
378 if (!ME_StreamOutPrint(pStream, "\\red%u\\green%u\\blue%u;", pStream->colortbl[i] & 0xFF,
379 (pStream->colortbl[i] >> 8) & 0xFF, (pStream->colortbl[i] >> 16) & 0xFF))
380 return FALSE;
381 }
382 if (!ME_StreamOutPrint(pStream, "}\r\n")) return FALSE;
383
384 return TRUE;
385}
386
388 ME_Paragraph *para )
389{
390 ME_Cell *cell;
391 char props[STREAMOUT_BUFFER_SIZE] = "";
392 int i;
393 const char sideChar[4] = {'t','l','b','r'};
394
395 if (!ME_StreamOutPrint(pStream, "\\trowd"))
396 return FALSE;
397 if (!editor->bEmulateVersion10) /* v4.1 */
398 {
399 PARAFORMAT2 *pFmt = &table_row_end( para )->fmt;
400 cell = table_row_first_cell( para );
401 assert( cell );
402 if (pFmt->dxOffset)
403 sprintf(props + strlen(props), "\\trgaph%d", pFmt->dxOffset);
404 if (pFmt->dxStartIndent)
405 sprintf(props + strlen(props), "\\trleft%d", pFmt->dxStartIndent);
406 do
407 {
408 ME_Border* borders[4] = { &cell->border.top, &cell->border.left,
409 &cell->border.bottom, &cell->border.right };
410 for (i = 0; i < 4; i++)
411 {
412 if (borders[i]->width)
413 {
414 unsigned int idx;
415 COLORREF crColor = borders[i]->colorRef;
416 sprintf(props + strlen(props), "\\clbrdr%c", sideChar[i]);
417 sprintf(props + strlen(props), "\\brdrs");
418 sprintf(props + strlen(props), "\\brdrw%d", borders[i]->width);
419 if (find_color_in_colortbl( pStream, crColor, &idx ))
420 sprintf(props + strlen(props), "\\brdrcf%u", idx);
421 }
422 }
423 sprintf( props + strlen(props), "\\cellx%d", cell->nRightBoundary );
424 cell = cell_next( cell );
425 } while (cell_next( cell ));
426 }
427 else /* v1.0 - 3.0 */
428 {
429 const ME_Border* borders[4] = { &para->border.top,
430 &para->border.left,
431 &para->border.bottom,
432 &para->border.right };
433 PARAFORMAT2 *pFmt = &para->fmt;
434
435 assert( !(para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND | MEPF_CELL)) );
436 if (pFmt->dxOffset)
437 sprintf(props + strlen(props), "\\trgaph%d", pFmt->dxOffset);
438 if (pFmt->dxStartIndent)
439 sprintf(props + strlen(props), "\\trleft%d", pFmt->dxStartIndent);
440 for (i = 0; i < 4; i++)
441 {
442 if (borders[i]->width)
443 {
444 unsigned int idx;
445 COLORREF crColor = borders[i]->colorRef;
446 sprintf(props + strlen(props), "\\trbrdr%c", sideChar[i]);
447 sprintf(props + strlen(props), "\\brdrs");
448 sprintf(props + strlen(props), "\\brdrw%d", borders[i]->width);
449 if (find_color_in_colortbl( pStream, crColor, &idx ))
450 sprintf(props + strlen(props), "\\brdrcf%u", idx);
451 }
452 }
453 for (i = 0; i < pFmt->cTabCount; i++)
454 {
455 sprintf(props + strlen(props), "\\cellx%d", pFmt->rgxTabs[i] & 0x00FFFFFF);
456 }
457 }
458 if (!ME_StreamOutPrint(pStream, props))
459 return FALSE;
460 props[0] = '\0';
461 return TRUE;
462}
463
465{
466 static const char fmt_label[] = "{\\*\\pn\\pnlvlbody\\pnf%u\\pnindent%d\\pnstart%d%s%s}";
467 static const char fmt_bullet[] = "{\\*\\pn\\pnlvlblt\\pnf%u\\pnindent%d{\\pntxtb\\'b7}}";
468 static const char dec[] = "\\pndec";
469 static const char lcltr[] = "\\pnlcltr";
470 static const char ucltr[] = "\\pnucltr";
471 static const char lcrm[] = "\\pnlcrm";
472 static const char ucrm[] = "\\pnucrm";
473 static const char period[] = "{\\pntxta.}";
474 static const char paren[] = "{\\pntxta)}";
475 static const char parens[] = "{\\pntxtb(}{\\pntxta)}";
476 const char *type, *style = "";
477 unsigned int idx;
478
479 find_font_in_fonttbl( stream, &para->para_num.style->fmt, &idx );
480
481 if (!ME_StreamOutPrint( stream, "{\\pntext\\f%u ", idx )) return FALSE;
482 if (!ME_StreamOutRTFText( stream, para->para_num.text->szData, para->para_num.text->nLen ))
483 return FALSE;
484 if (!ME_StreamOutPrint( stream, "\\tab}" )) return FALSE;
485
486 if (!pn_dest) return TRUE;
487
488 if (para->fmt.wNumbering == PFN_BULLET)
489 {
490 if (!ME_StreamOutPrint( stream, fmt_bullet, idx, para->fmt.wNumberingTab ))
491 return FALSE;
492 }
493 else
494 {
495 switch (para->fmt.wNumbering)
496 {
497 case PFN_ARABIC:
498 default:
499 type = dec;
500 break;
501 case PFN_LCLETTER:
502 type = lcltr;
503 break;
504 case PFN_UCLETTER:
505 type = ucltr;
506 break;
507 case PFN_LCROMAN:
508 type = lcrm;
509 break;
510 case PFN_UCROMAN:
511 type = ucrm;
512 break;
513 }
514 switch (para->fmt.wNumberingStyle & 0xf00)
515 {
516 case PFNS_PERIOD:
517 style = period;
518 break;
519 case PFNS_PAREN:
520 style = paren;
521 break;
522 case PFNS_PARENS:
523 style = parens;
524 break;
525 }
526
527 if (!ME_StreamOutPrint( stream, fmt_label, idx, para->fmt.wNumberingTab,
528 para->fmt.wNumberingStart, type, style ))
529 return FALSE;
530 }
531 return TRUE;
532}
533
535 ME_Paragraph *para )
536{
537 PARAFORMAT2 *fmt = &para->fmt;
538 char props[STREAMOUT_BUFFER_SIZE] = "";
539 int i;
540 ME_Paragraph *prev_para = para_prev( para );
541
542 if (!editor->bEmulateVersion10) /* v4.1 */
543 {
544 if (para->nFlags & MEPF_ROWSTART)
545 {
546 pStream->nNestingLevel++;
547 if (pStream->nNestingLevel == 1)
548 if (!stream_out_table_props( editor, pStream, para )) return FALSE;
549 return TRUE;
550 }
551 else if (para->nFlags & MEPF_ROWEND)
552 {
553 pStream->nNestingLevel--;
554 if (pStream->nNestingLevel >= 1)
555 {
556 if (!ME_StreamOutPrint(pStream, "{\\*\\nesttableprops")) return FALSE;
557 if (!stream_out_table_props( editor, pStream, para )) return FALSE;
558 if (!ME_StreamOutPrint(pStream, "\\nestrow}{\\nonesttables\\par}\r\n")) return FALSE;
559 }
560 else if (!ME_StreamOutPrint(pStream, "\\row\r\n")) return FALSE;
561 return TRUE;
562 }
563 }
564 else /* v1.0 - 3.0 */
565 {
566 if (para->fmt.dwMask & PFM_TABLE && para->fmt.wEffects & PFE_TABLE)
567 if (!stream_out_table_props( editor, pStream, para )) return FALSE;
568 }
569
570 if (prev_para && !memcmp( fmt, &prev_para->fmt, sizeof(*fmt) ))
571 {
572 if (fmt->wNumbering)
573 return stream_out_para_num( pStream, para, FALSE );
574 return TRUE;
575 }
576
577 if (!ME_StreamOutPrint(pStream, "\\pard"))
578 return FALSE;
579
580 if (fmt->wNumbering)
581 if (!stream_out_para_num( pStream, para, TRUE )) return FALSE;
582
583 if (!editor->bEmulateVersion10) /* v4.1 */
584 {
585 if (pStream->nNestingLevel > 0) strcat(props, "\\intbl");
586 if (pStream->nNestingLevel > 1) sprintf(props + strlen(props), "\\itap%d", pStream->nNestingLevel);
587 }
588 else /* v1.0 - 3.0 */
589 {
590 if (fmt->dwMask & PFM_TABLE && fmt->wEffects & PFE_TABLE)
591 strcat(props, "\\intbl");
592 }
593
594 /* TODO: PFM_BORDER. M$ does not emit any keywords for these properties, and
595 * when streaming border keywords in, PFM_BORDER is set, but wBorder field is
596 * set very different from the documentation.
597 * (Tested with RichEdit 5.50.25.0601) */
598
599 if (fmt->dwMask & PFM_ALIGNMENT)
600 {
601 switch (fmt->wAlignment)
602 {
603 case PFA_LEFT:
604 /* Default alignment: not emitted */
605 break;
606 case PFA_RIGHT:
607 strcat(props, "\\qr");
608 break;
609 case PFA_CENTER:
610 strcat(props, "\\qc");
611 break;
612 case PFA_JUSTIFY:
613 strcat(props, "\\qj");
614 break;
615 }
616 }
617
618 if (fmt->dwMask & PFM_LINESPACING)
619 {
620 /* FIXME: MSDN says that the bLineSpacingRule field is controlled by the
621 * PFM_SPACEAFTER flag. Is that true? I don't believe so. */
622 switch (fmt->bLineSpacingRule)
623 {
624 case 0: /* Single spacing */
625 strcat(props, "\\sl-240\\slmult1");
626 break;
627 case 1: /* 1.5 spacing */
628 strcat(props, "\\sl-360\\slmult1");
629 break;
630 case 2: /* Double spacing */
631 strcat(props, "\\sl-480\\slmult1");
632 break;
633 case 3:
634 sprintf(props + strlen(props), "\\sl%d\\slmult0", fmt->dyLineSpacing);
635 break;
636 case 4:
637 sprintf(props + strlen(props), "\\sl-%d\\slmult0", fmt->dyLineSpacing);
638 break;
639 case 5:
640 sprintf(props + strlen(props), "\\sl-%d\\slmult1", fmt->dyLineSpacing * 240 / 20);
641 break;
642 }
643 }
644
645 if (fmt->dwMask & PFM_DONOTHYPHEN && fmt->wEffects & PFE_DONOTHYPHEN)
646 strcat(props, "\\hyph0");
647 if (fmt->dwMask & PFM_KEEP && fmt->wEffects & PFE_KEEP)
648 strcat(props, "\\keep");
649 if (fmt->dwMask & PFM_KEEPNEXT && fmt->wEffects & PFE_KEEPNEXT)
650 strcat(props, "\\keepn");
651 if (fmt->dwMask & PFM_NOLINENUMBER && fmt->wEffects & PFE_NOLINENUMBER)
652 strcat(props, "\\noline");
653 if (fmt->dwMask & PFM_NOWIDOWCONTROL && fmt->wEffects & PFE_NOWIDOWCONTROL)
654 strcat(props, "\\nowidctlpar");
655 if (fmt->dwMask & PFM_PAGEBREAKBEFORE && fmt->wEffects & PFE_PAGEBREAKBEFORE)
656 strcat(props, "\\pagebb");
657 if (fmt->dwMask & PFM_RTLPARA && fmt->wEffects & PFE_RTLPARA)
658 strcat(props, "\\rtlpar");
659 if (fmt->dwMask & PFM_SIDEBYSIDE && fmt->wEffects & PFE_SIDEBYSIDE)
660 strcat(props, "\\sbys");
661
662 if (!(editor->bEmulateVersion10 && /* v1.0 - 3.0 */
663 fmt->dwMask & PFM_TABLE && fmt->wEffects & PFE_TABLE))
664 {
665 if (fmt->dxOffset)
666 sprintf(props + strlen(props), "\\li%d", fmt->dxOffset);
667 if (fmt->dxStartIndent)
668 sprintf(props + strlen(props), "\\fi%d", fmt->dxStartIndent);
669 if (fmt->dxRightIndent)
670 sprintf(props + strlen(props), "\\ri%d", fmt->dxRightIndent);
671 if (fmt->dwMask & PFM_TABSTOPS) {
672 static const char * const leader[6] = { "", "\\tldot", "\\tlhyph", "\\tlul", "\\tlth", "\\tleq" };
673
674 for (i = 0; i < fmt->cTabCount; i++)
675 {
676 switch ((fmt->rgxTabs[i] >> 24) & 0xf)
677 {
678 case 1:
679 strcat(props, "\\tqc");
680 break;
681 case 2:
682 strcat(props, "\\tqr");
683 break;
684 case 3:
685 strcat(props, "\\tqdec");
686 break;
687 case 4:
688 /* Word bar tab (vertical bar). Handled below */
689 break;
690 }
691 if (fmt->rgxTabs[i] >> 28 <= 5)
692 strcat(props, leader[fmt->rgxTabs[i] >> 28]);
693 sprintf(props+strlen(props), "\\tx%d", fmt->rgxTabs[i]&0x00FFFFFF);
694 }
695 }
696 }
697 if (fmt->dySpaceAfter)
698 sprintf(props + strlen(props), "\\sa%d", fmt->dySpaceAfter);
699 if (fmt->dySpaceBefore)
700 sprintf(props + strlen(props), "\\sb%d", fmt->dySpaceBefore);
701 if (fmt->sStyle != -1)
702 sprintf(props + strlen(props), "\\s%d", fmt->sStyle);
703
704 if (fmt->dwMask & PFM_SHADING)
705 {
706 static const char * const style[16] = { "", "\\bgdkhoriz", "\\bgdkvert", "\\bgdkfdiag",
707 "\\bgdkbdiag", "\\bgdkcross", "\\bgdkdcross",
708 "\\bghoriz", "\\bgvert", "\\bgfdiag",
709 "\\bgbdiag", "\\bgcross", "\\bgdcross",
710 "", "", "" };
711 if (fmt->wShadingWeight)
712 sprintf(props + strlen(props), "\\shading%d", fmt->wShadingWeight);
713 if (fmt->wShadingStyle & 0xF)
714 strcat(props, style[fmt->wShadingStyle & 0xF]);
715 if ((fmt->wShadingStyle >> 4) & 0xf)
716 sprintf(props + strlen(props), "\\cfpat%d", (fmt->wShadingStyle >> 4) & 0xf);
717 if ((fmt->wShadingStyle >> 8) & 0xf)
718 sprintf(props + strlen(props), "\\cbpat%d", (fmt->wShadingStyle >> 8) & 0xf);
719 }
720 if (*props)
721 strcat(props, " ");
722
723 if (*props && !ME_StreamOutPrint(pStream, props))
724 return FALSE;
725
726 return TRUE;
727}
728
729
730static BOOL
732{
733 char props[STREAMOUT_BUFFER_SIZE] = "";
734 unsigned int i;
735 CHARFORMAT2W *old_fmt = &pStream->cur_fmt;
736 static const struct
737 {
738 DWORD effect;
739 const char *on, *off;
740 } effects[] =
741 {
742 { CFE_ALLCAPS, "\\caps", "\\caps0" },
743 { CFE_BOLD, "\\b", "\\b0" },
744 { CFE_DISABLED, "\\disabled", "\\disabled0" },
745 { CFE_EMBOSS, "\\embo", "\\embo0" },
746 { CFE_HIDDEN, "\\v", "\\v0" },
747 { CFE_IMPRINT, "\\impr", "\\impr0" },
748 { CFE_ITALIC, "\\i", "\\i0" },
749 { CFE_OUTLINE, "\\outl", "\\outl0" },
750 { CFE_PROTECTED, "\\protect", "\\protect0" },
751 { CFE_SHADOW, "\\shad", "\\shad0" },
752 { CFE_SMALLCAPS, "\\scaps", "\\scaps0" },
753 { CFE_STRIKEOUT, "\\strike", "\\strike0" },
754 };
755
756 for (i = 0; i < ARRAY_SIZE( effects ); i++)
757 {
758 if ((old_fmt->dwEffects ^ fmt->dwEffects) & effects[i].effect)
759 strcat( props, fmt->dwEffects & effects[i].effect ? effects[i].on : effects[i].off );
760 }
761
762 if ((old_fmt->dwEffects ^ fmt->dwEffects) & CFE_AUTOBACKCOLOR ||
763 (!(fmt->dwEffects & CFE_AUTOBACKCOLOR) && old_fmt->crBackColor != fmt->crBackColor))
764 {
765 if (fmt->dwEffects & CFE_AUTOBACKCOLOR) i = 0;
766 else find_color_in_colortbl( pStream, fmt->crBackColor, &i );
767 sprintf(props + strlen(props), "\\highlight%u", i);
768 }
769 if ((old_fmt->dwEffects ^ fmt->dwEffects) & CFE_AUTOCOLOR ||
770 (!(fmt->dwEffects & CFE_AUTOCOLOR) && old_fmt->crTextColor != fmt->crTextColor))
771 {
772 if (fmt->dwEffects & CFE_AUTOCOLOR) i = 0;
773 else find_color_in_colortbl( pStream, fmt->crTextColor, &i );
774 sprintf(props + strlen(props), "\\cf%u", i);
775 }
776
777 if (old_fmt->bAnimation != fmt->bAnimation)
778 sprintf(props + strlen(props), "\\animtext%u", fmt->bAnimation);
779 if (old_fmt->wKerning != fmt->wKerning)
780 sprintf(props + strlen(props), "\\kerning%u", fmt->wKerning);
781
782 if (old_fmt->lcid != fmt->lcid)
783 {
784 /* TODO: handle SFF_PLAINRTF */
785 if (LOWORD(fmt->lcid) == 1024)
786 strcat(props, "\\noproof\\lang1024\\langnp1024\\langfe1024\\langfenp1024");
787 else
788 sprintf(props + strlen(props), "\\lang%u", LOWORD(fmt->lcid));
789 }
790
791 if (old_fmt->yOffset != fmt->yOffset)
792 {
793 if (fmt->yOffset >= 0)
794 sprintf(props + strlen(props), "\\up%d", fmt->yOffset);
795 else
796 sprintf(props + strlen(props), "\\dn%d", -fmt->yOffset);
797 }
798 if (old_fmt->yHeight != fmt->yHeight)
799 sprintf(props + strlen(props), "\\fs%d", fmt->yHeight / 10);
800 if (old_fmt->sSpacing != fmt->sSpacing)
801 sprintf(props + strlen(props), "\\expnd%u\\expndtw%u", fmt->sSpacing / 5, fmt->sSpacing);
802 if ((old_fmt->dwEffects ^ fmt->dwEffects) & (CFM_SUBSCRIPT | CFM_SUPERSCRIPT))
803 {
804 if (fmt->dwEffects & CFE_SUBSCRIPT)
805 strcat(props, "\\sub");
806 else if (fmt->dwEffects & CFE_SUPERSCRIPT)
807 strcat(props, "\\super");
808 else
809 strcat(props, "\\nosupersub");
810 }
811 if ((old_fmt->dwEffects ^ fmt->dwEffects) & CFE_UNDERLINE ||
812 old_fmt->bUnderlineType != fmt->bUnderlineType)
813 {
814 BYTE type = (fmt->dwEffects & CFE_UNDERLINE) ? fmt->bUnderlineType : CFU_UNDERLINENONE;
815 switch (type)
816 {
817 case CFU_UNDERLINE:
818 strcat(props, "\\ul");
819 break;
821 strcat(props, "\\uld");
822 break;
824 strcat(props, "\\uldb");
825 break;
827 strcat(props, "\\ulw");
828 break;
829 case CFU_CF1UNDERLINE:
831 default:
832 strcat(props, "\\ulnone");
833 break;
834 }
835 }
836
837 if (wcscmp(old_fmt->szFaceName, fmt->szFaceName) ||
838 old_fmt->bCharSet != fmt->bCharSet)
839 {
840 if (find_font_in_fonttbl( pStream, fmt, &i ))
841 {
842 sprintf(props + strlen(props), "\\f%u", i);
843
844 /* In UTF-8 mode, charsets/codepages are not used */
845 if (pStream->nDefaultCodePage != CP_UTF8)
846 {
847 if (pStream->fonttbl[i].bCharSet == DEFAULT_CHARSET)
848 pStream->nCodePage = pStream->nDefaultCodePage;
849 else
850 pStream->nCodePage = RTFCharSetToCodePage(NULL, pStream->fonttbl[i].bCharSet);
851 }
852 }
853 }
854 if (*props)
855 strcat(props, " ");
856 if (!ME_StreamOutPrint(pStream, props))
857 return FALSE;
858 *old_fmt = *fmt;
859 return TRUE;
860}
861
862
863static BOOL
865{
867 int pos = 0;
868 int fit, nBytes, i;
869
870 if (nChars == -1)
871 nChars = lstrlenW(text);
872
873 while (nChars) {
874 /* In UTF-8 mode, font charsets are not used. */
875 if (pStream->nDefaultCodePage == CP_UTF8) {
876 /* 6 is the maximum character length in UTF-8 */
877 fit = min(nChars, STREAMOUT_BUFFER_SIZE / 6);
878 nBytes = WideCharToMultiByte(CP_UTF8, 0, text, fit, buffer,
880 nChars -= fit;
881 text += fit;
882 for (i = 0; i < nBytes; i++)
883 if (buffer[i] == '{' || buffer[i] == '}' || buffer[i] == '\\') {
884 if (!ME_StreamOutPrint(pStream, "%.*s\\", i - pos, buffer + pos))
885 return FALSE;
886 pos = i;
887 }
888 if (pos < nBytes)
889 if (!ME_StreamOutMove(pStream, buffer + pos, nBytes - pos))
890 return FALSE;
891 pos = 0;
892 } else if (*text < 128) {
893 if (*text == '{' || *text == '}' || *text == '\\')
894 buffer[pos++] = '\\';
895 buffer[pos++] = (char)(*text++);
896 nChars--;
897 } else {
899 char letter[3];
900
901 /* FIXME: In the MS docs for WideCharToMultiByte there is a big list of
902 * codepages including CP_SYMBOL for which the last parameter must be set
903 * to NULL for the function to succeed. But in Wine we need to care only
904 * about CP_SYMBOL */
905 nBytes = WideCharToMultiByte(pStream->nCodePage, 0, text, 1,
906 letter, 3, NULL,
907 (pStream->nCodePage == CP_SYMBOL) ? NULL : &unknown);
908 if (unknown)
909 pos += sprintf(buffer + pos, "\\u%d?", (short)*text);
910 else if ((BYTE)*letter < 128) {
911 if (*letter == '{' || *letter == '}' || *letter == '\\')
912 buffer[pos++] = '\\';
913 buffer[pos++] = *letter;
914 } else {
915 for (i = 0; i < nBytes; i++)
916 pos += sprintf(buffer + pos, "\\'%02x", (BYTE)letter[i]);
917 }
918 text++;
919 nChars--;
920 }
921 if (pos >= STREAMOUT_BUFFER_SIZE - 11) {
922 if (!ME_StreamOutMove(pStream, buffer, pos))
923 return FALSE;
924 pos = 0;
925 }
926 }
927 return ME_StreamOutMove(pStream, buffer, pos);
928}
929
931 ME_Run *run )
932{
934 HRESULT hr;
935 FORMATETC fmt = { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF };
936 STGMEDIUM med = { TYMED_NULL };
937 BOOL ret = FALSE;
938 ENHMETAHEADER *emf_bits = NULL;
939 UINT size;
940 SIZE goal, pic;
942 HDC hdc;
943
944 hr = IOleObject_QueryInterface( run->reobj->obj.poleobj, &IID_IDataObject, (void **)&data );
945 if (FAILED(hr)) return FALSE;
946
947 hdc = ITextHost_TxGetDC( editor->texthost );
948 ME_InitContext( &c, editor, hdc );
949 hr = IDataObject_QueryGetData( data, &fmt );
950 if (hr != S_OK) goto done;
951
952 hr = IDataObject_GetData( data, &fmt, &med );
953 if (FAILED(hr)) goto done;
954 if (med.tymed != TYMED_ENHMF) goto done;
955
956 size = GetEnhMetaFileBits( med.u.hEnhMetaFile, 0, NULL );
957 if (size < FIELD_OFFSET(ENHMETAHEADER, cbPixelFormat)) goto done;
958
959 emf_bits = HeapAlloc( GetProcessHeap(), 0, size );
960 if (!emf_bits) goto done;
961
962 size = GetEnhMetaFileBits( med.u.hEnhMetaFile, size, (BYTE *)emf_bits );
963 if (size < FIELD_OFFSET(ENHMETAHEADER, cbPixelFormat)) goto done;
964
965 /* size_in_pixels = (frame_size / 100) * szlDevice / szlMillimeters
966 pic = size_in_pixels * 2540 / dpi */
967 pic.cx = MulDiv( emf_bits->rclFrame.right - emf_bits->rclFrame.left, emf_bits->szlDevice.cx * 254,
968 emf_bits->szlMillimeters.cx * c.dpi.cx * 10 );
969 pic.cy = MulDiv( emf_bits->rclFrame.bottom - emf_bits->rclFrame.top, emf_bits->szlDevice.cy * 254,
970 emf_bits->szlMillimeters.cy * c.dpi.cy * 10 );
971
972 /* convert goal size to twips */
973 goal.cx = MulDiv( run->reobj->obj.sizel.cx, 144, 254 );
974 goal.cy = MulDiv( run->reobj->obj.sizel.cy, 144, 254 );
975
976 if (!ME_StreamOutPrint( stream, "{\\*\\shppict{\\pict\\emfblip\\picw%d\\pich%d\\picwgoal%d\\pichgoal%d\n",
977 pic.cx, pic.cy, goal.cx, goal.cy ))
978 goto done;
979
980 if (!ME_StreamOutHexData( stream, (BYTE *)emf_bits, size ))
981 goto done;
982
983 if (!ME_StreamOutPrint( stream, "}}\n" ))
984 goto done;
985
986 ret = TRUE;
987
988done:
991 HeapFree( GetProcessHeap(), 0, emf_bits );
992 ReleaseStgMedium( &med );
993 IDataObject_Release( data );
994 return ret;
995}
996
998 const ME_Cursor *start, int nChars, int dwFormat)
999{
1001 ME_Paragraph *prev_para = NULL;
1002 ME_Cursor endCur = cursor;
1003
1004 ME_MoveCursorChars(editor, &endCur, nChars, TRUE);
1005
1006 if (!ME_StreamOutRTFHeader(pStream, dwFormat))
1007 return FALSE;
1008
1009 if (!stream_out_font_and_colour_tbls( pStream, cursor.run, endCur.run ))
1010 return FALSE;
1011
1012 /* TODO: stylesheet table */
1013
1014 if (!ME_StreamOutPrint(pStream, "{\\*\\generator Wine Riched20 2.0;}\r\n"))
1015 return FALSE;
1016
1017 /* TODO: information group */
1018
1019 /* TODO: document formatting properties */
1020
1021 /* FIXME: We have only one document section */
1022
1023 /* TODO: section formatting properties */
1024
1025 do
1026 {
1027 if (cursor.para != prev_para)
1028 {
1029 prev_para = cursor.para;
1030 if (!stream_out_para_props( editor, pStream, cursor.para ))
1031 return FALSE;
1032 }
1033
1034 if (cursor.run == endCur.run && !endCur.nOffset)
1035 break;
1036
1037 TRACE("flags %xh\n", cursor.run->nFlags);
1038 /* TODO: emit embedded objects */
1039 if (cursor.para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND))
1040 continue;
1041 if (cursor.run->nFlags & MERF_GRAPHICS)
1042 {
1043 if (!stream_out_graphics( editor, pStream, cursor.run ))
1044 return FALSE;
1045 }
1046 else if (cursor.run->nFlags & MERF_TAB)
1047 {
1048 if (editor->bEmulateVersion10 && /* v1.0 - 3.0 */
1049 para_in_table( cursor.para ))
1050 {
1051 if (!ME_StreamOutPrint(pStream, "\\cell "))
1052 return FALSE;
1053 }
1054 else
1055 {
1056 if (!ME_StreamOutPrint(pStream, "\\tab "))
1057 return FALSE;
1058 }
1059 }
1060 else if (cursor.run->nFlags & MERF_ENDCELL)
1061 {
1062 if (pStream->nNestingLevel > 1)
1063 {
1064 if (!ME_StreamOutPrint(pStream, "\\nestcell "))
1065 return FALSE;
1066 }
1067 else
1068 {
1069 if (!ME_StreamOutPrint(pStream, "\\cell "))
1070 return FALSE;
1071 }
1072 nChars--;
1073 }
1074 else if (cursor.run->nFlags & MERF_ENDPARA)
1075 {
1076 if (!ME_StreamOutRTFCharProps( pStream, &cursor.run->style->fmt ))
1077 return FALSE;
1078
1079 if (para_in_table( cursor.para ) &&
1080 !(cursor.para->nFlags & (MEPF_ROWSTART | MEPF_ROWEND | MEPF_CELL)))
1081 {
1082 if (!ME_StreamOutPrint(pStream, "\\row\r\n"))
1083 return FALSE;
1084 }
1085 else
1086 {
1087 if (!ME_StreamOutPrint(pStream, "\\par\r\n"))
1088 return FALSE;
1089 }
1090 /* Skip as many characters as required by current line break */
1091 nChars = max(0, nChars - cursor.run->len);
1092 }
1093 else if (cursor.run->nFlags & MERF_ENDROW)
1094 {
1095 if (!ME_StreamOutPrint(pStream, "\\line\r\n"))
1096 return FALSE;
1097 nChars--;
1098 }
1099 else
1100 {
1101 int nEnd;
1102
1103 TRACE("style %p\n", cursor.run->style);
1104 if (!ME_StreamOutRTFCharProps( pStream, &cursor.run->style->fmt ))
1105 return FALSE;
1106
1107 nEnd = (cursor.run == endCur.run) ? endCur.nOffset : cursor.run->len;
1108 if (!ME_StreamOutRTFText(pStream, get_text( cursor.run, cursor.nOffset ),
1109 nEnd - cursor.nOffset))
1110 return FALSE;
1111 cursor.nOffset = 0;
1112 }
1113 } while (cursor.run != endCur.run && cursor_next_run( &cursor, TRUE ));
1114
1115 if (!ME_StreamOutMove(pStream, "}\0", 2))
1116 return FALSE;
1117 return TRUE;
1118}
1119
1120
1122 const ME_Cursor *start, int nChars, DWORD dwFormat)
1123{
1125 int nLen;
1126 UINT nCodePage = CP_ACP;
1127 char *buffer = NULL;
1128 int nBufLen = 0;
1129 BOOL success = TRUE;
1130
1131 if (!cursor.run)
1132 return FALSE;
1133
1134 if (dwFormat & SF_USECODEPAGE)
1135 nCodePage = HIWORD(dwFormat);
1136
1137 /* TODO: Handle SF_TEXTIZED */
1138
1139 while (success && nChars && cursor.run)
1140 {
1141 nLen = min(nChars, cursor.run->len - cursor.nOffset);
1142
1143 if (!editor->bEmulateVersion10 && cursor.run->nFlags & MERF_ENDPARA)
1144 {
1145 /* richedit 2.0 - all line breaks are \r\n */
1146 if (dwFormat & SF_UNICODE)
1147 success = ME_StreamOutMove(pStream, (const char *)L"\r\n", 2 * sizeof(WCHAR));
1148 else
1149 success = ME_StreamOutMove(pStream, "\r\n", 2);
1150 } else {
1151 if (dwFormat & SF_UNICODE)
1152 success = ME_StreamOutMove(pStream, (const char *)(get_text( cursor.run, cursor.nOffset )),
1153 sizeof(WCHAR) * nLen);
1154 else {
1155 int nSize;
1156
1157 nSize = WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ),
1158 nLen, NULL, 0, NULL, NULL);
1159 if (nSize > nBufLen) {
1161 nBufLen = nSize;
1162 }
1163 WideCharToMultiByte(nCodePage, 0, get_text( cursor.run, cursor.nOffset ),
1164 nLen, buffer, nSize, NULL, NULL);
1165 success = ME_StreamOutMove(pStream, buffer, nSize);
1166 }
1167 }
1168
1169 nChars -= nLen;
1170 cursor.nOffset = 0;
1171 cursor.run = run_next_all_paras( cursor.run );
1172 }
1173
1175 return success;
1176}
1177
1178
1180 const ME_Cursor *start,
1181 int nChars, EDITSTREAM *stream)
1182{
1183 ME_OutStream *pStream = ME_StreamOutInit(editor, stream);
1184
1185 if (dwFormat & SF_RTF)
1186 ME_StreamOutRTF(editor, pStream, start, nChars, dwFormat);
1187 else if (dwFormat & SF_TEXT || dwFormat & SF_TEXTIZED)
1188 ME_StreamOutText(editor, pStream, start, nChars, dwFormat);
1189 if (!pStream->stream->dwError)
1190 ME_StreamOutFlush(pStream);
1191 return ME_StreamOutFree(pStream);
1192}
1193
1194LRESULT
1196{
1198 int nChars;
1199
1200 if (dwFormat & SFF_SELECTION) {
1201 int nStart, nTo;
1202 start = editor->pCursors[ME_GetSelectionOfs(editor, &nStart, &nTo)];
1203 nChars = nTo - nStart;
1204 } else {
1205 ME_SetCursorToStart(editor, &start);
1206 nChars = ME_GetTextLength(editor);
1207 /* Generate an end-of-paragraph at the end of SCF_ALL RTF output */
1208 if (dwFormat & SF_RTF)
1209 nChars++;
1210 }
1211 return ME_StreamOutRange(editor, dwFormat, &start, nChars, stream);
1212}
ios_base &_STLP_CALL dec(ios_base &__s)
Definition: _ios_base.h:321
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Arabic default style
Definition: afstyles.h:94
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define CF_ENHMETAFILE
Definition: constants.h:409
#define ARRAY_SIZE(A)
Definition: main.h:20
CFF_Charset charset
Definition: cffcmap.c:138
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
WORD face[3]
Definition: mesh.c:4747
unsigned int idx
Definition: utils.c:41
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WideCharToMultiByte
Definition: compat.h:111
#define lstrlenW
Definition: compat.h:750
UINT WINAPI GetACP(void)
Definition: locale.c:2021
BOOL WINAPI GetCPInfoExW(UINT codepage, DWORD dwFlags, LPCPINFOEXW cpinfo)
Definition: locale.c:2220
LANGID WINAPI GetUserDefaultLangID(void)
Definition: locale.c:1177
UINT WINAPI GetOEMCP(void)
Definition: locale.c:2060
const WCHAR * text
Definition: package.c:1794
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:27
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop)
Definition: caret.c:678
int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *to)
Definition: caret.c:42
int ME_GetTextLength(ME_TextEditor *editor)
Definition: caret.c:83
void ME_DestroyContext(ME_Context *c)
Definition: context.c:44
void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
Definition: context.c:23
int RTFCharSetToCodePage(RTF_Info *info, int charset)
Definition: reader.c:493
static BOOL find_font_in_fonttbl(ME_OutStream *stream, CHARFORMAT2W *fmt, unsigned int *idx)
Definition: writer.c:257
#define HEX_BYTES_PER_LINE
Definition: writer.c:137
#define STREAMOUT_BUFFER_SIZE
Definition: writer.c:28
static LONG ME_StreamOutFree(ME_OutStream *pStream)
Definition: writer.c:92
static ME_OutStream * ME_StreamOutInit(ME_TextEditor *editor, EDITSTREAM *stream)
Definition: writer.c:55
static void add_color_to_colortbl(ME_OutStream *stream, COLORREF color)
Definition: writer.c:282
static BOOL ME_StreamOutRTFHeader(ME_OutStream *pStream, int dwFormat)
Definition: writer.c:165
LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream)
Definition: writer.c:1179
struct tagME_OutStream ME_OutStream
static BOOL find_color_in_colortbl(ME_OutStream *stream, COLORREF color, unsigned int *idx)
Definition: writer.c:297
static BOOL ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt)
Definition: writer.c:731
static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream, const ME_Cursor *start, int nChars, DWORD dwFormat)
Definition: writer.c:1121
static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream, const ME_Cursor *start, int nChars, int dwFormat)
Definition: writer.c:997
static BOOL ME_StreamOutHexData(ME_OutStream *stream, const BYTE *data, UINT len)
Definition: writer.c:140
static BOOL stream_out_font_and_colour_tbls(ME_OutStream *pStream, ME_Run *first, ME_Run *last)
Definition: writer.c:314
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream)
Definition: writer.c:1195
static BOOL WINAPIV ME_StreamOutPrint(ME_OutStream *pStream, const char *format,...)
Definition: writer.c:124
static BOOL stream_out_para_props(ME_TextEditor *editor, ME_OutStream *pStream, ME_Paragraph *para)
Definition: writer.c:534
static BOOL stream_out_graphics(ME_TextEditor *editor, ME_OutStream *stream, ME_Run *run)
Definition: writer.c:930
static void add_font_to_fonttbl(ME_OutStream *stream, ME_Style *style)
Definition: writer.c:233
static BOOL stream_out_table_props(ME_TextEditor *editor, ME_OutStream *pStream, ME_Paragraph *para)
Definition: writer.c:387
#define STREAMOUT_COLORTBL_SIZE
Definition: writer.c:30
static BOOL stream_out_para_num(ME_OutStream *stream, ME_Paragraph *para, BOOL pn_dest)
Definition: writer.c:464
static BOOL ME_StreamOutRTFText(ME_OutStream *pStream, const WCHAR *text, LONG nChars)
Definition: writer.c:864
#define STREAMOUT_FONTTBL_SIZE
Definition: writer.c:29
static BOOL ME_StreamOutFlush(ME_OutStream *pStream)
Definition: writer.c:69
static BOOL ME_StreamOutMove(ME_OutStream *pStream, const char *buffer, int len)
Definition: writer.c:103
unsigned char
Definition: typeof.h:29
#define assert(x)
Definition: debug.h:53
switch(r->id)
Definition: btrfs.c:3046
ME_Run * run_next_all_paras(ME_Run *run) DECLSPEC_HIDDEN
Definition: run.c:96
ME_Cell * para_cell(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:127
BOOL para_in_table(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:122
#define ITextHost_TxGetDC(This)
Definition: editor.h:333
ME_Cell * table_row_first_cell(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: table.c:170
ME_Cell * cell_next(ME_Cell *cell) DECLSPEC_HIDDEN
Definition: table.c:192
BOOL cursor_next_run(ME_Cursor *cursor, BOOL all_para) DECLSPEC_HIDDEN
Definition: run.c:30
#define ITextHost_TxReleaseDC(This, a)
Definition: editor.h:334
ME_Paragraph * para_prev(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:63
static WCHAR * get_text(const ME_Run *run, int offset)
Definition: editor.h:42
ME_Paragraph * table_row_end(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: table.c:127
#define MERF_TAB
Definition: editstr.h:106
#define MERF_ENDPARA
Definition: editstr.h:121
#define MERF_ENDCELL
Definition: editstr.h:108
#define MEPF_CELL
Definition: editstr.h:142
#define MERF_GRAPHICS
Definition: editstr.h:104
#define MEPF_ROWSTART
Definition: editstr.h:143
#define MEPF_ROWEND
Definition: editstr.h:144
#define MERF_ENDROW
Definition: editstr.h:123
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint color
Definition: glext.h:6243
const GLubyte * c
Definition: glext.h:8905
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
const GLint * first
Definition: glext.h:5794
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int hex(char ch)
const char cursor[]
Definition: icontest.c:13
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define c
Definition: ke_i.h:80
USHORT LANGID
Definition: mui.h:9
if(dx< 0)
Definition: linetemp.h:194
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define sprintf(buf, format,...)
Definition: sprintf.c:55
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static UINT UINT last
Definition: font.c:45
static va_list valist
Definition: printf.c:46
#define min(a, b)
Definition: monoChain.cc:55
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
const GUID IID_IDataObject
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
#define PFN_UCLETTER
Definition: richedit.h:908
#define CFU_UNDERLINEDOUBLE
Definition: richedit.h:430
#define PFA_RIGHT
Definition: richedit.h:922
#define SFF_SELECTION
Definition: richedit.h:979
#define PFA_CENTER
Definition: richedit.h:923
#define PFE_RTLPARA
Definition: richedit.h:932
#define CFE_SMALLCAPS
Definition: richedit.h:416
#define PFE_KEEP
Definition: richedit.h:933
#define PFE_DONOTHYPHEN
Definition: richedit.h:938
#define PFN_ARABIC
Definition: richedit.h:906
#define CFE_STRIKEOUT
Definition: richedit.h:409
#define CFE_OUTLINE
Definition: richedit.h:419
#define CFE_HIDDEN
Definition: richedit.h:418
#define CFE_BOLD
Definition: richedit.h:406
#define SF_USECODEPAGE
Definition: richedit.h:725
#define PFE_NOWIDOWCONTROL
Definition: richedit.h:937
#define PFA_LEFT
Definition: richedit.h:921
#define CFE_AUTOCOLOR
Definition: richedit.h:414
#define PFM_NOLINENUMBER
Definition: richedit.h:860
#define PFM_KEEPNEXT
Definition: richedit.h:858
#define CFU_UNDERLINEWORD
Definition: richedit.h:429
#define PFM_DONOTHYPHEN
Definition: richedit.h:862
#define CFE_ALLCAPS
Definition: richedit.h:417
#define SF_RTF
Definition: richedit.h:721
#define CFE_ITALIC
Definition: richedit.h:407
#define PFM_LINESPACING
Definition: richedit.h:849
#define CFE_DISABLED
Definition: richedit.h:423
#define PFN_LCLETTER
Definition: richedit.h:907
#define CFE_SUPERSCRIPT
Definition: richedit.h:413
#define CFM_SUBSCRIPT
Definition: richedit.h:348
#define CFE_IMPRINT
Definition: richedit.h:422
#define PFN_UCROMAN
Definition: richedit.h:910
#define CFM_CHARSET
Definition: richedit.h:358
#define PFM_SHADING
Definition: richedit.h:852
#define CFE_UNDERLINE
Definition: richedit.h:408
#define CFM_BACKCOLOR
Definition: richedit.h:357
#define CFE_SUBSCRIPT
Definition: richedit.h:412
#define PFM_TABLE
Definition: richedit.h:870
#define PFNS_PAREN
Definition: richedit.h:913
#define PFN_BULLET
Definition: richedit.h:905
#define CFU_UNDERLINE
Definition: richedit.h:428
#define CFE_PROTECTED
Definition: richedit.h:410
#define PFE_SIDEBYSIDE
Definition: richedit.h:939
#define PFM_NOWIDOWCONTROL
Definition: richedit.h:861
#define CFE_EMBOSS
Definition: richedit.h:421
#define PFE_NOLINENUMBER
Definition: richedit.h:936
#define PFM_PAGEBREAKBEFORE
Definition: richedit.h:859
#define PFE_TABLE
Definition: richedit.h:944
#define PFE_PAGEBREAKBEFORE
Definition: richedit.h:935
#define PFM_ALIGNMENT
Definition: richedit.h:841
#define SF_TEXT
Definition: richedit.h:720
#define CFE_AUTOBACKCOLOR
Definition: richedit.h:425
#define PFM_SIDEBYSIDE
Definition: richedit.h:863
#define PFA_JUSTIFY
Definition: richedit.h:924
#define PFM_TABSTOPS
Definition: richedit.h:842
#define PFN_LCROMAN
Definition: richedit.h:909
#define SF_UNICODE
Definition: richedit.h:724
#define PFNS_PARENS
Definition: richedit.h:914
#define CFU_CF1UNDERLINE
Definition: richedit.h:447
#define PFM_KEEP
Definition: richedit.h:857
#define CFU_UNDERLINENONE
Definition: richedit.h:427
#define CFM_FACE
Definition: richedit.h:360
#define CFE_SHADOW
Definition: richedit.h:420
#define PFM_RTLPARA
Definition: richedit.h:856
#define PFE_KEEPNEXT
Definition: richedit.h:934
#define CFU_UNDERLINEDOTTED
Definition: richedit.h:431
#define CFM_COLOR
Definition: richedit.h:361
#define SF_TEXTIZED
Definition: richedit.h:723
#define PFNS_PERIOD
Definition: richedit.h:915
#define CFM_SUPERSCRIPT
Definition: richedit.h:349
#define WINAPIV
Definition: sdbpapi.h:64
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define CP_UTF8
Definition: nls.h:20
strcat
Definition: string.h:92
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
BYTE bCharSet
Definition: richedit.h:311
WCHAR szFaceName[LF_FACESIZE]
Definition: richedit.h:313
BYTE bAnimation
Definition: richedit.h:322
WORD wKerning
Definition: richedit.h:320
LONG yOffset
Definition: richedit.h:309
DWORD dwEffects
Definition: richedit.h:307
SHORT sSpacing
Definition: richedit.h:315
BYTE bUnderlineType
Definition: richedit.h:321
LONG yHeight
Definition: richedit.h:308
COLORREF crBackColor
Definition: richedit.h:316
COLORREF crTextColor
Definition: richedit.h:310
DWORD dwError
Definition: richedit.h:523
WORD wNumberingStart
Definition: richedit.h:680
DWORD dwMask
Definition: richedit.h:667
WORD wNumberingStyle
Definition: richedit.h:680
LONG dxOffset
Definition: richedit.h:672
LONG rgxTabs[MAX_TAB_STOPS]
Definition: richedit.h:675
WORD wNumbering
Definition: richedit.h:668
SHORT cTabCount
Definition: richedit.h:674
WORD wEffects
Definition: richedit.h:669
LONG dxStartIndent
Definition: richedit.h:670
WORD wNumberingTab
Definition: richedit.h:680
Definition: dsound.c:943
Definition: format.c:58
Definition: parser.c:49
Definition: parse.h:23
RECTL rclFrame
Definition: wingdi.h:2323
SIZEL szlDevice
Definition: wingdi.h:2333
SIZEL szlMillimeters
Definition: wingdi.h:2334
ME_Border bottom
Definition: editstr.h:189
ME_Border right
Definition: editstr.h:190
ME_Border left
Definition: editstr.h:188
ME_Border top
Definition: editstr.h:187
COLORREF colorRef
Definition: editstr.h:182
int nRightBoundary
Definition: editstr.h:223
ME_BorderRect border
Definition: editstr.h:224
int nOffset
Definition: editstr.h:276
ME_Run * run
Definition: editstr.h:275
EDITSTREAM * stream
Definition: writer.c:34
COLORREF colortbl[STREAMOUT_COLORTBL_SIZE]
Definition: writer.c:41
UINT nFontTblLen
Definition: writer.c:38
UINT written
Definition: writer.c:36
ME_FontTableItem fonttbl[STREAMOUT_FONTTBL_SIZE]
Definition: writer.c:39
CHARFORMAT2W cur_fmt
Definition: writer.c:47
UINT nCodePage
Definition: writer.c:37
UINT nDefaultFont
Definition: writer.c:42
UINT nNestingLevel
Definition: writer.c:46
UINT nColorTblLen
Definition: writer.c:40
char buffer[STREAMOUT_BUFFER_SIZE]
Definition: writer.c:35
UINT nDefaultCodePage
Definition: writer.c:43
struct para_num para_num
Definition: editstr.h:214
ME_BorderRect border
Definition: editstr.h:207
PARAFORMAT2 fmt
Definition: editstr.h:203
struct tagME_Paragraph * para
Definition: editstr.h:160
ME_Style * style
Definition: editstr.h:159
struct re_object * reobj
Definition: editstr.h:167
CHARFORMAT2W fmt
Definition: editstr.h:72
ITextHost2 * texthost
Definition: editstr.h:384
ME_Cursor * pCursors
Definition: editstr.h:389
unsigned int bEmulateVersion10
Definition: editstr.h:385
#define max(a, b)
Definition: svc.c:63
#define vsnprintf
Definition: tif_win32.c:406
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HIWORD(l)
Definition: typedefs.h:247
static const WCHAR props[]
Definition: wbemdisp.c:288
int ret
#define success(from, fromstr, to, tostr)
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2115
#define __ms_va_list
Definition: windef.h:456
LONG_PTR LRESULT
Definition: windef.h:209
#define __ms_va_end(list)
Definition: windef.h:458
#define __ms_va_start(list, arg)
Definition: windef.h:457
DWORD COLORREF
Definition: windef.h:300
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define CP_OEMCP
Definition: winnls.h:233
#define CP_SYMBOL
Definition: winnls.h:236
#define CP_MACCP
Definition: winnls.h:234
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193