-
Notifications
You must be signed in to change notification settings - Fork 0
/
append_master.go
61 lines (55 loc) · 1.22 KB
/
append_master.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"log"
"google.golang.org/api/slides/v1"
)
func appendMasterAndLayout(
source, target *slides.Presentation,
sourceMasterID, sourceLayoutID string,
batch *slides.BatchUpdatePresentationRequest) string {
masterExists := false
for _, each := range target.Masters {
if each.ObjectId == sourceMasterID {
masterExists = true
break
}
}
layoutExists := false
for _, each := range target.Layouts {
if each.ObjectId == sourceLayoutID {
layoutExists = true
break
}
}
if !masterExists {
var master *slides.Page
for _, each := range source.Masters {
if each.ObjectId == sourceMasterID {
master = each
break
}
}
if master == nil {
panic("no such master" + sourceMasterID)
}
log.Println("copying src master:", sourceMasterID)
appendMaster(master, batch)
}
if !layoutExists {
var layout *slides.Page
for _, each := range source.Layouts {
if each.ObjectId == sourceLayoutID {
layout = each
break
}
}
if layout == nil {
panic("no such layout" + sourceLayoutID)
}
log.Println("copying src layout:", sourceLayoutID)
}
return ""
}
func appendMaster(sourceMaster *slides.Page, batch *slides.BatchUpdatePresentationRequest) {
//dump(sourceMaster)
}