Browse Source

Add skipped (hidden) slides to Office Slides

Add a Slide.Hidden flag ("Skip slide") that the slide show walks past while the slide stays in the deck and every export.

File formats: pptx reads and writes <p:sld show="0">, odp reads and writes presentation:visibility="hidden" on the drawing-page style, and ppt reads the fHidden flag (import only).

Editor: slide menu and Slide Show tab toggle, faded rail and overview previews with an eye-slash icon, "(skipped)" in the status bar. present.js skips hidden slides for next/prev/Home/End and the presenter view's next slide. Click links and the Preview buttons can still open a skipped slide. Also fixes menu icon vertical alignment.

Desktop: use Cmd instead of Ctrl as the multi-select modifier on macOS, add Cmd+Backspace to delete, ignore Delete while typing in a field, and reset modifier state on window blur.

Docs and tests are updated for the new flag.
Toby Chui 1 month ago
parent
commit
ee2ed42e26

+ 6 - 2
src/mod/office/model/presentation.go

@@ -84,8 +84,12 @@ type Slide struct {
 	BgGrad  *Gradient `json:"bgGrad,omitempty"`
 	Notes   string    `json:"notes,omitempty"`
 	// entry transition: "" / "none" | "fade" | "slide" | "zoom"
-	Transition string    `json:"transition,omitempty"`
-	Objects    []*Object `json:"objects"`
+	Transition string `json:"transition,omitempty"`
+	// Hidden is a slide the slide show skips ("Skip slide" in the editor):
+	// pptx <p:sld show="0">, odp presentation:visibility="hidden". It
+	// stays in the deck and in every export.
+	Hidden  bool      `json:"hidden,omitempty"`
+	Objects []*Object `json:"objects"`
 }
 
 // BgImage is a picture that fills the slide background. X/Y/W/H place the

+ 12 - 0
src/mod/office/odf/odp_reader.go

@@ -155,6 +155,7 @@ func ParseOdp(data []byte) (*model.Presentation, error) {
 		slide := &model.Slide{ID: fmt.Sprintf("s-odp-%d", pi+1), Objects: []*model.Object{}}
 		master := cv.masterOf(page)
 		slide.Bg = cv.backgroundOf(page, master)
+		slide.Hidden = cv.hiddenPage(page)
 		cv.master = master
 		// the master page's own drawing sits underneath the slide's
 		if master != nil {
@@ -248,6 +249,17 @@ func (cv *odpConverter) backgroundOf(page, master *onode) string {
 	return ""
 }
 
+// hiddenPage reports a slide the show skips: presentation:visibility
+// "hidden" on the page's drawing-page style (LibreOffice's Hide Slide)
+func (cv *odpConverter) hiddenPage(page *onode) bool {
+	st, ok := cv.styles[page.attr("style-name")]
+	if !ok || st == nil {
+		return false
+	}
+	props := st.first("drawing-page-properties")
+	return props != nil && props.attr("visibility") == "hidden"
+}
+
 // walkPage draws every shape on a page. When masterOnly is set the
 // placeholders are skipped: on a master page they are prototypes that
 // state where a slide's title and body go, not content of their own.

+ 31 - 0
src/mod/office/odf/odp_test.go

@@ -3,6 +3,8 @@ package odf
 import (
 	"strings"
 	"testing"
+
+	"imuslab.com/arozos/mod/office/model"
 )
 
 // Only fo:font-weight makes a run heavy; a weight word in the family name
@@ -55,3 +57,32 @@ func TestOdpShapeTypesRoundTrip(t *testing.T) {
 		}
 	}
 }
+
+// A skipped slide is LibreOffice's hidden slide: presentation:visibility
+// "hidden" on its drawing-page style, which keeps the slide's colour too.
+func TestOdpSkippedSlides(t *testing.T) {
+	p := &model.Presentation{Slides: []*model.Slide{
+		{ID: "a", Bg: "#112233", Objects: []*model.Object{}},
+		{ID: "b", Bg: "#445566", Hidden: true, Objects: []*model.Object{}},
+		{ID: "c", Hidden: true, Objects: []*model.Object{}},
+	}}
+	data, err := BuildOdp(p)
+	if err != nil {
+		t.Fatal(err)
+	}
+	back, err := ParseOdp(data)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if len(back.Slides) != 3 {
+		t.Fatalf("read back %d slides, want 3", len(back.Slides))
+	}
+	for i, want := range []bool{false, true, true} {
+		if back.Slides[i].Hidden != want {
+			t.Errorf("slide %d hidden = %v, want %v", i+1, back.Slides[i].Hidden, want)
+		}
+	}
+	if back.Slides[1].Bg != "#445566" {
+		t.Errorf("hidden slide background = %q, want #445566", back.Slides[1].Bg)
+	}
+}

