Skip to content

Commit 1beb554

Browse files
authored
Merge pull request #30 from TomTasche/development
v1.10
2 parents 2cd7a44 + 9b4425e commit 1beb554

180 files changed

Lines changed: 13393 additions & 1862 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

OpenDocument.core

OpenDocumentReader.xcodeproj/project.pbxproj

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,65 @@
160160
isa = PBXContainerItemProxy;
161161
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
162162
proxyType = 1;
163-
remoteGlobalIDString = 8D4E2F0BCFAD4292AE1273E6;
163+
remoteGlobalIDString = 68722AEF2DC64BF8AB2DF7D5;
164164
remoteInfo = glog;
165165
};
166166
E26C39322250D976009C484A /* PBXContainerItemProxy */ = {
167167
isa = PBXContainerItemProxy;
168168
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
169169
proxyType = 1;
170-
remoteGlobalIDString = 757CD8A4AB3B4664A378839E;
170+
remoteGlobalIDString = DBADB6840206443A97F2A76D;
171171
remoteInfo = miniz;
172172
};
173173
E26C39342250D976009C484A /* PBXContainerItemProxy */ = {
174174
isa = PBXContainerItemProxy;
175175
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
176176
proxyType = 1;
177-
remoteGlobalIDString = 670CFA8E9DBD4C75B0F5E2B4;
177+
remoteGlobalIDString = CD40E84D34284EF7A80FB402;
178178
remoteInfo = odrlib;
179179
};
180180
E26C39362250D976009C484A /* PBXContainerItemProxy */ = {
181181
isa = PBXContainerItemProxy;
182182
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
183183
proxyType = 1;
184-
remoteGlobalIDString = 7EB41FC0D1724584A85196BA;
184+
remoteGlobalIDString = B382587C51824ECE8AB80585;
185185
remoteInfo = tinyxml2;
186186
};
187+
E29A02212365EF7800BD6A96 /* PBXContainerItemProxy */ = {
188+
isa = PBXContainerItemProxy;
189+
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
190+
proxyType = 2;
191+
remoteGlobalIDString = 48C1E359B46B47C5B2EC8386;
192+
remoteInfo = gmock;
193+
};
194+
E29A02232365EF7800BD6A96 /* PBXContainerItemProxy */ = {
195+
isa = PBXContainerItemProxy;
196+
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
197+
proxyType = 2;
198+
remoteGlobalIDString = C9C0C7A13E604FABAB50807E;
199+
remoteInfo = gmock_main;
200+
};
201+
E29A02252365EF7800BD6A96 /* PBXContainerItemProxy */ = {
202+
isa = PBXContainerItemProxy;
203+
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
204+
proxyType = 2;
205+
remoteGlobalIDString = 4A3FBC799E3946AFBC52340F;
206+
remoteInfo = gtest;
207+
};
208+
E29A02272365EF7800BD6A96 /* PBXContainerItemProxy */ = {
209+
isa = PBXContainerItemProxy;
210+
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
211+
proxyType = 2;
212+
remoteGlobalIDString = 9A974A6917734F869FAF1CC6;
213+
remoteInfo = gtest_main;
214+
};
215+
E29A02292365EF7800BD6A96 /* PBXContainerItemProxy */ = {
216+
isa = PBXContainerItemProxy;
217+
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
218+
proxyType = 2;
219+
remoteGlobalIDString = 2A920CCD2EC04ED8BF0FCC37;
220+
remoteInfo = odrmain;
221+
};
187222
E2CDC4BA226A407500E9FCED /* PBXContainerItemProxy */ = {
188223
isa = PBXContainerItemProxy;
189224
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
@@ -216,7 +251,7 @@
216251
isa = PBXContainerItemProxy;
217252
containerPortal = E26C38EA2250D91C009C484A /* odr.xcodeproj */;
218253
proxyType = 1;
219-
remoteGlobalIDString = E3B45187C92B47DCB57902A1;
254+
remoteGlobalIDString = E08901684B824F61ACF4B07B;
220255
remoteInfo = "cryptopp-object";
221256
};
222257
/* End PBXContainerItemProxy section */
@@ -290,9 +325,14 @@
290325
E26C39132250D91C009C484A /* example5 */,
291326
E26C39152250D91C009C484A /* example6 */,
292327
E26C39172250D91C009C484A /* libglog.a */,
328+
E29A02222365EF7800BD6A96 /* libgmockd.a */,
329+
E29A02242365EF7800BD6A96 /* libgmock_maind.a */,
330+
E29A02262365EF7800BD6A96 /* libgtestd.a */,
331+
E29A02282365EF7800BD6A96 /* libgtest_maind.a */,
293332
E26C39192250D91C009C484A /* logging_unittest */,
294333
E26C391B2250D91C009C484A /* libminiz.a */,
295334
E26C391D2250D91C009C484A /* libodrlib.a */,
335+
E29A022A2365EF7800BD6A96 /* odrmain */,
296336
E26C391F2250D91C009C484A /* odrtests */,
297337
E26C39212250D91C009C484A /* signalhandler_unittest */,
298338
E26C39232250D91C009C484A /* stacktrace_unittest */,
@@ -564,6 +604,42 @@
564604
remoteRef = E26C392A2250D91C009C484A /* PBXContainerItemProxy */;
565605
sourceTree = BUILT_PRODUCTS_DIR;
566606
};
607+
E29A02222365EF7800BD6A96 /* libgmockd.a */ = {
608+
isa = PBXReferenceProxy;
609+
fileType = archive.ar;
610+
path = libgmockd.a;
611+
remoteRef = E29A02212365EF7800BD6A96 /* PBXContainerItemProxy */;
612+
sourceTree = BUILT_PRODUCTS_DIR;
613+
};
614+
E29A02242365EF7800BD6A96 /* libgmock_maind.a */ = {
615+
isa = PBXReferenceProxy;
616+
fileType = archive.ar;
617+
path = libgmock_maind.a;
618+
remoteRef = E29A02232365EF7800BD6A96 /* PBXContainerItemProxy */;
619+
sourceTree = BUILT_PRODUCTS_DIR;
620+
};
621+
E29A02262365EF7800BD6A96 /* libgtestd.a */ = {
622+
isa = PBXReferenceProxy;
623+
fileType = archive.ar;
624+
path = libgtestd.a;
625+
remoteRef = E29A02252365EF7800BD6A96 /* PBXContainerItemProxy */;
626+
sourceTree = BUILT_PRODUCTS_DIR;
627+
};
628+
E29A02282365EF7800BD6A96 /* libgtest_maind.a */ = {
629+
isa = PBXReferenceProxy;
630+
fileType = archive.ar;
631+
path = libgtest_maind.a;
632+
remoteRef = E29A02272365EF7800BD6A96 /* PBXContainerItemProxy */;
633+
sourceTree = BUILT_PRODUCTS_DIR;
634+
};
635+
E29A022A2365EF7800BD6A96 /* odrmain */ = {
636+
isa = PBXReferenceProxy;
637+
fileType = "compiled.mach-o.executable";
638+
name = odrmain;
639+
path = odrmain.app;
640+
remoteRef = E29A02292365EF7800BD6A96 /* PBXContainerItemProxy */;
641+
sourceTree = BUILT_PRODUCTS_DIR;
642+
};
567643
E2CDC4BB226A407500E9FCED /* cryptest.exe */ = {
568644
isa = PBXReferenceProxy;
569645
fileType = "compiled.mach-o.executable";
@@ -854,6 +930,7 @@
854930
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
855931
CLANG_ENABLE_MODULES = YES;
856932
CODE_SIGN_STYLE = Automatic;
933+
CURRENT_PROJECT_VERSION = 14;
857934
DEVELOPMENT_TEAM = 5LS6X97G6J;
858935
HEADER_SEARCH_PATHS = (
859936
"$(inherited)",
@@ -866,6 +943,7 @@
866943
"@executable_path/Frameworks",
867944
);
868945
LIBRARY_SEARCH_PATHS = "$(inherited)";
946+
MARKETING_VERSION = 1.10;
869947
PRODUCT_BUNDLE_IDENTIFIER = at.tomtasche.reader;
870948
PRODUCT_NAME = "$(TARGET_NAME)";
871949
SWIFT_OBJC_BRIDGING_HEADER = OpenDocumentReader/BridgingHeader.h;
@@ -882,6 +960,7 @@
882960
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
883961
CLANG_ENABLE_MODULES = YES;
884962
CODE_SIGN_STYLE = Automatic;
963+
CURRENT_PROJECT_VERSION = 14;
885964
DEVELOPMENT_TEAM = 5LS6X97G6J;
886965
HEADER_SEARCH_PATHS = (
887966
"$(inherited)",
@@ -894,6 +973,7 @@
894973
"@executable_path/Frameworks",
895974
);
896975
LIBRARY_SEARCH_PATHS = "$(inherited)";
976+
MARKETING_VERSION = 1.10;
897977
PRODUCT_BUNDLE_IDENTIFIER = at.tomtasche.reader;
898978
PRODUCT_NAME = "$(TARGET_NAME)";
899979
SWIFT_OBJC_BRIDGING_HEADER = OpenDocumentReader/BridgingHeader.h;

OpenDocumentReader.xcodeproj/xcshareddata/xcschemes/OpenDocumentReader.xcscheme

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,11 +36,11 @@
3836
ReferencedContainer = "container:OpenDocumentReader.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4341
</TestAction>
4442
<LaunchAction
45-
buildConfiguration = "Release"
43+
buildConfiguration = "Debug"
4644
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4745
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4846
launchStyle = "0"
@@ -61,8 +59,6 @@
6159
ReferencedContainer = "container:OpenDocumentReader.xcodeproj">
6260
</BuildableReference>
6361
</BuildableProductRunnable>
64-
<AdditionalOptions>
65-
</AdditionalOptions>
6662
</LaunchAction>
6763
<ProfileAction
6864
buildConfiguration = "Release"

OpenDocumentReader/AppDelegate.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4646

4747
func application(_ app: UIApplication, open inputURL: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
4848
guard let documentBrowserViewController = window?.rootViewController as? DocumentBrowserViewController else {
49-
print("*** The root view is not a document browser! ***")
49+
Crashlytics.sharedInstance().throwException()
50+
5051
return false
5152
}
5253

5354
documentBrowserViewController.revealDocument(at: inputURL, importIfNeeded: true) { (revealedDocumentURL, error) in
5455

5556
guard error == nil else {
56-
print("*** Failed to reveal the document at %@. Error: %@. ***")
57+
Crashlytics.sharedInstance().recordError(error!)
58+
Crashlytics.sharedInstance().throwException()
59+
5760
return
5861
}
5962

6063
guard let url = revealedDocumentURL else {
61-
print("*** No URL revealed. ***")
64+
Crashlytics.sharedInstance().throwException()
65+
6266
return
6367
}
64-
65-
print("==> Revealed URL")
66-
68+
6769
documentBrowserViewController.presentDocument(at: url)
6870
}
6971

OpenDocumentReader/CoreWrapper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
@property NSArray *pageNames;
1717
@property NSNumber *errorCode;
1818

19-
- (bool)translate:(NSString *)inputPath into:(NSString *)outputPath at:(NSNumber *)page with:(NSString *)password;
19+
- (bool)translate:(NSString *)inputPath into:(NSString *)outputPath at:(NSNumber *)page with:(NSString *)password editable:(bool)editable;
20+
- (bool)backTranslate:(NSString *)inputPath into:(NSString *)outputPath;
2021
@end
2122

2223
#endif /* CoreWrapper_h */

OpenDocumentReader/CoreWrapper.mm

Lines changed: 74 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,86 @@
1414
#include "TranslationConfig.h"
1515
#include "FileMeta.h"
1616

17-
@implementation CoreWrapper
18-
- (bool)translate:(NSString *)inputPath into:(NSString *)outputPath at:(NSNumber *)page with:(NSString *)password {
19-
try {
20-
auto translator = odr::TranslationHelper();
21-
bool opened = translator.open([inputPath cStringUsingEncoding:NSUTF8StringEncoding]);
22-
if (!opened) {
23-
_errorCode = @(-1);
24-
return false;
25-
}
26-
27-
const odr::FileMeta& meta = translator.getMeta();
28-
29-
bool decrypted = !meta.encrypted;
30-
if (password != nil) {
31-
decrypted = translator.decrypt([password cStringUsingEncoding:NSUTF8StringEncoding]);
32-
}
33-
34-
if (!decrypted) {
35-
_errorCode = @(-2);
17+
@implementation CoreWrapper {
18+
odr::TranslationHelper translator;
19+
bool initialized;
20+
}
21+
22+
- (bool)translate:(NSString *)inputPath into:(NSString *)outputPath at:(NSNumber *)page with:(NSString *)password editable:(bool)editable {
23+
@synchronized(self) {
24+
try {
25+
_errorCode = 0;
26+
27+
if (!initialized) {
28+
bool opened = translator.openOpenDocument([inputPath cStringUsingEncoding:NSUTF8StringEncoding]);
29+
if (!opened) {
30+
_errorCode = @(-1);
31+
return false;
32+
}
33+
34+
const auto meta = translator.getMeta();
35+
36+
bool decrypted = !meta->encrypted;
37+
if (password != nil) {
38+
decrypted = translator.decrypt([password cStringUsingEncoding:NSUTF8StringEncoding]);
39+
}
40+
41+
if (!decrypted) {
42+
_errorCode = @(-2);
43+
return false;
44+
}
45+
46+
NSMutableArray *pageNames = [[NSMutableArray alloc] init];
47+
if (meta->type == odr::FileType::OPENDOCUMENT_TEXT) {
48+
[pageNames addObject:@"Text document"];
49+
} else {
50+
for (auto page = meta->entries.begin(); page != meta->entries.end(); page++) {
51+
auto pageName = page->name;
52+
53+
[pageNames addObject:[NSString stringWithCString:pageName.c_str() encoding:[NSString defaultCStringEncoding]]];
54+
}
55+
}
56+
_pageNames = pageNames;
57+
58+
initialized = true;
59+
}
60+
61+
odr::TranslationConfig config = {};
62+
config.editable = editable;
63+
config.entryOffset = page.intValue;
64+
config.entryCount = 1;
65+
66+
bool translated = translator.translate([outputPath cStringUsingEncoding:NSUTF8StringEncoding], config);
67+
if (!translated) {
68+
_errorCode = @(-4);
69+
return false;
70+
}
71+
} catch (...) {
72+
_errorCode = @(-3);
3673
return false;
3774
}
3875

39-
odr::TranslationConfig config = {};
40-
config.entryOffset = page.intValue;
41-
config.entryCount = 1;
42-
43-
NSMutableArray *pageNames = [[NSMutableArray alloc] init];
44-
if (meta.type == odr::FileType::OPENDOCUMENT_TEXT) {
45-
[pageNames addObject:@"Text document"];
46-
} else {
47-
for (auto page = meta.entries.begin(); page != meta.entries.end(); page++) {
48-
auto pageName = page->name;
49-
50-
[pageNames addObject:[NSString stringWithCString:pageName.c_str() encoding:[NSString defaultCStringEncoding]]];
76+
return true;
77+
}
78+
}
79+
80+
- (bool)backTranslate:(NSString *)inputPath into:(NSString *)outputPath {
81+
@synchronized(self) {
82+
try {
83+
_errorCode = 0;
84+
85+
bool translated = translator.backTranslate([inputPath cStringUsingEncoding:NSUTF8StringEncoding], [outputPath cStringUsingEncoding:NSUTF8StringEncoding]);
86+
if (!translated) {
87+
_errorCode = @(-4);
88+
return false;
5189
}
90+
} catch (...) {
91+
_errorCode = @(-3);
92+
return false;
5293
}
53-
_pageNames = pageNames;
5494

55-
translator.translate([outputPath cStringUsingEncoding:NSUTF8StringEncoding], config);
56-
} catch (...) {
57-
_errorCode = @(-3);
58-
return false;
95+
return true;
5996
}
60-
61-
return true;
6297
}
98+
6399
@end

0 commit comments

Comments
 (0)