Dylan Smith : richedit: Added code to stream out table border properties.
Alexandre Julliard
julliard at winehq.org
Wed Oct 1 14:09:34 CDT 2008
Module: wine
Branch: master
Commit: 3af4419688f85237b75e64c81f074e4d3099d4cb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3af4419688f85237b75e64c81f074e4d3099d4cb
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Tue Sep 30 17:11:49 2008 -0400
richedit: Added code to stream out table border properties.
This code was simply missing, since the table border properties are
already stored and displayed.
---
dlls/riched20/writer.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c
index 50c0c61..6a03ae0 100644
--- a/dlls/riched20/writer.c
+++ b/dlls/riched20/writer.c
@@ -196,11 +196,14 @@ ME_StreamOutRTFHeader(ME_OutStream *pStream, int dwFormat)
static BOOL
-ME_StreamOutRTFFontAndColorTbl(ME_OutStream *pStream, ME_DisplayItem *pFirstRun, const ME_DisplayItem *pLastRun)
+ME_StreamOutRTFFontAndColorTbl(ME_OutStream *pStream, ME_DisplayItem *pFirstRun,
+ ME_DisplayItem *pLastRun)
{
ME_DisplayItem *item = pFirstRun;
ME_FontTableItem *table = pStream->fonttbl;
int i;
+ ME_DisplayItem *pLastPara = ME_GetParagraph(pLastRun);
+ ME_DisplayItem *pCell = NULL;
do {
CHARFORMAT2W *fmt = &item->member.run.style->fmt;
@@ -246,6 +249,38 @@ ME_StreamOutRTFFontAndColorTbl(ME_OutStream *pStream, ME_DisplayItem *pFirstRun,
break;
item = ME_FindItemFwd(item, diRun);
} while (item);
+ item = ME_GetParagraph(pFirstRun);
+ do {
+ if (item->member.para.pCell && item->member.para.pCell)
+ {
+ pCell = item->member.para.pCell;
+ if (pCell)
+ {
+ ME_Border* borders[4] = { &pCell->member.cell.border.top,
+ &pCell->member.cell.border.left,
+ &pCell->member.cell.border.bottom,
+ &pCell->member.cell.border.right };
+ for (i = 0; i < 4; i++)
+ {
+ if (borders[i]->width > 0)
+ {
+ int j;
+ COLORREF crColor = borders[i]->colorRef;
+ for (j = 1; j < pStream->nColorTblLen; j++)
+ if (pStream->colortbl[j] == crColor)
+ break;
+ if (j == pStream->nColorTblLen && j < STREAMOUT_COLORTBL_SIZE) {
+ pStream->colortbl[j] = crColor;
+ pStream->nColorTblLen++;
+ }
+ }
+ }
+ }
+ }
+ if (item == pLastPara)
+ break;
+ item = item->member.para.next_para;
+ } while (item);
if (!ME_StreamOutPrint(pStream, "{\\fonttbl"))
return FALSE;
@@ -290,26 +325,74 @@ ME_StreamOutRTFTableProps(ME_TextEditor *editor, ME_OutStream *pStream,
{
ME_DisplayItem *cell;
char props[STREAMOUT_BUFFER_SIZE] = "";
+ int i;
+ const char sideChar[4] = {'t','l','b','r'};
if (!ME_StreamOutPrint(pStream, "\\trowd"))
return FALSE;
if (!editor->bEmulateVersion10) { /* v4.1 */
+ PARAFORMAT2 *pFmt = ME_GetTableRowEnd(para)->member.para.pFmt;
para = ME_GetTableRowStart(para);
cell = para->member.para.next_para->member.para.pCell;
assert(cell);
+ if (pFmt->dxOffset)
+ sprintf(props + strlen(props), "\\trgaph%d", pFmt->dxOffset);
+ if (pFmt->dxStartIndent)
+ sprintf(props + strlen(props), "\\trleft%d", pFmt->dxStartIndent);
do {
+ ME_Border* borders[4] = { &cell->member.cell.border.top,
+ &cell->member.cell.border.left,
+ &cell->member.cell.border.bottom,
+ &cell->member.cell.border.right };
+ for (i = 0; i < 4; i++)
+ {
+ if (borders[i]->width)
+ {
+ int j;
+ COLORREF crColor = borders[i]->colorRef;
+ sprintf(props + strlen(props), "\\clbrdr%c", sideChar[i]);
+ sprintf(props + strlen(props), "\\brdrs");
+ sprintf(props + strlen(props), "\\brdrw%d", borders[i]->width);
+ for (j = 1; j < pStream->nColorTblLen; j++) {
+ if (pStream->colortbl[j] == crColor) {
+ sprintf(props + strlen(props), "\\brdrcf%u", j);
+ break;
+ }
+ }
+ }
+ }
sprintf(props + strlen(props), "\\cellx%d", cell->member.cell.nRightBoundary);
cell = cell->member.cell.next_cell;
} while (cell->member.cell.next_cell);
} else { /* v1.0 - 3.0 */
+ const ME_Border* borders[4] = { ¶->member.para.border.top,
+ ¶->member.para.border.left,
+ ¶->member.para.border.bottom,
+ ¶->member.para.border.right };
PARAFORMAT2 *pFmt = para->member.para.pFmt;
- int i;
assert(!(para->member.para.nFlags & (MEPF_ROWSTART|MEPF_ROWEND|MEPF_CELL)));
if (pFmt->dxOffset)
sprintf(props + strlen(props), "\\trgaph%d", pFmt->dxOffset);
if (pFmt->dxStartIndent)
sprintf(props + strlen(props), "\\trleft%d", pFmt->dxStartIndent);
+ for (i = 0; i < 4; i++)
+ {
+ if (borders[i]->width)
+ {
+ int j;
+ COLORREF crColor = borders[i]->colorRef;
+ sprintf(props + strlen(props), "\\trbrdr%c", sideChar[i]);
+ sprintf(props + strlen(props), "\\brdrs");
+ sprintf(props + strlen(props), "\\brdrw%d", borders[i]->width);
+ for (j = 1; j < pStream->nColorTblLen; j++) {
+ if (pStream->colortbl[j] == crColor) {
+ sprintf(props + strlen(props), "\\brdrcf%u", j);
+ break;
+ }
+ }
+ }
+ }
for (i = 0; i < pFmt->cTabCount; i++)
{
sprintf(props + strlen(props), "\\cellx%d", pFmt->rgxTabs[i] & 0x00FFFFFF);
More information about the wine-cvs
mailing list