+ 9 - 2
src/mod/office/odf/odp_writer.go

@@ -39,9 +39,16 @@ func BuildOdp(p *model.Presentation) ([]byte, error) {
 				bg = "#" + c
 			}
 		}
+		pageProps := ""
 		if strings.HasPrefix(bg, "#") {
-			ps := b.newStyle("drawing-page",
-				`<style:drawing-page-properties draw:fill="solid" draw:fill-color="`+bg+`"/>`)
+			pageProps = ` draw:fill="solid" draw:fill-color="` + bg + `"`
+		}
+		// a skipped slide: LibreOffice's Hide Slide is a page property
+		if slide.Hidden {
+			pageProps += ` presentation:visibility="hidden"`
+		}
+		if pageProps != "" {
+			ps := b.newStyle("drawing-page", `<style:drawing-page-properties`+pageProps+`/>`)
 			pageAttr = ` draw:style-name="` + ps + `"`
 		}
 		body.WriteString(fmt.Sprintf(`<draw:page draw:name="page%d"%s>`, si+1, pageAttr))

+ 8 - 0
src/mod/office/ppt/ppt.go

@@ -92,6 +92,7 @@ type slideRec struct {
 	styles     [9]*masterStyle // a master's text styles by text type
 	isMaster   bool
 	transition string
+	hidden     bool // Hide Slide: the slide show skips it
 	number     int
 }
 
@@ -383,9 +384,16 @@ func (p *pres) readSlide(s *slideRec) {
 	}
 	if ti := s.rec.Child(rtSSSlideInfoAtom); ti != nil && len(ti.Data) >= 10 {
 		s.transition = transitionName(int(ti.Data[9]), int(ti.Data[8]))
+		s.hidden = slideHidden(ti.Data)
 	}
 }
 
+// slideHidden reads fHidden, the third flag bit after the effect bytes of
+// a SlideShowSlideInfoAtom: PowerPoint's Hide Slide
+func slideHidden(info []byte) bool {
+	return len(info) > 10 && info[10]&0x04 != 0
+}
+
 // transitionName maps a SlideShowSlideInfoAtom effect onto the
 // PresentationML transition element
 func transitionName(effect, dir int) string {

+ 28 - 0
src/mod/office/ppt/ppt_test.go

@@ -364,3 +364,31 @@ func TestBoundaryValuesDoNotPanic(t *testing.T) {
 		}
 	}
 }
+
+// fHidden is bit 2 of the flag byte after a SlideShowSlideInfoAtom's
+// effect type; the neighbouring flags must not read as hidden
+func TestHiddenSlideFlag(t *testing.T) {
+	info := func(flags byte) []byte {
+		d := make([]byte, 16)
+		d[9] = 6 // a fade, so the transition bytes are not all zero
+		d[10] = flags
+		return d
+	}
+	cases := []struct {
+		name string
+		data []byte
+		want bool
+	}{
+		{"no flags", info(0), false},
+		{"hidden", info(0x04), true},
+		{"hidden and manual advance", info(0x05), true},
+		{"manual advance only", info(0x01), false},
+		{"sound only", info(0x10), false},
+		{"truncated atom", info(0x04)[:10], false},
+	}
+	for _, c := range cases {
+		if got := slideHidden(c.data); got != c.want {
+			t.Errorf("%s: slideHidden = %v, want %v", c.name, got, c.want)
+		}
+	}
+}

+ 3 - 0
src/mod/office/ppt/writer.go

