diff options
author | George Hazan <ghazan@miranda.im> | 2020-07-07 14:33:45 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-07-07 14:33:45 +0300 |
commit | cca308b6079ee778c564c0197756595faf63ec88 (patch) | |
tree | f0e4e92ca2f80cc288a82489fb47a0f754495915 /plugins/IEView | |
parent | 81a813415b1921236ec456dd0cf74839191d2363 (diff) |
IEView:
- text in groupchats isn't scrolled down;
- unused flag removed from IEE_GET_SELECTION processing;
- minor code optimization
Diffstat (limited to 'plugins/IEView')
-rw-r--r-- | plugins/IEView/src/IEView.cpp | 21 | ||||
-rw-r--r-- | plugins/IEView/src/IEView.h | 88 | ||||
-rw-r--r-- | plugins/IEView/src/ieview_logger.cpp | 21 | ||||
-rw-r--r-- | plugins/IEView/src/ieview_services.cpp | 2 |
4 files changed, 60 insertions, 72 deletions
diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp index 74ca50d60d..1163503dca 100644 --- a/plugins/IEView/src/IEView.cpp +++ b/plugins/IEView/src/IEView.cpp @@ -293,8 +293,6 @@ IEView::~IEView() if (m_pConnectionPoint != nullptr)
m_pConnectionPoint->Unadvise(m_dwCookie);
- mir_free(selectedText);
-
if (sink != nullptr)
delete sink;
DestroyWindow(hwnd);
@@ -913,19 +911,10 @@ void IEView::clear(IEVIEWEVENT *event) setBorder();
}
-void* IEView::getSelection(IEVIEWEVENT *event)
+wchar_t* IEView::selection()
{
- mir_free(selectedText);
- selectedText = getSelection();
- if (mir_wstrlen(selectedText) == 0)
- return nullptr;
-
- if (event->dwFlags & IEEF_NO_UNICODE) {
- char *str = mir_u2a_cp(selectedText, event->codepage);
- mir_free(selectedText);
- selectedText = (BSTR)str;
- }
- return (void*)selectedText;
+ wszSelectedText = getSelection();
+ return (mir_wstrlen(wszSelectedText) == 0) ? nullptr : wszSelectedText.get();
}
HWND IEView::getHWND()
@@ -954,7 +943,7 @@ void IEView::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam) /**
* Returns the selected text within the active document
**/
-WCHAR* IEView::getSelection()
+wchar_t* IEView::getSelection()
{
CComPtr<IHTMLDocument2> document = getDocument();
if (document == nullptr)
@@ -976,7 +965,7 @@ WCHAR* IEView::getSelection() if (FAILED(pRange->get_text(&text)))
return nullptr;
- WCHAR *res = mir_wstrdup(text);
+ wchar_t *res = mir_wstrdup(text);
::SysFreeString(text);
return res;
}
diff --git a/plugins/IEView/src/IEView.h b/plugins/IEView/src/IEView.h index 12707efa0f..57141f0b3e 100644 --- a/plugins/IEView/src/IEView.h +++ b/plugins/IEView/src/IEView.h @@ -422,9 +422,9 @@ public: class IEView :public IDispatch, public IOleClientSite, public IOleInPlaceSite, public IDocHostUIHandler, public IInternetSecurityManager, public IServiceProvider, public MZeroedObject
{
-private:
static IEView *list;
static mir_cs mutex;
+
HWND parent;
HWND hwnd;
IEView *prev, *next;
@@ -440,7 +440,7 @@ private: WNDPROC mainWndProc, docWndProc, serverWndProc;
bool getFocus;
bool clearRequired;
- WCHAR* selectedText;
+ ptrW wszSelectedText;
bool isContactSet;
MCONTACT hContact;
@@ -509,52 +509,52 @@ private: STDMETHOD(GetZoneMappings)(DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags);
IHTMLDocument2 *getDocument();
- WCHAR* getHrefFromAnchor(CComPtr<IHTMLElement> element);
WCHAR* getSelection();
- void setBorder();
+ wchar_t* getHrefFromAnchor(CComPtr<IHTMLElement> element);
+ void setBorder();
protected:
- void navigate(const char *);
- void navigate(const wchar_t *);
+ void navigate(const char *);
+ void navigate(const wchar_t *);
public:
IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy);
- virtual ~IEView();
-
- void waitWhileBusy();
- HWND getHWND();
- void translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam);
- bool mouseClick(POINT pt);
- bool mouseActivate();
- bool setFocus(HWND prevFocus);
- void setWindowPos(int x, int y, int cx, int cy);
-
- void write(const wchar_t *text);
- void write(const char *text);
- void writef(const char *fmt, ...);
- void documentClose();
- void scrollToBottom();
- void scrollToBottomSoft();
- void scrollToTop();
-
- void setMainWndProc(WNDPROC);
- WNDPROC getMainWndProc();
- void setDocWndProc(WNDPROC);
- WNDPROC getDocWndProc();
- void setServerWndProc(WNDPROC);
- WNDPROC getServerWndProc();
-
- void appendEventOld(IEVIEWEVENT * event);
- void appendEvent(IEVIEWEVENT * event);
- void clear(IEVIEWEVENT * event);
- void* getSelection(IEVIEWEVENT * event);
- void navigate(IEVIEWNAVIGATE * nav);
- void saveDocument();
-
- void setContact(MCONTACT hContact);
-
- static IEView* get(HWND);
- static void release();
-
- inline MCONTACT Get_CurrentContact()
+ virtual ~IEView();
+
+ void waitWhileBusy();
+ HWND getHWND();
+ void translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam);
+ bool mouseClick(POINT pt);
+ bool mouseActivate();
+ bool setFocus(HWND prevFocus);
+ void setWindowPos(int x, int y, int cx, int cy);
+
+ void write(const wchar_t *text);
+ void write(const char *text);
+ void writef(const char *fmt, ...);
+ void documentClose();
+ void scrollToBottom();
+ void scrollToBottomSoft();
+ void scrollToTop();
+
+ void setMainWndProc(WNDPROC);
+ WNDPROC getMainWndProc();
+ void setDocWndProc(WNDPROC);
+ WNDPROC getDocWndProc();
+ void setServerWndProc(WNDPROC);
+ WNDPROC getServerWndProc();
+
+ void appendEventOld(IEVIEWEVENT * event);
+ void appendEvent(IEVIEWEVENT * event);
+ void clear(IEVIEWEVENT * event);
+ wchar_t* selection();
+ void navigate(IEVIEWNAVIGATE * nav);
+ void saveDocument();
+
+ void setContact(MCONTACT hContact);
+
+ static IEView* get(HWND);
+ static void release();
+
+ inline MCONTACT Get_CurrentContact()
{
return hContact;
}
diff --git a/plugins/IEView/src/ieview_logger.cpp b/plugins/IEView/src/ieview_logger.cpp index 05dc9064f6..baecdf63b7 100644 --- a/plugins/IEView/src/ieview_logger.cpp +++ b/plugins/IEView/src/ieview_logger.cpp @@ -77,13 +77,10 @@ public: return m_hwnd; } - wchar_t *GetSelection() override + wchar_t* GetSelection() override { - IEVIEWEVENT event = {}; - event.hwnd = m_hwnd; - event.iType = IEE_GET_SELECTION; - event.hContact = m_pDlg.m_hContact; - return (wchar_t *)HandleIEEvent(0, LPARAM(&event)); + auto *view = IEView::get(m_hwnd); + return (view != nullptr) ? view->selection() : nullptr; } int GetType() override @@ -105,7 +102,7 @@ public: HandleIEEvent(0, LPARAM(&event)); } - void LogEvents(LOGINFO *pLog, bool) override + void LogEvents(LOGINFO *pLog, bool bRedraw) override { IEVIEWEVENTDATA ied = {}; ied.dwFlags = IEEDF_UNICODE_NICK; @@ -170,6 +167,9 @@ public: pLog = pLog->prev; } + + if (bRedraw) + ScrollToBottom(); } void Resize() override @@ -194,10 +194,9 @@ public: void ScrollToBottom() override { - IEVIEWWINDOW ieWindow = { sizeof(ieWindow) }; - ieWindow.iType = IEW_SCROLLBOTTOM; - ieWindow.hwnd = m_hwnd; - HandleIEWindow(0, LPARAM(&ieWindow)); + auto *view = IEView::get(m_hwnd); + if (view != nullptr) + view->scrollToBottom(); } }; diff --git a/plugins/IEView/src/ieview_services.cpp b/plugins/IEView/src/ieview_services.cpp index 2db0aa73de..e53eda024d 100644 --- a/plugins/IEView/src/ieview_services.cpp +++ b/plugins/IEView/src/ieview_services.cpp @@ -76,7 +76,7 @@ INT_PTR HandleIEEvent(WPARAM, LPARAM lParam) else if (event->iType == IEE_CLEAR_LOG)
view->clear(event);
else if (event->iType == IEE_GET_SELECTION)
- return (INT_PTR)view->getSelection(event);
+ return (INT_PTR)view->selection();
else if (event->iType == IEE_SAVE_DOCUMENT)
view->saveDocument();
else if (event->iType == IEE_LOG_MEM_EVENTS)
|