respecting UTI string rules when constructing native format in wxDataFormat::SetId
adding part from 4ae329472c
This commit is contained in:
@@ -228,15 +228,27 @@ void wxDataFormat::SetId( NativeFormat format )
|
|||||||
void wxDataFormat::SetId( const wxString& zId )
|
void wxDataFormat::SetId( const wxString& zId )
|
||||||
{
|
{
|
||||||
m_type = wxDF_PRIVATE;
|
m_type = wxDF_PRIVATE;
|
||||||
m_id = zId;
|
|
||||||
|
|
||||||
// in newer macOS version this must conform to a UTI
|
// in newer macOS version this must conform to a UTI
|
||||||
// https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html
|
// https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/UniformTypeIdentifier.html
|
||||||
|
|
||||||
if ( zId.Find('.') != wxNOT_FOUND )
|
// first filter characters
|
||||||
m_format = wxCFStringRef(zId);
|
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
|
else
|
||||||
m_format = wxCFStringRef(privateUTIPrefix+zId);
|
m_format = wxCFStringRef(privateUTIPrefix+utiString);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxDataFormat::operator==(const wxDataFormat& format) const
|
bool wxDataFormat::operator==(const wxDataFormat& format) const
|
||||||
|
Reference in New Issue
Block a user