CAWT 2.4.7 Reference Manual

# ::OneNoteMain

The `OneNote` namespace provides commands to control Microsoft OneNote.

## CommandsOneNote, Main

#### FindNodeByName [::OneNote]OneNote, Main

Get a specific node by name.

FindNodeByName domNode nodeType nodeName

`domNode` | DOM node.
`nodeType` | Node type (`Notebook`, `Section`, `Page`).
`nodeName` | Node name.

Returns the found node or an empty string, if the node could not be found.

See also: FindNotebook, FindSection, FindPage, GetNodeName

Show source

    proc ::OneNote::FindNodeByName {domNode nodeType nodeName} {

        # Get a specific node by name.
        #
        # domNode  - DOM node.
        # nodeType - Node type (`Notebook`, `Section`, `Page`).
        # nodeName - Node name.
        #
        # Returns the found node or an empty string, if the node could not be found.
        #
        # See also: FindNotebook FindSection FindPage GetNodeName

        set result ""
        if { [OneNote IsNodeType $domNode $nodeType] } {
            if { [OneNote GetNodeName $domNode] eq $nodeName } {
                set result $domNode
            }
            return $result
        }
        if { [$domNode hasChildNodes] } {
            foreach childNode [$domNode childNodes] {
                set result [OneNote::FindNodeByName $childNode $nodeType $nodeName]
                if { $result ne "" } {
                    return $result
                }
            }
        }
        return $result
    }

#### FindNotebook [::OneNote]OneNote, Main

Get a specific notebook by name.

FindNotebook domNode nodeName

`domNode` | DOM root node as returned by GetDomRoot.
`nodeName` | Node name.

Returns the found notebook or an empty string, if the notebook could not be found.

See also: FindNodeByName, FindSection, FindPage, GetDomRoot, GetNodeName

Show source

    proc ::OneNote::FindNotebook {domNode nodeName} {

        # Get a specific notebook by name.
        #
        # domNode  - DOM root node as returned by [GetDomRoot].
        # nodeName - Node name.
        #
        # Returns the found notebook or an empty string, if the notebook could not be found.
        #
        # See also: FindNodeByName FindSection FindPage GetDomRoot GetNodeName

        return [OneNote::FindNodeByName $domNode "Notebook" $nodeName]
    }

#### FindPage [::OneNote]OneNote, Main

Get a specific page by name.

FindPage domNode nodeName

`domNode` | DOM node identifying a section.
`nodeName` | Node name.

Returns the found page or an empty string, if the page could not be found.

See also: FindNodeByName, FindNotebook, FindSection, GetPages, GetNodeName

Show source

    proc ::OneNote::FindPage {domNode nodeName} {

        # Get a specific page by name.
        #
        # domNode  - DOM node identifying a section.
        # nodeName - Node name.
        #
        # Returns the found page or an empty string, if the page could not be found.
        #
        # See also: FindNodeByName FindNotebook FindSection GetPages GetNodeName

        return [OneNote::FindNodeByName $domNode "Page" $nodeName]
    }

#### FindSection [::OneNote]OneNote, Main

Get a specific section by name.

FindSection domNode nodeName

`domNode` | DOM node identifying a notebook.
`nodeName` | Node name.

Returns the found section or an empty string, if the section could not be found.

See also: FindNodeByName, FindNotebook, FindPage, GetSections, GetNodeName

Show source

    proc ::OneNote::FindSection {domNode nodeName} {

        # Get a specific section by name.
        #
        # domNode  - DOM node identifying a notebook.
        # nodeName - Node name.
        #
        # Returns the found section or an empty string, if the section could not be found.
        #
        # See also: FindNodeByName FindNotebook FindPage GetSections GetNodeName

        return [OneNote::FindNodeByName $domNode "Section" $nodeName]
    }

#### GetApplicationId [::OneNote]OneNote, Main

Get the application identifier of a OneNote object.

GetApplicationId oneNoteId

`oneNoteId` | Identifier dictionary of a OneNote object.

Returns the application identifier of the OneNote object.

See also: Open, GetDomId

Show source

    proc ::OneNote::GetApplicationId {oneNoteId} {

        # Get the application identifier of a OneNote object.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        #
        # Returns the application identifier of the OneNote object.
        #
        # See also: Open GetDomId

        return [dict get $oneNoteId "appId"]
    }

