Changeset 96
- Timestamp:
- Jul 6, 2006, 11:11:46 PM (19 years ago)
- Location:
- trunk/src/kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel/qclipboard_pm.cpp
r20 r96 156 156 } 157 157 158 // Not efficient to iterate over this (so we provide provides() above).159 160 // In order to be able to use UniCode characters, we have to give161 // it a higher priority than single-byte characters. To do this, we162 // treat CF_TEXT as a special case and postpone its processing until163 // we're sure we do not have CF_TextUnicode ("text/unicode" atom)164 158 const char* format( int n ) const 165 159 { 166 160 const char* mime = 0; 167 bool sawText = false;168 161 169 162 if ( n >= 0 ) { … … 171 164 ulong cf = 0; 172 165 while ( (cf = WinEnumClipbrdFmts( 0, cf )) ) { 173 if ( cf == CF_TEXT ) { 174 sawText = true; 175 } else { 176 mime = QPMMime::cfToMime( cf ); 177 if ( mime ) { 178 if ( !n ) 179 break; // COME FROM HERE 180 n--; 181 mime = 0; 182 } 183 } 184 } 185 // COME FROM BREAK 186 187 // If we did not find a suitable mime type, yet skipped 188 // CF_TEXT due to the priorities above, give it a shot 189 if ( !mime && sawText && !n ) { 190 mime = QPMMime::cfToMime( CF_TEXT ); 166 mime = QPMMime::cfToMime( cf ); 167 if ( mime ) { 168 if ( !n ) 169 break; 170 n--; 171 mime = 0; 172 } 191 173 } 192 174 WinCloseClipbrd( 0 ); … … 617 599 } 618 600 } 601 // Don't search for other formats for the same mime type -- 602 // we've already represented it in the clipboard and adding a 603 // new format would just introduce mime type duplicates on the 604 // clipboard reader's side (where the first encountered format 605 // would be used for actual data transfer anyway). 606 // See also QDragManager::drag(). 607 break; 619 608 } 620 609 } -
trunk/src/kernel/qdragobject.cpp
r8 r96 607 607 608 608 switch ( i ) { 609 #if defined(Q_WS_PM) 610 // We want "text/whatever" w/o any charset to be the first (the "default") 611 // mime type of the QTextDrag object, so that a rendering mechanism/format 612 // pair for it will be the first in the RMF list, wchich is essential for 613 // some native drop targets (i.e. WPS) to render text correctly. Note that 614 // it won't hide unicode data from Qt apps because QTextDrag::decode() 615 // for Q_WS_PM prefers unicode mime types (see the implementation below). 616 case 0: 617 return ""; 618 case 1: 619 if ( localcharset.isNull() ) { 620 QTextCodec *localCodec = QTextCodec::codecForLocale(); 621 if ( localCodec ) { 622 localcharset = localCodec->name(); 623 localcharset = localcharset.lower(); 624 stripws(localcharset); 625 } else { 626 localcharset = ""; 627 } 628 } 629 return localcharset; 630 case 2: 631 return "UTF-8"; 632 case 3: 633 return "ISO-10646-UCS-2"; 634 #else 609 635 case 0: 610 636 return "UTF-8"; … … 625 651 } 626 652 return localcharset; 653 #endif 627 654 } 628 655 return 0; … … 898 925 } 899 926 927 #if defined(Q_WS_PM) 928 // We give Unicode formats a higher priority, so that if there are several 929 // encodings of the same subtype present in the given mime source, a 930 // Unicode one will be used for decoding. Otherwise, the first recognized 931 // format will be choosen. 932 int fallbackMime = -1; 933 bool secondPass = FALSE; 934 935 const char *mime; 936 for( int i = 0; /* FOREVER */; ++i ) { 937 mime = e->format( i ); 938 if ( !mime ) { 939 // We went through all mimes but didn't find Unicode. If there is 940 // a fall-back mime, iterate again starting directly from it. 941 if ( !secondPass && fallbackMime >= 0 ) { 942 i = fallbackMime - 1; // will do ++i on continue 943 secondPass = TRUE; 944 continue; 945 } 946 break; 947 } 948 #else 900 949 const char* mime; 901 950 for (int i=0; (mime = e->format(i)); i++) { 951 #endif 902 952 if ( 0==qstrnicmp(mime,"text/",5) ) { 903 953 QCString m(mime); … … 916 966 codec = qt_findcharset(m); 917 967 if ( codec ) { 968 #if defined(Q_WS_PM) 969 if ( codec->mibEnum() == 1000 /* ISO-10646-UCS-2 */ || 970 codec->mibEnum() == 106 /* UTF-8 */ ) { 971 // no need to try it again on the second pass 972 if ( secondPass ) 973 continue; 974 } else if ( !secondPass ) { 975 // memorize the fall-back mime on the first pass 976 if ( fallbackMime < 0 ) 977 fallbackMime = i; 978 continue; 979 } 980 #endif 918 981 QByteArray payload; 919 920 982 payload = e->encodedData(mime); 921 983 if ( payload.size() ) {
Note:
See TracChangeset
for help on using the changeset viewer.