+ EM_SETCHARFORMAT (partly done, no ANSI)
- EM_SETEDITSTYLE
+ EM_SETEVENTMASK (few notifications supported)
- - EM_SETFONTSIZE
+ + EM_SETFONTSIZE
- EM_SETIMECOLOR 1.0asian
- EM_SETIMEOPTIONS 1.0asian
- EM_SETIMESTATUS
- ES_AUTOHSCROLL
- ES_AUTOVSCROLL
- - ES_CENTER
+ + ES_CENTER
+ ES_DISABLENOSCROLL (scrollbar is always visible)
- ES_EX_NOCALLOLEINIT
- - ES_LEFT
+ + ES_LEFT
- ES_MULTILINE (currently single line controls aren't supported)
- ES_NOIME
- ES_READONLY (I'm not sure if beeping is the proper behaviour)
- - ES_RIGHT
+ + ES_RIGHT
- ES_SAVESEL
- ES_SELFIME
- ES_SUNKEN
ME_Style *style2;
RTFFlushOutputBuffer(info);
/* FIXME too slow ? how come ? */
- style2 = ME_ApplyStyle(info->style, &fmt);
+ style2 = ME_ApplyStyle(info->editor, info->style, &fmt);
ME_ReleaseStyle(info->style);
info->style = style2;
info->styleChanged = TRUE;
PARAFORMAT2 fmt;
fmt.cbSize = sizeof(fmt);
fmt.dwMask = 0;
-
+ fmt.wEffects = 0;
+
switch(info->rtfMinor)
{
case rtfParDef: /* restores default paragraph attributes */
ME_DisplayItem *para = info->editor->pCursors[0].pPara;
PARAFORMAT2 *pFmt = para->member.para.pFmt;
pFmt->rgxTabs[cellNum] &= ~0x00FFFFFF;
- pFmt->rgxTabs[cellNum] = 0x00FFFFFF & info->rtfParam;
+ pFmt->rgxTabs[cellNum] |= 0x00FFFFFF & info->rtfParam;
}
info->tableDef->numCellsDefined++;
break;
return ret;
}
-static void ME_RTFReadPictGroup(RTF_Info *info)
+static void ME_RTFReadShpPictGroup( RTF_Info *info )
{
- SIZEL sz;
- BYTE* buffer = NULL;
- unsigned bufsz, bufidx;
- BOOL flip;
- BYTE val;
- METAFILEPICT mfp;
- HENHMETAFILE hemf;
- HBITMAP hbmp;
- enum gfxkind {gfx_unknown = 0, gfx_enhmetafile, gfx_metafile, gfx_dib} gfx = gfx_unknown;
-
- RTFGetToken (info);
- if (info->rtfClass == rtfEOF)
- return;
- mfp.mm = MM_TEXT;
- /* fetch picture type */
- if (RTFCheckMM (info, rtfPictAttr, rtfWinMetafile))
- {
- mfp.mm = info->rtfParam;
- gfx = gfx_metafile;
- }
- else if (RTFCheckMM (info, rtfPictAttr, rtfDevIndBitmap))
- {
- if (info->rtfParam != 0) FIXME("dibitmap should be 0 (%d)\n", info->rtfParam);
- gfx = gfx_dib;
- }
- else if (RTFCheckMM (info, rtfPictAttr, rtfEmfBlip))
- {
- gfx = gfx_enhmetafile;
- }
- else
- {
- FIXME("%d %d\n", info->rtfMajor, info->rtfMinor);
- goto skip_group;
- }
- sz.cx = sz.cy = 0;
- /* fetch picture attributes */
- for (;;)
- {
- RTFGetToken (info);
- if (info->rtfClass == rtfEOF)
- return;
- if (info->rtfClass == rtfText)
- break;
- if (!RTFCheckCM (info, rtfControl, rtfPictAttr))
- {
- ERR("Expected picture attribute (%d %d)\n",
- info->rtfClass, info->rtfMajor);
- goto skip_group;
- }
- else if (RTFCheckMM (info, rtfPictAttr, rtfPicWid))
+ int level = 1;
+
+ for (;;)
{
- if (gfx == gfx_metafile) mfp.xExt = info->rtfParam;
+ RTFGetToken (info);
+
+ if (info->rtfClass == rtfEOF) return;
+ if (RTFCheckCM( info, rtfGroup, rtfEndGroup ))
+ {
+ if (--level == 0) break;
+ }
+ else if (RTFCheckCM( info, rtfGroup, rtfBeginGroup ))
+ {
+ level++;
+ }
+ else
+ {
+ RTFRouteToken( info );
+ if (RTFCheckCM( info, rtfGroup, rtfEndGroup ))
+ level--;
+ }
}
- else if (RTFCheckMM (info, rtfPictAttr, rtfPicHt))
+
+ RTFRouteToken( info ); /* feed "}" back to router */
+ return;
+}
+
+static DWORD read_hex_data( RTF_Info *info, BYTE **out )
+{
+ DWORD read = 0, size = 1024;
+ BYTE *buf, val;
+ BOOL flip;
+
+ *out = NULL;
+
+ if (info->rtfClass != rtfText)
{
- if (gfx == gfx_metafile) mfp.yExt = info->rtfParam;
+ ERR("Called with incorrect token\n");
+ return 0;
}
- else if (RTFCheckMM (info, rtfPictAttr, rtfPicGoalWid))
- sz.cx = info->rtfParam;
- else if (RTFCheckMM (info, rtfPictAttr, rtfPicGoalHt))
- sz.cy = info->rtfParam;
- else
- FIXME("Non supported attribute: %d %d %d\n", info->rtfClass, info->rtfMajor, info->rtfMinor);
- }
- /* fetch picture data */
- bufsz = 1024;
- bufidx = 0;
- buffer = HeapAlloc(GetProcessHeap(), 0, bufsz);
- val = info->rtfMajor;
- for (flip = TRUE;; flip = !flip)
- {
- RTFGetToken (info);
- if (info->rtfClass == rtfEOF)
+
+ buf = HeapAlloc( GetProcessHeap(), 0, size );
+ if (!buf) return 0;
+
+ val = info->rtfMajor;
+ for (flip = TRUE;; flip = !flip)
{
- HeapFree(GetProcessHeap(), 0, buffer);
- return; /* Warn ?? */
+ RTFGetToken( info );
+ if (info->rtfClass == rtfEOF)
+ {
+ HeapFree( GetProcessHeap(), 0, buf );
+ return 0;
+ }
+ if (info->rtfClass != rtfText) break;
+ if (flip)
+ {
+ if (read >= size)
+ {
+ size *= 2;
+ buf = HeapReAlloc( GetProcessHeap(), 0, buf, size );
+ if (!buf) return 0;
+ }
+ buf[read++] = RTFCharToHex(val) * 16 + RTFCharToHex(info->rtfMajor);
+ }
+ else
+ val = info->rtfMajor;
}
- if (RTFCheckCM(info, rtfGroup, rtfEndGroup))
- break;
- if (info->rtfClass != rtfText) goto skip_group;
- if (flip)
+ if (flip) FIXME("wrong hex string\n");
+
+ *out = buf;
+ return read;
+}
+
+static void ME_RTFReadPictGroup(RTF_Info *info)
+{
+ SIZEL sz;
+ BYTE *buffer = NULL;
+ DWORD size = 0;
+ METAFILEPICT mfp;
+ HENHMETAFILE hemf;
+ HBITMAP hbmp;
+ enum gfxkind {gfx_unknown = 0, gfx_enhmetafile, gfx_metafile, gfx_dib} gfx = gfx_unknown;
+ int level = 1;
+
+ mfp.mm = MM_TEXT;
+ sz.cx = sz.cy = 0;
+
+ for (;;)
{
- if (bufidx >= bufsz &&
- !(buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, bufsz += 1024)))
- goto skip_group;
- buffer[bufidx++] = RTFCharToHex(val) * 16 + RTFCharToHex(info->rtfMajor);
+ RTFGetToken( info );
+
+ if (info->rtfClass == rtfText)
+ {
+ if (level == 1)
+ {
+ if (!buffer)
+ size = read_hex_data( info, &buffer );
+ }
+ else
+ {
+ RTFSkipGroup( info );
+ }
+ } /* We potentially have a new token so fall through. */
+
+ if (info->rtfClass == rtfEOF) return;
+
+ if (RTFCheckCM( info, rtfGroup, rtfEndGroup ))
+ {
+ if (--level == 0) break;
+ continue;
+ }
+ if (RTFCheckCM( info, rtfGroup, rtfBeginGroup ))
+ {
+ level++;
+ continue;
+ }
+ if (!RTFCheckCM( info, rtfControl, rtfPictAttr ))
+ {
+ RTFRouteToken( info );
+ if (RTFCheckCM( info, rtfGroup, rtfEndGroup ))
+ level--;
+ continue;
+ }
+
+ if (RTFCheckMM( info, rtfPictAttr, rtfWinMetafile ))
+ {
+ mfp.mm = info->rtfParam;
+ gfx = gfx_metafile;
+ }
+ else if (RTFCheckMM( info, rtfPictAttr, rtfDevIndBitmap ))
+ {
+ if (info->rtfParam != 0) FIXME("dibitmap should be 0 (%d)\n", info->rtfParam);
+ gfx = gfx_dib;
+ }
+ else if (RTFCheckMM( info, rtfPictAttr, rtfEmfBlip ))
+ gfx = gfx_enhmetafile;
+ else if (RTFCheckMM( info, rtfPictAttr, rtfPicWid ))
+ mfp.xExt = info->rtfParam;
+ else if (RTFCheckMM( info, rtfPictAttr, rtfPicHt ))
+ mfp.yExt = info->rtfParam;
+ else if (RTFCheckMM( info, rtfPictAttr, rtfPicGoalWid ))
+ sz.cx = info->rtfParam;
+ else if (RTFCheckMM( info, rtfPictAttr, rtfPicGoalHt ))
+ sz.cy = info->rtfParam;
+ else
+ FIXME("Non supported attribute: %d %d %d\n", info->rtfClass, info->rtfMajor, info->rtfMinor);
}
- else
- val = info->rtfMajor;
- }
- if (flip) FIXME("wrong hex string\n");
- switch (gfx)
- {
- case gfx_enhmetafile:
- if ((hemf = SetEnhMetaFileBits(bufidx, buffer)))
- ME_RTFInsertOleObject(info, hemf, NULL, &sz);
- break;
- case gfx_metafile:
- if ((hemf = SetWinMetaFileBits(bufidx, buffer, NULL, &mfp)))
- ME_RTFInsertOleObject(info, hemf, NULL, &sz);
- break;
- case gfx_dib:
+ if (buffer)
{
- BITMAPINFO* bi = (BITMAPINFO*)buffer;
- HDC hdc = GetDC(0);
- unsigned nc = bi->bmiHeader.biClrUsed;
-
- /* not quite right, especially for bitfields type of compression */
- if (!nc && bi->bmiHeader.biBitCount <= 8)
- nc = 1 << bi->bmiHeader.biBitCount;
- if ((hbmp = CreateDIBitmap(hdc, &bi->bmiHeader,
- CBM_INIT, (char*)(bi + 1) + nc * sizeof(RGBQUAD),
- bi, DIB_RGB_COLORS)))
- ME_RTFInsertOleObject(info, NULL, hbmp, &sz);
- ReleaseDC(0, hdc);
+ switch (gfx)
+ {
+ case gfx_enhmetafile:
+ if ((hemf = SetEnhMetaFileBits( size, buffer )))
+ ME_RTFInsertOleObject( info, hemf, NULL, &sz );
+ break;
+ case gfx_metafile:
+ if ((hemf = SetWinMetaFileBits( size, buffer, NULL, &mfp )))
+ ME_RTFInsertOleObject( info, hemf, NULL, &sz );
+ break;
+ case gfx_dib:
+ {
+ BITMAPINFO *bi = (BITMAPINFO*)buffer;
+ HDC hdc = GetDC(0);
+ unsigned nc = bi->bmiHeader.biClrUsed;
+
+ /* not quite right, especially for bitfields type of compression */
+ if (!nc && bi->bmiHeader.biBitCount <= 8)
+ nc = 1 << bi->bmiHeader.biBitCount;
+ if ((hbmp = CreateDIBitmap( hdc, &bi->bmiHeader,
+ CBM_INIT, (char*)(bi + 1) + nc * sizeof(RGBQUAD),
+ bi, DIB_RGB_COLORS)) )
+ ME_RTFInsertOleObject( info, NULL, hbmp, &sz );
+ ReleaseDC( 0, hdc );
+ break;
+ }
+ default:
+ break;
+ }
}
- break;
- default:
- break;
- }
- HeapFree(GetProcessHeap(), 0, buffer);
- RTFRouteToken (info); /* feed "}" back to router */
- return;
-skip_group:
- HeapFree(GetProcessHeap(), 0, buffer);
- RTFSkipGroup(info);
- RTFRouteToken(info); /* feed "}" back to router */
+ HeapFree( GetProcessHeap(), 0, buffer );
+ RTFRouteToken( info ); /* feed "}" back to router */
+ return;
}
/* for now, lookup the \result part and use it, whatever the object */
ME_GetTextLength(editor), FALSE);
from = to = 0;
ME_ClearTempStyle(editor);
- ME_SetDefaultParaFormat(editor->pCursors[0].pPara->member.para.pFmt);
+ ME_SetDefaultParaFormat(editor, editor->pCursors[0].pPara->member.para.pFmt);
}
WriterInit(&parser);
RTFInit(&parser);
RTFSetReadHook(&parser, ME_RTFReadHook);
+ RTFSetDestinationCallback(&parser, rtfShpPict, ME_RTFReadShpPictGroup);
RTFSetDestinationCallback(&parser, rtfPict, ME_RTFReadPictGroup);
RTFSetDestinationCallback(&parser, rtfObject, ME_RTFReadObjectGroup);
if (!parser.editor->bEmulateVersion10) /* v4.1 */
ME_InsertTextFromCursor(editor, 0, &endl, 1,
editor->pCursors[0].pRun->member.run.style);
para = editor->pBuffer->pFirst->member.para.next_para;
- ME_SetDefaultParaFormat(para->member.para.pFmt);
+ ME_SetDefaultParaFormat(editor, para->member.para.pFmt);
para->member.para.nFlags = MEPF_REWRAP;
editor->pCursors[0].pPara = para;
editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
return TRUE;
}
-ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
+ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD csStyle)
{
ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor);
int i;
ed->reOle = NULL;
ed->bEmulateVersion10 = bEmulateVersion10;
ed->styleFlags = 0;
+ ed->alignStyle = PFA_LEFT;
+ if (csStyle & ES_RIGHT)
+ ed->alignStyle = PFA_RIGHT;
+ if (csStyle & ES_CENTER)
+ ed->alignStyle = PFA_CENTER;
ITextHost_TxGetPropertyBits(texthost,
(TXTBIT_RICHTEXT|TXTBIT_MULTILINE|
TXTBIT_READONLY|TXTBIT_USEPASSWORD|
ed->wheel_remain = 0;
+ list_init( &ed->style_list );
OleInitialize(NULL);
return ed;
{
ME_DisplayItem *pFirst = editor->pBuffer->pFirst;
ME_DisplayItem *p = pFirst, *pNext = NULL;
+ ME_Style *s, *cursor2;
int i;
ME_ClearTempStyle(editor);
ME_DestroyDisplayItem(p);
p = pNext;
}
+
+ LIST_FOR_EACH_ENTRY_SAFE( s, cursor2, &editor->style_list, ME_Style, entry )
+ ME_DestroyStyle( s );
+
ME_ReleaseStyle(editor->pBuffer->pDefaultStyle);
for (i=0; i<HFONT_CACHE_SIZE; i++)
{
UNSUPPORTED_MSG(EM_SELECTIONTYPE)
UNSUPPORTED_MSG(EM_SETBIDIOPTIONS)
UNSUPPORTED_MSG(EM_SETEDITSTYLE)
- UNSUPPORTED_MSG(EM_SETFONTSIZE)
UNSUPPORTED_MSG(EM_SETLANGOPTIONS)
UNSUPPORTED_MSG(EM_SETMARGINS)
UNSUPPORTED_MSG(EM_SETPALETTE)
return settings;
}
+ case EM_SETFONTSIZE:
+ {
+ CHARFORMAT2W cf;
+ LONG tmp_size, size;
+ BOOL is_increase = ((LONG)wParam > 0);
+
+ if (editor->mode & TM_PLAINTEXT)
+ return FALSE;
+
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_SIZE;
+ ME_GetSelectionCharFormat(editor, &cf);
+ tmp_size = (cf.yHeight / 20) + wParam;
+
+ if (tmp_size <= 1)
+ size = 1;
+ else if (tmp_size > 12 && tmp_size < 28 && tmp_size % 2)
+ size = tmp_size + (is_increase ? 1 : -1);
+ else if (tmp_size > 28 && tmp_size < 36)
+ size = is_increase ? 36 : 28;
+ else if (tmp_size > 36 && tmp_size < 48)
+ size = is_increase ? 48 : 36;
+ else if (tmp_size > 48 && tmp_size < 72)
+ size = is_increase ? 72 : 48;
+ else if (tmp_size > 72 && tmp_size < 80)
+ size = is_increase ? 80 : 72;
+ else if (tmp_size > 80 && tmp_size < 1638)
+ size = 10 * (is_increase ? (tmp_size / 10 + 1) : (tmp_size / 10));
+ else if (tmp_size >= 1638)
+ size = 1638;
+ else
+ size = tmp_size;
+
+ cf.yHeight = size * 20; /* convert twips to points */
+ ME_SetSelectionCharFormat(editor, &cf);
+ ME_CommitUndo(editor);
+ ME_WrapMarkedParagraphs(editor);
+ ME_UpdateScrollBar(editor);
+ ME_Repaint(editor);
+
+ return TRUE;
+ }
case EM_SETOPTIONS:
{
/* these flags are equivalent to ES_* counterparts, except for
if (!wParam)
wParam = (WPARAM)GetStockObject(SYSTEM_FONT);
- GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf);
+
+ if (!GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf))
+ return 0;
+
hDC = ITextHost_TxGetDC(editor->texthost);
ME_CharFormatFromLogFont(hDC, &lf, &fmt);
ITextHost_TxReleaseDC(editor->texthost, hDC);