#### GetDomId [::OneNote]OneNote, Main

Get the DOM identifier of a OneNote object.

GetDomId oneNoteId

`oneNoteId` | Identifier dictionary of a OneNote object.

Returns the DOM identifier of the OneNote object.

See also: Open, GetApplicationId, GetDomRoot

Show source

    proc ::OneNote::GetDomId {oneNoteId} {

        # Get the DOM identifier of a OneNote object.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        #
        # Returns the DOM identifier of the OneNote object.
        #
        # See also: Open GetApplicationId GetDomRoot

        return [dict get $oneNoteId "docId"]
    }

#### GetDomRoot [::OneNote]OneNote, Main

Get the DOM root of a OneNote object.

GetDomRoot oneNoteId

`oneNoteId` | Identifier dictionary of a OneNote object.

Returns the DOM root of the OneNote object.

See also: Open, GetApplicationId, GetDomId

Show source

    proc ::OneNote::GetDomRoot {oneNoteId} {

        # Get the DOM root of a OneNote object.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        #
        # Returns the DOM root of the OneNote object.
        #
        # See also: Open GetApplicationId GetDomId

        return [[dict get $oneNoteId "docId"] documentElement]
    }

#### GetEnum [::OneNote]OneNote, Main

Get numeric value of an enumeration.

GetEnum enumOrString

`enumOrString` | Enumeration name

Returns the numeric value of an enumeration.

See also: GetEnumName, GetEnumTypes, GetEnumVal, GetEnumNames

Show source

    proc ::OneNote::GetEnum {enumOrString} {

        # Get numeric value of an enumeration.
        #
        # enumOrString - Enumeration name
        #
        # Returns the numeric value of an enumeration.
        #
        # See also: GetEnumName GetEnumTypes GetEnumVal GetEnumNames

        set retVal [catch { expr int($enumOrString) } enumInt]
        if { $retVal == 0 } {
            return $enumInt
        } else {
            return [GetEnumVal $enumOrString]
        }
    }

#### GetEnumName [::OneNote]OneNote, Main

Get name of a given enumeration type and numeric value.

GetEnumName enumType enumVal

`enumType` | Enumeration type
`enumVal` | Enumeration numeric value.

Returns the list of names of a given enumeration type.

See also: GetEnumNames, GetEnumTypes, GetEnumVal, GetEnum

Show source

    proc ::OneNote::GetEnumName {enumType enumVal} {

        # Get name of a given enumeration type and numeric value.
        #
        # enumType - Enumeration type
        # enumVal  - Enumeration numeric value.
        #
        # Returns the list of names of a given enumeration type.
        #
        # See also: GetEnumNames GetEnumTypes GetEnumVal GetEnum

        variable enums

        set enumName ""
        if { [info exists enums($enumType)] } {
            foreach { key val } $enums($enumType) {
                if { $val eq $enumVal } {
                    set enumName $key
                    break
                }
            }
        }
        return $enumName
    }

#### GetEnumNames [::OneNote]OneNote, Main

Get names of a given enumeration type.

GetEnumNames enumType

`enumType` | Enumeration type

Returns the list of names of a given enumeration type.

See also: GetEnumName, GetEnumTypes, GetEnumVal, GetEnum

Show source

    proc ::OneNote::GetEnumNames {enumType} {

        # Get names of a given enumeration type.
        #
        # enumType - Enumeration type
        #
        # Returns the list of names of a given enumeration type.
        #
        # See also: GetEnumName GetEnumTypes GetEnumVal GetEnum

        variable enums

        if { [info exists enums($enumType)] } {
            foreach { key val } $enums($enumType) {
                lappend nameList $key
            }
            return $nameList
        } else {
            return [list]
        }
    }

#### GetEnumTypes [::OneNote]OneNote, Main

Get available enumeration types.

GetEnumTypes

Returns the list of available enumeration types.

See also: GetEnumName, GetEnumNames, GetEnumVal, GetEnum

