ooxml

Check-in [c894d762dd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:added "-tag" to the method "numberformat". with this you can give a style a name. in the method "style" as NUMFMTID you can also pass the given name.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | namedfmts
Files: files | file ages | folders
SHA3-256: c894d762dd4c44f2c6bffa761a77e7021a73cddc6cab3c9f54d245b8d08fbb08
User & Date: alex 2020-03-06 07:46:54
Context
2020-03-06
07:52
added "-tag" to the method "font". with this you can give a style a name. in the method "style" as FONTID you can also pass the given name. check-in: 2e0fa3b0bd user: alex tags: namedfmts
07:46
added "-tag" to the method "numberformat". with this you can give a style a name. in the method "style" as NUMFMTID you can also pass the given name. check-in: c894d762dd user: alex tags: namedfmts
2020-03-05
21:33
added "-tag" to the method "styles". with this you can give a style a name. in the methods "defaultdatestyle", "column" and "cell" as STYLEID you can also pass the given name. check-in: bcad321da9 user: alex tags: namedfmts
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ooxml.tcl.

1614
1615
1616
1617
1618
1619
1620

1621
1622
1623
1624
1625
1626
1627
....
1649
1650
1651
1652
1653
1654
1655













1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670



1671
1672
1673



1674
1675
1676



1677
1678
1679
1680
1681



1682
1683



1684
1685
1686
1687
1688
1689



1690
1691
1692
1693
1694
1695



1696
1697
1698
1699



1700
1701



1702
1703
1704
1705
1706
1707



1708
1709
1710
1711
1712



1713
1714
1715



1716
1717
1718



1719
1720
1721



1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733



1734
1735
1736
1737
1738



1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750



1751
1752
1753
1754
1755
1756
1757
....
2078
2079
2080
2081
2082
2083
2084




2085
2086
2087
2088
2089
2090
2091
  destructor {
    return 0
  }

  method numberformat { args } {
    my variable obj
    my variable numFmts


    array set opts {
      list 0
      format {}
      general 0
      date 0
      time 0
................................................................................
          } else {
            error "option '$opt': missing argument"
          }            
        }
        -list - -general - -date - -time - -datetime - -iso8601 - -number - -decimal - -red - -separator - -fraction - -scientific - -percent - -string - -text {
	  set opts([string range $opt 1 end]) 1
        }













        default {
          error "unknown option \"$opt\", should be: -format, -list, -general, -date, -time, -datetime, -iso8601, -number, -decimal, -red, -separator, -fraction, -scientific, -percent, -string or -text"
        }
      }
    }

    if {$opts(list)} {
      array set tmp [array get ::ooxml::predefNumFmts]
      array set tmp [array get numFmts]
      return [array get tmp]
    }

    set obj(blockPreset) 1

    if {$opts(general)} {



      return 0
    }
    if {$opts(date)} {



      return 14
    }
    if {$opts(time)} {



      return 20
    }
    if {$opts(number)} {
      if {$opts(separator)} {
	if {$opts(red)} {



	  return 38
	} else {



	  return 3
	}
      } else {
	if {$opts(red)} {
	  return -1
	} else {



	  return 1
	}
      }
    }
    if {$opts(decimal)} {
      if {$opts(percent)} {



        return 10
      }
      if {$opts(separator)} {
	if {$opts(red)} {



	  return 40
	} else {



	  return 4
	}
      } else {
	if {$opts(red)} {
	  return -1
	} else {



	  return 2
	}
      }
    }
    if {$opts(fraction)} {



      return 12
    }
    if {$opts(scientific)} {



      return 11
    }
    if {$opts(percent)} {



      return 9
    }
    if {$opts(text) || $opts(string)} {



      return 49
    }

    if {$opts(datetime)} {
      set opts(format) {dd/mm/yyyy\ hh:mm;@}
    }
    if {$opts(iso8601)} {
      set opts(format) {yyyy\-mm\-dd\ hh:mm:ss;@}
    }

    foreach idx [array names ::ooxml::predefNumFmts] {
      if {[dict get $::ooxml::predefNumFmts($idx) fmt] eq $opts(format)} {



        return $idx
      }
    }
    foreach idx [array names numFmts] {
      if {$numFmts($idx) eq $opts(format)} {



        return $idx
      }
    }

    if {$opts(format) eq {}} {
      return -1
    }

    set idx $obj(numFmts)
    set numFmts($idx) $opts(format)
    incr obj(numFmts)




    return $idx
  }

  method defaultdatestyle { style } {
    my variable obj
    my variable tags

................................................................................
        }
      }
    }

    if {$opts(list)} {
      return [array get styles]
    }





    set obj(blockPreset) 1
    
    if {![string is integer -strict $opts(numfmt)] || $opts(numfmt) < 0} {
      set opts(numfmt) 0
    }
    if {![string is integer -strict $opts(font)] || $opts(font) < 0} {







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>

|













>
>
>



>
>
>



>
>
>





>
>
>


>
>
>






>
>
>






>
>
>




>
>
>


>
>
>






>
>
>





>
>
>



>
>
>



>
>
>



>
>
>












>
>
>





>
>
>












>
>
>







 







>
>
>
>







1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
....
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
....
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
  destructor {
    return 0
  }

  method numberformat { args } {
    my variable obj
    my variable numFmts
    my variable tags

    array set opts {
      list 0
      format {}
      general 0
      date 0
      time 0
................................................................................
          } else {
            error "option '$opt': missing argument"
          }            
        }
        -list - -general - -date - -time - -datetime - -iso8601 - -number - -decimal - -red - -separator - -fraction - -scientific - -percent - -string - -text {
	  set opts([string range $opt 1 end]) 1
        }
        -tag {
	  incr idx
          if {$idx < $len} {
	    if {[string is integer -strict [set tag [lindex $args $idx]]]} {
	      error "option '$opt': should not be an integer value"
	    } else {
	      set opts([string range $opt 1 end]) $tag
	    } 
	    unset tag
          } else {
            error "option '$opt': missing argument"
          }            
        }
        default {
          error "unknown option \"$opt\", should be: -format, -list, -general, -date, -time, -datetime, -iso8601, -number, -decimal, -red, -separator, -fraction, -scientific, -percent, -string, -text or tag"
        }
      }
    }

    if {$opts(list)} {
      array set tmp [array get ::ooxml::predefNumFmts]
      array set tmp [array get numFmts]
      return [array get tmp]
    }

    set obj(blockPreset) 1

    if {$opts(general)} {
      if {$opts(tag) ne {}} {
	set tags(numFmts,$opts(tag)) 0
      }
      return 0
    }
    if {$opts(date)} {
      if {$opts(tag) ne {}} {
	set tags(numFmts,$opts(tag)) 14
      }
      return 14
    }
    if {$opts(time)} {
      if {$opts(tag) ne {}} {
	set tags(numFmts,$opts(tag)) 20
      }
      return 20
    }
    if {$opts(number)} {
      if {$opts(separator)} {
	if {$opts(red)} {
	  if {$opts(tag) ne {}} {
	    set tags(numFmts,$opts(tag)) 38
	  }
	  return 38
	} else {
	  if {$opts(tag) ne {}} {
	    set tags(numFmts,$opts(tag)) 3
	  }
	  return 3
	}
      } else {
	if {$opts(red)} {
	  return -1
	} else {
	  if {$opts(tag) ne {}} {
	    set tags(numFmts,$opts(tag)) 1
	  }
	  return 1
	}
      }
    }
    if {$opts(decimal)} {
      if {$opts(percent)} {
	if {$opts(tag) ne {}} {
	  set tags(numFmts,$opts(tag)) 10
	}
        return 10
      }
      if {$opts(separator)} {
	if {$opts(red)} {
	  if {$opts(tag) ne {}} {
	    set tags(numFmts,$opts(tag)) 40
	  }
	  return 40
	} else {
	  if {$opts(tag) ne {}} {
	    set tags(numFmts,$opts(tag)) 4
	  }
	  return 4
	}
      } else {
	if {$opts(red)} {
	  return -1
	} else {
	  if {$opts(tag) ne {}} {
	    set tags(numFmts,$opts(tag)) 2
	  }
	  return 2
	}
      }
    }
    if {$opts(fraction)} {
      if {$opts(tag) ne {}} {
	set tags(numFmts,$opts(tag)) 12
      }
      return 12
    }
    if {$opts(scientific)} {
      if {$opts(tag) ne {}} {
	set tags(numFmts,$opts(tag)) 11
      }
      return 11
    }
    if {$opts(percent)} {
      if {$opts(tag) ne {}} {
	set tags(numFmts,$opts(tag)) 9
      }
      return 9
    }
    if {$opts(text) || $opts(string)} {
      if {$opts(tag) ne {}} {
	set tags(numFmts,$opts(tag)) 49
      }
      return 49
    }

    if {$opts(datetime)} {
      set opts(format) {dd/mm/yyyy\ hh:mm;@}
    }
    if {$opts(iso8601)} {
      set opts(format) {yyyy\-mm\-dd\ hh:mm:ss;@}
    }

    foreach idx [array names ::ooxml::predefNumFmts] {
      if {[dict get $::ooxml::predefNumFmts($idx) fmt] eq $opts(format)} {
	if {$opts(tag) ne {}} {
	  set tags(numFmts,$opts(tag)) $idx
	}
        return $idx
      }
    }
    foreach idx [array names numFmts] {
      if {$numFmts($idx) eq $opts(format)} {
	if {$opts(tag) ne {}} {
	  set tags(numFmts,$opts(tag)) $idx
	}
        return $idx
      }
    }

    if {$opts(format) eq {}} {
      return -1
    }

    set idx $obj(numFmts)
    set numFmts($idx) $opts(format)
    incr obj(numFmts)

    if {$opts(tag) ne {}} {
      set tags(numFmts,$opts(tag)) $idx
    }
    return $idx
  }

  method defaultdatestyle { style } {
    my variable obj
    my variable tags

................................................................................
        }
      }
    }

    if {$opts(list)} {
      return [array get styles]
    }

    if {![string is integer -strict $opts(numfmt)] && [info exists tags(numFmts,$opts(numfmt))]} {
      set opts(numfmt) $tags(numFmts,$opts(numfmt))
    }

    set obj(blockPreset) 1
    
    if {![string is integer -strict $opts(numfmt)] || $opts(numfmt) < 0} {
      set opts(numfmt) 0
    }
    if {![string is integer -strict $opts(font)] || $opts(font) < 0} {