Browse Source

upper/lower/capitalize/sentence special paste support international characters now

Scott Brogden 9 years ago
parent
commit
6f8db8c58f

+ 20 - 14
OleClipSource.cpp

@@ -10,6 +10,8 @@
 #include "Shared\Tokenizer.h"
 #include <random>
 #include "Client.h"
+#include "sqlite\unicode\unistr.h"
+#include "sqlite\unicode\uchar.h"
 
 /*------------------------------------------------------------------*\
 COleClipSource
@@ -187,25 +189,25 @@ void COleClipSource::DoUpperLowerCase(CClip &clip, bool upper)
 		HGLOBAL data = unicodeTextFormat->Data();
 		wchar_t * stringData = (wchar_t *) GlobalLock(data);
 		int size = (int) GlobalSize(data);
-		CString cs(stringData);
-		GlobalUnlock(data);
+		icu::UnicodeString s = stringData;
+		GlobalUnlock(data);		
 
 		//free the old text we are going to replace it below with an upper case version
 		unicodeTextFormat->Free();
 
-		CString val;
+		icu::UnicodeString val;
 		if (upper)
 		{
-			val = cs.MakeUpper();
+			val = s.toUpper();
 		}
 		else
 		{
-			val = cs.MakeLower();
+			val = s.toLower();
 		}
 		
-		long lLen = val.GetLength();
-		HGLOBAL hGlobal = NewGlobalP(val.GetBuffer(), ((lLen+1) * sizeof(wchar_t)));
-		val.ReleaseBuffer();
+		long lLen = val.length();
+		HGLOBAL hGlobal = NewGlobalP((LPVOID)val.getTerminatedBuffer(), ((lLen+1) * sizeof(wchar_t)));
+		val.releaseBuffer();
 
 		unicodeTextFormat->Data(hGlobal);		
 	}
@@ -254,14 +256,16 @@ void COleClipSource::Capitalize(CClip &clip)
 		//free the old text we are going to replace it below with an upper case version
 		unicodeTextFormat->Free();
 
-		CString val = cs.MakeLower();		
+		icu::UnicodeString temp = cs;
+
+		CString val = temp.toLower().getTerminatedBuffer();
 		long len = val.GetLength();
 
 		if (len > 0)
 		{
 			wchar_t * pText = val.GetBuffer();
 			
-			pText[0] = toupper(pText[0]);
+			pText[0] = u_toupper(pText[0]);
 			bool capitalize = false;
 			
 			for (int i = 1; i < len; i++)
@@ -273,7 +277,7 @@ void COleClipSource::Capitalize(CClip &clip)
 				}
 				else if (capitalize)
 				{
-					pText[i] = toupper(item);
+					pText[i] = u_toupper(item);
 					capitalize = false;
 				}
 			}
@@ -349,14 +353,16 @@ void COleClipSource::SentenceCase(CClip &clip)
 		//free the old text we are going to replace it below with an upper case version
 		unicodeTextFormat->Free();
 
-		CString val = cs.MakeLower();
+		icu::UnicodeString temp = cs;
+
+		CString val = temp.toLower().getTerminatedBuffer();
 		long len = val.GetLength();
 
 		if (len > 0)
 		{
 			wchar_t * pText = val.GetBuffer();
 
-			pText[0] = toupper(pText[0]);
+			pText[0] = u_toupper(pText[0]);
 			bool capitalize = false;
 
 			for (int i = 1; i < len; i++)
@@ -370,7 +376,7 @@ void COleClipSource::SentenceCase(CClip &clip)
 				}
 				else if (capitalize && item != ' ')
 				{
-					pText[i] = toupper(item);
+					pText[i] = u_toupper(item);
 					capitalize = false;
 				}
 			}

+ 3 - 3
sqlite/unicode/bytestream.h

@@ -35,9 +35,9 @@
  * \brief C++ API: Interface for writing bytes, and implementation classes.
  */
 
-#include "unicode/utypes.h"
-#include "unicode/uobject.h"
-#include "unicode/std_string.h"
+#include "utypes.h"
+#include "uobject.h"
+#include "std_string.h"
 
 U_NAMESPACE_BEGIN
 

+ 1 - 1
sqlite/unicode/localpointer.h

@@ -36,7 +36,7 @@
  * For details see http://site.icu-project.org/design/cpp/scoped_ptr
  */
 