Show source

    proc ::OneNote::GetEnumTypes {} {

        # Get available enumeration types.
        #
        # Returns the list of available enumeration types.
        #
        # See also: GetEnumName GetEnumNames GetEnumVal GetEnum

        variable enums

        return [lsort -dictionary [array names enums]]
    }

#### GetEnumVal [::OneNote]OneNote, Main

Get numeric value of an enumeration name.

GetEnumVal enumName

`enumName` | Enumeration name

Returns the numeric value of an enumeration name.

See also: GetEnumName, GetEnumTypes, GetEnumNames, GetEnum

Show source

    proc ::OneNote::GetEnumVal {enumName} {

        # Get numeric value of an enumeration name.
        #
        # enumName - Enumeration name
        #
        # Returns the numeric value of an enumeration name.
        #
        # See also: GetEnumName GetEnumTypes GetEnumNames GetEnum

        variable enums

        foreach enumType [GetEnumTypes] {
            set ind [lsearch -exact $enums($enumType) $enumName]
            if { $ind >= 0 } {
                return [lindex $enums($enumType) [expr { $ind + 1 }]]
            }
        }
        return ""
    }

#### GetExtString [::OneNote]OneNote, Main

Return the default extension of a OneNote file.

GetExtString oneNoteId

`oneNoteId` | Identifier dictionary of a OneNote object.

Returns the default extension of a OneNote file.

See also: Open, GetVersion

Show source

    proc ::OneNote::GetExtString {oneNoteId} {

        # Return the default extension of a OneNote file.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        #
        # Returns the default extension of a OneNote file.
        #
        # See also: Open GetVersion

        # oneNoteId is only needed, so we are sure, that oneNoteVersion is initialized.
        # Note: Currently not needed, but kept to be conformant to other Cawt modules.

        variable oneNoteVersion

        return ".one"
    }

#### GetLastModified [::OneNote]OneNote, Main

Get nodes with specific modification date.

GetLastModified domNode ?compareDate? ?nodeType? ?notebookName?

`domNode` | DOM node.
`compareDate` | Date in seconds (as returned by `clock seconds`). Optional, default `0`.
`nodeType` | Node type (`any`, `Notebook`, `Section`, `Page`). Optional, default `any`.
`notebookName` | Notebook name. Optional, default `""`.

Returns found nodes as list.

See also: FindNotebook, GetDomRoot

Show source

    proc ::OneNote::GetLastModified {domNode {compareDate 0} {nodeType any} {notebookName {}}} {

        # Get nodes with specific modification date.
        #
        # domNode      - DOM node.
        # compareDate  - Date in seconds (as returned by `clock seconds`).
        # nodeType     - Node type (`any`, `Notebook`, `Section`, `Page`).
        # notebookName - Notebook name.
        #
        # Returns found nodes as list.
        #
        # See also: FindNotebook GetDomRoot

        variable sModifiedList

        catch { unset sModifiedList }
        set modifiedList [list]
        OneNote::_GetLastModifiedRecursive $domNode $compareDate $nodeType $notebookName
        foreach date [lsort -integer -decreasing [array names sModifiedList]] {
            foreach entry $sModifiedList($date) {
                lappend modifiedList $entry
            }
        }
        return $modifiedList
    }

#### GetNodeAttribute [::OneNote]OneNote, Main

Get attribute value of a DOM node.

GetNodeAttribute domNode attrName

`domNode` | DOM node.
`attrName` | Attribute name.

Returns attribute value as string.

See also: GetNodeName, GetNodeHyperLink

Show source

    proc ::OneNote::GetNodeAttribute {domNode attrName} {

        # Get attribute value of a DOM node.
        #
        # domNode  - DOM node.
        # attrName - Attribute name.
        #
        # Returns attribute value as string.
        #
        # See also: GetNodeName GetNodeHyperLink

        set attrValue ""
        if { [$domNode hasAttribute $attrName] } {
            set attrValue [$domNode getAttribute $attrName]
        }
        return $attrValue
    }

#### GetNodeHyperLink [::OneNote]OneNote, Main

Get hyperlink to OneNote node.

GetNodeHyperLink oneNoteId domNode

`oneNoteId` | Identifier dictionary of a OneNote object.
`domNode` | DOM node.

Returns hyperlink as string.

See also: Open, GetNodeAttribute, GetNodeName

