file delete -force $TEX
file rename $TMPFILENAME $TEX
}
-}
-
-# update image sizes in *.md files for PDF documentation if necessary
-proc OCCDoc_UpdateImagesSize {{DocFilesList {}} DoxDir verboseMode} {
-
- foreach DocFile $DocFilesList {
- if {$verboseMode == "YES"} {
- puts "Info: Updating image sizes for file $DocFile..."
- }
-
- if {![file exists $DoxDir/$DocFile]} {
- puts "Error: file $DoxDir/$DocFile does not exist."
- return -1
- }
-
- if { [catch {set aFile [open $DoxDir/$DocFile r]} aReason] } {
- puts "Error: cannot open file \"$DoxDir/$DocFile\" for reading: $aReason"
- return -1
- }
-
- set aFileContent [read $aFile]
- close $aFile
-
- set aNumberOfImages [regexp -all -line {@figure\s*\{[^\}]+\}} $aFileContent]
- set aLastImageIndex 0
-
- if {!$aNumberOfImages} {
- continue
- }
-
- while { $aNumberOfImages } {
- set currentFigureIndex [string first "@figure" $aFileContent ${aLastImageIndex}]
- set first_figure_inclusion [string range $aFileContent $currentFigureIndex end]
- set line ""
- set path ""
- set name ""
- set width ""
- set dump ""
- if [regexp {^(@figure[\s\t]*\{[^\}]+\})} $first_figure_inclusion dump line] {
- if { [regexp {@figure[\s\t]*\{([^,\}]+)[\s\t]*\}} $line dump aPath] } {
- set path "${aPath}"
- } elseif { [regexp {@figure[\s\t]*\{([^,\}]+)[\s\t]*,[\s\t]*\"(.*)\"\}} $line dump aPath aName] } {
- set path "${aPath}"
- set name "\"${aName}\""
- } elseif { [regexp {@figure[\s\t]*\{([^,\}]+)[\s\t]*,[\s\t]*\"(.*)\"[\s\t]*,[\s\t]*([0-9]+)\}} $line dump aPath aName aWidth] } {
- set path "${aPath}"
- set name "\"${aName}\""
- set width "${aWidth}"
- }
-
- if {$name == ""} {
- set name "\"\""
- }
- # find image
- set anImagePath ""
- if {[file exists "$DoxDir/$path"]} {
- set anImagePath "$DoxDir/$path"
- } elseif {[file exists "[OCCDoc_GetDoxDir]/$path"]} {
- set anImagePath "[OCCDoc_GetDoxDir]/$path"
- } elseif {[file exists "[OCCDoc_GetDoxDir]/resources/$path"]} {
- set anImagePath "[OCCDoc_GetDoxDir]/resources/$path"
- } elseif {[file exists "$DoxDir/[file dirname ${DocFile}]/images/$path"]} {
- set anImagePath "$DoxDir/[file dirname ${DocFile}]/images/$path"
- }
- if { ![file exists "$anImagePath"] } {
- puts "Warning: Could not find \"$DoxDir/$path\" file"
- incr aNumberOfImages -1
- set aLastImageIndex [expr $currentFigureIndex + [string length $dump]]
- continue
- }
- # get image width
- if [catch {exec identify "$anImagePath"} res] {
- puts "Error: identify returns \"${identify_error}\""
- incr aNumberOfImages -1
- set aLastImageIndex [expr $currentFigureIndex + [string length $dump]]
- continue
- } else {
- if [regexp {([0-9]+)x[0-9]+} $res dump2 loc_width] {
- set width $loc_width
- }
- }
-
- set newInfo "@figure{$path,$name,$width}"
- set aFileContent "[string replace $aFileContent $currentFigureIndex [expr $currentFigureIndex + [string length $dump] - 1] $newInfo]"
- set aLastImageIndex [expr $currentFigureIndex + [string length $newInfo]]
- }
- incr aNumberOfImages -1
- }
-
- if { [catch {set aFile [open $DoxDir/$DocFile w]} aReason] } {
- puts "Error: cannot open file \"$DoxDir/$DocFile\" for writting: $aReason"
- return -1
- }
-
- puts $aFile "${aFileContent}"
- close $aFile
- }
-}
+}
\ No newline at end of file