2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
re-base on ALv2 code. Includes (at least) relevant parts of:
linecap: Reintegrating finished LineCap feature
Patch contributed by Regina Henschel
http://svn.apache.org/viewvc?view=revision&revision=1232507
Patches contributed by Sven Jacobi
impress212: #i81610# fixed animation export
http://svn.apache.org/viewvc?view=revision&revision=1167620
impress212: drawinglayer gbuild environment changes
http://svn.apache.org/viewvc?view=revision&revision=1167627
http://svn.apache.org/viewvc?view=revision&revision=1167628
impress212: DffPropSet -> minor code improvements, removing table
http://svn.apache.org/viewvc?view=revision&revision=1167634
impress212: #158494# fixed excel import (text rotation)
http://svn.apache.org/viewvc?view=revision&revision=1167638
Patches contributed by Armin Le Grand
Svg: Reintegrated Svg replacement from /branches/alg/svgreplavement
http://svn.apache.org/viewvc?view=revision&revision=1220836
#118728# changed indentifying definitions for Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1229961
#118838# LineGeometry creation for complicated cases optimized to
create single Polygons
http://svn.apache.org/viewvc?view=revision&revision=1236232
#119176# corrected file type detection for SVG for svg files
without xml header
http://svn.apache.org/viewvc?view=revision&revision=1309445
#118728# Extended Svg file detection
http://svn.apache.org/viewvc?view=revision&revision=1230531
#118529# solve break converters and convert commands for OLEs and images
http://svn.apache.org/viewvc?view=revision&revision=1186168
svg: added WaE changes from branch svgreplacement to trunc
http://svn.apache.org/viewvc?view=revision&revision=1222974
svg: corrected missing member initialization
http://svn.apache.org/viewvc?view=revision&revision=1226134
fix for #118525#: Using primitives for chart sub-geometry visualisation
http://svn.apache.org/viewvc?view=revision&revision=1226879
#118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert
metafiles to bitmapEx ...
http://svn.apache.org/viewvc?view=revision&revision=1293316
fix for #118525#: removed no longer used variable maOriginalMapMode, one
more exception eliminated
http://svn.apache.org/viewvc?view=revision&revision=1227097
#16758# Added buffering to the VDev usages of the VclProcessor2D derivates...
http://svn.apache.org/viewvc?view=revision&revision=1229521
#116758# Secured VDev buffer device to Vcl deinit
http://svn.apache.org/viewvc?view=revision&revision=1230574
#116758# added remembering allocated VDevs for VDevBuffer to be able to also
delete these when vcl goes down; it should never happen, but You never know
http://svn.apache.org/viewvc?view=revision&revision=1230927
#118730# Changed SvgClipPathNode to use MaskPrimitive2D for primitive
representation instead of TransparencePrimitive2D
http://svn.apache.org/viewvc?view=revision&revision=1231198
#118822# secured 3D geometry creation (slices) by subdividing the 2D
source polyPolygon early
http://svn.apache.org/viewvc?view=revision&revision=1234749
#118829# enhanced Svg gradient quality, obstacles avoided
http://svn.apache.org/viewvc?view=revision&revision=1235361
#118834# Unified usage of TextBreakupHelper as single tooling class
for i18n text primitive breakup
http://svn.apache.org/viewvc?view=revision&revision=1236110
#118853# added square pixel size limit to conversion of
TransparencePrimitive2D to Metafile action
http://svn.apache.org/viewvc?view=revision&revision=1237656
#118824# coreccted mirroring and boundrect when the graphicmanager
is used for bitmap output
http://svn.apache.org/viewvc?view=revision&revision=1240097
#115092# Corrected VclProcessor2D::RenderPolygonStrokePrimitive2D for
various optimization scenarios
http://svn.apache.org/viewvc?view=revision&revision=1241434
#118783# Corrected errors in ID strings, corrected Svg line/fill export,
corrected polygon close state
http://svn.apache.org/viewvc?view=revision&revision=1232006
#118796# corrected null-pointer usage in SVG text exporter
http://svn.apache.org/viewvc?view=revision&revision=1240262
#118729# Use GraphicStreamUrl and GraphicUrl to allow multi image
import with linked graphics, too
http://svn.apache.org/viewvc?view=revision&revision=1229962
#118898# corrected error in GDIMetaFile::GetBoundRect in handling
MetaFloatTransparentAction
http://svn.apache.org/viewvc?view=revision&revision=1293349
#118855# Corrected handling of possibly created empty clipRegions
after PolyPolygon clipping
http://svn.apache.org/viewvc?view=revision&revision=1237725
#115962# Better (but not yet optimal, see comments in task) handling
of MetaFloatTransparentAction in PDF export
http://svn.apache.org/viewvc?view=revision&revision=1241078
IP clearance: #118466# This patch removes librsvg, libcroco, libgsf, ...
http://svn.apache.org/viewvc?view=revision&revision=1200879
118779# Added svg content streaming in/out to ImpGraphic stream operators
http://svn.apache.org/viewvc?view=revision&revision=1231908
linecap: correctons for WaE and mac drawing
http://svn.apache.org/viewvc?view=revision&revision=1232793
svg: uses current system Dpi for Svg replacement image creation
http://svn.apache.org/viewvc?view=revision&revision=1233948
Patches contributed by Mathias Bauer (and others)
gnumake4 work variously
http://svn.apache.org/viewvc?view=revision&revision=1394326
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1394326
Remove duplicate header includes.
cws mba34issues01: #i117720#: convert assertion into warning
http://svn.apache.org/viewvc?view=revision&revision=1172352
118485 - Styles for OLEs are not saved. Submitted by Armin Le Grand.
http://svn.apache.org/viewvc?view=revision&revision=1182166
cws mba34issues01: #i117714#: remove assertion
http://svn.apache.org/viewvc?view=revision&revision=1172357
Patch contributed by Jurgen Schmidt
add some additional checks to ensure proper reading operations
http://svn.apache.org/viewvc?view=revision&revision=1209022
mostly prefer our stream / bounds checking work.
Patches contributed by Herbert Duerr
#i118816# add clarifying comment regarding Font::*Color*() methods
http://svn.apache.org/viewvc?view=revision&revision=1233833
extend macro->string handling for empty strings
http://svn.apache.org/viewvc?view=revision&revision=1175801
avoid magic constants for SALCOLOR_NONE
http://svn.apache.org/viewvc?view=revision&revision=1177543
initialize slant properly in ImplFontMetricData constructor (author=iorsh)
http://svn.apache.org/viewvc?view=revision&revision=1177551
#i118675# make check for extension updates more stable
http://svn.apache.org/viewvc?view=revision&revision=1214797
#a118617# remove VBasicEventListener.dll binary
There are no known users depending on its CLSID
http://svn.apache.org/viewvc?view=revision&revision=1203697
Patches contributed by Ariel Constenla-Haile
Fix build breaker on Linux/gcc
http://svn.apache.org/viewvc?view=revision&revision=1221104
Fix crash when trying to instantiate css.graphic.GraphicRasterizer_RSVG
http://svn.apache.org/viewvc?view=revision&revision=1215559
Patches contributed by Oliver-Rainer Wittmann
sw34bf06: #i117962# - method <SwFlyFrm::IsPaint(..)> - consider
instances of <SwFlyDrawObj>
http://svn.apache.org/viewvc?view=revision&revision=1172120
sw34bf06: #i117783# - Writer's implementation of XPagePrintable -
apply print settings to new printing routines
http://svn.apache.org/viewvc?view=revision&revision=1172115
gnumake4 work variously from Hans-Joachim Lankenau
http://svn.apache.org/viewvc?view=revision&revision=1397315
http://svn.apache.org/viewvc?view=revision&revision=1396797
http://svn.apache.org/viewvc?view=revision&revision=1396782
http://svn.apache.org/viewvc?view=revision&revision=1394707
plus some amount of re-splitting of legacy headers.
Patch contributed by Pavel Janik
WaE: Remove unused variables.
http://svn.apache.org/viewvc?view=revision&revision=1230697
Patches contributed by Takashi Ono
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
mingwport35: i#117795: MinGW port fix for vcl2gnumake
http://svn.apache.org/viewvc?view=revision&revision=1172091
Patch contributed by Christian Lippka
impress212: #i98044# re enable Text menu for outline and title shapes
http://svn.apache.org/viewvc?view=revision&revision=1167639
Patch contributed by Andre Fischer
118674: Made category B code optional and disabled by default.
http://svn.apache.org/viewvc?view=revision&revision=1215131
118881: Ignore empty paragraphs after bullets.
http://svn.apache.org/viewvc?view=revision&revision=1296205
Patches contributed by Philipp Lohmann
ooo340fixes: #i117780# use rtl allocator
http://svn.apache.org/viewvc?view=revision&revision=1172087
ooo34gsl02: #i117807# fix an off by one error (index actually
inside the pfb section header)
http://svn.apache.org/viewvc?view=revision&revision=1167576
various cleanups, related compilation fixes, warning cleanups, re-working
of obsolete stl template pieces to use boost instead, changed string
classes, re-adapt KDE about data, about dialog, fixing warnings,
and other fixes & improvements.
Disable svg import / render for about/ branding code-paths for now.
Restore full icon theme set.
Remove OS/2 conditionals and sources.
Remove conflicting gtk/full-screen monitors support.
Retain existing svg rasterizer files - temporarily disabled.
Standardize stringificaiton and fixup dllpostfix issues.
Rename SvgGradientHelper::== to equalTo to avoid overloading issues.
Use the flat GdiPlus API for LineCaps calls.
2012-10-09 12:22:23 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2013-03-23 21:55:27 +01:00
|
|
|
#include "sal/config.h"
|
|
|
|
|
2007-07-05 08:10:07 +00:00
|
|
|
#include <DataFlavorMapping.hxx>
|
|
|
|
#include "HtmlFmtFlt.hxx"
|
|
|
|
#include "PictToBmpFlt.hxx"
|
2009-09-18 11:54:06 +00:00
|
|
|
#include "com/sun/star/datatransfer/UnsupportedFlavorException.hpp"
|
|
|
|
#include "com/sun/star/datatransfer/XMimeContentType.hpp"
|
2013-02-06 17:14:00 +02:00
|
|
|
#include "com/sun/star/datatransfer/MimeContentTypeFactory.hpp"
|
2007-07-05 08:10:07 +00:00
|
|
|
#include "com/sun/star/uno/Sequence.hxx"
|
2012-10-31 09:22:53 +01:00
|
|
|
#include "comphelper/processfactory.hxx"
|
2007-07-05 08:10:07 +00:00
|
|
|
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
#include <osl/endian.h>
|
|
|
|
|
2014-02-21 23:46:33 +01:00
|
|
|
#include <cassert>
|
2012-08-13 11:21:13 +02:00
|
|
|
#include <string.h>
|
2007-07-05 08:10:07 +00:00
|
|
|
|
|
|
|
#include <premac.h>
|
2010-01-26 11:23:25 +01:00
|
|
|
#include <Cocoa/Cocoa.h>
|
2007-07-05 08:10:07 +00:00
|
|
|
#include <postmac.h>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::datatransfer;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace cppu;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace // private
|
|
|
|
{
|
|
|
|
/* Determine whether or not a DataFlavor is valid.
|
|
|
|
*/
|
|
|
|
bool isValidFlavor(const DataFlavor& aFlavor)
|
|
|
|
{
|
|
|
|
size_t len = aFlavor.MimeType.getLength();
|
|
|
|
Type dtype = aFlavor.DataType;
|
2015-04-01 08:43:18 +02:00
|
|
|
return ((len > 0) && ((dtype == cppu::UnoType<Sequence<sal_Int8>>::get()) || (dtype == cppu::UnoType<OUString>::get())));
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 13:37:51 +00:00
|
|
|
OUString NSStringToOUString( const NSString* cfString)
|
2012-05-14 15:10:16 +00:00
|
|
|
{
|
2014-02-21 23:46:33 +01:00
|
|
|
assert(cfString && "Invalid parameter");
|
2012-05-14 15:10:16 +00:00
|
|
|
|
|
|
|
const char* utf8Str = [cfString UTF8String];
|
|
|
|
unsigned int len = rtl_str_getLength(utf8Str);
|
|
|
|
|
|
|
|
return OUString(utf8Str, len, RTL_TEXTENCODING_UTF8);
|
|
|
|
}
|
|
|
|
|
|
|
|
NSString* OUStringToNSString(const OUString& ustring)
|
|
|
|
{
|
|
|
|
OString utf8Str = OUStringToOString(ustring, RTL_TEXTENCODING_UTF8);
|
|
|
|
return [NSString stringWithCString: utf8Str.getStr() encoding: NSUTF8StringEncoding];
|
|
|
|
}
|
|
|
|
|
2011-10-22 09:40:55 +02:00
|
|
|
NSString* PBTYPE_SODX = @"application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\"";
|
|
|
|
NSString* PBTYPE_SESX = @"application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"";
|
|
|
|
NSString* PBTYPE_SLSDX = @"application/x-openoffice-linksrcdescriptor-xml;windows_formatname=\"Star Link Source Descriptor (XML)\"";
|
|
|
|
NSString* PBTYPE_ESX = @"application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"";
|
|
|
|
NSString* PBTYPE_LSX = @"application/x-openoffice-link-source-xml;windows_formatname=\"Star Link Source (XML)\"";
|
|
|
|
NSString* PBTYPE_EOX = @"application/x-openoffice-embedded-obj-xml;windows_formatname=\"Star Embedded Object (XML)\"";
|
|
|
|
NSString* PBTYPE_SVXB = @"application/x-openoffice-svbx;windows_formatname=\"SVXB (StarView Bitmap/Animation)\"";
|
|
|
|
NSString* PBTYPE_GDIMF = @"application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"";
|
|
|
|
NSString* PBTYPE_WMF = @"application/x-openoffice-wmf;windows_formatname=\"Image WMF\"";
|
|
|
|
NSString* PBTYPE_EMF = @"application/x-openoffice-emf;windows_formatname=\"Image EMF\"";
|
|
|
|
|
|
|
|
NSString* PBTYPE_DUMMY_INTERNAL = @"application/x-openoffice-internal";
|
2008-07-01 22:00:52 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
const char* FLAVOR_SODX = "application/x-openoffice-objectdescriptor-xml;windows_formatname=\"Star Object Descriptor (XML)\"";
|
|
|
|
const char* FLAVOR_SESX = "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"";
|
|
|
|
const char* FLAVOR_SLSDX = "application/x-openoffice-linksrcdescriptor-xml;windows_formatname=\"Star Link Source Descriptor (XML)\"";
|
|
|
|
const char* FLAVOR_ESX = "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"";
|
|
|
|
const char* FLAVOR_LSX = "application/x-openoffice-link-source-xml;windows_formatname=\"Star Link Source (XML)\"";
|
|
|
|
const char* FLAVOR_EOX = "application/x-openoffice-embedded-obj-xml;windows_formatname=\"Star Embedded Object (XML)\"";
|
|
|
|
const char* FLAVOR_SVXB = "application/x-openoffice-svbx;windows_formatname=\"SVXB (StarView Bitmap/Animation)\"";
|
|
|
|
const char* FLAVOR_GDIMF = "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"";
|
|
|
|
const char* FLAVOR_WMF = "application/x-openoffice-wmf;windows_formatname=\"Image WMF\"";
|
|
|
|
const char* FLAVOR_EMF = "application/x-openoffice-emf;windows_formatname=\"Image EMF\"";
|
|
|
|
|
2008-07-01 22:00:52 +00:00
|
|
|
const char* FLAVOR_DUMMY_INTERNAL = "application/x-openoffice-internal";
|
|
|
|
|
2007-07-05 08:10:07 +00:00
|
|
|
struct FlavorMap
|
|
|
|
{
|
2013-12-12 13:37:51 +00:00
|
|
|
const NSString* SystemFlavor;
|
2008-02-18 13:46:25 +00:00
|
|
|
const char* OOoFlavor;
|
|
|
|
const char* HumanPresentableName;
|
2012-11-13 17:53:42 +01:00
|
|
|
bool DataTypeOUString; // sequence<byte> otherwise
|
2007-07-05 08:10:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* At the moment it appears as if only MS Office pastes "public.html" to the clipboard.
|
|
|
|
*/
|
2013-12-12 13:37:51 +00:00
|
|
|
static const FlavorMap flavorMap[] =
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2012-11-13 17:53:42 +01:00
|
|
|
{ NSStringPboardType, "text/plain;charset=utf-16", "Unicode Text (UTF-16)", true },
|
|
|
|
{ NSRTFPboardType, "text/richtext", "Rich Text Format", false },
|
2013-01-10 16:28:40 +00:00
|
|
|
{ NSTIFFPboardType, "image/png", "Portable Network Graphics", false },
|
2012-11-13 17:53:42 +01:00
|
|
|
{ NSHTMLPboardType, "text/html", "Plain Html", false },
|
|
|
|
{ NSFilenamesPboardType, "application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", false },
|
|
|
|
{ PBTYPE_SESX, FLAVOR_SESX, "Star Embed Source (XML)", false },
|
|
|
|
{ PBTYPE_SLSDX, FLAVOR_SLSDX, "Star Link Source Descriptor (XML)", false },
|
|
|
|
{ PBTYPE_ESX, FLAVOR_ESX, "Star Embed Source (XML)", false },
|
|
|
|
{ PBTYPE_LSX, FLAVOR_LSX, "Star Link Source (XML)", false },
|
|
|
|
{ PBTYPE_EOX, FLAVOR_EOX, "Star Embedded Object (XML)", false },
|
|
|
|
{ PBTYPE_SVXB, FLAVOR_SVXB, "SVXB (StarView Bitmap/Animation", false },
|
|
|
|
{ PBTYPE_GDIMF, FLAVOR_GDIMF, "GDIMetaFile", false },
|
|
|
|
{ PBTYPE_WMF, FLAVOR_WMF, "Windows MetaFile", false },
|
|
|
|
{ PBTYPE_EMF, FLAVOR_EMF, "Windows Enhanced MetaFile", false },
|
|
|
|
{ PBTYPE_SODX, FLAVOR_SODX, "Star Object Descriptor (XML)", false },
|
|
|
|
{ PBTYPE_DUMMY_INTERNAL, FLAVOR_DUMMY_INTERNAL, "internal data",false }
|
2007-07-05 08:10:07 +00:00
|
|
|
};
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
#define SIZE_FLAVOR_MAP (sizeof(flavorMap)/sizeof(FlavorMap))
|
2007-07-05 08:10:07 +00:00
|
|
|
|
|
|
|
inline bool isByteSequenceType(const Type& theType)
|
|
|
|
{
|
2015-04-01 08:43:18 +02:00
|
|
|
return (theType == cppu::UnoType<Sequence<sal_Int8>>::get());
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2012-04-25 13:16:25 +02:00
|
|
|
inline bool isOUStringType(const Type& theType)
|
|
|
|
{
|
2014-05-11 10:57:54 +02:00
|
|
|
return (theType == cppu::UnoType<OUString>::get() );
|
2012-04-25 13:16:25 +02:00
|
|
|
}
|
|
|
|
|
2007-07-05 08:10:07 +00:00
|
|
|
} // namespace private
|
|
|
|
|
|
|
|
/* A base class for other data provider.
|
|
|
|
*/
|
|
|
|
class DataProviderBaseImpl : public DataProvider
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataProviderBaseImpl(const Any& data);
|
2008-02-18 13:46:25 +00:00
|
|
|
DataProviderBaseImpl(id data);
|
2007-07-05 08:10:07 +00:00
|
|
|
virtual ~DataProviderBaseImpl();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Any mData;
|
2008-02-18 13:46:25 +00:00
|
|
|
//NSData* mSystemData;
|
|
|
|
id mSystemData;
|
2007-07-05 08:10:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
DataProviderBaseImpl::DataProviderBaseImpl(const Any& data) :
|
|
|
|
mData(data),
|
2008-02-18 13:46:25 +00:00
|
|
|
mSystemData(nil)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
DataProviderBaseImpl::DataProviderBaseImpl(id data) :
|
2007-07-05 08:10:07 +00:00
|
|
|
mSystemData(data)
|
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
[mSystemData retain];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DataProviderBaseImpl::~DataProviderBaseImpl()
|
|
|
|
{
|
|
|
|
if (mSystemData)
|
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
[mSystemData release];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class UniDataProvider : public DataProviderBaseImpl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UniDataProvider(const Any& data);
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
UniDataProvider(NSData* data);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual NSData* getSystemData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual Any getOOoData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
UniDataProvider::UniDataProvider(const Any& data) :
|
|
|
|
DataProviderBaseImpl(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
UniDataProvider::UniDataProvider(NSData* data) :
|
2007-07-05 08:10:07 +00:00
|
|
|
DataProviderBaseImpl(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
NSData* UniDataProvider::getSystemData()
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
OUString ustr;
|
|
|
|
mData >>= ustr;
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
OString strUtf8;
|
|
|
|
ustr.convertToString(&strUtf8, RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return [NSData dataWithBytes: strUtf8.getStr() length: strUtf8.getLength()];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Any UniDataProvider::getOOoData()
|
|
|
|
{
|
|
|
|
Any oOOData;
|
|
|
|
|
|
|
|
if (mSystemData)
|
|
|
|
{
|
2015-04-02 19:43:15 +02:00
|
|
|
oOOData = makeAny(OUString(static_cast<const sal_Char*>([mSystemData bytes]),
|
2008-02-18 13:46:25 +00:00
|
|
|
[mSystemData length],
|
|
|
|
RTL_TEXTENCODING_UTF8));
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oOOData = mData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return oOOData;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ByteSequenceDataProvider : public DataProviderBaseImpl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ByteSequenceDataProvider(const Any& data);
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
ByteSequenceDataProvider(NSData* data);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual NSData* getSystemData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual Any getOOoData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ByteSequenceDataProvider::ByteSequenceDataProvider(const Any& data) :
|
|
|
|
DataProviderBaseImpl(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
ByteSequenceDataProvider::ByteSequenceDataProvider(NSData* data) :
|
2007-07-05 08:10:07 +00:00
|
|
|
DataProviderBaseImpl(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
NSData* ByteSequenceDataProvider::getSystemData()
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
Sequence<sal_Int8> rawData;
|
|
|
|
mData >>= rawData;
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return [NSData dataWithBytes: rawData.getArray() length: rawData.getLength()];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Any ByteSequenceDataProvider::getOOoData()
|
|
|
|
{
|
|
|
|
Any oOOData;
|
|
|
|
|
|
|
|
if (mSystemData)
|
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
unsigned int flavorDataLength = [mSystemData length];
|
2007-07-05 08:10:07 +00:00
|
|
|
Sequence<sal_Int8> byteSequence;
|
|
|
|
byteSequence.realloc(flavorDataLength);
|
2008-02-18 13:46:25 +00:00
|
|
|
memcpy(byteSequence.getArray(), [mSystemData bytes], flavorDataLength);
|
2007-07-05 08:10:07 +00:00
|
|
|
oOOData = makeAny(byteSequence);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oOOData = mData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return oOOData;
|
|
|
|
}
|
|
|
|
|
|
|
|
class HTMLFormatDataProvider : public DataProviderBaseImpl
|
|
|
|
{
|
|
|
|
public:
|
2008-02-18 13:46:25 +00:00
|
|
|
HTMLFormatDataProvider(NSData* data);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual NSData* getSystemData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual Any getOOoData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
};
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
HTMLFormatDataProvider::HTMLFormatDataProvider(NSData* data) :
|
2007-07-05 08:10:07 +00:00
|
|
|
DataProviderBaseImpl(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
NSData* HTMLFormatDataProvider::getSystemData()
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
Sequence<sal_Int8> textHtmlData;
|
|
|
|
mData >>= textHtmlData;
|
|
|
|
|
|
|
|
Sequence<sal_Int8> htmlFormatData = TextHtmlToHTMLFormat(textHtmlData);
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return [NSData dataWithBytes: htmlFormatData.getArray() length: htmlFormatData.getLength()];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Any HTMLFormatDataProvider::getOOoData()
|
|
|
|
{
|
|
|
|
Any oOOData;
|
|
|
|
|
|
|
|
if (mSystemData)
|
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
unsigned int flavorDataLength = [mSystemData length];
|
2007-07-05 08:10:07 +00:00
|
|
|
Sequence<sal_Int8> unkHtmlData;
|
|
|
|
|
|
|
|
unkHtmlData.realloc(flavorDataLength);
|
2008-02-18 13:46:25 +00:00
|
|
|
memcpy(unkHtmlData.getArray(), [mSystemData bytes], flavorDataLength);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
|
|
|
Sequence<sal_Int8>* pPlainHtml = &unkHtmlData;
|
|
|
|
Sequence<sal_Int8> plainHtml;
|
|
|
|
|
|
|
|
if (isHTMLFormat(unkHtmlData))
|
|
|
|
{
|
|
|
|
plainHtml = HTMLFormatToTextHtml(unkHtmlData);
|
|
|
|
pPlainHtml = &plainHtml;
|
|
|
|
}
|
|
|
|
|
|
|
|
oOOData = makeAny(*pPlainHtml);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oOOData = mData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return oOOData;
|
|
|
|
}
|
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
class PNGDataProvider : public DataProviderBaseImpl
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2010-01-26 11:23:25 +01:00
|
|
|
NSBitmapImageFileType meImageType;
|
2007-07-05 08:10:07 +00:00
|
|
|
public:
|
2013-01-10 16:28:40 +00:00
|
|
|
PNGDataProvider( const Any&, NSBitmapImageFileType);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
PNGDataProvider( NSData*, NSBitmapImageFileType);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual NSData* getSystemData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual Any getOOoData() SAL_OVERRIDE;
|
2007-07-05 08:10:07 +00:00
|
|
|
};
|
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
PNGDataProvider::PNGDataProvider( const Any& data, NSBitmapImageFileType eImageType) :
|
2010-01-26 11:23:25 +01:00
|
|
|
DataProviderBaseImpl(data),
|
|
|
|
meImageType( eImageType )
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
PNGDataProvider::PNGDataProvider( NSData* data, NSBitmapImageFileType eImageType) :
|
2010-01-26 11:23:25 +01:00
|
|
|
DataProviderBaseImpl(data),
|
|
|
|
meImageType( eImageType )
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
NSData* PNGDataProvider::getSystemData()
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2013-01-10 16:28:40 +00:00
|
|
|
Sequence<sal_Int8> pngData;
|
|
|
|
mData >>= pngData;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
Sequence<sal_Int8> imgData;
|
|
|
|
NSData* sysData = NULL;
|
|
|
|
if( PNGToImage( pngData, imgData, meImageType))
|
|
|
|
sysData = [NSData dataWithBytes: imgData.getArray() length: imgData.getLength()];
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
return sysData;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
/* The AOO 'PCT' filter is not yet good enough to be used
|
|
|
|
and there is no flavor defined for exchanging 'PCT' with AOO
|
|
|
|
so we convert 'PCT' to a PNG and provide this to AOO
|
2007-07-05 08:10:07 +00:00
|
|
|
*/
|
2013-01-10 16:28:40 +00:00
|
|
|
Any PNGDataProvider::getOOoData()
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2013-01-10 16:28:40 +00:00
|
|
|
Any oOOData;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
if( mSystemData)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2013-01-10 16:28:40 +00:00
|
|
|
const unsigned int flavorDataLength = [mSystemData length];
|
|
|
|
Sequence<sal_Int8> imgData( flavorDataLength);
|
|
|
|
memcpy( imgData.getArray(), [mSystemData bytes], flavorDataLength);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
Sequence<sal_Int8> pngData;
|
|
|
|
if( ImageToPNG( imgData, pngData, meImageType))
|
|
|
|
oOOData = makeAny( pngData);
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
2013-01-10 16:28:40 +00:00
|
|
|
else
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2013-01-10 16:28:40 +00:00
|
|
|
oOOData = mData;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return oOOData;
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
class FileListDataProvider : public DataProviderBaseImpl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FileListDataProvider(const Any& data);
|
|
|
|
FileListDataProvider(NSArray* data);
|
|
|
|
|
2014-02-28 14:27:15 +02:00
|
|
|
virtual NSData* getSystemData() SAL_OVERRIDE;
|
|
|
|
virtual Any getOOoData() SAL_OVERRIDE;
|
2008-02-18 13:46:25 +00:00
|
|
|
};
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
FileListDataProvider::FileListDataProvider(const Any& data) :
|
|
|
|
DataProviderBaseImpl(data)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
}
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
FileListDataProvider::FileListDataProvider(NSArray* data) :
|
|
|
|
DataProviderBaseImpl(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NSData* FileListDataProvider::getSystemData()
|
|
|
|
{
|
|
|
|
return [NSData data];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
Any FileListDataProvider::getOOoData()
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
Any oOOData;
|
|
|
|
|
|
|
|
if (mSystemData)
|
|
|
|
{
|
|
|
|
size_t length = [mSystemData count];
|
|
|
|
size_t lenSeqRequired = 0;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
NSString* fname = [mSystemData objectAtIndex: i];
|
|
|
|
lenSeqRequired += [fname maximumLengthOfBytesUsingEncoding: NSUnicodeStringEncoding] + sizeof(unichar);
|
|
|
|
}
|
|
|
|
|
|
|
|
Sequence<sal_Int8> oOOFileList(lenSeqRequired);
|
|
|
|
unichar* pBuffer = reinterpret_cast<unichar*>(oOOFileList.getArray());
|
2012-08-13 11:21:13 +02:00
|
|
|
memset(pBuffer, 0, lenSeqRequired);
|
2008-02-18 13:46:25 +00:00
|
|
|
|
|
|
|
for (size_t i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
NSString* fname = [mSystemData objectAtIndex: i];
|
|
|
|
[fname getCharacters: pBuffer];
|
|
|
|
size_t l = [fname length];
|
|
|
|
pBuffer += l + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
oOOData = makeAny(oOOFileList);
|
|
|
|
}
|
|
|
|
else
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
oOOData = mData;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return oOOData;
|
|
|
|
}
|
|
|
|
|
2009-09-18 11:54:06 +00:00
|
|
|
DataFlavorMapper::DataFlavorMapper()
|
2008-02-18 13:46:25 +00:00
|
|
|
{
|
2013-02-06 17:14:00 +02:00
|
|
|
Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
|
|
|
|
mrXMimeCntFactory = MimeContentTypeFactory::create( xContext );
|
2008-02-18 13:46:25 +00:00
|
|
|
}
|
|
|
|
|
2012-05-14 15:10:16 +00:00
|
|
|
DataFlavorMapper::~DataFlavorMapper()
|
|
|
|
{
|
|
|
|
// release potential NSStrings
|
|
|
|
for( OfficeOnlyTypes::iterator it = maOfficeOnlyTypes.begin(); it != maOfficeOnlyTypes.end(); ++it )
|
|
|
|
{
|
|
|
|
[it->second release];
|
|
|
|
it->second = nil;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-12 13:37:51 +00:00
|
|
|
DataFlavor DataFlavorMapper::systemToOpenOfficeFlavor( const NSString* systemDataFlavor) const
|
2008-02-18 13:46:25 +00:00
|
|
|
{
|
2007-07-05 08:10:07 +00:00
|
|
|
DataFlavor oOOFlavor;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < SIZE_FLAVOR_MAP; i++)
|
|
|
|
{
|
2013-12-12 13:37:51 +00:00
|
|
|
if ([systemDataFlavor caseInsensitiveCompare:const_cast<NSString*>(flavorMap[i].SystemFlavor)] == NSOrderedSame)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
oOOFlavor.MimeType = OUString::createFromAscii(flavorMap[i].OOoFlavor);
|
2012-12-10 01:19:27 +02:00
|
|
|
oOOFlavor.HumanPresentableName = OUString::createFromAscii(flavorMap[i].HumanPresentableName);
|
2015-04-01 08:43:18 +02:00
|
|
|
oOOFlavor.DataType = flavorMap[i].DataTypeOUString ? cppu::UnoType<OUString>::get() : cppu::UnoType<Sequence<sal_Int8>>::get();
|
2008-02-18 13:46:25 +00:00
|
|
|
return oOOFlavor;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
} // for
|
|
|
|
|
2012-05-14 15:10:16 +00:00
|
|
|
// 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
|
|
|
|
OUString aTryFlavor( NSStringToOUString( systemDataFlavor ) );
|
|
|
|
if( maOfficeOnlyTypes.find( aTryFlavor ) != maOfficeOnlyTypes.end() )
|
|
|
|
{
|
|
|
|
oOOFlavor.MimeType = aTryFlavor;
|
2014-11-12 14:24:10 +05:30
|
|
|
oOOFlavor.HumanPresentableName.clear();
|
2015-04-01 08:43:18 +02:00
|
|
|
oOOFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get();
|
2012-05-14 15:10:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return oOOFlavor;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 13:37:51 +00:00
|
|
|
const NSString* DataFlavorMapper::openOfficeToSystemFlavor( const DataFlavor& oOOFlavor, bool& rbInternal) const
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2013-12-12 13:37:51 +00:00
|
|
|
const NSString* sysFlavor = NULL;
|
|
|
|
rbInternal = false;
|
2008-02-18 13:46:25 +00:00
|
|
|
|
2012-05-14 15:10:16 +00:00
|
|
|
for( size_t i = 0; i < SIZE_FLAVOR_MAP; ++i )
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2012-05-14 15:10:16 +00:00
|
|
|
if (oOOFlavor.MimeType.startsWith(OUString::createFromAscii(flavorMap[i].OOoFlavor)))
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2012-05-14 15:10:16 +00:00
|
|
|
sysFlavor = flavorMap[i].SystemFlavor;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-06 12:10:35 +00:00
|
|
|
if(!sysFlavor)
|
|
|
|
{
|
|
|
|
rbInternal = true;
|
|
|
|
OfficeOnlyTypes::const_iterator it = maOfficeOnlyTypes.find( oOOFlavor.MimeType );
|
2012-08-22 07:37:16 +00:00
|
|
|
|
2013-06-06 12:10:35 +00:00
|
|
|
if( it == maOfficeOnlyTypes.end() )
|
|
|
|
sysFlavor = maOfficeOnlyTypes[ oOOFlavor.MimeType ] = OUStringToNSString( oOOFlavor.MimeType );
|
|
|
|
else
|
|
|
|
sysFlavor = it->second;
|
|
|
|
}
|
2012-05-14 15:10:16 +00:00
|
|
|
|
|
|
|
return sysFlavor;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2015-05-11 08:41:14 +02:00
|
|
|
NSString* DataFlavorMapper::openOfficeImageToSystemFlavor(NSPasteboard* pPasteboard)
|
2010-01-26 11:23:25 +01:00
|
|
|
{
|
2013-06-17 22:12:07 +03:00
|
|
|
NSArray *supportedTypes = [NSArray arrayWithObjects: NSTIFFPboardType, nil];
|
2010-01-26 11:23:25 +01:00
|
|
|
NSString *sysFlavor = [pPasteboard availableTypeFromArray:supportedTypes];
|
|
|
|
return sysFlavor;
|
|
|
|
}
|
|
|
|
|
2013-12-12 13:37:51 +00:00
|
|
|
DataProviderPtr_t DataFlavorMapper::getDataProvider( const NSString* systemFlavor, Reference<XTransferable> rTransferable) const
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
DataProviderPtr_t dp;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
DataFlavor oOOFlavor = systemToOpenOfficeFlavor(systemFlavor);
|
|
|
|
|
|
|
|
Any data = rTransferable->getTransferData(oOOFlavor);
|
|
|
|
|
|
|
|
if (isByteSequenceType(data.getValueType()))
|
|
|
|
{
|
2010-10-11 14:33:33 +02:00
|
|
|
/*
|
|
|
|
the HTMLFormatDataProvider prepends segment information to HTML
|
|
|
|
this is useful for exchange with MS Word (which brings this stuff from Windows)
|
|
|
|
but annoying for other applications. Since this extension is not a standard datatype
|
|
|
|
on the Mac, let us not provide but provide normal HTML
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
if ([systemFlavor caseInsensitiveCompare: NSHTMLPboardType] == NSOrderedSame)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
dp = DataProviderPtr_t(new HTMLFormatDataProvider(data));
|
|
|
|
}
|
2010-10-11 14:33:33 +02:00
|
|
|
else
|
|
|
|
*/
|
2013-06-17 22:12:07 +03:00
|
|
|
if ([systemFlavor caseInsensitiveCompare: NSTIFFPboardType] == NSOrderedSame)
|
2010-01-26 11:23:25 +01:00
|
|
|
{
|
2013-01-10 16:28:40 +00:00
|
|
|
dp = DataProviderPtr_t( new PNGDataProvider( data, NSTIFFFileType));
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
2008-02-18 13:46:25 +00:00
|
|
|
else if ([systemFlavor caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
dp = DataProviderPtr_t(new FileListDataProvider(data));
|
|
|
|
}
|
2007-07-05 08:10:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dp = DataProviderPtr_t(new ByteSequenceDataProvider(data));
|
|
|
|
}
|
|
|
|
}
|
2008-02-18 13:46:25 +00:00
|
|
|
else // Must be OUString type
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2012-04-25 13:16:25 +02:00
|
|
|
SAL_WARN_IF(
|
|
|
|
!isOUStringType(data.getValueType()), "vcl",
|
|
|
|
"must be OUString type");
|
2007-07-05 08:10:07 +00:00
|
|
|
dp = DataProviderPtr_t(new UniDataProvider(data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(UnsupportedFlavorException&)
|
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
// Somebody violates the contract of the clipboard
|
|
|
|
// interface @see XTransferable
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return dp;
|
|
|
|
}
|
|
|
|
|
2015-05-11 08:41:14 +02:00
|
|
|
DataProviderPtr_t DataFlavorMapper::getDataProvider( const NSString* /*systemFlavor*/, NSArray* systemData)
|
2008-02-18 13:46:25 +00:00
|
|
|
{
|
|
|
|
return DataProviderPtr_t(new FileListDataProvider(systemData));
|
|
|
|
}
|
|
|
|
|
2015-05-11 08:41:14 +02:00
|
|
|
DataProviderPtr_t DataFlavorMapper::getDataProvider( const NSString* systemFlavor, NSData* systemData)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
DataProviderPtr_t dp;
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
if ([systemFlavor caseInsensitiveCompare: NSStringPboardType] == NSOrderedSame)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
dp = DataProviderPtr_t(new UniDataProvider(systemData));
|
|
|
|
}
|
2008-02-18 13:46:25 +00:00
|
|
|
else if ([systemFlavor caseInsensitiveCompare: NSHTMLPboardType] == NSOrderedSame)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
|
|
|
dp = DataProviderPtr_t(new HTMLFormatDataProvider(systemData));
|
|
|
|
}
|
2010-01-26 11:23:25 +01:00
|
|
|
else if ([systemFlavor caseInsensitiveCompare: NSTIFFPboardType] == NSOrderedSame)
|
|
|
|
{
|
2013-01-10 16:28:40 +00:00
|
|
|
dp = DataProviderPtr_t( new PNGDataProvider(systemData, NSTIFFFileType));
|
2008-02-18 13:46:25 +00:00
|
|
|
}
|
|
|
|
else if ([systemFlavor caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
//dp = DataProviderPtr_t(new FileListDataProvider(systemData));
|
|
|
|
}
|
2007-07-05 08:10:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dp = DataProviderPtr_t(new ByteSequenceDataProvider(systemData));
|
|
|
|
}
|
|
|
|
|
|
|
|
return dp;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
bool DataFlavorMapper::isValidMimeContentType(const OUString& contentType) const
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
bool result = true;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
try
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
Reference<XMimeContentType> xCntType(mrXMimeCntFactory->createMimeContentType(contentType));
|
|
|
|
}
|
|
|
|
catch( IllegalArgumentException& )
|
|
|
|
{
|
|
|
|
result = false;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return result;
|
|
|
|
}
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
NSArray* DataFlavorMapper::flavorSequenceToTypesArray(const com::sun::star::uno::Sequence<com::sun::star::datatransfer::DataFlavor>& flavors) const
|
|
|
|
{
|
|
|
|
sal_uInt32 nFlavors = flavors.getLength();
|
|
|
|
NSMutableArray* array = [[NSMutableArray alloc] initWithCapacity: 1];
|
|
|
|
|
2013-06-06 12:10:35 +00:00
|
|
|
bool bNeedDummyInternalFlavor(false);
|
2012-08-22 07:37:16 +00:00
|
|
|
|
2008-08-01 07:56:14 +00:00
|
|
|
for (sal_uInt32 i = 0; i < nFlavors; i++)
|
2008-07-01 22:00:52 +00:00
|
|
|
{
|
2013-03-09 22:47:20 +01:00
|
|
|
if( flavors[i].MimeType.startsWith("image/bmp") )
|
2008-08-01 07:56:14 +00:00
|
|
|
{
|
2010-01-26 11:23:25 +01:00
|
|
|
[array addObject: NSTIFFPboardType];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-12 13:37:51 +00:00
|
|
|
const NSString* str = openOfficeToSystemFlavor(flavors[i], bNeedDummyInternalFlavor);
|
2010-01-26 11:23:25 +01:00
|
|
|
|
|
|
|
if (str != NULL)
|
|
|
|
{
|
2012-05-14 15:10:16 +00:00
|
|
|
[str retain];
|
2010-01-26 11:23:25 +01:00
|
|
|
[array addObject: str];
|
|
|
|
}
|
2008-07-01 22:00:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-08-01 07:56:14 +00:00
|
|
|
// #i89462# #i90747#
|
|
|
|
// in case no system flavor was found to report
|
|
|
|
// report at least one so D&D between OOo targets works
|
2012-08-22 07:37:16 +00:00
|
|
|
if( [array count] == 0 || bNeedDummyInternalFlavor)
|
2008-08-01 07:56:14 +00:00
|
|
|
{
|
|
|
|
[array addObject: PBTYPE_DUMMY_INTERNAL];
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return [array autorelease];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
com::sun::star::uno::Sequence<com::sun::star::datatransfer::DataFlavor> DataFlavorMapper::typesArrayToFlavorSequence(NSArray* types) const
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
int nFormats = [types count];
|
|
|
|
Sequence<DataFlavor> flavors;
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
for (int i = 0; i < nFormats; i++)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
NSString* sysFormat = [types objectAtIndex: i];
|
|
|
|
DataFlavor oOOFlavor = systemToOpenOfficeFlavor(sysFormat);
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
if (isValidFlavor(oOOFlavor))
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
flavors.realloc(flavors.getLength() + 1);
|
|
|
|
flavors[flavors.getLength() - 1] = oOOFlavor;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return flavors;
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2015-05-11 08:41:14 +02:00
|
|
|
NSArray* DataFlavorMapper::getAllSupportedPboardTypes()
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
NSMutableArray* array = [[NSMutableArray alloc] initWithCapacity: SIZE_FLAVOR_MAP];
|
2007-07-05 08:10:07 +00:00
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
for (sal_uInt32 i = 0; i < SIZE_FLAVOR_MAP; i++)
|
2007-07-05 08:10:07 +00:00
|
|
|
{
|
2008-02-18 13:46:25 +00:00
|
|
|
[array addObject: flavorMap[i].SystemFlavor];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
|
|
|
|
2008-02-18 13:46:25 +00:00
|
|
|
return [array autorelease];
|
2007-07-05 08:10:07 +00:00
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|