Show source

    proc ::OneNote::GetNodeHyperLink {oneNoteId domNode} {

        # Get hyperlink to OneNote node.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        # domNode   - DOM node.
        #
        # Returns hyperlink as string.
        #
        # See also: Open GetNodeAttribute GetNodeName

        set objId [OneNote GetNodeAttribute $domNode "ID"]
        set appId [OneNote GetApplicationId $oneNoteId]
        $appId -call GetHyperlinkToObject $objId "" xmlOut
        return [twapi::variant_value $xmlOut 0 0 0]
    }

#### GetNodeName [::OneNote]OneNote, Main

Get value of node attribute `name`.

GetNodeName domNode

`domNode` | DOM node.

Returns attribute value as string.

See also: GetNodeAttribute, GetNodeHyperLink

Show source

    proc ::OneNote::GetNodeName {domNode} {

        # Get value of node attribute `name`.
        #
        # domNode - DOM node.
        #
        # Returns attribute value as string.
        #
        # See also: GetNodeAttribute GetNodeHyperLink

        return [OneNote GetNodeAttribute $domNode "name"]
    }

#### GetNodesByType [::OneNote]OneNote, Main

Get nodes of specific type.

GetNodesByType domNode nodeType

`domNode` | DOM node.
`nodeType` | Node type (`Notebook`, `Section`, `Page`).

Returns the found nodes as a list.

See also: GetNotebooks, GetSections, GetPages, GetNodeType

Show source

    proc ::OneNote::GetNodesByType {domNode nodeType} {

        # Get nodes of specific type.
        #
        # domNode  - DOM node.
        # nodeType - Node type (`Notebook`, `Section`, `Page`).
        #
        # Returns the found nodes as a list.
        #
        # See also: GetNotebooks GetSections GetPages GetNodeType

        set resultList [list]
        if { [OneNote IsNodeType $domNode $nodeType] } {
            return $domNode
        }
        if {[$domNode hasChildNodes]} {
            foreach childNode [$domNode childNodes] {
                set result [OneNote::GetNodesByType $childNode $nodeType]
                if { [llength $result] > 0 } {
                    lappend resultList {*}$result
                }
            }
        }
        return $resultList
    }

#### GetNodeType [::OneNote]OneNote, Main

Get type of a DOM node.

GetNodeType domNode

`domNode` | DOM node.

Returns node type as string. Possible values: `Notebook`, `Section`, `Page`.

See also: IsNodeType, GetNodesByType

Show source

    proc ::OneNote::GetNodeType {domNode} {

        # Get type of a DOM node.
        #
        # domNode  - DOM node.
        #
        # Returns node type as string.
        # Possible values: `Notebook`, `Section`, `Page`.
        #
        # See also: IsNodeType GetNodesByType

        set nodeType [$domNode nodeName]
        return [lindex [split $nodeType ":"] 1]
    }

#### GetNotebooks [::OneNote]OneNote, Main

Get the notebooks of a OneNote object.

GetNotebooks domNode

`domNode` | DOM root node as returned by GetDomRoot.

Returns the notebooks of the OneNote object as list.

See also: GetNodesByType, GetSections, GetPages, GetDomRoot, GetNodeType

Show source

    proc ::OneNote::GetNotebooks {domNode} {

        # Get the notebooks of a OneNote object.
        #
        # domNode - DOM root node as returned by GetDomRoot.
        #
        # Returns the notebooks of the OneNote object as list.
        #
        # See also: GetNodesByType GetSections GetPages GetDomRoot GetNodeType

        return [OneNote::GetNodesByType $domNode "Notebook"]
    }

#### GetPageContent [::OneNote]OneNote, Main

Get page content as XML.

GetPageContent oneNoteId domNode

`oneNoteId` | Identifier dictionary of a OneNote object.
`domNode` | DOM node of a page.

See also: Open, PrintPage

Show source

    proc ::OneNote::GetPageContent {oneNoteId domNode} {

        # Get page content as XML.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        # domNode   - DOM node of a page.
        #
        # See also: Open PrintPage

        set pageId [OneNote GetNodeAttribute $domNode "ID"]
        set appId  [OneNote GetApplicationId $oneNoteId]
        $appId -call GetPageContent $pageId xmlOut
        set pageXml [twapi::variant_value $xmlOut 0 0 0]
        set pageDoc [dom parse $pageXml]
        return $pageDoc
    }

