2018-09-11 01:30:55 -05:00
|
|
|
// -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*-
|
|
|
|
//
|
|
|
|
// This file is part of the LibreOffice project.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
#import "config.h"
|
|
|
|
|
Add a way to have templates specific to a customer deployment
Add two settings: One setting "Template list URL" is a string that
should either be empty (the typical case for a random user of the
app), or contain a https: URL. If this setting is empty, only the
templates bundled in the app are provided.
If the "Template list URL" is non-empty, it should be a https: URL
pointing to a text file (or dynamically generated text resource). That
file is downloaded and read when the app starts. Each line in the file
should either be a comment (starting with a hash '#'), or a https: URL
pointing to a template document, that is of type .ott, .ots, or .otp.
That document is downloaded if it hasn't been downloaded already, or
if its time stamp is newer than that of the already downloaded copy.
Also a thumbnail image for the template, formed by appending ".png" to
its URL, is downloaded, if available.
Any previously downloaded templates that aren't mentioned in the list
file are removed.
The intent is that in some managed mass deployment environment, the
mobile device management software would set up this setting, so that
the end-user devices would see the same templates.
Obviously, this URL does not have to point to a static file on a web
server, but could point to some dynamically generated resource on a
web server, that enumerates the templates available on the server and
returns their URLs as a text document.
Another setting is "Empty tile cache next time". This is a toggle. If
toggled on, the next time a document is opened in the app, the tile
cache is emptied (and the toggle is reset off). This is mostly for
potential problem solving, and might be removd later.
Various refactoring to support the new functionality.
Change-Id: Ie2ebf032acb9e43bb1c6f7ae4d0c449ae66eaa05
2018-12-17 14:18:49 -06:00
|
|
|
#import "AppDelegate.h"
|
2018-09-11 01:30:55 -05:00
|
|
|
#import "DocumentBrowserViewController.h"
|
|
|
|
#import "Document.h"
|
|
|
|
#import "DocumentViewController.h"
|
2018-12-04 14:01:45 -06:00
|
|
|
#import "TemplateCollectionViewController.h"
|
2018-09-11 01:30:55 -05:00
|
|
|
|
|
|
|
@interface DocumentBrowserViewController () <UIDocumentBrowserViewControllerDelegate>
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation DocumentBrowserViewController
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
Add a way to have templates specific to a customer deployment
Add two settings: One setting "Template list URL" is a string that
should either be empty (the typical case for a random user of the
app), or contain a https: URL. If this setting is empty, only the
templates bundled in the app are provided.
If the "Template list URL" is non-empty, it should be a https: URL
pointing to a text file (or dynamically generated text resource). That
file is downloaded and read when the app starts. Each line in the file
should either be a comment (starting with a hash '#'), or a https: URL
pointing to a template document, that is of type .ott, .ots, or .otp.
That document is downloaded if it hasn't been downloaded already, or
if its time stamp is newer than that of the already downloaded copy.
Also a thumbnail image for the template, formed by appending ".png" to
its URL, is downloaded, if available.
Any previously downloaded templates that aren't mentioned in the list
file are removed.
The intent is that in some managed mass deployment environment, the
mobile device management software would set up this setting, so that
the end-user devices would see the same templates.
Obviously, this URL does not have to point to a static file on a web
server, but could point to some dynamically generated resource on a
web server, that enumerates the templates available on the server and
returns their URLs as a text document.
Another setting is "Empty tile cache next time". This is a toggle. If
toggled on, the next time a document is opened in the app, the tile
cache is emptied (and the toggle is reset off). This is mostly for
potential problem solving, and might be removd later.
Various refactoring to support the new functionality.
Change-Id: Ie2ebf032acb9e43bb1c6f7ae4d0c449ae66eaa05
2018-12-17 14:18:49 -06:00
|
|
|
|
2018-09-11 01:30:55 -05:00
|
|
|
self.delegate = self;
|
|
|
|
self.allowsDocumentCreation = YES;
|
|
|
|
self.allowsPickingMultipleItems = NO;
|
|
|
|
|
|
|
|
// Update the style of the UIDocumentBrowserViewController
|
|
|
|
// self.browserUserInterfaceStyle = UIDocumentBrowserUserInterfaceStyleDark;
|
|
|
|
// self.view.tintColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
// Specify the allowed content types of your application via the Info.plist.
|
|
|
|
|
|
|
|
// Do any additional setup after loading the view, typically from a nib.
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)documentBrowser:(UIDocumentBrowserViewController *)controller didRequestDocumentCreationWithHandler:(void (^)(NSURL * _Nullable, UIDocumentBrowserImportMode))importHandler {
|
2018-12-04 14:01:45 -06:00
|
|
|
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
|
|
|
|
TemplateCollectionViewController *templateCollectionViewController = [storyBoard instantiateViewControllerWithIdentifier:@"TemplateCollectionViewController"];
|
2018-09-11 01:30:55 -05:00
|
|
|
|
2018-12-05 12:12:34 -06:00
|
|
|
templateCollectionViewController.importHandler = importHandler;
|
|
|
|
[self presentViewController:templateCollectionViewController animated:YES completion:nil];
|
2018-09-11 01:30:55 -05:00
|
|
|
}
|
|
|
|
|
Add a way to have templates specific to a customer deployment
Add two settings: One setting "Template list URL" is a string that
should either be empty (the typical case for a random user of the
app), or contain a https: URL. If this setting is empty, only the
templates bundled in the app are provided.
If the "Template list URL" is non-empty, it should be a https: URL
pointing to a text file (or dynamically generated text resource). That
file is downloaded and read when the app starts. Each line in the file
should either be a comment (starting with a hash '#'), or a https: URL
pointing to a template document, that is of type .ott, .ots, or .otp.
That document is downloaded if it hasn't been downloaded already, or
if its time stamp is newer than that of the already downloaded copy.
Also a thumbnail image for the template, formed by appending ".png" to
its URL, is downloaded, if available.
Any previously downloaded templates that aren't mentioned in the list
file are removed.
The intent is that in some managed mass deployment environment, the
mobile device management software would set up this setting, so that
the end-user devices would see the same templates.
Obviously, this URL does not have to point to a static file on a web
server, but could point to some dynamically generated resource on a
web server, that enumerates the templates available on the server and
returns their URLs as a text document.
Another setting is "Empty tile cache next time". This is a toggle. If
toggled on, the next time a document is opened in the app, the tile
cache is emptied (and the toggle is reset off). This is mostly for
potential problem solving, and might be removd later.
Various refactoring to support the new functionality.
Change-Id: Ie2ebf032acb9e43bb1c6f7ae4d0c449ae66eaa05
2018-12-17 14:18:49 -06:00
|
|
|
-(void)documentBrowser:(UIDocumentBrowserViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)documentURLs {
|
2018-09-11 01:30:55 -05:00
|
|
|
NSURL *sourceURL = documentURLs.firstObject;
|
|
|
|
if (!sourceURL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)documentBrowser:(UIDocumentBrowserViewController *)controller didImportDocumentAtURL:(NSURL *)sourceURL toDestinationURL:(NSURL *)destinationURL {
|
|
|
|
// Present the Document View Controller for the new newly created document
|
|
|
|
[self presentDocumentAtURL:destinationURL];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)documentBrowser:(UIDocumentBrowserViewController *)controller failedToImportDocumentAtURL:(NSURL *)documentURL error:(NSError * _Nullable)error {
|
|
|
|
// Make sure to handle the failed import appropriately, e.g., by presenting an error message to the user.
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)presentDocumentAtURL:(NSURL *)documentURL {
|
|
|
|
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
|
|
|
|
DocumentViewController *documentViewController = [storyBoard instantiateViewControllerWithIdentifier:@"DocumentViewController"];
|
|
|
|
documentViewController.document = [[Document alloc] initWithFileURL:documentURL];
|
2018-11-29 11:21:49 -06:00
|
|
|
documentViewController.document->fakeClientFd = -1;
|
2018-09-11 01:30:55 -05:00
|
|
|
documentViewController.document.viewController = documentViewController;
|
|
|
|
[self presentViewController:documentViewController animated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
// vim:set shiftwidth=4 softtabstop=4 expandtab:
|