From ae1a70b24e2a2615b114a1af7257d5c7cdc4eedf Mon Sep 17 00:00:00 2001 From: Thomas Taschauer Date: Sun, 2 Feb 2025 08:52:58 +0100 Subject: [PATCH 1/3] fix PDF --- OpenDocumentReader/CoreWrapper.mm | 20 +++++ Podfile.lock | 118 +++++++++++++++--------------- 2 files changed, 79 insertions(+), 59 deletions(-) diff --git a/OpenDocumentReader/CoreWrapper.mm b/OpenDocumentReader/CoreWrapper.mm index 3b5e4f7..b14c988 100644 --- a/OpenDocumentReader/CoreWrapper.mm +++ b/OpenDocumentReader/CoreWrapper.mm @@ -47,6 +47,26 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath with:(NSStri auto inputPathC = [inputPath cStringUsingEncoding:NSUTF8StringEncoding]; auto inputPathCpp = std::string(inputPathC); + odr::FileType fileType; + try { + const auto types = odr::OpenDocumentReader::types(inputPathCpp); + if (types.empty()) { + _errorCode = @(-5); + return false; + } + + fileType = types.back(); + } catch (odr::UnsupportedFileType &e) { + _errorCode = @(-5); + return false; + } + + const auto extensionCpp = odr::OpenDocumentReader::type_to_string(fileType); + if (extensionCpp == "pdf") { + _errorCode = @(-5); + return false; + } + auto outputPathC = [outputPath cStringUsingEncoding:NSUTF8StringEncoding]; auto outputPathCpp = std::string(outputPathC); diff --git a/Podfile.lock b/Podfile.lock index e0f75b5..3598590 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,47 +1,47 @@ PODS: - - Firebase/Analytics (11.2.0): + - Firebase/Analytics (11.7.0): - Firebase/Core - - Firebase/Core (11.2.0): + - Firebase/Core (11.7.0): - Firebase/CoreOnly - - FirebaseAnalytics (~> 11.2.0) - - Firebase/CoreOnly (11.2.0): - - FirebaseCore (= 11.2.0) - - Firebase/Crashlytics (11.2.0): + - FirebaseAnalytics (~> 11.7.0) + - Firebase/CoreOnly (11.7.0): + - FirebaseCore (~> 11.7.0) + - Firebase/Crashlytics (11.7.0): - Firebase/CoreOnly - - FirebaseCrashlytics (~> 11.2.0) - - Firebase/Storage (11.2.0): + - FirebaseCrashlytics (~> 11.7.0) + - Firebase/Storage (11.7.0): - Firebase/CoreOnly - - FirebaseStorage (~> 11.2.0) - - FirebaseAnalytics (11.2.0): - - FirebaseAnalytics/AdIdSupport (= 11.2.0) - - FirebaseCore (~> 11.0) + - FirebaseStorage (~> 11.7.0) + - FirebaseAnalytics (11.7.0): + - FirebaseAnalytics/AdIdSupport (= 11.7.0) + - FirebaseCore (~> 11.7.0) - FirebaseInstallations (~> 11.0) - GoogleUtilities/AppDelegateSwizzler (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/Network (~> 8.0) - "GoogleUtilities/NSData+zlib (~> 8.0)" - nanopb (~> 3.30910.0) - - FirebaseAnalytics/AdIdSupport (11.2.0): - - FirebaseCore (~> 11.0) + - FirebaseAnalytics/AdIdSupport (11.7.0): + - FirebaseCore (~> 11.7.0) - FirebaseInstallations (~> 11.0) - - GoogleAppMeasurement (= 11.2.0) + - GoogleAppMeasurement (= 11.7.0) - GoogleUtilities/AppDelegateSwizzler (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/Network (~> 8.0) - "GoogleUtilities/NSData+zlib (~> 8.0)" - nanopb (~> 3.30910.0) - - FirebaseAppCheckInterop (11.2.0) - - FirebaseAuthInterop (11.2.0) - - FirebaseCore (11.2.0): - - FirebaseCoreInternal (~> 11.0) + - FirebaseAppCheckInterop (11.7.0) + - FirebaseAuthInterop (11.7.0) + - FirebaseCore (11.7.0): + - FirebaseCoreInternal (~> 11.7.0) - GoogleUtilities/Environment (~> 8.0) - GoogleUtilities/Logger (~> 8.0) - - FirebaseCoreExtension (11.2.0): - - FirebaseCore (~> 11.0) - - FirebaseCoreInternal (11.2.0): + - FirebaseCoreExtension (11.7.0): + - FirebaseCore (~> 11.7.0) + - FirebaseCoreInternal (11.7.0): - "GoogleUtilities/NSData+zlib (~> 8.0)" - - FirebaseCrashlytics (11.2.0): - - FirebaseCore (~> 11.0) + - FirebaseCrashlytics (11.7.0): + - FirebaseCore (~> 11.7.0) - FirebaseInstallations (~> 11.0) - FirebaseRemoteConfigInterop (~> 11.0) - FirebaseSessions (~> 11.0) @@ -49,45 +49,45 @@ PODS: - GoogleUtilities/Environment (~> 8.0) - nanopb (~> 3.30910.0) - PromisesObjC (~> 2.4) - - FirebaseInstallations (11.2.0): - - FirebaseCore (~> 11.0) + - FirebaseInstallations (11.7.0): + - FirebaseCore (~> 11.7.0) - GoogleUtilities/Environment (~> 8.0) - GoogleUtilities/UserDefaults (~> 8.0) - PromisesObjC (~> 2.4) - - FirebaseRemoteConfigInterop (11.2.0) - - FirebaseSessions (11.2.0): - - FirebaseCore (~> 11.0) - - FirebaseCoreExtension (~> 11.0) + - FirebaseRemoteConfigInterop (11.7.0) + - FirebaseSessions (11.7.0): + - FirebaseCore (~> 11.7.0) + - FirebaseCoreExtension (~> 11.7.0) - FirebaseInstallations (~> 11.0) - GoogleDataTransport (~> 10.0) - GoogleUtilities/Environment (~> 8.0) - GoogleUtilities/UserDefaults (~> 8.0) - nanopb (~> 3.30910.0) - PromisesSwift (~> 2.1) - - FirebaseStorage (11.2.0): + - FirebaseStorage (11.7.0): - FirebaseAppCheckInterop (~> 11.0) - FirebaseAuthInterop (~> 11.0) - - FirebaseCore (~> 11.0) - - FirebaseCoreExtension (~> 11.0) + - FirebaseCore (~> 11.7.0) + - FirebaseCoreExtension (~> 11.7.0) - GoogleUtilities/Environment (~> 8.0) - - GTMSessionFetcher/Core (~> 3.4) - - Google-Mobile-Ads-SDK (11.9.0): + - GTMSessionFetcher/Core (< 5.0, >= 3.4) + - Google-Mobile-Ads-SDK (11.13.0): - GoogleUserMessagingPlatform (>= 1.1) - - GoogleAppMeasurement (11.2.0): - - GoogleAppMeasurement/AdIdSupport (= 11.2.0) + - GoogleAppMeasurement (11.7.0): + - GoogleAppMeasurement/AdIdSupport (= 11.7.0) - GoogleUtilities/AppDelegateSwizzler (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/Network (~> 8.0) - "GoogleUtilities/NSData+zlib (~> 8.0)" - nanopb (~> 3.30910.0) - - GoogleAppMeasurement/AdIdSupport (11.2.0): - - GoogleAppMeasurement/WithoutAdIdSupport (= 11.2.0) + - GoogleAppMeasurement/AdIdSupport (11.7.0): + - GoogleAppMeasurement/WithoutAdIdSupport (= 11.7.0) - GoogleUtilities/AppDelegateSwizzler (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/Network (~> 8.0) - "GoogleUtilities/NSData+zlib (~> 8.0)" - nanopb (~> 3.30910.0) - - GoogleAppMeasurement/WithoutAdIdSupport (11.2.0): + - GoogleAppMeasurement/WithoutAdIdSupport (11.7.0): - GoogleUtilities/AppDelegateSwizzler (~> 8.0) - GoogleUtilities/MethodSwizzler (~> 8.0) - GoogleUtilities/Network (~> 8.0) @@ -96,7 +96,7 @@ PODS: - GoogleDataTransport (10.1.0): - nanopb (~> 3.30910.0) - PromisesObjC (~> 2.4) - - GoogleUserMessagingPlatform (2.6.0) + - GoogleUserMessagingPlatform (2.7.0) - GoogleUtilities/AppDelegateSwizzler (8.0.2): - GoogleUtilities/Environment - GoogleUtilities/Logger @@ -124,7 +124,7 @@ PODS: - GoogleUtilities/UserDefaults (8.0.2): - GoogleUtilities/Logger - GoogleUtilities/Privacy - - GTMSessionFetcher/Core (3.5.0) + - GTMSessionFetcher/Core (4.3.0) - nanopb (3.30910.0): - nanopb/decode (= 3.30910.0) - nanopb/encode (= 3.30910.0) @@ -169,24 +169,24 @@ SPEC REPOS: - ScrollableSegmentedControl SPEC CHECKSUMS: - Firebase: 98e6bf5278170668a7983e12971a66b2cd57fc8c - FirebaseAnalytics: c36efd5710c60c17558650fa58c2066eca7e9265 - FirebaseAppCheckInterop: ea21450529cf0ebd132788dd8916a0269abc684f - FirebaseAuthInterop: 47c09558af5d1b31f16fb352387c72d4804f4a24 - FirebaseCore: a282032ae9295c795714ded2ec9c522fc237f8da - FirebaseCoreExtension: cda74ddfb001224bd8fd1d6e74698b4ed07803de - FirebaseCoreInternal: 0c569513412da9f3b31bd0b340013bbee8f295c5 - FirebaseCrashlytics: cfc69af5b53565dc6a5e563788809b5778ac4eac - FirebaseInstallations: 771177d89d6c451dc6e50085ec82e2fc77ed0a4a - FirebaseRemoteConfigInterop: 477b26fdeb8fb5fbaf22fa9db5343b42289dc7db - FirebaseSessions: adcec8b72d0066a385e3affcd1bcb1ebb3908ce6 - FirebaseStorage: 9353f926690b2329957860abfcbc8b4074fe45e8 - Google-Mobile-Ads-SDK: 6a3cdd892fd87c8b2a388c1cc74d2b7df2570f0b - GoogleAppMeasurement: 76d4f8b36b03bd8381fa9a7fe2cc7f99c0a2e93a + Firebase: a64bf6a8546e6eab54f1c715cd6151f39d2329f4 + FirebaseAnalytics: bc9e565af9044ba8d6c6e4157e4edca8e5fdf7ec + FirebaseAppCheckInterop: 2376d3ec5cb4267facad4fe754ab4f301a5a519b + FirebaseAuthInterop: a6973d72aa242ea88ffb6be9c9b06c65455071da + FirebaseCore: 3227e35f4197a924206fbcdc0349325baf4f5de4 + FirebaseCoreExtension: 206c1b399f0d103055207c16f299b28e3dbd1949 + FirebaseCoreInternal: d6c17dafc8dc33614733a8b52df78fcb4394c881 + FirebaseCrashlytics: 785a73b624715bbc09a40bb56cdc3829a801cc98 + FirebaseInstallations: 9347e719c3d52d8d7b9074b2c32407dd027305e9 + FirebaseRemoteConfigInterop: ca12abf9da0003efd3a476b2dff4f7a04fd31b4f + FirebaseSessions: 32ed7a9387ae71efe3a35a7f20f3a7292950957b + FirebaseStorage: d35da127dd49edcbd07b8c07cf651a70161558b2 + Google-Mobile-Ads-SDK: 14f57f2dc33532a24db288897e26494640810407 + GoogleAppMeasurement: 0471a5b5bff51f3a91b1e76df22c952d04c63967 GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7 - GoogleUserMessagingPlatform: 0c3a08353e53ce8c2feab7addd0b652cde522450 + GoogleUserMessagingPlatform: a8b56893477f67212fbc8411c139e61d463349f5 GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d - GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6 + GTMSessionFetcher: 257ead9ba8e15a2d389d79496e02b9cc5dd0c62c nanopb: fad817b59e0457d11a5dfbde799381cd727c1275 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 @@ -194,4 +194,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 35cd182dc790891ebc7626066c33a6e947e7167e -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 From db0544b1cae66463c46853c69ab53d56f1870734 Mon Sep 17 00:00:00 2001 From: Thomas Taschauer Date: Thu, 6 Feb 2025 20:58:00 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Andreas Stefl --- OpenDocumentReader/CoreWrapper.mm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/OpenDocumentReader/CoreWrapper.mm b/OpenDocumentReader/CoreWrapper.mm index b14c988..665af30 100644 --- a/OpenDocumentReader/CoreWrapper.mm +++ b/OpenDocumentReader/CoreWrapper.mm @@ -47,22 +47,19 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath with:(NSStri auto inputPathC = [inputPath cStringUsingEncoding:NSUTF8StringEncoding]; auto inputPathCpp = std::string(inputPathC); - odr::FileType fileType; + std::vector fileTypes; try { - const auto types = odr::OpenDocumentReader::types(inputPathCpp); + fileTypes = odr::OpenDocumentReader::types(inputPathCpp); if (types.empty()) { _errorCode = @(-5); return false; } - - fileType = types.back(); } catch (odr::UnsupportedFileType &e) { _errorCode = @(-5); return false; } - const auto extensionCpp = odr::OpenDocumentReader::type_to_string(fileType); - if (extensionCpp == "pdf") { + if (fileTypes.find(odr::FileType::portable_document_format) != fileTypes.end()) { _errorCode = @(-5); return false; } From 4abbf10978949febb6ab6bbc1073aa7122e4f0c4 Mon Sep 17 00:00:00 2001 From: Thomas Taschauer Date: Thu, 6 Feb 2025 21:11:14 +0100 Subject: [PATCH 3/3] fix review feedback --- OpenDocumentReader.xcodeproj/project.pbxproj | 16 ++++++++-------- OpenDocumentReader/CoreWrapper.mm | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/OpenDocumentReader.xcodeproj/project.pbxproj b/OpenDocumentReader.xcodeproj/project.pbxproj index c836c73..30aeba9 100644 --- a/OpenDocumentReader.xcodeproj/project.pbxproj +++ b/OpenDocumentReader.xcodeproj/project.pbxproj @@ -604,7 +604,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 42; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 5LS6X97G6J; ENABLE_BITCODE = NO; @@ -616,7 +616,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.33; + MARKETING_VERSION = 1.34; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = at.tomtasche.reader.lite1; PRODUCT_NAME = "$(BUNDLE_DISPLAY_NAME)"; @@ -695,7 +695,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 42; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 5LS6X97G6J; ENABLE_BITCODE = NO; @@ -707,7 +707,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.33; + MARKETING_VERSION = 1.34; PRODUCT_BUNDLE_IDENTIFIER = at.tomtasche.reader.lite1; PRODUCT_NAME = "$(BUNDLE_DISPLAY_NAME)"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -930,7 +930,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 42; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 5LS6X97G6J; ENABLE_BITCODE = NO; @@ -942,7 +942,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.33; + MARKETING_VERSION = 1.34; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "at.tomtasche.reader$(BUNDLE_ID_SUFFIX)"; PRODUCT_NAME = "$(BUNDLE_DISPLAY_NAME)"; @@ -965,7 +965,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 42; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 5LS6X97G6J; ENABLE_BITCODE = NO; @@ -977,7 +977,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.33; + MARKETING_VERSION = 1.34; PRODUCT_BUNDLE_IDENTIFIER = "at.tomtasche.reader$(BUNDLE_ID_SUFFIX)"; PRODUCT_NAME = "$(BUNDLE_DISPLAY_NAME)"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; diff --git a/OpenDocumentReader/CoreWrapper.mm b/OpenDocumentReader/CoreWrapper.mm index 665af30..d82bade 100644 --- a/OpenDocumentReader/CoreWrapper.mm +++ b/OpenDocumentReader/CoreWrapper.mm @@ -50,7 +50,7 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath with:(NSStri std::vector fileTypes; try { fileTypes = odr::OpenDocumentReader::types(inputPathCpp); - if (types.empty()) { + if (fileTypes.empty()) { _errorCode = @(-5); return false; } @@ -59,7 +59,7 @@ - (bool)translate:(NSString *)inputPath into:(NSString *)outputPath with:(NSStri return false; } - if (fileTypes.find(odr::FileType::portable_document_format) != fileTypes.end()) { + if (std::find(fileTypes.begin(), fileTypes.end(), odr::FileType::portable_document_format) != fileTypes.end()) { _errorCode = @(-5); return false; }