Bugzilla – Attachment 159561 Details for
Bug 128510
Opening a template file should be possible using the iOS app
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Attempted (not working) patch.
TDF#128510.ATTEMPT1.DIFF (text/plain), 9.76 KB, created by
How can I remove my account?
on 2020-04-14 17:36:33 UTC
(
hide
)
Description:
Attempted (not working) patch.
Filename:
MIME Type:
Creator:
How can I remove my account?
Created:
2020-04-14 17:36:33 UTC
Size:
9.76 KB
patch
obsolete
>diff --git a/ios/Mobile/DocumentBrowserViewController.mm b/ios/Mobile/DocumentBrowserViewController.mm >index 92a9dedf0..4d1aa7400 100644 >--- a/ios/Mobile/DocumentBrowserViewController.mm >+++ b/ios/Mobile/DocumentBrowserViewController.mm >@@ -50,6 +50,9 @@ -(void)documentBrowser:(UIDocumentBrowserViewController *)controller didPickDocu > return; > } > >+ // Check whether it is a template document, and if so, do the necessary thing >+ // NSURL *docSavedFromTemplate = [TemplateCollectionViewController loadTemplate:sourceURL]; >+ > // Present the Document View Controller for the first document that was picked. > // If you support picking multiple items, make sure you handle them all. > [self presentDocumentAtURL:sourceURL]; >diff --git a/ios/Mobile/Info.plist.in b/ios/Mobile/Info.plist.in >index 8971a6d7e..e49b8efbe 100644 >--- a/ios/Mobile/Info.plist.in >+++ b/ios/Mobile/Info.plist.in >@@ -239,6 +239,7 @@ > UTImportedTypeDeclarations array at all (and presumably even less in the > UTExportedTypeDeclarations one). --> > <!-- Document sub-types are listed in order ODF, OOXML, MSO, other --> >+ <!-- In each case first the actual document type, then the template type, if any --> > <!-- Writer document types --> > <dict> > <key>CFBundleTypeName</key> >@@ -250,6 +251,18 @@ > <string>org.oasis-open.opendocument.text</string> > </array> > </dict> >+ <dict> >+ <key>CFBundleTypeName</key> >+ <string>OpenDocument Text Template</string> >+ <key>CFBundleTypeRole</key> >+ <string>Viewer</string> >+ <key>LSHandlerRank</key> >+ <string>Owner</string> >+ <key>LSItemContentTypes</key> >+ <array> >+ <string>org.oasis-open.opendocument.text-template</string> >+ </array> >+ </dict> > <dict> > <key>CFBundleTypeName</key> > <string>OpenDocument Flat Text</string> >@@ -317,6 +330,20 @@ > <string>org.oasis-open.opendocument.spreadsheet</string> > </array> > </dict> >+ <dict> >+ <key>CFBundleTypeIconFiles</key> >+ <array/> >+ <key>CFBundleTypeName</key> >+ <string>OpenDocument Spreadsheet Template</string> >+ <key>CFBundleTypeRole</key> >+ <string>Viewer</string> >+ <key>LSHandlerRank</key> >+ <string>Owner</string> >+ <key>LSItemContentTypes</key> >+ <array> >+ <string>org.oasis-open.opendocument.spreadsheet-template</string> >+ </array> >+ </dict> > <dict> > <key>CFBundleTypeIconFiles</key> > <array/> >@@ -356,6 +383,16 @@ > <string>org.oasis-open.opendocument.presentation</string> > </array> > </dict> >+ <dict> >+ <key>CFBundleTypeName</key> >+ <string>OpenDocument Presentation Template</string> >+ <key>LSHandlerRank</key> >+ <string>Viewer</string> >+ <key>LSItemContentTypes</key> >+ <array> >+ <string>org.oasis-open.opendocument.presentation-template</string> >+ </array> >+ </dict> > <dict> > <key>CFBundleTypeIconFiles</key> > <array/> >@@ -463,6 +500,24 @@ > <string>odt</string> > </dict> > </dict> >+ <dict> >+ <key>UTTypeConformsTo</key> >+ <array> >+ <string>public.data</string> >+ <string>public.content</string> >+ </array> >+ <key>UTTypeDescription</key> >+ <string>OpenDocument Text Template</string> >+ <key>UTTypeIconFiles</key> >+ <array/> >+ <key>UTTypeIdentifier</key> >+ <string>org.oasis-open.opendocument.text-template</string> >+ <key>UTTypeTagSpecification</key> >+ <dict> >+ <key>public.filename-extension</key> >+ <string>ott</string> >+ </dict> >+ </dict> > <dict> > <key>UTTypeConformsTo</key> > <array> >@@ -497,6 +552,24 @@ > <string>ods</string> > </dict> > </dict> >+ <dict> >+ <key>UTTypeConformsTo</key> >+ <array> >+ <string>public.data</string> >+ <string>public.content</string> >+ </array> >+ <key>UTTypeDescription</key> >+ <string>OpenDocument Spreadsheet Template</string> >+ <key>UTTypeIconFiles</key> >+ <array/> >+ <key>UTTypeIdentifier</key> >+ <string>org.oasis-open.opendocument.spreadsheet-template</string> >+ <key>UTTypeTagSpecification</key> >+ <dict> >+ <key>public.filename-extension</key> >+ <string>ots</string> >+ </dict> >+ </dict> > <dict> > <key>UTTypeConformsTo</key> > <array> >@@ -515,6 +588,24 @@ > <string>odp</string> > </dict> > </dict> >+ <dict> >+ <key>UTTypeConformsTo</key> >+ <array> >+ <string>public.data</string> >+ <string>public.content</string> >+ </array> >+ <key>UTTypeDescription</key> >+ <string>OpenDocument Presentation Template</string> >+ <key>UTTypeIconFiles</key> >+ <array/> >+ <key>UTTypeIdentifier</key> >+ <string>org.oasis-open.opendocument.presentation-template</string> >+ <key>UTTypeTagSpecification</key> >+ <dict> >+ <key>public.filename-extension</key> >+ <string>otp</string> >+ </dict> >+ </dict> > <dict> > <key>UTTypeConformsTo</key> > <array> >diff --git a/ios/Mobile/TemplateCollectionViewController.h b/ios/Mobile/TemplateCollectionViewController.h >index 02801bef1..566f633f4 100644 >--- a/ios/Mobile/TemplateCollectionViewController.h >+++ b/ios/Mobile/TemplateCollectionViewController.h >@@ -14,6 +14,9 @@ > > @property (copy) void (^ _Nullable importHandler)(NSURL * _Nullable, UIDocumentBrowserImportMode); > >++ (NSString *)mapTemplateExtensionToActual:(NSString *)templateName; >++ (NSURL *)loadTemplate:(NSURL *)templateURL; >+ > @end > > // vim:set shiftwidth=4 softtabstop=4 expandtab: >diff --git a/ios/Mobile/TemplateCollectionViewController.mm b/ios/Mobile/TemplateCollectionViewController.mm >index b283d580a..f4997adb5 100644 >--- a/ios/Mobile/TemplateCollectionViewController.mm >+++ b/ios/Mobile/TemplateCollectionViewController.mm >@@ -16,20 +16,6 @@ > #import "TemplateCollectionViewController.h" > #import "TemplateSectionHeaderView.h" > >-static NSString *mapTemplateExtensionToActual(NSString *templateName) { >- NSString *baseName = [templateName stringByDeletingPathExtension]; >- NSString *extension = [templateName substringFromIndex:baseName.length]; >- >- if ([extension isEqualToString:@".ott"]) >- return [baseName stringByAppendingString:@".odt"]; >- else if ([extension isEqualToString:@".ots"]) >- return [baseName stringByAppendingString:@".ods"]; >- else if ([extension isEqualToString:@".otp"]) >- return [baseName stringByAppendingString:@".odp"]; >- else >- assert(false); >-} >- > @implementation TemplateCollectionViewController > > - (void)viewDidLoad { >@@ -135,21 +121,46 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView > - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { > NSURL *selectedTemplate = templates[[indexPath indexAtPosition:0]][[indexPath indexAtPosition:1]]; > >+ NSURL *newURL = [TemplateCollectionViewController loadTemplate:selectedTemplate]; >+ >+ self.importHandler(newURL, UIDocumentBrowserImportModeMove); >+ >+ [self dismissViewControllerAnimated:YES completion:nil]; >+ >+ return YES; >+} >+ >++ (NSString *)mapTemplateExtensionToActual:(NSString *)templateName { >+ NSString *baseName = [templateName stringByDeletingPathExtension]; >+ NSString *extension = [templateName substringFromIndex:baseName.length]; >+ >+ if ([extension isEqualToString:@".ott"]) >+ return [baseName stringByAppendingString:@".odt"]; >+ else if ([extension isEqualToString:@".ots"]) >+ return [baseName stringByAppendingString:@".ods"]; >+ else if ([extension isEqualToString:@".otp"]) >+ return [baseName stringByAppendingString:@".odp"]; >+ else >+ return nil; >+} >+ >++ (NSURL *)loadTemplate:(NSURL *)templateURL { > NSURL *cacheDirectory = [NSFileManager.defaultManager URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask][0]; >- NSURL *newURL = [cacheDirectory URLByAppendingPathComponent:mapTemplateExtensionToActual(selectedTemplate.lastPathComponent) >+ NSString *newExtension = [TemplateCollectionViewController mapTemplateExtensionToActual:[templateURL lastPathComponent]]; >+ >+ if (newExtension == nil) >+ return nil; >+ >+ NSURL *newURL = [cacheDirectory URLByAppendingPathComponent:newExtension > isDirectory:NO]; > // Load the template into LibreOffice core, save as the corresponding document type (with the >- // same basename), and then proceed to edit that. >+ // same basename). > >- LibreOfficeKitDocument *doc = lo_kit->pClass->documentLoad(lo_kit, [[selectedTemplate absoluteString] UTF8String]); >+ LibreOfficeKitDocument *doc = lo_kit->pClass->documentLoad(lo_kit, [[templateURL absoluteString] UTF8String]); > doc->pClass->saveAs(doc, [[newURL absoluteString] UTF8String], nullptr, nullptr); > doc->pClass->destroy(doc); > >- self.importHandler(newURL, UIDocumentBrowserImportModeMove); >- >- [self dismissViewControllerAnimated:YES completion:nil]; >- >- return YES; >+ return newURL; > } > > @end
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 128510
: 159561