/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * 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 .
*/
// This is a list of the bidirectional mapping between (internal) MIME types and (system) // pasteboard types.
// Only pasteboard types mentioned here will be recognized, mapped, and available for pasting in a // fresh LibreOffice process. When copy-pasting in-process, the situation is different.
// Also MIME types not mentioned here will be stored on the pasteboard (using the same type name), // though. But that is IMHO a bit pointless as they in general won't then be pasteable anyway in a // new LibreOffice process. See the use of the maOfficeOnlyTypes array.
// The SystemFlavor member is nil for the cases where there is no predefined pasteboard type UTI // and we use the internal MIME type (media type) also on the pasteboard. That is OK in macOS, // there is no requirement that the types are well-formed UTIs. It is different on iOS, I think, // though. For an introduction to UTIs, see for instance // https://alastairs-place.net/blog/2012/06/06/utis-are-better-than-you-think-and-heres-why/ // // In those cases the MIME type might actually have parameters appended, separated by semicolons. // At least the FLAVOR_SODX one must have at least a typename="%PRODUCTNAME %PRODUCTVERSION // Spreadsheet" parameter (with macros expanded and translated) for LO to recognise it. See // lcl_TestFormat() in sc/source/ui/view/cellsh.cxx.
/* A base class for other data provider.
*/ class DataProviderBaseImpl : public DataProvider
{ public:
DataProviderBaseImpl(const Any& data);
DataProviderBaseImpl(id data); virtual ~DataProviderBaseImpl() override;
protected:
Any mData; //NSData* mSystemData;
id mSystemData;
};
/* 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
*/
Any PNGDataProvider::getOOoData()
{
Any oOOData;
for (size_t i = 0; i < SIZE_FLAVOR_MAP; i++)
{ if ((flavorMap[i].SystemFlavor == nil && ([systemDataFlavor isEqualToString:[NSString stringWithUTF8String:flavorMap[i].OOoFlavor]]
||
[systemDataFlavor hasPrefix:[[NSString stringWithUTF8String:flavorMap[i].OOoFlavor] stringByAppendingString:@";"]]))
||
(flavorMap[i].SystemFlavor != nil && [systemDataFlavor isEqualToString:const_cast<NSString*>(flavorMap[i].SystemFlavor)]))
{ if (flavorMap[i].SystemFlavor == nil)
oOOFlavor.MimeType = NSStringToOUString(systemDataFlavor); else
oOOFlavor.MimeType = OUString::createFromAscii(flavorMap[i].OOoFlavor);
oOOFlavor.HumanPresentableName = OUString::createFromAscii(flavorMap[i].HumanPresentableName);
oOOFlavor.DataType = flavorMap[i].DataTypeOUString ? cppu::UnoType<OUString>::get() : cppu::UnoType<Sequence<sal_Int8>>::get(); return oOOFlavor;
}
} // for
// 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;
oOOFlavor.HumanPresentableName.clear();
oOOFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get();
}
for( size_t i = 0; i < SIZE_FLAVOR_MAP; ++i )
{ if (oOOFlavor.MimeType.startsWith(OUString::createFromAscii(flavorMap[i].OOoFlavor)))
{ // tdf#151679 Do not push FLAVOR_LINK to macOS general pasteboard // When copying text from a Writer document and the FLAVOR_LINK // flavor is pasted, Writer will edit the copied text in order // to create a bookmark for DDE. // The problem is that many macOS clipboard managers fetch *all* // available flavors that are available in the macOS general // pasteboard instead of just one flavor and this triggers the // FLAVOR_LINK flavor's unusual editing behavior in Writer every // time the user copies Writer text. // Users have reported in tdf#1515679 that on macOS, Microsoft // Writer, Excel, and PowerPoint do not recognize this flavor // like is done on Windows so, in theory, we can just filter out // this flavor when adding flavors to the macOS general pasteboard. // With this change, the FLAVOR_LINK flavor will still be visible // when copying and pasting within a single LibreOffice instance // as well as when dragging from LibreOffice to other applications. if (bIsSystemClipboard && !strcmp(FLAVOR_LINK, flavorMap[i].OOoFlavor)) return nullptr;
if( it == maOfficeOnlyTypes.end() )
{ // tdf#161461 stop crashing by retaining NSString // OUStringToNSString() returns an autoreleased NSString so it // needs to be retained for the life of maOfficeOnlyTypes.
sysFlavor = maOfficeOnlyTypes[oOOFlavor.MimeType] =
[OUStringToNSString(oOOFlavor.MimeType) retain];
} else
{
sysFlavor = it->second;
}
}
Any data = rTransferable->getTransferData(oOOFlavor);
if (isByteSequenceType(data.getValueType()))
{ /* 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
if ([systemFlavor caseInsensitiveCompare: NSHTMLPboardType] == NSOrderedSame) { dp = DataProviderPtr_t(new HTMLFormatDataProvider(data)); } else
*/ if ([systemFlavor caseInsensitiveCompare: NSPasteboardTypeTIFF] == NSOrderedSame)
{
dp = DataProviderPtr_t( new PNGDataProvider( data, NSBitmapImageFileTypeTIFF));
}
SAL_WNODEPRECATED_DECLARATIONS_PUSH // "'NSFilenamesPboardType' is deprecated: first deprecated in macOS 10.14 - Create // multiple pasteboard items with NSPasteboardTypeFileURL or kUTTypeFileURL instead" elseif ([systemFlavor caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame)
SAL_WNODEPRECATED_DECLARATIONS_POP
{
dp = DataProviderPtr_t(new FileListDataProvider(data));
} else
{
dp = DataProviderPtr_t(new ByteSequenceDataProvider(data));
}
} else// Must be OUString type
{
SAL_WARN_IF(
!isOUStringType(data.getValueType()), "vcl", "must be OUString type");
dp = DataProviderPtr_t(new UniDataProvider(data));
}
} catch( const UnsupportedFlavorException& e )
{
SAL_WARN( "vcl.osx.clipboard", "DataFlavorMapper::getDataProvider(): Exception: " << e.Message ); // Somebody violates the contract of the clipboard // interface @see XTransferable
}
for (sal_uInt32 i = 0; i < nFlavors; i++)
{ if( flavors[i].MimeType.startsWith("image/bmp") )
{
[array addObject: NSPasteboardTypeTIFF];
} else
{ const NSString* str = openOfficeToSystemFlavor(flavors[i], bNeedDummyInternalFlavor, bIsSystemClipboard);
if (str != nullptr)
[array addObject: str];
}
}
// #i89462# #i90747# // in case no system flavor was found to report // report at least one so D&D between OOo targets works if( [array count] == 0 || bNeedDummyInternalFlavor)
{
[array addObject: [NSString stringWithUTF8String: FLAVOR_DUMMY_INTERNAL]];
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.