diff --git a/packages/windows_data/lib/src/exports.g.dart b/packages/windows_data/lib/src/exports.g.dart index a086141a..380aa2bb 100644 --- a/packages/windows_data/lib/src/exports.g.dart +++ b/packages/windows_data/lib/src/exports.g.dart @@ -13,6 +13,15 @@ export 'json/jsonerrorstatus.dart'; export 'json/jsonobject.dart'; export 'json/jsonvalue.dart'; export 'json/jsonvaluetype.dart'; +export 'pdf/ipdfdocument.dart'; +export 'pdf/ipdfpage.dart'; +export 'pdf/ipdfpagedimensions.dart'; +export 'pdf/ipdfpagerenderoptions.dart'; +export 'pdf/pdfdocument.dart'; +export 'pdf/pdfpage.dart'; +export 'pdf/pdfpagedimensions.dart'; +export 'pdf/pdfpagerenderoptions.dart'; +export 'pdf/pdfpagerotation.dart'; export 'text/textsegment.dart'; export 'xml/dom/ixmlattribute.dart'; export 'xml/dom/ixmlcdatasection.dart'; diff --git a/packages/windows_data/lib/src/pdf/ipdfdocument.dart b/packages/windows_data/lib/src/pdf/ipdfdocument.dart new file mode 100644 index 00000000..c493b644 --- /dev/null +++ b/packages/windows_data/lib/src/pdf/ipdfdocument.dart @@ -0,0 +1,107 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +import 'pdfpage.dart'; + +/// @nodoc +const IID_IPdfDocument = '{ac7ebedd-80fa-4089-846e-81b77ff5a86c}'; + +class IPdfDocument extends IInspectable { + // vtable begins at 6, is 3 entries long. + IPdfDocument.fromPtr(super.ptr); + + factory IPdfDocument.from(IInspectable interface) => + interface.cast(IPdfDocument.fromPtr, IID_IPdfDocument); + + PdfPage? getPage(int pageIndex) { + final pdfPage = calloc(); + + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Uint32 pageIndex, + Pointer pdfPage)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, int pageIndex, + Pointer pdfPage)>()( + ptr.ref.lpVtbl, pageIndex, pdfPage); + + if (FAILED(hr)) { + free(pdfPage); + throwWindowsException(hr); + } + + if (pdfPage.isNull) { + free(pdfPage); + return null; + } + + return PdfPage.fromPtr(pdfPage); + } + + int get pageCount { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.value; + } finally { + free(value); + } + } + + bool get isPasswordProtected { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.value; + } finally { + free(value); + } + } +} diff --git a/packages/windows_data/lib/src/pdf/ipdfdocumentstatics.dart b/packages/windows_data/lib/src/pdf/ipdfdocumentstatics.dart new file mode 100644 index 00000000..7b864b83 --- /dev/null +++ b/packages/windows_data/lib/src/pdf/ipdfdocumentstatics.dart @@ -0,0 +1,149 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'pdfdocument.dart'; + +/// @nodoc +const IID_IPdfDocumentStatics = '{433a0b5f-c007-4788-90f2-08143d922599}'; + +class IPdfDocumentStatics extends IInspectable { + // vtable begins at 6, is 4 entries long. + IPdfDocumentStatics.fromPtr(super.ptr); + + factory IPdfDocumentStatics.from(IInspectable interface) => + interface.cast(IPdfDocumentStatics.fromPtr, IID_IPdfDocumentStatics); + + Future loadFromFileAsync(IStorageFile? file) { + final asyncInfo = calloc(); + + final hr = + ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer file, + Pointer asyncInfo)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer file, + Pointer asyncInfo)>()( + ptr.ref.lpVtbl, file.lpVtbl, asyncInfo); + + if (FAILED(hr)) { + free(asyncInfo); + throwWindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(asyncInfo, + creator: PdfDocument.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future loadFromFileWithPasswordAsync( + IStorageFile? file, String password) { + final asyncInfo = calloc(); + + final hr = + ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer file, + IntPtr password, + Pointer asyncInfo)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer file, + int password, Pointer asyncInfo)>()( + ptr.ref.lpVtbl, file.lpVtbl, password.toHString(), asyncInfo); + + if (FAILED(hr)) { + free(asyncInfo); + throwWindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(asyncInfo, + creator: PdfDocument.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future loadFromStreamAsync(IRandomAccessStream? inputStream) { + final asyncInfo = calloc(); + + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer inputStream, + Pointer asyncInfo)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer inputStream, + Pointer asyncInfo)>()( + ptr.ref.lpVtbl, inputStream.lpVtbl, asyncInfo); + + if (FAILED(hr)) { + free(asyncInfo); + throwWindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(asyncInfo, + creator: PdfDocument.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } + + Future loadFromStreamWithPasswordAsync( + IRandomAccessStream? inputStream, String password) { + final asyncInfo = calloc(); + + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer inputStream, + IntPtr password, + Pointer asyncInfo)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer inputStream, + int password, Pointer asyncInfo)>()( + ptr.ref.lpVtbl, inputStream.lpVtbl, password.toHString(), asyncInfo); + + if (FAILED(hr)) { + free(asyncInfo); + throwWindowsException(hr); + } + + final asyncOperation = IAsyncOperation.fromPtr(asyncInfo, + creator: PdfDocument.fromPtr); + return asyncOperation.toFuture(asyncOperation.getResults); + } +} diff --git a/packages/windows_data/lib/src/pdf/ipdfpage.dart b/packages/windows_data/lib/src/pdf/ipdfpage.dart new file mode 100644 index 00000000..82e67204 --- /dev/null +++ b/packages/windows_data/lib/src/pdf/ipdfpage.dart @@ -0,0 +1,234 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'pdfpagedimensions.dart'; +import 'pdfpagerenderoptions.dart'; +import 'pdfpagerotation.dart'; + +/// @nodoc +const IID_IPdfPage = '{9db4b0c8-5320-4cfc-ad76-493fdad0e594}'; + +class IPdfPage extends IInspectable { + // vtable begins at 6, is 8 entries long. + IPdfPage.fromPtr(super.ptr); + + factory IPdfPage.from(IInspectable interface) => + interface.cast(IPdfPage.fromPtr, IID_IPdfPage); + + Future renderToStreamAsync(IRandomAccessStream? outputStream) { + final asyncInfo = calloc(); + + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer outputStream, + Pointer asyncInfo)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer outputStream, + Pointer asyncInfo)>()( + ptr.ref.lpVtbl, outputStream.lpVtbl, asyncInfo); + + if (FAILED(hr)) { + free(asyncInfo); + throwWindowsException(hr); + } + + return IAsyncAction.fromPtr(asyncInfo).toFuture(); + } + + Future renderWithOptionsToStreamAsync( + IRandomAccessStream? outputStream, PdfPageRenderOptions? options) { + final asyncInfo = calloc(); + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, + VTablePointer outputStream, + VTablePointer options, + Pointer asyncInfo)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, VTablePointer outputStream, + VTablePointer options, Pointer asyncInfo)>()( + ptr.ref.lpVtbl, outputStream.lpVtbl, options.lpVtbl, asyncInfo); + + if (FAILED(hr)) { + free(asyncInfo); + throwWindowsException(hr); + } + + return IAsyncAction.fromPtr(asyncInfo).toFuture(); + } + + Future preparePageAsync() { + final asyncInfo = calloc(); + + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer asyncInfo)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer asyncInfo)>()(ptr.ref.lpVtbl, asyncInfo); + + if (FAILED(hr)) { + free(asyncInfo); + throwWindowsException(hr); + } + + return IAsyncAction.fromPtr(asyncInfo).toFuture(); + } + + int get index { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.value; + } finally { + free(value); + } + } + + Size get size { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(10) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } + + PdfPageDimensions? get dimensions { + final value = calloc(); + + final hr = ptr.ref.vtable + .elementAt(11) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) { + free(value); + throwWindowsException(hr); + } + + if (value.isNull) { + free(value); + return null; + } + + return PdfPageDimensions.fromPtr(value); + } + + PdfPageRotation get rotation { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(12) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return PdfPageRotation.from(value.value); + } finally { + free(value); + } + } + + double get preferredZoom { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(13) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.value; + } finally { + free(value); + } + } +} diff --git a/packages/windows_data/lib/src/pdf/ipdfpagedimensions.dart b/packages/windows_data/lib/src/pdf/ipdfpagedimensions.dart new file mode 100644 index 00000000..d1a80fe6 --- /dev/null +++ b/packages/windows_data/lib/src/pdf/ipdfpagedimensions.dart @@ -0,0 +1,148 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +/// @nodoc +const IID_IPdfPageDimensions = '{22170471-313e-44e8-835d-63a3e7624a10}'; + +class IPdfPageDimensions extends IInspectable { + // vtable begins at 6, is 5 entries long. + IPdfPageDimensions.fromPtr(super.ptr); + + factory IPdfPageDimensions.from(IInspectable interface) => + interface.cast(IPdfPageDimensions.fromPtr, IID_IPdfPageDimensions); + + Rect get mediaBox { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } + + Rect get cropBox { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } + + Rect get bleedBox { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } + + Rect get trimBox { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } + + Rect get artBox { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(10) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } +} diff --git a/packages/windows_data/lib/src/pdf/ipdfpagerenderoptions.dart b/packages/windows_data/lib/src/pdf/ipdfpagerenderoptions.dart new file mode 100644 index 00000000..3e79e34b --- /dev/null +++ b/packages/windows_data/lib/src/pdf/ipdfpagerenderoptions.dart @@ -0,0 +1,276 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_ui/windows_ui.dart'; + +/// @nodoc +const IID_IPdfPageRenderOptions = '{3c98056f-b7cf-4c29-9a04-52d90267f425}'; + +class IPdfPageRenderOptions extends IInspectable { + // vtable begins at 6, is 12 entries long. + IPdfPageRenderOptions.fromPtr(super.ptr); + + factory IPdfPageRenderOptions.from(IInspectable interface) => + interface.cast(IPdfPageRenderOptions.fromPtr, IID_IPdfPageRenderOptions); + + Rect get sourceRect { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(6) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } + + set sourceRect(Rect value) { + final valueNativeStructPtr = value.toNative(); + + final hr = ptr.ref.vtable + .elementAt(7) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, NativeRect value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, valueNativeStructPtr.ref); + + free(valueNativeStructPtr); + + if (FAILED(hr)) throwWindowsException(hr); + } + + int get destinationWidth { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(8) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.value; + } finally { + free(value); + } + } + + set destinationWidth(int value) { + final hr = + ptr.ref.vtable + .elementAt(9) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Uint32 value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + } + + int get destinationHeight { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(10) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.value; + } finally { + free(value); + } + } + + set destinationHeight(int value) { + final hr = + ptr.ref.vtable + .elementAt(11) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Uint32 value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + } + + Color get backgroundColor { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(12) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, + Pointer value)>()(ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDart(); + } finally { + free(value); + } + } + + set backgroundColor(Color value) { + final valueNativeStructPtr = value.toNative(); + + final hr = ptr.ref.vtable + .elementAt(13) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, NativeColor value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, NativeColor value)>()( + ptr.ref.lpVtbl, valueNativeStructPtr.ref); + + free(valueNativeStructPtr); + + if (FAILED(hr)) throwWindowsException(hr); + } + + bool get isIgnoringHighContrast { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(14) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.value; + } finally { + free(value); + } + } + + set isIgnoringHighContrast(bool value) { + final hr = ptr.ref.vtable + .elementAt(15) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, Bool value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + } + + Guid get bitmapEncoderId { + final value = calloc(); + + try { + final hr = ptr.ref.vtable + .elementAt(16) + .cast< + Pointer< + NativeFunction< + HRESULT Function( + VTablePointer lpVtbl, Pointer value)>>>() + .value + .asFunction< + int Function(VTablePointer lpVtbl, Pointer value)>()( + ptr.ref.lpVtbl, value); + + if (FAILED(hr)) throwWindowsException(hr); + + return value.toDartGuid(); + } finally { + free(value); + } + } + + set bitmapEncoderId(Guid value) { + final valueNativeStructPtr = value.toNativeGUID(); + + final hr = ptr.ref.vtable + .elementAt(17) + .cast< + Pointer< + NativeFunction< + HRESULT Function(VTablePointer lpVtbl, GUID value)>>>() + .value + .asFunction()( + ptr.ref.lpVtbl, valueNativeStructPtr.ref); + + free(valueNativeStructPtr); + + if (FAILED(hr)) throwWindowsException(hr); + } +} diff --git a/packages/windows_data/lib/src/pdf/pdfdocument.dart b/packages/windows_data/lib/src/pdf/pdfdocument.dart new file mode 100644 index 00000000..0d4a1fc5 --- /dev/null +++ b/packages/windows_data/lib/src/pdf/pdfdocument.dart @@ -0,0 +1,63 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'ipdfdocument.dart'; +import 'ipdfdocumentstatics.dart'; +import 'pdfpage.dart'; + +/// Represents a Portable Document Format (PDF) document. +class PdfDocument extends IInspectable implements IPdfDocument { + PdfDocument.fromPtr(super.ptr); + + static const _className = 'Windows.Data.Pdf.PdfDocument'; + + static Future loadFromFileAsync(IStorageFile? file) => + createActivationFactory( + IPdfDocumentStatics.fromPtr, _className, IID_IPdfDocumentStatics) + .loadFromFileAsync(file); + + static Future loadFromFileWithPasswordAsync( + IStorageFile? file, String password) => + createActivationFactory( + IPdfDocumentStatics.fromPtr, _className, IID_IPdfDocumentStatics) + .loadFromFileWithPasswordAsync(file, password); + + static Future loadFromStreamAsync( + IRandomAccessStream? inputStream) => + createActivationFactory( + IPdfDocumentStatics.fromPtr, _className, IID_IPdfDocumentStatics) + .loadFromStreamAsync(inputStream); + + static Future loadFromStreamWithPasswordAsync( + IRandomAccessStream? inputStream, String password) => + createActivationFactory( + IPdfDocumentStatics.fromPtr, _className, IID_IPdfDocumentStatics) + .loadFromStreamWithPasswordAsync(inputStream, password); + + late final _iPdfDocument = IPdfDocument.from(this); + + @override + PdfPage? getPage(int pageIndex) => _iPdfDocument.getPage(pageIndex); + + @override + int get pageCount => _iPdfDocument.pageCount; + + @override + bool get isPasswordProtected => _iPdfDocument.isPasswordProtected; +} diff --git a/packages/windows_data/lib/src/pdf/pdfpage.dart b/packages/windows_data/lib/src/pdf/pdfpage.dart new file mode 100644 index 00000000..7d10d1ec --- /dev/null +++ b/packages/windows_data/lib/src/pdf/pdfpage.dart @@ -0,0 +1,62 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_storage/windows_storage.dart'; + +import 'ipdfpage.dart'; +import 'pdfpagedimensions.dart'; +import 'pdfpagerenderoptions.dart'; +import 'pdfpagerotation.dart'; + +/// Represents a single page in a Portable Document Format (PDF) document. +class PdfPage extends IInspectable implements IPdfPage, IClosable { + PdfPage.fromPtr(super.ptr); + + late final _iPdfPage = IPdfPage.from(this); + + @override + Future renderToStreamAsync(IRandomAccessStream? outputStream) => + _iPdfPage.renderToStreamAsync(outputStream); + + @override + Future renderWithOptionsToStreamAsync( + IRandomAccessStream? outputStream, PdfPageRenderOptions? options) => + _iPdfPage.renderWithOptionsToStreamAsync(outputStream, options); + + @override + Future preparePageAsync() => _iPdfPage.preparePageAsync(); + + @override + int get index => _iPdfPage.index; + + @override + Size get size => _iPdfPage.size; + + @override + PdfPageDimensions? get dimensions => _iPdfPage.dimensions; + + @override + PdfPageRotation get rotation => _iPdfPage.rotation; + + @override + double get preferredZoom => _iPdfPage.preferredZoom; + + late final _iClosable = IClosable.from(this); + + @override + void close() => _iClosable.close(); +} diff --git a/packages/windows_data/lib/src/pdf/pdfpagedimensions.dart b/packages/windows_data/lib/src/pdf/pdfpagedimensions.dart new file mode 100644 index 00000000..693b08cd --- /dev/null +++ b/packages/windows_data/lib/src/pdf/pdfpagedimensions.dart @@ -0,0 +1,42 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; + +import 'ipdfpagedimensions.dart'; + +/// Represents the dimensions of a single page in a Portable Document Format +/// (PDF) document. +class PdfPageDimensions extends IInspectable implements IPdfPageDimensions { + PdfPageDimensions.fromPtr(super.ptr); + + late final _iPdfPageDimensions = IPdfPageDimensions.from(this); + + @override + Rect get mediaBox => _iPdfPageDimensions.mediaBox; + + @override + Rect get cropBox => _iPdfPageDimensions.cropBox; + + @override + Rect get bleedBox => _iPdfPageDimensions.bleedBox; + + @override + Rect get trimBox => _iPdfPageDimensions.trimBox; + + @override + Rect get artBox => _iPdfPageDimensions.artBox; +} diff --git a/packages/windows_data/lib/src/pdf/pdfpagerenderoptions.dart b/packages/windows_data/lib/src/pdf/pdfpagerenderoptions.dart new file mode 100644 index 00000000..91480c5f --- /dev/null +++ b/packages/windows_data/lib/src/pdf/pdfpagerenderoptions.dart @@ -0,0 +1,74 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: constant_identifier_names, non_constant_identifier_names +// ignore_for_file: unnecessary_import, unused_import + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:ffi/ffi.dart'; +import 'package:win32/win32.dart' + hide DocumentProperties, WinRTStringConversion; +import 'package:windows_foundation/internal.dart'; +import 'package:windows_foundation/windows_foundation.dart'; +import 'package:windows_ui/windows_ui.dart'; + +import 'ipdfpagerenderoptions.dart'; + +/// Represents display settings for a single page of a Portable Document Format +/// (PDF) document, such as the page's background color and its encoding type. +class PdfPageRenderOptions extends IInspectable + implements IPdfPageRenderOptions { + PdfPageRenderOptions() : super(activateClass(_className)); + PdfPageRenderOptions.fromPtr(super.ptr); + + static const _className = 'Windows.Data.Pdf.PdfPageRenderOptions'; + + late final _iPdfPageRenderOptions = IPdfPageRenderOptions.from(this); + + @override + Rect get sourceRect => _iPdfPageRenderOptions.sourceRect; + + @override + set sourceRect(Rect value) => _iPdfPageRenderOptions.sourceRect = value; + + @override + int get destinationWidth => _iPdfPageRenderOptions.destinationWidth; + + @override + set destinationWidth(int value) => + _iPdfPageRenderOptions.destinationWidth = value; + + @override + int get destinationHeight => _iPdfPageRenderOptions.destinationHeight; + + @override + set destinationHeight(int value) => + _iPdfPageRenderOptions.destinationHeight = value; + + @override + Color get backgroundColor => _iPdfPageRenderOptions.backgroundColor; + + @override + set backgroundColor(Color value) => + _iPdfPageRenderOptions.backgroundColor = value; + + @override + bool get isIgnoringHighContrast => + _iPdfPageRenderOptions.isIgnoringHighContrast; + + @override + set isIgnoringHighContrast(bool value) => + _iPdfPageRenderOptions.isIgnoringHighContrast = value; + + @override + Guid get bitmapEncoderId => _iPdfPageRenderOptions.bitmapEncoderId; + + @override + set bitmapEncoderId(Guid value) => + _iPdfPageRenderOptions.bitmapEncoderId = value; +} diff --git a/packages/windows_data/lib/src/pdf/pdfpagerotation.dart b/packages/windows_data/lib/src/pdf/pdfpagerotation.dart new file mode 100644 index 00000000..1f5d1f7b --- /dev/null +++ b/packages/windows_data/lib/src/pdf/pdfpagerotation.dart @@ -0,0 +1,26 @@ +// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. +// All rights reserved. Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. + +// ignore_for_file: deprecated_member_use_from_same_package + +import 'package:windows_foundation/windows_foundation.dart'; + +/// Specifies the number of degrees that a page in a Portable Document Format +/// (PDF) document is rotated in the rendered output. +enum PdfPageRotation implements WinRTEnum { + normal(0), + rotate90(1), + rotate180(2), + rotate270(3); + + @override + final int value; + + const PdfPageRotation(this.value); + + factory PdfPageRotation.from(int value) => + PdfPageRotation.values.byValue(value); +} diff --git a/packages/winrtgen/assets/enums.json b/packages/winrtgen/assets/enums.json index b7b77355..76f8cd48 100644 --- a/packages/winrtgen/assets/enums.json +++ b/packages/winrtgen/assets/enums.json @@ -12,6 +12,7 @@ "Windows.ApplicationModel.StartupTaskState": "Represents the state (enabled, disabled, or disabled by user) of a startup task.", "Windows.Data.Json.JsonErrorStatus": "Defines errors encountered while parsing JSON data.", "Windows.Data.Json.JsonValueType": "Specifies the JSON value type of a JsonValue object.", + "Windows.Data.Pdf.PdfPageRotation": "Specifies the number of degrees that a page in a Portable Document Format (PDF) document is rotated in the rendered output.", "Windows.Data.Xml.Dom.NodeType": "The type of an IXmlNode, as returned by the NodeType property.", "Windows.Devices.Display.DisplayMonitorConnectionKind": "Defines constants that specify an abstract method in which a display is connected (not specific to a physical protocol).", "Windows.Devices.Display.DisplayMonitorDescriptorKind": "Defines constants that specify various kinds of display monitor hardware descriptor.", diff --git a/packages/winrtgen/assets/objects.json b/packages/winrtgen/assets/objects.json index 655b73cb..fde95129 100644 --- a/packages/winrtgen/assets/objects.json +++ b/packages/winrtgen/assets/objects.json @@ -39,6 +39,10 @@ "Windows.Data.Json.JsonArray": "Represents a JSON array.", "Windows.Data.Json.JsonObject": "Represents a JSON object containing a collection of name and [JsonValue] pairs.", "Windows.Data.Json.JsonValue": "Implements the [IJsonValue] interface which represents a JSON value.", + "Windows.Data.Pdf.PdfDocument": "Represents a Portable Document Format (PDF) document.", + "Windows.Data.Pdf.PdfPage": "Represents a single page in a Portable Document Format (PDF) document.", + "Windows.Data.Pdf.PdfPageDimensions": "Represents the dimensions of a single page in a Portable Document Format (PDF) document.", + "Windows.Data.Pdf.PdfPageRenderOptions": "Represents display settings for a single page of a Portable Document Format (PDF) document, such as the page's background color and its encoding type.", "Windows.Data.Xml.Dom.IXmlNode": "Contains information for the entire Document Object Model. This interface represents a single node in the document tree. While all objects that implement this interface expose methods for dealing with children, not all objects that implement this interface may have children.", "Windows.Data.Xml.Dom.XmlAttribute": "Represents an attribute of an XmlElement. Valid and default values for the attribute are defined in a document type definition (DTD) or schema.", "Windows.Data.Xml.Dom.XmlCDataSection": "Represents a CDATA section of an XML document.",