respecting UTI string rules when constructing native format in wxDataFormat::SetId

adding part from 4ae329472c
This commit is contained in:
Stefan Csomor
2021-01-24 19:51:33 +01:00
parent 3ccfa976aa
commit 0f4c65dd4f

View File

@@ -228,15 +228,27 @@ void wxDataFormat::SetId( NativeFormat format )
void wxDataFormat::SetId( const wxString& zId )
{
m_type = wxDF_PRIVATE;
m_id = zId;
// in newer macOS version this must conform to a UTI
// https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html
if ( zId.Find('.') != wxNOT_FOUND )
m_format = wxCFStringRef(zId);
// first filter characters
wxString utiString = zId;
wxString::iterator it;
for (it = utiString.begin(); it != utiString.end(); ++it)
{
wxUniChar c = *it;
if ( !( c >= 'A' && c <='Z') && !( c >= 'a' && c <='z') && !( c >= '0' && c <='9') &&
c != '.' && c !='-' )
*it= '-';
}
m_id = utiString;
// make sure it follows a reverse DNS notation
if ( utiString.Find('.') != wxNOT_FOUND )
m_format = wxCFStringRef(utiString);
else
m_format = wxCFStringRef(privateUTIPrefix+zId);
m_format = wxCFStringRef(privateUTIPrefix+utiString);
}
bool wxDataFormat::operator==(const wxDataFormat& format) const