Explorar el Código

changes things to compile in 6.0

Change Process Paste to put ClipboardIgnore on instead of app variable to ignore

Changed Accell class to use a map


git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@33 595ec19a-5cb4-439b-94a8-42fb3063c22c
sabrogden hace 22 años
padre
commit
6cc5c20c90
Se han modificado 12 ficheros con 69 adiciones y 140 borrados
  1. 4 4
      CP_Main.cpp
  2. 1 1
      CP_Main.h
  3. 2 2
      CopyProperties.cpp
  4. 3 2
      InternetUpdate.cpp
  5. 0 4
      MainTable.cpp
  6. 25 84
      Misc.cpp
  7. 5 12
      Misc.h
  8. 11 11
      ProcessCopy.cpp
  9. 11 14
      ProcessPaste.cpp
  10. 1 1
      ProcessPaste.h
  11. 5 4
      QListCtrl.cpp
  12. 1 1
      QPasteWnd.cpp

+ 4 - 4
CP_Main.cpp

@@ -58,7 +58,7 @@ CCP_MainApp::~CCP_MainApp()
 
 BOOL CCP_MainApp::InitInstance()
 {
-	LOG(FUNC);
+	LOG("InitInstance");
 
 	AfxEnableControlContainer();
 
@@ -72,7 +72,7 @@ BOOL CCP_MainApp::InitInstance()
 
 		return TRUE;
 	}
-
+	
 	m_cfIgnoreClipboard = ::RegisterClipboardFormat("Clipboard Viewer Ignore");
 
 	if(CheckDBExists(CGetSetOptions::GetDBPath()) == FALSE)
@@ -252,7 +252,7 @@ CClipTypes* pTypes = new CClipTypes;
 		e->Delete();
 	}
 