#### GetPages [::OneNote]OneNote, Main

Get the pages of a OneNote section.

GetPages domNode

`domNode` | DOM node identifying a section.

Return the pages of the OneNote section as list.

See also: GetNodesByType, GetSections, GetPages, FindSection, GetNodeType

Show source

    proc ::OneNote::GetPages {domNode} {

        # Get the pages of a OneNote section.
        #
        # domNode - DOM node identifying a section.
        #
        # Return the pages of the OneNote section as list.
        #
        # See also: GetNodesByType GetSections GetPages FindSection GetNodeType

        return [OneNote::GetNodesByType $domNode "Page"]
    }

#### GetSections [::OneNote]OneNote, Main

Get the sections of a OneNote notebook.

GetSections domNode

`domNode` | DOM node identifying a notebook.

Returns the sections of the OneNote notebook as list.

See also: GetNodesByType, GetNotebooks, GetPages, FindNotebook, GetNodeType

Show source

    proc ::OneNote::GetSections {domNode} {

        # Get the sections of a OneNote notebook.
        #
        # domNode - DOM node identifying a notebook.
        #
        # Returns the sections of the OneNote notebook as list.
        #
        # See also: GetNodesByType GetNotebooks GetPages FindNotebook GetNodeType

        return [OneNote::GetNodesByType $domNode "Section"]
    }

#### GetVersion [::OneNote]OneNote, Main

Return the version of a OneNote application.

GetVersion oneNoteId ?useString?

`oneNoteId` | Identifier dictionary of a OneNote object.
`useString` | If set to true, return the version name (ex. `OneNote 2010`). Otherwise return the version number (ex. `12.0`). Optional, default `false`.

Both version name and version number are returned as strings. Version number is in a format, so that it can be evaluated as a floating point number.

Returns the version of a OneNote application.

See also: Open, GetExtString

Show source

    proc ::OneNote::GetVersion {oneNoteId {useString false}} {

        # Return the version of a OneNote application.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        # useString - If set to true, return the version name (ex. `OneNote 2010`).
        #             Otherwise return the version number (ex. `12.0`).
        #
        # Both version name and version number are returned as strings.
        # Version number is in a format, so that it can be evaluated as a
        # floating point number.
        #
        # Returns the version of a OneNote application.
        #
        # See also: Open GetExtString

        variable oneNoteVersion

        array set map {
            "12.0" "OneNote 2007"
            "14.0" "OneNote 2010"
            "15.0" "OneNote 2013"
            "16.0" "OneNote 2016"
        }

        if { $useString } {
            if { [info exists map($oneNoteVersion)] } {
                return $map($oneNoteVersion)
            } else {
                return "Unknown OneNote version $oneNoteVersion"
            }
        } else {
            return $oneNoteVersion
        }
    }

#### IsNodeType [::OneNote]OneNote, Main

Check, if node is of specific type.

IsNodeType domNode nodeType

`domNode` | DOM node.
`nodeType` | Node type (`Notebook`, `Section`, `Page`).

Returns true, if node is of specified type. Otherwise false.

See also: GetNodeType, GetNodesByType

Show source

    proc ::OneNote::IsNodeType {domNode nodeType} {

        # Check, if node is of specific type.
        #
        # domNode  - DOM node.
        # nodeType - Node type (`Notebook`, `Section`, `Page`).
        #
        # Returns true, if node is of specified type. Otherwise false.
        #
        # See also: GetNodeType GetNodesByType

        if { $nodeType eq "any" || [OneNote GetNodeType $domNode] eq $nodeType } {
            return true
        } else {
            return false
        }
    }

#### Open [::OneNote]OneNote, Main

Open a OneNote instance.

Open

The identifier is a dictionary containing 2 elements:

Key appId | The application identifier.
Key docId | The DOM node identifier.

Returns the identifier of the OneNote instance.

See also: Quit, GetApplicationId, GetDomId

