[Foundation] Unify the source code for NSAttributedStringDocumentAttributes. (#17069)
Unify the source code for NSAttributedStringDocumentAttributes between iOS and maOS. As a result, we're now exposing a few APIs on macOS that were previously only exposed on iOS. This PR might be easier to review commit-by-commit.
This commit is contained in:
Коммит
e69d361c11
|
@ -25,7 +25,6 @@ namespace Foundation {
|
|||
}
|
||||
|
||||
// Utility enum, ObjC uses NSString
|
||||
[NoMac]
|
||||
public enum NSDocumentViewMode {
|
||||
Normal,
|
||||
PageLayout
|
||||
|
|
|
@ -1,276 +0,0 @@
|
|||
//
|
||||
// UIStringAttributes.cs: Implements strongly typed access to UIKit specific part of UIStringAttributeKey
|
||||
//
|
||||
// Authors: Marek Safar (marek.safar@gmail.com)
|
||||
//
|
||||
// Copyright 2012-2013, Xamarin Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
using ObjCRuntime;
|
||||
using Foundation;
|
||||
using CoreGraphics;
|
||||
|
||||
#if !MONOMAC
|
||||
using UIKit;
|
||||
#endif
|
||||
|
||||
namespace Foundation {
|
||||
|
||||
public partial class NSAttributedStringDocumentAttributes : DictionaryContainer {
|
||||
#if !MONOMAC && !COREBUILD
|
||||
public NSAttributedStringDocumentAttributes () : base (new NSMutableDictionary ()) { }
|
||||
public NSAttributedStringDocumentAttributes (NSDictionary? dictionary) : base (dictionary) { }
|
||||
|
||||
public NSStringEncoding? StringEncoding {
|
||||
get {
|
||||
var value = GetInt32Value (NSAttributedStringDocumentAttributeKey.NSCharacterEncodingDocumentAttribute);
|
||||
if (value is null)
|
||||
return null;
|
||||
else
|
||||
return (NSStringEncoding) value.Value;
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSCharacterEncodingDocumentAttribute, (int?) value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSString? WeakDocumentType {
|
||||
get {
|
||||
return GetNSStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSDocumentType DocumentType {
|
||||
get {
|
||||
var s = GetNSStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute);
|
||||
if (s == NSAttributedStringDocumentType.NSPlainTextDocumentType)
|
||||
return NSDocumentType.PlainText;
|
||||
if (s == NSAttributedStringDocumentType.NSRtfdTextDocumentType)
|
||||
return NSDocumentType.RTFD;
|
||||
if (s == NSAttributedStringDocumentType.NSRtfTextDocumentType)
|
||||
return NSDocumentType.RTF;
|
||||
if (s == NSAttributedStringDocumentType.NSHtmlTextDocumentType)
|
||||
return NSDocumentType.HTML;
|
||||
return NSDocumentType.Unknown;
|
||||
}
|
||||
|
||||
set {
|
||||
switch (value) {
|
||||
case NSDocumentType.PlainText:
|
||||
SetStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute, NSAttributedStringDocumentType.NSPlainTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.RTFD:
|
||||
SetStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute, NSAttributedStringDocumentType.NSRtfdTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.RTF:
|
||||
SetStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute, NSAttributedStringDocumentType.NSRtfTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.HTML:
|
||||
SetStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute, NSAttributedStringDocumentType.NSHtmlTextDocumentType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CGSize? PaperSize {
|
||||
get {
|
||||
NSObject value;
|
||||
Dictionary.TryGetValue (NSAttributedStringDocumentAttributeKey.NSPaperSizeDocumentAttribute, out value);
|
||||
var size = value as NSValue;
|
||||
if (size != null)
|
||||
return size.CGSizeValue;
|
||||
return null;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSPaperSizeDocumentAttribute);
|
||||
else
|
||||
Dictionary [NSAttributedStringDocumentAttributeKey.NSPaperSizeDocumentAttribute] = NSValue.FromCGSize (value.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public UIEdgeInsets? PaperMargin {
|
||||
get {
|
||||
NSObject value;
|
||||
Dictionary.TryGetValue (NSAttributedStringDocumentAttributeKey.NSPaperMarginDocumentAttribute, out value);
|
||||
var size = value as NSValue;
|
||||
if (size != null)
|
||||
return size.UIEdgeInsetsValue;
|
||||
return null;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSPaperMarginDocumentAttribute);
|
||||
else
|
||||
Dictionary [NSAttributedStringDocumentAttributeKey.NSPaperMarginDocumentAttribute] = NSValue.FromUIEdgeInsets (value.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public CGSize? ViewSize {
|
||||
get {
|
||||
NSObject value;
|
||||
Dictionary.TryGetValue (NSAttributedStringDocumentAttributeKey.NSViewSizeDocumentAttribute, out value);
|
||||
var size = value as NSValue;
|
||||
if (size != null)
|
||||
return size.CGSizeValue;
|
||||
return null;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSViewSizeDocumentAttribute);
|
||||
else
|
||||
Dictionary [NSAttributedStringDocumentAttributeKey.NSViewSizeDocumentAttribute] = NSValue.FromCGSize (value.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public float? ViewZoom {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentAttributeKey.NSViewZoomDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSViewZoomDocumentAttribute);
|
||||
else
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSViewZoomDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSDocumentViewMode? ViewMode {
|
||||
get {
|
||||
var value = GetInt32Value (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute);
|
||||
if (value is null)
|
||||
return null;
|
||||
else
|
||||
return (NSDocumentViewMode) value.Value;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute);
|
||||
else
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute, (int) value.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReadOnly {
|
||||
get {
|
||||
var value = GetInt32Value (NSAttributedStringDocumentAttributeKey.NSReadOnlyDocumentAttribute);
|
||||
if (value is null || value.Value <= 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSReadOnlyDocumentAttribute, value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public UIColor? BackgroundColor {
|
||||
get {
|
||||
NSObject? value;
|
||||
Dictionary.TryGetValue (NSAttributedStringDocumentAttributeKey.NSBackgroundColorDocumentAttribute, out value);
|
||||
return value as UIColor;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSBackgroundColorDocumentAttribute);
|
||||
else
|
||||
Dictionary [NSAttributedStringDocumentAttributeKey.NSBackgroundColorDocumentAttribute] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float? HyphenationFactor {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentAttributeKey.NSHyphenationFactorDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSHyphenationFactorDocumentAttribute);
|
||||
else {
|
||||
if (value < 0 || value > 1.0f)
|
||||
throw new ArgumentException ("value must be between 0 and 1");
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSHyphenationFactorDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float? DefaultTabInterval {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentAttributeKey.NSDefaultTabIntervalDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSDefaultTabIntervalDocumentAttribute);
|
||||
else {
|
||||
if (value < 0 || value > 1.0f)
|
||||
throw new ArgumentException ("value must be between 0 and 1");
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSDefaultTabIntervalDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NSDictionary? WeakDefaultAttributes {
|
||||
get {
|
||||
NSObject? value;
|
||||
Dictionary.TryGetValue (NSAttributedStringDocumentAttributeKey.NSDefaultAttributesDocumentAttribute, out value);
|
||||
return value as NSDictionary;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentAttributeKey.NSDefaultAttributesDocumentAttribute);
|
||||
else
|
||||
Dictionary [NSAttributedStringDocumentAttributeKey.NSDefaultAttributesDocumentAttribute] = value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if !COREBUILD && !TVOS && !WATCH
|
||||
// documentation is unclear if an NSString or an NSUrl should be used...
|
||||
// but providing an `NSString` throws a `NSInvalidArgumentException Reason: (null) is not a file URL`
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos10.15")]
|
||||
[SupportedOSPlatform ("ios13.0")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
#else
|
||||
[Mac (10, 15)]
|
||||
[iOS (13, 0)]
|
||||
#endif
|
||||
public NSUrl? ReadAccessUrl {
|
||||
get {
|
||||
Dictionary.TryGetValue (NSAttributedStringDocumentReadingOptionKeys.ReadAccessUrlKey, out var value);
|
||||
return value as NSUrl;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSAttributedStringDocumentReadingOptionKeys.ReadAccessUrlKey);
|
||||
else
|
||||
Dictionary [NSAttributedStringDocumentReadingOptionKeys.ReadAccessUrlKey] = value;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -136,164 +136,6 @@ namespace Foundation
|
|||
return attr is null ? null : new NSStringAttributes (attr);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class NSAttributedStringDocumentAttributes : DictionaryContainer {
|
||||
public NSAttributedStringDocumentAttributes () : base (new NSMutableDictionary ()) {}
|
||||
public NSAttributedStringDocumentAttributes (NSDictionary dictionary) : base (dictionary) {}
|
||||
|
||||
public WebPreferences? WebPreferences {
|
||||
get {
|
||||
NSObject value;
|
||||
Dictionary.TryGetValue (NSStringAttributeKey.NSWebPreferencesDocumentOption, out value);
|
||||
return value as WebPreferences;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSStringAttributeKey.NSWebPreferencesDocumentOption);
|
||||
else
|
||||
Dictionary [NSStringAttributeKey.NSWebPreferencesDocumentOption] = value;
|
||||
}
|
||||
}
|
||||
public NSObject? WebResourceLoadDelegate {
|
||||
get {
|
||||
NSObject value;
|
||||
Dictionary.TryGetValue (NSStringAttributeKey.NSWebResourceLoadDelegateDocumentOption, out value);
|
||||
return value;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSStringAttributeKey.NSWebResourceLoadDelegateDocumentOption);
|
||||
else
|
||||
Dictionary [NSStringAttributeKey.NSWebResourceLoadDelegateDocumentOption] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public NSStringEncoding? StringEncoding {
|
||||
get {
|
||||
var value = GetInt32Value (NSStringAttributeKey.NSCharacterEncodingDocumentOption);
|
||||
if (value is null)
|
||||
return null;
|
||||
else
|
||||
return (NSStringEncoding) value.Value;
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSStringAttributeKey.NSCharacterEncodingDocumentOption, (int?) value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSString? WeakDocumentType {
|
||||
get {
|
||||
return GetNSStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSDocumentType DocumentType {
|
||||
get {
|
||||
var s = GetNSStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption);
|
||||
|
||||
if (s == NSAttributedStringDocumentType.NSPlainTextDocumentType)
|
||||
return NSDocumentType.PlainText;
|
||||
if (s == NSAttributedStringDocumentType.NSRtfTextDocumentType)
|
||||
return NSDocumentType.RTF;
|
||||
if (s == NSAttributedStringDocumentType.NSRtfdTextDocumentType)
|
||||
return NSDocumentType.RTFD;
|
||||
if (s == NSAttributedStringDocumentType.NSMacSimpleTextDocumentType)
|
||||
return NSDocumentType.MacSimpleText;
|
||||
if (s == NSAttributedStringDocumentType.NSHtmlTextDocumentType)
|
||||
return NSDocumentType.HTML;
|
||||
if (s == NSAttributedStringDocumentType.NSDocFormatTextDocumentType)
|
||||
return NSDocumentType.DocFormat;
|
||||
if (s == NSAttributedStringDocumentType.NSWordMLTextDocumentType)
|
||||
return NSDocumentType.WordML;
|
||||
if (s == NSAttributedStringDocumentType.NSWebArchiveTextDocumentType)
|
||||
return NSDocumentType.WebArchive;
|
||||
if (s == NSAttributedStringDocumentType.NSOfficeOpenXMLTextDocumentType)
|
||||
return NSDocumentType.OfficeOpenXml;
|
||||
if (s == NSAttributedStringDocumentType.NSOpenDocumentTextDocumentType)
|
||||
return NSDocumentType.OpenDocument;
|
||||
return NSDocumentType.Unknown;
|
||||
}
|
||||
|
||||
set {
|
||||
switch (value){
|
||||
case NSDocumentType.PlainText:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSPlainTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.RTFD:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSRtfdTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.RTF:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSRtfTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.HTML:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSHtmlTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.MacSimpleText:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSMacSimpleTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.DocFormat:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSDocFormatTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.WordML:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSWordMLTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.WebArchive:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSWebArchiveTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.OfficeOpenXml:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSOfficeOpenXMLTextDocumentType);
|
||||
break;
|
||||
case NSDocumentType.OpenDocument:
|
||||
SetStringValue (NSStringAttributeKey.NSDocumentTypeDocumentOption, NSAttributedStringDocumentType.NSOpenDocumentTextDocumentType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NSDictionary? WeakDefaultAttributes {
|
||||
get {
|
||||
NSObject value;
|
||||
Dictionary.TryGetValue (NSStringAttributeKey.NSDefaultAttributesDocumentOption, out value);
|
||||
return value as NSDictionary;
|
||||
}
|
||||
set {
|
||||
if (value is null)
|
||||
RemoveValue (NSStringAttributeKey.NSDefaultAttributesDocumentOption);
|
||||
else
|
||||
Dictionary [NSStringAttributeKey.NSDefaultAttributesDocumentOption] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public NSUrl? BaseUrl {
|
||||
get {
|
||||
return GetNativeValue <NSUrl> (NSStringAttributeKey.NSBaseURLDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSStringAttributeKey.NSBaseURLDocumentOption, value);
|
||||
}
|
||||
}
|
||||
|
||||
public string? TextEncodingName {
|
||||
get {
|
||||
return (string)GetNSStringValue (NSStringAttributeKey.NSTextEncodingNameDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetStringValue (NSStringAttributeKey.NSTextEncodingNameDocumentOption, (NSString)value);
|
||||
}
|
||||
}
|
||||
public float? TextSizeMultiplier {
|
||||
get { return GetFloatValue (NSStringAttributeKey.NSTextSizeMultiplierDocumentOption); }
|
||||
set { SetNumberValue (NSStringAttributeKey.NSTextSizeMultiplierDocumentOption, (float?) value); }
|
||||
}
|
||||
|
||||
public float? Timeout {
|
||||
get { return GetFloatValue (NSStringAttributeKey.NSTimeoutDocumentOption); }
|
||||
set { SetNumberValue (NSStringAttributeKey.NSTimeoutDocumentOption, (float?)value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MONOMAC
|
||||
|
|
|
@ -0,0 +1,383 @@
|
|||
//
|
||||
// NSAttributedStringDocumentAttributes.cs
|
||||
//
|
||||
// Authors:
|
||||
// Rolf Bjarne Kvinge (rolf@xamarin.com)
|
||||
//
|
||||
// Copyright 2022 Microsoft Corp
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
|
||||
#if HAS_APPKIT
|
||||
using AppKit;
|
||||
#endif
|
||||
using CoreGraphics;
|
||||
using Foundation;
|
||||
#if HAS_UIKIT
|
||||
using UIKit;
|
||||
#endif
|
||||
#if !COREBUILD && HAS_WEBKIT
|
||||
using WebKit;
|
||||
#endif
|
||||
|
||||
#if !COREBUILD
|
||||
#if __MACOS__
|
||||
using XColor = AppKit.NSColor;
|
||||
#else
|
||||
using XColor = UIKit.UIColor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace Foundation {
|
||||
public partial class NSAttributedStringDocumentAttributes : DictionaryContainer {
|
||||
#if !COREBUILD
|
||||
public NSAttributedStringDocumentAttributes () { }
|
||||
public NSAttributedStringDocumentAttributes (NSDictionary? dictionary) : base (dictionary) { }
|
||||
|
||||
public XColor? BackgroundColor {
|
||||
get {
|
||||
return GetNativeValue<XColor> (NSAttributedStringDocumentAttributeKey.NSBackgroundColorDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSAttributedStringDocumentAttributeKey.NSBackgroundColorDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float? DefaultTabInterval {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentAttributeKey.NSDefaultTabIntervalDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
if (value < 0 || value > 1.0f)
|
||||
throw new ArgumentOutOfRangeException (nameof (value), value, "Value must be between 0 and 1");
|
||||
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSDefaultTabIntervalDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float? HyphenationFactor {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentAttributeKey.NSHyphenationFactorDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
if (value < 0 || value > 1.0f)
|
||||
throw new ArgumentOutOfRangeException (nameof (value), value, "Value must be between 0 and 1");
|
||||
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSHyphenationFactorDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSStringEncoding? StringEncoding {
|
||||
get {
|
||||
return (NSStringEncoding?) (long?) GetNIntValue (NSAttributedStringDocumentAttributeKey.NSCharacterEncodingDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSCharacterEncodingDocumentAttribute, (nint?) (long?) value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSString? WeakDocumentType {
|
||||
get {
|
||||
return GetNSStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetStringValue (NSAttributedStringDocumentAttributeKey.NSDocumentTypeDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSDocumentType DocumentType {
|
||||
get {
|
||||
var s = WeakDocumentType;
|
||||
|
||||
if (s == NSAttributedStringDocumentType.NSPlainTextDocumentType)
|
||||
return NSDocumentType.PlainText;
|
||||
if (s == NSAttributedStringDocumentType.NSRtfdTextDocumentType)
|
||||
return NSDocumentType.RTFD;
|
||||
if (s == NSAttributedStringDocumentType.NSRtfTextDocumentType)
|
||||
return NSDocumentType.RTF;
|
||||
if (s == NSAttributedStringDocumentType.NSHtmlTextDocumentType)
|
||||
return NSDocumentType.HTML;
|
||||
|
||||
#if __MACOS__
|
||||
if (s == NSAttributedStringDocumentType.NSMacSimpleTextDocumentType)
|
||||
return NSDocumentType.MacSimpleText;
|
||||
if (s == NSAttributedStringDocumentType.NSDocFormatTextDocumentType)
|
||||
return NSDocumentType.DocFormat;
|
||||
if (s == NSAttributedStringDocumentType.NSWordMLTextDocumentType)
|
||||
return NSDocumentType.WordML;
|
||||
if (s == NSAttributedStringDocumentType.NSWebArchiveTextDocumentType)
|
||||
return NSDocumentType.WebArchive;
|
||||
if (s == NSAttributedStringDocumentType.NSOfficeOpenXMLTextDocumentType)
|
||||
return NSDocumentType.OfficeOpenXml;
|
||||
if (s == NSAttributedStringDocumentType.NSOpenDocumentTextDocumentType)
|
||||
return NSDocumentType.OpenDocument;
|
||||
#endif // __MACOS__
|
||||
|
||||
return NSDocumentType.Unknown;
|
||||
}
|
||||
|
||||
set {
|
||||
NSString? documentType = null;
|
||||
switch (value) {
|
||||
case NSDocumentType.PlainText:
|
||||
documentType = NSAttributedStringDocumentType.NSPlainTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.RTFD:
|
||||
documentType = NSAttributedStringDocumentType.NSRtfdTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.RTF:
|
||||
documentType = NSAttributedStringDocumentType.NSRtfTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.HTML:
|
||||
documentType = NSAttributedStringDocumentType.NSHtmlTextDocumentType;
|
||||
break;
|
||||
#if __MACOS__
|
||||
case NSDocumentType.MacSimpleText:
|
||||
documentType = NSAttributedStringDocumentType.NSMacSimpleTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.DocFormat:
|
||||
documentType = NSAttributedStringDocumentType.NSDocFormatTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.WordML:
|
||||
documentType = NSAttributedStringDocumentType.NSWordMLTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.WebArchive:
|
||||
documentType = NSAttributedStringDocumentType.NSWebArchiveTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.OfficeOpenXml:
|
||||
documentType = NSAttributedStringDocumentType.NSOfficeOpenXMLTextDocumentType;
|
||||
break;
|
||||
case NSDocumentType.OpenDocument:
|
||||
documentType = NSAttributedStringDocumentType.NSOpenDocumentTextDocumentType;
|
||||
break;
|
||||
#endif // __MACOS__
|
||||
}
|
||||
|
||||
if (documentType is not null)
|
||||
WeakDocumentType = documentType;
|
||||
}
|
||||
}
|
||||
|
||||
public NSDictionary? WeakDefaultAttributes {
|
||||
get {
|
||||
return GetNativeValue<NSDictionary> (NSAttributedStringDocumentAttributeKey.NSDefaultAttributesDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSAttributedStringDocumentAttributeKey.NSDefaultAttributesDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public CGSize? PaperSize {
|
||||
get {
|
||||
return GetCGSizeValue (NSAttributedStringDocumentAttributeKey.NSPaperSizeDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetCGSizeValue (NSAttributedStringDocumentAttributeKey.NSPaperSizeDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
#if !__MACOS__
|
||||
#if NET
|
||||
[SupportedOSPlatform ("ios")]
|
||||
[SupportedOSPlatform ("tvos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
[UnsupportedOSPlatform ("macos")]
|
||||
#endif // NET
|
||||
public UIEdgeInsets? PaperMargin {
|
||||
get {
|
||||
if (!Dictionary.TryGetValue (NSAttributedStringDocumentAttributeKey.NSPaperMarginDocumentAttribute, out var value))
|
||||
return null;
|
||||
|
||||
if (value is NSValue size)
|
||||
return size.UIEdgeInsetsValue;
|
||||
|
||||
return null;
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSAttributedStringDocumentAttributeKey.NSPaperMarginDocumentAttribute, value is null ? null : NSValue.FromUIEdgeInsets (value.Value));
|
||||
}
|
||||
}
|
||||
#endif // !__MACOS__
|
||||
|
||||
public CGSize? ViewSize {
|
||||
get {
|
||||
return GetCGSizeValue (NSAttributedStringDocumentAttributeKey.NSViewSizeDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetCGSizeValue (NSAttributedStringDocumentAttributeKey.NSViewSizeDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public float? ViewZoom {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentAttributeKey.NSViewZoomDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSViewZoomDocumentAttribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
public NSDocumentViewMode? ViewMode {
|
||||
get {
|
||||
return (NSDocumentViewMode?) GetInt32Value (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute);
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSViewModeDocumentAttribute, value is null ? null : (int) value.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#if XAMCORE_5_0 || __MACOS__
|
||||
public bool? ReadOnly {
|
||||
get {
|
||||
var value = GetInt32Value (NSAttributedStringDocumentAttributeKey.NSReadOnlyDocumentAttribute);
|
||||
if (value is null)
|
||||
return null;
|
||||
return value.Value == 1;
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSReadOnlyDocumentAttribute, value is null ? null : (value.Value ? 1 : 0));
|
||||
}
|
||||
}
|
||||
#else
|
||||
public bool ReadOnly {
|
||||
get {
|
||||
var value = GetInt32Value (NSAttributedStringDocumentAttributeKey.NSReadOnlyDocumentAttribute);
|
||||
if (value is null || value.Value != 1)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentAttributeKey.NSReadOnlyDocumentAttribute, value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
#endif // XAMCORE_5_0 || __MACOS__
|
||||
|
||||
#if !TVOS && !WATCH
|
||||
// documentation is unclear if an NSString or an NSUrl should be used...
|
||||
// but providing an `NSString` throws a `NSInvalidArgumentException Reason: (null) is not a file URL`
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos10.15")]
|
||||
[SupportedOSPlatform ("ios13.0")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
#else
|
||||
[Mac (10, 15)]
|
||||
[iOS (13, 0)]
|
||||
#endif
|
||||
public NSUrl? ReadAccessUrl {
|
||||
get {
|
||||
return GetNativeValue<NSUrl> (NSAttributedStringDocumentReadingOptionKeys.ReadAccessUrlKey);
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSAttributedStringDocumentReadingOptionKeys.ReadAccessUrlKey, value);
|
||||
}
|
||||
}
|
||||
#endif // !TVOS && !WATCH
|
||||
|
||||
#if __MACOS__
|
||||
#if NET
|
||||
[UnsupportedOSPlatform ("ios")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
[UnsupportedOSPlatform ("maccatalyst")]
|
||||
[SupportedOSPlatform ("macos")]
|
||||
#endif // NET
|
||||
public WebPreferences? WebPreferences {
|
||||
get {
|
||||
return GetNativeValue<WebPreferences> (NSAttributedStringDocumentReadingOptionKey.NSWebPreferencesDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSAttributedStringDocumentReadingOptionKey.NSWebPreferencesDocumentOption, value);
|
||||
}
|
||||
}
|
||||
#endif // !__MACOS__
|
||||
|
||||
#if __MACOS__
|
||||
#if NET
|
||||
[UnsupportedOSPlatform ("ios")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
[UnsupportedOSPlatform ("maccatalyst")]
|
||||
[SupportedOSPlatform ("macos")]
|
||||
#endif // NET
|
||||
public NSObject? WebResourceLoadDelegate {
|
||||
get {
|
||||
return GetNativeValue<NSObject> (NSAttributedStringDocumentReadingOptionKey.NSWebResourceLoadDelegateDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSAttributedStringDocumentReadingOptionKey.NSWebResourceLoadDelegateDocumentOption, value);
|
||||
}
|
||||
}
|
||||
#endif // !__MACOS__
|
||||
|
||||
#if __MACOS__
|
||||
#if NET
|
||||
[UnsupportedOSPlatform ("ios")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
[UnsupportedOSPlatform ("maccatalyst")]
|
||||
[SupportedOSPlatform ("macos")]
|
||||
#endif // NET
|
||||
public NSUrl? BaseUrl {
|
||||
get {
|
||||
return GetNativeValue<NSUrl> (NSAttributedStringDocumentReadingOptionKey.NSBaseURLDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetNativeValue (NSAttributedStringDocumentReadingOptionKey.NSBaseURLDocumentOption, value);
|
||||
}
|
||||
}
|
||||
#endif // !__MACOS__
|
||||
|
||||
#if __MACOS__
|
||||
#if NET
|
||||
[UnsupportedOSPlatform ("ios")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
[UnsupportedOSPlatform ("maccatalyst")]
|
||||
[SupportedOSPlatform ("macos")]
|
||||
#endif // NET
|
||||
public string? TextEncodingName {
|
||||
get {
|
||||
return GetStringValue (NSAttributedStringDocumentReadingOptionKey.NSTextEncodingNameDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetStringValue (NSAttributedStringDocumentReadingOptionKey.NSTextEncodingNameDocumentOption, value);
|
||||
}
|
||||
}
|
||||
#endif // !__MACOS__
|
||||
|
||||
#if __MACOS__
|
||||
#if NET
|
||||
[UnsupportedOSPlatform ("ios")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
[UnsupportedOSPlatform ("maccatalyst")]
|
||||
[SupportedOSPlatform ("macos")]
|
||||
#endif // NET
|
||||
public float? TextSizeMultiplier {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentReadingOptionKey.NSTextSizeMultiplierDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentReadingOptionKey.NSTextSizeMultiplierDocumentOption, value);
|
||||
}
|
||||
}
|
||||
#endif // !__MACOS__
|
||||
|
||||
#if __MACOS__
|
||||
#if NET
|
||||
[UnsupportedOSPlatform ("ios")]
|
||||
[UnsupportedOSPlatform ("tvos")]
|
||||
[UnsupportedOSPlatform ("maccatalyst")]
|
||||
[SupportedOSPlatform ("macos")]
|
||||
#endif // NET
|
||||
public float? Timeout {
|
||||
get {
|
||||
return GetFloatValue (NSAttributedStringDocumentReadingOptionKey.NSTimeoutDocumentOption);
|
||||
}
|
||||
set {
|
||||
SetNumberValue (NSAttributedStringDocumentReadingOptionKey.NSTimeoutDocumentOption, value);
|
||||
}
|
||||
}
|
||||
#endif // !__MACOS__
|
||||
|
||||
#endif // !COREBUILD
|
||||
}
|
||||
}
|
|
@ -15524,33 +15524,6 @@ namespace AppKit {
|
|||
NSString TextEffect { get; }
|
||||
|
||||
// Internal
|
||||
[Internal, Field ("NSDocumentTypeDocumentOption")]
|
||||
NSString NSDocumentTypeDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSDefaultAttributesDocumentOption")]
|
||||
NSString NSDefaultAttributesDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSCharacterEncodingDocumentOption")]
|
||||
NSString NSCharacterEncodingDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSTextEncodingNameDocumentOption")]
|
||||
NSString NSTextEncodingNameDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSBaseURLDocumentOption")]
|
||||
NSString NSBaseURLDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSTimeoutDocumentOption")]
|
||||
NSString NSTimeoutDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSWebPreferencesDocumentOption")]
|
||||
NSString NSWebPreferencesDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSWebResourceLoadDelegateDocumentOption")]
|
||||
NSString NSWebResourceLoadDelegateDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSTextSizeMultiplierDocumentOption")]
|
||||
NSString NSTextSizeMultiplierDocumentOption { get; }
|
||||
|
||||
[Internal, Field ("NSFileTypeDocumentOption")]
|
||||
NSString NSFileTypeDocumentOption { get; }
|
||||
|
||||
|
|
|
@ -284,10 +284,6 @@ namespace Foundation {
|
|||
#endif
|
||||
}
|
||||
|
||||
#if MONOMAC
|
||||
interface NSAttributedStringDocumentAttributes { }
|
||||
#endif
|
||||
|
||||
[BaseType (typeof (NSObject))]
|
||||
partial interface NSAttributedString : NSCoding, NSMutableCopying, NSSecureCoding
|
||||
#if MONOMAC
|
||||
|
|
|
@ -786,7 +786,7 @@ FOUNDATION_CORE_SOURCES = \
|
|||
Foundation/ProtocolAttribute.cs \
|
||||
Foundation/RegisterAttribute.cs \
|
||||
Foundation/NSObject.iOS.cs \
|
||||
Foundation/NSAttributedString.iOS.cs \
|
||||
Foundation/NSAttributedStringDocumentAttributes.cs \
|
||||
Foundation/NSObject.mac.cs \
|
||||
Foundation/NSDateComponents.cs \
|
||||
Foundation/XpcInterfaceAttribute.cs \
|
||||
|
|
29
src/xkit.cs
29
src/xkit.cs
|
@ -4381,4 +4381,33 @@ namespace UIKit {
|
|||
[iOS (13, 0), TV (13, 0), Watch (6, 0)]
|
||||
NSString CocoaVersionDocumentAttribute { get; }
|
||||
}
|
||||
|
||||
[Static]
|
||||
[Internal]
|
||||
interface NSAttributedStringDocumentReadingOptionKey {
|
||||
|
||||
[NoiOS, NoTV, NoWatch, NoMacCatalyst]
|
||||
[Internal, Field ("NSWebPreferencesDocumentOption")]
|
||||
NSString NSWebPreferencesDocumentOption { get; }
|
||||
|
||||
[NoiOS, NoTV, NoWatch, NoMacCatalyst]
|
||||
[Internal, Field ("NSWebResourceLoadDelegateDocumentOption")]
|
||||
NSString NSWebResourceLoadDelegateDocumentOption { get; }
|
||||
|
||||
[NoiOS, NoTV, NoWatch, NoMacCatalyst]
|
||||
[Internal, Field ("NSBaseURLDocumentOption")]
|
||||
NSString NSBaseURLDocumentOption { get; }
|
||||
|
||||
[NoiOS, NoTV, NoWatch, NoMacCatalyst]
|
||||
[Internal, Field ("NSTextEncodingNameDocumentOption")]
|
||||
NSString NSTextEncodingNameDocumentOption { get; }
|
||||
|
||||
[NoiOS, NoTV, NoWatch, NoMacCatalyst]
|
||||
[Internal, Field ("NSTextSizeMultiplierDocumentOption")]
|
||||
NSString NSTextSizeMultiplierDocumentOption { get; }
|
||||
|
||||
[NoiOS, NoTV, NoWatch, NoMacCatalyst]
|
||||
[Internal, Field ("NSTimeoutDocumentOption")]
|
||||
NSString NSTimeoutDocumentOption { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
## unsorted
|
||||
|
||||
!unknown-field! item bound
|
||||
!missing-field! NSCharacterEncodingDocumentOption not bound
|
||||
!missing-field! NSDefaultAttributesDocumentOption not bound
|
||||
!missing-field! NSDocumentTypeDocumentOption not bound
|
||||
!missing-field! NSImageNameColumnViewTemplate not bound
|
||||
!missing-field! NSImageNameGoBackTemplate not bound
|
||||
!missing-field! NSImageNameGoForwardTemplate not bound
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
!missing-field! NSBadRTFStyleSheetException not bound
|
||||
!missing-field! NSBlack not bound
|
||||
!missing-field! NSBrowserIllegalDelegateException not bound
|
||||
!missing-field! NSCharacterEncodingDocumentOption not bound
|
||||
!missing-field! NSColorListDidChangeNotification not bound
|
||||
!missing-field! NSColorListIOException not bound
|
||||
!missing-field! NSColorListNotEditableException not bound
|
||||
|
@ -110,6 +111,7 @@
|
|||
!missing-field! NSCriticalValueBinding not bound
|
||||
!missing-field! NSDarkGray not bound
|
||||
!missing-field! NSDataBinding not bound
|
||||
!missing-field! NSDefaultAttributesDocumentOption not bound
|
||||
!missing-field! NSDefinitionPresentationTypeDictionaryApplication not bound
|
||||
!missing-field! NSDefinitionPresentationTypeKey not bound
|
||||
!missing-field! NSDefinitionPresentationTypeOverlay not bound
|
||||
|
@ -125,6 +127,7 @@
|
|||
!missing-field! NSDisplayPatternTitleBinding not bound
|
||||
!missing-field! NSDisplayPatternValueBinding not bound
|
||||
!missing-field! NSDocumentEditedBinding not bound
|
||||
!missing-field! NSDocumentTypeDocumentOption not bound
|
||||
!missing-field! NSDoubleClickArgumentBinding not bound
|
||||
!missing-field! NSDoubleClickTargetBinding not bound
|
||||
!missing-field! NSDraggingException not bound
|
||||
|
|
Загрузка…
Ссылка в новой задаче