-#include "unicode/utypes.h"
+#include "utypes.h"
 
 #if U_SHOW_CPLUSPLUS_API
 

+ 2 - 2
sqlite/unicode/platform.h

@@ -19,8 +19,8 @@
 #ifndef _PLATFORM_H
 #define _PLATFORM_H
 
-#include "unicode/uconfig.h"
-#include "unicode/uvernum.h"
+#include "uconfig.h"
+#include "uvernum.h"
 
 /**
  * \file

+ 1 - 1
sqlite/unicode/ptypes.h

@@ -47,7 +47,7 @@
  */
 
 /* Find out if we have stdint.h etc. */
-#include "unicode/platform.h"
+#include "platform.h"
 
 /*===========================================================================*/
 /* Generic data types                                                        */

+ 1 - 1
sqlite/unicode/putil.h

@@ -24,7 +24,7 @@
 #ifndef PUTIL_H
 #define PUTIL_H
 
-#include "unicode/utypes.h"
+#include "utypes.h"
  /**
   * \file
   * \brief C API: Platform Utilities

+ 1 - 1
sqlite/unicode/rep.h

@@ -14,7 +14,7 @@
 #ifndef REP_H
 #define REP_H
 
-#include "unicode/uobject.h"
+#include "uobject.h"
 
 /**
  * \file 

+ 1 - 1
sqlite/unicode/std_string.h

@@ -23,7 +23,7 @@
  *                 header and for related definitions.
  */
 
-#include "unicode/utypes.h"
+#include "utypes.h"
 
 #if U_HAVE_STD_STRING
 

+ 3 - 3
sqlite/unicode/stringpiece.h

@@ -25,9 +25,9 @@
  * \brief C++ API: StringPiece: Read-only byte string wrapper class.
  */
 
-#include "unicode/utypes.h"
-#include "unicode/uobject.h"
-#include "unicode/std_string.h"
+#include "utypes.h"
+#include "uobject.h"
+#include "std_string.h"
 
 // Arghh!  I wish C++ literals were "string".
 

+ 3 - 3
sqlite/unicode/ucasemap.h

@@ -19,9 +19,9 @@
 #ifndef __UCASEMAP_H__
 #define __UCASEMAP_H__
 
-#include "unicode/utypes.h"
-#include "unicode/ustring.h"
-#include "unicode/localpointer.h"
+#include "utypes.h"
+#include "ustring.h"
+#include "localpointer.h"
 
 /**
  * \file

+ 1 - 1
sqlite/unicode/uchar.h

@@ -23,7 +23,7 @@
 #ifndef UCHAR_H
 #define UCHAR_H
 
-#include "unicode/utypes.h"
+#include "utypes.h"
 
 U_CDECL_BEGIN
 

+ 1 - 1
sqlite/unicode/uiter.h

@@ -24,7 +24,7 @@
  * @see UCharIterator
  */
 
-#include "unicode/utypes.h"
+#include "utypes.h"
 
 #if U_SHOW_CPLUSPLUS_API
     U_NAMESPACE_BEGIN

+ 2 - 2
sqlite/unicode/umachine.h

@@ -41,7 +41,7 @@
 /* which are contained in the platform-specific file platform.h             */
 /*==========================================================================*/
 
-#include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
+#include "ptypes.h" /* platform.h is included in ptypes.h */
 
 /*
  * ANSI C headers:
@@ -351,6 +351,6 @@ typedef int32_t UChar32;
  */
 #define U_SENTINEL (-1)
 
-#include "unicode/urename.h"
+#include "urename.h"
 
 #endif

+ 6 - 6
sqlite/unicode/unistr.h

@@ -26,12 +26,12 @@
  * \brief C++ API: Unicode String 
  */
 
-#include "unicode/utypes.h"
-#include "unicode/rep.h"
-#include "unicode/std_string.h"
-#include "unicode/stringpiece.h"
-#include "unicode/bytestream.h"
-#include "unicode/ucasemap.h"
+#include "utypes.h"
+#include "rep.h"
+#include "std_string.h"
+#include "stringpiece.h"
+#include "bytestream.h"
+#include "ucasemap.h"
 
 struct UConverter;          // unicode/ucnv.h
 class  StringThreadTest;

+ 1 - 1
sqlite/unicode/uobject.h

@@ -17,7 +17,7 @@
 #ifndef __UOBJECT_H__
 #define __UOBJECT_H__
 
-#include "unicode/utypes.h"
+#include "utypes.h"
 
 /**
  * \file

+ 3 - 3
sqlite/unicode/urename.h

@@ -27,7 +27,7 @@
  *   - by changing the default setting of U_DISABLE_RENAMING in uconfig.h
  */
 
-#include "unicode/uconfig.h"
+#include "uconfig.h"
 
 #if !U_DISABLE_RENAMING
 
@@ -37,12 +37,12 @@
  */
 
 #ifndef U_ICU_ENTRY_POINT_RENAME
-#include "unicode/umachine.h"
+#include "umachine.h"
 #endif
 
 /* If we still don't have U_ICU_ENTRY_POINT_RENAME use the default. */
 #ifndef U_ICU_ENTRY_POINT_RENAME
-#include "unicode/uvernum.h"
+#include "uvernum.h"
 #endif
 
 /* Error out before the following defines cause very strange and unexpected code breakage */

+ 3 - 3
sqlite/unicode/ustring.h

@@ -16,9 +16,9 @@
 #ifndef USTRING_H
 #define USTRING_H
 
-#include "unicode/utypes.h"
-#include "unicode/putil.h"
-#include "unicode/uiter.h"
+#include "utypes.h"
+#include "putil.h"
+#include "uiter.h"
 
 /**
  * \def UBRK_TYPEDEF_UBREAK_ITERATOR

+ 4 - 4
sqlite/unicode/utf.h

@@ -111,7 +111,7 @@
 #ifndef __UTF_H__
 #define __UTF_H__
 
-#include "unicode/umachine.h"
+#include "umachine.h"
 /* include the utfXX.h after the following definitions */
 
 /* single-code point definitions -------------------------------------------- */
@@ -212,11 +212,11 @@
 
 #if !U_NO_DEFAULT_INCLUDE_UTF_HEADERS
 
-#include "unicode/utf8.h"
-#include "unicode/utf16.h"
+#include "utf8.h"
+#include "utf16.h"
 
 /* utf_old.h contains deprecated, pre-ICU 2.4 definitions */
-#include "unicode/utf_old.h"
+#include "utf_old.h"
 
 #endif  /* !U_NO_DEFAULT_INCLUDE_UTF_HEADERS */
 

+ 2 - 2
sqlite/unicode/utf16.h

@@ -32,9 +32,9 @@
 #ifndef __UTF16_H__
 #define __UTF16_H__
 
-#include "unicode/umachine.h"
+#include "umachine.h"
 #ifndef __UTF_H__
-#   include "unicode/utf.h"
+#   include "utf.h"
 #endif
 
 /* single-code point definitions -------------------------------------------- */

+ 2 - 2
sqlite/unicode/utf8.h

@@ -32,9 +32,9 @@
 #ifndef __UTF8_H__
 #define __UTF8_H__
 
-#include "unicode/umachine.h"
+#include "umachine.h"
 #ifndef __UTF_H__
-#   include "unicode/utf.h"
+#   include "utf.h"
 #endif
 
 /* internal definitions ----------------------------------------------------- */

+ 3 - 3
sqlite/unicode/utf_old.h

@@ -145,9 +145,9 @@
 
 #ifndef U_HIDE_DEPRECATED_API
 
-#include "unicode/utf.h"
-#include "unicode/utf8.h"
-#include "unicode/utf16.h"
+#include "utf.h"
+#include "utf8.h"
+#include "utf16.h"
 
 /* Formerly utf.h, part 1 --------------------------------------------------- */
 

+ 4 - 4
sqlite/unicode/utypes.h

@@ -33,13 +33,13 @@
 #define UTYPES_H
 
 
-#include "unicode/umachine.h"
-#include "unicode/uversion.h"
-#include "unicode/uconfig.h"
+#include "umachine.h"
+#include "uversion.h"
+#include "uconfig.h"
 #include <float.h>
 
 #if !U_NO_DEFAULT_INCLUDE_UTF_HEADERS
-#   include "unicode/utf.h"
+#   include "utf.h"
 #endif
 
 /*!

+ 2 - 2
sqlite/unicode/uversion.h

@@ -25,10 +25,10 @@
 #ifndef UVERSION_H
 #define UVERSION_H
 
-#include "unicode/umachine.h"
+#include "umachine.h"
 
 /* Actual version info lives in uvernum.h */
-#include "unicode/uvernum.h"
+#include "uvernum.h"
 
 /** Maximum length of the copyright string.
  *  @stable ICU 2.4