Show source

    proc ::OneNote::Open {} {

        # Open a OneNote instance.
        #
        # Returns the identifier of the OneNote instance.
        #
        # The identifier is a dictionary containing 2 elements:
        # Key appId - The application identifier.
        # Key docId - The DOM node identifier.
        #
        # See also: Quit GetApplicationId GetDomId

        variable oneNoteVersion
        variable oneNoteAppName

        if { ! [Cawt HavePkg "tdom"] } {
            error "Cannot use $oneNoteAppName. No tDOM extension available."
        }
        foreach version { 10 11 12 13 14 15 16 17 18 19 20 } {
            set catchVal [catch { twapi::comobj $oneNoteAppName.$version } appId]
            if { ! $catchVal } {
                set catchVal [catch { $appId GetHierarchy "" $::OneNote::hsSelf str } retVal]
                if { ! $catchVal } {
                    # puts "Using $oneNoteAppName.$version"
                    set oneNoteVersion "$version.0"
                    set hierarchyXml [OneNote::_GetHierarchy $appId "" $::OneNote::hsPages]
                    set doc [dom parse $hierarchyXml]
                    dict set oneNoteId "appId" $appId
                    dict set oneNoteId "docId" $doc
                    return $oneNoteId
                }
            }
        }
        error "Cannot open $oneNoteAppName application."
    }

#### PrintPage [::OneNote]OneNote, Main

Print page content as XML to standard output.

PrintPage oneNoteId domNode

`oneNoteId` | Identifier dictionary of a OneNote object.
`domNode` | DOM node of a page.

Returns no value.

See also: GetPageContent

Show source

    proc ::OneNote::PrintPage {oneNoteId domNode} {

        # Print page content as XML to standard output.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        # domNode   - DOM node of a page.
        #
        # Returns no value.
        #
        # See also: GetPageContent

        set pageDomDoc [OneNote GetPageContent $oneNoteId $domNode]
        set pageRoot   [$pageDomDoc documentElement]
        puts [$pageRoot asXML]
    }

#### Quit [::OneNote]OneNote, Main

Quit a OneNote instance.

Quit oneNoteId

`oneNoteId` | Identifier dictionary of a OneNote object.

Returns no value.

See also: Open

Show source

    proc ::OneNote::Quit {oneNoteId} {

        # Quit a OneNote instance.
        #
        # oneNoteId - Identifier dictionary of a OneNote object.
        #
        # Returns no value.
        #
        # See also: Open
    }

# Start page

# Cawt

# Office

# Excel

# Ppt

# Word

# Outlook

# OneNote

# Office::Enum

# Excel::Enum

# Ppt::Enum

# Word::Enum

# Outlook::Enum

# OneNote::Enum

# Earth

# Explorer

# Ocr

# Reader

# Matlab

# OneNote

## Commands

#### FindNodeByName Get a specific node by name.

#### FindNotebook Get a specific notebook by name.

#### FindPage Get a specific page by name.

#### FindSection Get a specific section by name.

#### GetApplicationId Get the application identifier of a OneNote object.

#### GetDomId Get the DOM identifier of a OneNote object.

#### GetDomRoot Get the DOM root of a OneNote object.

#### GetEnum Get numeric value of an enumeration.

#### GetEnumName Get name of a given enumeration type and numeric value.

#### GetEnumNames Get names of a given enumeration type.

#### GetEnumTypes Get available enumeration types.

#### GetEnumVal Get numeric value of an enumeration name.

#### GetExtString Return the default extension of a OneNote file.

#### GetLastModified Get nodes with specific modification date.

#### GetNodeAttribute Get attribute value of a DOM node.

#### GetNodeHyperLink Get hyperlink to OneNote node.

#### GetNodeName Get value of node attribute `name`.

#### GetNodesByType Get nodes of specific type.

#### GetNodeType Get type of a DOM node.

#### GetNotebooks Get the notebooks of a OneNote object.

#### GetPageContent Get page content as XML.

#### GetPages Get the pages of a OneNote section.

#### GetSections Get the sections of a OneNote notebook.

#### GetVersion Return the version of a OneNote application.

#### IsNodeType Check, if node is of specific type.

#### Open Open a OneNote instance.

#### PrintPage Print page content as XML to standard output.

#### Quit Quit a OneNote instance.

Document generated by Ruff!