Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2021-03-11 11:25:11 +0300
committerGitHub <noreply@github.com>2021-03-11 11:25:11 +0300
commit0691b2dcb4504260fd90731e25cabfb53ff3ff86 (patch)
treee0179bcebb33027df93a418b004be30d320a19f6
parent6402c6345b252c2153343c23e6dd02d2d43ccd28 (diff)
parent9083ff3afece324858245fd4b01b50e1c7ff638f (diff)
Merge pull request #1422 from nextcloud/bugfix/template-ooxmlv4.0.3
Properly handle ooxml with the new template mechanism
-rw-r--r--lib/AppInfo/Application.php44
1 files changed, 31 insertions, 13 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 691bcc24..e6b8bd31 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -27,7 +27,6 @@ namespace OCA\Richdocuments\AppInfo;
use OC\EventDispatcher\SymfonyAdapter;
use OC\Files\Type\Detection;
use OC\Security\CSP\ContentSecurityPolicy;
-use OCA\Federation\TrustedServers;
use OCA\Richdocuments\AppConfig;
use OCA\Richdocuments\Capabilities;
use OCA\Richdocuments\PermissionManager;
@@ -48,7 +47,8 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Template\ITemplateManager;
use OCP\Files\Template\TemplateFileCreator;
-use OCP\GlobalScale\IConfig;
+use OCP\IConfig;
+use OCP\IL10N;
use OCP\IPreview;
class Application extends App implements IBootstrap {
@@ -82,27 +82,45 @@ class Application extends App implements IBootstrap {
\OCP\Util::addScript('richdocuments', 'viewer');
});
- $context->injectFn(function(ITemplateManager $templateManager) {
- $templateManager->registerTemplateFileCreator(function () {
- $odtType = new TemplateFileCreator('richdocuments', 'New document', '.odt');
+ $context->injectFn(function(ITemplateManager $templateManager, IL10N $l10n, IConfig $config) {
+ $ooxml = $config->getAppValue(self::APPNAME, 'doc_format', '') === 'ooxml';
+ $templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
+ $odtType = new TemplateFileCreator('richdocuments', $l10n->t('New document'), ($ooxml ? '.docx' : '.odt'));
+ if ($ooxml) {
+ $odtType->addMimetype('application/msword');
+ $odtType->addMimetype('application/vnd.openxmlformats-officedocument.wordprocessingml.document');
+ } else {
+ $odtType->addMimetype('application/vnd.oasis.opendocument.text');
+ $odtType->addMimetype('application/vnd.oasis.opendocument.text-template');
+ }
$odtType->addMimetype('application/vnd.oasis.opendocument.text');
$odtType->addMimetype('application/vnd.oasis.opendocument.text-template');
$odtType->setIconClass('icon-filetype-document');
$odtType->setRatio(21/29.7);
return $odtType;
});
- $templateManager->registerTemplateFileCreator(function () {
- $odsType = new TemplateFileCreator('richdocuments', 'New spreadsheet', '.ods');
- $odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet');
- $odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet-template');
+ $templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
+ $odsType = new TemplateFileCreator('richdocuments', $l10n->t('New spreadsheet'), ($ooxml ? '.xslx' : '.ods'));
+ if ($ooxml) {
+ $odsType->addMimetype('application/vnd.ms-excel');
+ $odsType->addMimetype('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
+ } else {
+ $odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet');
+ $odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet-template');
+ }
$odsType->setIconClass('icon-filetype-spreadsheet');
$odsType->setRatio(16/9);
return $odsType;
});
- $templateManager->registerTemplateFileCreator(function () {
- $odpType = new TemplateFileCreator('richdocuments', 'New presentation', '.odp');
- $odpType->addMimetype('application/vnd.oasis.opendocument.presentation');
- $odpType->addMimetype('application/vnd.oasis.opendocument.presentation-template');
+ $templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
+ $odpType = new TemplateFileCreator('richdocuments', $l10n->t('New presentation'), ($ooxml ? '.pptx' : '.odp'));
+ if ($ooxml) {
+ $odpType->addMimetype('application/vnd.ms-powerpoint');
+ $odpType->addMimetype('application/vnd.openxmlformats-officedocument.presentationml.presentation');
+ } else {
+ $odpType->addMimetype('application/vnd.oasis.opendocument.presentation');
+ $odpType->addMimetype('application/vnd.oasis.opendocument.presentation-template');
+ }
$odpType->setIconClass('icon-filetype-presentation');
$odpType->setRatio(16/9);
return $odpType;