Skip to content

Commit b1cedb6

Browse files
committed
Impress: add buttons for .uno:InsertCanvasSlide & .uno:ReshufflePages
- Add buttons for .uno:InsertCanvasSlide and .uno:ReshufflePages - Create Widget.NewSlideLayoutEntry.ts for having both grid, and a separate button in the dropdown Signed-off-by: Mohit Marathe <[email protected]> Change-Id: I82120479cf599f9058a6151cda0827ea12c8d777
1 parent 73cc14d commit b1cedb6

File tree

7 files changed

+104
-4
lines changed

7 files changed

+104
-4
lines changed

browser/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ COOL_JS_LST =\
459459
src/control/jsdialog/Widget.MobileBorderSelector.js \
460460
src/control/jsdialog/Widget.MobileTabControl.js \
461461
src/control/jsdialog/Widget.MultilineEdit.js \
462+
src/control/jsdialog/Widget.NewSlideLayoutEntry.ts \
462463
src/control/jsdialog/Widget.OverflowGroup.ts \
463464
src/control/jsdialog/Widget.OverflowManager.ts \
464465
src/control/jsdialog/Widget.Progressbar.js \
@@ -1120,6 +1121,7 @@ pot:
11201121
src/control/jsdialog/Widget.PageSizeEntry.ts \
11211122
src/control/jsdialog/Widget.HTMLContent.ts \
11221123
src/control/jsdialog/Widget.MobileBorderSelector.js \
1124+
src/control/jsdialog/Widget.NewSlideLayoutEntry.ts \
11231125
src/control/jsdialog/Widget.RadioButton.ts \
11241126
src/control/jsdialog/Widget.SidebarContainers.ts \
11251127
src/control/jsdialog/Widget.TreeView.ts \

browser/css/toolbar.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,3 +1934,24 @@ menu-entry-with-icon.padding-left + menu-entry-icon.width */
19341934
font-size: var(--default-font-size);
19351935
color: var(--color-main-text);
19361936
}
1937+
1938+
.slidelayout-button {
1939+
display: flex;
1940+
justify-content: center;
1941+
align-items: center;
1942+
padding: 8px;
1943+
cursor: pointer;
1944+
border-radius: 3px;
1945+
border: 1px solid transparent;
1946+
font-size: var(--default-font-size);
1947+
background-color: var(--color-background-lighter);
1948+
}
1949+
1950+
.slidelayout-button:hover {
1951+
background-color: var(--color-background-dark);
1952+
}
1953+
1954+
.slidelayout-button:focus {
1955+
outline: 2px solid var(--color-primary);
1956+
outline-offset: 2px;
1957+
}

