Révision 3409

TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/transcription/AddSectionsFromTableMacro.groovy (revision 3409)
33 33

  
34 34
@Field @Option(name="metadataColumnsGroups", usage="Colonnes des gruopes de metadonnées de section", widget="String", required=true, def="metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;metadata;secondary;secondary;secondary;secondary;secondary;secondary;secondary;text;text;text;text")
35 35
		def metadataColumnsGroups
36
		
37
@Field @Option(name="fixSectionsLimits", usage="Correction des limites de sections du tableau de metadonnees", widget="Boolean", required=true, def="true")
38
		def fixSectionsLimits
36 39

  
37 40
@Field @Option(name="debug", usage="show debug messages", widget="String", required=true, def="false")
38 41
		def debug
......
178 181
		
179 182
		//println "Processing $id..."
180 183
		def sections = sectionGroupsToInsert[id]
181
		sections = sections.sort() { a, b -> a[0] <=> b[0] ?: a[1] <=> b[1] }
184
		sections = sections.sort() { a, b -> a[0] <=> b[0] ?: a[1] <=> -b[1] } // negative second test for sections inclusion
182 185
		
186
		if (fixSectionsLimits) {
187
			if (debug) println "Fixing sections of $id"
188
			for (int iSection = 1 ; iSection < sections.size() ; iSection++) {
189
				//println sections[iSection]
190
				if (sections[iSection][0] - sections[iSection - 1][1] > 0.1) {
191
					if (debug) println "s=$iSection start <- end : "+sections[iSection][0]+ " <- "+sections[iSection - 1][1]
192
					sections[iSection][0] = sections[iSection - 1][1] // fix the start time with the previous section end time
193
				}
194
			}
195
		}
196
		
183 197
		// Open input file
184 198
		def slurper = new groovy.util.XmlParser(false, true, true);
185 199
		slurper.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false) // allow DTD declaration

Formats disponibles : Unified diff