Skip to content

Commit

Permalink
feat: Use new svgs in New file menu
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal authored and juliushaertl committed Mar 21, 2024
1 parent 3d55b8b commit bdfbae2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ public function register(IRegistrationContext $context): void {
}

public function boot(IBootContext $context): void {
$context->injectFn(function (ITemplateManager $templateManager, IL10N $l10n, IConfig $config, CapabilitiesService $capabilitiesService, PermissionManager $permissionManager) {
$context->injectFn(function (ITemplateManager $templateManager, IL10N $l10n, IConfig $config, CapabilitiesService $capabilitiesService, PermissionManager $permissionManager, IAppManager $appManager) {
if (!$permissionManager->isEnabledForUser() || empty($capabilitiesService->getCapabilities())) {
return;
}
$ooxml = $config->getAppValue(self::APPNAME, 'doc_format', '') === 'ooxml';
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odtType = new TemplateFileCreator('richdocuments', $l10n->t('New document'), ($ooxml ? '.docx' : '.odt'));
if ($ooxml) {
$odtType->addMimetype('application/msword');
Expand All @@ -115,11 +115,11 @@ public function boot(IBootContext $context): void {
$odtType->addMimetype('application/vnd.oasis.opendocument.text');
$odtType->addMimetype('application/vnd.oasis.opendocument.text-template');
}
$odtType->setIconClass('icon-filetype-document');
$odtType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-document.svg'));
$odtType->setRatio(21 / 29.7);
return $odtType;
});
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odsType = new TemplateFileCreator('richdocuments', $l10n->t('New spreadsheet'), ($ooxml ? '.xlsx' : '.ods'));
if ($ooxml) {
$odsType->addMimetype('application/vnd.ms-excel');
Expand All @@ -128,11 +128,11 @@ public function boot(IBootContext $context): void {
$odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet');
$odsType->addMimetype('application/vnd.oasis.opendocument.spreadsheet-template');
}
$odsType->setIconClass('icon-filetype-spreadsheet');
$odsType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-spreadsheet.svg'));
$odsType->setRatio(16 / 9);
return $odsType;
});
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odpType = new TemplateFileCreator('richdocuments', $l10n->t('New presentation'), ($ooxml ? '.pptx' : '.odp'));
if ($ooxml) {
$odpType->addMimetype('application/vnd.ms-powerpoint');
Expand All @@ -141,19 +141,19 @@ public function boot(IBootContext $context): void {
$odpType->addMimetype('application/vnd.oasis.opendocument.presentation');
$odpType->addMimetype('application/vnd.oasis.opendocument.presentation-template');
}
$odpType->setIconClass('icon-filetype-presentation');
$odpType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-presentation.svg'));
$odpType->setRatio(16 / 9);
return $odpType;
});

if (!$capabilitiesService->hasDrawSupport()) {
return;
}
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml) {
$templateManager->registerTemplateFileCreator(function () use ($l10n, $ooxml, $appManager) {
$odpType = new TemplateFileCreator('richdocuments', $l10n->t('New diagram'), '.odg');
$odpType->addMimetype('application/vnd.oasis.opendocument.graphics');
$odpType->addMimetype('application/vnd.oasis.opendocument.graphics-template');
$odpType->setIconClass('icon-filetype-draw');
$odpType->setIconSvgInline(file_get_contents($appManager->getAppPath('richdocuments') . '/img/x-office-drawing.svg'));
$odpType->setRatio(1);
return $odpType;
});
Expand Down

0 comments on commit bdfbae2

Please sign in to comment.