browser/src/control/Control.JSDialogBuilder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ window.L.Control.JSDialogBuilder = window.L.Control.extend({
9393
this._controlHandlers['radiobutton'] = JSDialog.RadioButton;
9494
this._controlHandlers['progressbar'] = JSDialog.progressbar;
9595
this._controlHandlers['pagemarginentry'] = JSDialog.pageMarginEntry;
96+
this._controlHandlers['newslidelayoutentry'] = JSDialog.slideLayoutEntry;
9697
this._controlHandlers['pagesizeentry'] = JSDialog.pageSizeEntry;
9798
this._controlHandlers['checkbox'] = JSDialog.Checkbox;
9899
this._controlHandlers['basespinfield'] = this.baseSpinField;

browser/src/control/Control.NotebookbarImpress.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,7 @@ window.L.Control.NotebookbarImpress = window.L.Control.NotebookbarWriter.extend(
13041304
},
13051305

13061306
getFormatTab: function() {
1307+
const isODF = app.LOUtil.isFileODF(this.map);
13071308
var content = [
13081309
{
13091310
'type': 'overflowgroup',
@@ -1397,6 +1398,15 @@ window.L.Control.NotebookbarImpress = window.L.Control.NotebookbarWriter.extend(
13971398
],
13981399
'vertical': 'true'
13991400
},
1401+
{ type: 'separator', id: 'format-namedescription-break', orientation: 'vertical', 'visible': isODF && app.isExperimentalMode() },
1402+
{
1403+
'id': 'format-shuffle-pages',
1404+
'type': 'bigtoolitem',
1405+
'text': _UNO('.uno:ReshufflePages', 'presentation'),
1406+
'command': '.uno:ReshufflePages',
1407+
'visible': isODF && app.isExperimentalMode(),
1408+
'accessibility': { focusBack: true, combination: 'RP', de: null }
1409+
},
14001410
];
14011411

14021412
return this.getTabPage('Format', content);
@@ -1411,9 +1421,10 @@ window.L.Control.NotebookbarImpress = window.L.Control.NotebookbarWriter.extend(
14111421
'accessibility': { focusBack: true, combination: 'IP', de: null },
14121422
'children' : [
14131423
{
1414-
'id': 'insert-insert-slide',
1415-
'type': 'bigtoolitem',
1416-
'text': _UNO('.uno:InsertSlide', 'presentation'),
1424+
'id': 'home-create-slide:NewSlideLayoutMenu',
1425+
'type': 'menubutton',
1426+
'applyCallback': '.uno:InsertPage',
1427+
'text': _('New'),
14171428
'command': '.uno:InsertPage',
14181429
'accessibility': { focusBack: true, combination: 'IP', de: null }
14191430
},

browser/src/control/jsdialog/Definitions.Menu.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,13 @@ function generatePictureTransparencyMenu(
22652265
menuDefinitions.set('NewSlideLayoutMenu', [
22662266
{
22672267
type: 'json',
2268-
content: generateLayoutPopupGrid('InsertPage'),
2268+
content: {
2269+
id: 'Layout-NewSlideLayoutMenu',
2270+
// _UNO('.uno:InsertCanvasSlide')
2271+
// Keep the above comment for unocommands.py
2272+
type: 'newslidelayoutentry',
2273+
gridContent: generateLayoutPopupGrid('InsertPage'),
2274+
},
22692275
},
22702276
{ type: 'separator' }, // required to show dropdown arrow
22712277
] as Array<MenuDefinition>);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/* -*- js-indent-level: 8 -*- */
2+
/*
3+
* Copyright the Collabora Online contributors.
4+
*
5+
* SPDX-License-Identifier: MPL-2.0
6+
*
7+
* This Source Code Form is subject to the terms of the Mozilla Public
8+
* License, v. 2.0. If a copy of the MPL was not distributed with this
9+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
10+
*/
11+
12+
/**
13+
* Widget.NewSlideLayoutEntry.ts
14+
*
15+
* A JSDialog "json" widget for rendering the slide layout presets
16+
* and the "New Slide Layout" link.
17+
*/
18+
declare var JSDialog: any;
19+
20+
function createSlideLayoutEntryWidget(data: any, builder: any): HTMLElement {
21+
const container = document.createElement('div');
22+
container.className = 'slidelayout-popup-container';
23+
// Build the grid first
24+
const gridData = data.gridContent; // The grid from generateLayoutPopupGrid
25+
const gridContainer = document.createElement('div');
26+
builder.build(gridContainer, [gridData], false);
27+
container.appendChild(gridContainer);
28+
if (app.isExperimentalMode()) {
29+
const hr = document.createElement('hr');
30+
hr.className = 'jsdialog ui-separator horizontal';
31+
container.appendChild(hr);
32+
33+
const button = document.createElement('div');
34+
button.className = 'slidelayout-button';
35+
button.id = 'newcanvasslide';
36+
button.textContent = _('New Canvas Slide');
37+
button.setAttribute('role', 'button');
38+
button.setAttribute('tabindex', '0');
39+
button.addEventListener('click', () => {
40+
builder.map.sendUnoCommand('.uno:InsertCanvasSlide'); // or your command
41+
builder.callback('dialog', 'close', { id: data.id }, null);
42+
});
43+
44+
container.appendChild(button);
45+
}
46+
return container;
47+
}
48+
49+
JSDialog.slideLayoutEntry = function (
50+
parentContainer: Element,
51+
data: any,
52+
builder: any,
53+
) {
54+
const widget = createSlideLayoutEntryWidget(data, builder);
55+
parentContainer.appendChild(widget);
56+
return false;
57+
};

browser/src/unocommands.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ var unoCommandsArray = {
373373
'InsertAxisTitle':{global:{menu:_('Insert Axis Title'),},},
374374
'InsertBookmark':{text:{context:_('Insert Bookmark'),menu:_('Bookmar~k...'),},},
375375
'InsertBreak':{text:{menu:_('Manual ~Break...'),},},
376+
'InsertCanvasSlide':{presentation:{menu:_('New Canvas Slide'),},},
376377
'InsertCaptionDialog':{text:{context:_('Insert Caption...'),menu:_('Caption...'),},},
377378
'InsertCell':{spreadsheet:{context:_('~Insert...'),menu:_('Insert ~Cells...'),},},
378379
'InsertColumnBreak':{spreadsheet:{menu:_('~Column Break'),},text:{menu:_('Insert Column Break'),},},
@@ -531,6 +532,7 @@ var unoCommandsArray = {
531532
'ResetAllDataPoints':{global:{menu:_('Reset all Data Points'),},},
532533
'ResetAttributes':{global:{context:_('Clear Direct Formatting'),menu:_('~Clear Direct Formatting'),},spreadsheet:{context:_('Clear Direct Formatting'),menu:_('Clear ~Direct Formatting'),},text:{context:_('Clear Direct Formatting'),menu:_('Clear ~Direct Formatting'),},},
533534
'ResetDataPoint':{global:{menu:_('Reset Data Point'),},},
535+
'ReshufflePages':{presentation:{menu:_('Re-order pages'),},},
534536
'RightPara':{global:{context:_('Align Right'),menu:_('Right'),},},
535537
'RotateLeft':{text:{menu:_('Rotate 90° ~Left'),},},
536538
'RotateMenu':{global:{menu:_('Rot~ate'),},},

0 commit comments

Comments
 (0)