Commit c6ea6cae authored by Phil Krylov's avatar Phil Krylov Committed by Alexandre Julliard

Initial implementation of EM_STREAMOUT and RTF writer.

parent e3d8bf9d
......@@ -20,7 +20,8 @@ C_SRCS = \
string.c \
style.c \
undo.c \
wrap.c
wrap.c \
writer.c
@MAKE_DLL_RULES@
......
......@@ -461,6 +461,37 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
return 0;
}
ME_DisplayItem *
ME_FindItemAtOffset(ME_TextEditor *editor, ME_DIType nItemType, int nOffset, int *nItemOffset)
{
ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
while (item && item->member.para.next_para->member.para.nCharOfs <= nOffset)
item = ME_FindItemFwd(item, diParagraph);
if (!item)
return item;
nOffset -= item->member.para.nCharOfs;
if (nItemType == diParagraph) {
if (nItemOffset)
*nItemOffset = nOffset;
return item;
}
do {
item = ME_FindItemFwd(item, diRun);
} while (item && (item->member.run.nCharOfs + ME_StrLen(item->member.run.strText) <= nOffset));
if (item) {
nOffset -= item->member.run.nCharOfs;
if (nItemOffset)
*nItemOffset = nOffset;
}
return item;
}
ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor);
HDC hDC;
......@@ -586,7 +617,6 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
UNSUPPORTED_MSG(EM_SETUNDOLIMIT)
UNSUPPORTED_MSG(EM_SETWORDBREAKPROC)
UNSUPPORTED_MSG(EM_SETWORDBREAKPROCEX)
UNSUPPORTED_MSG(EM_STREAMOUT)
UNSUPPORTED_MSG(WM_SETFONT)
UNSUPPORTED_MSG(WM_PASTE)
UNSUPPORTED_MSG(WM_STYLECHANGING)
......@@ -597,6 +627,8 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
case EM_STREAMIN:
return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam);
case EM_STREAMOUT:
return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam);
case WM_GETDLGCODE:
{
UINT code = DLGC_WANTCHARS|DLGC_WANTARROWS;
......@@ -999,26 +1031,18 @@ int ME_CountParagraphsBetween(ME_TextEditor *editor, int from, int to)
return i;
}
int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, int bCRLF)
{
ME_DisplayItem *item = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
ME_DisplayItem *item = ME_FindItemAtOffset(editor, diRun, nStart, &nStart);
int nWritten = 0;
while(item && item->member.para.next_para->member.para.nCharOfs <= nStart)
item = ME_FindItemFwd(item, diParagraph);
if (!item) {
*buffer = L'\0';
return 0;
}
nStart -= item->member.para.nCharOfs;
do {
item = ME_FindItemFwd(item, diRun);
} while(item && (item->member.run.nCharOfs + ME_StrLen(item->member.run.strText) <= nStart));
assert(item);
nStart -= item->member.run.nCharOfs;
if (nStart)
{
int nLen = ME_StrLen(item->member.run.strText) - nStart;
......
......@@ -206,7 +206,11 @@ void ME_Undo(ME_TextEditor *editor);
void ME_Redo(ME_TextEditor *editor);
void ME_EmptyUndoStack(ME_TextEditor *editor);
int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, BOOL bCRLF);
ME_DisplayItem *ME_FindItemAtOffset(ME_TextEditor *editor, ME_DIType nItemType, int nOffset, int *nItemOffset);
extern int me_debug;
extern HANDLE me_heap;
extern void DoWrap(ME_TextEditor *editor);
/* writer.c */
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream);
......@@ -192,6 +192,27 @@ typedef enum {
umAddBackToUndo
} ME_UndoMode;
typedef struct tagME_FontTableItem {
BYTE bCharSet;
WCHAR *szFaceName;
} ME_FontTableItem;
#define STREAMOUT_BUFFER_SIZE 4096
#define STREAMOUT_FONTTBL_SIZE 8192
#define STREAMOUT_COLORTBL_SIZE 1024
typedef struct tagME_OutStream {
EDITSTREAM *stream;
char buffer[STREAMOUT_BUFFER_SIZE];
UINT pos, written;
UINT nCodePage;
UINT nFontTblLen;
ME_FontTableItem fonttbl[STREAMOUT_FONTTBL_SIZE];
UINT nColorTblLen;
COLORREF colortbl[STREAMOUT_COLORTBL_SIZE];
UINT nDefaultFont;
} ME_OutStream;
typedef struct tagME_FontCacheItem
{
LOGFONTW lfSpecs;
......@@ -224,6 +245,7 @@ typedef struct tagME_TextEditor
int nParagraphs;
int nLastSelStart, nLastSelEnd;
ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE];
ME_OutStream *pStream;
} ME_TextEditor;
typedef struct tagME_Context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment