[aquaskk-changes 175] CVS update: AquaSKK

Back to archive index

Tomotaka SUWA t-suw****@users*****
2006年 3月 26日 (日) 23:39:11 JST


Index: AquaSKK/ChangeLog
diff -u AquaSKK/ChangeLog:1.20.2.17 AquaSKK/ChangeLog:1.20.2.18
--- AquaSKK/ChangeLog:1.20.2.17	Sat Mar 25 00:10:22 2006
+++ AquaSKK/ChangeLog	Sun Mar 26 23:39:11 2006
@@ -1,3 +1,15 @@
+2006-03-26  Tomotaka SUWA  <t.suw****@mac*****>
+
+	* CppScrap.*: íœB
+
+	* WordRegisterMode.cpp: Scrap Manager ‚ð”pŽ~‚µAPasteboardManager
+	‚ɈڍsB
+
+	* KotoeriDictionary.cpp: ŒŸõƒL[‚͏í‚É BigEndian ‚É•ÏŠ·‚·‚é‚悤‚É
+	C³B‚Ü‚½A•ÏŠ·Œó•â‚ÍŠO•”•\Œ»‚Ŏ󂯎æ‚é‚悤‚ɏC³B
+
+	* CppCFString.*: toBigEndianCFString() ‚ð’ljÁB
+
 2006-03-25  Tomotaka SUWA  <t.suw****@mac*****>
 
 	* Info-*.plist: ƒo[ƒWƒ‡ƒ“‚ðC³B
Index: AquaSKK/CppCFString.cpp
diff -u AquaSKK/CppCFString.cpp:1.3.2.3 AquaSKK/CppCFString.cpp:1.3.2.4
--- AquaSKK/CppCFString.cpp:1.3.2.3	Wed Mar 22 22:34:40 2006
+++ AquaSKK/CppCFString.cpp	Sun Mar 26 23:39:11 2006
@@ -1,5 +1,5 @@
 /*
-  $Id: CppCFString.cpp,v 1.3.2.3 2006/03/22 13:34:40 t-suwa Exp $
+  $Id: CppCFString.cpp,v 1.3.2.4 2006/03/26 14:39:11 t-suwa Exp $
 	
   MacOS X implementation of the SKK input method.
 
@@ -254,6 +254,27 @@
     return cf_string;
 }
 
+CFStringRef CppCFString::toBigEndianCFString() const {
+    CFStringRef result;
+    CFIndex len = CFStringGetLength(cf_string);
+    CFIndex bufsize = len * sizeof(UInt16);
+    UInt16* buf = new UInt16[len];
+
+    CFStringGetBytes(cf_string, CFRangeMake(0, len), kCFStringEncodingUnicode, 0, false,
+		     reinterpret_cast<UInt8*>(buf), bufsize, NULL);
+
+    for(int i = 0; i < len; ++ i) {
+	buf[i] = CFSwapInt16HostToBig(buf[i]);
+    };
+
+    result = CFStringCreateWithBytes(NULL, reinterpret_cast<UInt8*>(buf), bufsize, kCFStringEncodingUnicode, false);
+
+    delete[] buf;
+
+    return result;
+}
+
+
 UniChar* CppCFString::toUniCharPtr() const {
     // •Ô‚³‚ꂽƒ|ƒCƒ“ƒ^‚́A•K—v–³‚­‚È‚Á‚½‚çdelete[]‚µ‚È‚¯‚ê‚΂Ȃè‚Ü‚¹‚ñB
     const int len = CFStringGetLength(cf_string);
@@ -264,7 +285,7 @@
 }
 
 CFMutableDataRef CppCFString::toCFData() const {
-    // •Ô‚³‚ꂽCFDataRef‚́AŽg—pŒã‚É•K‚¸CFRelease‚·‚邱‚ƁB‚³‚à‚È‚­‚΃Š[ƒNB
+    // •Ô‚³‚ꂽCFDataRef ‚́AŽg—pŒã‚É•K‚¸ CFRelease ‚·‚邱‚ƁB‚³‚à‚È‚­‚΃Š[ƒNB
     CFDataRef src = CFStringCreateExternalRepresentation(NULL, cf_string, kCFStringEncodingUnicode, 0);
     CFMutableDataRef result = CFDataCreateMutableCopy(NULL, 0, src);
     CFRelease(src);
Index: AquaSKK/CppCFString.h
diff -u AquaSKK/CppCFString.h:1.3.2.1 AquaSKK/CppCFString.h:1.3.2.2
--- AquaSKK/CppCFString.h:1.3.2.1	Sun Jan  8 16:15:30 2006
+++ AquaSKK/CppCFString.h	Sun Mar 26 23:39:11 2006
@@ -1,5 +1,5 @@
 /*  -*- c++ -*-
-  $Id: CppCFString.h,v 1.3.2.1 2006/01/08 07:15:30 t-suwa Exp $
+  $Id: CppCFString.h,v 1.3.2.2 2006/03/26 14:39:11 t-suwa Exp $
 
   MacOS X implementation of the SKK input method.
 
@@ -75,6 +75,7 @@
     virtual CppCFString& operator+= (const UniChar c);
     
     virtual CFStringRef getString() const;
+    virtual CFStringRef toBigEndianCFString() const;
     virtual UniChar* toUniCharPtr() const;
     virtual CFMutableDataRef toCFData() const;
     virtual char* toCString(CFStringEncoding encoding = kCFStringEncodingMacRomanLatin1) const;
Index: AquaSKK/CppScrap.cpp
diff -u AquaSKK/CppScrap.cpp:1.2.2.1 AquaSKK/CppScrap.cpp:1.2
--- AquaSKK/CppScrap.cpp:1.2.2.1	Sat Jan 14 20:01:58 2006
+++ AquaSKK/CppScrap.cpp	Sat Oct  8 00:08:36 2005
@@ -7,46 +7,52 @@
  *
  */
 
+#include <Carbon/Carbon.h>
+#include <exception>
+#include "CppCFData.h"
 #include "CppScrap.h"
 
 // ---------- CppScrap ---------- //
 
 CppScrap::CppScrap() {
-    GetCurrentScrap(&scrap);
+	GetCurrentScrap(&scrap);
 }
 
 CppScrap::CppScrap(const CppScrap& copy_src) {
-    scrap = copy_src.scrap;
+	scrap = copy_src.scrap;
 }
 
 CppScrapFlavor * CppScrap::makeFlavor(ScrapFlavorType type) {
-    return new CppScrapFlavor(*this, type);
+	return new CppScrapFlavor(*this,type);
 }
 
 ScrapRef CppScrap::getScrapRef() const {
-    return scrap;
+	return scrap;
 }
 
 // ---------- CppScrapFlavor ---------- //
 
-CppScrapFlavor::CppScrapFlavor(CppScrap& s,ScrapFlavorType t) :scrap(s), type(t) {
-    // empty
+CppScrapFlavor::CppScrapFlavor(CppScrap& s,ScrapFlavorType t)
+	:scrap(s),
+	 type(t) {
+	
 }
 
 bool CppScrapFlavor::exists() const {
-    // このflavorのデータが存在するか?
-    ScrapFlavorFlags flags;
-    return GetScrapFlavorFlags(scrap.getScrapRef(), type, &flags) != scrapFlavorNotFoundErr;
+	// このflavorのデータが存在するか?
+	ScrapFlavorFlags flags;
+	return GetScrapFlavorFlags(scrap.getScrapRef(),type,&flags) != scrapFlavorNotFoundErr;
 }
 
 unsigned CppScrapFlavor::size() const {
-    if(exists()) {
-	Size flavorSize;
-	GetScrapFlavorSize(scrap.getScrapRef(), type, &flavorSize);
-	return flavorSize;
-    } else {
-	return 0;
-    }
+	if (exists()) {
+		Size size;
+		GetScrapFlavorSize(scrap.getScrapRef(),type,&size);
+		return size;
+	}
+	else {
+		return 0;
+	}
 }
 
 struct exception_CppScrapFlavor_content : public std::exception {
@@ -56,15 +62,16 @@
 };
 
 CppCFData CppScrapFlavor::content() const throw(std::exception) {
-    if(exists()) {
-	Size flavorSize = this->size();
-	char* buf = new char[flavorSize];
-	GetScrapFlavorData(scrap.getScrapRef(), type, &flavorSize, buf);
-	CppCFData data(buf, flavorSize);
-	delete[] buf;
-
-	return data;
-    } else {
-	throw exception_CppScrapFlavor_content();
-    }
+	if (exists()) {
+		Size size = this->size();
+		char* buf = new char[size];
+		GetScrapFlavorData(scrap.getScrapRef(),type,&size,buf);
+		CppCFData data(buf,size);
+		delete[] buf;
+		
+		return data;
+	}
+	else {
+	    throw exception_CppScrapFlavor_content();
+	}
 }
Index: AquaSKK/CppScrap.h
diff -u AquaSKK/CppScrap.h:1.2.2.1 AquaSKK/CppScrap.h:1.2
--- AquaSKK/CppScrap.h:1.2.2.1	Sat Jan 14 20:01:58 2006
+++ AquaSKK/CppScrap.h	Sat Oct  8 00:08:36 2005
@@ -1,60 +1,56 @@
 /*
-  $Id: CppScrap.h,v 1.2.2.1 2006/01/14 11:01:58 t-suwa Exp $
-
-  MacOS X implementation of the SKK input method.
-
-  Copyright (C) 2002 phonohawk
-  Copyright (C) 2006 Tomotaka SUWA <t.suw****@mac*****>
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+	$Id: CppScrap.h,v 1.2 2005/10/07 15:08:36 t-suwa Exp $
+	---------
+	
+    MacOS X implementation of the SKK input method.
+    Copyright (C) 2002 phonohawk
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 #pragma once
 
-#include <Carbon/Carbon.h>
-#include <exception>
-#include "CppCFData.h"
-
 /*
 	ScrapRefのラッパーであるCppScrapの他、
 	scrap flavorを表すCppScrapFlavorを定義します。
 */
 
+class CppScrap;
 class CppScrapFlavor;
 
 class CppScrap {
-protected:
-    ScrapRef scrap; // クリアされると無効になる事に注意。
-
-public:
-    CppScrap(); // 通常のクリップボードを表すCppScrapを作る。
-    CppScrap(const CppScrap& copy_src); // コピーコンストラクタは、同じScrapRefを指すものを作る。
-
-    CppScrapFlavor* makeFlavor(ScrapFlavorType type);
-    ScrapRef getScrapRef() const;
+	protected:
+		ScrapRef scrap; // クリアされると無効になる事に注意。
+	
+	public:
+		CppScrap(); // 通常のクリップボードを表すCppScrapを作る。
+		CppScrap(const CppScrap& copy_src); // コピーコンストラクタは、同じScrapRefを指すものを作る。
+		
+		CppScrapFlavor* makeFlavor(ScrapFlavorType type);
+		ScrapRef getScrapRef() const;
 };
 
 class CppScrapFlavor {
-protected:
-    CppScrap scrap;
-    ScrapFlavorType type;
-
-public:
-    CppScrapFlavor(CppScrap& s, ScrapFlavorType t);
-
-    bool exists() const; // このflavorが存在するか?
-    unsigned size() const; // flavorのサイズ。存在しなければ0。
-    CppCFData content() const throw(std::exception); // 中身。存在しなければ例外を投げる。
+	protected:
+		CppScrap scrap;
+		ScrapFlavorType type;
+	
+	public:
+		CppScrapFlavor(CppScrap& s,ScrapFlavorType t);
+		
+		bool exists() const; // このflavorが存在するか?
+		unsigned size() const; // flavorのサイズ。存在しなければ0。
+		CppCFData content() const throw(std::exception); // 中身。存在しなければ例外を投げる。
 };
Index: AquaSKK/KotoeriDictionary.cpp
diff -u AquaSKK/KotoeriDictionary.cpp:1.1.2.1 AquaSKK/KotoeriDictionary.cpp:1.1.2.2
--- AquaSKK/KotoeriDictionary.cpp:1.1.2.1	Sat Feb 18 02:20:38 2006
+++ AquaSKK/KotoeriDictionary.cpp	Sun Mar 26 23:39:11 2006
@@ -1,5 +1,5 @@
 /*
-  $Id: KotoeriDictionary.cpp,v 1.1.2.1 2006/02/17 17:20:38 t-suwa Exp $
+  $Id: KotoeriDictionary.cpp,v 1.1.2.2 2006/03/26 14:39:11 t-suwa Exp $
 
   MacOS X implementation of the SKK input method.
 
@@ -106,7 +106,7 @@
     std::vector<CppCFString> result;
 
     DCMFoundRecordIterator iterator;
-    if(!find(str.getString(), &iterator)) {
+    if(!find(str, &iterator)) {
 	return result;
     }
 
@@ -127,32 +127,42 @@
 	if(status != noErr) break;
 
 	DescType actualType;
-	char dataBuffer[kMaxKanjiLengthInAppleJapaneseDictionary];
+	UInt8 dataBuffer[kMaxKanjiLengthInAppleJapaneseDictionary];
 	Size actualSize;
 
 	// Get one data from AERecord
-	status = AEGetKeyPtr(&dataList, 
-			     kDCMJapaneseHyokiTag,
-			     'utxt',
-			     &actualType,
-			     dataBuffer,
-			     kMaxKanjiLengthInAppleJapaneseDictionary,
-			     &actualSize);
+	status = AEGetParamPtr(&dataList, 
+			       kDCMJapaneseHyokiTag,
+#if MAC_OS_X_VERSION_MAX_ALLOWED>=1040
+			       typeUTF16ExternalRepresentation,
+#else
+			       'utxt',
+#endif
+			       &actualType,
+			       dataBuffer,
+			       kMaxKanjiLengthInAppleJapaneseDictionary,
+			       &actualSize);
 
 	// Dispose data AERecord
 	AEDisposeDesc(&dataList);
 
 	if(status != noErr) break;
 
+#if MAC_OS_X_VERSION_MAX_ALLOWED>=1040
 	// Œ‹‰Ê‚ɒljÁ‚·‚é
 	result.push_back(CppCFData(dataBuffer, actualSize).getData());
+#else
+	CFStringRef tmp = CFStringCreateWithBytes(NULL, dataBuffer, actualSize, kCFStringEncodingUnicode, false);
+	result.push_back(tmp);
+	CFRelease(tmp);
+#endif
     }
     DCMDisposeRecordIterator(iterator);
 
     return result;
 }
 
-bool KotoeriDictionary::find(const CFStringRef key, DCMFoundRecordIterator* iterator) {
+bool KotoeriDictionary::find(const CppCFString key, DCMFoundRecordIterator* iterator) {
     DCMDictionaryRef ref;
     if(DCMOpenDictionary(id_, 0, NULL, &ref) != noErr) {
 	std::cerr << "DCMOpenDictionary() failed" << std::endl;
@@ -162,18 +172,19 @@
     // ƒŒƒR[ƒh‚ðŒŸõ
     OSStatus status;
     DCMFieldTag	dataFieldTagList[] = { kDCMJapaneseHyokiTag };
-    ByteCount length = CFStringGetLength(key) * sizeof(UniChar);
+    CFStringRef keydata = key.toBigEndianCFString();
     status = DCMFindRecords(ref, // Dictionary reference
-			    kDCMJapaneseYomiTag, // key field tag
-			    length,		 // key data length
-			    CFStringGetCharactersPtr(key), // key data
-			    kDCMFindMethodExactMatch, // find method
+			    kDCMJapaneseYomiTag,  // key field tag
+			    CFStringGetLength(keydata) * sizeof(UInt16), // key data length
+			    CFStringGetCharactersPtr(keydata), // key data
+			    kDCMFindMethodExactMatch,  // find method
 			    1,		      // number of data field
 			    dataFieldTagList, // data field tag list
-			    0, 0, // search all records
-			    iterator); // found result
+			    0, 0,	      // search all records
+			    iterator);	      // found result
 
     DCMCloseDictionary(ref);
+    CFRelease(keydata);
 
     return (status == noErr);
 }
Index: AquaSKK/KotoeriDictionary.h
diff -u AquaSKK/KotoeriDictionary.h:1.1.2.1 AquaSKK/KotoeriDictionary.h:1.1.2.2
--- AquaSKK/KotoeriDictionary.h:1.1.2.1	Sat Feb 18 02:20:38 2006
+++ AquaSKK/KotoeriDictionary.h	Sun Mar 26 23:39:11 2006
@@ -1,5 +1,5 @@
 /*
-  $Id: KotoeriDictionary.h,v 1.1.2.1 2006/02/17 17:20:38 t-suwa Exp $
+  $Id: KotoeriDictionary.h,v 1.1.2.2 2006/03/26 14:39:11 t-suwa Exp $
 
   MacOS X implementation of the SKK input method.
 
@@ -36,7 +36,7 @@
     bool isRegistered_;
     DCMDictionaryID id_;
 
-    bool find(const CFStringRef key, DCMFoundRecordIterator* iterator);
+    bool find(const CppCFString key, DCMFoundRecordIterator* iterator);
 
 public:
     KotoeriDictionary();
Index: AquaSKK/UserDefaults.plist
diff -u AquaSKK/UserDefaults.plist:1.1.2.5 AquaSKK/UserDefaults.plist:1.1.2.6
--- AquaSKK/UserDefaults.plist:1.1.2.5	Sat Mar 18 02:30:14 2006
+++ AquaSKK/UserDefaults.plist	Sun Mar 26 23:39:11 2006
@@ -5,7 +5,7 @@
 	<key>candidates_count</key>
 	<integer>7</integer>
 	<key>candidates_font_name</key>
-	<string>TrebuchetMS</string>
+	<string>LucidaGrande</string>
 	<key>candidates_font_size</key>
 	<integer>18</integer>
 	<key>candidates_window_alpha</key>
Index: AquaSKK/WordRegisterMode.cpp
diff -u AquaSKK/WordRegisterMode.cpp:1.3.2.1 AquaSKK/WordRegisterMode.cpp:1.3.2.2
--- AquaSKK/WordRegisterMode.cpp:1.3.2.1	Sat Jan 14 20:01:58 2006
+++ AquaSKK/WordRegisterMode.cpp	Sun Mar 26 23:39:11 2006
@@ -1,5 +1,5 @@
 /*
-  $Id: WordRegisterMode.cpp,v 1.3.2.1 2006/01/14 11:01:58 t-suwa Exp $
+  $Id: WordRegisterMode.cpp,v 1.3.2.2 2006/03/26 14:39:11 t-suwa Exp $
 
   MacOS X implementation of the SKK input method.
 
@@ -26,7 +26,6 @@
 #include "ParentInputMode.h"
 #include "IMSessionInputMode.h"
 #include "WordRegisterMode.h"
-#include "CppScrap.h"
 
 WordRegisterMode::WordRegisterMode(ChildInputMode& src, const CppCFString& word)
 	: ParentInputMode(), owner(&src), caret(0) {
@@ -111,17 +110,39 @@
 	return true;
     }
 	
-    CppScrapFlavor* clipped = CppScrap().makeFlavor(kScrapFlavorTypeUnicode);
-    if(clipped->exists()) {
-	// ƒNƒŠƒbƒvƒ{[ƒh‚É•¶Žš—ñ‚ª“ü‚Á‚Ä‚½‚̂ŁA‚±‚ê‚ðƒLƒƒƒŒƒbƒg‚̈ʒu‚É‘}“üB
-	// ƒLƒƒƒŒƒbƒg‚Í‘}“ü‚³‚ꂽ•¶Žš‚ÌŽŸ‚Ɉړ®‚·‚éB
-	CppCFString str_in_clip(clipped->content().getData());
-	buffer.insert(caret,str_in_clip);
-	caret += str_in_clip.length();
-		
+    PasteboardRef pasteboard;
+    PasteboardCreate(kPasteboardClipboard, &pasteboard);
+    PasteboardSynchronize(pasteboard);
+
+    ItemCount items;
+    PasteboardGetItemCount(pasteboard, &items);
+    for(UInt32 pos = 0; pos < items; ++ pos) {
+	PasteboardItemID id;
+	CFDataRef data;
+
+	// index ‚Í 1 based
+	if(PasteboardGetItemIdentifier(pasteboard, pos + 1, &id) < 0) continue;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED>=1040
+	if(PasteboardCopyItemFlavorData(pasteboard, id, kUTTypeUTF16ExternalPlainText, &data) < 0) continue;
+	CppCFString str(data);
+#else
+	if(PasteboardCopyItemFlavorData(pasteboard, id, CFSTR("public.utf16-plain-text"), &data) < 0) continue;
+	CFStringRef tmp = CFStringCreateWithBytes(NULL, CFDataGetBytePtr(data), CFDataGetLength(data),
+						  kCFStringEncodingUnicode, false);
+	CppCFString str(tmp);
+	CFRelease(tmp);
+#endif
+	CFRelease(data);
+
+	buffer.insert(caret, str);
+	caret += str.length();
 	display(CppCFString());
+
+	break;
     }
-    delete clipped;
+    CFRelease(pasteboard);
+
     return true;
 }
 


aquaskk-changes メーリングリストの案内
Back to archive index