From e917285fba29df3e0262eaba9f4903a0ad85f298 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 20 Jul 2015 22:53:23 +0000 Subject: [PATCH] [RICHED20] Sync with Wine Staging 1.7.47. CORE-9924 svn path=/trunk/; revision=68495 --- reactos/dll/win32/riched20/CMakeLists.txt | 8 + reactos/dll/win32/riched20/editor.c | 220 +- reactos/dll/win32/riched20/editor.h | 3 + reactos/dll/win32/riched20/editstr.h | 2 +- reactos/dll/win32/riched20/res.h | 2 +- reactos/dll/win32/riched20/riched_tom.idl | 723 +++ reactos/dll/win32/riched20/riched_tom.rgs | 56 + reactos/dll/win32/riched20/richole.c | 5807 +++++++++++++-------- reactos/dll/win32/riched20/run.c | 1 + reactos/dll/win32/riched20/txtsrv.c | 4 +- reactos/dll/win32/riched20/version.rc | 3 + reactos/dll/win32/riched20/writer.c | 28 +- reactos/media/doc/README.WINE | 2 +- 13 files changed, 4587 insertions(+), 2272 deletions(-) create mode 100644 reactos/dll/win32/riched20/riched_tom.idl create mode 100644 reactos/dll/win32/riched20/riched_tom.rgs diff --git a/reactos/dll/win32/riched20/CMakeLists.txt b/reactos/dll/win32/riched20/CMakeLists.txt index 58a9d68cb8b..c53d071a351 100644 --- a/reactos/dll/win32/riched20/CMakeLists.txt +++ b/reactos/dll/win32/riched20/CMakeLists.txt @@ -42,7 +42,15 @@ list(APPEND ADDITIONAL_SOURCE version.rc ${CMAKE_CURRENT_BINARY_DIR}/riched20.def) +list(APPEND riched20_rc_deps + ${CMAKE_CURRENT_SOURCE_DIR}/riched_tom.rgs + ${CMAKE_CURRENT_BINARY_DIR}/riched_tom.tlb) + +set_source_files_properties(version.rc PROPERTIES OBJECT_DEPENDS "${riched20_rc_deps}") + add_library(riched20 SHARED ${SOURCE} ${ADDITIONAL_SOURCE}) +add_typelib(riched_tom.idl) +add_dependencies(riched20 stdole2) set_module_type(riched20 win32dll) target_link_libraries(riched20 wine uuid) add_importlibs(riched20 ole32 oleaut32 usp10 imm32 user32 gdi32 msvcrt kernel32 ntdll) diff --git a/reactos/dll/win32/riched20/editor.c b/reactos/dll/win32/riched20/editor.c index 92eb0206381..8d995f7446f 100644 --- a/reactos/dll/win32/riched20/editor.c +++ b/reactos/dll/win32/riched20/editor.c @@ -227,6 +227,7 @@ #include "editor.h" #include +#include #include "rtf.h" #include "res.h" @@ -1704,7 +1705,7 @@ ME_StreamInRTFString(ME_TextEditor *editor, BOOL selection, char *string) data.pos = 0; es.dwCookie = (DWORD_PTR)&data; es.pfnCallback = ME_ReadFromRTFString; - ME_StreamIn(editor, SF_RTF | (selection ? SFF_SELECTION : 0), &es, FALSE); + ME_StreamIn(editor, SF_RTF | (selection ? SFF_SELECTION : 0), &es, TRUE); } @@ -1868,7 +1869,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH if (nCurEnd == 0) { ME_PrevRun(&pCurPara, &pCurItem); - nCurEnd = pCurItem->member.run.len + nMatched; + nCurEnd = pCurItem->member.run.len; } while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurEnd - nMatched - 1 ), @@ -2923,6 +2924,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) UnregisterClassW(REComboBox20W, 0); LookupCleanup(); HeapDestroy (me_heap); + release_typelib(); break; } return TRUE; @@ -3129,13 +3131,108 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM } } +void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) +{ + int from, to, nStartCursor; + ME_Style *style; + + nStartCursor = ME_GetSelectionOfs(editor, &from, &to); + style = ME_GetSelectionInsertStyle(editor); + ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE); + ME_InsertTextFromCursor(editor, 0, str, len, style); + ME_ReleaseStyle(style); + /* drop temporary style if line end */ + /* + * FIXME question: does abc\n mean: put abc, + * clear temp style, put \n? (would require a change) + */ + if (len>0 && str[len-1] == '\n') + ME_ClearTempStyle(editor); + ME_CommitUndo(editor); + ME_UpdateSelectionLinkAttribute(editor); + if (!can_undo) + ME_EmptyUndoStack(editor); + ME_UpdateRepaint(editor, FALSE); +} + +static void ME_SetText(ME_TextEditor *editor, void *text, BOOL unicode) +{ + LONG codepage = unicode ? CP_UNICODE : CP_ACP; + int textLen; + + LPWSTR wszText = ME_ToUnicode(codepage, text, &textLen); + + if (textLen > 0) + { + int len = -1; + + /* uses default style! */ + if (!(editor->styleFlags & ES_MULTILINE)) + { + WCHAR *p = wszText; + + while (*p != '\0' && *p != '\r' && *p != '\n') p++; + len = p - wszText; + } + ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle); + } + ME_EndToUnicode(codepage, wszText); +} + +static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam, BOOL unicode) +{ + CREATESTRUCTW *createW = (CREATESTRUCTW*)lParam; + CREATESTRUCTA *createA = (CREATESTRUCTA*)lParam; + void *text = NULL; + INT max; + + if (lParam) + text = unicode ? (void*)createW->lpszName : (void*)createA->lpszName; + + ME_SetDefaultFormatRect(editor); + + max = (editor->styleFlags & ES_DISABLENOSCROLL) ? 1 : 0; + if (~editor->styleFlags & ES_DISABLENOSCROLL || editor->styleFlags & WS_VSCROLL) + ITextHost_TxSetScrollRange(editor->texthost, SB_VERT, 0, max, TRUE); + + if (~editor->styleFlags & ES_DISABLENOSCROLL || editor->styleFlags & WS_HSCROLL) + ITextHost_TxSetScrollRange(editor->texthost, SB_HORZ, 0, max, TRUE); + + if (editor->styleFlags & ES_DISABLENOSCROLL) + { + if (editor->styleFlags & WS_VSCROLL) + { + ITextHost_TxEnableScrollBar(editor->texthost, SB_VERT, ESB_DISABLE_BOTH); + ITextHost_TxShowScrollBar(editor->texthost, SB_VERT, TRUE); + } + if (editor->styleFlags & WS_HSCROLL) + { + ITextHost_TxEnableScrollBar(editor->texthost, SB_HORZ, ESB_DISABLE_BOTH); + ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ, TRUE); + } + } + + if (text) + { + ME_SetText(editor, text, unicode); + ME_SetCursorToStart(editor, &editor->pCursors[0]); + ME_SetCursorToStart(editor, &editor->pCursors[1]); + } + + ME_CommitUndo(editor); + ME_WrapMarkedParagraphs(editor); + ME_MoveCaret(editor); + return 0; +} + + #define UNSUPPORTED_MSG(e) \ case e: \ FIXME(#e ": stub\n"); \ *phresult = S_FALSE; \ return 0; -/* Handle messages for windowless and windoweded richedit controls. +/* Handle messages for windowless and windowed richedit controls. * * The LRESULT that is returned is a return value for window procs, * and the phresult parameter is the COM return code needed by the @@ -3604,31 +3701,14 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, } case EM_REPLACESEL: { - int from, to, nStartCursor; - ME_Style *style; int len = 0; LONG codepage = unicode ? CP_UNICODE : CP_ACP; LPWSTR wszText = ME_ToUnicode(codepage, (void *)lParam, &len); + TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText)); - nStartCursor = ME_GetSelectionOfs(editor, &from, &to); - style = ME_GetSelectionInsertStyle(editor); - ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE); - ME_InsertTextFromCursor(editor, 0, wszText, len, style); - ME_ReleaseStyle(style); - /* drop temporary style if line end */ - /* - * FIXME question: does abc\n mean: put abc, - * clear temp style, put \n? (would require a change) - */ - if (len>0 && wszText[len-1] == '\n') - ME_ClearTempStyle(editor); + ME_ReplaceSel(editor, !!wParam, wszText, len); ME_EndToUnicode(codepage, wszText); - ME_CommitUndo(editor); - ME_UpdateSelectionLinkAttribute(editor); - if (!wParam) - ME_EmptyUndoStack(editor); - ME_UpdateRepaint(editor, FALSE); return len; } case EM_SCROLLCARET: @@ -3677,28 +3757,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ME_StreamInRTFString(editor, 0, (char *)lParam); } else - { - int textLen; - LONG codepage = unicode ? CP_UNICODE : CP_ACP; - LPWSTR wszText = ME_ToUnicode(codepage, (void *)lParam, &textLen); - TRACE("WM_SETTEXT - %s\n", debugstr_w(wszText)); /* debugstr_w() */ - if (textLen > 0) - { - int len = -1; - - /* uses default style! */ - if (!(editor->styleFlags & ES_MULTILINE)) - { - WCHAR * p; - - p = wszText; - while (*p != '\0' && *p != '\r' && *p != '\n') p++; - len = p - wszText; - } - ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle); - } - ME_EndToUnicode(codepage, wszText); - } + ME_SetText(editor, (void*)lParam, unicode); } else TRACE("WM_SETTEXT - NULL\n"); @@ -4053,66 +4112,16 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y ); } case WM_CREATE: - { - void *text = NULL; - INT max; - - ME_SetDefaultFormatRect(editor); - - max = (editor->styleFlags & ES_DISABLENOSCROLL) ? 1 : 0; - if (~editor->styleFlags & ES_DISABLENOSCROLL || editor->styleFlags & WS_VSCROLL) - ITextHost_TxSetScrollRange(editor->texthost, SB_VERT, 0, max, TRUE); - - if (~editor->styleFlags & ES_DISABLENOSCROLL || editor->styleFlags & WS_HSCROLL) - ITextHost_TxSetScrollRange(editor->texthost, SB_HORZ, 0, max, TRUE); - - if (editor->styleFlags & ES_DISABLENOSCROLL) - { - if (editor->styleFlags & WS_VSCROLL) - { - ITextHost_TxEnableScrollBar(editor->texthost, SB_VERT, ESB_DISABLE_BOTH); - ITextHost_TxShowScrollBar(editor->texthost, SB_VERT, TRUE); - } - if (editor->styleFlags & WS_HSCROLL) - { - ITextHost_TxEnableScrollBar(editor->texthost, SB_HORZ, ESB_DISABLE_BOTH); - ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ, TRUE); - } - } - - if (lParam) - { - text = (unicode ? (void*)((CREATESTRUCTW*)lParam)->lpszName - : (void*)((CREATESTRUCTA*)lParam)->lpszName); - } - if (text) - { - WCHAR *textW; - int len; - LONG codepage = unicode ? CP_UNICODE : CP_ACP; - textW = ME_ToUnicode(codepage, text, &len); - if (!(editor->styleFlags & ES_MULTILINE)) - { - len = 0; - while(textW[len] != '\0' && textW[len] != '\r' && textW[len] != '\n') - len++; - } - ME_InsertTextFromCursor(editor, 0, textW, len, editor->pBuffer->pDefaultStyle); - ME_EndToUnicode(codepage, textW); - ME_SetCursorToStart(editor, &editor->pCursors[0]); - ME_SetCursorToStart(editor, &editor->pCursors[1]); - } - - ME_CommitUndo(editor); - ME_WrapMarkedParagraphs(editor); - ME_MoveCaret(editor); - return 0; - } + return ME_WmCreate(editor, lParam, unicode); case WM_DESTROY: ME_DestroyEditor(editor); return 0; case WM_SETCURSOR: { + POINT cursor_pos; + if (wParam == (WPARAM)editor->hWnd && GetCursorPos(&cursor_pos) && + ScreenToClient(editor->hWnd, &cursor_pos)) + ME_LinkNotify(editor, msg, 0, MAKELPARAM(cursor_pos.x, cursor_pos.y)); return ME_SetCursor(editor); } case WM_LBUTTONDBLCLK: @@ -4127,7 +4136,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, ME_CalculateClickCount(editor, msg, wParam, lParam)); ITextHost_TxSetCapture(editor->texthost, TRUE); editor->bMouseCaptured = TRUE; - ME_LinkNotify(editor,msg,wParam,lParam); + ME_LinkNotify(editor, msg, wParam, lParam); if (!ME_SetCursor(editor)) goto do_default; break; } @@ -4137,7 +4146,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, return 0; if (editor->bMouseCaptured) ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)); - ME_LinkNotify(editor,msg,wParam,lParam); + else + ME_LinkNotify(editor, msg, wParam, lParam); /* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */ if (editor->bMouseCaptured) ME_SetCursor(editor); @@ -4155,15 +4165,17 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, else { ME_SetCursor(editor); - ME_LinkNotify(editor,msg,wParam,lParam); + ME_LinkNotify(editor, msg, wParam, lParam); } break; case WM_RBUTTONUP: case WM_RBUTTONDOWN: + case WM_RBUTTONDBLCLK: ME_CommitUndo(editor); /* End coalesced undos for typed characters */ if ((editor->nEventMask & ENM_MOUSEEVENTS) && !ME_FilterEvent(editor, msg, &wParam, &lParam)) return 0; + ME_LinkNotify(editor, msg, wParam, lParam); goto do_default; case WM_CONTEXTMENU: if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam))) @@ -4405,10 +4417,12 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, return 0; case WM_SETREDRAW: goto do_default; - case WM_SIZE: + case WM_WINDOWPOSCHANGED: { RECT clientRect; + WINDOWPOS *winpos = (WINDOWPOS *)lParam; + if (winpos->flags & SWP_NOCLIENTSIZE) goto do_default; ITextHost_TxGetClientRect(editor->texthost, &clientRect); if (editor->bDefaultFormatRect) { ME_SetDefaultFormatRect(editor); diff --git a/reactos/dll/win32/riched20/editor.h b/reactos/dll/win32/riched20/editor.h index 1b78ff0380e..4054c99dfd1 100644 --- a/reactos/dll/win32/riched20/editor.h +++ b/reactos/dll/win32/riched20/editor.h @@ -297,6 +297,7 @@ void ME_RTFTblAttrHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; void ME_RTFSpecialCharHook(struct _RTF_Info *info) DECLSPEC_HIDDEN; void ME_StreamInFill(ME_InStream *stream) DECLSPEC_HIDDEN; extern BOOL me_debug DECLSPEC_HIDDEN; +void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) DECLSPEC_HIDDEN; /* table.c */ BOOL ME_IsInTable(ME_DisplayItem *pItem) DECLSPEC_HIDDEN; @@ -385,4 +386,6 @@ LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) /* clipboard.c */ HRESULT ME_GetDataObject(ME_TextEditor *editor, const ME_Cursor *start, int nChars, LPDATAOBJECT *lplpdataobj) DECLSPEC_HIDDEN; +void release_typelib(void) DECLSPEC_HIDDEN; + #endif /* _RICHED20_EDITOR_H */ diff --git a/reactos/dll/win32/riched20/editstr.h b/reactos/dll/win32/riched20/editstr.h index d9809db469d..cecd552d646 100644 --- a/reactos/dll/win32/riched20/editstr.h +++ b/reactos/dll/win32/riched20/editstr.h @@ -22,7 +22,7 @@ #define __EDITSTR_H #ifdef __i386__ -extern const struct ITextHostVtbl itextHostStdcallVtbl; +extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN; #endif /* __i386__ */ typedef struct tagME_String diff --git a/reactos/dll/win32/riched20/res.h b/reactos/dll/win32/riched20/res.h index 72343105705..edf2b07cdfd 100644 --- a/reactos/dll/win32/riched20/res.h +++ b/reactos/dll/win32/riched20/res.h @@ -1,5 +1,5 @@ /* - * Top level resource file for MOUSE driver dll + * Top level resource file for rich edit control * * Copyright 2007 Maarten Lankhorst for CodeWeavers * diff --git a/reactos/dll/win32/riched20/riched_tom.idl b/reactos/dll/win32/riched20/riched_tom.idl new file mode 100644 index 00000000000..03ca032e933 --- /dev/null +++ b/reactos/dll/win32/riched20/riched_tom.idl @@ -0,0 +1,723 @@ +/* + * Copyright 2006 Juan Lang + * Copyright 2015 Nikolay Sivov for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "unknwn.idl"; +import "objidl.idl"; +import "oaidl.idl"; + +#pragma makedep regtypelib + +cpp_quote("#ifdef WINE_NO_UNICODE_MACROS") +cpp_quote("#undef FindText") +cpp_quote("#endif") + +[ + uuid(8cc497c9-a1df-11ce-8098-00aa0047be5d), + version(1.0) +] +library tom +{ + +importlib("stdole2.tlb"); + +typedef enum tagTomConstants +{ + tomFalse = 0, + tomTrue = -1, + tomUndefined = -9999999, + tomToggle = -9999998, + tomAutoColor = -9999997, + tomDefault = -9999996, + tomSuspend = -9999995, + tomResume = -9999994, + + /* ITextFont::Reset() modes */ + tomApplyNow = 0, + tomApplyLater = 1, + tomTrackParms = 2, + tomCacheParms = 3, + tomApplyTmp = 4, + tomDisableSmartFont = 8, + tomEnableSmartFont = 9, + tomUsePoints = 10, + tomUseTwips = 11, + + tomBackward = 0xc0000001, + tomForward = 0x3fffffff, + tomMove = 0, + tomExtend = 1, + tomNoSelection = 0, + tomSelectionIP = 1, + tomSelectionNormal = 2, + tomSelectionFrame = 3, + tomSelectionColumn = 4, + tomSelectionRow = 5, + tomSelectionBlock = 6, + tomSelectionInlineShape = 7, + tomSelectionShape = 8, + tomSelStartActive = 1, + tomSelAtEOL = 2, + tomSelOvertype = 4, + tomSelActive = 8, + tomSelReplace = 16, + tomEnd = 0, + tomStart = 32, + tomCollapseEnd = 0, + tomCollapseStart = 1, + tomClientCoord = 256, + tomNone = 0, + tomSingle = 1, + tomWords = 2, + tomDouble = 3, + tomDotted = 4, + tomDash = 5, + tomDashDot = 6, + tomDashDotDot = 7, + tomWave = 8, + tomThick = 9, + tomHair = 10, + tomLineSpaceSingle = 0, + tomLineSpace1pt5 = 1, + tomLineSpaceDouble = 2, + tomLineSpaceAtLeast = 3, + tomLineSpaceExactly = 4, + tomLineSpaceMultiple = 5, + tomAlignLeft = 0, + tomAlignCenter = 1, + tomAlignRight = 2, + tomAlignJustify = 3, + tomAlignDecimal = 3, + tomAlignBar = 4, + tomAlignInterWord = 3, + tomAlignInterLetter = 4, + tomAlignScaled = 5, + tomAlignGlyphs = 6, + tomAlignSnapGrid = 7, + tomSpaces = 0, + tomDots = 1, + tomDashes = 2, + tomLines = 3, + tomThickLines = 4, + tomEquals = 5, + tomTabBack = -3, + tomTabNext = -2, + tomTabHere = -1, + tomListBullet = 1, + tomListNumberAsArabic = 2, + tomListNumberAsLCLetter = 3, + tomListNumberAsUCLetter = 4, + tomListNumberAsLCRoman = 5, + tomListNumberAsUCRoman = 6, + tomListNumberAsSequence = 7, + tomListParentheses = 0x10000, + tomListPeriod = 0x20000, + tomListPlain = 0x30000, + tomCharacter = 1, + tomWord = 2, + tomSentence = 3, + tomParagraph = 4, + tomLine = 5, + tomStory = 6, + tomScreen = 7, + tomSection = 8, + tomColumn = 9, + tomRow = 10, + tomWindow = 11, + tomCell = 12, + tomCharFormat = 13, + tomParaFormat = 14, + tomTable = 15, + tomObject = 16, + tomMatchWord = 2, + tomMatchCase = 4, + tomMatchPattern = 8, + + /* ITextRange story type values */ + tomUnknownStory = 0, + tomMainTextStory = 1, + tomFootnotesStory = 2, + tomEndnotesStory = 3, + tomCommentsStory = 4, + tomTextFrameStory = 5, + tomEvenPagesHeaderStory = 6, + tomPrimaryHeaderStory = 7, + tomEvenPagesFooterStory = 8, + tomPrimaryFooterStory = 9, + tomFirstPageHeaderStory = 10, + tomFirstPageFooterStory = 11, + + /* ITextFont animation property */ + tomNoAnimation = 0, + tomLasVegasLights = 1, + tomBlinkingBackground = 2, + tomSparkleText = 3, + tomMarchingBlackAnts = 4, + tomMarchingRedAnts = 5, + tomShimmer = 6, + tomWipeDown = 7, + tomWipeRight = 8, + tomAnimationMax = 8, + + tomLowerCase = 0, + tomUpperCase = 1, + tomTitleCase = 2, + tomSentenceCase = 4, + tomToggleCase = 5, + tomReadOnly = 0x100, + tomShareDenyRead = 0x200, + tomShareDenyWrite = 0x400, + tomPasteFile = 0x1000, + tomCreateNew = 0x10, + tomCreateAlways = 0x20, + tomOpenExisting = 0x30, + tomOpenAlways = 0x40, + tomTruncateExisting = 0x50, + tomRTF = 0x1, + tomText = 0x2, + tomHTML = 0x3, + tomWordDocument = 0x4, + tomBold = 0x80000001, + tomItalic = 0x80000002, + tomUnderline = 0x80000004, + tomStrikeout = 0x80000008, + tomProtected = 0x80000010, + tomLink = 0x80000020, + tomSmallCaps = 0x80000040, + tomAllCaps = 0x80000080, + tomHidden = 0x80000100, + tomOutline = 0x80000200, + tomShadow = 0x80000400, + tomEmboss = 0x80000800, + tomImprint = 0x80001000, + tomDisabled = 0x80002000, + tomRevised = 0x80004000, + tomNormalCaret = 0, + tomKoreanBlockCaret = 0x1, + tomIncludeInset = 0x1, + tomIgnoreCurrentFont = 0, + tomMatchFontCharset = 0x1, + tomMatchFontSignature = 0x2, + tomCharset = 0x80000000, + tomRE10Mode = 0x1, + tomNoIME = 0x80000, + tomSelfIME = 0x40000 +} tomConstants; + +interface ITextRange; +interface ITextSelection; +interface ITextStoryRanges; + +[ + uuid(8cc497c0-a1df-11ce-8098-00aa0047be5d), + object, + dual, + oleautomation +] +interface ITextDocument : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Name([retval, out] BSTR *name); + + [propget] + HRESULT Selection([retval, out] ITextSelection **selection); + + [propget] + HRESULT StoryCount([retval, out] LONG *count); + + [propget] + HRESULT StoryRanges([retval, out] ITextStoryRanges **ranges); + + [propget] + HRESULT Saved([retval, out] LONG *value); + + [propput] + HRESULT Saved([in] LONG value); + + [propget] + HRESULT DefaultTabStop([retval, out] float *value); + + [propput] + HRESULT DefaultTabStop([in] float value); + + HRESULT New(); + + HRESULT Open([in] VARIANT *var, [in] LONG flags, [in] LONG codepage); + + HRESULT Save([in] VARIANT *var, [in] LONG flags, [in] LONG codepage); + + HRESULT Freeze([retval, out] LONG *count); + HRESULT Unfreeze([retval, out] LONG *count); + HRESULT BeginEditCollection(); + HRESULT EndEditCollection(); + HRESULT Undo([in] LONG count, [retval, out] LONG *prop); + HRESULT Redo([in] LONG count, [retval, out] LONG *prop); + HRESULT Range([in] LONG start, [in] LONG end, [retval, out] ITextRange **range); + HRESULT RangeFromPoint([in] LONG x, [in] LONG y, [retval, out] ITextRange **range); +} + +interface ITextFont; +interface ITextPara; + +[ + uuid(8cc497c2-a1df-11ce-8098-00aa0047be5d), + object, + dual, + oleautomation +] +interface ITextRange : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Text([retval, out] BSTR *text); + + [propput, id(DISPID_VALUE)] + HRESULT Text([in] BSTR text); + + [propget] + HRESULT Char([retval, out] LONG *ch); + + [propput] + HRESULT Char([in] LONG ch); + + [propget] + HRESULT Duplicate([retval, out] ITextRange **range); + + [propget] + HRESULT FormattedText([retval, out] ITextRange **range); + + [propput] + HRESULT FormattedText([in] ITextRange *range); + + [propget] + HRESULT Start([retval, out] LONG *start); + + [propput] + HRESULT Start([in] LONG start); + + [propget] + HRESULT End([retval, out] LONG *end); + + [propput] + HRESULT End([in] LONG end); + + [propget] + HRESULT Font([retval, out] ITextFont **font); + + [propput] + HRESULT Font([in] ITextFont *font); + + [propget] + HRESULT Para([retval, out] ITextPara **para); + + [propput] + HRESULT Para([in] ITextPara *para); + + [propget] + HRESULT StoryLength([retval, out] LONG *len); + + [propget] + HRESULT StoryType([retval, out] LONG *value); + + HRESULT Collapse([in] LONG start); + HRESULT Expand([in] LONG unit, [retval, out] LONG *delta); + HRESULT GetIndex([in] LONG unit, [retval, out] LONG *index); + HRESULT SetIndex([in] LONG unit, [in] LONG index, [in] LONG extend); + HRESULT SetRange([in] LONG anchor, [in] LONG active); + HRESULT InRange([in] ITextRange *range, [retval, out] LONG *pb); + HRESULT InStory([in] ITextRange *range, [retval, out] LONG *pb); + HRESULT IsEqual([in] ITextRange *range, [retval, out] LONG *pb); + HRESULT Select(); + HRESULT StartOf([in] LONG unit, [in] LONG extend, [retval, out] LONG *delta); + HRESULT EndOf([in] LONG unit, [in] LONG extend, [retval, out] LONG *delta); + HRESULT Move([in] LONG unit, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveStart([in] LONG unit, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveEnd([in] LONG unit, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveWhile([in] VARIANT *charset, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveStartWhile([in] VARIANT *charset, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveEndWhile([in] VARIANT *charset, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveUntil([in] VARIANT *charset, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveStartUntil([in] VARIANT *charset, [in] LONG count, [retval, out] LONG *delta); + HRESULT MoveEndUntil([in] VARIANT *charset, [in] LONG count, [retval, out] LONG *delta); + HRESULT FindText([in] BSTR str, [in] LONG ch, [in] LONG flags, [retval, out] LONG *len); + HRESULT FindTextStart([in] BSTR str, [in] LONG cch, [in] LONG flags, [retval, out] LONG *len); + HRESULT FindTextEnd([in] BSTR str, [in] LONG ch, [in] LONG flags, [retval, out] LONG *len); + HRESULT Delete([in] LONG unit, [in] LONG count, [retval, out] LONG *delta); + HRESULT Cut([out] VARIANT *var); + HRESULT Copy([out] VARIANT *var); + HRESULT Paste([in] VARIANT *var, [in] LONG format); + HRESULT CanPaste([in] VARIANT *var, [in] LONG format, [retval, out] LONG *pb); + HRESULT CanEdit([retval, out] LONG *pb); + HRESULT ChangeCase([in] LONG type); + HRESULT GetPoint([in] LONG type, [out] LONG *cx, [out] LONG *cy); + HRESULT SetPoint([in] LONG x, [in] LONG y, [in] LONG type, [in] LONG extend); + HRESULT ScrollIntoView([in] LONG value); + HRESULT GetEmbeddedObject([retval, out] IUnknown **ppv); +} + +[ + uuid(8cc497c1-a1df-11ce-8098-00aa0047be5d), + object, + dual, + oleautomation +] +interface ITextSelection : ITextRange +{ + [propget] + HRESULT Flags([retval, out] LONG *flags); + + [propput] + HRESULT Flags([in] LONG flags); + + [propget] + HRESULT Type([retval, out] LONG *type); + + HRESULT MoveLeft([in] LONG unit, [in] LONG count, [in] LONG extend, [retval, out] LONG *delta); + HRESULT MoveRight([in] LONG unit, [in] LONG count, [in] LONG extend, [retval, out] LONG *delta); + HRESULT MoveUp([in] LONG unit, [in] LONG count, [in] LONG extend, [retval, out] LONG *delta); + HRESULT MoveDown([in] LONG unit, [in] LONG count, [in] LONG extend, [retval, out] LONG *delta); + HRESULT HomeKey([in] LONG unit, [in] LONG extend, [retval, out] LONG *delta); + HRESULT EndKey([in] LONG unit, [in] LONG extend, [retval, out] LONG *delta); + HRESULT TypeText([in] BSTR str); +} + +[ + uuid(8cc497c3-a1df-11ce-8098-00aa0047be5d), + object, + dual, + oleautomation +] +interface ITextFont : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Duplicate([retval, out] ITextFont **font); + + [propput, id(DISPID_VALUE)] + HRESULT Duplicate([in] ITextFont *font); + + HRESULT CanChange([out] LONG *pB); + HRESULT IsEqual([in] ITextFont *font, [retval, out] LONG *pB); + HRESULT Reset([in] LONG value); + + [propget] + HRESULT GetStyle([retval, out] LONG *value); + + [propput] + HRESULT SetStyle([in] LONG value); + + [propget] + HRESULT AllCaps([retval, out] LONG *value); + + [propput] + HRESULT AllCaps([in] LONG value); + + [propget] + HRESULT Animation([retval, out] LONG *value); + + [propput] + HRESULT Animation([in] LONG value); + + [propget] + HRESULT BackColor([retval, out] LONG *value); + + [propput] + HRESULT BackColor([in] LONG value); + + [propget] + HRESULT Bold([retval, out] LONG *value); + + [propput] + HRESULT Bold([in] LONG value); + + [propget] + HRESULT Emboss([retval, out] LONG *value); + + [propput] + HRESULT Emboss([in] LONG value); + + [propget] + HRESULT ForeColor([retval, out] LONG *value); + + [propput] + HRESULT ForeColor([in] LONG value); + + [propget] + HRESULT Hidden([retval, out] LONG *value); + + [propput] + HRESULT Hidden([in] LONG value); + + [propget] + HRESULT Engrave([retval, out] LONG *value); + + [propput] + HRESULT Engrave([in] LONG value); + + [propget] + HRESULT Italic([retval, out] LONG *value); + + [propput] + HRESULT Italic([in] LONG value); + + [propget] + HRESULT Kerning([retval, out] float *value); + + [propput] + HRESULT Kerning([in] float value); + + [propget] + HRESULT LanguageID([retval, out] LONG *value); + + [propput] + HRESULT LanguageID([in] LONG value); + + [propget] + HRESULT Name([retval, out] BSTR *value); + + [propput] + HRESULT Name([in] BSTR value); + + [propget] + HRESULT Outline([retval, out] LONG *value); + + [propput] + HRESULT Outline([in] LONG value); + + [propget] + HRESULT Position([retval, out] float *value); + + [propput] + HRESULT Position([in] float value); + + [propget] + HRESULT Protected([retval, out] LONG *value); + + [propput] + HRESULT Protected([in] LONG value); + + [propget] + HRESULT Shadow([retval, out] LONG *value); + + [propput] + HRESULT Shadow([in] LONG value); + + [propget] + HRESULT Size([retval, out] float *value); + + [propput] + HRESULT Size([in] float value); + + [propget] + HRESULT SmallCaps([retval, out] LONG *value); + + [propput] + HRESULT SmallCaps([in] LONG value); + + [propget] + HRESULT Spacing([retval, out] float *value); + + [propput] + HRESULT Spacing([in] float value); + + [propget] + HRESULT StrikeThrough([retval, out] LONG *value); + + [propput] + HRESULT StrikeThrough([in] LONG value); + + [propget] + HRESULT Subscript([retval, out] LONG *value); + + [propput] + HRESULT Subscript([in] LONG value); + + [propget] + HRESULT Superscript([retval, out] LONG *value); + + [propput] + HRESULT Superscript([in] LONG value); + + [propget] + HRESULT Underline([retval, out] LONG *value); + + [propput] + HRESULT Underline([in] LONG value); + + [propget] + HRESULT Weight([retval, out] LONG *value); + + [propput] + HRESULT Weight([in] LONG value); +} + +[ + uuid(8cc497c4-a1df-11ce-8098-00aa0047be5d), + object, + dual, + oleautomation +] +interface ITextPara : IDispatch +{ + [propget, id(DISPID_VALUE)] + HRESULT Duplicate([retval, out] ITextPara **para); + + [propput, id(DISPID_VALUE)] + HRESULT Duplicate([in] ITextPara *para); + + HRESULT CanChange([out, retval] LONG *pB); + HRESULT IsEqual([in] ITextPara *para, [retval, out] LONG *pB); + HRESULT Reset([in] LONG value); + + [propget] + HRESULT Style([retval, out] LONG *value); + + [propput] + HRESULT Style([in] LONG value); + + [propget] + HRESULT Alignment([retval, out] LONG *value); + + [propput] + HRESULT Alignment([in] LONG value); + + [propget] + HRESULT Hyphenation([retval, out]LONG *value); + + [propput] + HRESULT Hyphenation([in] LONG value); + + [propget] + HRESULT FirstLineIndent([retval, out] float *value); + + [propget] + HRESULT KeepTogether([retval, out] LONG *value); + + [propput] + HRESULT KeepTogether([in] LONG value); + + [propget] + HRESULT KeepWithNext([retval, out] LONG *value); + + [propput] + HRESULT KeepWithNext([in] LONG value); + + [propget] + HRESULT LeftIndent([retval, out] float *value); + + [propget] + HRESULT LineSpacing([retval, out] float *value); + + [propget] + HRESULT LineSpacingRule([retval, out] LONG *value); + + [propget] + HRESULT ListAlignment([retval, out] LONG *value); + + [propput] + HRESULT ListAlignment([in] LONG value); + + [propget] + HRESULT ListLevelIndex([retval, out] LONG *value); + + [propput] + HRESULT ListLevelIndex([in] LONG value); + + [propget] + HRESULT ListStart([retval, out] LONG *value); + + [propput] + HRESULT ListStart([in] LONG value); + + [propget] + HRESULT ListTab([retval, out] float *value); + + [propput] + HRESULT ListTab([in] float value); + + [propget] + HRESULT ListType([retval, out] LONG *value); + + [propput] + HRESULT ListType([in] LONG value); + + [propget] + HRESULT NoLineNumber([retval, out] LONG *value); + + [propput] + HRESULT NoLineNumber([in] LONG value); + + [propget] + HRESULT PageBreakBefore([retval, out] LONG *value); + + [propput] + HRESULT PageBreakBefore([in] LONG value); + + [propget] + HRESULT RightIndent([retval, out] float *value); + + [propput] + HRESULT RightIndent([in] float value); + + HRESULT SetIndents([in] float StartIndent, [in] float LeftIndent, [in] float RightIndent); + HRESULT SetLineSpacing([in] LONG LineSpacingRule, [in] float LineSpacing); + + [propget] + HRESULT SpaceAfter([retval, out] float *value); + + [propput] + HRESULT SpaceAfter([in] float value); + + [propget] + HRESULT SpaceBefore([retval, out] float *value); + + [propput] + HRESULT SpaceBefore([in] float value); + + [propget] + HRESULT WidowControl([retval, out] LONG *value); + + [propput] + HRESULT WidowControl([in] LONG value); + + [propget] + HRESULT TabCount([retval, out] LONG *count); + + HRESULT AddTab([in] float tbPos, [in] LONG tbAlign, [in] LONG tbLeader); + HRESULT ClearAllTabs(); + HRESULT DeleteTab([in] float tbPos); + HRESULT GetTab([in] LONG iTab, [out] float *ptbPos, [out] LONG *ptbAlign, [out] LONG *ptbLeader); +} + +[ + uuid(8cc497c5-a1df-11ce-8098-00aa0047be5d), + object, + dual, + oleautomation +] +interface ITextStoryRanges : IDispatch +{ + [restricted, hidden, id(DISPID_NEWENUM)] + HRESULT _NewEnum([retval, out] IUnknown **ppEnum); + + [id(DISPID_VALUE)] + HRESULT Item([in] LONG index, [retval, out] ITextRange **range); + + [propget] + HRESULT Count([retval, out] LONG *count); +} + +} /* Library tom */ diff --git a/reactos/dll/win32/riched20/riched_tom.rgs b/reactos/dll/win32/riched20/riched_tom.rgs new file mode 100644 index 00000000000..a5dd1e1fbe7 --- /dev/null +++ b/reactos/dll/win32/riched20/riched_tom.rgs @@ -0,0 +1,56 @@ +HKCR +{ + NoRemove Typelib + { + NoRemove '{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}' + { + '1.0' = s 'tom' + { + '0' { win32 = s '%MODULE%' } + FLAGS = s '0' + } + } + } + NoRemove Interface + { + '{8CC497C0-A1DF-11CE-8098-00AA0047BE5D}' = s 'ITextDocument' + { + ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}' + ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}' + TypeLib = s '{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}' { val Version = s '1.0' } + } + '{8CC497C2-A1DF-11CE-8098-00AA0047BE5D}' = s 'ITextRange' + { + ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}' + ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}' + TypeLib = s '{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}' { val Version = s '1.0' } + } + '{8CC497C1-A1DF-11CE-8098-00AA0047BE5D}' = s 'ITextSelection' + { + ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}' + ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}' + TypeLib = s '{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}' { val Version = s '1.0' } + } + '{8CC497C3-A1DF-11CE-8098-00AA0047BE5D}' = s 'ITextFont' + { + ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}' + ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}' + TypeLib = s '{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}' { val Version = s '1.0' } + } + '{8CC497C4-A1DF-11CE-8098-00AA0047BE5D}' = s 'ITextPara' + { + ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}' + ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}' + TypeLib = s '{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}' { val Version = s '1.0' } + } + '{8CC497C5-A1DF-11CE-8098-00AA0047BE5D}' = s 'ITextStoryRanges' + { + ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}' + ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}' + TypeLib = s '{8CC497C9-A1DF-11CE-8098-00AA0047BE5D}' { val Version = s '1.0' } + } + } + NoRemove CLSID + { + } +} diff --git a/reactos/dll/win32/riched20/richole.c b/reactos/dll/win32/riched20/richole.c index 0d52376db09..53c3a47aae3 100644 --- a/reactos/dll/win32/riched20/richole.c +++ b/reactos/dll/win32/riched20/richole.c @@ -26,6 +26,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/ #include + +DEFINE_GUID(LIBID_tom, 0x8cc497c9, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5); DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1); @@ -35,11 +37,159 @@ DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0x DEFINE_GUID(IID_ITextFont, 0x8cc497c3, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); DEFINE_GUID(IID_ITextPara, 0x8cc497c4, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); +static ITypeLib *typelib; + +enum tid_t { + NULL_tid, + ITextDocument_tid, + ITextRange_tid, + ITextSelection_tid, + ITextFont_tid, + ITextPara_tid, + LAST_tid +}; + +static const IID * const tid_ids[] = +{ + &IID_NULL, + &IID_ITextDocument, + &IID_ITextRange, + &IID_ITextSelection, + &IID_ITextFont, + &IID_ITextPara, +}; +static ITypeInfo *typeinfos[LAST_tid]; + +static HRESULT load_typelib(void) +{ + ITypeLib *tl; + HRESULT hr; + + hr = LoadRegTypeLib(&LIBID_tom, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl); + if (FAILED(hr)) { + ERR("LoadRegTypeLib failed: %08x\n", hr); + return hr; + } + + if (InterlockedCompareExchangePointer((void**)&typelib, tl, NULL)) + ITypeLib_Release(tl); + return hr; +} + +void release_typelib(void) +{ + unsigned i; + + if (!typelib) + return; + + for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++) + if (typeinfos[i]) + ITypeInfo_Release(typeinfos[i]); + + ITypeLib_Release(typelib); +} + +static HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo) +{ + HRESULT hr; + + if (!typelib) + hr = load_typelib(); + if (!typelib) + return hr; + + if (!typeinfos[tid]) + { + ITypeInfo *ti; + + hr = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti); + if (FAILED(hr)) + { + ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hr); + return hr; + } + + if (InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL)) + ITypeInfo_Release(ti); + } + + *typeinfo = typeinfos[tid]; + return S_OK; +} + +/* private IID used to get back IRichEditOleImpl pointer */ +DEFINE_GUID(IID_Igetrichole, 0xe3ce5c7a, 0x8247, 0x4622, 0x81, 0xad, 0x11, 0x81, 0x02, 0xaa, 0x01, 0x30); + typedef struct ITextSelectionImpl ITextSelectionImpl; typedef struct IOleClientSiteImpl IOleClientSiteImpl; typedef struct ITextRangeImpl ITextRangeImpl; -typedef struct ITextFontImpl ITextFontImpl; -typedef struct ITextParaImpl ITextParaImpl; + +enum textfont_prop_id { + FONT_ALLCAPS = 0, + FONT_ANIMATION, + FONT_BACKCOLOR, + FONT_BOLD, + FONT_EMBOSS, + FONT_FORECOLOR, + FONT_HIDDEN, + FONT_ENGRAVE, + FONT_ITALIC, + FONT_KERNING, + FONT_LANGID, + FONT_NAME, + FONT_OUTLINE, + FONT_POSITION, + FONT_PROTECTED, + FONT_SHADOW, + FONT_SIZE, + FONT_SMALLCAPS, + FONT_SPACING, + FONT_STRIKETHROUGH, + FONT_SUBSCRIPT, + FONT_SUPERSCRIPT, + FONT_UNDERLINE, + FONT_WEIGHT, + FONT_PROPID_LAST, + FONT_PROPID_FIRST = FONT_ALLCAPS +}; + +static const DWORD textfont_prop_masks[][2] = { + { CFM_ALLCAPS, CFE_ALLCAPS }, + { CFM_ANIMATION }, + { CFM_BACKCOLOR, CFE_AUTOBACKCOLOR }, + { CFM_BOLD, CFE_BOLD }, + { CFM_EMBOSS, CFE_EMBOSS }, + { CFM_COLOR, CFE_AUTOCOLOR }, + { CFM_HIDDEN, CFE_HIDDEN }, + { CFM_IMPRINT, CFE_IMPRINT }, + { CFM_ITALIC, CFE_ITALIC }, + { CFM_KERNING }, + { CFM_LCID }, + { CFM_FACE }, + { CFM_OUTLINE, CFE_OUTLINE }, + { CFM_OFFSET }, + { CFM_PROTECTED, CFE_PROTECTED }, + { CFM_SHADOW, CFE_SHADOW }, + { CFM_SIZE }, + { CFM_SMALLCAPS, CFE_SMALLCAPS }, + { CFM_SPACING }, + { CFM_STRIKEOUT, CFE_STRIKEOUT }, + { CFM_SUBSCRIPT, CFE_SUBSCRIPT }, + { CFM_SUPERSCRIPT, CFE_SUPERSCRIPT }, + { CFM_UNDERLINE, CFE_UNDERLINE }, + { CFM_WEIGHT } +}; + +typedef union { + FLOAT f; + LONG l; + BSTR str; +} textfont_prop_val; + +enum range_update_op { + RANGE_UPDATE_DELETE +}; typedef struct IRichEditOleImpl { IUnknown IUnknown_inner; @@ -50,39 +200,21 @@ typedef struct IRichEditOleImpl { ME_TextEditor *editor; ITextSelectionImpl *txtSel; - IOleClientSiteImpl *clientSite; + struct list rangelist; - struct list fontlist; - struct list paralist; + struct list clientsites; } IRichEditOleImpl; -struct ITextParaImpl { - ITextPara ITextPara_iface; - LONG ref; +struct reole_child { struct list entry; - - IRichEditOleImpl *reOle; - ITextRangeImpl *txtRge; - ITextSelectionImpl *txtSel; -}; - -struct ITextFontImpl { - ITextFont ITextFont_iface; - LONG ref; - struct list entry; - - IRichEditOleImpl *reOle; - ITextRangeImpl *txtRge; - ITextSelectionImpl *txtSel; + IRichEditOleImpl *reole; }; struct ITextRangeImpl { + struct reole_child child; ITextRange ITextRange_iface; LONG ref; LONG start, end; - struct list entry; - - IRichEditOleImpl *reOle; }; struct ITextSelectionImpl { @@ -92,11 +224,29 @@ struct ITextSelectionImpl { IRichEditOleImpl *reOle; }; -struct IOleClientSiteImpl { - IOleClientSite IOleClientSite_iface; +typedef struct ITextFontImpl { + ITextFont ITextFont_iface; LONG ref; - IRichEditOleImpl *reOle; + ITextRange *range; + textfont_prop_val props[FONT_PROPID_LAST]; + BOOL get_cache_enabled; + BOOL set_cache_enabled; +} ITextFontImpl; + +typedef struct ITextParaImpl { + ITextPara ITextPara_iface; + LONG ref; + + ITextRange *range; +} ITextParaImpl; + +struct IOleClientSiteImpl { + struct reole_child child; + IOleClientSite IOleClientSite_iface; + IOleWindow IOleWindow_iface; + IOleInPlaceSite IOleInPlaceSite_iface; + LONG ref; }; static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface) @@ -114,6 +264,666 @@ static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface) return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner); } +static inline IOleClientSiteImpl *impl_from_IOleWindow(IOleWindow *iface) +{ + return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleWindow_iface); +} + +static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface) +{ + return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface); +} + +static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface) +{ + return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface); +} + +static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface) +{ + return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface); +} + +static inline ITextFontImpl *impl_from_ITextFont(ITextFont *iface) +{ + return CONTAINING_RECORD(iface, ITextFontImpl, ITextFont_iface); +} + +static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface) +{ + return CONTAINING_RECORD(iface, ITextParaImpl, ITextPara_iface); +} + +static HRESULT create_textfont(ITextRange*, const ITextFontImpl*, ITextFont**); +static HRESULT create_textpara(ITextRange*, ITextPara**); +static ITextSelectionImpl *CreateTextSelection(IRichEditOleImpl*); + +static HRESULT textrange_get_storylength(ME_TextEditor *editor, LONG *length) +{ + if (!length) + return E_INVALIDARG; + + *length = ME_GetTextLength(editor) + 1; + return S_OK; +} + +static void textranges_update_ranges(IRichEditOleImpl *reole, LONG start, LONG end, enum range_update_op op) +{ + ITextRangeImpl *range; + + LIST_FOR_EACH_ENTRY(range, &reole->rangelist, ITextRangeImpl, child.entry) { + switch (op) + { + case RANGE_UPDATE_DELETE: + /* range fully covered by deleted range - collapse to insertion point */ + if (range->start >= start && range->end <= end) + range->start = range->end = start; + /* deleted range cuts from the right */ + else if (range->start < start && range->end <= end) + range->end = start; + /* deleted range cuts from the left */ + else if (range->start >= start && range->end > end) { + range->start = start; + range->end -= end - start; + } + /* deleted range cuts within */ + else + range->end -= end - start; + break; + default: + FIXME("unknown update op, %d\n", op); + } + } +} + +static inline BOOL is_equal_textfont_prop_value(enum textfont_prop_id propid, textfont_prop_val *left, + textfont_prop_val *right) +{ + switch (propid) + { + case FONT_ALLCAPS: + case FONT_ANIMATION: + case FONT_BACKCOLOR: + case FONT_BOLD: + case FONT_EMBOSS: + case FONT_FORECOLOR: + case FONT_HIDDEN: + case FONT_ENGRAVE: + case FONT_ITALIC: + case FONT_KERNING: + case FONT_LANGID: + case FONT_OUTLINE: + case FONT_PROTECTED: + case FONT_SHADOW: + case FONT_SMALLCAPS: + case FONT_STRIKETHROUGH: + case FONT_SUBSCRIPT: + case FONT_SUPERSCRIPT: + case FONT_UNDERLINE: + case FONT_WEIGHT: + return left->l == right->l; + case FONT_NAME: + return !strcmpW(left->str, right->str); + case FONT_POSITION: + case FONT_SIZE: + case FONT_SPACING: + return left->f == right->f; + default: + FIXME("unhandled font property %d\n", propid); + return FALSE; + } +} + +static inline void init_textfont_prop_value(enum textfont_prop_id propid, textfont_prop_val *v) +{ + switch (propid) + { + case FONT_ALLCAPS: + case FONT_ANIMATION: + case FONT_BACKCOLOR: + case FONT_BOLD: + case FONT_EMBOSS: + case FONT_FORECOLOR: + case FONT_HIDDEN: + case FONT_ENGRAVE: + case FONT_ITALIC: + case FONT_KERNING: + case FONT_LANGID: + case FONT_OUTLINE: + case FONT_PROTECTED: + case FONT_SHADOW: + case FONT_SMALLCAPS: + case FONT_STRIKETHROUGH: + case FONT_SUBSCRIPT: + case FONT_SUPERSCRIPT: + case FONT_UNDERLINE: + case FONT_WEIGHT: + v->l = tomUndefined; + return; + case FONT_NAME: + v->str = NULL; + return; + case FONT_POSITION: + case FONT_SIZE: + case FONT_SPACING: + v->f = tomUndefined; + return; + default: + FIXME("unhandled font property %d\n", propid); + v->l = tomUndefined; + return; + } +} + +static inline FLOAT twips_to_points(LONG value) +{ + return value * 72.0 / 1440; +} + +static inline FLOAT points_to_twips(FLOAT value) +{ + return value * 1440 / 72.0; +} + +static HRESULT get_textfont_prop_for_pos(const IRichEditOleImpl *reole, int pos, enum textfont_prop_id propid, + textfont_prop_val *value) +{ + ME_Cursor from, to; + CHARFORMAT2W fmt; + + memset(&fmt, 0, sizeof(fmt)); + fmt.cbSize = sizeof(fmt); + fmt.dwMask = textfont_prop_masks[propid][0]; + + ME_CursorFromCharOfs(reole->editor, pos, &from); + to = from; + ME_MoveCursorChars(reole->editor, &to, 1); + ME_GetCharFormat(reole->editor, &from, &to, &fmt); + + switch (propid) + { + case FONT_ALLCAPS: + case FONT_BOLD: + case FONT_EMBOSS: + case FONT_HIDDEN: + case FONT_ENGRAVE: + case FONT_ITALIC: + case FONT_OUTLINE: + case FONT_PROTECTED: + case FONT_SHADOW: + case FONT_SMALLCAPS: + case FONT_STRIKETHROUGH: + case FONT_SUBSCRIPT: + case FONT_SUPERSCRIPT: + case FONT_UNDERLINE: + value->l = fmt.dwEffects & textfont_prop_masks[propid][1] ? tomTrue : tomFalse; + break; + case FONT_ANIMATION: + value->l = fmt.bAnimation; + break; + case FONT_BACKCOLOR: + value->l = fmt.dwEffects & CFE_AUTOBACKCOLOR ? GetSysColor(COLOR_WINDOW) : fmt.crBackColor; + break; + case FONT_FORECOLOR: + value->l = fmt.dwEffects & CFE_AUTOCOLOR ? GetSysColor(COLOR_WINDOWTEXT) : fmt.crTextColor; + break; + case FONT_KERNING: + value->f = twips_to_points(fmt.wKerning); + break; + case FONT_LANGID: + value->l = fmt.lcid; + break; + case FONT_NAME: + /* this case is used exclusively by GetName() */ + value->str = SysAllocString(fmt.szFaceName); + if (!value->str) + return E_OUTOFMEMORY; + break; + case FONT_POSITION: + value->f = twips_to_points(fmt.yOffset); + break; + case FONT_SIZE: + value->f = twips_to_points(fmt.yHeight); + break; + case FONT_SPACING: + value->f = fmt.sSpacing; + break; + case FONT_WEIGHT: + value->l = fmt.wWeight; + break; + default: + FIXME("unhandled font property %d\n", propid); + return E_FAIL; + } + + return S_OK; +} + +static inline const IRichEditOleImpl *get_range_reole(ITextRange *range) +{ + IRichEditOleImpl *reole = NULL; + ITextRange_QueryInterface(range, &IID_Igetrichole, (void**)&reole); + return reole; +} + +static void textrange_set_font(ITextRange *range, ITextFont *font) +{ + CHARFORMAT2W fmt; + HRESULT hr; + LONG value; + BSTR str; + FLOAT f; + +#define CHARFORMAT_SET_B_FIELD(mask, value) \ + if (hr == S_OK && value != tomUndefined) { \ + fmt.dwMask |= CFM_##mask; \ + if (value == tomTrue) fmt.dwEffects |= CFE_##mask; \ + } \ + + /* fill format data from font */ + memset(&fmt, 0, sizeof(fmt)); + fmt.cbSize = sizeof(fmt); + + value = tomUndefined; + hr = ITextFont_GetAllCaps(font, &value); + CHARFORMAT_SET_B_FIELD(ALLCAPS, value); + + value = tomUndefined; + hr = ITextFont_GetBold(font, &value); + CHARFORMAT_SET_B_FIELD(BOLD, value); + + value = tomUndefined; + hr = ITextFont_GetEmboss(font, &value); + CHARFORMAT_SET_B_FIELD(EMBOSS, value); + + value = tomUndefined; + hr = ITextFont_GetHidden(font, &value); + CHARFORMAT_SET_B_FIELD(HIDDEN, value); + + value = tomUndefined; + hr = ITextFont_GetEngrave(font, &value); + CHARFORMAT_SET_B_FIELD(IMPRINT, value); + + value = tomUndefined; + hr = ITextFont_GetItalic(font, &value); + CHARFORMAT_SET_B_FIELD(ITALIC, value); + + value = tomUndefined; + hr = ITextFont_GetOutline(font, &value); + CHARFORMAT_SET_B_FIELD(OUTLINE, value); + + value = tomUndefined; + hr = ITextFont_GetProtected(font, &value); + CHARFORMAT_SET_B_FIELD(PROTECTED, value); + + value = tomUndefined; + hr = ITextFont_GetShadow(font, &value); + CHARFORMAT_SET_B_FIELD(SHADOW, value); + + value = tomUndefined; + hr = ITextFont_GetSmallCaps(font, &value); + CHARFORMAT_SET_B_FIELD(SMALLCAPS, value); + + value = tomUndefined; + hr = ITextFont_GetStrikeThrough(font, &value); + CHARFORMAT_SET_B_FIELD(STRIKEOUT, value); + + value = tomUndefined; + hr = ITextFont_GetSubscript(font, &value); + CHARFORMAT_SET_B_FIELD(SUBSCRIPT, value); + + value = tomUndefined; + hr = ITextFont_GetSuperscript(font, &value); + CHARFORMAT_SET_B_FIELD(SUPERSCRIPT, value); + + value = tomUndefined; + hr = ITextFont_GetUnderline(font, &value); + CHARFORMAT_SET_B_FIELD(UNDERLINE, value); + +#undef CHARFORMAT_SET_B_FIELD + + value = tomUndefined; + hr = ITextFont_GetAnimation(font, &value); + if (hr == S_OK && value != tomUndefined) { + fmt.dwMask |= CFM_ANIMATION; + fmt.bAnimation = value; + } + + value = tomUndefined; + hr = ITextFont_GetBackColor(font, &value); + if (hr == S_OK && value != tomUndefined) { + fmt.dwMask |= CFM_BACKCOLOR; + if (value == tomAutoColor) + fmt.dwEffects |= CFE_AUTOBACKCOLOR; + else + fmt.crBackColor = value; + } + + value = tomUndefined; + hr = ITextFont_GetForeColor(font, &value); + if (hr == S_OK && value != tomUndefined) { + fmt.dwMask |= CFM_COLOR; + if (value == tomAutoColor) + fmt.dwEffects |= CFE_AUTOCOLOR; + else + fmt.crTextColor = value; + } + + value = tomUndefined; + hr = ITextFont_GetKerning(font, &f); + if (hr == S_OK && f != tomUndefined) { + fmt.dwMask |= CFM_KERNING; + fmt.wKerning = points_to_twips(f); + } + + value = tomUndefined; + hr = ITextFont_GetLanguageID(font, &value); + if (hr == S_OK && value != tomUndefined) { + fmt.dwMask |= CFM_LCID; + fmt.lcid = value; + } + + if (ITextFont_GetName(font, &str) == S_OK) { + fmt.dwMask |= CFM_FACE; + lstrcpynW(fmt.szFaceName, str, sizeof(fmt.szFaceName)/sizeof(WCHAR)); + SysFreeString(str); + } + + hr = ITextFont_GetPosition(font, &f); + if (hr == S_OK && f != tomUndefined) { + fmt.dwMask |= CFM_OFFSET; + fmt.yOffset = points_to_twips(f); + } + + hr = ITextFont_GetSize(font, &f); + if (hr == S_OK && f != tomUndefined) { + fmt.dwMask |= CFM_SIZE; + fmt.yHeight = points_to_twips(f); + } + + hr = ITextFont_GetSpacing(font, &f); + if (hr == S_OK && f != tomUndefined) { + fmt.dwMask |= CFM_SPACING; + fmt.sSpacing = f; + } + + hr = ITextFont_GetWeight(font, &value); + if (hr == S_OK && value != tomUndefined) { + fmt.dwMask |= CFM_WEIGHT; + fmt.wWeight = value; + } + + if (fmt.dwMask) { + const IRichEditOleImpl *reole = get_range_reole(range); + ME_Cursor from, to; + LONG start, end; + + ITextRange_GetStart(range, &start); + ITextRange_GetEnd(range, &end); + + ME_CursorFromCharOfs(reole->editor, start, &from); + ME_CursorFromCharOfs(reole->editor, end, &to); + ME_SetCharFormat(reole->editor, &from, &to, &fmt); + } +} + +static HRESULT get_textfont_prop(const ITextFontImpl *font, enum textfont_prop_id propid, textfont_prop_val *value) +{ + const IRichEditOleImpl *reole; + textfont_prop_val v; + LONG start, end, i; + HRESULT hr; + + /* when font is not attached to any range use cached values */ + if (!font->range || font->get_cache_enabled) { + *value = font->props[propid]; + return S_OK; + } + + if (!(reole = get_range_reole(font->range))) + return CO_E_RELEASED; + + init_textfont_prop_value(propid, value); + + ITextRange_GetStart(font->range, &start); + ITextRange_GetEnd(font->range, &end); + + /* iterate trough a range to see if property value is consistent */ + hr = get_textfont_prop_for_pos(reole, start, propid, &v); + if (FAILED(hr)) + return hr; + + for (i = start + 1; i < end; i++) { + textfont_prop_val cur; + + hr = get_textfont_prop_for_pos(reole, i, propid, &cur); + if (FAILED(hr)) + return hr; + + if (!is_equal_textfont_prop_value(propid, &v, &cur)) + return S_OK; + } + + *value = v; + return S_OK; +} + +static HRESULT get_textfont_propf(const ITextFontImpl *font, enum textfont_prop_id propid, FLOAT *value) +{ + textfont_prop_val v; + HRESULT hr; + + if (!value) + return E_INVALIDARG; + + hr = get_textfont_prop(font, propid, &v); + *value = v.f; + return hr; +} + +static HRESULT get_textfont_propl(const ITextFontImpl *font, enum textfont_prop_id propid, LONG *value) +{ + textfont_prop_val v; + HRESULT hr; + + if (!value) + return E_INVALIDARG; + + hr = get_textfont_prop(font, propid, &v); + *value = v.l; + return hr; +} + +/* Value should already have a terminal value, for boolean properties it means tomToggle is not handled */ +static HRESULT set_textfont_prop(ITextFontImpl *font, enum textfont_prop_id propid, const textfont_prop_val *value) +{ + const IRichEditOleImpl *reole; + ME_Cursor from, to; + CHARFORMAT2W fmt; + LONG start, end; + + /* when font is not attached to any range use cache */ + if (!font->range || font->set_cache_enabled) { + if (propid == FONT_NAME) { + SysFreeString(font->props[propid].str); + font->props[propid].str = SysAllocString(value->str); + } + else + font->props[propid] = *value; + return S_OK; + } + + if (!(reole = get_range_reole(font->range))) + return CO_E_RELEASED; + + memset(&fmt, 0, sizeof(fmt)); + fmt.cbSize = sizeof(fmt); + fmt.dwMask = textfont_prop_masks[propid][0]; + + switch (propid) + { + case FONT_ALLCAPS: + case FONT_BOLD: + case FONT_EMBOSS: + case FONT_HIDDEN: + case FONT_ENGRAVE: + case FONT_ITALIC: + case FONT_OUTLINE: + case FONT_PROTECTED: + case FONT_SHADOW: + case FONT_SMALLCAPS: + case FONT_STRIKETHROUGH: + case FONT_SUBSCRIPT: + case FONT_SUPERSCRIPT: + case FONT_UNDERLINE: + fmt.dwEffects = value->l == tomTrue ? textfont_prop_masks[propid][1] : 0; + break; + case FONT_ANIMATION: + fmt.bAnimation = value->l; + break; + case FONT_BACKCOLOR: + case FONT_FORECOLOR: + if (value->l == tomAutoColor) + fmt.dwEffects = textfont_prop_masks[propid][1]; + else if (propid == FONT_BACKCOLOR) + fmt.crBackColor = value->l; + else + fmt.crTextColor = value->l; + break; + case FONT_KERNING: + fmt.wKerning = value->f; + break; + case FONT_LANGID: + fmt.lcid = value->l; + break; + case FONT_POSITION: + fmt.yOffset = value->f; + break; + case FONT_SIZE: + fmt.yHeight = value->f; + break; + case FONT_SPACING: + fmt.sSpacing = value->f; + break; + case FONT_WEIGHT: + fmt.wWeight = value->l; + break; + case FONT_NAME: + lstrcpynW(fmt.szFaceName, value->str, sizeof(fmt.szFaceName)/sizeof(WCHAR)); + break; + default: + FIXME("unhandled font property %d\n", propid); + return E_FAIL; + } + + ITextRange_GetStart(font->range, &start); + ITextRange_GetEnd(font->range, &end); + + ME_CursorFromCharOfs(reole->editor, start, &from); + ME_CursorFromCharOfs(reole->editor, end, &to); + ME_SetCharFormat(reole->editor, &from, &to, &fmt); + + return S_OK; +} + +static inline HRESULT set_textfont_propl(ITextFontImpl *font, enum textfont_prop_id propid, LONG value) +{ + textfont_prop_val v; + v.l = value; + return set_textfont_prop(font, propid, &v); +} + +static inline HRESULT set_textfont_propf(ITextFontImpl *font, enum textfont_prop_id propid, FLOAT value) +{ + textfont_prop_val v; + v.f = value; + return set_textfont_prop(font, propid, &v); +} + +static HRESULT set_textfont_propd(ITextFontImpl *font, enum textfont_prop_id propid, LONG value) +{ + textfont_prop_val v; + + switch (value) + { + case tomUndefined: + return S_OK; + case tomToggle: { + LONG oldvalue; + get_textfont_propl(font, propid, &oldvalue); + if (oldvalue == tomFalse) + value = tomTrue; + else if (oldvalue == tomTrue) + value = tomFalse; + else + return E_INVALIDARG; + /* fallthrough */ + } + case tomTrue: + case tomFalse: + v.l = value; + return set_textfont_prop(font, propid, &v); + default: + return E_INVALIDARG; + } +} + +static HRESULT textfont_getname_from_range(ITextRange *range, BSTR *ret) +{ + const IRichEditOleImpl *reole; + textfont_prop_val v; + HRESULT hr; + LONG start; + + if (!(reole = get_range_reole(range))) + return CO_E_RELEASED; + + ITextRange_GetStart(range, &start); + hr = get_textfont_prop_for_pos(reole, start, FONT_NAME, &v); + *ret = v.str; + return hr; +} + +static void textfont_cache_range_props(ITextFontImpl *font) +{ + enum textfont_prop_id propid; + for (propid = FONT_PROPID_FIRST; propid < FONT_PROPID_LAST; propid++) { + if (propid == FONT_NAME) + textfont_getname_from_range(font->range, &font->props[propid].str); + else + get_textfont_prop(font, propid, &font->props[propid]); + } +} + +static HRESULT textrange_expand(ITextRange *range, LONG unit, LONG *delta) +{ + LONG expand_start, expand_end; + + switch (unit) + { + case tomStory: + expand_start = 0; + ITextRange_GetStoryLength(range, &expand_end); + break; + default: + FIXME("unit %d is not supported\n", unit); + return E_NOTIMPL; + } + + if (delta) { + LONG start, end; + + ITextRange_GetStart(range, &start); + ITextRange_GetEnd(range, &end); + *delta = expand_end - expand_start - (end - start); + } + + ITextRange_SetStart(range, expand_start); + ITextRange_SetEnd(range, expand_end); + + return S_OK; +} + static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppvObj) { IRichEditOleImpl *This = impl_from_IUnknown(iface); @@ -164,21 +974,21 @@ static ULONG WINAPI IRichEditOleImpl_inner_fnRelease(IUnknown *iface) if (!ref) { + IOleClientSiteImpl *clientsite; ITextRangeImpl *txtRge; - ITextFontImpl *txtFont; - ITextParaImpl *txtPara; - TRACE("Destroying %p\n", This); - This->txtSel->reOle = NULL; This->editor->reOle = NULL; - ITextSelection_Release(&This->txtSel->ITextSelection_iface); - IOleClientSite_Release(&This->clientSite->IOleClientSite_iface); - LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, entry) - txtRge->reOle = NULL; - LIST_FOR_EACH_ENTRY(txtFont, &This->fontlist, ITextFontImpl, entry) - txtFont->reOle = NULL; - LIST_FOR_EACH_ENTRY(txtPara, &This->paralist, ITextParaImpl, entry) - txtPara->reOle = NULL; + if (This->txtSel) { + This->txtSel->reOle = NULL; + ITextSelection_Release(&This->txtSel->ITextSelection_iface); + } + + LIST_FOR_EACH_ENTRY(txtRge, &This->rangelist, ITextRangeImpl, child.entry) + txtRge->child.reole = NULL; + + LIST_FOR_EACH_ENTRY(clientsite, &This->clientsites, IOleClientSiteImpl, child.entry) + clientsite->child.reole = NULL; + heap_free(This); } return ref; @@ -245,12 +1055,17 @@ static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface static HRESULT WINAPI IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj) { + IOleClientSiteImpl *This = impl_from_IOleClientSite(me); TRACE("%p %s\n", me, debugstr_guid(riid) ); *ppvObj = NULL; if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IOleClientSite)) *ppvObj = me; + else if (IsEqualGUID(riid, &IID_IOleWindow)) + *ppvObj = &This->IOleWindow_iface; + else if (IsEqualGUID(riid, &IID_IOleInPlaceSite)) + *ppvObj = &This->IOleInPlaceSite_iface; if (*ppvObj) { IOleClientSite_AddRef(me); @@ -264,34 +1079,43 @@ IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj) static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); - return InterlockedIncrement(&This->ref); + ULONG ref = InterlockedIncrement(&This->ref); + TRACE("(%p)->(%u)\n", This, ref); + return ref; } static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); ULONG ref = InterlockedDecrement(&This->ref); - if (ref == 0) + + TRACE("(%p)->(%u)\n", This, ref); + + if (ref == 0) { + if (This->child.reole) { + list_remove(&This->child.entry); + This->child.reole = NULL; + } heap_free(This); + } return ref; } static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); - if (!This->reOle) + if (!This->child.reole) return CO_E_RELEASED; FIXME("stub %p\n", iface); return E_NOTIMPL; } - static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); - if (!This->reOle) + if (!This->child.reole) return CO_E_RELEASED; FIXME("stub %p\n", iface); @@ -302,7 +1126,7 @@ static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface, IOleContainer **ppContainer) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); - if (!This->reOle) + if (!This->child.reole) return CO_E_RELEASED; FIXME("stub %p\n", iface); @@ -312,7 +1136,7 @@ static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface, static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); - if (!This->reOle) + if (!This->child.reole) return CO_E_RELEASED; FIXME("stub %p\n", iface); @@ -322,7 +1146,7 @@ static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface) static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); - if (!This->reOle) + if (!This->child.reole) return CO_E_RELEASED; FIXME("stub %p\n", iface); @@ -332,7 +1156,7 @@ static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface) { IOleClientSiteImpl *This = impl_from_IOleClientSite(iface); - if (!This->reOle) + if (!This->child.reole) return CO_E_RELEASED; FIXME("stub %p\n", iface); @@ -351,32 +1175,207 @@ static const IOleClientSiteVtbl ocst = { IOleClientSite_fnRequestNewObjectLayout }; -static IOleClientSiteImpl * -CreateOleClientSite(IRichEditOleImpl *reOle) +/* IOleWindow interface */ +static HRESULT WINAPI IOleWindow_fnQueryInterface(IOleWindow *iface, REFIID riid, void **ppvObj) +{ + IOleClientSiteImpl *This = impl_from_IOleWindow(iface); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj); +} + +static ULONG WINAPI IOleWindow_fnAddRef(IOleWindow *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleWindow(iface); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); +} + +static ULONG WINAPI IOleWindow_fnRelease(IOleWindow *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleWindow(iface); + return IOleClientSite_Release(&This->IOleClientSite_iface); +} + +static HRESULT WINAPI IOleWindow_fnContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode) +{ + IOleClientSiteImpl *This = impl_from_IOleWindow(iface); + FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode); + return E_NOTIMPL; +} + +static HRESULT WINAPI IOleWindow_fnGetWindow(IOleWindow *iface, HWND *phwnd) +{ + IOleClientSiteImpl *This = impl_from_IOleWindow(iface); + + TRACE("(%p)->(%p)\n", This, phwnd); + + if (!This->child.reole) + return CO_E_RELEASED; + + if (!phwnd) + return E_INVALIDARG; + + *phwnd = This->child.reole->editor->hWnd; + return S_OK; +} + +static const IOleWindowVtbl olewinvt = { + IOleWindow_fnQueryInterface, + IOleWindow_fnAddRef, + IOleWindow_fnRelease, + IOleWindow_fnGetWindow, + IOleWindow_fnContextSensitiveHelp +}; + +/* IOleInPlaceSite interface */ +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnQueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppvObj) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj); +} + +static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnAddRef(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + return IOleClientSite_AddRef(&This->IOleClientSite_iface); +} + +static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnRelease(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + return IOleClientSite_Release(&This->IOleClientSite_iface); +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindow(IOleInPlaceSite *iface, HWND *phwnd) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + return IOleWindow_GetWindow(&This->IOleWindow_iface, phwnd); +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + return IOleWindow_ContextSensitiveHelp(&This->IOleWindow_iface, fEnterMode); +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnCanInPlaceActivate(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceActivate(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIActivate(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindowContext(IOleInPlaceSite *iface, IOleInPlaceFrame **ppFrame, + IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, + LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)->(%p %p %p %p %p)\n", This, ppFrame, ppDoc, lprcPosRect, lprcClipRect, lpFrameInfo); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnScroll(IOleInPlaceSite *iface, SIZE scrollExtent) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)->(%d)\n", This, fUndoable); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnInPlaceDeactivate(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDiscardUndoState(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnDeactivateAndUndo(IOleInPlaceSite *iface) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)\n", This); + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnOnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect) +{ + IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); + FIXME("not implemented: (%p)->(%p)\n", This, lprcPosRect); + return E_NOTIMPL; +} + +static const IOleInPlaceSiteVtbl olestvt = +{ + IOleInPlaceSite_fnQueryInterface, + IOleInPlaceSite_fnAddRef, + IOleInPlaceSite_fnRelease, + IOleInPlaceSite_fnGetWindow, + IOleInPlaceSite_fnContextSensitiveHelp, + IOleInPlaceSite_fnCanInPlaceActivate, + IOleInPlaceSite_fnOnInPlaceActivate, + IOleInPlaceSite_fnOnUIActivate, + IOleInPlaceSite_fnGetWindowContext, + IOleInPlaceSite_fnScroll, + IOleInPlaceSite_fnOnUIDeactivate, + IOleInPlaceSite_fnOnInPlaceDeactivate, + IOleInPlaceSite_fnDiscardUndoState, + IOleInPlaceSite_fnDeactivateAndUndo, + IOleInPlaceSite_fnOnPosRectChange +}; + +static HRESULT CreateOleClientSite(IRichEditOleImpl *reOle, IOleClientSite **ret) { IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite); + if (!clientSite) - return NULL; + return E_OUTOFMEMORY; clientSite->IOleClientSite_iface.lpVtbl = &ocst; + clientSite->IOleWindow_iface.lpVtbl = &olewinvt; + clientSite->IOleInPlaceSite_iface.lpVtbl = &olestvt; clientSite->ref = 1; - clientSite->reOle = reOle; - return clientSite; + clientSite->child.reole = reOle; + list_add_head(&reOle->clientsites, &clientSite->child.entry); + + *ret = &clientSite->IOleClientSite_iface; + return S_OK; } static HRESULT WINAPI -IRichEditOle_fnGetClientSite(IRichEditOle *me, - LPOLECLIENTSITE *lplpolesite) +IRichEditOle_fnGetClientSite(IRichEditOle *me, IOleClientSite **clientsite) { IRichEditOleImpl *This = impl_from_IRichEditOle(me); - TRACE("%p,%p\n",This, lplpolesite); + TRACE("(%p)->(%p)\n", This, clientsite); - if(!lplpolesite) + if (!clientsite) return E_INVALIDARG; - *lplpolesite = &This->clientSite->IOleClientSite_iface; - IOleClientSite_AddRef(*lplpolesite); - return S_OK; + + return CreateOleClientSite(This, clientsite); } static HRESULT WINAPI @@ -454,8 +1453,12 @@ static HRESULT WINAPI IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo) { IRichEditOleImpl *This = impl_from_IRichEditOle(me); + TRACE("(%p,%p)\n", This, reo); + if (!reo) + return E_INVALIDARG; + if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER; ME_InsertOLEFromCursor(This->editor, reo, 0); @@ -518,1403 +1521,11 @@ static const IRichEditOleVtbl revt = { IRichEditOle_fnImportDataObject }; -/* ITextPara interface */ -static inline ITextParaImpl *impl_from_ITextPara(ITextPara *iface) -{ - return CONTAINING_RECORD(iface, ITextParaImpl, ITextPara_iface); -} - -static HRESULT WINAPI ITextPara_fnQueryInterface(ITextPara *me, REFIID riid, void **ppvObj) -{ - *ppvObj = NULL; - if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_ITextPara) - || IsEqualGUID(riid, &IID_IDispatch)) - { - *ppvObj = me; - ITextPara_AddRef(me); - return S_OK; - } - - return E_NOINTERFACE; -} - -static ULONG WINAPI ITextPara_fnAddRef(ITextPara *me) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - return InterlockedIncrement(&This->ref); -} - -static ULONG WINAPI ITextPara_fnRelease(ITextPara *me) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE ("%p ref=%u\n", This, ref); - if (ref == 0) - { - if (This->txtRge) - ITextRange_Release(&This->txtRge->ITextRange_iface); - else - ITextSelection_Release(&This->txtSel->ITextSelection_iface); - This->txtRge = NULL; - This->txtSel = NULL; - if (This->reOle) - { - list_remove(&This->entry); - This->reOle = NULL; - } - heap_free(This); - } - return ref; -} - -static HRESULT WINAPI ITextPara_fnGetTypeInfoCount(ITextPara *me, UINT *pctinfo) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetTypeInfo(ITextPara *me, UINT iTInfo, LCID lcid, - ITypeInfo **ppTInfo) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetIDsOfNames(ITextPara *me, REFIID riid, - LPOLESTR *rgszNames, UINT cNames, - LCID lcid, DISPID *rgDispId) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnInvoke(ITextPara *me, DISPID dispIdMember, REFIID riid, - LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, - VARIANT *pVarResult, EXCEPINFO *pExcepInfo, - UINT *puArgErr) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetDuplicate(ITextPara *me, ITextPara **ppPara) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetDuplicate(ITextPara *me, ITextPara *pPara) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnCanChange(ITextPara *me, LONG *pB) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnIsEqual(ITextPara *me, ITextPara *pPara, LONG *pB) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnReset(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetStyle(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetStyle(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetAlignment(ITextPara *me, LONG *pValue) -{ - static int once; - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetAlignment(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetHyphenation(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetHyphenation(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetFirstLineIndent(ITextPara *me, float *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetKeepTogether(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetKeepTogether(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetKeepWithNext(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetKeepWithNext(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetLeftIndent(ITextPara *me, float *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetLineSpacing(ITextPara *me, float *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetLineSpacingRule(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetListAlignment(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetListAlignment(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetListLevelIndex(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetListLevelIndex(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetListStart(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetListStart(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetListTab(ITextPara *me, float *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetListTab(ITextPara *me, float Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetListType(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetListType(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetNoLineNumber(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetNoLineNumber(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetPageBreakBefore(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetPageBreakBefore(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetRightIndent(ITextPara *me, float *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetRightIndent(ITextPara *me, float Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetIndents(ITextPara *me, float StartIndent, float LeftIndent, - float RightIndent) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetLineSpacing(ITextPara *me, LONG LineSpacingRule, float LineSpacing) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetSpaceAfter(ITextPara *me, float *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetSpaceAfter(ITextPara *me, float Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetSpaceBefore(ITextPara *me, float *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetSpaceBefore(ITextPara *me, float Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetWindowControl(ITextPara *me, LONG *pValue) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnSetWindowControl(ITextPara *me, LONG Value) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetTabCount(ITextPara *me, LONG *pCount) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnAddTab(ITextPara *me, float tbPos, LONG tbAlign, LONG tbLeader) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnClearAllTabs(ITextPara *me) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnDeleteTab(ITextPara *me, float tbPos) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextPara_fnGetTab(ITextPara *me, LONG iTab, float *ptbPos, - LONG *ptbAlign, LONG *ptbLeader) -{ - ITextParaImpl *This = impl_from_ITextPara(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static const ITextParaVtbl tpvt = { - ITextPara_fnQueryInterface, - ITextPara_fnAddRef, - ITextPara_fnRelease, - ITextPara_fnGetTypeInfoCount, - ITextPara_fnGetTypeInfo, - ITextPara_fnGetIDsOfNames, - ITextPara_fnInvoke, - ITextPara_fnGetDuplicate, - ITextPara_fnSetDuplicate, - ITextPara_fnCanChange, - ITextPara_fnIsEqual, - ITextPara_fnReset, - ITextPara_fnGetStyle, - ITextPara_fnSetStyle, - ITextPara_fnGetAlignment, - ITextPara_fnSetAlignment, - ITextPara_fnGetHyphenation, - ITextPara_fnSetHyphenation, - ITextPara_fnGetFirstLineIndent, - ITextPara_fnGetKeepTogether, - ITextPara_fnSetKeepTogether, - ITextPara_fnGetKeepWithNext, - ITextPara_fnSetKeepWithNext, - ITextPara_fnGetLeftIndent, - ITextPara_fnGetLineSpacing, - ITextPara_fnGetLineSpacingRule, - ITextPara_fnGetListAlignment, - ITextPara_fnSetListAlignment, - ITextPara_fnGetListLevelIndex, - ITextPara_fnSetListLevelIndex, - ITextPara_fnGetListStart, - ITextPara_fnSetListStart, - ITextPara_fnGetListTab, - ITextPara_fnSetListTab, - ITextPara_fnGetListType, - ITextPara_fnSetListType, - ITextPara_fnGetNoLineNumber, - ITextPara_fnSetNoLineNumber, - ITextPara_fnGetPageBreakBefore, - ITextPara_fnSetPageBreakBefore, - ITextPara_fnGetRightIndent, - ITextPara_fnSetRightIndent, - ITextPara_fnSetIndents, - ITextPara_fnSetLineSpacing, - ITextPara_fnGetSpaceAfter, - ITextPara_fnSetSpaceAfter, - ITextPara_fnGetSpaceBefore, - ITextPara_fnSetSpaceBefore, - ITextPara_fnGetWindowControl, - ITextPara_fnSetWindowControl, - ITextPara_fnGetTabCount, - ITextPara_fnAddTab, - ITextPara_fnClearAllTabs, - ITextPara_fnDeleteTab, - ITextPara_fnGetTab -}; -/* ITextPara interface */ - -/* ITextFont interface */ -static inline ITextFontImpl *impl_from_ITextFont(ITextFont *iface) -{ - return CONTAINING_RECORD(iface, ITextFontImpl, ITextFont_iface); -} - -static HRESULT WINAPI ITextFont_fnQueryInterface(ITextFont *me, REFIID riid, void **ppvObj) -{ - *ppvObj = NULL; - if (IsEqualGUID(riid, &IID_IUnknown) - || IsEqualGUID(riid, &IID_ITextFont) - || IsEqualGUID(riid, &IID_IDispatch)) - { - *ppvObj = me; - ITextFont_AddRef(me); - return S_OK; - } - - return E_NOINTERFACE; -} - -static ULONG WINAPI ITextFont_fnAddRef(ITextFont *me) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - return InterlockedIncrement(&This->ref); -} - -static ULONG WINAPI ITextFont_fnRelease(ITextFont *me) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE ("%p ref=%u\n", This, ref); - if (ref == 0) - { - if (This->txtRge) - ITextRange_Release(&This->txtRge->ITextRange_iface); - else - ITextSelection_Release(&This->txtSel->ITextSelection_iface); - This->txtRge = NULL; - This->txtSel = NULL; - if (This->reOle) - { - list_remove(&This->entry); - This->reOle = NULL; - } - heap_free(This); - } - return ref; -} - -static HRESULT WINAPI ITextFont_fnGetTypeInfoCount(ITextFont *me, UINT *pctinfo) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetTypeInfo(ITextFont *me, UINT iTInfo, LCID lcid, - ITypeInfo **ppTInfo) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetIDsOfNames(ITextFont *me, REFIID riid, - LPOLESTR *rgszNames, UINT cNames, - LCID lcid, DISPID *rgDispId) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnInvoke(ITextFont *me, DISPID dispIdMember, REFIID riid, - LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, - VARIANT *pVarResult, EXCEPINFO *pExcepInfo, - UINT *puArgErr) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetDuplicate(ITextFont *me, ITextFont **ppFont) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetDuplicate(ITextFont *me, ITextFont *pFont) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnCanChange(ITextFont *me, LONG *pB) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnIsEqual(ITextFont *me, ITextFont *pFont, LONG *pB) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnReset(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetStyle(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetStyle(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetAllCaps(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetAllCaps(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetAnimation(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetAnimation(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetBackColor(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetBackColor(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetBold(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("Stub\n"); - *pValue = tomFalse; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetBold(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetEmboss(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetEmboss(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetForeColor(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("Stub\n"); - *pValue = tomAutoColor; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetForeColor(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetHidden(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetHidden(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetEngrave(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetEngrave(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetItalic(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("Stub\n"); - *pValue = tomFalse; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetItalic(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetKerning(ITextFont *me, float *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetKerning(ITextFont *me, float Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetLanguageID(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetLanguageID(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetName(ITextFont *me, BSTR *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - WCHAR font[] = {'S', 'y', 's', 't', 'e', 'm', 0}; - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("Stub\n"); - *pValue = SysAllocString(font); - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetName(ITextFont *me, BSTR Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetOutline(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetOutline(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetPosition(ITextFont *me, float *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetPosition(ITextFont *me, float Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetProtected(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetProtected(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetShadow(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetShadow(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetSize(ITextFont *me, float *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("Stub\n"); - *pValue = 12.0; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetSize(ITextFont *me, float Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetSmallCaps(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetSmallCaps(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetSpacing(ITextFont *me, float *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetSpacing(ITextFont *me, float Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetStrikeThrough(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("Stub\n"); - *pValue = tomFalse; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetStrikeThrough(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetSubscript(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("Stub\n"); - *pValue = tomFalse; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetSubscript(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetSuperscript(ITextFont *me, LONG *pValue) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("Stub\n"); - *pValue = tomFalse; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetSuperscript(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetUnderline(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!pValue) - return E_INVALIDARG; - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("Stub\n"); - *pValue = tomNone; - return S_OK; -} - -static HRESULT WINAPI ITextFont_fnSetUnderline(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnGetWeight(ITextFont *me, LONG *pValue) -{ - static int once; - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - if (!once++) FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextFont_fnSetWeight(ITextFont *me, LONG Value) -{ - ITextFontImpl *This = impl_from_ITextFont(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented: %p\n", This); - return E_NOTIMPL; -} - -static const ITextFontVtbl tfvt = { - ITextFont_fnQueryInterface, - ITextFont_fnAddRef, - ITextFont_fnRelease, - ITextFont_fnGetTypeInfoCount, - ITextFont_fnGetTypeInfo, - ITextFont_fnGetIDsOfNames, - ITextFont_fnInvoke, - ITextFont_fnGetDuplicate, - ITextFont_fnSetDuplicate, - ITextFont_fnCanChange, - ITextFont_fnIsEqual, - ITextFont_fnReset, - ITextFont_fnGetStyle, - ITextFont_fnSetStyle, - ITextFont_fnGetAllCaps, - ITextFont_fnSetAllCaps, - ITextFont_fnGetAnimation, - ITextFont_fnSetAnimation, - ITextFont_fnGetBackColor, - ITextFont_fnSetBackColor, - ITextFont_fnGetBold, - ITextFont_fnSetBold, - ITextFont_fnGetEmboss, - ITextFont_fnSetEmboss, - ITextFont_fnGetForeColor, - ITextFont_fnSetForeColor, - ITextFont_fnGetHidden, - ITextFont_fnSetHidden, - ITextFont_fnGetEngrave, - ITextFont_fnSetEngrave, - ITextFont_fnGetItalic, - ITextFont_fnSetItalic, - ITextFont_fnGetKerning, - ITextFont_fnSetKerning, - ITextFont_fnGetLanguageID, - ITextFont_fnSetLanguageID, - ITextFont_fnGetName, - ITextFont_fnSetName, - ITextFont_fnGetOutline, - ITextFont_fnSetOutline, - ITextFont_fnGetPosition, - ITextFont_fnSetPosition, - ITextFont_fnGetProtected, - ITextFont_fnSetProtected, - ITextFont_fnGetShadow, - ITextFont_fnSetShadow, - ITextFont_fnGetSize, - ITextFont_fnSetSize, - ITextFont_fnGetSmallCaps, - ITextFont_fnSetSmallCaps, - ITextFont_fnGetSpacing, - ITextFont_fnSetSpacing, - ITextFont_fnGetStrikeThrough, - ITextFont_fnSetStrikeThrough, - ITextFont_fnGetSubscript, - ITextFont_fnSetSubscript, - ITextFont_fnGetSuperscript, - ITextFont_fnSetSuperscript, - ITextFont_fnGetUnderline, - ITextFont_fnSetUnderline, - ITextFont_fnGetWeight, - ITextFont_fnSetWeight -}; -/* ITextFont interface */ - /* ITextRange interface */ -static inline ITextRangeImpl *impl_from_ITextRange(ITextRange *iface) -{ - return CONTAINING_RECORD(iface, ITextRangeImpl, ITextRange_iface); -} - static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, void **ppvObj) { + ITextRangeImpl *This = impl_from_ITextRange(me); + *ppvObj = NULL; if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDispatch) @@ -1924,6 +1535,11 @@ static HRESULT WINAPI ITextRange_fnQueryInterface(ITextRange *me, REFIID riid, v ITextRange_AddRef(me); return S_OK; } + else if (IsEqualGUID(riid, &IID_Igetrichole)) + { + *ppvObj = This->child.reole; + return S_OK; + } return E_NOINTERFACE; } @@ -1942,10 +1558,10 @@ static ULONG WINAPI ITextRange_fnRelease(ITextRange *me) TRACE ("%p ref=%u\n", This, ref); if (ref == 0) { - if (This->reOle) + if (This->child.reole) { - list_remove(&This->entry); - This->reOle = NULL; + list_remove(&This->child.entry); + This->child.reole = NULL; } heap_free(This); } @@ -1955,33 +1571,39 @@ static ULONG WINAPI ITextRange_fnRelease(ITextRange *me) static HRESULT WINAPI ITextRange_fnGetTypeInfoCount(ITextRange *me, UINT *pctinfo) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", This, pctinfo); + *pctinfo = 1; + return S_OK; } static HRESULT WINAPI ITextRange_fnGetTypeInfo(ITextRange *me, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; + HRESULT hr; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + + hr = get_typeinfo(ITextRange_tid, ppTInfo); + if (SUCCEEDED(hr)) + ITypeInfo_AddRef(*ppTInfo); + return hr; } static HRESULT WINAPI ITextRange_fnGetIDsOfNames(ITextRange *me, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; + ITypeInfo *ti; + HRESULT hr; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid, + rgDispId); + + hr = get_typeinfo(ITextRange_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId); + return hr; } static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, REFIID riid, @@ -1990,57 +1612,96 @@ static HRESULT WINAPI ITextRange_fnInvoke(ITextRange *me, DISPID dispIdMember, R UINT *puArgErr) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; + ITypeInfo *ti; + HRESULT hr; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid, + wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + + hr = get_typeinfo(ITextRange_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_Invoke(ti, me, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return hr; } -static HRESULT range_GetText(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, BSTR *pbstr) +static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *str) { - int nChars, endOfs; + ITextRangeImpl *This = impl_from_ITextRange(me); + ME_TextEditor *editor; + ME_Cursor start, end; + int length; BOOL bEOP; - endOfs = ME_GetCursorOfs(end); - nChars = endOfs - ME_GetCursorOfs(start); - if (!nChars) - { - *pbstr = NULL; + TRACE("(%p)->(%p)\n", This, str); + + if (!This->child.reole) + return CO_E_RELEASED; + + if (!str) + return E_INVALIDARG; + + /* return early for degenerate range */ + if (This->start == This->end) { + *str = NULL; return S_OK; } - *pbstr = SysAllocStringLen(NULL, nChars); - if (!*pbstr) + editor = This->child.reole->editor; + ME_CursorFromCharOfs(editor, This->start, &start); + ME_CursorFromCharOfs(editor, This->end, &end); + + length = This->end - This->start; + *str = SysAllocStringLen(NULL, length); + if (!*str) return E_OUTOFMEMORY; - bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(editor)); - ME_GetTextW(editor, *pbstr, nChars, start, nChars, FALSE, bEOP); - TRACE("%s\n", wine_dbgstr_w(*pbstr)); - + bEOP = (end.pRun->next->type == diTextEnd && This->end > ME_GetTextLength(editor)); + ME_GetTextW(editor, *str, length, &start, length, FALSE, bEOP); return S_OK; } -static HRESULT WINAPI ITextRange_fnGetText(ITextRange *me, BSTR *pbstr) +static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR str) { ITextRangeImpl *This = impl_from_ITextRange(me); - ME_Cursor start, end; - if (!This->reOle) + ME_TextEditor *editor; + ME_Cursor cursor; + ME_Style *style; + int len; + + TRACE("(%p)->(%s)\n", This, debugstr_w(str)); + + if (!This->child.reole) return CO_E_RELEASED; - ME_CursorFromCharOfs(This->reOle->editor, This->start, &start); - ME_CursorFromCharOfs(This->reOle->editor, This->end, &end); - return range_GetText(This->reOle->editor, &start, &end, pbstr); -} + editor = This->child.reole->editor; -static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR bstr) -{ - ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; + /* delete only where's something to delete */ + if (This->start != This->end) { + ME_CursorFromCharOfs(editor, This->start, &cursor); + ME_InternalDeleteText(editor, &cursor, This->end - This->start, FALSE); + } - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + if (!str || !*str) { + /* will update this range as well */ + textranges_update_ranges(This->child.reole, This->start, This->end, RANGE_UPDATE_DELETE); + return S_OK; + } + + /* it's safer not to rely on stored BSTR length */ + len = strlenW(str); + cursor = editor->pCursors[0]; + ME_CursorFromCharOfs(editor, This->start, &editor->pCursors[0]); + style = ME_GetInsertStyle(editor, 0); + ME_InsertTextFromCursor(editor, 0, str, len, style); + ME_ReleaseStyle(style); + editor->pCursors[0] = cursor; + + if (len < This->end - This->start) + textranges_update_ranges(This->child.reole, This->start + len, This->end, RANGE_UPDATE_DELETE); + else + This->end = len - This->start; + + return S_OK; } static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch) @@ -2056,25 +1717,31 @@ static HRESULT range_GetChar(ME_TextEditor *editor, ME_Cursor *cursor, LONG *pch static HRESULT WINAPI ITextRange_fnGetChar(ITextRange *me, LONG *pch) { ITextRangeImpl *This = impl_from_ITextRange(me); + ME_TextEditor *editor; ME_Cursor cursor; - if (!This->reOle) + TRACE("(%p)->(%p)\n", This, pch); + + if (!This->child.reole) return CO_E_RELEASED; - TRACE("%p\n", pch); + if (!pch) return E_INVALIDARG; - ME_CursorFromCharOfs(This->reOle->editor, This->start, &cursor); - return range_GetChar(This->reOle->editor, &cursor, pch); + editor = This->child.reole->editor; + ME_CursorFromCharOfs(editor, This->start, &cursor); + return range_GetChar(editor, &cursor, pch); } static HRESULT WINAPI ITextRange_fnSetChar(ITextRange *me, LONG ch) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%x): stub\n", This, ch); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } @@ -2083,226 +1750,221 @@ static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, I static HRESULT WINAPI ITextRange_fnGetDuplicate(ITextRange *me, ITextRange **ppRange) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%p)\n", This, ppRange); + + if (!This->child.reole) return CO_E_RELEASED; - TRACE("%p %p\n", This, ppRange); if (!ppRange) return E_INVALIDARG; - return CreateITextRange(This->reOle, This->start, This->end, ppRange); + return CreateITextRange(This->child.reole, This->start, This->end, ppRange); } -static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **ppRange) +static HRESULT WINAPI ITextRange_fnGetFormattedText(ITextRange *me, ITextRange **range) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%p): stub\n", This, range); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *pRange) +static HRESULT WINAPI ITextRange_fnSetFormattedText(ITextRange *me, ITextRange *range) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%p): stub\n", This, range); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *pcpFirst) +static HRESULT WINAPI ITextRange_fnGetStart(ITextRange *me, LONG *start) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%p)\n", This, start); + + if (!This->child.reole) return CO_E_RELEASED; - if (!pcpFirst) + if (!start) return E_INVALIDARG; - *pcpFirst = This->start; - TRACE("%d\n", *pcpFirst); + + *start = This->start; return S_OK; } -static HRESULT range_SetStart(ME_TextEditor *editor, LONG cpFirst, LONG *start, LONG *end) +static HRESULT textrange_setstart(const IRichEditOleImpl *reole, LONG value, LONG *start, LONG *end) { - int len = ME_GetTextLength(editor); + int len; - TRACE("%d\n", cpFirst); - if (cpFirst == *start) + if (value < 0) + value = 0; + + if (value == *start) return S_FALSE; - cpFirst = min(cpFirst, len); - cpFirst = max(cpFirst, 0); - *end = max(*end, cpFirst); - *start = cpFirst; + + if (value <= *end) { + *start = value; + return S_OK; + } + + len = ME_GetTextLength(reole->editor); + *start = *end = value > len ? len : value; return S_OK; } -static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG cpFirst) +static HRESULT WINAPI ITextRange_fnSetStart(ITextRange *me, LONG value) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%d)\n", This, value); + + if (!This->child.reole) return CO_E_RELEASED; - return range_SetStart(This->reOle->editor, cpFirst, &This->start, &This->end); + return textrange_setstart(This->child.reole, value, &This->start, &This->end); } -static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *pcpLim) +static HRESULT WINAPI ITextRange_fnGetEnd(ITextRange *me, LONG *end) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%p)\n", This, end); + + if (!This->child.reole) return CO_E_RELEASED; - if (!pcpLim) + if (!end) return E_INVALIDARG; - *pcpLim = This->end; - TRACE("%d\n", *pcpLim); + + *end = This->end; return S_OK; } -static HRESULT range_SetEnd(ME_TextEditor *editor, LONG cpLim, LONG *start, LONG *end) +static HRESULT textrange_setend(const IRichEditOleImpl *reole, LONG value, LONG *start, LONG *end) { - int len = ME_GetTextLength(editor) + 1; + int len; - TRACE("%d\n", cpLim); - if (cpLim == *end) + if (value == *end) return S_FALSE; - cpLim = min(cpLim, len); - cpLim = max(cpLim, 0); - *start = min(*start, cpLim); - *end = cpLim; - return S_OK; -} -static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG cpLim) -{ - ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; - - return range_SetEnd(This->reOle->editor, cpLim, &This->start, &This->end); -} - -static HRESULT CreateITextFont(IRichEditOleImpl *reOle, ITextFontImpl **ptxtFont) -{ - ITextFontImpl *txtFont = NULL; - txtFont = heap_alloc(sizeof(ITextFontImpl)); - if (!txtFont) - return E_OUTOFMEMORY; - - txtFont->ITextFont_iface.lpVtbl = &tfvt; - txtFont->ref = 1; - txtFont->reOle = reOle; - list_add_head(&reOle->fontlist, &txtFont->entry); - *ptxtFont = txtFont; - return S_OK; -} - -static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **pFont) -{ - ITextRangeImpl *This = impl_from_ITextRange(me); - ITextFontImpl *txtFont = NULL; - HRESULT hres; - - if (!This->reOle) - return CO_E_RELEASED; - - TRACE("%p\n", This); - if (!pFont) - return E_INVALIDARG; - hres = CreateITextFont(This->reOle, &txtFont); - if (!hres) - { - txtFont->txtSel = NULL; - txtFont->txtRge = This; - ITextRange_AddRef(me); - *pFont = &txtFont->ITextFont_iface; + if (value < *start) { + *start = *end = max(0, value); + return S_OK; } - return hres; -} -static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *pFont) -{ - ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented %p\n", This); - return E_NOTIMPL; -} - -static HRESULT CreateITextPara(IRichEditOleImpl *reOle, ITextParaImpl **ptxtPara) -{ - ITextParaImpl *txtPara = NULL; - txtPara = heap_alloc(sizeof(ITextParaImpl)); - if (!txtPara) - return E_OUTOFMEMORY; - - txtPara->ITextPara_iface.lpVtbl = &tpvt; - txtPara->ref = 1; - txtPara->reOle = reOle; - list_add_head(&reOle->paralist, &txtPara->entry); - *ptxtPara = txtPara; + len = ME_GetTextLength(reole->editor); + *end = value > len ? len + 1 : value; return S_OK; } -static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **ppPara) +static HRESULT WINAPI ITextRange_fnSetEnd(ITextRange *me, LONG value) { ITextRangeImpl *This = impl_from_ITextRange(me); - ITextParaImpl *txtPara = NULL; - HRESULT hres; - if (!This->reOle) + TRACE("(%p)->(%d)\n", This, value); + + if (!This->child.reole) return CO_E_RELEASED; - TRACE("%p\n", This); - if (!ppPara) - return E_INVALIDARG; - hres = CreateITextPara(This->reOle, &txtPara); - if (!hres) - { - txtPara->txtSel = NULL; - txtPara->txtRge = This; - ITextRange_AddRef(me); - *ppPara = &txtPara->ITextPara_iface; - } - return hres; + return textrange_setend(This->child.reole, value, &This->start, &This->end); } -static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *pPara) +static HRESULT WINAPI ITextRange_fnGetFont(ITextRange *me, ITextFont **font) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%p)\n", This, font); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; + if (!font) + return E_INVALIDARG; + + return create_textfont(me, NULL, font); } -static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *pcch) +static HRESULT WINAPI ITextRange_fnSetFont(ITextRange *me, ITextFont *font) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%p)\n", This, font); + + if (!font) + return E_INVALIDARG; + + if (!This->child.reole) return CO_E_RELEASED; - if (!pcch) - return E_INVALIDARG; - *pcch = ME_GetTextLength(This->reOle->editor) + 1; + textrange_set_font(me, font); return S_OK; } -static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *pValue) +static HRESULT WINAPI ITextRange_fnGetPara(ITextRange *me, ITextPara **para) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%p)\n", This, para); + + if (!This->child.reole) + return CO_E_RELEASED; + + if (!para) + return E_INVALIDARG; + + return create_textpara(me, para); +} + +static HRESULT WINAPI ITextRange_fnSetPara(ITextRange *me, ITextPara *para) +{ + ITextRangeImpl *This = impl_from_ITextRange(me); + + FIXME("(%p)->(%p): stub\n", This, para); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } +static HRESULT WINAPI ITextRange_fnGetStoryLength(ITextRange *me, LONG *length) +{ + ITextRangeImpl *This = impl_from_ITextRange(me); + + TRACE("(%p)->(%p)\n", This, length); + + if (!This->child.reole) + return CO_E_RELEASED; + + return textrange_get_storylength(This->child.reole->editor, length); +} + +static HRESULT WINAPI ITextRange_fnGetStoryType(ITextRange *me, LONG *value) +{ + ITextRangeImpl *This = impl_from_ITextRange(me); + + TRACE("(%p)->(%p)\n", This, value); + + if (!This->child.reole) + return CO_E_RELEASED; + + if (!value) + return E_INVALIDARG; + + *value = tomUnknownStory; + return S_OK; +} + static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end) { if (*end == *start) @@ -2318,40 +1980,49 @@ static HRESULT range_Collapse(LONG bStart, LONG *start, LONG *end) static HRESULT WINAPI ITextRange_fnCollapse(ITextRange *me, LONG bStart) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%d)\n", This, bStart); + + if (!This->child.reole) return CO_E_RELEASED; return range_Collapse(bStart, &This->start, &This->end); } -static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG Unit, LONG *pDelta) +static HRESULT WINAPI ITextRange_fnExpand(ITextRange *me, LONG unit, LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%d %p)\n", This, unit, delta); + + if (!This->child.reole) + return CO_E_RELEASED; + + return textrange_expand(me, unit, delta); +} + +static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG unit, LONG *index) +{ + ITextRangeImpl *This = impl_from_ITextRange(me); + + FIXME("(%p)->(%d %p): stub\n", This, unit, index); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnGetIndex(ITextRange *me, LONG Unit, LONG *pIndex) +static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG unit, LONG index, + LONG extend) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d %d): stub\n", This, unit, index, extend); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG Unit, LONG Index, - LONG Extend) -{ - ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented %p\n", This); return E_NOTIMPL; } @@ -2372,339 +2043,426 @@ static void cp2range(ME_TextEditor *editor, LONG *cp1, LONG *cp2) *cp1 = *cp2 = len - 1; } -static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG cpActive, LONG cpOther) +static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG anchor, LONG active) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d): stub\n", This, anchor, active); + + if (!This->child.reole) return CO_E_RELEASED; - cp2range(This->reOle->editor, &cpActive, &cpOther); - if (cpActive == This->start && cpOther == This->end) + cp2range(This->child.reole->editor, &anchor, &active); + if (anchor == This->start && active == This->end) return S_FALSE; - This->start = cpActive; - This->end = cpOther; + This->start = anchor; + This->end = active; return S_OK; } -static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *pRange, LONG *pb) +static HRESULT textrange_inrange(LONG start, LONG end, ITextRange *range, LONG *ret) { - ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; + LONG from, to, v; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; -} + if (!ret) + ret = &v; -static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *pb) -{ - ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented %p\n", This); - return E_NOTIMPL; -} - -static HRESULT range_IsEqual(LONG start, LONG end, ITextRange *pRange, LONG *pb) -{ - ITextRangeImpl *pRangeImpl = impl_from_ITextRange(pRange); - if (start == pRangeImpl->start && end == pRangeImpl->end) - { - if (pb) - *pb = tomTrue; - return S_OK; + if (FAILED(ITextRange_GetStart(range, &from)) || FAILED(ITextRange_GetEnd(range, &to))) { + *ret = tomFalse; } - if (pb) - *pb = tomFalse; - return S_FALSE; + else + *ret = (start >= from && end <= to) ? tomTrue : tomFalse; + return *ret == tomTrue ? S_OK : S_FALSE; } -static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *pRange, LONG *pb) +static HRESULT WINAPI ITextRange_fnInRange(ITextRange *me, ITextRange *range, LONG *ret) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)->(%p %p)\n", This, range, ret); + + if (ret) + *ret = tomFalse; + + if (!This->child.reole) return CO_E_RELEASED; - if (!pRange) + if (!range) return S_FALSE; - return range_IsEqual(This->start, This->end, pRange, pb); + + return textrange_inrange(This->start, This->end, range, ret); +} + +static HRESULT WINAPI ITextRange_fnInStory(ITextRange *me, ITextRange *pRange, LONG *ret) +{ + ITextRangeImpl *This = impl_from_ITextRange(me); + + FIXME("(%p)->(%p): stub\n", This, ret); + + if (!This->child.reole) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT textrange_isequal(LONG start, LONG end, ITextRange *range, LONG *ret) +{ + LONG from, to, v; + + if (!ret) + ret = &v; + + if (FAILED(ITextRange_GetStart(range, &from)) || FAILED(ITextRange_GetEnd(range, &to))) { + *ret = tomFalse; + } + else + *ret = (start == from && end == to) ? tomTrue : tomFalse; + return *ret == tomTrue ? S_OK : S_FALSE; +} + +static HRESULT WINAPI ITextRange_fnIsEqual(ITextRange *me, ITextRange *range, LONG *ret) +{ + ITextRangeImpl *This = impl_from_ITextRange(me); + + TRACE("(%p)->(%p %p)\n", This, range, ret); + + if (ret) + *ret = tomFalse; + + if (!This->child.reole) + return CO_E_RELEASED; + + if (!range) + return S_FALSE; + + return textrange_isequal(This->start, This->end, range, ret); } static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + TRACE("(%p)\n", This); + + if (!This->child.reole) + return CO_E_RELEASED; + + ME_SetSelection(This->child.reole->editor, This->start, This->end); + return S_OK; +} + +static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG unit, LONG extend, + LONG *delta) +{ + ITextRangeImpl *This = impl_from_ITextRange(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnStartOf(ITextRange *me, LONG Unit, LONG Extend, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG unit, LONG extend, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnEndOf(ITextRange *me, LONG Unit, LONG Extend, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG unit, LONG count, LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMove(ITextRange *me, LONG Unit, LONG Count, LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG unit, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveStart(ITextRange *me, LONG Unit, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG unit, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveEnd(ITextRange *me, LONG Unit, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *charset, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveWhile(ITextRange *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *charset, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveStartWhile(ITextRange *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *charset, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveEndWhile(ITextRange *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *charset, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveUntil(ITextRange *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *charset, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveStartUntil(ITextRange *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *charset, LONG count, + LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnMoveEndUntil(ITextRange *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR text, LONG count, LONG flags, + LONG *length) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnFindText(ITextRange *me, BSTR bstr, LONG cch, LONG Flags, - LONG *pLength) +static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR text, LONG count, + LONG flags, LONG *length) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnFindTextStart(ITextRange *me, BSTR bstr, LONG cch, - LONG Flags, LONG *pLength) +static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR text, LONG count, + LONG flags, LONG *length) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnFindTextEnd(ITextRange *me, BSTR bstr, LONG cch, - LONG Flags, LONG *pLength) +static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG unit, LONG count, LONG *delta) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnDelete(ITextRange *me, LONG Unit, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *v) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%p): stub\n", This, v); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnCut(ITextRange *me, VARIANT *pVar) +static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *v) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%p): stub\n", This, v); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnCopy(ITextRange *me, VARIANT *pVar) +static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *v, LONG format) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %x): stub\n", This, debugstr_variant(v), format); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnPaste(ITextRange *me, VARIANT *pVar, LONG Format) +static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *v, LONG format, LONG *ret) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%s %x %p): stub\n", This, debugstr_variant(v), format, ret); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnCanPaste(ITextRange *me, VARIANT *pVar, LONG Format, - LONG *pb) +static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *ret) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%p): stub\n", This, ret); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnCanEdit(ITextRange *me, LONG *pb) +static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG type) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d): stub\n", This, type); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnChangeCase(ITextRange *me, LONG Type) +static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG type, LONG *cx, LONG *cy) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %p %p): stub\n", This, type, cx, cy); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnGetPoint(ITextRange *me, LONG Type, LONG *cx, LONG *cy) +static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG type, + LONG extend) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d %d %d %d): stub\n", This, x, y, type, extend); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } -static HRESULT WINAPI ITextRange_fnSetPoint(ITextRange *me, LONG x, LONG y, LONG Type, - LONG Extend) +static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG value) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%d): stub\n", This, value); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG Value) -{ - ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented %p\n", This); return E_NOTIMPL; } static HRESULT WINAPI ITextRange_fnGetEmbeddedObject(ITextRange *me, IUnknown **ppv) { ITextRangeImpl *This = impl_from_ITextRange(me); - if (!This->reOle) + + FIXME("(%p)->(%p): stub\n", This, ppv); + + if (!This->child.reole) return CO_E_RELEASED; - FIXME("not implemented %p\n", This); return E_NOTIMPL; } @@ -2768,8 +2526,1534 @@ static const ITextRangeVtbl trvt = { ITextRange_fnScrollIntoView, ITextRange_fnGetEmbeddedObject }; -/* ITextRange interface */ +/* ITextFont */ +static HRESULT WINAPI TextFont_QueryInterface(ITextFont *iface, REFIID riid, void **ppv) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + + if (IsEqualIID(riid, &IID_ITextFont) || + IsEqualIID(riid, &IID_IDispatch) || + IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = iface; + ITextFont_AddRef(iface); + return S_OK; + } + + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI TextFont_AddRef(ITextFont *iface) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + ULONG ref = InterlockedIncrement(&This->ref); + TRACE("(%p)->(%u)\n", This, ref); + return ref; +} + +static ULONG WINAPI TextFont_Release(ITextFont *iface) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(%u)\n", This, ref); + + if (!ref) + { + if (This->range) + ITextRange_Release(This->range); + SysFreeString(This->props[FONT_NAME].str); + heap_free(This); + } + + return ref; +} + +static HRESULT WINAPI TextFont_GetTypeInfoCount(ITextFont *iface, UINT *pctinfo) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, pctinfo); + *pctinfo = 1; + return S_OK; +} + +static HRESULT WINAPI TextFont_GetTypeInfo(ITextFont *iface, UINT iTInfo, LCID lcid, + ITypeInfo **ppTInfo) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + HRESULT hr; + + TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + + hr = get_typeinfo(ITextFont_tid, ppTInfo); + if (SUCCEEDED(hr)) + ITypeInfo_AddRef(*ppTInfo); + return hr; +} + +static HRESULT WINAPI TextFont_GetIDsOfNames(ITextFont *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + ITypeInfo *ti; + HRESULT hr; + + TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid, + rgDispId); + + hr = get_typeinfo(ITextFont_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId); + return hr; +} + +static HRESULT WINAPI TextFont_Invoke( + ITextFont *iface, + DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + ITypeInfo *ti; + HRESULT hr; + + TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid, + wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + + hr = get_typeinfo(ITextFont_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_Invoke(ti, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return hr; +} + +static HRESULT WINAPI TextFont_GetDuplicate(ITextFont *iface, ITextFont **ret) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + + TRACE("(%p)->(%p)\n", This, ret); + + if (!ret) + return E_INVALIDARG; + + *ret = NULL; + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + + return create_textfont(NULL, This, ret); +} + +static HRESULT WINAPI TextFont_SetDuplicate(ITextFont *iface, ITextFont *pFont) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + FIXME("(%p)->(%p): stub\n", This, pFont); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextFont_CanChange(ITextFont *iface, LONG *ret) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + FIXME("(%p)->(%p): stub\n", This, ret); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextFont_IsEqual(ITextFont *iface, ITextFont *font, LONG *ret) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + FIXME("(%p)->(%p %p): stub\n", This, font, ret); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static void textfont_reset_to_default(ITextFontImpl *font) +{ + enum textfont_prop_id id; + + for (id = FONT_PROPID_FIRST; id < FONT_PROPID_LAST; id++) { + switch (id) + { + case FONT_ALLCAPS: + case FONT_ANIMATION: + case FONT_BOLD: + case FONT_EMBOSS: + case FONT_HIDDEN: + case FONT_ENGRAVE: + case FONT_ITALIC: + case FONT_OUTLINE: + case FONT_PROTECTED: + case FONT_SHADOW: + case FONT_SMALLCAPS: + case FONT_STRIKETHROUGH: + case FONT_SUBSCRIPT: + case FONT_SUPERSCRIPT: + case FONT_UNDERLINE: + font->props[id].l = tomFalse; + break; + case FONT_BACKCOLOR: + case FONT_FORECOLOR: + font->props[id].l = tomAutoColor; + break; + case FONT_KERNING: + case FONT_POSITION: + case FONT_SIZE: + case FONT_SPACING: + font->props[id].f = 0.0; + break; + case FONT_LANGID: + font->props[id].l = GetSystemDefaultLCID(); + break; + case FONT_NAME: { + static const WCHAR sysW[] = {'S','y','s','t','e','m',0}; + SysFreeString(font->props[id].str); + font->props[id].str = SysAllocString(sysW); + break; + } + case FONT_WEIGHT: + font->props[id].l = FW_NORMAL; + break; + default: + FIXME("font property %d not handled\n", id); + } + } +} + +static void textfont_reset_to_undefined(ITextFontImpl *font) +{ + enum textfont_prop_id id; + + for (id = FONT_PROPID_FIRST; id < FONT_PROPID_LAST; id++) { + switch (id) + { + case FONT_ALLCAPS: + case FONT_ANIMATION: + case FONT_BOLD: + case FONT_EMBOSS: + case FONT_HIDDEN: + case FONT_ENGRAVE: + case FONT_ITALIC: + case FONT_OUTLINE: + case FONT_PROTECTED: + case FONT_SHADOW: + case FONT_SMALLCAPS: + case FONT_STRIKETHROUGH: + case FONT_SUBSCRIPT: + case FONT_SUPERSCRIPT: + case FONT_UNDERLINE: + case FONT_BACKCOLOR: + case FONT_FORECOLOR: + case FONT_LANGID: + case FONT_WEIGHT: + font->props[id].l = tomUndefined; + break; + case FONT_KERNING: + case FONT_POSITION: + case FONT_SIZE: + case FONT_SPACING: + font->props[id].f = tomUndefined; + break; + case FONT_NAME: + break; + default: + FIXME("font property %d not handled\n", id); + } + } +} + +static void textfont_apply_range_props(ITextFontImpl *font) +{ + enum textfont_prop_id propid; + for (propid = FONT_PROPID_FIRST; propid < FONT_PROPID_LAST; propid++) + set_textfont_prop(font, propid, &font->props[propid]); +} + +static HRESULT WINAPI TextFont_Reset(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + + TRACE("(%p)->(%d)\n", This, value); + + /* If font is attached to a range, released or not, we can't + reset to undefined */ + if (This->range) { + if (!get_range_reole(This->range)) + return CO_E_RELEASED; + + switch (value) + { + case tomUndefined: + return E_INVALIDARG; + case tomCacheParms: + textfont_cache_range_props(This); + This->get_cache_enabled = TRUE; + break; + case tomTrackParms: + This->get_cache_enabled = FALSE; + break; + case tomApplyLater: + This->set_cache_enabled = TRUE; + break; + case tomApplyNow: + This->set_cache_enabled = FALSE; + textfont_apply_range_props(This); + break; + case tomUsePoints: + case tomUseTwips: + return E_INVALIDARG; + default: + FIXME("reset mode %d not supported\n", value); + } + + return S_OK; + } + else { + switch (value) + { + /* reset to global defaults */ + case tomDefault: + textfont_reset_to_default(This); + return S_OK; + /* all properties are set to tomUndefined, font name is retained */ + case tomUndefined: + textfont_reset_to_undefined(This); + return S_OK; + case tomApplyNow: + case tomApplyLater: + case tomTrackParms: + case tomCacheParms: + return S_OK; + case tomUsePoints: + case tomUseTwips: + return E_INVALIDARG; + } + } + + FIXME("reset mode %d not supported\n", value); + return E_NOTIMPL; +} + +static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + FIXME("(%p)->(%p): stub\n", This, value); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + FIXME("(%p)->(%d): stub\n", This, value); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextFont_GetAllCaps(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_ALLCAPS, value); +} + +static HRESULT WINAPI TextFont_SetAllCaps(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_ALLCAPS, value); +} + +static HRESULT WINAPI TextFont_GetAnimation(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_ANIMATION, value); +} + +static HRESULT WINAPI TextFont_SetAnimation(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + + TRACE("(%p)->(%d)\n", This, value); + + if (value < tomNoAnimation || value > tomAnimationMax) + return E_INVALIDARG; + + return set_textfont_propl(This, FONT_ANIMATION, value); +} + +static HRESULT WINAPI TextFont_GetBackColor(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_BACKCOLOR, value); +} + +static HRESULT WINAPI TextFont_SetBackColor(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propl(This, FONT_BACKCOLOR, value); +} + +static HRESULT WINAPI TextFont_GetBold(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_BOLD, value); +} + +static HRESULT WINAPI TextFont_SetBold(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_BOLD, value); +} + +static HRESULT WINAPI TextFont_GetEmboss(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_EMBOSS, value); +} + +static HRESULT WINAPI TextFont_SetEmboss(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_EMBOSS, value); +} + +static HRESULT WINAPI TextFont_GetForeColor(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_FORECOLOR, value); +} + +static HRESULT WINAPI TextFont_SetForeColor(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propl(This, FONT_FORECOLOR, value); +} + +static HRESULT WINAPI TextFont_GetHidden(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_HIDDEN, value); +} + +static HRESULT WINAPI TextFont_SetHidden(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_HIDDEN, value); +} + +static HRESULT WINAPI TextFont_GetEngrave(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_ENGRAVE, value); +} + +static HRESULT WINAPI TextFont_SetEngrave(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_ENGRAVE, value); +} + +static HRESULT WINAPI TextFont_GetItalic(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_ITALIC, value); +} + +static HRESULT WINAPI TextFont_SetItalic(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_ITALIC, value); +} + +static HRESULT WINAPI TextFont_GetKerning(ITextFont *iface, FLOAT *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propf(This, FONT_KERNING, value); +} + +static HRESULT WINAPI TextFont_SetKerning(ITextFont *iface, FLOAT value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%.2f)\n", This, value); + return set_textfont_propf(This, FONT_KERNING, value); +} + +static HRESULT WINAPI TextFont_GetLanguageID(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_LANGID, value); +} + +static HRESULT WINAPI TextFont_SetLanguageID(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propl(This, FONT_LANGID, value); +} + +static HRESULT WINAPI TextFont_GetName(ITextFont *iface, BSTR *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + + TRACE("(%p)->(%p)\n", This, value); + + if (!value) + return E_INVALIDARG; + + *value = NULL; + + if (!This->range) { + if (This->props[FONT_NAME].str) + *value = SysAllocString(This->props[FONT_NAME].str); + else + *value = SysAllocStringLen(NULL, 0); + return *value ? S_OK : E_OUTOFMEMORY; + } + + return textfont_getname_from_range(This->range, value); +} + +static HRESULT WINAPI TextFont_SetName(ITextFont *iface, BSTR value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + textfont_prop_val v; + + TRACE("(%p)->(%s)\n", This, debugstr_w(value)); + + v.str = value; + return set_textfont_prop(This, FONT_NAME, &v); +} + +static HRESULT WINAPI TextFont_GetOutline(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_OUTLINE, value); +} + +static HRESULT WINAPI TextFont_SetOutline(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_OUTLINE, value); +} + +static HRESULT WINAPI TextFont_GetPosition(ITextFont *iface, FLOAT *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propf(This, FONT_POSITION, value); +} + +static HRESULT WINAPI TextFont_SetPosition(ITextFont *iface, FLOAT value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%.2f)\n", This, value); + return set_textfont_propf(This, FONT_POSITION, value); +} + +static HRESULT WINAPI TextFont_GetProtected(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_PROTECTED, value); +} + +static HRESULT WINAPI TextFont_SetProtected(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_PROTECTED, value); +} + +static HRESULT WINAPI TextFont_GetShadow(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_SHADOW, value); +} + +static HRESULT WINAPI TextFont_SetShadow(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_SHADOW, value); +} + +static HRESULT WINAPI TextFont_GetSize(ITextFont *iface, FLOAT *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propf(This, FONT_SIZE, value); +} + +static HRESULT WINAPI TextFont_SetSize(ITextFont *iface, FLOAT value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%.2f)\n", This, value); + return set_textfont_propf(This, FONT_SIZE, value); +} + +static HRESULT WINAPI TextFont_GetSmallCaps(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_SMALLCAPS, value); +} + +static HRESULT WINAPI TextFont_SetSmallCaps(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_SMALLCAPS, value); +} + +static HRESULT WINAPI TextFont_GetSpacing(ITextFont *iface, FLOAT *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propf(This, FONT_SPACING, value); +} + +static HRESULT WINAPI TextFont_SetSpacing(ITextFont *iface, FLOAT value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%.2f)\n", This, value); + return set_textfont_propf(This, FONT_SPACING, value); +} + +static HRESULT WINAPI TextFont_GetStrikeThrough(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_STRIKETHROUGH, value); +} + +static HRESULT WINAPI TextFont_SetStrikeThrough(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_STRIKETHROUGH, value); +} + +static HRESULT WINAPI TextFont_GetSubscript(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_SUBSCRIPT, value); +} + +static HRESULT WINAPI TextFont_SetSubscript(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_SUBSCRIPT, value); +} + +static HRESULT WINAPI TextFont_GetSuperscript(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_SUPERSCRIPT, value); +} + +static HRESULT WINAPI TextFont_SetSuperscript(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_SUPERSCRIPT, value); +} + +static HRESULT WINAPI TextFont_GetUnderline(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_UNDERLINE, value); +} + +static HRESULT WINAPI TextFont_SetUnderline(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propd(This, FONT_UNDERLINE, value); +} + +static HRESULT WINAPI TextFont_GetWeight(ITextFont *iface, LONG *value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%p)\n", This, value); + return get_textfont_propl(This, FONT_WEIGHT, value); +} + +static HRESULT WINAPI TextFont_SetWeight(ITextFont *iface, LONG value) +{ + ITextFontImpl *This = impl_from_ITextFont(iface); + TRACE("(%p)->(%d)\n", This, value); + return set_textfont_propl(This, FONT_WEIGHT, value); +} + +static ITextFontVtbl textfontvtbl = { + TextFont_QueryInterface, + TextFont_AddRef, + TextFont_Release, + TextFont_GetTypeInfoCount, + TextFont_GetTypeInfo, + TextFont_GetIDsOfNames, + TextFont_Invoke, + TextFont_GetDuplicate, + TextFont_SetDuplicate, + TextFont_CanChange, + TextFont_IsEqual, + TextFont_Reset, + TextFont_GetStyle, + TextFont_SetStyle, + TextFont_GetAllCaps, + TextFont_SetAllCaps, + TextFont_GetAnimation, + TextFont_SetAnimation, + TextFont_GetBackColor, + TextFont_SetBackColor, + TextFont_GetBold, + TextFont_SetBold, + TextFont_GetEmboss, + TextFont_SetEmboss, + TextFont_GetForeColor, + TextFont_SetForeColor, + TextFont_GetHidden, + TextFont_SetHidden, + TextFont_GetEngrave, + TextFont_SetEngrave, + TextFont_GetItalic, + TextFont_SetItalic, + TextFont_GetKerning, + TextFont_SetKerning, + TextFont_GetLanguageID, + TextFont_SetLanguageID, + TextFont_GetName, + TextFont_SetName, + TextFont_GetOutline, + TextFont_SetOutline, + TextFont_GetPosition, + TextFont_SetPosition, + TextFont_GetProtected, + TextFont_SetProtected, + TextFont_GetShadow, + TextFont_SetShadow, + TextFont_GetSize, + TextFont_SetSize, + TextFont_GetSmallCaps, + TextFont_SetSmallCaps, + TextFont_GetSpacing, + TextFont_SetSpacing, + TextFont_GetStrikeThrough, + TextFont_SetStrikeThrough, + TextFont_GetSubscript, + TextFont_SetSubscript, + TextFont_GetSuperscript, + TextFont_SetSuperscript, + TextFont_GetUnderline, + TextFont_SetUnderline, + TextFont_GetWeight, + TextFont_SetWeight +}; + +static HRESULT create_textfont(ITextRange *range, const ITextFontImpl *src, ITextFont **ret) +{ + ITextFontImpl *font; + + *ret = NULL; + font = heap_alloc(sizeof(*font)); + if (!font) + return E_OUTOFMEMORY; + + font->ITextFont_iface.lpVtbl = &textfontvtbl; + font->ref = 1; + + if (src) { + font->range = NULL; + font->get_cache_enabled = TRUE; + font->set_cache_enabled = TRUE; + memcpy(&font->props, &src->props, sizeof(font->props)); + if (font->props[FONT_NAME].str) + font->props[FONT_NAME].str = SysAllocString(font->props[FONT_NAME].str); + } + else { + font->range = range; + ITextRange_AddRef(range); + + /* cache current properties */ + font->get_cache_enabled = FALSE; + font->set_cache_enabled = FALSE; + textfont_cache_range_props(font); + } + + *ret = &font->ITextFont_iface; + return S_OK; +} + +/* ITextPara */ +static HRESULT WINAPI TextPara_QueryInterface(ITextPara *iface, REFIID riid, void **ppv) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + + TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + + if (IsEqualIID(riid, &IID_ITextPara) || + IsEqualIID(riid, &IID_IDispatch) || + IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = iface; + ITextPara_AddRef(iface); + return S_OK; + } + + *ppv = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI TextPara_AddRef(ITextPara *iface) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + ULONG ref = InterlockedIncrement(&This->ref); + TRACE("(%p)->(%u)\n", This, ref); + return ref; +} + +static ULONG WINAPI TextPara_Release(ITextPara *iface) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p)->(%u)\n", This, ref); + + if (!ref) + { + ITextRange_Release(This->range); + heap_free(This); + } + + return ref; +} + +static IRichEditOleImpl *para_get_reole(ITextParaImpl *This) +{ + if (This->range) + { + ITextRangeImpl *rng = impl_from_ITextRange(This->range); + return rng->child.reole; + } + return NULL; +} + +static HRESULT WINAPI TextPara_GetTypeInfoCount(ITextPara *iface, UINT *pctinfo) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + TRACE("(%p)->(%p)\n", This, pctinfo); + *pctinfo = 1; + return S_OK; +} + +static HRESULT WINAPI TextPara_GetTypeInfo(ITextPara *iface, UINT iTInfo, LCID lcid, + ITypeInfo **ppTInfo) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + HRESULT hr; + + TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + + hr = get_typeinfo(ITextPara_tid, ppTInfo); + if (SUCCEEDED(hr)) + ITypeInfo_AddRef(*ppTInfo); + return hr; +} + +static HRESULT WINAPI TextPara_GetIDsOfNames(ITextPara *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + ITypeInfo *ti; + HRESULT hr; + + TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid, + rgDispId); + + hr = get_typeinfo(ITextPara_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId); + return hr; +} + +static HRESULT WINAPI TextPara_Invoke( + ITextPara *iface, + DISPID dispIdMember, + REFIID riid, + LCID lcid, + WORD wFlags, + DISPPARAMS *pDispParams, + VARIANT *pVarResult, + EXCEPINFO *pExcepInfo, + UINT *puArgErr) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + ITypeInfo *ti; + HRESULT hr; + + TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid, + wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + + hr = get_typeinfo(ITextPara_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_Invoke(ti, iface, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return hr; +} + +static HRESULT WINAPI TextPara_GetDuplicate(ITextPara *iface, ITextPara **ret) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, ret); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetDuplicate(ITextPara *iface, ITextPara *para) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, para); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_CanChange(ITextPara *iface, LONG *ret) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, ret); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_IsEqual(ITextPara *iface, ITextPara *para, LONG *ret) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p %p)\n", This, para, ret); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_Reset(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetStyle(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetStyle(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetAlignment(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + static int once; + + if (!once++) FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetAlignment(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetHyphenation(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetHyphenation(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetFirstLineIndent(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetKeepTogether(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetKeepTogether(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetKeepWithNext(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetKeepWithNext(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetLeftIndent(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetLineSpacing(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetLineSpacingRule(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListAlignment(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListAlignment(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListLevelIndex(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListLevelIndex(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListStart(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListStart(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListTab(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListTab(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetListType(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetListType(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetNoLineNumber(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetNoLineNumber(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetPageBreakBefore(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetPageBreakBefore(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetRightIndent(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetRightIndent(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetIndents(ITextPara *iface, FLOAT StartIndent, FLOAT LeftIndent, FLOAT RightIndent) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f %.2f %.2f)\n", This, StartIndent, LeftIndent, RightIndent); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetLineSpacing(ITextPara *iface, LONG LineSpacingRule, FLOAT LineSpacing) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d %.2f)\n", This, LineSpacingRule, LineSpacing); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetSpaceAfter(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetSpaceAfter(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetSpaceBefore(ITextPara *iface, FLOAT *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetSpaceBefore(ITextPara *iface, FLOAT value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetWidowControl(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_SetWidowControl(ITextPara *iface, LONG value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetTabCount(ITextPara *iface, LONG *value) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_AddTab(ITextPara *iface, FLOAT tbPos, LONG tbAlign, LONG tbLeader) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f %d %d)\n", This, tbPos, tbAlign, tbLeader); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_ClearAllTabs(ITextPara *iface) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)\n", This); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_DeleteTab(ITextPara *iface, FLOAT pos) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%.2f)\n", This, pos); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI TextPara_GetTab(ITextPara *iface, LONG iTab, FLOAT *ptbPos, LONG *ptbAlign, LONG *ptbLeader) +{ + ITextParaImpl *This = impl_from_ITextPara(iface); + FIXME("(%p)->(%d %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static ITextParaVtbl textparavtbl = { + TextPara_QueryInterface, + TextPara_AddRef, + TextPara_Release, + TextPara_GetTypeInfoCount, + TextPara_GetTypeInfo, + TextPara_GetIDsOfNames, + TextPara_Invoke, + TextPara_GetDuplicate, + TextPara_SetDuplicate, + TextPara_CanChange, + TextPara_IsEqual, + TextPara_Reset, + TextPara_GetStyle, + TextPara_SetStyle, + TextPara_GetAlignment, + TextPara_SetAlignment, + TextPara_GetHyphenation, + TextPara_SetHyphenation, + TextPara_GetFirstLineIndent, + TextPara_GetKeepTogether, + TextPara_SetKeepTogether, + TextPara_GetKeepWithNext, + TextPara_SetKeepWithNext, + TextPara_GetLeftIndent, + TextPara_GetLineSpacing, + TextPara_GetLineSpacingRule, + TextPara_GetListAlignment, + TextPara_SetListAlignment, + TextPara_GetListLevelIndex, + TextPara_SetListLevelIndex, + TextPara_GetListStart, + TextPara_SetListStart, + TextPara_GetListTab, + TextPara_SetListTab, + TextPara_GetListType, + TextPara_SetListType, + TextPara_GetNoLineNumber, + TextPara_SetNoLineNumber, + TextPara_GetPageBreakBefore, + TextPara_SetPageBreakBefore, + TextPara_GetRightIndent, + TextPara_SetRightIndent, + TextPara_SetIndents, + TextPara_SetLineSpacing, + TextPara_GetSpaceAfter, + TextPara_SetSpaceAfter, + TextPara_GetSpaceBefore, + TextPara_SetSpaceBefore, + TextPara_GetWidowControl, + TextPara_SetWidowControl, + TextPara_GetTabCount, + TextPara_AddTab, + TextPara_ClearAllTabs, + TextPara_DeleteTab, + TextPara_GetTab +}; + +static HRESULT create_textpara(ITextRange *range, ITextPara **ret) +{ + ITextParaImpl *para; + + *ret = NULL; + para = heap_alloc(sizeof(*para)); + if (!para) + return E_OUTOFMEMORY; + + para->ITextPara_iface.lpVtbl = &textparavtbl; + para->ref = 1; + para->range = range; + ITextRange_AddRef(range); + + *ret = ¶->ITextPara_iface; + return S_OK; +} + +/* ITextDocument */ static HRESULT WINAPI ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid, void** ppvObject) @@ -2797,8 +4081,9 @@ ITextDocument_fnGetTypeInfoCount(ITextDocument* me, UINT* pctinfo) { IRichEditOleImpl *This = impl_from_ITextDocument(me); - FIXME("stub %p\n",This); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", This, pctinfo); + *pctinfo = 1; + return S_OK; } static HRESULT WINAPI @@ -2806,8 +4091,14 @@ ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) { IRichEditOleImpl *This = impl_from_ITextDocument(me); - FIXME("stub %p\n",This); - return E_NOTIMPL; + HRESULT hr; + + TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + + hr = get_typeinfo(ITextDocument_tid, ppTInfo); + if (SUCCEEDED(hr)) + ITypeInfo_AddRef(*ppTInfo); + return hr; } static HRESULT WINAPI @@ -2815,8 +4106,16 @@ ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) { IRichEditOleImpl *This = impl_from_ITextDocument(me); - FIXME("stub %p\n",This); - return E_NOTIMPL; + ITypeInfo *ti; + HRESULT hr; + + TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid, + rgDispId); + + hr = get_typeinfo(ITextDocument_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId); + return hr; } static HRESULT WINAPI @@ -2825,8 +4124,16 @@ ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) { IRichEditOleImpl *This = impl_from_ITextDocument(me); - FIXME("stub %p\n",This); - return E_NOTIMPL; + ITypeInfo *ti; + HRESULT hr; + + TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid, + wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + + hr = get_typeinfo(ITextDocument_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_Invoke(ti, me, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return hr; } static HRESULT WINAPI @@ -2838,15 +4145,25 @@ ITextDocument_fnGetName(ITextDocument* me, BSTR* pName) } static HRESULT WINAPI -ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel) +ITextDocument_fnGetSelection(ITextDocument *me, ITextSelection **selection) { IRichEditOleImpl *This = impl_from_ITextDocument(me); - TRACE("(%p)\n", me); - if(!ppSel) + TRACE("(%p)->(%p)\n", me, selection); + + if (!selection) return E_INVALIDARG; - *ppSel = &This->txtSel->ITextSelection_iface; - ITextSelection_AddRef(*ppSel); + + if (!This->txtSel) { + This->txtSel = CreateTextSelection(This); + if (!This->txtSel) { + *selection = NULL; + return E_OUTOFMEMORY; + } + } + + *selection = &This->txtSel->ITextSelection_iface; + ITextSelection_AddRef(*selection); return S_OK; } @@ -2981,10 +4298,10 @@ static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end, I return E_OUTOFMEMORY; txtRge->ITextRange_iface.lpVtbl = &trvt; txtRge->ref = 1; - txtRge->reOle = reOle; + txtRge->child.reole = reOle; txtRge->start = start; txtRge->end = end; - list_add_head(&reOle->rangelist, &txtRge->entry); + list_add_head(&reOle->rangelist, &txtRge->child.entry); *ppRange = &txtRge->ITextRange_iface; return S_OK; } @@ -3041,16 +4358,14 @@ static const ITextDocumentVtbl tdvt = { ITextDocument_fnRangeFromPoint }; -static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface) -{ - return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface); -} - +/* ITextSelection */ static HRESULT WINAPI ITextSelection_fnQueryInterface( ITextSelection *me, REFIID riid, void **ppvObj) { + ITextSelectionImpl *This = impl_from_ITextSelection(me); + *ppvObj = NULL; if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDispatch) @@ -3061,6 +4376,11 @@ static HRESULT WINAPI ITextSelection_fnQueryInterface( ITextSelection_AddRef(me); return S_OK; } + else if (IsEqualGUID(riid, &IID_Igetrichole)) + { + *ppvObj = This->reOle; + return S_OK; + } return E_NOINTERFACE; } @@ -3083,33 +4403,39 @@ static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me) static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", This, pctinfo); + *pctinfo = 1; + return S_OK; } static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; + HRESULT hr; - FIXME("not implemented\n"); - return E_NOTIMPL; + TRACE("(%p)->(%u,%d,%p)\n", This, iTInfo, lcid, ppTInfo); + + hr = get_typeinfo(ITextSelection_tid, ppTInfo); + if (SUCCEEDED(hr)) + ITypeInfo_AddRef(*ppTInfo); + return hr; } static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; + ITypeInfo *ti; + HRESULT hr; - FIXME("not implemented\n"); - return E_NOTIMPL; + TRACE("(%p)->(%p,%p,%u,%d,%p)\n", This, riid, rgszNames, cNames, lcid, + rgDispId); + + hr = get_typeinfo(ITextSelection_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId); + return hr; } static HRESULT WINAPI ITextSelection_fnInvoke( @@ -3123,8 +4449,17 @@ static HRESULT WINAPI ITextSelection_fnInvoke( EXCEPINFO *pExcepInfo, UINT *puArgErr) { - FIXME("not implemented\n"); - return E_NOTIMPL; + ITextSelectionImpl *This = impl_from_ITextSelection(me); + ITypeInfo *ti; + HRESULT hr; + + TRACE("(%p)->(%d,%p,%d,%u,%p,%p,%p,%p)\n", This, dispIdMember, riid, lcid, + wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + + hr = get_typeinfo(ITextSelection_tid, &ti); + if (SUCCEEDED(hr)) + hr = ITypeInfo_Invoke(ti, me, dispIdMember, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return hr; } /*** ITextRange methods ***/ @@ -3132,25 +4467,57 @@ static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr) { ITextSelectionImpl *This = impl_from_ITextSelection(me); ME_Cursor *start = NULL, *end = NULL; + int nChars, endOfs; + BOOL bEOP; + + TRACE("(%p)->(%p)\n", This, pbstr); if (!This->reOle) return CO_E_RELEASED; - TRACE("%p\n", pbstr); + if (!pbstr) return E_INVALIDARG; ME_GetSelection(This->reOle->editor, &start, &end); - return range_GetText(This->reOle->editor, start, end, pbstr); + endOfs = ME_GetCursorOfs(end); + nChars = endOfs - ME_GetCursorOfs(start); + if (!nChars) + { + *pbstr = NULL; + return S_OK; + } + + *pbstr = SysAllocStringLen(NULL, nChars); + if (!*pbstr) + return E_OUTOFMEMORY; + + bEOP = (end->pRun->next->type == diTextEnd && endOfs > ME_GetTextLength(This->reOle->editor)); + ME_GetTextW(This->reOle->editor, *pbstr, nChars, start, nChars, FALSE, bEOP); + TRACE("%s\n", wine_dbgstr_w(*pbstr)); + + return S_OK; } -static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr) +static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR str) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + ME_TextEditor *editor; + int len, to, from; + + TRACE("(%p)->(%s)\n", This, debugstr_w(str)); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); - return E_NOTIMPL; + editor = This->reOle->editor; + len = strlenW(str); + ME_GetSelectionOfs(editor, &from, &to); + ME_ReplaceSel(editor, FALSE, str, len); + + if (len < to - from) + textranges_update_ranges(This->reOle, from, len, RANGE_UPDATE_DELETE); + + return S_OK; } static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch) @@ -3158,9 +4525,11 @@ static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch) ITextSelectionImpl *This = impl_from_ITextSelection(me); ME_Cursor *start = NULL, *end = NULL; + TRACE("(%p)->(%p)\n", This, pch); + if (!This->reOle) return CO_E_RELEASED; - TRACE("%p\n", pch); + if (!pch) return E_INVALIDARG; @@ -3171,42 +4540,51 @@ static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch) static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%x): stub\n", This, ch); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange) +static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **range) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - int start, end; + LONG start, end; + + TRACE("(%p)->(%p)\n", This, range); if (!This->reOle) return CO_E_RELEASED; - TRACE("%p %p\n", This, ppRange); - if (!ppRange) + if (!range) return E_INVALIDARG; - ME_GetSelectionOfs(This->reOle->editor, &start, &end); - return CreateITextRange(This->reOle, start, end, ppRange); + ITextSelection_GetStart(me, &start); + ITextSelection_GetEnd(me, &end); + return CreateITextRange(This->reOle, start, end, range); } -static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange) +static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **range) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, range); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange) +static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *range) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, range); + if (!This->reOle) return CO_E_RELEASED; @@ -3218,128 +4596,124 @@ static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFir { ITextSelectionImpl *This = impl_from_ITextSelection(me); LONG lim; + + TRACE("(%p)->(%p)\n", This, pcpFirst); + if (!This->reOle) return CO_E_RELEASED; if (!pcpFirst) return E_INVALIDARG; ME_GetSelectionOfs(This->reOle->editor, pcpFirst, &lim); - TRACE("%d\n", *pcpFirst); return S_OK; } -static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst) +static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG value) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - int start, end; - HRESULT hres; + LONG start, end; + HRESULT hr; + + TRACE("(%p)->(%d)\n", This, value); + if (!This->reOle) return CO_E_RELEASED; ME_GetSelectionOfs(This->reOle->editor, &start, &end); - hres = range_SetStart(This->reOle->editor, cpFirst, &start, &end); - if (!hres) + hr = textrange_setstart(This->reOle, value, &start, &end); + if (hr == S_OK) ME_SetSelection(This->reOle->editor, start, end); - return hres; + + return hr; } static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim) { ITextSelectionImpl *This = impl_from_ITextSelection(me); LONG first; + + TRACE("(%p)->(%p)\n", This, pcpLim); + if (!This->reOle) return CO_E_RELEASED; if (!pcpLim) return E_INVALIDARG; ME_GetSelectionOfs(This->reOle->editor, &first, pcpLim); - TRACE("%d\n", *pcpLim); return S_OK; } -static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim) +static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG value) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - int start, end; - HRESULT hres; + LONG start, end; + HRESULT hr; + + TRACE("(%p)->(%d)\n", This, value); + if (!This->reOle) return CO_E_RELEASED; ME_GetSelectionOfs(This->reOle->editor, &start, &end); - hres = range_SetEnd(This->reOle->editor, cpLim, &start, &end); - if (!hres) + hr = textrange_setend(This->reOle, value, &start, &end); + if (hr == S_OK) ME_SetSelection(This->reOle->editor, start, end); - return hres; + + return hr; } -static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont) +static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **font) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - ITextFontImpl *txtFont = NULL; - HRESULT hres; + + TRACE("(%p)->(%p)\n", This, font); if (!This->reOle) return CO_E_RELEASED; - TRACE("%p\n", This); - if (!pFont) + if (!font) return E_INVALIDARG; - hres = CreateITextFont(This->reOle, &txtFont); - if (!hres) - { - txtFont->txtSel = This; - txtFont->txtRge = NULL; - ITextSelection_AddRef(me); - *pFont = &txtFont->ITextFont_iface; - } - return hres; + + return create_textfont((ITextRange*)me, NULL, font); } -static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont) +static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *font) { ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - FIXME("not implemented\n"); - return E_NOTIMPL; -} + TRACE("(%p)->(%p)\n", This, font); -static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - if (!pcch) + if (!font) return E_INVALIDARG; - *pcch = ME_GetTextLength(This->reOle->editor) + 1; + + if (!This->reOle) + return CO_E_RELEASED; + + textrange_set_font((ITextRange*)me, font); return S_OK; } -static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue) +static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **para) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + TRACE("(%p)->(%p)\n", This, para); + + if (!This->reOle) + return CO_E_RELEASED; + + if (!para) + return E_INVALIDARG; + + return create_textpara((ITextRange*)me, para); +} + +static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *para) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, para); + if (!This->reOle) return CO_E_RELEASED; @@ -3347,11 +4721,42 @@ static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pV return E_NOTIMPL; } +static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *length) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + TRACE("(%p)->(%p)\n", This, length); + + if (!This->reOle) + return CO_E_RELEASED; + + return textrange_get_storylength(This->reOle->editor, length); +} + +static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *value) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + TRACE("(%p)->(%p)\n", This, value); + + if (!This->reOle) + return CO_E_RELEASED; + + if (!value) + return E_INVALIDARG; + + *value = tomUnknownStory; + return S_OK; +} + static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart) { ITextSelectionImpl *This = impl_from_ITextSelection(me); LONG start, end; HRESULT hres; + + TRACE("(%p)->(%d)\n", This, bStart); + if (!This->reOle) return CO_E_RELEASED; @@ -3362,80 +4767,283 @@ static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart) return hres; } -static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG unit, LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + TRACE("(%p)->(%d %p)\n", This, unit, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return textrange_expand((ITextRange*)me, unit, delta); +} + +static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG unit, LONG *index) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %p): stub\n", This, unit, index); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex) +static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG unit, LONG index, + LONG extend) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %d): stub\n", This, unit, index, extend); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index, - LONG Extend) +static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG anchor, LONG active) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d): stub\n", This, anchor, active); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther) +static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *range, LONG *ret) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + ITextSelection *selection = NULL; + LONG start, end; + + TRACE("(%p)->(%p %p)\n", This, range, ret); + + if (ret) + *ret = tomFalse; + + if (!This->reOle) + return CO_E_RELEASED; + + if (!range) + return S_FALSE; + + ITextRange_QueryInterface(range, &IID_ITextSelection, (void**)&selection); + if (!selection) + return S_FALSE; + ITextSelection_Release(selection); + + ITextSelection_GetStart(me, &start); + ITextSelection_GetEnd(me, &end); + return textrange_inrange(start, end, range, ret); +} + +static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *range, LONG *ret) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p %p): stub\n", This, range, ret); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb) +static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *range, LONG *ret) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + ITextSelection *selection = NULL; + LONG start, end; + + TRACE("(%p)->(%p %p)\n", This, range, ret); + + if (ret) + *ret = tomFalse; + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); - return E_NOTIMPL; -} + if (!range) + return S_FALSE; -static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; + ITextRange_QueryInterface(range, &IID_ITextSelection, (void**)&selection); + if (!selection) + return S_FALSE; + ITextSelection_Release(selection); - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; + ITextSelection_GetStart(me, &start); + ITextSelection_GetEnd(me, &end); + return textrange_isequal(start, end, range, ret); } static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + TRACE("(%p)\n", This); + + if (!This->reOle) + return CO_E_RELEASED; + + /* nothing to do */ + return S_OK; +} + +static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG unit, LONG extend, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG unit, LONG extend, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG unit, LONG count, LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG unit, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG unit, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *charset, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *charset, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *charset, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *charset, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *charset, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *charset, LONG count, + LONG *delta) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %p): stub\n", This, debugstr_variant(charset), count, delta); + + if (!This->reOle) + return CO_E_RELEASED; + + return E_NOTIMPL; +} + +static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR text, LONG count, LONG flags, + LONG *length) +{ + ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + if (!This->reOle) return CO_E_RELEASED; @@ -3443,376 +5051,291 @@ static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me) return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR text, LONG count, + LONG flags, LONG *length) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR text, LONG count, + LONG flags, LONG *length) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %d %x %p): stub\n", This, debugstr_w(text), count, flags, length); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG unit, LONG count, + LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, count, delta); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *v) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, v); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *v) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, v); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *v, LONG format) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %x): stub\n", This, debugstr_variant(v), format); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *v, LONG format, + LONG *ret) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s %x %p): stub\n", This, debugstr_variant(v), format, ret); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *ret) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, ret); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG type) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d): stub\n", This, type); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG type, LONG *cx, LONG *cy) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %p %p): stub\n", This, type, cx, cy); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG type, + LONG extend) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %d %d): stub\n", This, x, y, type, extend); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags, - LONG *pLength) +static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG value) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d): stub\n", This, value); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch, - LONG Flags, LONG *pLength) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch, - LONG Flags, LONG *pLength) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count, - LONG *pDelta) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format, - LONG *pb) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type, - LONG Extend) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); - return E_NOTIMPL; -} - -static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value) -{ - ITextSelectionImpl *This = impl_from_ITextSelection(me); - if (!This->reOle) - return CO_E_RELEASED; - - FIXME("not implemented\n"); return E_NOTIMPL; } static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, ppv); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } /*** ITextSelection methods ***/ -static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags) +static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *flags) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, flags); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags) +static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG flags) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%x): stub\n", This, flags); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType) +static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *type) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%p): stub\n", This, type); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count, - LONG Extend, LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG unit, LONG count, + LONG extend, LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count, - LONG Extend, LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG unit, LONG count, + LONG extend, LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count, - LONG Extend, LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG unit, LONG count, + LONG extend, LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count, - LONG Extend, LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG unit, LONG count, + LONG extend, LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %d %p): stub\n", This, unit, count, extend, delta); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG unit, LONG extend, + LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend, - LONG *pDelta) +static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG unit, LONG extend, + LONG *delta) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%d %d %p): stub\n", This, unit, extend, delta); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } -static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr) +static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR text) { ITextSelectionImpl *This = impl_from_ITextSelection(me); + + FIXME("(%p)->(%s): stub\n", This, debugstr_w(text)); + if (!This->reOle) return CO_E_RELEASED; - FIXME("not implemented\n"); return E_NOTIMPL; } @@ -3913,23 +5436,11 @@ LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *p reo->ITextDocument_iface.lpVtbl = &tdvt; reo->ref = 1; reo->editor = editor; - reo->txtSel = CreateTextSelection(reo); - if (!reo->txtSel) - { - heap_free(reo); - return 0; - } - reo->clientSite = CreateOleClientSite(reo); - if (!reo->clientSite) - { - ITextSelection_Release(&reo->txtSel->ITextSelection_iface); - heap_free(reo); - return 0; - } + reo->txtSel = NULL; + TRACE("Created %p\n",reo); list_init(&reo->rangelist); - list_init(&reo->fontlist); - list_init(&reo->paralist); + list_init(&reo->clientsites); if (outer_unk) reo->outer_unk = outer_unk; else @@ -3973,6 +5484,12 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) return; } + if (!run->ole_obj->poleobj) + { + pSize->cx = pSize->cy = 0; + return; + } + if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK) { FIXME("Query Interface IID_IDataObject failed!\n"); diff --git a/reactos/dll/win32/riched20/run.c b/reactos/dll/win32/riched20/run.c index ad08b82a28b..4a93bbc9fc0 100644 --- a/reactos/dll/win32/riched20/run.c +++ b/reactos/dll/win32/riched20/run.c @@ -781,6 +781,7 @@ void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod) style = ME_ApplyStyle(editor->pBuffer->pDefaultStyle, mod); editor->pBuffer->pDefaultStyle->fmt = style->fmt; editor->pBuffer->pDefaultStyle->tm = style->tm; + ScriptFreeCache( &editor->pBuffer->pDefaultStyle->script_cache ); ME_ReleaseStyle(style); ME_MarkAllForWrapping(editor); /* pcf = editor->pBuffer->pDefaultStyle->fmt; */ diff --git a/reactos/dll/win32/riched20/txtsrv.c b/reactos/dll/win32/riched20/txtsrv.c index 26e5ec7eb6c..4aacffae554 100644 --- a/reactos/dll/win32/riched20/txtsrv.c +++ b/reactos/dll/win32/riched20/txtsrv.c @@ -387,7 +387,7 @@ static const ITextServicesVtbl textservices_vtbl = HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, IUnknown **ppUnk) { ITextServicesImpl *ITextImpl; - HRESULT hres; + TRACE("%p %p --> %p\n", pUnkOuter, pITextHost, ppUnk); if (pITextHost == NULL) return E_POINTER; @@ -409,8 +409,6 @@ HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, I ITextImpl->editor->rcFormat.right = 0; ITextImpl->editor->rcFormat.bottom = 0; - ME_HandleMessage(ITextImpl->editor, WM_CREATE, 0, 0, TRUE, &hres); - if (pUnkOuter) ITextImpl->outer_unk = pUnkOuter; else diff --git a/reactos/dll/win32/riched20/version.rc b/reactos/dll/win32/riched20/version.rc index ff2a2baa0dd..22b5a701c68 100644 --- a/reactos/dll/win32/riched20/version.rc +++ b/reactos/dll/win32/riched20/version.rc @@ -28,3 +28,6 @@ #include "res.h" OCR_REVERSE CURSOR ocr_reverse.cur + +1 TYPELIB riched_tom.tlb +1 WINE_REGISTRY riched_tom.rgs diff --git a/reactos/dll/win32/riched20/writer.c b/reactos/dll/win32/riched20/writer.c index 9a2c3c7f87a..bedfd3fcb64 100644 --- a/reactos/dll/win32/riched20/writer.c +++ b/reactos/dll/win32/riched20/writer.c @@ -46,29 +46,18 @@ ME_StreamOutInit(ME_TextEditor *editor, EDITSTREAM *stream) static BOOL ME_StreamOutFlush(ME_OutStream *pStream) { - LONG nStart = 0; LONG nWritten = 0; - LONG nRemaining = 0; EDITSTREAM *stream = pStream->stream; - while (nStart < pStream->pos) { - TRACE("sending %u bytes\n", pStream->pos - nStart); - /* Some apps seem not to set *pcb unless a problem arises, relying - on initial random nWritten value, which is usually >STREAMOUT_BUFFER_SIZE */ - nRemaining = pStream->pos - nStart; - nWritten = 0xDEADBEEF; - stream->dwError = stream->pfnCallback(stream->dwCookie, (LPBYTE)pStream->buffer + nStart, - pStream->pos - nStart, &nWritten); + if (pStream->pos) { + TRACE("sending %u bytes\n", pStream->pos); + nWritten = pStream->pos; + stream->dwError = stream->pfnCallback(stream->dwCookie, (LPBYTE)pStream->buffer, + pStream->pos, &nWritten); TRACE("error=%u written=%u\n", stream->dwError, nWritten); - if (nWritten > (pStream->pos - nStart) || nWritten<0) { - FIXME("Invalid returned written size *pcb: 0x%x (%d) instead of %d\n", - (unsigned)nWritten, nWritten, nRemaining); - nWritten = nRemaining; - } if (nWritten == 0 || stream->dwError) return FALSE; - pStream->written += nWritten; - nStart += nWritten; + /* Don't resend partial chunks if nWritten < pStream->pos */ } pStream->pos = 0; return TRUE; @@ -796,8 +785,11 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream, ME_Cursor cursor = *start; ME_DisplayItem *prev_para = cursor.pPara; ME_Cursor endCur = cursor; + int actual_chars; - ME_MoveCursorChars(editor, &endCur, nChars); + actual_chars = ME_MoveCursorChars(editor, &endCur, nChars); + /* Include the final \r which MoveCursorChars will ignore. */ + if (actual_chars != nChars) endCur.nOffset++; if (!ME_StreamOutRTFHeader(pStream, dwFormat)) return FALSE; diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index d40c52850c3..607cef0414a 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -164,7 +164,7 @@ reactos/dll/win32/qmgrprxy # Synced to WineStaging-1.7.47 reactos/dll/win32/query # Synced to WineStaging-1.7.37 reactos/dll/win32/rasapi32 # Synced to WineStaging-1.7.47 reactos/dll/win32/resutils # Synced to WineStaging-1.7.37 -reactos/dll/win32/riched20 # Synced to WineStaging-1.7.37 +reactos/dll/win32/riched20 # Synced to WineStaging-1.7.47 reactos/dll/win32/riched32 # Synced to WineStaging-1.7.37 reactos/dll/win32/rpcrt4 # Synced to Wine-1.7.17 reactos/dll/win32/rsabase # Synced to WineStaging-1.7.37