Explorar el Código

use rtf control to pre process rtf before we try and try, was finding newer versio of word would add data that our draw routine could not handle

sabrogden hace 8 años
padre
commit
e7b3e532c1
Se han modificado 2 ficheros con 16 adiciones y 23 borrados
  1. 15 23
      QListCtrl.cpp
  2. 1 0
      QListCtrl.h

+ 15 - 23
QListCtrl.cpp

@@ -550,36 +550,28 @@ BOOL CQListCtrl::DrawRtfText(int nItem, CRect &crRect, CDC *pDC)
 		m_pFormatter->Create();
 	}
 
+	if (m_rtfFormater.m_hWnd == NULL)
+	{
+		m_rtfFormater.Create(_T(""), _T(""), WS_CHILD | WS_VSCROLL |
+			WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_NOHIDESEL |
+			ES_AUTOHSCROLL, CRect(0, 0, 0, 0), this, -1);
+	}
+
 	if(m_pFormatter)
 	{
 	   char *pData = (char*)GlobalLock(pThumbnail->m_hgData);
 	   if(pData)
-	   {
-		   CStringA CStringData((char*)pData);		   
-
-		   /*CFile file;
-		   if (file.Open(_T("c:\\temp\\rtf.txt"), CFile::modeRead))
-		   {
-			   int len = file.GetLength();
-			   file.Read(CStringData.GetBuffer(len), len);
-			   CStringData.ReleaseBuffer();
-		   }*/
-
-		   //newer version of word adds these to the rtf, i tracked these sections down, remove them and it draws correcty, might find more later
-		   if (g_Opt.m_cleanRTFBeforeDrawing)
-		   {
-			   RemoveRTFSection(CStringData, "{\\fonttbl");
-			   RemoveRTFSection(CStringData, "{\\stylesheet");
-		   }
-
-		   CComBSTR bStr(CStringData);
-		   
+	   {		   
+		   //somehow ms word places crazy rtf text onto the clipboard and our draw routine doesn't handle that
+		   //pass the rtf text into a richtext control and get it out and the contorl will clean  the rtf so our routine can draw it
+		   m_rtfFormater.SetRTF((char*)pData);
+		   CString betterRTF = m_rtfFormater.GetRTF();		   
+
+		   CComBSTR bStr(betterRTF);		   
 		   m_pFormatter->put_RTFText(bStr);
 		   
 		   m_pFormatter->Draw(pDC->m_hDC, crRect);
 
-		   GlobalUnlock(pThumbnail->m_hgData);
-
 		   bRet = TRUE;
 	   }
 	}
@@ -781,7 +773,7 @@ int CQListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
 	else
 	{
 		EnableToolTips(FALSE);
-	}
+	}	
 
 	m_pToolTip = new CToolTipEx;
 	m_pToolTip->Create(this);

+ 1 - 0
QListCtrl.h

@@ -190,6 +190,7 @@ protected:
 	CString m_searchText;
 	BOOL m_showIfClipWasPasted;
 	CAccels *m_pToolTipActions;
+	CRichEditCtrlEx m_rtfFormater;
 
 
 	// Generated message map functions