incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject svn commit: r1338268 - in /incubator/ooo/trunk/main/vcl/aqua/source/dtrans: DataFlavorMapping.cxx DataFlavorMapping.hxx
Date Mon, 14 May 2012 16:10:17 GMT
Author: hdu
Date: Mon May 14 16:10:16 2012
New Revision: 1338268

URL: http://svn.apache.org/viewvc?rev=1338268&view=rev
Log:
(author=pl) fix for transporting OOo types through OSX system clipboard

Modified:
    incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.cxx
    incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.hxx

Modified: incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.cxx?rev=1338268&r1=1338267&r2=1338268&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.cxx (original)
+++ incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.cxx Mon May 14 16:10:16
2012
@@ -519,6 +519,16 @@ DataFlavorMapper::DataFlavorMapper()
 	throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("AquaClipboard: Cannot create
com.sun.star.datatransfer.MimeContentTypeFactory")), NULL);
 }
 
+DataFlavorMapper::~DataFlavorMapper()
+{
+    // release potential NSStrings
+    for( OfficeOnlyTypes::iterator it = maOfficeOnlyTypes.begin(); it != maOfficeOnlyTypes.end();
++it )
+    {
+        [it->second release];
+        it->second = nil;
+    }    
+}
+
 DataFlavor DataFlavorMapper::systemToOpenOfficeFlavor(NSString* systemDataFlavor) const
 {
   DataFlavor oOOFlavor;
@@ -534,22 +544,41 @@ DataFlavor DataFlavorMapper::systemToOpe
 		}
 	} // for
 
-  return oOOFlavor;
+	// look if this might be an internal type; if it comes in here it must have
+	// been through openOfficeToSystemFlavor before, so it should then be in the map
+	rtl::OUString aTryFlavor( NSStringToOUString( systemDataFlavor ) );
+	if( maOfficeOnlyTypes.find( aTryFlavor ) != maOfficeOnlyTypes.end() )
+	{
+	    oOOFlavor.MimeType = aTryFlavor;
+	    oOOFlavor.HumanPresentableName = rtl::OUString();
+	    oOOFlavor.DataType = CPPUTYPE_SEQINT8;
+	}
+	
+	return oOOFlavor;
 }
 
 NSString* DataFlavorMapper::openOfficeToSystemFlavor(const DataFlavor& oOOFlavor) const
 {
-  NSString* sysFlavor = NULL;
-
-  for (size_t i = 0; i < SIZE_FLAVOR_MAP; i++)
+    NSString* sysFlavor = NULL;
+    
+	for( size_t i = 0; i < SIZE_FLAVOR_MAP; ++i )
 	{
-	  if (oOOFlavor.MimeType.compareToAscii(flavorMap[i].OOoFlavor, strlen(flavorMap[i].OOoFlavor))
== 0)
+	    if (oOOFlavor.MimeType.compareToAscii(flavorMap[i].OOoFlavor, strlen(flavorMap[i].OOoFlavor))
== 0)
 		{
-		  sysFlavor = flavorMap[i].SystemFlavor;
+		    sysFlavor = flavorMap[i].SystemFlavor;
 		}
 	}
-
-  return sysFlavor;
+	
+	if( ! sysFlavor )
+	{
+		OfficeOnlyTypes::const_iterator it = maOfficeOnlyTypes.find( oOOFlavor.MimeType );
+		if( it == maOfficeOnlyTypes.end() )
+			sysFlavor = maOfficeOnlyTypes[ oOOFlavor.MimeType ] = OUStringToNSString( oOOFlavor.MimeType
);
+		else
+			sysFlavor = it->second;
+	}
+	
+	return sysFlavor;
 }
 
 NSString* DataFlavorMapper::openOfficeImageToSystemFlavor(NSPasteboard* pPasteboard) const
@@ -686,6 +715,7 @@ NSArray* DataFlavorMapper::flavorSequenc
           
           if (str != NULL)
           {
+              [str retain];
               [array addObject: str];
           }
       }

Modified: incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.hxx?rev=1338268&r1=1338267&r2=1338268&view=diff
==============================================================================
--- incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.hxx (original)
+++ incubator/ooo/trunk/main/vcl/aqua/source/dtrans/DataFlavorMapping.hxx Mon May 14 16:10:16
2012
@@ -33,6 +33,7 @@
 #import <Cocoa/Cocoa.h>
 #include <postmac.h>
 
+#include <hash_map>
 #include <memory>
 #include <boost/shared_ptr.hpp>
 
@@ -69,6 +70,7 @@ public:
 	 cannot be created.
    */
   DataFlavorMapper();
+  ~DataFlavorMapper();
 
 
   /* Map a system data flavor to an OpenOffice data flavor. 
@@ -132,6 +134,8 @@ private:
 
 private:
   ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XMimeContentTypeFactory>
mrXMimeCntFactory;
+  typedef std::hash_map< rtl::OUString, NSString*, rtl::OUStringHash > OfficeOnlyTypes;
+  mutable OfficeOnlyTypes maOfficeOnlyTypes;
 };
 
 typedef boost::shared_ptr<DataFlavorMapper> DataFlavorMapperPtr_t;



Mime
View raw message