This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(windows_data): add
PdfDocument
APIs
- Loading branch information
1 parent
dbc4005
commit a1b366b
Showing
13 changed files
with
1,195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<COMObject>(); | ||
|
||
final hr = ptr.ref.vtable | ||
.elementAt(6) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function(VTablePointer lpVtbl, Uint32 pageIndex, | ||
Pointer<COMObject> pdfPage)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, int pageIndex, | ||
Pointer<COMObject> 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<Uint32>(); | ||
|
||
try { | ||
final hr = ptr.ref.vtable | ||
.elementAt(7) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, Pointer<Uint32> value)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, Pointer<Uint32> value)>()( | ||
ptr.ref.lpVtbl, value); | ||
|
||
if (FAILED(hr)) throwWindowsException(hr); | ||
|
||
return value.value; | ||
} finally { | ||
free(value); | ||
} | ||
} | ||
|
||
bool get isPasswordProtected { | ||
final value = calloc<Bool>(); | ||
|
||
try { | ||
final hr = ptr.ref.vtable | ||
.elementAt(8) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, Pointer<Bool> value)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, Pointer<Bool> value)>()( | ||
ptr.ref.lpVtbl, value); | ||
|
||
if (FAILED(hr)) throwWindowsException(hr); | ||
|
||
return value.value; | ||
} finally { | ||
free(value); | ||
} | ||
} | ||
} |
149 changes: 149 additions & 0 deletions
149
packages/windows_data/lib/src/pdf/ipdfdocumentstatics.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<PdfDocument?> loadFromFileAsync(IStorageFile? file) { | ||
final asyncInfo = calloc<COMObject>(); | ||
|
||
final hr = | ||
ptr.ref.vtable | ||
.elementAt(6) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, | ||
VTablePointer file, | ||
Pointer<COMObject> asyncInfo)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, VTablePointer file, | ||
Pointer<COMObject> asyncInfo)>()( | ||
ptr.ref.lpVtbl, file.lpVtbl, asyncInfo); | ||
|
||
if (FAILED(hr)) { | ||
free(asyncInfo); | ||
throwWindowsException(hr); | ||
} | ||
|
||
final asyncOperation = IAsyncOperation<PdfDocument?>.fromPtr(asyncInfo, | ||
creator: PdfDocument.fromPtr); | ||
return asyncOperation.toFuture(asyncOperation.getResults); | ||
} | ||
|
||
Future<PdfDocument?> loadFromFileWithPasswordAsync( | ||
IStorageFile? file, String password) { | ||
final asyncInfo = calloc<COMObject>(); | ||
|
||
final hr = | ||
ptr.ref.vtable | ||
.elementAt(7) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, | ||
VTablePointer file, | ||
IntPtr password, | ||
Pointer<COMObject> asyncInfo)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, VTablePointer file, | ||
int password, Pointer<COMObject> asyncInfo)>()( | ||
ptr.ref.lpVtbl, file.lpVtbl, password.toHString(), asyncInfo); | ||
|
||
if (FAILED(hr)) { | ||
free(asyncInfo); | ||
throwWindowsException(hr); | ||
} | ||
|
||
final asyncOperation = IAsyncOperation<PdfDocument?>.fromPtr(asyncInfo, | ||
creator: PdfDocument.fromPtr); | ||
return asyncOperation.toFuture(asyncOperation.getResults); | ||
} | ||
|
||
Future<PdfDocument?> loadFromStreamAsync(IRandomAccessStream? inputStream) { | ||
final asyncInfo = calloc<COMObject>(); | ||
|
||
final hr = ptr.ref.vtable | ||
.elementAt(8) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, | ||
VTablePointer inputStream, | ||
Pointer<COMObject> asyncInfo)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, VTablePointer inputStream, | ||
Pointer<COMObject> asyncInfo)>()( | ||
ptr.ref.lpVtbl, inputStream.lpVtbl, asyncInfo); | ||
|
||
if (FAILED(hr)) { | ||
free(asyncInfo); | ||
throwWindowsException(hr); | ||
} | ||
|
||
final asyncOperation = IAsyncOperation<PdfDocument?>.fromPtr(asyncInfo, | ||
creator: PdfDocument.fromPtr); | ||
return asyncOperation.toFuture(asyncOperation.getResults); | ||
} | ||
|
||
Future<PdfDocument?> loadFromStreamWithPasswordAsync( | ||
IRandomAccessStream? inputStream, String password) { | ||
final asyncInfo = calloc<COMObject>(); | ||
|
||
final hr = ptr.ref.vtable | ||
.elementAt(9) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, | ||
VTablePointer inputStream, | ||
IntPtr password, | ||
Pointer<COMObject> asyncInfo)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, VTablePointer inputStream, | ||
int password, Pointer<COMObject> asyncInfo)>()( | ||
ptr.ref.lpVtbl, inputStream.lpVtbl, password.toHString(), asyncInfo); | ||
|
||
if (FAILED(hr)) { | ||
free(asyncInfo); | ||
throwWindowsException(hr); | ||
} | ||
|
||
final asyncOperation = IAsyncOperation<PdfDocument?>.fromPtr(asyncInfo, | ||
creator: PdfDocument.fromPtr); | ||
return asyncOperation.toFuture(asyncOperation.getResults); | ||
} | ||
} |
Oops, something went wrong.