diff options
author | George Hazan <george.hazan@gmail.com> | 2016-03-02 11:06:38 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-03-02 11:06:38 +0000 |
commit | 14bdc60ec9715ed7a0e74ade4072cf86f3fefb4a (patch) | |
tree | 7c8c30ba5af1343682c972527caf6d0c22f3c75c /plugins/SmileyAdd/src/SmileyBase.cpp | |
parent | cbb56a2046b7894f4bb09e98dfb8b56febf1cb0f (diff) |
- crash fix on smiley pack change;
- massive code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@16389 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SmileyAdd/src/SmileyBase.cpp')
-rw-r--r-- | plugins/SmileyAdd/src/SmileyBase.cpp | 125 |
1 files changed, 64 insertions, 61 deletions
diff --git a/plugins/SmileyAdd/src/SmileyBase.cpp b/plugins/SmileyAdd/src/SmileyBase.cpp index 69af533942..f5d545bfb6 100644 --- a/plugins/SmileyAdd/src/SmileyBase.cpp +++ b/plugins/SmileyAdd/src/SmileyBase.cpp @@ -25,23 +25,18 @@ static void HiMetricToPixel(const SIZEL * lpSizeInHiMetric, LPSIZEL lpSizeInPix) const int nPixelsPerInchY = GetDeviceCaps(hDCScreen, LOGPIXELSY);
ReleaseDC(NULL, hDCScreen);
- lpSizeInPix->cx = (lpSizeInHiMetric->cx * nPixelsPerInchX + (2540/2)) / 2540;
- lpSizeInPix->cy = (lpSizeInHiMetric->cy * nPixelsPerInchY + (2540/2)) / 2540;
+ lpSizeInPix->cx = (lpSizeInHiMetric->cx * nPixelsPerInchX + (2540 / 2)) / 2540;
+ lpSizeInPix->cy = (lpSizeInHiMetric->cy * nPixelsPerInchY + (2540 / 2)) / 2540;
}
-static int CompareISmileyBase(const ISmileyBase* p1, const ISmileyBase* p2)
-{
- return (int)((char*)p2 - (char*)p1);
-}
-
-static LIST<ISmileyBase> regSmileys(10, CompareISmileyBase);
+static LIST<ISmileyBase> regSmileys(10, PtrKeySortT);
// {105C56DF-6455-4705-A501-51F1CCFCF688}
-const GUID IID_ISmileyAddSmiley =
+const GUID IID_ISmileyAddSmiley =
{ 0x105c56df, 0x6455, 0x4705, { 0xa5, 0x1, 0x51, 0xf1, 0xcc, 0xfc, 0xf6, 0x88 } };
// {58B32D03-1BD2-4840-992E-9AE799FD4ADE}
-const GUID IID_ITooltipData =
+const GUID IID_ITooltipData =
{ 0x58b32d03, 0x1bd2, 0x4840, { 0x99, 0x2e, 0x9a, 0xe7, 0x99, 0xfd, 0x4a, 0xde } };
ISmileyBase::ISmileyBase(void)
@@ -69,13 +64,12 @@ ISmileyBase::~ISmileyBase(void) Close(OLECLOSE_NOSAVE);
- if (m_spClientSite)
- {
+ if (m_spClientSite) {
m_spClientSite->Release();
m_spClientSite = NULL;
}
- if (m_spAdviseHolder)
- {
+
+ if (m_spAdviseHolder) {
m_spAdviseHolder->Release();
m_spAdviseHolder = NULL;
}
@@ -83,14 +77,14 @@ ISmileyBase::~ISmileyBase(void) void ISmileyBase::OnClose(void)
{
- if (m_spAdviseHolder) m_spAdviseHolder->SendOnClose();
+ if (m_spAdviseHolder)
+ m_spAdviseHolder->SendOnClose();
}
-void ISmileyBase::SendOnViewChange(void)
+void ISmileyBase::SendOnViewChange(void)
{
if (m_spAdviseSink) m_spAdviseSink->OnViewChange(DVASPECT_CONTENT, -1);
- if (m_advf & ADVF_ONLYONCE)
- {
+ if (m_advf & ADVF_ONLYONCE) {
m_spAdviseSink->Release();
m_spAdviseSink = NULL;
m_advf = 0;
@@ -100,8 +94,7 @@ void ISmileyBase::SendOnViewChange(void) bool ISmileyBase::QueryHitPointSpecial(int x, int y, HWND hwnd, TCHAR** smltxt)
{
bool result = m_visible && m_hwnd == hwnd;
- if (result)
- {
+ if (result) {
result = x >= m_orect.left && x <= m_orect.right &&
y >= m_orect.top && y <= m_orect.bottom;
}
@@ -118,28 +111,23 @@ void ISmileyBase::SetHint(TCHAR* smltxt) void ISmileyBase::SetPosition(HWND hwnd, LPCRECT lpRect)
{
m_hwnd = hwnd;
- if (lpRect == NULL || (lpRect->top == -1 && lpRect->bottom == -1))
- {
+ if (lpRect == NULL || (lpRect->top == -1 && lpRect->bottom == -1)) {
m_visible = false;
- }
- else
- {
+ }
+ else {
m_visible = true;
m_dirAniAllow = true;
m_orect.left = lpRect->left;
m_orect.right = lpRect->left + m_sizeExtent.cx;
- if (lpRect->top == -1)
- {
+ if (lpRect->top == -1) {
m_orect.top = lpRect->bottom - m_sizeExtent.cy;
m_orect.bottom = lpRect->bottom;
}
- else if (lpRect->bottom == -1)
- {
+ else if (lpRect->bottom == -1) {
m_orect.top = lpRect->top;
m_orect.bottom = lpRect->top + m_sizeExtent.cy;
}
- else
- {
+ else {
m_orect.top = lpRect->bottom - m_sizeExtent.cy;
m_orect.bottom = lpRect->bottom;
}
@@ -150,13 +138,15 @@ void ISmileyBase::SetPosition(HWND hwnd, LPCRECT lpRect) //
// IUnknown members
//
-ULONG ISmileyBase::AddRef(void)
-{ return InterlockedIncrement(&m_lRefCount); }
+ULONG ISmileyBase::AddRef(void)
+{
+ return InterlockedIncrement(&m_lRefCount);
+}
ULONG ISmileyBase::Release(void)
{
LONG count = InterlockedDecrement(&m_lRefCount);
- if (count == 0)
+ if (count == 0)
delete this;
return count;
}
@@ -174,12 +164,11 @@ HRESULT ISmileyBase::QueryInterface(REFIID iid, void ** ppvObject) *ppvObject = static_cast<IViewObject2*>(this);
else if (iid == IID_IOleObject)
*ppvObject = static_cast<IOleObject*>(this);
- else if (iid == IID_IUnknown)
+ else if (iid == IID_IUnknown)
*ppvObject = this;
else if (iid == IID_IViewObject2)
*ppvObject = static_cast<IViewObject2*>(this);
- else
- {
+ else {
*ppvObject = NULL;
return E_NOINTERFACE;
}
@@ -207,29 +196,41 @@ HRESULT ISmileyBase::GetClientSite(IOleClientSite **ppClientSite) }
HRESULT ISmileyBase::SetHostNames(LPCOLESTR /* szContainerApp */, LPCOLESTR /* szContainerObj */)
-{ return S_OK; }
+{
+ return S_OK;
+}
HRESULT ISmileyBase::Close(DWORD /* dwSaveOption */)
{
regSmileys.remove(this);
- if (m_spAdviseSink) m_spAdviseSink->Release();
- m_spAdviseSink = NULL;
+ if (m_spAdviseSink) {
+ m_spAdviseSink->Release();
+ m_spAdviseSink = NULL;
+ }
return S_OK;
}
HRESULT ISmileyBase::SetMoniker(DWORD /* dwWhichMoniker */, IMoniker* /* pmk */)
-{ return E_NOTIMPL; }
+{
+ return E_NOTIMPL;
+}
HRESULT ISmileyBase::GetMoniker(DWORD /* dwAssign */, DWORD /* dwWhichMoniker */, IMoniker** /* ppmk */)
-{ return E_NOTIMPL; }
+{
+ return E_NOTIMPL;
+}
HRESULT ISmileyBase::InitFromData(IDataObject* /* pDataObject */, BOOL /* fCreation */, DWORD /* dwReserved */)
-{ return E_NOTIMPL; }
+{
+ return E_NOTIMPL;
+}
HRESULT ISmileyBase::GetClipboardData(DWORD /* dwReserved */, IDataObject** /* ppDataObject */)
-{ return E_NOTIMPL; }
+{
+ return E_NOTIMPL;
+}
HRESULT ISmileyBase::DoVerb(LONG /* iVerb */, LPMSG /* pMsg */, IOleClientSite* /* pActiveSite */, LONG /* lindex */,
HWND /* hwndParent */, LPCRECT /* lprcPosRect */)
@@ -249,10 +250,12 @@ HRESULT ISmileyBase::GetUserClassID(CLSID *pClsid) }
HRESULT ISmileyBase::GetUserType(DWORD /*dwFormOfType*/, LPOLESTR* /*pszUserType*/)
-{ return E_NOTIMPL; }
+{
+ return E_NOTIMPL;
+}
HRESULT ISmileyBase::SetExtent(DWORD dwDrawAspect, SIZEL* psizel)
-{
+{
if (dwDrawAspect != DVASPECT_CONTENT) return E_FAIL;
if (psizel == NULL) return E_POINTER;
@@ -296,26 +299,26 @@ HRESULT ISmileyBase::EnumAdvise(IEnumSTATDATA **ppEnumAdvise) HRESULT ISmileyBase::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus)
{
if (pdwStatus == NULL) return E_POINTER;
- if (dwAspect == DVASPECT_CONTENT)
- {
- *pdwStatus = OLEMISC_STATIC | OLEMISC_INVISIBLEATRUNTIME |
- OLEMISC_CANTLINKINSIDE | OLEMISC_NOUIACTIVATE;
+ if (dwAspect == DVASPECT_CONTENT) {
+ *pdwStatus = OLEMISC_STATIC | OLEMISC_INVISIBLEATRUNTIME |
+ OLEMISC_CANTLINKINSIDE | OLEMISC_NOUIACTIVATE;
return S_OK;
}
- else
- {
+ else {
*pdwStatus = 0;
return E_FAIL;
}
}
HRESULT ISmileyBase::SetColorScheme(LOGPALETTE* /* pLogpal */)
-{ return E_NOTIMPL; }
+{
+ return E_NOTIMPL;
+}
//
// IViewObject members
//
-HRESULT ISmileyBase::SetAdvise(DWORD aspect, DWORD advf, IAdviseSink* pAdvSink)
+HRESULT ISmileyBase::SetAdvise(DWORD aspect, DWORD advf, IAdviseSink* pAdvSink)
{
if (aspect != DVASPECT_CONTENT) return DV_E_DVASPECT;
m_advf = advf;
@@ -324,22 +327,22 @@ HRESULT ISmileyBase::SetAdvise(DWORD aspect, DWORD advf, IAdviseSink* pAdvSink) if (advf & ADVF_PRIMEFIRST) SendOnViewChange();
return S_OK;
}
-HRESULT ISmileyBase::GetAdvise(DWORD* /*pAspects*/, DWORD* /*pAdvf*/, IAdviseSink** ppAdvSink)
+HRESULT ISmileyBase::GetAdvise(DWORD* /*pAspects*/, DWORD* /*pAdvf*/, IAdviseSink** ppAdvSink)
{
if (!ppAdvSink) return E_POINTER;
*ppAdvSink = m_spAdviseSink;
if (m_spAdviseSink) m_spAdviseSink->AddRef();
return S_OK;
}
+
HRESULT ISmileyBase::Freeze(DWORD, long, void*, DWORD*) { return E_NOTIMPL; }
HRESULT ISmileyBase::Unfreeze(DWORD) { return E_NOTIMPL; }
-HRESULT ISmileyBase::GetColorSet(DWORD, long, void*, DVTARGETDEVICE*, HDC,
- LOGPALETTE**) { return E_NOTIMPL; }
+HRESULT ISmileyBase::GetColorSet(DWORD, long, void*, DVTARGETDEVICE*, HDC, LOGPALETTE**) { return E_NOTIMPL; }
//
// IViewObject2 members
//
-HRESULT ISmileyBase::GetExtent(DWORD aspect, long, DVTARGETDEVICE*, SIZEL* pSize)
+HRESULT ISmileyBase::GetExtent(DWORD aspect, long, DVTARGETDEVICE*, SIZEL* pSize)
{
if (pSize == NULL) return E_POINTER;
if (aspect != DVASPECT_CONTENT) return DV_E_DVASPECT;
@@ -359,14 +362,14 @@ HRESULT ISmileyBase::SetTooltip(BSTR /* bstrHint */) HRESULT ISmileyBase::GetTooltip(BSTR *bstrHint)
{
if (bstrHint == NULL) return E_POINTER;
- *bstrHint = SysAllocString(T2W_SM(m_smltxt));
+ *bstrHint = SysAllocString(m_smltxt);
return S_OK;
}
void CloseSmileys(void)
{
- for (int i=regSmileys.getCount()-1; i >= 0; i--) {
+ for (int i = regSmileys.getCount() - 1; i >= 0; i--) {
regSmileys[i]->OnClose();
regSmileys[i]->Close(OLECLOSE_NOSAVE);
}
@@ -374,7 +377,7 @@ void CloseSmileys(void) int CheckForTip(int x, int y, HWND hwnd, TCHAR** smltxt)
{
- for (int i=0; i < regSmileys.getCount(); i++)
+ for (int i = 0; i < regSmileys.getCount(); i++)
if (regSmileys[i]->QueryHitPointSpecial(x, y, hwnd, smltxt))
return i;
|