Skip to content

Commit 0e671bd

Browse files
committed
fix bogus 404 errors for sidebar toolbar icons
Sidebar JSDialog toolbox items send icon names with LO's 'sc_' (small-command) prefix, but COOL only has 'lc_' (large-command) icons, resulting in requests for non-existent files like lc_sc_changecasetoupper.svg. The data.icon code path in _unoToolButton bypassed getIconNameOfCommand entirely, so normalize it through that function to apply sc_ prefix stripping and alias resolution. Also: - skip legacy LO resource IDs (like sr20006) - add icon aliases: insertfooter, textbodyparastyle, showmultiplepages, showtwopages, validatedialogsa11y, validatesidebara11y - add changecasetoupper icon (light + dark) from colibre theme - add dark mode icon for ai_sidebar Signed-off-by: Andras Timar <andras.timar@collabora.com> Change-Id: I6a91b161af0269330265822440c3f0a87fbb104b
1 parent deec650 commit 0e671bd

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

browser/src/app/LOUtil.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,16 @@ class LOUtil {
406406
}
407407

408408
// Skip icon lookup for numeric-only IDs (JSDialog artifacts like 1, 5, 65535)
409-
if (/^\d+$/.test(cleanName)) return '';
409+
// and LO StarRes resource IDs (like sr20006)
410+
if (/^\d+$/.test(cleanName) || /^sr\d+$/.test(cleanName)) return '';
410411

411412
// Skip icon lookup for overflow button pseudo-commands
412413
if (cleanName.startsWith('overflow-button-')) return '';
413414

415+
// Strip 'sc_' prefix from sidebar controller command names
416+
// (LO's small-command icon prefix that doesn't apply to COOL)
417+
if (cleanName.startsWith('sc_')) cleanName = cleanName.substring(3);
418+
414419
var iconURLAliases: IconNameMap = {
415420
// lc_closemobile.svg is generated when loading in NB mode then
416421
// switch to compact mode: 1st hidden element in the top toolbar
@@ -432,6 +437,7 @@ class LOUtil {
432437
formatsparklinemenu: 'insertsparkline',
433438
insertdatecontentcontrol: 'datefield',
434439
editheaderandfooter: 'headerandfooter',
440+
insertfooter: 'insertpagefooter',
435441
exportas: 'saveas',
436442
insertheaderfooter: 'headerandfooter',
437443
previoustrackedchange: 'prevrecord',
@@ -456,6 +462,7 @@ class LOUtil {
456462
insertrowsafter: 'insertrowsmenu',
457463
insertobjectchart: 'drawchart',
458464
textpropertypanel: 'sidebartextpanel',
465+
textbodyparastyle: 'parastyle',
459466
spacepara15: 'linespacing',
460467
orientationdegrees: 'rotation',
461468
clearoutline: 'delete',
@@ -527,6 +534,8 @@ class LOUtil {
527534
tableautofitmenu: 'columnwidth',
528535
menucolumnwidth: 'columnwidth',
529536
hyphenation: 'hyphenate',
537+
validatedialogsa11y: 'validation',
538+
validatesidebara11y: 'validation',
530539
objectbackone: 'behindobject',
531540
deleteannotation: 'deletenote',
532541
areapropertypanel: 'chartareapanel',
@@ -631,6 +640,8 @@ class LOUtil {
631640
graphicfiltersharpen: 'graphicfiltersharpen',
632641
graphicfiltersobel: 'graphicfiltersobel',
633642
effects: 'pictureeffectsmenu',
643+
showmultiplepages: 'multipageview',
644+
showtwopages: 'multipageview',
634645
fitwidthzoom: 'pagewidth',
635646
open: 'formularesfapopen',
636647
'exportas-pdf': 'exportpdf',

browser/src/control/Control.JSDialogBuilder.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,22 @@ window.L.Control.JSDialogBuilder = window.L.Control.extend({
19151915
else if (hasImage !== false){
19161916
if (data.icon) {
19171917
buttonImage = window.L.DomUtil.create('img', '', button);
1918-
this._isStringCloseToURL(data.icon) ? buttonImage.src = data.icon : app.LOUtil.setImage(buttonImage, data.icon, builder.map);
1918+
if (this._isStringCloseToURL(data.icon)) {
1919+
buttonImage.src = data.icon;
1920+
} else {
1921+
// Normalize LO icon filenames through getIconNameOfCommand
1922+
// to apply sc_ prefix stripping and alias resolution
1923+
var normalizedIcon = data.icon;
1924+
var iconMatch = data.icon.match(/^lc_(.+)\.svg$/);
1925+
if (iconMatch) {
1926+
normalizedIcon = app.LOUtil.getIconNameOfCommand(iconMatch[1], true);
1927+
}
1928+
if (normalizedIcon) {
1929+
app.LOUtil.setImage(buttonImage, normalizedIcon, builder.map);
1930+
} else {
1931+
buttonImage = false;
1932+
}
1933+
}
19191934
}
19201935
else if (data.image) {
19211936
buttonImage = window.L.DomUtil.create('img', '', button);

0 commit comments

Comments
 (0)