Jactry Zeng : riched20: Save reobj in linked list.
Alexandre Julliard
julliard at winehq.org
Mon Apr 16 15:26:25 CDT 2018
Module: wine
Branch: master
Commit: 0154b59c7eb28613342def98dc580083695d8833
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0154b59c7eb28613342def98dc580083695d8833
Author: Jactry Zeng <jzeng at codeweavers.com>
Date: Fri Apr 13 15:56:54 2018 +0800
riched20: Save reobj in linked list.
Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/riched20/caret.c | 32 ++++++++++++++++++++++++++++++--
dlls/riched20/editor.c | 1 +
dlls/riched20/editor.h | 2 +-
dlls/riched20/editstr.h | 9 ++++++++-
dlls/riched20/list.c | 6 +++++-
dlls/riched20/richole.c | 30 +++++++++++++++---------------
dlls/riched20/run.c | 2 +-
dlls/riched20/writer.c | 6 +++---
8 files changed, 64 insertions(+), 24 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index d676a1b..1d35696 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -471,12 +471,26 @@ ME_InternalInsertTextFromCursor(ME_TextEditor *editor, int nCursor,
return ME_InsertRunAtCursor(editor, p, style, str, len, flags);
}
+static struct re_object* create_re_object(const REOBJECT *reo)
+{
+ struct re_object *reobj = heap_alloc(sizeof(*reobj));
+
+ if (!reobj)
+ {
+ WARN("Fail to allocate re_object.\n");
+ return NULL;
+ }
+ ME_CopyReObject(&reobj->obj, reo);
+ return reobj;
+}
void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor)
{
ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor);
ME_DisplayItem *di;
WCHAR space = ' ';
+ ME_DisplayItem *di_prev = NULL;
+ struct re_object *reobj_prev = NULL;
/* FIXME no no no */
if (ME_IsSelection(editor))
@@ -484,8 +498,22 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur
di = ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle,
MERF_GRAPHICS);
- di->member.run.ole_obj = heap_alloc(sizeof(*reo));
- ME_CopyReObject(di->member.run.ole_obj, reo);
+ di->member.run.reobj = create_re_object(reo);
+
+ di_prev = di;
+ while (ME_PrevRun(NULL, &di_prev, TRUE))
+ {
+ if (di_prev->member.run.reobj)
+ {
+ reobj_prev = di_prev->member.run.reobj;
+ break;
+ }
+ }
+ if (reobj_prev)
+ list_add_after(&reobj_prev->entry, &di->member.run.reobj->entry);
+ else
+ list_add_head(&editor->reobj_list, &di->member.run.reobj->entry);
+
ME_ReleaseStyle(pStyle);
}
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index c442512..c57d3ea 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3113,6 +3113,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed->wheel_remain = 0;
list_init( &ed->style_list );
+ list_init( &ed->reobj_list );
OleInitialize(NULL);
return ed;
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 0db5326..1a9bec3 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -232,7 +232,7 @@ LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *p
void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, BOOL selected) DECLSPEC_HIDDEN;
void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN;
void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src) DECLSPEC_HIDDEN;
-void ME_DeleteReObject(REOBJECT* reo) DECLSPEC_HIDDEN;
+void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN;
void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN;
/* editor.c */
diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
index a37c4de..206ce85 100644
--- a/dlls/riched20/editstr.h
+++ b/dlls/riched20/editstr.h
@@ -153,6 +153,12 @@ typedef enum {
struct tagME_DisplayItem;
+struct re_object
+{
+ struct list entry;
+ REOBJECT obj;
+};
+
typedef struct tagME_Run
{
ME_Style *style;
@@ -163,7 +169,7 @@ typedef struct tagME_Run
int nFlags;
int nAscent, nDescent; /* pixels above/below baseline */
POINT pt; /* relative to para's position */
- REOBJECT *ole_obj; /* FIXME: should be a union with strText (at least) */
+ struct re_object *reobj; /* FIXME: should be a union with strText (at least) */
SCRIPT_ANALYSIS script_analysis;
int num_glyphs, max_glyphs;
@@ -436,6 +442,7 @@ typedef struct tagME_TextEditor
BOOL bMouseCaptured;
int wheel_remain;
struct list style_list;
+ struct list reobj_list;
} ME_TextEditor;
typedef struct tagME_Context
diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c
index 8c4f0de..ba35a90 100644
--- a/dlls/riched20/list.c
+++ b/dlls/riched20/list.c
@@ -169,7 +169,11 @@ void ME_DestroyDisplayItem(ME_DisplayItem *item)
if (item->type==diRun)
{
- if (item->member.run.ole_obj) ME_DeleteReObject(item->member.run.ole_obj);
+ if (item->member.run.reobj)
+ {
+ list_remove(&item->member.run.reobj->entry);
+ ME_DeleteReObject(item->member.run.reobj);
+ }
heap_free( item->member.run.glyphs );
heap_free( item->member.run.clusters );
ME_ReleaseStyle(item->member.run.style);
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index c19a2e7..ef985fe 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -5284,11 +5284,11 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
ENHMETAHEADER emh;
assert(run->nFlags & MERF_GRAPHICS);
- assert(run->ole_obj);
+ assert(run->reobj);
- if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
+ if (run->reobj->obj.sizel.cx != 0 || run->reobj->obj.sizel.cy != 0)
{
- convert_sizel(c, &run->ole_obj->sizel, pSize);
+ convert_sizel(c, &run->reobj->obj.sizel, pSize);
if (c->editor->nZoomNumerator != 0)
{
pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
@@ -5297,13 +5297,13 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
return;
}
- if (!run->ole_obj->poleobj)
+ if (!run->reobj->obj.poleobj)
{
pSize->cx = pSize->cy = 0;
return;
}
- if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
+ if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
{
FIXME("Query Interface IID_IDataObject failed!\n");
pSize->cx = pSize->cy = 0;
@@ -5366,13 +5366,13 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
RECT rc;
assert(run->nFlags & MERF_GRAPHICS);
- assert(run->ole_obj);
- if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
+ assert(run->reobj);
+ if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
{
FIXME("Couldn't get interface\n");
return;
}
- has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
+ has_size = run->reobj->obj.sizel.cx != 0 || run->reobj->obj.sizel.cy != 0;
fmt.cfFormat = CF_BITMAP;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
@@ -5399,7 +5399,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
old_bm = SelectObject(hMemDC, stgm.u.hBitmap);
if (has_size)
{
- convert_sizel(c, &run->ole_obj->sizel, &sz);
+ convert_sizel(c, &run->reobj->obj.sizel, &sz);
} else {
sz.cx = dibsect.dsBm.bmWidth;
sz.cy = dibsect.dsBm.bmHeight;
@@ -5419,7 +5419,7 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
if (has_size)
{
- convert_sizel(c, &run->ole_obj->sizel, &sz);
+ convert_sizel(c, &run->reobj->obj.sizel, &sz);
} else {
sz.cx = emh.rclBounds.right - emh.rclBounds.left;
sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
@@ -5447,12 +5447,12 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
}
-void ME_DeleteReObject(REOBJECT* reo)
+void ME_DeleteReObject(struct re_object *reobj)
{
- if (reo->poleobj) IOleObject_Release(reo->poleobj);
- if (reo->pstg) IStorage_Release(reo->pstg);
- if (reo->polesite) IOleClientSite_Release(reo->polesite);
- heap_free(reo);
+ if (reobj->obj.poleobj) IOleObject_Release(reobj->obj.poleobj);
+ if (reobj->obj.pstg) IStorage_Release(reobj->obj.pstg);
+ if (reobj->obj.polesite) IOleClientSite_Release(reobj->obj.polesite);
+ heap_free(reobj);
}
void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 098c4f8..73adc7e 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -290,7 +290,7 @@ ME_DisplayItem *ME_MakeRun(ME_Style *s, int nFlags)
{
ME_DisplayItem *item = ME_MakeDI(diRun);
item->member.run.style = s;
- item->member.run.ole_obj = NULL;
+ item->member.run.reobj = NULL;
item->member.run.nFlags = nFlags;
item->member.run.nCharOfs = -1;
item->member.run.len = 0;
diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c
index aad2e44..b1e99d6 100644
--- a/dlls/riched20/writer.c
+++ b/dlls/riched20/writer.c
@@ -947,7 +947,7 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream,
SIZE goal, pic;
ME_Context c;
- hr = IOleObject_QueryInterface( run->ole_obj->poleobj, &IID_IDataObject, (void **)&data );
+ hr = IOleObject_QueryInterface( run->reobj->obj.poleobj, &IID_IDataObject, (void **)&data );
if (FAILED(hr)) return FALSE;
ME_InitContext( &c, editor, ITextHost_TxGetDC( editor->texthost ) );
@@ -975,8 +975,8 @@ static BOOL stream_out_graphics( ME_TextEditor *editor, ME_OutStream *stream,
emf_bits->szlMillimeters.cy * c.dpi.cy * 10 );
/* convert goal size to twips */
- goal.cx = MulDiv( run->ole_obj->sizel.cx, 144, 254 );
- goal.cy = MulDiv( run->ole_obj->sizel.cy, 144, 254 );
+ goal.cx = MulDiv( run->reobj->obj.sizel.cx, 144, 254 );
+ goal.cy = MulDiv( run->reobj->obj.sizel.cy, 144, 254 );
if (!ME_StreamOutPrint( stream, "{\\*\\shppict{\\pict\\emfblip\\picw%d\\pich%d\\picwgoal%d\\pichgoal%d\n",
pic.cx, pic.cy, goal.cx, goal.cy ))
More information about the wine-cvs
mailing list