DataFlavorMapping.cxx (3ee7bea8) | DataFlavorMapping.cxx (1cc6f0e2) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 50 unchanged lines hidden (view full) --- 59 { 60 size_t len = aFlavor.MimeType.getLength(); 61 Type dtype = aFlavor.DataType; 62 return ((len > 0) && ((dtype == CPPUTYPE_SEQINT8) || (dtype == CPPUTYPE_OUSTRING))); 63 } 64 65 typedef vector<sal_Unicode> UnicodeBuffer; 66 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 50 unchanged lines hidden (view full) --- 59 { 60 size_t len = aFlavor.MimeType.getLength(); 61 Type dtype = aFlavor.DataType; 62 return ((len > 0) && ((dtype == CPPUTYPE_SEQINT8) || (dtype == CPPUTYPE_OUSTRING))); 63 } 64 65 typedef vector<sal_Unicode> UnicodeBuffer; 66 |
67 OUString NSStringToOUString(NSString* cfString) | 67 OUString NSStringToOUString( const NSString* cfString) |
68 { 69 BOOST_ASSERT(cfString && "Invalid parameter"); 70 71 const char* utf8Str = [cfString UTF8String]; 72 unsigned int len = rtl_str_getLength(utf8Str); 73 74 return OUString(utf8Str, len, RTL_TEXTENCODING_UTF8); 75 } --- 32 unchanged lines hidden (view full) --- 108 const char* FLAVOR_WMF = "application/x-openoffice-wmf;windows_formatname=\"Image WMF\""; 109 const char* FLAVOR_EMF = "application/x-openoffice-emf;windows_formatname=\"Image EMF\""; 110 111 const char* FLAVOR_DUMMY_INTERNAL = "application/x-openoffice-internal"; 112 113 114 struct FlavorMap 115 { | 68 { 69 BOOST_ASSERT(cfString && "Invalid parameter"); 70 71 const char* utf8Str = [cfString UTF8String]; 72 unsigned int len = rtl_str_getLength(utf8Str); 73 74 return OUString(utf8Str, len, RTL_TEXTENCODING_UTF8); 75 } --- 32 unchanged lines hidden (view full) --- 108 const char* FLAVOR_WMF = "application/x-openoffice-wmf;windows_formatname=\"Image WMF\""; 109 const char* FLAVOR_EMF = "application/x-openoffice-emf;windows_formatname=\"Image EMF\""; 110 111 const char* FLAVOR_DUMMY_INTERNAL = "application/x-openoffice-internal"; 112 113 114 struct FlavorMap 115 { |
116 NSString* SystemFlavor; | 116 const NSString* SystemFlavor; |
117 const char* OOoFlavor; 118 const char* HumanPresentableName; 119 Type DataType; 120 }; 121 122 /* At the moment it appears as if only MS Office pastes "public.html" to the clipboard. 123 */ | 117 const char* OOoFlavor; 118 const char* HumanPresentableName; 119 Type DataType; 120 }; 121 122 /* At the moment it appears as if only MS Office pastes "public.html" to the clipboard. 123 */ |
124 FlavorMap flavorMap[] = | 124 static const FlavorMap flavorMap[] = |
125 { 126 { NSStringPboardType, "text/plain;charset=utf-16", "Unicode Text (UTF-16)", CPPUTYPE_OUSTRING }, 127 { NSRTFPboardType, "text/richtext", "Rich Text Format", CPPUTYPE_SEQINT8 }, 128 { NSTIFFPboardType, "image/png", "Portable Network Graphics", CPPUTYPE_SEQINT8 }, 129 { NSPICTPboardType, "image/png", "Portable Network Graphics", CPPUTYPE_SEQINT8 }, 130 { NSHTMLPboardType, "text/html", "Plain Html", CPPUTYPE_SEQINT8 }, 131 { NSFilenamesPboardType, "application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", CPPUTYPE_SEQINT8 }, 132 { PBTYPE_SESX, FLAVOR_SESX, "Star Embed Source (XML)", CPPUTYPE_SEQINT8 }, --- 383 unchanged lines hidden (view full) --- 516 // release potential NSStrings 517 for( OfficeOnlyTypes::iterator it = maOfficeOnlyTypes.begin(); it != maOfficeOnlyTypes.end(); ++it ) 518 { 519 [it->second release]; 520 it->second = nil; 521 } 522} 523 | 125 { 126 { NSStringPboardType, "text/plain;charset=utf-16", "Unicode Text (UTF-16)", CPPUTYPE_OUSTRING }, 127 { NSRTFPboardType, "text/richtext", "Rich Text Format", CPPUTYPE_SEQINT8 }, 128 { NSTIFFPboardType, "image/png", "Portable Network Graphics", CPPUTYPE_SEQINT8 }, 129 { NSPICTPboardType, "image/png", "Portable Network Graphics", CPPUTYPE_SEQINT8 }, 130 { NSHTMLPboardType, "text/html", "Plain Html", CPPUTYPE_SEQINT8 }, 131 { NSFilenamesPboardType, "application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", CPPUTYPE_SEQINT8 }, 132 { PBTYPE_SESX, FLAVOR_SESX, "Star Embed Source (XML)", CPPUTYPE_SEQINT8 }, --- 383 unchanged lines hidden (view full) --- 516 // release potential NSStrings 517 for( OfficeOnlyTypes::iterator it = maOfficeOnlyTypes.begin(); it != maOfficeOnlyTypes.end(); ++it ) 518 { 519 [it->second release]; 520 it->second = nil; 521 } 522} 523 |
524DataFlavor DataFlavorMapper::systemToOpenOfficeFlavor(NSString* systemDataFlavor) const | 524DataFlavor DataFlavorMapper::systemToOpenOfficeFlavor( const NSString* systemDataFlavor) const |
525{ 526 DataFlavor oOOFlavor; 527 528 for (size_t i = 0; i < SIZE_FLAVOR_MAP; i++) 529 { | 525{ 526 DataFlavor oOOFlavor; 527 528 for (size_t i = 0; i < SIZE_FLAVOR_MAP; i++) 529 { |
530 if ([systemDataFlavor caseInsensitiveCompare: flavorMap[i].SystemFlavor] == NSOrderedSame) | 530 if ([systemDataFlavor caseInsensitiveCompare:const_cast<NSString*>(flavorMap[i].SystemFlavor)] == NSOrderedSame) |
531 { 532 oOOFlavor.MimeType = OUString::createFromAscii( flavorMap[i].OOoFlavor); 533 oOOFlavor.HumanPresentableName = OUString::createFromAscii( flavorMap[i].HumanPresentableName); 534 oOOFlavor.DataType = flavorMap[i].DataType; 535 return oOOFlavor; 536 } 537 } // for 538 --- 5 unchanged lines hidden (view full) --- 544 oOOFlavor.MimeType = aTryFlavor; 545 oOOFlavor.HumanPresentableName = rtl::OUString(); 546 oOOFlavor.DataType = CPPUTYPE_SEQINT8; 547 } 548 549 return oOOFlavor; 550} 551 | 531 { 532 oOOFlavor.MimeType = OUString::createFromAscii( flavorMap[i].OOoFlavor); 533 oOOFlavor.HumanPresentableName = OUString::createFromAscii( flavorMap[i].HumanPresentableName); 534 oOOFlavor.DataType = flavorMap[i].DataType; 535 return oOOFlavor; 536 } 537 } // for 538 --- 5 unchanged lines hidden (view full) --- 544 oOOFlavor.MimeType = aTryFlavor; 545 oOOFlavor.HumanPresentableName = rtl::OUString(); 546 oOOFlavor.DataType = CPPUTYPE_SEQINT8; 547 } 548 549 return oOOFlavor; 550} 551 |
552NSString* DataFlavorMapper::openOfficeToSystemFlavor(const DataFlavor& oOOFlavor, bool& rbInternal) const | 552const NSString* DataFlavorMapper::openOfficeToSystemFlavor( const DataFlavor& oOOFlavor, bool& rbInternal) const |
553{ | 553{ |
554 NSString* sysFlavor = NULL; | 554 const NSString* sysFlavor = NULL; |
555 rbInternal = false; | 555 rbInternal = false; |
556 rbInternal = false; |
|
556 557 for( size_t i = 0; i < SIZE_FLAVOR_MAP; ++i ) 558 { 559 if (oOOFlavor.MimeType.compareToAscii(flavorMap[i].OOoFlavor, strlen(flavorMap[i].OOoFlavor)) == 0) 560 { 561 sysFlavor = flavorMap[i].SystemFlavor; 562 } 563 } --- 14 unchanged lines hidden (view full) --- 578 579NSString* DataFlavorMapper::openOfficeImageToSystemFlavor(NSPasteboard* pPasteboard) const 580{ 581 NSArray *supportedTypes = [NSArray arrayWithObjects: NSTIFFPboardType, NSPICTPboardType, nil]; 582 NSString *sysFlavor = [pPasteboard availableTypeFromArray:supportedTypes]; 583 return sysFlavor; 584} 585 | 557 558 for( size_t i = 0; i < SIZE_FLAVOR_MAP; ++i ) 559 { 560 if (oOOFlavor.MimeType.compareToAscii(flavorMap[i].OOoFlavor, strlen(flavorMap[i].OOoFlavor)) == 0) 561 { 562 sysFlavor = flavorMap[i].SystemFlavor; 563 } 564 } --- 14 unchanged lines hidden (view full) --- 579 580NSString* DataFlavorMapper::openOfficeImageToSystemFlavor(NSPasteboard* pPasteboard) const 581{ 582 NSArray *supportedTypes = [NSArray arrayWithObjects: NSTIFFPboardType, NSPICTPboardType, nil]; 583 NSString *sysFlavor = [pPasteboard availableTypeFromArray:supportedTypes]; 584 return sysFlavor; 585} 586 |
586DataProviderPtr_t DataFlavorMapper::getDataProvider(NSString* systemFlavor, Reference<XTransferable> rTransferable) const | 587DataProviderPtr_t DataFlavorMapper::getDataProvider( const NSString* systemFlavor, Reference<XTransferable> rTransferable) const |
587{ 588 DataProviderPtr_t dp; 589 590 try 591 { 592 DataFlavor oOOFlavor = systemToOpenOfficeFlavor(systemFlavor); 593 594 Any data = rTransferable->getTransferData(oOOFlavor); --- 39 unchanged lines hidden (view full) --- 634 { 635 // Somebody violates the contract of the clipboard 636 // interface @see XTransferable 637 } 638 639 return dp; 640} 641 | 588{ 589 DataProviderPtr_t dp; 590 591 try 592 { 593 DataFlavor oOOFlavor = systemToOpenOfficeFlavor(systemFlavor); 594 595 Any data = rTransferable->getTransferData(oOOFlavor); --- 39 unchanged lines hidden (view full) --- 635 { 636 // Somebody violates the contract of the clipboard 637 // interface @see XTransferable 638 } 639 640 return dp; 641} 642 |
642DataProviderPtr_t DataFlavorMapper::getDataProvider(const NSString* /*systemFlavor*/, NSArray* systemData) const | 643DataProviderPtr_t DataFlavorMapper::getDataProvider( const NSString* /*systemFlavor*/, NSArray* systemData) const |
643{ 644 return DataProviderPtr_t(new FileListDataProvider(systemData)); 645} 646 | 644{ 645 return DataProviderPtr_t(new FileListDataProvider(systemData)); 646} 647 |
647DataProviderPtr_t DataFlavorMapper::getDataProvider(const NSString* systemFlavor, NSData* systemData) const | 648DataProviderPtr_t DataFlavorMapper::getDataProvider( const NSString* systemFlavor, NSData* systemData) const |
648{ 649 DataProviderPtr_t dp; 650 651 if ([systemFlavor caseInsensitiveCompare: NSStringPboardType] == NSOrderedSame) 652 { 653 dp = DataProviderPtr_t(new UniDataProvider(systemData)); 654 } 655 else if ([systemFlavor caseInsensitiveCompare: NSHTMLPboardType] == NSOrderedSame) --- 47 unchanged lines hidden (view full) --- 703 { 704 if( flavors[i].MimeType.compareToAscii( "image/bmp", 9 ) == 0 ) 705 { 706 [array addObject: NSTIFFPboardType]; 707 [array addObject: NSPICTPboardType]; 708 } 709 else 710 { | 649{ 650 DataProviderPtr_t dp; 651 652 if ([systemFlavor caseInsensitiveCompare: NSStringPboardType] == NSOrderedSame) 653 { 654 dp = DataProviderPtr_t(new UniDataProvider(systemData)); 655 } 656 else if ([systemFlavor caseInsensitiveCompare: NSHTMLPboardType] == NSOrderedSame) --- 47 unchanged lines hidden (view full) --- 704 { 705 if( flavors[i].MimeType.compareToAscii( "image/bmp", 9 ) == 0 ) 706 { 707 [array addObject: NSTIFFPboardType]; 708 [array addObject: NSPICTPboardType]; 709 } 710 else 711 { |
711 NSString* str = openOfficeToSystemFlavor(flavors[i], bNeedDummyInternalFlavor); | 712 const NSString* str = openOfficeToSystemFlavor(flavors[i], bNeedDummyInternalFlavor); |
712 713 if (str != NULL) 714 { 715 [str retain]; 716 [array addObject: str]; 717 } 718 } 719 } --- 44 unchanged lines hidden --- | 713 714 if (str != NULL) 715 { 716 [str retain]; 717 [array addObject: str]; 718 } 719 } 720 } --- 44 unchanged lines hidden --- |