-	if( pTypes->GetCount() <= 0 )
+	if( pTypes->GetSize() <= 0 )
 	{
 		pTypes->Add(CF_TEXT);
 		pTypes->Add(RegisterClipboardFormat(CF_RTF));
@@ -367,7 +367,7 @@ void CCP_MainApp::Delayed_RemoveOldEntries( UINT delay )
 
 int CCP_MainApp::ExitInstance() 
 {
-	LOG(FUNC);
+	LOG("ExitInstance");
 	if(CGetSetOptions::GetCompactAndRepairOnExit())
 		CompactDatabase();
 	

+ 1 - 1
CP_Main.h

@@ -61,7 +61,7 @@ public:
 	bool ReleaseFocus(); // activate the target only if we are the active window
 	CString GetTargetName() { return GetWndText( m_hTargetWnd ); }
 	void SendPaste(); // Activates the Target and sends Ctrl-V
-
+	
 	CLIPFORMAT m_cfIgnoreClipboard; // used by CClip::LoadFromClipboard
 
 // CopyThread and ClipViewer (Copy and Paste Management)

+ 2 - 2
CopyProperties.cpp

@@ -329,7 +329,7 @@ CTokenizer tokenizer(text,delims);
 CClip clip;
 int len;
 long lDate = (long) CTime::GetCurrentTime().GetTime();
-int count = tokens.GetCount();
+int count = tokens.GetSize();
 
 	for( int i = 0; i < count; i++ )
 	{
@@ -349,7 +349,7 @@ int count = tokens.GetCount();
 		::MessageBox( m_hWnd, "No new tokens found by parsing", "Parse Failed", MB_OK|MB_ICONINFORMATION );
 	else
 	{
-		::MessageBox( m_hWnd, StrF("Successfully parsed %d tokens.", tokens.GetCount()), "Parse Completed", MB_OK|MB_ICONINFORMATION );
+		::MessageBox( m_hWnd, StrF("Successfully parsed %d tokens.", tokens.GetSize()), "Parse Completed", MB_OK|MB_ICONINFORMATION );
 		theApp.RefreshView();
 	}
 }

+ 3 - 2
InternetUpdate.cpp

@@ -139,12 +139,13 @@ long CInternetUpdate::GetRunningVersion()
     VS_FIXEDFILEINFO *lpFFI;
     long ver;
 
-    dwSize = GetFileVersionInfoSize(csFileName, &dwHandle);
+    dwSize = GetFileVersionInfoSize(csFileName.GetBuffer(csFileName.GetLength()), &dwHandle);
     if(dwSize != 0)
     {
+		csFileName.ReleaseBuffer();
 		if((lpData=(unsigned char *)malloc(dwSize)) != NULL)
 		{
-			if(GetFileVersionInfo(csFileName, dwHandle, dwSize, lpData) != 0)
+			if(GetFileVersionInfo(csFileName.GetBuffer(csFileName.GetLength()), dwHandle, dwSize, lpData) != 0)
 			{
 				if(VerQueryValue(lpData, "\\", (LPVOID*)&lpFFI, &iBuffSize) != 0)
 				{

+ 0 - 4
MainTable.cpp

@@ -122,8 +122,6 @@ void CMainTable::LoadAcceleratorKeys( CAccels& accels )
 	{
 		recset.Open("SELECT * FROM Main WHERE lShortCut > 0");
 		
-		accels.StartBuildingTable();
-
 		CAccel a;
 		while(!recset.IsEOF())
 		{
@@ -133,8 +131,6 @@ void CMainTable::LoadAcceleratorKeys( CAccels& accels )
 
 			recset.MoveNext();
 		}
-
-		accels.FinishBuildingTable();
 	}
 	catch(CDaoException* e)
 	{

+ 25 - 84
Misc.cpp

@@ -72,7 +72,7 @@ void SetThreadName(DWORD dwThreadID, LPCTSTR szThreadName)
 
 CString StrF(const char * pszFormat, ...)
 {
-	ASSERT( AtlIsValidString( pszFormat ) );
+	ASSERT( AfxIsValidString( pszFormat ) );
 CString str;
 	va_list argList;
 	va_start( argList, pszFormat );
@@ -999,7 +999,7 @@ bool CHotKey::Unregister()
 		}
 		else
 		{
-			LOG(FUNC "FAILED!");
+			LOG("Unregister" "FAILED!");
 			ASSERT(0);
 		}
 	}
@@ -1022,7 +1022,7 @@ CHotKeys::CHotKeys() : m_hWnd(NULL) {}
 CHotKeys::~CHotKeys()
 {
 CHotKey* pHotKey;
-int count = GetCount();
+int count = GetSize();
 	for( int i=0; i < count; i++ )
 	{
 		pHotKey = GetAt(i);
@@ -1033,7 +1033,7 @@ int count = GetCount();
 
 int CHotKeys::Find( CHotKey* pHotKey )
 {
-int count = GetCount();
+int count = GetSize();
 	for( int i=0; i < count; i++ )
 	{
 		if( pHotKey == GetAt(i) )
@@ -1055,14 +1055,14 @@ int i = Find(pHotKey);
 
 void CHotKeys::LoadAllKeys()
 {
-int count = GetCount();
+int count = GetSize();
 	for( int i=0; i < count; i++ )
 		GetAt(i)->LoadKey();
 }
 
 void CHotKeys::SaveAllKeys()
 {
-int count = GetCount();
+int count = GetSize();
 	for( int i=0; i < count; i++ )
 		GetAt(i)->SaveKey();
 }
@@ -1071,7 +1071,7 @@ void CHotKeys::RegisterAll( bool bMsgOnError )
 {
 CString str;
 CHotKey* pHotKey;
-int count = GetCount();
+int count = GetSize();
 	for( int i=0; i < count; i++ )
 	{
 		pHotKey = GetAt(i);
@@ -1090,7 +1090,7 @@ void CHotKeys::UnregisterAll( bool bMsgOnError )
 {
 CString str;
 CHotKey* pHotKey;
-int count = GetCount();
+int count = GetSize();
 	for( int i=0; i < count; i++ )
 	{
 		pHotKey = GetAt(i);
@@ -1107,7 +1107,7 @@ int count = GetCount();
 
 void CHotKeys::GetKeys( ARRAY& keys )
 {
-int count = GetCount();
+int count = GetSize();
 	keys.SetSize( count );
 	for( int i=0; i < count; i++ )
 		keys[i] = GetAt(i)->GetKey();
@@ -1116,8 +1116,8 @@ int count = GetCount();
 // caution! this alters hotkeys based upon corresponding indexes
 void CHotKeys::SetKeys( ARRAY& keys, bool bSave )
 {
-int count = GetCount();
-	ASSERT( count == keys.GetCount() );
+int count = GetSize();
+	ASSERT( count == keys.GetSize() );
 	for( int i=0; i < count; i++ )
 		GetAt(i)->SetKey( keys[i], bSave );
 }
@@ -1126,7 +1126,7 @@ bool CHotKeys::FindFirstConflict( ARRAY& keys, int* pX, int* pY )
 {
 bool bConflict = false;
 int i, j;
-int count = keys.GetCount();
+int count = keys.GetSize();
 DWORD key;
 	for( i=0; i < count && !bConflict; i++ )
 	{
@@ -1394,91 +1394,32 @@ CAccels::CAccels()
 
 void CAccels::AddAccel( CAccel& a )
 {
-	Add( a );
-}
-
-void CAccels::StartBuildingTable( bool bBigAndFast, int size )
-{
-	SetSize(0);
-
-	// m_Index is used as a fast hash table based upon the 1-byte vkey
-	if( bBigAndFast )
-		m_Index.SetSize( 256 );
-	else
-		m_Index.SetSize( 0 );
-
-int count = m_Index.GetCount();
-	for( int i=0; i < count; i++ )
-		m_Index[i] = NULL;
-}
-
-void CAccels::FinishBuildingTable()
-{
-int count = GetCount();
-	if( count <= 0 )
-		return;
-	// sort by key
-	qsort( GetData(), count, sizeof(CAccel), CompareAccel );
-
-CAccel* pAccel;
-int index;
-int idxCount = m_Index.GetCount();
-	if( idxCount != 256 )
-		return;
-	// setup m_Index hash table with each CAccel
-	for( int i=0; i < count; i++ )
-	{
-		pAccel = &GetAt(i);
-		index = ACCEL_VKEY( pAccel->Key );
-		// place the first accel for this vkey in the index
-		if( m_Index[index] == NULL )
-			m_Index[index] = pAccel;
-	}
+	m_Map.SetAt(a.Key, a.Cmd);
+	
 }
 
-CAccel* CAccels::OnMsg( MSG* pMsg )
+bool CAccels::OnMsg( MSG* pMsg, DWORD &dID)
 {
 	// bit 30 (0x40000000) is 1 if this is NOT the first msg of the key
 	//  i.e. auto-repeat may cause multiple msgs of the same key
 	if( (pMsg->lParam & 0x40000000) ||
 	    (pMsg->message != WM_KEYDOWN &&
 	     pMsg->message != WM_SYSKEYDOWN) )
-	{	return NULL; }
-
-int count = GetCount();
-	if( !pMsg || count <= 0 )
-		return NULL;
-
-BYTE vkey = LOBYTE(pMsg->wParam);
-BYTE mod  = GetKeyStateModifiers();
-DWORD key = ACCEL_MAKEKEY( vkey, mod );
-CAccel* pAccel;
-
-	// if we don't have an appropriately sized Index, do a binary search
-int idxCount = m_Index.GetCount();
-	if( idxCount != 256 )
-	{
-	CAccel a(key,0);
-		return (CAccel*) bsearch( &a, GetData(), count, sizeof(CAccel), CompareAccel );
+	{	
+		return NULL; 
 	}
-	// else we should have a valid m_Index hash table to use
-
-	pAccel = m_Index[ vkey ];
 
-	if( pAccel == NULL )
+	if( !pMsg || m_Map.GetCount() <= 0 )
 		return NULL;
 
-CAccel* pLast = &GetAt(count-1);
-	// for each CAccel that matches vkey
-    while( vkey == ACCEL_VKEY(pAccel->Key) && pAccel <= pLast )
-	{
-		// if modifiers are also the same, then this is the key we are looking for
-		if( mod == ACCEL_MOD(pAccel->Key) )
-			return pAccel;
-		pAccel++;
-	}
+	BYTE vkey = LOBYTE(pMsg->wParam);
+	BYTE mod  = GetKeyStateModifiers();
+	DWORD key = ACCEL_MAKEKEY( vkey, mod );
+
+	if(m_Map.Lookup(key, dID))
+		return true;;
 
-	return NULL;
+	return false;
 }
 
 BYTE GetKeyStateModifiers()

+ 5 - 12
Misc.h

@@ -278,7 +278,7 @@ public:
 	CHotKeys - Manages system-wide hotkeys
 \*------------------------------------------------------------------*/
 
-class CHotKeys : public CArray<CHotKey*>
+class CHotKeys : public CArray<CHotKey*,CHotKey*>
 {
 public:
 	HWND	m_hWnd;
@@ -330,26 +330,19 @@ public:
 /*------------------------------------------------------------------*\
 	CAccels - Manages a set of CAccel
 \*------------------------------------------------------------------*/
-class CAccels : public CArray<CAccel>
+class CAccels
 {
 public:
-	CArray<CAccel*>	m_Index;
-
 	CAccels();
 
-	void Clear() { SetSize(0); }
-	void AddAccel( CAccel& a );
+	CMap<DWORD, DWORD, DWORD, DWORD> m_Map;
 
-	// "bBigAndFast" means:
-	// - big: about 1024 bytes larger
-	// - fast: approx. constant speed lookup versus binary search
-	void StartBuildingTable( bool bBigAndFast = true, int size = -1 );
-	void FinishBuildingTable();
+	void AddAccel( CAccel& a );
 
 	// handles a key's first WM_KEYDOWN or WM_SYSKEYDOWN message.
 	// it uses GetKeyState to test for modifiers.
 	// returns a pointer to the internal CAccel if it matches the given key or NULL
-	CAccel* OnMsg( MSG* pMsg );
+	bool OnMsg( MSG* pMsg , DWORD &dID );
 };
 
 // returns a BYTE representing the current GetKeyState modifiers:

+ 11 - 11
ProcessCopy.cpp

@@ -81,7 +81,7 @@ HGLOBAL COleDataObjectEx::GetGlobalData(CLIPFORMAT cfFormat, LPFORMATETC lpForma
 CClipFormat* CClipFormats::FindFormat( UINT cfType )
 {
 CClipFormat* pCF;
-int count = GetCount();
+int count = GetSize();
 	for( int i=0; i < count; i++ )
 	{
 		pCF = &GetAt(i);
@@ -101,7 +101,7 @@ CClip::CClip() : m_ID(0), m_lTotalCopySize(0)
 
 CClip::~CClip()
 {
-int count = m_Formats.GetCount();
+int count = m_Formats.GetSize();
 	// in proper handling, m_Formats should be empty
 	ASSERT( count == 0 );
 	EmptyFormats();
@@ -119,7 +119,7 @@ void CClip::Clear()
 void CClip::EmptyFormats()
 {
 	// free global memory in m_Formats
-	for( int i = m_Formats.GetCount()-1; i >= 0; i-- )
+	for( int i = m_Formats.GetSize()-1; i >= 0; i-- )
 	{
 		m_Formats[i].Free();
 		m_Formats.RemoveAt( i );
@@ -175,7 +175,7 @@ CClipTypes* pTypes = pClipTypes;
 	g_bCopyingClipboard = true;
 
 	// m_Formats should be empty when this is called.
-	ASSERT( m_Formats.GetCount() == 0 );
+	ASSERT( m_Formats.GetSize() == 0 );
 
 	// If the data is supposed to be private, then return
 	if( ::IsClipboardFormatAvailable( theApp.m_cfIgnoreClipboard ) )
@@ -192,7 +192,7 @@ CClipTypes* pTypes = pClipTypes;
 
 	// if no types were given, get only the first (most important) type.
 	//  (subsequent types could be synthetic due to automatic type conversions)
-	if( pTypes == NULL || pTypes->GetCount() == 0 )
+	if( pTypes == NULL || pTypes->GetSize() == 0 )
 	{
 		ASSERT(0); // this feature is not currently used... it is an error if it is.
 
@@ -223,7 +223,7 @@ bool bIsDescSet = false;
 	// Get global data for each supported type on the clipboard
 UINT nSize;
 CClipFormat cf;
-int numTypes = pTypes->GetCount();
+int numTypes = pTypes->GetSize();
 	for(int i = 0; i < numTypes; i++)
 	{
 		cf.m_cfType = pTypes->GetAt(i);
@@ -303,7 +303,7 @@ ULONG ulBufLen = GlobalSize(hgData);
 
 bool CClip::SetDescFromType()
 {
-	if( m_Formats.GetCount() <= 0 )
+	if( m_Formats.GetSize() <= 0 )
 		return false;
 	m_Desc = GetFormatName( m_Formats[0].m_cfType );
 	return m_Desc.GetLength() > 0;
@@ -335,7 +335,7 @@ bool bResult;
 	bResult = AddToMainTable() && AddToDataTable();
 
 	// should be emptied by AddToDataTable
-	ASSERT( m_Formats.GetCount() == 0 );
+	ASSERT( m_Formats.GetSize() == 0 );
 
 	return bResult;
 }
@@ -393,7 +393,7 @@ CClipFormat* pFormat = NULL;
 			recset.MoveLast();
 			nRecs = recset.GetRecordCount();
 		}
-		nFormats = m_Formats.GetCount();
+		nFormats = m_Formats.GetSize();
 		nRet = nFormats - nRecs;
 		if( nRet != 0 || nRecs == 0 )
 		{	recset.Close();	return nRet; }
@@ -475,7 +475,7 @@ bool CClip::AddToDataTable()
 
 		recset.Open(AFX_DAO_USE_DEFAULT_TYPE, "SELECT * FROM Data" ,NULL);
 
-		for( int i = m_Formats.GetCount()-1; i >= 0 ; i-- )
+		for( int i = m_Formats.GetSize()-1; i >= 0 ; i-- )
 		{
 			pCF = & m_Formats.GetAt(i);
 
@@ -661,7 +661,7 @@ HGLOBAL hGlobal = 0;
 	}
 	CATCHDAO
 
-	return formats.GetCount() > 0;
+	return formats.GetSize() > 0;
 }
 
 void CClip::LoadTypes( long lID, CClipTypes& types )

+ 11 - 14
ProcessPaste.cpp

@@ -57,7 +57,7 @@ BOOL MarkClipAsPasted(long lID)
 // allocate an HGLOBAL of the given Format Type representing these Clip IDs.
 HGLOBAL CClipIDs::Render( UINT cfType )
 {
-int count = GetCount();
+int count = GetSize();
 	if( count <= 0 )
 		return 0;
 	if( count == 1 )
@@ -68,7 +68,7 @@ int count = GetCount();
 
 void CClipIDs::GetTypes( CClipTypes& types )
 {
-int count = GetCount();
+int count = GetSize();
 	types.RemoveAll();
 	if( count > 1 )
 		types.Add( CF_TEXT );
@@ -95,7 +95,7 @@ CString CClipIDs::AggregateText( UINT cfType, char* pSeparator )
 	text.GetBuffer(1000);
 	text.ReleaseBuffer(0);
 
-	int numIDs = GetCount();
+	int numIDs = GetSize();
 	int* pIDs = GetData();
 
 	csSQL.Format("SELECT * FROM Data WHERE strClipBoardFormat = \'%s\' AND lParentID = %%d", GetFormatName(cfType));
@@ -140,7 +140,7 @@ CString CClipIDs::AggregateText( UINT cfType, char* pSeparator )
 /*------------------------------------------------------------------*\
 	COleClipSource
 \*------------------------------------------------------------------*/
-IMPLEMENT_DYNAMIC(COleClipSource, COleDataSource)
+//IMPLEMENT_DYNAMIC(COleClipSource, COleDataSource)
 COleClipSource::COleClipSource()
 {
 }
@@ -154,7 +154,7 @@ BOOL COleClipSource::DoDelayRender()
 	CClipTypes types;
 	m_ClipIDs.GetTypes( types );
 
-	int count = types.GetCount();
+	int count = types.GetSize();
 	for( int i=0; i < count; i++ )
 		DelayRenderData( types[i] );
 
@@ -163,7 +163,7 @@ BOOL COleClipSource::DoDelayRender()
 
 BOOL COleClipSource::DoImmediateRender()
 {
-int count = m_ClipIDs.GetCount();
+int count = m_ClipIDs.GetSize();
 	if( count <= 0 )
 		return 0;
 	if( count == 1 )
@@ -171,7 +171,7 @@ int count = m_ClipIDs.GetCount();
 	CClipFormats formats;
 	CClipFormat* pCF;
 		CClip::LoadFormats( m_ClipIDs[0], formats );
-		count = formats.GetCount(); // reusing "count"
+		count = formats.GetSize(); // reusing "count"
 		for( int i=0; i < count; i++ )
 		{
 			pCF = &formats[i];
@@ -234,16 +234,14 @@ CProcessPaste::~CProcessPaste()
 
 BOOL CProcessPaste::DoPaste()
 {
-bool bOldState;
 	if( m_pOle->DoImmediateRender() )
 	{
 		// if we are pasting a single element, do not handle clipboard data change
 		// (the element is already in the db and its lDate is updated by MarkAsPasted())
-		if( GetClipIDs().GetCount() == 1 )
+		if( GetClipIDs().GetSize() == 1 )
 		{
-			bOldState = theApp.EnableCbCopy( false );
+			m_pOle->CacheGlobalData(theApp.m_cfIgnoreClipboard, NewGlobalP("Ignore", 8));
 			m_pOle->SetClipboard();
-			theApp.EnableCbCopy(bOldState);
 		}
 		else // we are pasting a new aggregate text
 		{
@@ -251,9 +249,8 @@ bool bOldState;
 				m_pOle->SetClipboard();
 			else
 			{
-				bOldState = theApp.EnableCbCopy( false );
+				m_pOle->CacheGlobalData(theApp.m_cfIgnoreClipboard, NewGlobalP("Ignore", 8));
 				m_pOle->SetClipboard();
-				theApp.EnableCbCopy( bOldState );
 			}
 		}
 
@@ -280,7 +277,7 @@ BOOL CProcessPaste::DoDrag()
 void CProcessPaste::MarkAsPasted()
 {
 CClipIDs& clips = GetClipIDs();
-	if( clips.GetCount() == 1 )
+	if( clips.GetSize() == 1 )
 		MarkClipAsPasted( clips.GetAt(0) );
 }
 

+ 1 - 1
ProcessPaste.h

@@ -37,7 +37,7 @@ public:
 \*------------------------------------------------------------------*/
 class COleClipSource : public COleDataSource
 {
-	DECLARE_DYNAMIC(COleClipSource)
+	//DECLARE_DYNAMIC(COleClipSource)
 
 public:
 	CClipIDs	m_ClipIDs;

+ 5 - 4
QListCtrl.cpp

@@ -588,9 +588,10 @@ BOOL CQListCtrl::PreTranslateMessage(MSG* pMsg)
 	//}
 	*/
 
-	CAccel* pAccel = m_Accels.OnMsg( pMsg );
-	if( pAccel && GetParent()->SendMessage(NM_SELECT_DB_ID, pAccel->Cmd, 0) )
-		return TRUE;
+	DWORD dID;
+	if(m_Accels.OnMsg(pMsg, dID))
+		if(GetParent()->SendMessage(NM_SELECT_DB_ID, dID, 0) )
+			return TRUE;
 
 	switch(pMsg->message) 
 	{
@@ -741,7 +742,7 @@ void CQListCtrl::DestroyAndCreateAccelerator(BOOL bCreate)
 	//if(bCreate)
 	//	m_Accelerator = CMainTable::LoadAcceleratorKeys();
 
-	m_Accels.Clear();
+//	m_Accels.Clear();
 
 	if( bCreate )
 		CMainTable::LoadAcceleratorKeys( m_Accels );

+ 1 - 1
QPasteWnd.cpp

@@ -1044,7 +1044,7 @@ NM_LISTVIEW* pLV = (NM_LISTVIEW*)pNMHDR;
 CProcessPaste paste;
 CClipIDs& clips = paste.GetClipIDs();
 	m_lstHeader.GetSelectionItemData( clips );
-	if( clips.GetCount() <= 0 )
+	if( clips.GetSize() <= 0 )
 	{
 		ASSERT(0); // does this ever happen ?????
 		clips.Add( m_lstHeader.GetItemData(pLV->iItem) );