Skip to content

Commit f847029

Browse files
Remove invalid local-table entries and graphc preview links
Charts saved from OpenOffice contain a copy of the data tables used to generate them as well as a reference to the original sheet data. Remove these local-data tables because they're no longer valid after we replace with new test results. Also blow away links to the cached chart images as we've removed them (again because they're no longer valid after we change sheet data).
1 parent ad758e0 commit f847029

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ezfio.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,12 +961,20 @@ VNEBUEsFBgAAAAABAAEAWgAAAFQAAAAAAA==
961961
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
962962
$wr.Write( $xmltext )
963963
$wr.Close()
964+
} elseif ($entry.FullName -like "Object */content.xml") {
965+
# Remove <table:table table:name="local-table"> table
966+
$rd = New-Object System.IO.StreamReader( $entry.Open() )
967+
$rdbytes = $rd.ReadToEnd()
968+
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
969+
$wrbytes = $rdbytes -replace "<table:table table:name=`"local-table`">.*</table:table>", ""
970+
$wr.write( $wrbytes )
971+
$wr.Close()
972+
$rd.Close()
964973
} elseif ($entry.FullName -eq "META-INF/manifest.xml") {
965974
# Remove ObjectReplacements from the list
966975
$rd = New-Object System.IO.StreamReader( $entry.Open() )
967976
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
968977
$rdbytes = $rd.ReadToEnd()
969-
$rd.close()
970978
$lines = $rdbytes.Split("`n")
971979
foreach ($line in $lines) {
972980
if ( -not ( ($line -contains "ObjectReplacement") -or ($line -contains "Thumbnails") ) ) {
@@ -975,6 +983,7 @@ VNEBUEsFBgAAAAABAAEAWgAAAFQAAAAAAA==
975983
}
976984
}
977985
$wr.Close();
986+
$rd.Close()
978987
} else {
979988
# Copying data for from the source ZIP
980989
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
@@ -994,6 +1003,8 @@ VNEBUEsFBgAAAAABAAEAWgAAAFQAAAAAAA==
9941003
[string]$xmlsrc = GetContentXMLFromODS $global:odssrc
9951004
$xmlsrc = ReplaceSheetWithCSV_regex Timeseries $global:timeseriescsv $xmlsrc
9961005
$xmlsrc = ReplaceSheetWithCSV_regex Tests $global:testcsv $xmlsrc
1006+
# Remove draw:image references to deleted binary previews
1007+
$xmlsrc = $xmlsrc -replace "<draw:image.*?/>",""
9971008
$xmlsrc = $xmlsrc -replace "_DRIVE",$global:physDrive -replace "_TESTCAP",$global:testcapacity -replace "_MODEL",$global:model -replace "_SERIAL",$global:serial -replace "_OS",$global:os -replace "_FIO",$global:fioVerString
9981009
UpdateContentXMLToODS_text $global:odssrc $global:odsdest $xmlsrc
9991010
}

ezfio.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,11 @@ def UpdateContentXMLToODS_text( odssrc, odsdest, xmltext ):
806806
continue
807807
elif entry == "content.xml":
808808
zadst.writestr( "content.xml", xmltext)
809+
elif ("Object" in entry) and ("content.xml" in entry):
810+
# Remove <table:table table:name="local-table"> table
811+
rdbytes = zasrc.read(entry)
812+
outbytes = re.sub('<table:table table:name="local-table">.*</table:table>', "", rdbytes)
813+
zadst.writestr(entry, outbytes)
809814
elif entry == "META-INF/manifest.xml":
810815
# Remove ObjectReplacements from the list
811816
rdbytes = zasrc.read(entry)
@@ -830,6 +835,8 @@ def UpdateContentXMLToODS_text( odssrc, odsdest, xmltext ):
830835
xmlsrc = GetContentXMLFromODS( odssrc )
831836
xmlsrc = ReplaceSheetWithCSV_regex( "Timeseries", timeseriescsv, xmlsrc )
832837
xmlsrc = ReplaceSheetWithCSV_regex( "Tests", testcsv, xmlsrc )
838+
# Remove draw:image references to deleted binary previews
839+
xmlsrc = re.sub("<draw:image.*?/>", "", xmlsrc)
833840
# OpenOffice doesn't recalculate these cells on load?!
834841
xmlsrc = xmlsrc.replace( "_DRIVE", str(physDrive) )
835842
xmlsrc = xmlsrc.replace( "_TESTCAP", str(testcapacity) )

0 commit comments

Comments
 (0)