@@ -300,6 +300,9 @@ func (w *writer) write() ([]byte, error) {
 		if !s.masterObjs {
 			attrs = ` showMasterSp="0"`
 		}
+		if s.hidden {
+			attrs += ` show="0"`
+		}
 		trans := ""
 		if s.transition != "" {
 			trans = `<p:transition><p:` + s.transition + `/></p:transition>`

+ 54 - 0
src/mod/office/pptx/links_test.go

@@ -2,10 +2,12 @@ package pptx
 
 import (
 	"errors"
+	"strconv"
 	"strings"
 	"testing"
 
 	"imuslab.com/arozos/mod/office/internal/officetest"
+	"imuslab.com/arozos/mod/office/internal/xmltree"
 	"imuslab.com/arozos/mod/office/model"
 )
 
@@ -85,3 +87,55 @@ func TestPptxReadsLinkedPictures(t *testing.T) {
 		t.Errorf("media parts = %d, want 1 (the readable picture)", n)
 	}
 }
+
+// A skipped slide is PowerPoint's hidden slide: <p:sld show="0">, and only
+// on that slide. "false" is the same xsd:boolean and reads as hidden too.
+func TestPptxSkippedSlides(t *testing.T) {
+	p := &model.Presentation{Slides: []*model.Slide{
+		{ID: "a", Objects: []*model.Object{}},
+		{ID: "b", Hidden: true, Objects: []*model.Object{}},
+		{ID: "c", Objects: []*model.Object{}},
+	}}
+	data, err := Build(p)
+	if err != nil {
+		t.Fatal(err)
+	}
+	parts := officetest.UnzipParts(t, data)
+	for i, want := range []bool{false, true, false} {
+		xml := parts["ppt/slides/slide"+strconv.Itoa(i+1)+".xml"]
+		if got := strings.Contains(xml, ` show="0"`); got != want {
+			t.Errorf("slide %d show=\"0\" written = %v, want %v", i+1, got, want)
+		}
+	}
+	back, err := Parse(data)
+	if err != nil {
+		t.Fatal(err)
+	}
+	for i, want := range []bool{false, true, false} {
+		if back.Slides[i].Hidden != want {
+			t.Errorf("slide %d read back hidden = %v, want %v", i+1, back.Slides[i].Hidden, want)
+		}
+	}
+}
+
+func TestPptxHiddenSlideAttr(t *testing.T) {
+	cases := []struct {
+		attr string
+		want bool
+	}{
+		{"", false},
+		{` show="1"`, false},
+		{` show="true"`, false},
+		{` show="0"`, true},
+		{` show="false"`, true},
+	}
+	for _, c := range cases {
+		tree, err := xmltree.Parse([]byte(`<p:sld xmlns:p="urn:p"` + c.attr + `><p:cSld/></p:sld>`))
+		if err != nil {
+			t.Fatal(err)
+		}
+		if got := hiddenSlide(tree); got != c.want {
+			t.Errorf("hiddenSlide(%q) = %v, want %v", c.attr, got, c.want)
+		}
+	}
+}

+ 8 - 0
src/mod/office/pptx/reader.go

@@ -384,6 +384,7 @@ func Parse(data []byte) (*model.Presentation, error) {
 		slide := sc.parseSlide(tree)
 		slide.ID = fmt.Sprintf("s-import%d", si+1)
 		slide.Transition = transitionOf(tree)
+		slide.Hidden = hiddenSlide(tree)
 		slide.Notes = sc.extractNotes()
 		out.Slides = append(out.Slides, slide)
 	}
@@ -2177,6 +2178,13 @@ func nearestRecolor(hex string) string {
 
 /* ---------------- transitions and click links ---------------- */
 
+// hiddenSlide reports PowerPoint's Hide Slide: <p:sld show="0"> (an
+// xsd:boolean, so "false" says the same), which the slide show skips
+func hiddenSlide(sld *xmltree.Node) bool {
+	v := strings.TrimSpace(sld.Attr("show"))
+	return v == "0" || v == "false"
+}
+
 // transitionOf maps a slide's <p:transition> onto the editor's three:
 // fade, slide (anything that moves the slide in) and zoom. PowerPoint 2010
 // and later wrap it in mc:AlternateContent, with a plain fallback.

+ 5 - 1
src/mod/office/pptx/writer.go

@@ -245,7 +245,11 @@ func buildSlideXML(p *model.Presentation, slide *model.Slide, mediaSet *pptxMedi
 	relIdx := 2
 
 	sb.WriteString(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>` + "\n")
-	sb.WriteString(`<p:sld ` + nsDecl + `><p:cSld>`)
+	show := ""
+	if slide.Hidden {
+		show = ` show="0"`
+	}
+	sb.WriteString(`<p:sld ` + nsDecl + show + `><p:cSld>`)
 
 	// slide background: a gradient or a picture when the slide has one,
 	// else its colour, else the theme's approximation

+ 21 - 5
src/web/Office/README.md

@@ -194,12 +194,27 @@ every format keeps it):
 Ctrl+Alt+1): the deck as a grid, like Google Slides' grid view or
 PowerPoint's Slide Sorter (`renderOverview` in `slides.js`). Click selects,
 double-click or Enter opens the slide, drag reorders, right-click has the
-slide menu, Delete / Ctrl+D / Ctrl+M act on the slide in hand, arrows move
+slide menu (the rail's own: new, duplicate, delete, **Skip / Unskip slide**,
+move, background), Delete / Ctrl+D / Ctrl+M act on the slide in hand, arrows move
 by card and by row, Escape goes back. The previews are the same
 `renderSlideContent()` the rail uses, and `renderThumb` / `renderRail` keep
 the grid in step with every edit; the floating control at the bottom sets
 the card size (`overviewSize`, saved).
 
+**Skipped slides** (Google Slides' Skip slide, PowerPoint's Hide Slide):
+the slide menu and the Slide Show tab toggle `slide.hidden`
+(`toggleSlideSkip` in `slides.js`). The rail and the overview fade the
+preview, strike the number through and add an eye-slash; the status bar
+says "(skipped)". The slide show walks past it (`shownFrom` in
+`present.js`): next / previous / Home / End, starting from a skipped slide
+starts at the next shown one, and the presenter view's next slide is the
+next shown one. A click link to a skipped slide still opens it (backup
+slides), and the Transitions / Animations Preview plays it
+(`showSkipped`). Skipped slides stay in the deck and in every export (PDF,
+PNG, print). Files carry it as pptx `<p:sld show="0">`, odp
+`presentation:visibility="hidden"` and, read only, the `fHidden` bit of a
+.ppt slide.
+
 ## Document body schemas (the JSON each app edits)
 
 Go structs are the source of truth — they mirror the JS exactly:
@@ -251,7 +266,8 @@ Go structs are the source of truth — they mirror the JS exactly:
   so the Go structs do not model it.
 - **Slides** (`presentation`): [`model/presentation.go`](../../mod/office/model/presentation.go) —
   `{size:[960,540], theme, slides[{id, bg, bgImage, bgGrad, notes,
-  objects[{type, x, y, w, h, rot, z, props}]}]}`. Object types: `text`,
+  transition, hidden, objects[{type, x, y, w, h, rot, z, props}]}]}`.
+  `hidden: true` is a skipped slide (absent otherwise). Object types: `text`,
   `image`, `shape`, `line`, `table`, `chart`, `video`, `audio`. `size` is
   960 wide and as tall as the deck's shape - a 4:3 PowerPoint deck is
   960x720, never squeezed into 16:9 (the editor, present mode and the PDF
@@ -314,11 +330,11 @@ keeps for the suite:
 |---|---|---|
 | Docs | text, styles, lists, tables, pictures, footnotes, headers/footers, **comments** (resolved state included) and **suggestions as tracked changes** ([`docx/review.go`](../../mod/office/docx/review.go)), "Suggest edits" as `trackRevisions` | - |
 | Sheets | cells, formulas, styles (font, size, colours, bold / italic / underline / strikethrough, horizontal and vertical alignment, wrap), merges, freeze panes, hidden rows, charts, notes, defined names, **conditional formats** (every editor condition, [`xlsx/cf.go`](../../mod/office/xlsx/cf.go)), **tab colours**, the **filter range** | pivot settings, the filter's hidden values |
-| Slides | every object, **transitions** (fade / push / zoom), **click links** (to a slide or a URL), **line dashes and ends** (a square end as a diamond, an open end as the filled one - PowerPoint has neither), **picture frames**, **callout tips**, charts as pictures, videos as their poster frame | groups, entrance animations, live charts, the video/audio files, the exact line end |
+| Slides | every object, **transitions** (fade / push / zoom), **skipped slides** (`show="0"`), **click links** (to a slide or a URL), **line dashes and ends** (a square end as a diamond, an open end as the filled one - PowerPoint has neither), **picture frames**, **callout tips**, charts as pictures, videos as their poster frame | groups, entrance animations, live charts, the video/audio files, the exact line end |
 
 The reverse holds too: comments, tracked changes, conditional formats, tab
-colours, filter ranges, transitions and click links made in Office
-applications are read back.
+colours, filter ranges, transitions, hidden slides and click links made in
+Office applications are read back.
 
 ### Office 97-2003 files (.doc / .xls / .ppt) — import only
 

+ 3 - 1
src/web/Office/common/CONTRACT.md

@@ -782,7 +782,9 @@ on click while presenting). New object types `video` / `audio` link their
 media (the .pptx shows the poster frame; the file itself travels in the
 editor copy the .pptx embeds). Each slide has
 `transition` ("none"|"fade"|"slide"|"zoom"), written as PowerPoint's
-fade / push / zoom, and `props.link` becomes an `a:hlinkClick`. Text boxes support `<ul>`/`<ol>`
+fade / push / zoom, and `props.link` becomes an `a:hlinkClick`. A slide may
+carry `hidden: true` ("Skip slide"): present.js walks past it except through
+a click link, and pptx writes it as `<p:sld show="0">`. Text boxes support `<ul>`/`<ol>`
 lists via execCommand; htmlToLines (mod/office) flattens them to bullet/number
 prefixes for .pptx. present.js adds transitions, click-to-reveal animations,
 laser pointer (L), interactive links, and a presenter-view popup.

+ 1 - 0
src/web/Office/common/icons.js

@@ -119,6 +119,7 @@ var OfficeIcons = (function () {
         overview: '<rect x="2.5" y="4" width="8.5" height="6.5" rx="1"/><rect x="13" y="4" width="8.5" height="6.5" rx="1"/><rect x="2.5" y="13.5" width="8.5" height="6.5" rx="1"/><rect class="accs" x="13" y="13.5" width="8.5" height="6.5" rx="1"/>',
         normalView: '<rect x="2.5" y="4" width="5" height="16" rx="1"/><rect class="accs" x="9.5" y="4" width="12" height="10" rx="1"/><path d="M9.5 17h12M9.5 20h8"/>',
         notes: '<rect x="3" y="3" width="18" height="11" rx="1"/><path class="accs" d="M3 17.5h18M3 21h12"/>',
+        skipSlide: '<path d="M2 12c2.4-4.2 5.8-6.5 10-6.5s7.6 2.3 10 6.5c-2.4 4.2-5.8 6.5-10 6.5S4.4 16.2 2 12z"/><circle cx="12" cy="12" r="3"/><path class="accs" d="M4 3.5l16 17"/>',
         snap: '<path d="M3 3h18v18H3zM9 3v18M15 3v18M3 9h18M3 15h18" opacity=".45"/><path class="accs" d="M6 18l3-3 3 3"/>',
         group: '<path d="M3 3h18v18H3z" stroke-dasharray="2 1.8"/><rect x="6" y="6" width="7" height="6" rx="1"/><rect class="accs" x="11" y="11" width="7" height="7" rx="1"/>',
         bringFront: '<rect x="3" y="3" width="11" height="11" rx="1" opacity=".5"/><rect class="acc" x="8" y="8" width="11" height="11" rx="1"/>',

+ 4 - 0
src/web/Office/common/office.css

@@ -141,6 +141,10 @@ body.of-app {
     margin: 0 !important;
     color: var(--of-fg-soft);
     font-size: 13px !important;
+    /* the icon box is 1em tall; with the item's 20px line-height the
+       glyph sat at the top of a taller line and showed below the label's
+       middle. A 1em line keeps it inside the box the flex row centres. */
+    line-height: 1;
 }
 .of-menu-item .of-mi-label { flex: 1 1 auto; }
 /* a menu entry shown as a picture of its choice (it.html): line samples */

+ 38 - 9
src/web/Office/slides/present.js

@@ -7,6 +7,9 @@
                     interactive object links, a laser pointer (L key),
                     slide counter, presenter timer and a presenter view
                     popup (current + next slide + speaker notes).
+                    Skipped slides (slide.hidden, "Skip slide") are walked
+                    past; only a click link to one still opens it, the way
+                    PowerPoint keeps hidden slides as backup slides.
     SlidesExport  - PNG export (PDF export is server-side, see slides.js).
 */
 
@@ -24,6 +27,15 @@ var SlidesPresent = (function () {
     function slideCount() { return SlidesApp.slideCount(); }
     function slideAt(i) { return SlidesApp.getBody().slides[i]; }
 
+    // the first slide from i on, walking by dir (+1 / -1), that the show
+    // does not skip; -1 when there is none that way
+    function shownFrom(i, dir) {
+        for (var n = slideCount(); i >= 0 && i < n; i += dir) {
+            if (!slideAt(i).hidden) return i;
+        }
+        return -1;
+    }
+
     // objects with an entrance animation, in stacking order
     function animQueue(slide) {
         return (slide.objects || []).filter(function (o) {
@@ -97,14 +109,16 @@ var SlidesPresent = (function () {
 
     function next() {
         if (revealNext()) return;
-        if (idx >= slideCount() - 1) { stop(); return; }
-        idx++;
+        var n = shownFrom(idx + 1, 1);
+        if (n < 0) { stop(); return; }
+        idx = n;
         revealed = 0;
         renderCurrent(true);
     }
     function prev() {
-        if (idx <= 0) return;
-        idx--;
+        var p = shownFrom(idx - 1, -1);
+        if (p < 0) return;
+        idx = p;
         // going back shows the previous slide fully revealed
         revealed = animQueue(slideAt(idx)).length;
         renderCurrent(false);
@@ -173,9 +187,13 @@ var SlidesPresent = (function () {
             case "ArrowLeft": case "ArrowUp": case "PageUp": case "Backspace":
                 e.preventDefault(); e.stopPropagation(); prev(); break;
             case "Home":
-                e.preventDefault(); e.stopPropagation(); goTo(0); break;
+                e.preventDefault(); e.stopPropagation();
+                if (shownFrom(0, 1) >= 0) goTo(shownFrom(0, 1));
+                break;
             case "End":
-                e.preventDefault(); e.stopPropagation(); goTo(slideCount() - 1); break;
+                e.preventDefault(); e.stopPropagation();
+                if (shownFrom(slideCount() - 1, -1) >= 0) goTo(shownFrom(slideCount() - 1, -1));
+                break;
             case "l": case "L":
                 e.preventDefault(); e.stopPropagation(); setLaser(!laserOn); break;
             case "Escape":
@@ -274,8 +292,9 @@ var SlidesPresent = (function () {
             curStage.innerHTML = stageEl.innerHTML;
             curStage.style.background = stageEl.style.background;
             curStage.style.color = stageEl.style.color;
-            if (idx + 1 < body.slides.length) {
-                SlidesApp.renderSlideContent(nextStage, body.slides[idx + 1]);
+            var nx = shownFrom(idx + 1, 1);
+            if (nx >= 0) {
+                SlidesApp.renderSlideContent(nextStage, body.slides[nx]);
             } else {
                 nextStage.innerHTML = "";
                 nextStage.style.background = "#111";
@@ -285,11 +304,21 @@ var SlidesPresent = (function () {
         } catch (e) { /* popup navigated away or closed */ }
     }
 
+    /* opts.presenter opens the presenter view too; opts.showSkipped plays
+       the slide asked for even when it is skipped (the Transitions and
+       Animations tabs' Preview), where otherwise the show starts at the
+       next slide it does not skip. */
     function start(fromIndex, opts) {
         if (active) return;
         if (!slideCount()) return;
+        var from = Math.max(0, Math.min(fromIndex || 0, slideCount() - 1));
+        if (!(opts && opts.showSkipped)) from = shownFrom(from, 1);
+        if (from < 0) {
+            OfficeApp.toast(fromIndex ? "Every slide from here on is skipped" : "Every slide is skipped", "info");
+            return;
+        }
         active = true;
-        idx = Math.max(0, Math.min(fromIndex || 0, slideCount() - 1));
+        idx = from;
         revealed = 0;
         laserOn = false;
         ignoreFsExit = false;

+ 9 - 0
src/web/Office/slides/slides.css

@@ -96,6 +96,15 @@
 .sl-thumb.drop-before::before { top: -7px; }
 .sl-thumb.drop-after::after { bottom: -7px; }
 .sl-thumb.dragging { opacity: 0.45; }
+/* a skipped slide ("Skip slide", slide.hidden): the preview fades, the
+   number is struck through and an eye-slash sits under it, here and in
+   the overview - the slide show walks past it (present.js) */
+.sl-thumb.sl-skipped .sl-thumb-mini,
+.sl-ov-card.sl-skipped .sl-ov-mini { opacity: 0.35; }
+.sl-thumb.sl-skipped .sl-thumb-num,
+.sl-ov-card.sl-skipped .sl-ov-num { text-decoration: line-through; }
+.sl-thumb-num .sl-skip-mark { display: block; margin-top: 4px; }
+.sl-thumb-num .sl-skip-mark .of-ic { width: 13px; height: 13px; margin-left: auto; }
 
 /* ---- Center column ---- */
 #slMain {

+ 43 - 4
src/web/Office/slides/slides.js

@@ -329,6 +329,7 @@ var SlidesApp = (function () {
                 !s.bgGrad.stops.length) delete s.bgGrad;
             s.notes = typeof s.notes === "string" ? s.notes : "";
             if (typeof s.transition !== "string") s.transition = "none";
+            if (s.hidden !== true) delete s.hidden;
             if (!Array.isArray(s.objects)) s.objects = [];
             s.objects = s.objects.filter(function (o) { return o && TYPE_NAMES[o.type]; });
             s.objects.forEach(function (o, i) {
@@ -1323,7 +1324,12 @@ var SlidesApp = (function () {
         body.slides.forEach(function (s, i) {
             var $th = $('<div class="sl-thumb" draggable="true" tabindex="0"></div>');
             if (i === cur) $th.addClass("active");
-            $th.append('<div class="sl-thumb-num">' + (i + 1) + "</div>");
+            var $num = $('<div class="sl-thumb-num"></div>').text(i + 1);
+            if (s.hidden) {
+                $th.addClass("sl-skipped");
+                $num.append($('<span class="sl-skip-mark"></span>').attr("title", SKIP_TIP).html(OfficeIcons.get("skipSlide")));
+            }
+            $th.append($num);
             var $view = $('<div class="sl-thumb-view"><div class="sl-thumb-mini sl-slidebase sl-showph"></div></div>');
             $th.append($view);
             renderSlideContent($view.find(".sl-thumb-mini")[0], s);
@@ -1410,7 +1416,8 @@ var SlidesApp = (function () {
 
     /* ================= status / notes ================= */
     function updateStatus() {
-        OfficeApp.updateStatusItem("slide", "Slide " + (cur + 1) + " of " + body.slides.length);
+        OfficeApp.updateStatusItem("slide", "Slide " + (cur + 1) + " of " + body.slides.length +
+            (curSlide() && curSlide().hidden ? " (skipped)" : ""));
         var msg = "";
         var so = selObjs();
         if (so.length === 1) msg = TYPE_NAMES[so[0].type] || "";
@@ -1592,11 +1599,33 @@ var SlidesApp = (function () {
         body.slides.splice(to, 0, s);
         structCommit(to);
     }
+    /* Skip slide, Google Slides' name for PowerPoint's Hide Slide: the
+       slide stays in the deck, the rail, the overview and every export,
+       but the slide show walks past it (present.js). The model keeps it
+       as slide.hidden, which the .pptx writes as <p:sld show="0">. */
+    var SKIP_TIP = "Skipped in the slide show";
+    function toggleSlideSkip(i) {
+        var s = body.slides[i];
+        if (!s) return;
+        endEdit(true);
+        if (s.hidden) delete s.hidden;
+        else s.hidden = true;
+        structCommit(i);
+        if (window.OfficeRibbon) OfficeRibbon.refresh();
+        OfficeApp.setStatus(s.hidden ? "Slide " + (i + 1) + " will be skipped in the slide show"
+            : "Slide " + (i + 1) + " is back in the slide show", "info", 3000);
+    }
     function showSlideContextMenu(x, y, i) {
+        var skipped = !!(body.slides[i] && body.slides[i].hidden);
         OfficeApp.showContextMenu(x, y, [
             { label: "New slide", icon: "plus", action: function () { addSlideAfter(i); } },
             { label: "Duplicate slide", icon: "clone outline", action: function () { duplicateSlide(i); } },
             { label: "Delete slide", icon: "trash alternate outline", action: function () { deleteSlide(i); } },
+            {
+                label: skipped ? "Unskip slide" : "Skip slide",
+                icon: skipped ? "eye" : "eye slash outline",
+                action: function () { toggleSlideSkip(i); }
+            },
             { sep: true },
             {
                 label: "Move up", icon: "angle up",
@@ -3919,7 +3948,7 @@ var SlidesApp = (function () {
                     OfficeApp.setStatus("Transition applied to every slide");
                 }
             }))
-            .add(R.big({ svg: "present", label: "Preview", title: "Play this slide from here", onClick: function () { startPresent(cur); } }));
+            .add(R.big({ svg: "present", label: "Preview", title: "Play this slide from here", onClick: function () { startPresent(cur, { showSkipped: true }); } }));
 
         /* ---------- Animations ---------- */
         var an = R.tab("animations", "Animations");
@@ -3943,7 +3972,7 @@ var SlidesApp = (function () {
             }));
         an.group({ id: "interaction", label: "Interaction", svg: "link" })
             .add(R.big({ svg: "link", label: "Click link", title: "Link the object to a slide or a web page", enabled: function () { return sel.length === 1; }, onClick: linkDialog }))
-            .add(R.big({ svg: "present", label: "Preview", onClick: function () { startPresent(cur); } }));
+            .add(R.big({ svg: "present", label: "Preview", onClick: function () { startPresent(cur, { showSkipped: true }); } }));
 
         /* ---------- Slide Show ---------- */
         var show = R.tab("slideshow", "Slide Show");
@@ -3952,6 +3981,11 @@ var SlidesApp = (function () {
             .add(R.big({ svg: "present", label: "From current slide", key: "F5", onClick: function () { startPresent(cur); } }))
             .add(R.big({ svg: "presenter", label: "Presenter view", onClick: function () { startPresent(cur, { presenter: true }); } }));
         show.group({ id: "setup", label: "Set Up", svg: "notes" })
+            .add(R.big({
+                svg: "skipSlide", label: "Skip slide", title: "Leave this slide out of the slide show",
+                active: function () { return !!(curSlide() && curSlide().hidden); },
+                onClick: function () { toggleSlideSkip(cur); }
+            }))
             .add(R.big({ svg: "notes", label: "Speaker notes", active: notesShown, onClick: function () { toggleNotes(); OfficeRibbon.refresh(); } }));
 
         /* ---------- View ---------- */
@@ -4576,9 +4610,13 @@ var SlidesApp = (function () {
         body.slides.forEach(function (s, i) {
             var $c = $('<div class="sl-ov-card" tabindex="0" draggable="true"></div>').attr("data-i", i);
             if (i === cur) $c.addClass("active");
+            if (s.hidden) $c.addClass("sl-skipped");
             var $v = $('<div class="sl-ov-view"><div class="sl-ov-mini sl-slidebase sl-showph"></div></div>');
             $c.append($v);
             var $meta = $('<div class="sl-ov-meta"></div>').append('<span class="sl-ov-num">' + (i + 1) + "</span>");
+            if (s.hidden) {
+                $meta.append($('<span class="sl-ov-flag sl-skip-mark"></span>').attr("title", SKIP_TIP).html(OfficeIcons.get("skipSlide")));
+            }
             if (s.transition && s.transition !== "none") {
                 $meta.append('<span class="sl-ov-flag" title="Transition: ' + esc(s.transition) + '">' + OfficeIcons.get("transition") + "</span>");
             }
@@ -4656,6 +4694,7 @@ var SlidesApp = (function () {
         renderEditorSlide();
         syncNotes();
         updateStatus();
+        if (window.OfficeRibbon) OfficeRibbon.refresh();
     }
     function overviewColumns() {
         var cards = document.querySelectorAll("#slOverview .sl-ov-card");

+ 45 - 6
src/web/desktop.html

@@ -5295,6 +5295,13 @@
             }
             hideAllContextMenus();
         
+            //The click's own modifier state wins over the tracked flag: Cmd on a
+            //Mac, Ctrl elsewhere. Ctrl + click on a Mac is the right click, so it
+            //selects like one instead of toggling
+            if (evt != undefined && evt.type == "mousedown"){
+                ctrlHold = isPrimaryModifierHeld(evt);
+            }
+
             //Clicked on a launch icon.
             var alreadyHighlighted = $(object).find(".launchIconWrapper").hasClass("selected");
             if (alreadyHighlighted){
@@ -5432,10 +5439,35 @@
         })
 
         // ======================= DOCUMENT KEY BINDING =====================
+        /*
+            The multi-select / shortcut modifier is Cmd on a Mac and Ctrl
+            elsewhere. Cmd reports keyCode 91 / 93 in Chrome and Safari and 224
+            in Firefox.
+        */
+        function isPrimaryModifierKey(event){
+            let keycode = event.which || event.keyCode;
+            if (isMacOS){
+                return event.key == "Meta" || keycode == 91 || keycode == 93 || keycode == 224;
+            }
+            return event.key == "Control" || keycode == 17;
+        }
+
+        function isPrimaryModifierHeld(event){
+            return isMacOS ? !!event.metaKey : !!event.ctrlKey;
+        }
+
+        //Typing in a text field must never act on the selected desktop icons
+        function isTypingTarget(target){
+            return $(target).is("input, textarea, select, [contenteditable='true']");
+        }
+
         document.addEventListener('keydown', function(event) {
             let keycode = event.which || event.keyCode;
-            if (keycode == "17") {
-                //Pressdown of Ctrl key
+            if (isPrimaryModifierHeld(event)){
+                ctrlHold = true;
+            }
+            if (isPrimaryModifierKey(event)) {
+                //Pressdown of Ctrl (Cmd on a Mac) key
                 ctrlHold = true;
             } else if (keycode == "16") {
                 //Pressdown of Shift key
@@ -5451,10 +5483,10 @@
                 multiSelecting = false;
                 ctrlHold = false;
                 shiftHold = false;
-            }else if (keycode == "46"){
-                //Delete key
+            }else if (keycode == "46" || (keycode == "8" && isMacOS && ctrlHold)){
+                //Delete key, or Cmd + Backspace on a Mac (no Delete key there)
 
-                if (renameMode){
+                if (renameMode || isTypingTarget(event.target)){
                     //Deleting content in textarea. Ignore delte action
                     return true
                 }
@@ -5534,7 +5566,7 @@
 
         $(document).keyup(function(event) {
             let keycode = event.which || event.keyCode;
-            if (keycode == "17") {
+            if (isPrimaryModifierKey(event)) {
                 ctrlHold = false;
             }else if (keycode == "16") {
                 shiftHold = false;
@@ -5553,6 +5585,13 @@
             }
         });
 
+        //A modifier released while the desktop is not focused (Cmd + Tab, or
+        //inside a float window's iframe) never sends its keyup here
+        $(window).on("blur", function(){
+            ctrlHold = false;
+            shiftHold = false;
+        });
+
         $("#bgwrapper").on("mouseup", function(event) {
             //Deselect all selected icons
             event.preventDefault();