summaryrefslogtreecommitdiff
path: root/plugins/mTextControl
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mTextControl')
-rw-r--r--plugins/mTextControl/src/FormattedTextDraw.cpp204
-rw-r--r--plugins/mTextControl/src/FormattedTextDraw.h7
-rw-r--r--plugins/mTextControl/src/dataobject.cpp128
-rw-r--r--plugins/mTextControl/src/enumformat.cpp78
-rw-r--r--plugins/mTextControl/src/fancy_rtf.cpp132
-rw-r--r--plugins/mTextControl/src/richeditutils.cpp42
-rw-r--r--plugins/mTextControl/src/services.cpp143
-rw-r--r--plugins/mTextControl/src/textusers.cpp26
8 files changed, 351 insertions, 409 deletions
diff --git a/plugins/mTextControl/src/FormattedTextDraw.cpp b/plugins/mTextControl/src/FormattedTextDraw.cpp
index 6555e8d0a0..6a9e2d2cdc 100644
--- a/plugins/mTextControl/src/FormattedTextDraw.cpp
+++ b/plugins/mTextControl/src/FormattedTextDraw.cpp
@@ -30,25 +30,25 @@ static const IID IID_ITextDocument = {
/////////////////////////////////////////////////////////////////////////////
// CallBack functions
+
DWORD CALLBACK EditStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
- PCOOKIE pCookie = (PCOOKIE) dwCookie;
- if (pCookie->isUnicode)
- {
- if ((pCookie->dwSize - pCookie->dwCount)*sizeof(WCHAR) < (DWORD)cb)
- *pcb = (pCookie->dwSize - pCookie->dwCount)*sizeof(WCHAR);
+ COOKIE *pCookie = (COOKIE*)dwCookie;
+ if (pCookie->isUnicode) {
+ if ((pCookie->cbSize - pCookie->cbCount)*sizeof(WCHAR) < (size_t)cb)
+ *pcb = LONG(pCookie->cbSize - pCookie->cbCount)*sizeof(WCHAR);
else
- *pcb = cb&~1UL;
- CopyMemory(pbBuff, pCookie->unicode+pCookie->dwCount, *pcb);
- pCookie->dwCount += *pcb/sizeof(WCHAR);
- } else
- {
- if(pCookie->dwSize - pCookie->dwCount < (DWORD)cb)
- *pcb = pCookie->dwSize - pCookie->dwCount;
+ *pcb = cb & ~1UL;
+ CopyMemory(pbBuff, pCookie->unicode + pCookie->cbCount, *pcb);
+ pCookie->cbCount += *pcb / sizeof(WCHAR);
+ }
+ else {
+ if (pCookie->cbSize - pCookie->cbCount < (DWORD)cb)
+ *pcb = LONG(pCookie->cbSize - pCookie->cbCount);
else
*pcb = cb;
- CopyMemory(pbBuff, pCookie->ansi+pCookie->dwCount, *pcb);
- pCookie->dwCount += *pcb;
+ CopyMemory(pbBuff, pCookie->ansi + pCookie->cbCount, *pcb);
+ pCookie->cbCount += *pcb;
}
return 0; // callback succeeded - no errors
@@ -56,69 +56,69 @@ DWORD CALLBACK EditStreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb,
/////////////////////////////////////////////////////////////////////////////
// CFormattedTextDraw
+
HRESULT CFormattedTextDraw::putRTFTextA(char *newVal)
{
- HRESULT hr;
- LRESULT lResult = 0;
- EDITSTREAM editStream;
-
- if (!m_spTextServices)
+ if (!m_spTextServices)
return S_FALSE;
m_editCookie.isUnicode = false;
m_editCookie.ansi = newVal;
- m_editCookie.dwSize = mir_strlen(m_editCookie.ansi);
- m_editCookie.dwCount = 0;
- editStream.dwCookie = (DWORD_PTR) &m_editCookie;
+ m_editCookie.cbSize = mir_strlen(m_editCookie.ansi);
+ m_editCookie.cbCount = 0;
+
+ EDITSTREAM editStream;
+ editStream.dwCookie = (DWORD_PTR)&m_editCookie;
editStream.dwError = 0;
editStream.pfnCallback = (EDITSTREAMCALLBACK)EditStreamInCallback;
- hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_RTF), (LPARAM)&editStream, &lResult);
+
+ LRESULT lResult = 0;
+ HRESULT hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_RTF), (LPARAM)&editStream, &lResult);
return S_OK;
}
HRESULT CFormattedTextDraw::putRTFTextW(WCHAR *newVal)
{
-
- HRESULT hr;
- LRESULT lResult = 0;
- EDITSTREAM editStream;
-
- if (!m_spTextServices)
+ if (!m_spTextServices)
return S_FALSE;
m_editCookie.isUnicode = true;
m_editCookie.unicode = newVal;
- m_editCookie.dwSize = mir_wstrlen(m_editCookie.unicode);
- m_editCookie.dwCount = 0;
- editStream.dwCookie = (DWORD_PTR) &m_editCookie;
+ m_editCookie.cbSize = mir_wstrlen(m_editCookie.unicode);
+ m_editCookie.cbCount = 0;
+
+ EDITSTREAM editStream;
+ editStream.dwCookie = (DWORD_PTR)&m_editCookie;
editStream.dwError = 0;
editStream.pfnCallback = (EDITSTREAMCALLBACK)EditStreamInCallback;
- hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_RTF|SF_UNICODE), (LPARAM)&editStream, &lResult);
+
+ LRESULT lResult = 0;
+ HRESULT hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_RTF | SF_UNICODE), (LPARAM)&editStream, &lResult);
return S_OK;
}
HRESULT CFormattedTextDraw::putTextA(char *newVal)
{
- HRESULT hr;
- LRESULT lResult = 0;
- EDITSTREAM editStream;
-
- if (!m_spTextServices)
+ if (!m_spTextServices)
return S_FALSE;
m_editCookie.isUnicode = false;
m_editCookie.ansi = newVal;
- m_editCookie.dwSize = mir_strlen(m_editCookie.ansi);
- m_editCookie.dwCount = 0;
- editStream.dwCookie = (DWORD_PTR) &m_editCookie;
+ m_editCookie.cbSize = mir_strlen(m_editCookie.ansi);
+ m_editCookie.cbCount = 0;
+
+ EDITSTREAM editStream;
+ editStream.dwCookie = (DWORD_PTR)&m_editCookie;
editStream.dwError = 0;
editStream.pfnCallback = (EDITSTREAMCALLBACK)EditStreamInCallback;
- hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_TEXT), (LPARAM)&editStream, &lResult);
-
+
+ LRESULT lResult = 0;
+ HRESULT hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_TEXT), (LPARAM)&editStream, &lResult);
+
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
- cf.dwMask = CFM_FACE|CFM_BOLD;
+ cf.dwMask = CFM_FACE | CFM_BOLD;
cf.dwEffects = 0;
mir_sntprintf(cf.szFaceName, SIZEOF(cf.szFaceName), _T("MS Shell Dlg"));
m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, (WPARAM)(SCF_ALL), (LPARAM)&cf, &lResult);
@@ -128,32 +128,29 @@ HRESULT CFormattedTextDraw::putTextA(char *newVal)
HRESULT CFormattedTextDraw::putTextW(WCHAR *newVal)
{
-
- HRESULT hr;
- LRESULT lResult = 0;
- EDITSTREAM editStream;
-
- if (!m_spTextServices)
+ if (!m_spTextServices)
return S_FALSE;
m_editCookie.isUnicode = true;
m_editCookie.unicode = newVal;
- m_editCookie.dwSize = mir_wstrlen(m_editCookie.unicode);
- m_editCookie.dwCount = 0;
- editStream.dwCookie = (DWORD_PTR) &m_editCookie;
+ m_editCookie.cbSize = mir_wstrlen(m_editCookie.unicode);
+ m_editCookie.cbCount = 0;
+
+ EDITSTREAM editStream;
+ editStream.dwCookie = (DWORD_PTR)&m_editCookie;
editStream.dwError = 0;
editStream.pfnCallback = (EDITSTREAMCALLBACK)EditStreamInCallback;
- hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_TEXT|SF_UNICODE), (LPARAM)&editStream, &lResult);
-
+
+ LRESULT lResult = 0;
+ HRESULT hr = m_spTextServices->TxSendMessage(EM_STREAMIN, (WPARAM)(SF_TEXT | SF_UNICODE), (LPARAM)&editStream, &lResult);
+
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
- cf.dwMask = CFM_FACE|CFM_BOLD;
+ cf.dwMask = CFM_FACE | CFM_BOLD;
cf.dwEffects = 0;
mir_sntprintf(cf.szFaceName, SIZEOF(cf.szFaceName), _T("MS Shell Dlg"));
m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, (WPARAM)(SCF_ALL), (LPARAM)&cf, &lResult);
-
return S_OK;
-
}
HRESULT CFormattedTextDraw::Draw(void *hdcDraw, RECT *prc)
@@ -164,12 +161,12 @@ HRESULT CFormattedTextDraw::Draw(void *hdcDraw, RECT *prc)
LRESULT lResult;
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
- cf.dwMask = CFM_FACE/*|CFM_COLOR*/|CFM_CHARSET|CFM_SIZE|
- (lf.lfWeight>=FW_BOLD?CFM_BOLD:0)|
- (lf.lfItalic?CFM_ITALIC:0)|
- (lf.lfUnderline?CFM_UNDERLINE:0)|
- (lf.lfStrikeOut?CFM_STRIKEOUT:0);
- cf.dwEffects = CFE_BOLD|CFE_ITALIC|CFE_STRIKEOUT|CFE_UNDERLINE;
+ cf.dwMask = CFM_FACE/*|CFM_COLOR*/ | CFM_CHARSET | CFM_SIZE |
+ (lf.lfWeight >= FW_BOLD ? CFM_BOLD : 0) |
+ (lf.lfItalic ? CFM_ITALIC : 0) |
+ (lf.lfUnderline ? CFM_UNDERLINE : 0) |
+ (lf.lfStrikeOut ? CFM_STRIKEOUT : 0);
+ cf.dwEffects = CFE_BOLD | CFE_ITALIC | CFE_STRIKEOUT | CFE_UNDERLINE;
cf.crTextColor = GetTextColor((HDC)hdcDraw);
cf.bCharSet = lf.lfCharSet;
cf.yHeight = 1440 * abs(lf.lfHeight) / GetDeviceCaps((HDC)hdcDraw, LOGPIXELSY);
@@ -177,15 +174,15 @@ HRESULT CFormattedTextDraw::Draw(void *hdcDraw, RECT *prc)
m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, (WPARAM)(SCF_ALL), (LPARAM)&cf, &lResult);
m_spTextServices->TxDraw(
- DVASPECT_CONTENT, // Draw Aspect
+ DVASPECT_CONTENT, // Draw Aspect
0, // Lindex
NULL, // Info for drawing optimization
NULL, // target device information
- (HDC) hdcDraw, // Draw device HDC
+ (HDC)hdcDraw, // Draw device HDC
NULL, // Target device HDC
- (RECTL *) prc, // Bounding client rectangle
+ (RECTL *)prc, // Bounding client rectangle
NULL, // Clipping rectangle for metafiles
- (RECT *) NULL, // Update rectangle
+ (RECT *)NULL, // Update rectangle
NULL, // Call back function
NULL, // Call back parameter
TXTVIEW_INACTIVE); // What view of the object could be TXTVIEW_ACTIVE
@@ -205,12 +202,12 @@ HRESULT CFormattedTextDraw::get_NaturalSize(void *hdcDraw, long *Width, long *He
LRESULT lResult;
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
- cf.dwMask = CFM_FACE/*|CFM_COLOR*/|CFM_CHARSET|CFM_SIZE|
- (lf.lfWeight>=FW_BOLD?CFM_BOLD:0)|
- (lf.lfItalic?CFM_ITALIC:0)|
- (lf.lfUnderline?CFM_UNDERLINE:0)|
- (lf.lfStrikeOut?CFM_STRIKEOUT:0);
- cf.dwEffects = CFE_BOLD|CFE_ITALIC|CFE_STRIKEOUT|CFE_UNDERLINE;
+ cf.dwMask = CFM_FACE/*|CFM_COLOR*/ | CFM_CHARSET | CFM_SIZE |
+ (lf.lfWeight >= FW_BOLD ? CFM_BOLD : 0) |
+ (lf.lfItalic ? CFM_ITALIC : 0) |
+ (lf.lfUnderline ? CFM_UNDERLINE : 0) |
+ (lf.lfStrikeOut ? CFM_STRIKEOUT : 0);
+ cf.dwEffects = CFE_BOLD | CFE_ITALIC | CFE_STRIKEOUT | CFE_UNDERLINE;
cf.crTextColor = GetTextColor((HDC)hdcDraw);
cf.bCharSet = lf.lfCharSet;
cf.yHeight = 1440 * abs(lf.lfHeight) / GetDeviceCaps((HDC)hdcDraw, LOGPIXELSY);
@@ -221,24 +218,20 @@ HRESULT CFormattedTextDraw::get_NaturalSize(void *hdcDraw, long *Width, long *He
m_spTextServices->TxSendMessage(EM_SETCHARFORMAT, (WPARAM)(SCF_ALL), (LPARAM)&cf, &lResult);
- SIZEL szExtent;
-// HDC hdcDraw;
-// hdcDraw = GetDC(NULL);
*Height = 1;
+
+ SIZEL szExtent;
szExtent.cx = *Width;
szExtent.cy = *Height;
if (m_spTextServices->TxGetNaturalSize(DVASPECT_CONTENT, (HDC)hdcDraw, NULL, NULL, TXTNS_FITTOCONTENT, &szExtent, Width, Height) != S_OK)
- {
-// ReleaseDC(NULL, hdcDraw);
return S_FALSE;
- }
-// ReleaseDC(NULL, hdcDraw);
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
// ITextHost functions
+
HDC CFormattedTextDraw::TxGetDC()
{
return NULL;
@@ -270,12 +263,10 @@ BOOL CFormattedTextDraw::TxSetScrollPos(INT fnBar, INT nPos, BOOL fRedraw)
}
void CFormattedTextDraw::TxInvalidateRect(LPCRECT prc, BOOL fMode)
-{
-}
+{}
void CFormattedTextDraw::TxViewChange(BOOL fUpdate)
-{
-}
+{}
BOOL CFormattedTextDraw::TxCreateCaret(HBITMAP hbmp, INT xWidth, INT yHeight)
{
@@ -313,33 +304,26 @@ void CFormattedTextDraw::TxSetFocus()
{
}
-
void CFormattedTextDraw::TxSetCursor(HCURSOR hcur, BOOL fText)
{
if (fText)
- {
SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
- } else
- {
+ else
SetCursor(hcur);
- }
}
BOOL CFormattedTextDraw::TxScreenToClient(LPPOINT lppt)
{
if (!m_hwndParent) return FALSE;
-// BOOL result = ScreenToClient(m_hwndParent, lppt);
-// lppt->x -= m_rcClient.left;
-// lppt->y -= m_rcClient.left;
return ScreenToClient(m_hwndParent, lppt);
}
BOOL CFormattedTextDraw::TxClientToScreen(LPPOINT lppt)
{
if (!m_hwndParent) return FALSE;
-// BOOL result = ;
-// lppt->x -= m_rcClient.left;
-// lppt->y -= m_rcClient.left;
+ // BOOL result = ;
+ // lppt->x -= m_rcClient.left;
+ // lppt->y -= m_rcClient.left;
return ClientToScreen(m_hwndParent, lppt);
}
@@ -445,8 +429,7 @@ HIMC CFormattedTextDraw::TxImmGetContext()
}
void CFormattedTextDraw::TxImmReleaseContext(HIMC himc)
-{
-}
+{}
HRESULT CFormattedTextDraw::TxGetSelectionBarWidth(LONG *lSelBarWidth)
{
@@ -460,17 +443,12 @@ HRESULT CFormattedTextDraw::TxGetSelectionBarWidth(LONG *lSelBarWidth)
HRESULT CFormattedTextDraw::CharFormatFromHFONT(CHARFORMAT2W* pCF, HFONT hFont)
// Takes an HFONT and fills in a CHARFORMAT2W structure with the corresponding info
{
-
- HWND hWnd;
- LOGFONT lf;
- HDC hDC;
- LONG yPixPerInch;
-
// Get LOGFONT for default font
if (!hFont)
- hFont = (HFONT) GetStockObject(SYSTEM_FONT);
+ hFont = (HFONT)GetStockObject(SYSTEM_FONT);
// Get LOGFONT for passed hfont
+ LOGFONT lf;
if (!GetObject(hFont, sizeof(LOGFONT), &lf))
return E_FAIL;
@@ -478,9 +456,9 @@ HRESULT CFormattedTextDraw::CharFormatFromHFONT(CHARFORMAT2W* pCF, HFONT hFont)
memset(pCF, 0, sizeof(CHARFORMAT2W));
pCF->cbSize = sizeof(CHARFORMAT2W);
- hWnd = GetDesktopWindow();
- hDC = GetDC(hWnd);
- yPixPerInch = GetDeviceCaps(hDC, LOGPIXELSY);
+ HWND hWnd = GetDesktopWindow();
+ HDC hDC = GetDC(hWnd);
+ LONG yPixPerInch = GetDeviceCaps(hDC, LOGPIXELSY);
pCF->yHeight = -lf.lfHeight * LY_PER_INCH / yPixPerInch;
ReleaseDC(hWnd, hDC);
@@ -490,7 +468,7 @@ HRESULT CFormattedTextDraw::CharFormatFromHFONT(CHARFORMAT2W* pCF, HFONT hFont)
pCF->dwEffects = CFM_EFFECTS | CFE_AUTOBACKCOLOR;
pCF->dwEffects &= ~(CFE_PROTECTED | CFE_LINK | CFE_AUTOCOLOR);
- if(lf.lfWeight < FW_BOLD)
+ if (lf.lfWeight < FW_BOLD)
pCF->dwEffects &= ~CFE_BOLD;
if (!lf.lfItalic)
@@ -506,10 +484,7 @@ HRESULT CFormattedTextDraw::CharFormatFromHFONT(CHARFORMAT2W* pCF, HFONT hFont)
pCF->bCharSet = lf.lfCharSet;
pCF->bPitchAndFamily = lf.lfPitchAndFamily;
-
mir_wstrcpy(pCF->szFaceName, lf.lfFaceName);
-
-
return S_OK;
}
@@ -531,10 +506,8 @@ HRESULT CFormattedTextDraw::InitDefaultParaFormat()
HRESULT CFormattedTextDraw::CreateTextServicesObject()
{
- HRESULT hr;
IUnknown *spUnk;
-
- hr = MyCreateTextServices(NULL, static_cast<ITextHost*>(this), &spUnk);
+ HRESULT hr = MyCreateTextServices(NULL, static_cast<ITextHost*>(this), &spUnk);
if (hr == S_OK) {
hr = spUnk->QueryInterface(IID_ITextServices, (void**)&m_spTextServices);
hr = spUnk->QueryInterface(IID_ITextDocument, (void**)&m_spTextDocument);
@@ -542,4 +515,3 @@ HRESULT CFormattedTextDraw::CreateTextServicesObject()
}
return hr;
}
-
diff --git a/plugins/mTextControl/src/FormattedTextDraw.h b/plugins/mTextControl/src/FormattedTextDraw.h
index 3ea2e2faee..bfadbb918f 100644
--- a/plugins/mTextControl/src/FormattedTextDraw.h
+++ b/plugins/mTextControl/src/FormattedTextDraw.h
@@ -11,7 +11,7 @@
#define HOST_BORDER 0
#endif
-typedef struct tagCOOKIE
+struct COOKIE
{
bool isUnicode;
union
@@ -19,9 +19,8 @@ typedef struct tagCOOKIE
char *ansi;
WCHAR *unicode;
};
- DWORD dwSize;
- DWORD dwCount;
-} COOKIE, *PCOOKIE;
+ size_t cbSize, cbCount;
+};
extern HRESULT (WINAPI *MyCreateTextServices)(IUnknown *punkOuter, ITextHost *pITextHost, IUnknown **ppUnk);
diff --git a/plugins/mTextControl/src/dataobject.cpp b/plugins/mTextControl/src/dataobject.cpp
index 99e0348bc6..c8f4f50e8f 100644
--- a/plugins/mTextControl/src/dataobject.cpp
+++ b/plugins/mTextControl/src/dataobject.cpp
@@ -63,16 +63,15 @@ private:
//
// Constructor
//
-CDataObject::CDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmed, int count)
+CDataObject::CDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmed, int count)
{
- m_lRefCount = 1;
+ m_lRefCount = 1;
m_nNumFormats = count;
-
- m_pFormatEtc = new FORMATETC[count];
- m_pStgMedium = new STGMEDIUM[count];
- for(int i = 0; i < count; i++)
- {
+ m_pFormatEtc = new FORMATETC[count];
+ m_pStgMedium = new STGMEDIUM[count];
+
+ for (int i = 0; i < count; i++) {
m_pFormatEtc[i] = fmtetc[i];
m_pStgMedium[i] = stgmed[i];
}
@@ -84,13 +83,12 @@ CDataObject::CDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmed, int c
CDataObject::~CDataObject()
{
// cleanup
- for (int i = 0; i < m_nNumFormats; i++)
- {
-// ReleaseStgMedium(&m_pStgMedium[i]);
+ for (int i = 0; i < m_nNumFormats; i++) {
+ // ReleaseStgMedium(&m_pStgMedium[i]);
}
- if(m_pFormatEtc) delete[] m_pFormatEtc;
- if(m_pStgMedium) delete[] m_pStgMedium;
+ if (m_pFormatEtc) delete[] m_pFormatEtc;
+ if (m_pStgMedium) delete[] m_pStgMedium;
}
//
@@ -98,8 +96,8 @@ CDataObject::~CDataObject()
//
ULONG __stdcall CDataObject::AddRef(void)
{
- // increment object reference count
- return InterlockedIncrement(&m_lRefCount);
+ // increment object reference count
+ return InterlockedIncrement(&m_lRefCount);
}
//
@@ -107,18 +105,15 @@ ULONG __stdcall CDataObject::AddRef(void)
//
ULONG __stdcall CDataObject::Release(void)
{
- // decrement object reference count
+ // decrement object reference count
LONG count = InterlockedDecrement(&m_lRefCount);
-
- if(count == 0)
- {
+
+ if (count == 0) {
delete this;
return 0;
}
- else
- {
- return count;
- }
+
+ return count;
}
//
@@ -126,28 +121,23 @@ ULONG __stdcall CDataObject::Release(void)
//
HRESULT __stdcall CDataObject::QueryInterface(REFIID iid, void **ppvObject)
{
- // check to see what interface has been requested
- if(iid == IID_IDataObject || iid == IID_IUnknown)
- {
- AddRef();
- *ppvObject = this;
- return S_OK;
- }
- else
- {
- *ppvObject = 0;
- return E_NOINTERFACE;
- }
+ // check to see what interface has been requested
+ if (iid == IID_IDataObject || iid == IID_IUnknown) {
+ AddRef();
+ *ppvObject = this;
+ return S_OK;
+ }
+
+ *ppvObject = 0;
+ return E_NOINTERFACE;
}
int CDataObject::LookupFormatEtc(FORMATETC *pFormatEtc)
{
- for (int i = 0; i < m_nNumFormats; i++)
- {
- if ((pFormatEtc->tymed & m_pFormatEtc[i].tymed) &&
- pFormatEtc->cfFormat == m_pFormatEtc[i].cfFormat &&
- pFormatEtc->dwAspect == m_pFormatEtc[i].dwAspect)
- {
+ for (int i = 0; i < m_nNumFormats; i++) {
+ if ((pFormatEtc->tymed & m_pFormatEtc[i].tymed) &&
+ pFormatEtc->cfFormat == m_pFormatEtc[i].cfFormat &&
+ pFormatEtc->dwAspect == m_pFormatEtc[i].dwAspect) {
return i;
}
}
@@ -158,35 +148,33 @@ int CDataObject::LookupFormatEtc(FORMATETC *pFormatEtc)
//
// IDataObject::GetData
//
-HRESULT __stdcall CDataObject::GetData (FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
+HRESULT __stdcall CDataObject::GetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
{
int idx;
//
// try to match the requested FORMATETC with one of our supported formats
//
- if ((idx = LookupFormatEtc(pFormatEtc)) == -1)
- {
+ if ((idx = LookupFormatEtc(pFormatEtc)) == -1) {
return DV_E_FORMATETC;
}
//
// found a match! transfer the data into the supplied storage-medium
//
- pMedium->tymed = m_pFormatEtc[idx].tymed;
- pMedium->pUnkForRelease = 0;
-
- switch (pMedium->tymed)
- {
- case TYMED_HGLOBAL:
- case TYMED_GDI:
- case TYMED_ENHMF:
-// pMedium->hBitmap = (HBITMAP)OleDuplicateData(m_pStgMedium[idx].hBitmap, pFormatEtc->cfFormat, 0);
- pMedium->hBitmap = m_pStgMedium[idx].hBitmap;
- break;
-
- default:
- return DV_E_FORMATETC;
+ pMedium->tymed = m_pFormatEtc[idx].tymed;
+ pMedium->pUnkForRelease = 0;
+
+ switch (pMedium->tymed) {
+ case TYMED_HGLOBAL:
+ case TYMED_GDI:
+ case TYMED_ENHMF:
+ // pMedium->hBitmap = (HBITMAP)OleDuplicateData(m_pStgMedium[idx].hBitmap, pFormatEtc->cfFormat, 0);
+ pMedium->hBitmap = m_pStgMedium[idx].hBitmap;
+ break;
+
+ default:
+ return DV_E_FORMATETC;
}
if (pMedium->hBitmap == NULL) return STG_E_MEDIUMFULL;
@@ -196,7 +184,7 @@ HRESULT __stdcall CDataObject::GetData (FORMATETC *pFormatEtc, STGMEDIUM *pMediu
//
// IDataObject::GetDataHere
//
-HRESULT __stdcall CDataObject::GetDataHere (FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
+HRESULT __stdcall CDataObject::GetDataHere(FORMATETC *pFormatEtc, STGMEDIUM *pMedium)
{
// GetDataHere is only required for IStream and IStorage mediums
// It is an error to call GetDataHere for things like HGLOBAL and other clipboard formats
@@ -211,7 +199,7 @@ HRESULT __stdcall CDataObject::GetDataHere (FORMATETC *pFormatEtc, STGMEDIUM *pM
//
// Called to see if the IDataObject supports the specified format of data
//
-HRESULT __stdcall CDataObject::QueryGetData (FORMATETC *pFormatEtc)
+HRESULT __stdcall CDataObject::QueryGetData(FORMATETC *pFormatEtc)
{
return (LookupFormatEtc(pFormatEtc) == -1) ? DV_E_FORMATETC : S_OK;
}
@@ -219,7 +207,7 @@ HRESULT __stdcall CDataObject::QueryGetData (FORMATETC *pFormatEtc)
//
// IDataObject::GetCanonicalFormatEtc
//
-HRESULT __stdcall CDataObject::GetCanonicalFormatEtc (FORMATETC *pFormatEct, FORMATETC *pFormatEtcOut)
+HRESULT __stdcall CDataObject::GetCanonicalFormatEtc(FORMATETC *pFormatEct, FORMATETC *pFormatEtcOut)
{
// Apparently we have to set this field to NULL even though we don't do anything else
pFormatEtcOut->ptd = NULL;
@@ -229,7 +217,7 @@ HRESULT __stdcall CDataObject::GetCanonicalFormatEtc (FORMATETC *pFormatEct, FOR
//
// IDataObject::SetData
//
-HRESULT __stdcall CDataObject::SetData (FORMATETC *pFormatEtc, STGMEDIUM *pMedium, BOOL fRelease)
+HRESULT __stdcall CDataObject::SetData(FORMATETC *pFormatEtc, STGMEDIUM *pMedium, BOOL fRelease)
{
return E_NOTIMPL;
}
@@ -237,16 +225,14 @@ HRESULT __stdcall CDataObject::SetData (FORMATETC *pFormatEtc, STGMEDIUM *pMediu
//
// IDataObject::EnumFormatEtc
//
-HRESULT __stdcall CDataObject::EnumFormatEtc (DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc)
+HRESULT __stdcall CDataObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppEnumFormatEtc)
{
- if(dwDirection == DATADIR_GET)
- {
+ if (dwDirection == DATADIR_GET) {
// for Win2k+ you can use the SHCreateStdEnumFmtEtc API call, however
// to support all Windows platforms we need to implement IEnumFormatEtc ourselves.
return CreateEnumFormatEtc(m_nNumFormats, m_pFormatEtc, ppEnumFormatEtc);
}
- else
- {
+ else {
// the direction specified is not support for drag+drop
return E_NOTIMPL;
}
@@ -255,7 +241,7 @@ HRESULT __stdcall CDataObject::EnumFormatEtc (DWORD dwDirection, IEnumFORMATETC
//
// IDataObject::DAdvise
//
-HRESULT __stdcall CDataObject::DAdvise (FORMATETC *pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
+HRESULT __stdcall CDataObject::DAdvise(FORMATETC *pFormatEtc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
{
return OLE_E_ADVISENOTSUPPORTED;
}
@@ -263,7 +249,7 @@ HRESULT __stdcall CDataObject::DAdvise (FORMATETC *pFormatEtc, DWORD advf, IAdvi
//
// IDataObject::DUnadvise
//
-HRESULT __stdcall CDataObject::DUnadvise (DWORD dwConnection)
+HRESULT __stdcall CDataObject::DUnadvise(DWORD dwConnection)
{
return OLE_E_ADVISENOTSUPPORTED;
}
@@ -271,7 +257,7 @@ HRESULT __stdcall CDataObject::DUnadvise (DWORD dwConnection)
//
// IDataObject::EnumDAdvise
//
-HRESULT __stdcall CDataObject::EnumDAdvise (IEnumSTATDATA **ppEnumAdvise)
+HRESULT __stdcall CDataObject::EnumDAdvise(IEnumSTATDATA **ppEnumAdvise)
{
return OLE_E_ADVISENOTSUPPORTED;
}
@@ -279,9 +265,9 @@ HRESULT __stdcall CDataObject::EnumDAdvise (IEnumSTATDATA **ppEnumAdvise)
//
// Helper function
//
-HRESULT CreateDataObject (const FORMATETC *fmtetc, const STGMEDIUM *stgmeds, UINT count, IDataObject **ppDataObject)
+HRESULT CreateDataObject(const FORMATETC *fmtetc, const STGMEDIUM *stgmeds, UINT count, IDataObject **ppDataObject)
{
- if(ppDataObject == 0)
+ if (ppDataObject == 0)
return E_INVALIDARG;
*ppDataObject = new CDataObject(fmtetc, stgmeds, count);
diff --git a/plugins/mTextControl/src/enumformat.cpp b/plugins/mTextControl/src/enumformat.cpp
index 7daac154d7..9aa3895e05 100644
--- a/plugins/mTextControl/src/enumformat.cpp
+++ b/plugins/mTextControl/src/enumformat.cpp
@@ -21,7 +21,6 @@
class CEnumFormatEtc : public IEnumFORMATETC
{
public:
-
//
// IUnknown members
//
@@ -56,7 +55,7 @@ private:
//
HRESULT CreateEnumFormatEtc(UINT nNumFormats, FORMATETC *pFormatEtc, IEnumFORMATETC **ppEnumFormatEtc)
{
- if(nNumFormats == 0 || pFormatEtc == 0 || ppEnumFormatEtc == 0)
+ if (nNumFormats == 0 || pFormatEtc == 0 || ppEnumFormatEtc == 0)
return E_INVALIDARG;
*ppEnumFormatEtc = new CEnumFormatEtc(pFormatEtc, nNumFormats);
@@ -71,9 +70,8 @@ static void DeepCopyFormatEtc(FORMATETC *dest, FORMATETC *source)
{
// copy the source FORMATETC into dest
*dest = *source;
-
- if(source->ptd)
- {
+
+ if (source->ptd) {
// allocate memory for the DVTARGETDEVICE if necessary
dest->ptd = (DVTARGETDEVICE*)CoTaskMemAlloc(sizeof(DVTARGETDEVICE));
@@ -87,14 +85,13 @@ static void DeepCopyFormatEtc(FORMATETC *dest, FORMATETC *source)
//
CEnumFormatEtc::CEnumFormatEtc(FORMATETC *pFormatEtc, int nNumFormats)
{
- m_lRefCount = 1;
- m_nIndex = 0;
+ m_lRefCount = 1;
+ m_nIndex = 0;
m_nNumFormats = nNumFormats;
- m_pFormatEtc = new FORMATETC[nNumFormats];
-
+ m_pFormatEtc = new FORMATETC[nNumFormats];
+
// copy the FORMATETC structures
- for(int i = 0; i < nNumFormats; i++)
- {
+ for (int i = 0; i < nNumFormats; i++) {
DeepCopyFormatEtc(&m_pFormatEtc[i], &pFormatEtc[i]);
}
}
@@ -104,11 +101,9 @@ CEnumFormatEtc::CEnumFormatEtc(FORMATETC *pFormatEtc, int nNumFormats)
//
CEnumFormatEtc::~CEnumFormatEtc()
{
- if(m_pFormatEtc)
- {
- for(ULONG i = 0; i < m_nNumFormats; i++)
- {
- if(m_pFormatEtc[i].ptd)
+ if (m_pFormatEtc) {
+ for (ULONG i = 0; i < m_nNumFormats; i++) {
+ if (m_pFormatEtc[i].ptd)
CoTaskMemFree(m_pFormatEtc[i].ptd);
}
@@ -121,8 +116,8 @@ CEnumFormatEtc::~CEnumFormatEtc()
//
ULONG __stdcall CEnumFormatEtc::AddRef(void)
{
- // increment object reference count
- return InterlockedIncrement(&m_lRefCount);
+ // increment object reference count
+ return InterlockedIncrement(&m_lRefCount);
}
//
@@ -130,16 +125,14 @@ ULONG __stdcall CEnumFormatEtc::AddRef(void)
//
ULONG __stdcall CEnumFormatEtc::Release(void)
{
- // decrement object reference count
+ // decrement object reference count
LONG count = InterlockedDecrement(&m_lRefCount);
-
- if(count == 0)
- {
+
+ if (count == 0) {
delete this;
return 0;
}
- else
- {
+ else {
return count;
}
}
@@ -149,18 +142,16 @@ ULONG __stdcall CEnumFormatEtc::Release(void)
//
HRESULT __stdcall CEnumFormatEtc::QueryInterface(REFIID iid, void **ppvObject)
{
- // check to see what interface has been requested
- if(iid == IID_IEnumFORMATETC || iid == IID_IUnknown)
- {
- AddRef();
- *ppvObject = this;
- return S_OK;
- }
- else
- {
- *ppvObject = 0;
- return E_NOINTERFACE;
- }
+ // check to see what interface has been requested
+ if (iid == IID_IEnumFORMATETC || iid == IID_IUnknown) {
+ AddRef();
+ *ppvObject = this;
+ return S_OK;
+ }
+ else {
+ *ppvObject = 0;
+ return E_NOINTERFACE;
+ }
}
//
@@ -171,22 +162,21 @@ HRESULT __stdcall CEnumFormatEtc::QueryInterface(REFIID iid, void **ppvObject)
//
HRESULT __stdcall CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG * pceltFetched)
{
- ULONG copied = 0;
+ ULONG copied = 0;
// validate arguments
- if(celt == 0 || pFormatEtc == 0)
+ if (celt == 0 || pFormatEtc == 0)
return E_INVALIDARG;
// copy FORMATETC structures into caller's buffer
- while(m_nIndex < m_nNumFormats && copied < celt)
- {
+ while (m_nIndex < m_nNumFormats && copied < celt) {
DeepCopyFormatEtc(&pFormatEtc[copied], &m_pFormatEtc[m_nIndex]);
copied++;
m_nIndex++;
}
// store result
- if(pceltFetched != 0)
+ if (pceltFetched != 0)
*pceltFetched = copied;
// did we copy all that was requested?
@@ -221,12 +211,10 @@ HRESULT __stdcall CEnumFormatEtc::Clone(IEnumFORMATETC ** ppEnumFormatEtc)
// make a duplicate enumerator
hResult = CreateEnumFormatEtc(m_nNumFormats, m_pFormatEtc, ppEnumFormatEtc);
- if(hResult == S_OK)
- {
+ if (hResult == S_OK) {
// manually set the index state
- ((CEnumFormatEtc *) *ppEnumFormatEtc)->m_nIndex = m_nIndex;
+ ((CEnumFormatEtc *)*ppEnumFormatEtc)->m_nIndex = m_nIndex;
}
return hResult;
}
-
diff --git a/plugins/mTextControl/src/fancy_rtf.cpp b/plugins/mTextControl/src/fancy_rtf.cpp
index 01ad6bc0f3..e5325bd706 100644
--- a/plugins/mTextControl/src/fancy_rtf.cpp
+++ b/plugins/mTextControl/src/fancy_rtf.cpp
@@ -14,38 +14,37 @@ enum { BBS_BOLD_S, BBS_BOLD_E, BBS_ITALIC_S, BBS_ITALIC_E, BBS_UNDERLINE_S, BBS_
static bool bbCodeSimpleFunc(IFormattedTextDraw *ftd, CHARRANGE range, TCHAR *txt, DWORD cookie)
{
- CHARFORMAT cf = {0};
+ CHARFORMAT cf = { 0 };
cf.cbSize = sizeof(cf);
- switch (cookie)
- {
- case BBS_BOLD_S:
- cf.dwMask = CFM_BOLD;
- cf.dwEffects = CFE_BOLD;
- break;
- case BBS_BOLD_E:
- cf.dwMask = CFM_BOLD;
- break;
- case BBS_ITALIC_S:
- cf.dwMask = CFM_ITALIC;
- cf.dwEffects = CFE_ITALIC;
- break;
- case BBS_ITALIC_E:
- cf.dwMask = CFM_ITALIC;
- break;
- case BBS_UNDERLINE_S:
- cf.dwMask = CFM_UNDERLINE;
- cf.dwEffects = CFE_UNDERLINE;
- break;
- case BBS_UNDERLINE_E:
- cf.dwMask = CFM_UNDERLINE;
- break;
- case BBS_STRIKEOUT_S:
- cf.dwMask = CFM_STRIKEOUT;
- cf.dwEffects = CFE_STRIKEOUT;
- break;
- case BBS_STRIKEOUT_E:
- cf.dwMask = CFM_STRIKEOUT;
- break;
+ switch (cookie) {
+ case BBS_BOLD_S:
+ cf.dwMask = CFM_BOLD;
+ cf.dwEffects = CFE_BOLD;
+ break;
+ case BBS_BOLD_E:
+ cf.dwMask = CFM_BOLD;
+ break;
+ case BBS_ITALIC_S:
+ cf.dwMask = CFM_ITALIC;
+ cf.dwEffects = CFE_ITALIC;
+ break;
+ case BBS_ITALIC_E:
+ cf.dwMask = CFM_ITALIC;
+ break;
+ case BBS_UNDERLINE_S:
+ cf.dwMask = CFM_UNDERLINE;
+ cf.dwEffects = CFE_UNDERLINE;
+ break;
+ case BBS_UNDERLINE_E:
+ cf.dwMask = CFM_UNDERLINE;
+ break;
+ case BBS_STRIKEOUT_S:
+ cf.dwMask = CFM_STRIKEOUT;
+ cf.dwEffects = CFE_STRIKEOUT;
+ break;
+ case BBS_STRIKEOUT_E:
+ cf.dwMask = CFM_STRIKEOUT;
+ break;
}
ITextServices *ts = ftd->getTextService();
@@ -66,20 +65,11 @@ static bool bbCodeImageFunc(IFormattedTextDraw *ftd, CHARRANGE range, TCHAR *txt
long cnt;
LRESULT lResult;
-/*
- TEXTRANGE trg;
- trg.chrg = range;
- trg.lpstrText = new TCHAR[trg.chrg.cpMax - trg.chrg.cpMin + 1];
- ts->TxSendMessage(EM_GETTEXTRANGE, 0, (LPARAM)&trg, &lResult);
- MessageBox(0, txt, trg.lpstrText, MB_OK);
-*/
ts->TxSendMessage(EM_SETSEL, range.cpMin, range.cpMax, &lResult);
IRichEditOle* RichEditOle;
ts->TxSendMessage(EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle, &lResult);
td->Freeze(&cnt);
-// HDC emfdc = CreateEnhMetaFile(NULL, NULL, NULL, _T("icon"));
-// DrawIconEx(emfdc, 0, 0, (HICON)_ttol(txt), 16, 16, 0, NULL, DI_NORMAL);
-// InsertBitmap(RichEditOle, CloseEnhMetaFile(emfdc));
+
#ifdef _WIN64
bool res = InsertBitmap(RichEditOle, CacheIconToEmf((HICON)_tstoi64(txt)));
#else
@@ -93,24 +83,24 @@ static bool bbCodeImageFunc(IFormattedTextDraw *ftd, CHARRANGE range, TCHAR *txt
static BBCodeInfo bbCodes[] =
{
- { _T("[b]"), 0, bbCodeSimpleFunc, BBS_BOLD_S },
- { _T("[/b]"), 0, bbCodeSimpleFunc, BBS_BOLD_E },
- { _T("[i]"), 0, bbCodeSimpleFunc, BBS_ITALIC_S },
- { _T("[/i]"), 0, bbCodeSimpleFunc, BBS_ITALIC_E },
- { _T("[u]"), 0, bbCodeSimpleFunc, BBS_UNDERLINE_S },
- { _T("[/u]"), 0, bbCodeSimpleFunc, BBS_UNDERLINE_E },
- { _T("[s]"), 0, bbCodeSimpleFunc, BBS_STRIKEOUT_S },
- { _T("[/s]"), 0, bbCodeSimpleFunc, BBS_STRIKEOUT_E },
-
-// { _T("[color="), _T("]"), bbCodeSimpleFunc, BBS_COLOR_S },
-// { _T("[/color]"), 0, bbCodeSimpleFunc, BBS_COLOR_E }
-
- { _T("[$hicon="), _T("$]"), bbCodeImageFunc, 0 }
-
-// { _T("[url]"), _T("[/url]"), bbCodeSimpleFunc, BBS_URL1 },
-// { _T("[url="), _T("]"), bbCodeSimpleFunc, BBS_URL2 },
-// { _T("[url]"), _T("[/url]"), bbCodeSimpleFunc, BBS_IMG1 },
-// { _T("[url="), _T("]"), bbCodeSimpleFunc, BBS_IMG2 },
+ { _T("[b]"), 0, bbCodeSimpleFunc, BBS_BOLD_S },
+ { _T("[/b]"), 0, bbCodeSimpleFunc, BBS_BOLD_E },
+ { _T("[i]"), 0, bbCodeSimpleFunc, BBS_ITALIC_S },
+ { _T("[/i]"), 0, bbCodeSimpleFunc, BBS_ITALIC_E },
+ { _T("[u]"), 0, bbCodeSimpleFunc, BBS_UNDERLINE_S },
+ { _T("[/u]"), 0, bbCodeSimpleFunc, BBS_UNDERLINE_E },
+ { _T("[s]"), 0, bbCodeSimpleFunc, BBS_STRIKEOUT_S },
+ { _T("[/s]"), 0, bbCodeSimpleFunc, BBS_STRIKEOUT_E },
+
+ // { _T("[color="), _T("]"), bbCodeSimpleFunc, BBS_COLOR_S },
+ // { _T("[/color]"), 0, bbCodeSimpleFunc, BBS_COLOR_E }
+
+ { _T("[$hicon="), _T("$]"), bbCodeImageFunc, 0 }
+
+ // { _T("[url]"), _T("[/url]"), bbCodeSimpleFunc, BBS_URL1 },
+ // { _T("[url="), _T("]"), bbCodeSimpleFunc, BBS_URL2 },
+ // { _T("[url]"), _T("[/url]"), bbCodeSimpleFunc, BBS_IMG1 },
+ // { _T("[url="), _T("]"), bbCodeSimpleFunc, BBS_IMG2 },
};
static int bbCodeCount = sizeof(bbCodes) / sizeof(*bbCodes);
@@ -120,15 +110,13 @@ void bbCodeParse(IFormattedTextDraw *ftd)
LRESULT lResult;
int pos = 0;
- for (bool found = true; found; )
- {
+ for (bool found = true; found;) {
found = false;
CHARRANGE fRange; fRange.cpMin = -1;
TCHAR *fText = 0;
BBCodeInfo *fBBCode;
- for (int i = 0; i < bbCodeCount; i++)
- {
+ for (int i = 0; i < bbCodeCount; i++) {
CHARRANGE range;
FINDTEXTEX fte;
@@ -141,8 +129,7 @@ void bbCodeParse(IFormattedTextDraw *ftd)
continue;
range = fte.chrgText;
- if (bbCodes[i].end)
- {
+ if (bbCodes[i].end) {
fte.chrg.cpMin = fte.chrgText.cpMax;
fte.lpstrText = bbCodes[i].end;
ts->TxSendMessage(EM_FINDTEXTEX, (WPARAM)FR_DOWN, (LPARAM)&fte, &lResult);
@@ -151,15 +138,13 @@ void bbCodeParse(IFormattedTextDraw *ftd)
range.cpMax = fte.chrgText.cpMax;
}
- if ((fRange.cpMin == -1) || (fRange.cpMin > range.cpMin))
- {
+ if ((fRange.cpMin == -1) || (fRange.cpMin > range.cpMin)) {
fRange = range;
- fBBCode = bbCodes+i;
+ fBBCode = bbCodes + i;
found = true;
- if (fText) delete [] fText;
- if (bbCodes[i].end)
- {
+ if (fText) delete[] fText;
+ if (bbCodes[i].end) {
TEXTRANGE trg;
trg.chrg.cpMin = fte.chrg.cpMin;
trg.chrg.cpMax = fte.chrgText.cpMin;
@@ -170,10 +155,9 @@ void bbCodeParse(IFormattedTextDraw *ftd)
}
}
- if (found)
- {
+ if (found) {
found = fBBCode->func(ftd, fRange, fText, fBBCode->cookie);
- if (fText) delete [] fText;
+ if (fText) delete[] fText;
}
}
}
diff --git a/plugins/mTextControl/src/richeditutils.cpp b/plugins/mTextControl/src/richeditutils.cpp
index 043ab81675..7ffa31c1bd 100644
--- a/plugins/mTextControl/src/richeditutils.cpp
+++ b/plugins/mTextControl/src/richeditutils.cpp
@@ -1,6 +1,6 @@
#include "headers.h"
-class CREOleCallback: public IRichEditOleCallback
+class CREOleCallback : public IRichEditOleCallback
{
private:
unsigned refCount;
@@ -16,8 +16,7 @@ public:
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID * ppvObj)
{
- if (IsEqualIID(riid, IID_IRichEditOleCallback))
- {
+ if (IsEqualIID(riid, IID_IRichEditOleCallback)) {
*ppvObj = this;
this->AddRef();
return S_OK;
@@ -30,49 +29,49 @@ public:
{
if (this->refCount == 0) {
if (S_OK != StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &this->pictStg))
- this->pictStg = NULL;
+ this->pictStg = NULL;
this->nextStgId = 0;
- }
- return ++this->refCount;
+ }
+ return ++this->refCount;
}
ULONG STDMETHODCALLTYPE Release()
{
- if (--this->refCount == 0) {
- if (this->pictStg)
+ if (--this->refCount == 0) {
+ if (this->pictStg)
this->pictStg->Release();
- }
- return this->refCount;
+ }
+ return this->refCount;
}
HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL fEnterMode)
{
- return S_OK;
+ return S_OK;
}
HRESULT STDMETHODCALLTYPE DeleteObject(LPOLEOBJECT lpoleobj)
{
- return S_OK;
+ return S_OK;
}
HRESULT STDMETHODCALLTYPE GetClipboardData(CHARRANGE * lpchrg, DWORD reco, LPDATAOBJECT * lplpdataobj)
{
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE GetContextMenu(WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE * lpchrg, HMENU * lphmenu)
{
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
HRESULT STDMETHODCALLTYPE GetDragDropEffect(BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect)
{
- return S_OK;
+ return S_OK;
}
HRESULT STDMETHODCALLTYPE GetInPlaceContext(LPOLEINPLACEFRAME * lplpFrame, LPOLEINPLACEUIWINDOW * lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo)
{
- return E_INVALIDARG;
+ return E_INVALIDARG;
}
HRESULT STDMETHODCALLTYPE GetNewStorage(LPSTORAGE * lplpstg)
@@ -82,7 +81,7 @@ public:
if (this->pictStg == NULL)
return STG_E_MEDIUMFULL;
- return this->pictStg->CreateStorage(sztName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
+ return this->pictStg->CreateStorage(sztName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg);
}
@@ -93,12 +92,12 @@ public:
HRESULT STDMETHODCALLTYPE QueryInsertObject(LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp)
{
- return S_OK;
+ return S_OK;
}
HRESULT STDMETHODCALLTYPE ShowContainerUI(BOOL fShow)
{
- return S_OK;
+ return S_OK;
}
};
@@ -113,8 +112,7 @@ void InitRichEdit(ITextServices *ts)
LRESULT CALLBACK RichEditProxyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ITextServices *ts = (ITextServices *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (ts && (msg != WM_DESTROY))
- {
+ if (ts && (msg != WM_DESTROY)) {
LRESULT lResult;
ts->TxSendMessage(msg, wParam, lParam, &lResult);
return lResult;
@@ -139,7 +137,7 @@ void LoadRichEdit()
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcl.lpszMenuName = NULL;
wcl.lpszClassName = _T("NBRichEditProxyWndClass");
- wcl.hIconSm = 0;
+ wcl.hIconSm = 0;
RegisterClassEx(&wcl);
}
diff --git a/plugins/mTextControl/src/services.cpp b/plugins/mTextControl/src/services.cpp
index 109431f846..b649d69b00 100644
--- a/plugins/mTextControl/src/services.cpp
+++ b/plugins/mTextControl/src/services.cpp
@@ -43,21 +43,23 @@ struct TextObject
//---------------------------------------------------------------------------
// elper functions
-void MText_InitFormatting0(IFormattedTextDraw *ftd, DWORD options) {
+void MText_InitFormatting0(IFormattedTextDraw *ftd, DWORD options)
+{
LRESULT lResult;
// urls
ftd->getTextService()->TxSendMessage(EM_AUTOURLDETECT, TRUE, 0, &lResult);
}
-void MText_InitFormatting1(TextObject *text) {
+void MText_InitFormatting1(TextObject *text)
+{
// bbcodes
bbCodeParse(text->ftd);
// smilies
-// HWND hwnd = (HWND)CallServiceSync(MS_TEXT_CREATEPROXY, (WPARAM)text, 0);
+ // HWND hwnd = (HWND)CallServiceSync(MS_TEXT_CREATEPROXY, (WPARAM)text, 0);
HWND hwnd = CreateProxyWindow(text->ftd->getTextService());
- SMADD_RICHEDIT3 sm = {0};
+ SMADD_RICHEDIT3 sm = { 0 };
sm.cbSize = sizeof(sm);
sm.hwndRichEditControl = hwnd;
sm.rangeToReplace = 0;
@@ -66,18 +68,18 @@ void MText_InitFormatting1(TextObject *text) {
CallService(MS_SMILEYADD_REPLACESMILEYS, RGB(0xff, 0xff, 0xff), (LPARAM)&sm);
DestroyWindow(hwnd);
-// text->ftd->getTextService()->TxSendMessage(EM_SETSEL, 0, -1, &lResult);
-/*
- // rtl stuff
- PARAFORMAT2 pf2;
- pf2.cbSize = sizeof(pf2);
- pf2.dwMask = PFM_ALIGNMENT|PFM_RTLPARA;
- pf2.wEffects = PFE_RTLPARA;
- pf2.wAlignment = PFA_RIGHT;
- text->ftd->getTextService()->TxSendMessage(EM_SETSEL, 0, -1, &lResult);
- text->ftd->getTextService()->TxSendMessage(EM_SETPARAFORMAT, 0, (LPARAM)&pf2, &lResult);
- text->ftd->getTextService()->TxSendMessage(EM_SETSEL, 0, 0, &lResult);
-*/
+ // text->ftd->getTextService()->TxSendMessage(EM_SETSEL, 0, -1, &lResult);
+ /*
+ // rtl stuff
+ PARAFORMAT2 pf2;
+ pf2.cbSize = sizeof(pf2);
+ pf2.dwMask = PFM_ALIGNMENT|PFM_RTLPARA;
+ pf2.wEffects = PFE_RTLPARA;
+ pf2.wAlignment = PFA_RIGHT;
+ text->ftd->getTextService()->TxSendMessage(EM_SETSEL, 0, -1, &lResult);
+ text->ftd->getTextService()->TxSendMessage(EM_SETPARAFORMAT, 0, (LPARAM)&pf2, &lResult);
+ text->ftd->getTextService()->TxSendMessage(EM_SETSEL, 0, 0, &lResult);
+ */
}
//---------------------------------------------------------------------------
@@ -118,8 +120,9 @@ INT_PTR MText_Register(WPARAM wParam, LPARAM lParam)
//---------------------------------------------------------------------------
// allocate text object (unicode)
-HANDLE DLL_CALLCONV
-MTI_MTextCreateW (HANDLE userHandle, WCHAR *text) {
+HANDLE DLL_CALLCONV
+MTI_MTextCreateW(HANDLE userHandle, WCHAR *text)
+{
TextObject *result = new TextObject;
result->options = TextUserGetOptions(userHandle);
@@ -135,18 +138,20 @@ MTI_MTextCreateW (HANDLE userHandle, WCHAR *text) {
}
-INT_PTR MText_CreateW(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_CreateW(WPARAM wParam, LPARAM lParam)
+{
//HANDLE userHandle = (HANDLE)wParam;
//WCHAR *wtext = (WCHAR *)lParam;
- return (INT_PTR)(HANDLE)MTI_MTextCreateW ((HANDLE)wParam, (WCHAR *)lParam);
+ return (INT_PTR)(HANDLE)MTI_MTextCreateW((HANDLE)wParam, (WCHAR *)lParam);
}
//---------------------------------------------------------------------------
// allocate text object (advanced)
-HANDLE DLL_CALLCONV
-MTI_MTextCreateEx (HANDLE userHandle, MCONTACT hContact, void *text, DWORD flags) {
+HANDLE DLL_CALLCONV
+MTI_MTextCreateEx(HANDLE userHandle, MCONTACT hContact, void *text, DWORD flags)
+{
TextObject *result = new TextObject;
result->options = TextUserGetOptions(userHandle);
result->ftd = new CFormattedTextDraw;
@@ -161,47 +166,51 @@ MTI_MTextCreateEx (HANDLE userHandle, MCONTACT hContact, void *text, DWORD flags
return 0;
}
-INT_PTR MText_CreateEx(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_CreateEx(WPARAM wParam, LPARAM lParam)
+{
HANDLE userHandle = (HANDLE)wParam;
MTEXTCREATE *textCreate = (MTEXTCREATE *)lParam;
- MTI_MTextCreateEx (userHandle, textCreate->hContact, textCreate->text, textCreate->flags);
+ MTI_MTextCreateEx(userHandle, textCreate->hContact, textCreate->text, textCreate->flags);
return 0;
}
//---------------------------------------------------------------------------
// measure text object
-int DLL_CALLCONV
-MTI_MTextMeasure (HDC dc, SIZE *sz, HANDLE text) {
+int DLL_CALLCONV
+MTI_MTextMeasure(HDC dc, SIZE *sz, HANDLE text)
+{
if (!text) return 0;
- long lWidth=sz->cx, lHeight=sz->cy;
+ long lWidth = sz->cx, lHeight = sz->cy;
((TextObject *)text)->ftd->get_NaturalSize(dc, &lWidth, &lHeight);
sz->cx = lWidth;
sz->cy = lHeight;
-// FancyMeasure(((TextObject *)text)->fancy, displayInfo);
+ // FancyMeasure(((TextObject *)text)->fancy, displayInfo);
return 0;
}
-INT_PTR MText_Measure(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_Measure(WPARAM wParam, LPARAM lParam)
+{
LPMTEXTDISPLAY displayInfo = (LPMTEXTDISPLAY)wParam;
if (!displayInfo) return 0;
if (!(TextObject *)displayInfo->text) return 0;
- MTI_MTextMeasure (displayInfo->dc, &displayInfo->sz, displayInfo->text);
+ MTI_MTextMeasure(displayInfo->dc, &displayInfo->sz, displayInfo->text);
return 0;
}
-int DLL_CALLCONV
+int DLL_CALLCONV
//---------------------------------------------------------------------------
// display text object
-MTI_MTextDisplay (HDC dc, POINT pos, SIZE sz, HANDLE text) {
+MTI_MTextDisplay(HDC dc, POINT pos, SIZE sz, HANDLE text)
+{
if (!text) return 0;
COLORREF cl = GetTextColor(dc);
-// if (GetTextColor(dc)&0xffffff != 0)
+ // if (GetTextColor(dc)&0xffffff != 0)
{
LRESULT lResult;
- CHARFORMAT cf = {0};
+ CHARFORMAT cf = { 0 };
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_COLOR;
cf.crTextColor = cl;
@@ -210,7 +219,7 @@ MTI_MTextDisplay (HDC dc, POINT pos, SIZE sz, HANDLE text) {
SetBkMode(dc, TRANSPARENT);
- long lWidth=sz.cx, lHeight;
+ long lWidth = sz.cx, lHeight;
((TextObject *)text)->ftd->get_NaturalSize(dc, &lWidth, &lHeight);
RECT rt;
rt.left = pos.x;
@@ -222,36 +231,40 @@ MTI_MTextDisplay (HDC dc, POINT pos, SIZE sz, HANDLE text) {
return 0;
}
-INT_PTR MText_Display(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_Display(WPARAM wParam, LPARAM lParam)
+{
LPMTEXTDISPLAY displayInfo = (LPMTEXTDISPLAY)wParam;
if (!displayInfo) return 0;
if (!displayInfo->text) return 0;
- MTI_MTextDisplay (displayInfo->dc, displayInfo->pos, displayInfo->sz, displayInfo->text);
+ MTI_MTextDisplay(displayInfo->dc, displayInfo->pos, displayInfo->sz, displayInfo->text);
return 0;
}
-int DLL_CALLCONV
+int DLL_CALLCONV
//---------------------------------------------------------------------------
// set parent window for text object (this is required for mouse handling, etc)
-MTI_MTextSetParent (HANDLE text, HWND hwnd, RECT rect) {
+MTI_MTextSetParent(HANDLE text, HWND hwnd, RECT rect)
+{
if (!text) return 0;
((TextObject *)text)->ftd->setParentWnd(hwnd, rect);
return 0;
}
-INT_PTR MText_SetParent(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_SetParent(WPARAM wParam, LPARAM lParam)
+{
LPMTEXTSETPARENT info = (LPMTEXTSETPARENT)wParam;
//TextObject *text = (TextObject *)info->text;
if (!info) return 0;
if (!info->text) return 0;
- MTI_MTextSetParent (info->text, info->hwnd, info->rc);
+ MTI_MTextSetParent(info->text, info->hwnd, info->rc);
return 0;
}
//---------------------------------------------------------------------------
// send message to an object
-int DLL_CALLCONV
-MTI_MTextSendMessage (HWND hwnd, HANDLE text, UINT msg, WPARAM wParam, LPARAM lParam) {
+int DLL_CALLCONV
+MTI_MTextSendMessage(HWND hwnd, HANDLE text, UINT msg, WPARAM wParam, LPARAM lParam)
+{
LRESULT lResult;
if (!text) return 0;
((TextObject *)text)->ftd->getTextService()->TxSendMessage(msg, wParam, lParam, &lResult);
@@ -265,37 +278,42 @@ MTI_MTextSendMessage (HWND hwnd, HANDLE text, UINT msg, WPARAM wParam, LPARAM lP
return lResult;
}
-INT_PTR MText_SendMessage(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_SendMessage(WPARAM wParam, LPARAM lParam)
+{
LPMTEXTMESSAGE message = (LPMTEXTMESSAGE)wParam;
TextObject *text = (TextObject *)message->text;
if (!message->text) return 0;
- return (INT_PTR)MTI_MTextSendMessage (message->hwnd, message->text, message->msg, message->wParam, message->lParam);
+ return (INT_PTR)MTI_MTextSendMessage(message->hwnd, message->text, message->msg, message->wParam, message->lParam);
}
//---------------------------------------------------------------------------
// create a proxy window
-HWND DLL_CALLCONV
-MTI_MTextCreateProxy (HANDLE text) {
+HWND DLL_CALLCONV
+MTI_MTextCreateProxy(HANDLE text)
+{
if (!text) return 0;
return CreateProxyWindow(((TextObject *)text)->ftd->getTextService());
}
-INT_PTR MText_CreateProxy(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_CreateProxy(WPARAM wParam, LPARAM lParam)
+{
if (!wParam) return 0;
return (INT_PTR)MTI_MTextCreateProxy((HANDLE)wParam);
}
-int DLL_CALLCONV
+int DLL_CALLCONV
//---------------------------------------------------------------------------
// destroy text object
-MTI_MTextDestroy (HANDLE text) {
+MTI_MTextDestroy(HANDLE text)
+{
//HANDLE textHandle = (HANDLE)wParam;
//TextObject *text = (TextObject *)textHandle;
if (text) delete (TextObject *)text;
return 0;
}
-INT_PTR MText_Destroy(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_Destroy(WPARAM wParam, LPARAM lParam)
+{
HANDLE textHandle = (HANDLE)wParam;
TextObject *text = (TextObject *)textHandle;
if (text) delete text;
@@ -304,21 +322,22 @@ INT_PTR MText_Destroy(WPARAM wParam, LPARAM lParam) {
//---------------------------------------------------------------------------
// populate the interface
-INT_PTR MText_GetInterface(WPARAM wParam, LPARAM lParam) {
+INT_PTR MText_GetInterface(WPARAM wParam, LPARAM lParam)
+{
MTEXT_INTERFACE *MText = (MTEXT_INTERFACE *)lParam;
- if ( MText == NULL )
+ if (MText == NULL)
return CALLSERVICE_NOTFOUND;
- MText->version = pluginInfoEx.version;
- MText->Register = MTI_TextUserAdd;
- MText->Create = MTI_MTextCreateW;
- MText->CreateEx = MTI_MTextCreateEx;
- MText->Measure = MTI_MTextMeasure;
- MText->Display = MTI_MTextDisplay;
- MText->SetParent = MTI_MTextSetParent;
- MText->SendMsg = MTI_MTextSendMessage;
+ MText->version = pluginInfoEx.version;
+ MText->Register = MTI_TextUserAdd;
+ MText->Create = MTI_MTextCreateW;
+ MText->CreateEx = MTI_MTextCreateEx;
+ MText->Measure = MTI_MTextMeasure;
+ MText->Display = MTI_MTextDisplay;
+ MText->SetParent = MTI_MTextSetParent;
+ MText->SendMsg = MTI_MTextSendMessage;
MText->CreateProxy = MTI_MTextCreateProxy;
- MText->Destroy = MTI_MTextDestroy;
+ MText->Destroy = MTI_MTextDestroy;
return S_OK;
}
diff --git a/plugins/mTextControl/src/textusers.cpp b/plugins/mTextControl/src/textusers.cpp
index 96dad7d8c6..a5a5e89897 100644
--- a/plugins/mTextControl/src/textusers.cpp
+++ b/plugins/mTextControl/src/textusers.cpp
@@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
HANDLE htuDefault = 0;
-TextUser *textUserFirst=0;
-TextUser *textUserLast=0;
+TextUser *textUserFirst = 0;
+TextUser *textUserLast = 0;
void LoadTextUsers()
{
@@ -31,34 +31,30 @@ void LoadTextUsers()
void UnloadTextUsers()
{
- while (textUserFirst)
- {
- delete [] textUserFirst->name;
+ while (textUserFirst) {
+ delete[] textUserFirst->name;
TextUser *next = textUserFirst->next;
- delete [] textUserFirst;
+ delete[] textUserFirst;
textUserFirst = next;
}
}
-HANDLE DLL_CALLCONV
-MTI_TextUserAdd(const char *userTitle, DWORD options)
+HANDLE DLL_CALLCONV MTI_TextUserAdd(const char *userTitle, DWORD options)
{
TextUser *textUserNew = new TextUser;
- textUserNew->name = new char [mir_strlen(userTitle)+1];
+ textUserNew->name = new char[mir_strlen(userTitle) + 1];
mir_strcpy(textUserNew->name, userTitle);
textUserNew->options =
(db_get_dw(0, MODULNAME, userTitle, options)&MTEXT_FANCY_MASK) | (textUserNew->options&MTEXT_SYSTEM_MASK);
db_set_dw(0, MODULNAME, userTitle, textUserNew->options);
textUserNew->prev = textUserLast;
textUserNew->next = 0;
- if (textUserLast)
- {
+ if (textUserLast) {
textUserLast->next = textUserNew;
textUserLast = textUserNew;
- } else
- {
- textUserFirst = textUserLast = textUserNew;
}
+ else textUserFirst = textUserLast = textUserNew;
+
return (HANDLE)textUserNew;
}
@@ -84,5 +80,5 @@ void TextUsersReset()
{
for (TextUser *textUser = textUserFirst; textUser; textUser = textUser->next)
textUser->options =
- (db_get_dw(0, MODULNAME, textUser->name, 0)&MTEXT_FANCY_MASK) | (textUser->options&MTEXT_SYSTEM_MASK);
+ (db_get_dw(0, MODULNAME, textUser->name, 0)&MTEXT_FANCY_MASK) | (textUser->options&MTEXT_SYSTEM_MASK);
}