@@ -10,7 +10,7 @@ import {
1010 IPro5SlideTextElement ,
1111 IPro5Song ,
1212} from './parser.model' ;
13- import { IXmlPro5Arrangement , IXmlPro5Doc , IXmlPro5DocRoot , IXmlPro5Slide , IXmlPro5SlideGroup } from './xml.model' ;
13+ import { IXmlPro5Doc , IXmlPro5DocRoot , IXmlPro5Slide , IXmlPro5SlideGroup } from './xml.model' ;
1414
1515export class v5Parser {
1616 parse ( fileContent : string ) : IPro5Song {
@@ -45,19 +45,19 @@ export class v5Parser {
4545
4646 const properties = this . getProperties ( parsedDoc . RVPresentationDocument ) ;
4747 const slideGroups = this . getSlideGroups ( parsedDoc . RVPresentationDocument . groups . RVSlideGrouping ) ;
48- const arrangements = this . getArrangements ( parsedDoc . RVPresentationDocument . arrangements . RVSongArrangement , slideGroups ) ;
48+ const arrangements = this . getArrangements ( parsedDoc . RVPresentationDocument , slideGroups ) ;
4949
5050 return { properties, slideGroups, arrangements } ;
5151 }
5252
5353 private getProperties ( xmlDoc : IXmlPro5Doc ) : IPro5Properties {
5454 return {
55- CCLIArtistCredits : xmlDoc [ '@CCLIArtistCredits' ] ,
56- CCLICopyrightInfo : xmlDoc [ '@CCLICopyrightInfo' ] ,
55+ CCLIArtistCredits : xmlDoc [ '@CCLIArtistCredits' ] ?? '' ,
56+ CCLICopyrightInfo : xmlDoc [ '@CCLICopyrightInfo' ] ?? '' ,
5757 CCLIDisplay : Boolean ( xmlDoc [ '@CCLIDisplay' ] ) ,
58- CCLILicenseNumber : xmlDoc [ '@CCLILicenseNumber' ] ,
59- CCLIPublisher : xmlDoc [ '@CCLIPublisher' ] ,
60- CCLISongTitle : xmlDoc [ '@CCLISongTitle' ] ,
58+ CCLILicenseNumber : xmlDoc [ '@CCLILicenseNumber' ] ?? '' ,
59+ CCLIPublisher : xmlDoc [ '@CCLIPublisher' ] ?? '' ,
60+ CCLISongTitle : xmlDoc [ '@CCLISongTitle' ] ?? '' ,
6161 album : xmlDoc [ '@album' ] ,
6262 artist : xmlDoc [ '@artist' ] ,
6363 author : xmlDoc [ '@author' ] ,
@@ -82,7 +82,7 @@ export class v5Parser {
8282 const groupColor = sg [ '@color' ] === '' ? null : Utils . normalizeColorToRgbObj ( sg [ '@color' ] ) ;
8383 return {
8484 groupColor,
85- groupLabel : sg [ '@name' ] ,
85+ groupLabel : sg [ '@name' ] ?? '' ,
8686 groupId : sg [ '@uuid' ] ,
8787 slides : this . getSlidesForGroup ( sg . slides . RVDisplaySlide ) ,
8888 } ;
@@ -139,28 +139,30 @@ export class v5Parser {
139139 } ) ;
140140 }
141141
142- private getArrangements ( xmlArrangements : IXmlPro5Arrangement [ ] , slideGroups : IPro5SlideGroup [ ] ) : IPro5Arrangement [ ] {
142+ private getArrangements ( xmlDoc : IXmlPro5Doc , slideGroups : IPro5SlideGroup [ ] ) : IPro5Arrangement [ ] {
143143 const arrangementsArr : IPro5Arrangement [ ] = [ ] ;
144144
145- for ( const a of xmlArrangements ) {
146- arrangementsArr . push ( {
147- color : Utils . normalizeColorToRgbObj ( a [ '@color' ] ) ,
148- label : a [ '@name' ] ,
149- groupOrder : a . groupIDs . NSMutableString . map ( ( group ) => {
150- //This should always find a match since you can't put something in an arrangement that doesn't already exist
151- //So because of that it's OK to have a non-null assertion here
152- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
153- const slideGroupMatch = slideGroups . find (
154- //Look up the actual slide group by ID so we can get its name
155- ( sg ) => sg . groupId === group [ '@serialization-native-value' ]
156- ) ! ;
145+ if ( xmlDoc . arrangements ?. RVSongArrangement ) {
146+ for ( const a of xmlDoc . arrangements . RVSongArrangement ) {
147+ arrangementsArr . push ( {
148+ color : Utils . normalizeColorToRgbObj ( a [ '@color' ] ) ,
149+ label : a [ '@name' ] ,
150+ groupOrder : a . groupIDs . NSMutableString . map ( ( group ) => {
151+ //This should always find a match since you can't put something in an arrangement that doesn't already exist
152+ //So because of that it's OK to have a non-null assertion here
153+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
154+ const slideGroupMatch = slideGroups . find (
155+ //Look up the actual slide group by ID so we can get its name
156+ ( sg ) => sg . groupId === group [ '@serialization-native-value' ]
157+ ) ! ;
157158
158- return {
159- groupId : group [ '@serialization-native-value' ] ,
160- groupLabel : slideGroupMatch . groupLabel ,
161- } ;
162- } ) ,
163- } ) ;
159+ return {
160+ groupId : group [ '@serialization-native-value' ] ,
161+ groupLabel : slideGroupMatch . groupLabel ,
162+ } ;
163+ } ) ,
164+ } ) ;
165+ }
164166 }
165167
166168 return arrangementsArr ;
0 commit comments