::namespace eval ::qw::com { ::set ::qw::com::package tcom; ::proc ::qw::com::debug_puts {Src} { ::if {$::qw::verbose(com)} {::puts "(::qw::com) $Src";} } ::proc ::qw::com::excel_peer_dump {_excel} { ::puts "pgq,debug::qw::com::excel_peer_dump enter --------------------------------------------------------------------------------------------------"; ::set StopWatch [::itcl::local ::QW::STOPWATCH #auto]; ::set BEFORE [$_excel synchronized_peer_check]; ::puts "pgq,debug::qw::com::excel_peer_dump==(\n[::sargs::format .structure $BEFORE]\n)"; ::set snames [::sargs::select_all .structure $BEFORE]; ::set sworkbooks ""; ::set ssheets ""; ::foreach sname $snames { ::if {[::string first "handle" $sname]<0} { ::continue; } ::switch -glob -- $sname { "*.handle_Get_name" { ::continue; } "*_sheet_*" { ::lappend ssheets $sname; } "*_workbook_*" { ::lappend sworkbooks $sname; } } } ::set Count 1; ::puts "::qw::com::excel_peer_dump _excel handle_Get==[$_excel handle_Get] Workbooks Count==[[$_excel Workbooks] Count] ::llength sworkbooks==[::llength $sworkbooks]"; ::while {$Count<=[[$_excel Workbooks] Count]} { ::puts "::qw::com::excel_peer_dump Count==$Count _excel Workbooks Item Count==[[$_excel Workbooks] Item $Count] name==[[::tcom::info interface [[$_excel Workbooks] Item $Count]] name]"; ::foreach sname $sworkbooks { ::if {[::tcom::ref equal [[$_excel Workbooks] Item $Count] [::sargs::get $BEFORE $sname]]} { ::puts "::qw::com::excel_peer_dump Count==$Count _excel Workbooks Item Count==[[$_excel Workbooks] Item $Count] EQUAL [::sargs::get $BEFORE $sname]"; } else { ::puts "::qw::com::excel_peer_dump Count==$Count _excel Workbooks Item Count==[[$_excel Workbooks] Item $Count] NOT EQUAL [::sargs::get $BEFORE $sname]"; } } ::set Count2 1; ::puts "::qw::com::excel_peer_dump _excel handle_Get==[$_excel handle_Get] Sheets Count==[[[[$_excel Workbooks] Item $Count] Sheets] Count] ::llength ssheets==[::llength $ssheets]"; ::while {$Count2<=[[[[$_excel Workbooks] Item $Count] Sheets] Count]} { ::puts "::qw::com::excel_peer_dump Count2==$Count2 _excel Workbooks Item Count Sheets Item Count2==[[[[$_excel Workbooks] Item $Count] Sheets] Item $Count2] name==[[::tcom::info interface [[[[$_excel Workbooks] Item $Count] Sheets] Item $Count2]] name]"; ::foreach sname $ssheets { ::if {[::tcom::ref equal [[[[$_excel Workbooks] Item $Count] Sheets] Item $Count2] [::sargs::get $BEFORE $sname]]} { ::puts "::qw::com::excel_peer_dump Count==$Count _excel Workbooks Item Count==[[[[$_excel Workbooks] Item $Count] Sheets] Item $Count2] EQUAL [::sargs::get $BEFORE $sname]"; } else { ::puts "::qw::com::excel_peer_dump Count==$Count _excel Workbooks Item Count==[[[[$_excel Workbooks] Item $Count] Sheets] Item $Count2] NOT EQUAL [::sargs::get $BEFORE $sname]"; } } ::incr Count2; } ::incr Count; } ::puts "::qw::com::excel_peer_dump exit StopWatch seconds==[$StopWatch seconds]"; ::puts "::qw::com::excel_peer_dump exit ================================================================================================================="; ::return; } } ::itcl::class ::qw::com::collection { protected variable _selected ""; protected variable _clientdata ""; public method selected {} { ::return $_selected; } public method select {Src} { ::if {[::lsearch -exact $_kids $Src]<0} { ::qw::throw "$this select failed, $Src does not exist." } ::set _selected $Src; ::return $Src; } public method clientdata {{Src "get"}} { ::if {$Src eq "get"} {::return $_clientdata;} ::set _clientdata $Src; } protected variable _kids ""; protected variable _owner ""; protected variable _is_destroying 0; constructor {args} { ::set _is_destroying 0; ::set ::qw::control(qw_com_collection_count) [::expr {$::qw::control(qw_com_collection_count)+1}]; ::return $this; } destructor { ::if {[is_being_destroyed]} { ::qw::throw "$this destructor called but object is already being destroyed."; } ::set _is_destroying 1; kidsDestroy; ::set ::qw::control(qw_com_collection_count) [::expr {$::qw::control(qw_com_collection_count)-1}]; } public method is_being_destroyed {} { ::return $_is_destroying; } public method init {} { ::return $this; } method kid_class {} { ::qw::bug "907020030922213734" "$this [lindex [info level 0] 0] is virtual"; } method kid_type {} { ::qw::bug "907020030921213836" "$this [lindex [info level 0] 0] is virtual"; } public method handle_Get {} { ::return [$_owner handle_Get]; } public method handle_method {args} { ::set Result [::eval [handle_Get] $args]; ::return $Result; } public method handle_property {args} { ::set Result [::eval [handle_Get] $args]; ::return $Result; } public method handle_property_bool {Property Src} { ::if {$Src} { ::set Bool "true"; } else { ::set Bool "false"; } ::if {$Bool} {} ::set Result [[handle_Get] $Property $Bool]; ::return $Result; } public method handle_command {args} { ::qw::try { ::set Result [::eval [handle_Get] $args]; } catch Exception { } ::return $Result; } public method owner_Set {Src} { ::set _owner $Src; ::return $this; } public method owner_Get {} { ::return $_owner; } method kidAttach {Src} { ::lappend _kids $Src ::return $this; } method kidDetach {Src} { ::set Index [::lsearch -exact $_kids $Src]; ::if {$Index<0} { ::qw::bug "907020030922214205" "kidDetach: $Src not found in list."; } ::set _kids [::lreplace $_kids $Index $Index]; ::return $this; } public method kidsDestroy {{s_args ""}} { ::foreach Kid $_kids { kidDestroy $Kid $s_args; } ::if {[::llength $_kids]} { ::qw::bug "907020030922214224" "Kids \"$_kids\" did not detach."; } ::return $this; } method kidDestroy {Src {s_args ""}} { ::if {[$Src is_being_destroyed]} { ::qw::throw "$this kidDestroy attempted to destroy $Src but it is already being destroyed."; } ::if {[::sargs::exists $s_args ".destroy_peer"]&&[::sargs::get $s_args ".destroy_peer"]} { $Src destroy_peer; } ::itcl::delete object $Src; ::return $this; } public method kidFirst {{s_args ""}} { ::set Result [::lindex $_kids 0]; ::if {$Result ne ""} {::return $Result;} ::if {[::sargs::get $s_args ".kid_create"] eq "1"} { ::return [factory]; } ::return ""; } public method kidNext {Src} { ::set Index [::lsearch -exact $_kids $Src]; ::if {$Index<0} {::qw::bug "907020030922214241" "kidNext [kid_type] kid $Src not found.";} ::return [::lindex $_kids [::expr $Index+1]]; } public method item {Name} { ::for {::set Kid [kidFirst]} {$Kid ne ""} {::set Kid [kidNext $Kid]} { ::if {[$Kid name_Get] eq $Name} {::return $Kid;} } ::qw::bug "907020030922214320" "$this item $Name not found."; } public method items {} { ::return [::llength $_kids]; } public method handles {} { ::set Result ""; ::foreach Kid $_kids { ::lappend Result $Kid; } ::return $Result; } public method names {} { ::set Result ""; ::foreach Kid $_kids {::lappend Result [$Kid name_Get];} ::return $Result; } public method exists {Src} { ::if {[::lsearch -exact [names] $Src]>=0} {::return 1;} ::return 0; } public method factory {args} { ::set Sheet 0; ::if {[::string first "::sheet" $this]>0} { ::set Sheet 1; } ::array set Args $args; ::if {[::info exists Args(-kid_class)]} { ::set Kid_Class $Args(-kid_class); ::unset Args(-kid_class); } else { ::set Kid_Class [kid_class]; } ::set Kid [::eval $Kid_Class ${Kid_Class}::#auto [::array get Args]]; $Kid owner_Set $this; $Kid init; ::return $Kid; } public method destroy {Src} { kidDestroy $Src; ::return $this; } public method collection {} { ::return [::qw::bug "907020030922214348" "$this [lindex [info level 0] 0] is virtual"]; } public method kids {} { ::return $_kids; } public method synchronized_peer_check {{Path ""} {ResultSoFar ""}} { ::foreach Kid [kids] { ::set ResultSoFar [$Kid synchronized_peer_check "$Path.[::string map {:: _} $Kid]" $ResultSoFar]; } ::return $ResultSoFar; } public method application {} { ::return [$_owner application]; } } ::itcl::class ::qw::com::collectionitem { public variable createcommand ""; public variable item "" { } protected variable _owner ""; protected variable _id ""; protected variable _handle ""; protected variable _name ""; protected variable peer_name_configurable 0; protected variable _is_destroying 0; protected variable _init_count 0; ;#// used only for debug protected variable _peer_exists 0; ;#// used only for debug protected variable _clientdata ""; public method clientdata {{Src "get"}} { ::if {$Src eq "get"} {::return $_clientdata;} ::set _clientdata $Src; } constructor {args} { ::set _is_destroying 0; ::set _id $this; ::set createcommand ""; ::set ::qw::control(qw_com_collectionitem_count) [::expr {$::qw::control(qw_com_collectionitem_count)+1}]; ::return $this; } method createcommand_value_changed {args} { } method item_value_changed {args} { } method handle_value_changed {args} { } method handle_value_unset {args} { } destructor { ::if {[is_being_destroyed]} { ::qw::throw "$this destructor called but object is already being destroyed."; } ::set _is_destroying 1; $_owner kidDetach $this; unbind; ::unset _handle; ::set ::qw::control(qw_com_collectionitem_count) [::expr {$::qw::control(qw_com_collectionitem_count)-1}]; ::if {[::info exists ::qw::_tcom_handle_count($this)]} { ::set ::qw::_tcom_handle_count($this) [::expr {$::qw::_tcom_handle_count($this)-1}]; } else { } } public method is_being_destroyed {} { ::return $_is_destroying; } public method init {} { ::set Sheet 0; ::if {[::string first "::sheet" $this]>0} { ::set Sheet 1; } handle_Set ""; ::if {[owner_Get] eq ""} { ::qw::bug "907020030928213306" "$_id owner has not been set."; } ::if {$createcommand eq ""} { ::return $this; } ::if {$item ne ""} { ::if {$::qw::com::package eq "optcl"} { handle_Set [::eval [::list $createcommand ":" "Item($item)"]]; } else { ::if {[::string is integer $item]} { ::qw::try { handle_Set [::eval [::list $createcommand "Item" [::expr $item]]]; } catch Exception { ::qw::babyship::singleton asynch_post_to_mothership .message [::sargs .message_type excel_unknown_error]; ::if {![::winfo exists .winexplo]} { ::source [::file join $::qw_library object system gui winexplo.qw_tcl]; } handle_Set [::eval [::list $createcommand "Item" [::expr $item]]]; } } else { handle_Set [::eval [::list $createcommand "Item" $item]]; } } } else { handle_Set [::eval $createcommand]; } ::if {$peer_name_configurable} { ::if {$::qw::com::package eq "optcl"} { ::catch {::set _name [[handle_Get] ":" "Name"]}; } else { ::catch {::set _name [handle_command "Name"]}; } } ::if {$::qw::com::package eq "optcl"} { ::catch {::set item [[handle_Get] ":" "Index"]}; } else { ::catch {::set item [handle_command "Index"]}; } ::return $this; } public method has_bindings {} { ::return 0; } protected variable _event ""; protected variable _event_args ""; protected variable _event_handles ""; public method event_receive {args} { ::set _event_args $args; ::return $this; ;#// for now (20040820) } public method event {} { ::return 1; } public method echo {Src} { ::set Result "$Src "; ::return [::string trim $Result]; } public method owner_Set {Src} { ::if {$_owner ne ""} { ::if {$_owner eq $Src} { ::qw::bug "907020030928213332" "$_id is already attached to same collection."; } else { ::qw::bug "907020030928213346" "$_id is already attached to different collection."; } } ::set _owner $Src; $_owner kidAttach $this; ::return $this; } public method owner_Get {} { ::return $_owner; } public method name_Set {Src} { ::if {[handle_Get] eq ""} { ::qw::bug "907020030928213403" "Excel peer for $_id not been created yet."; } ::if {!$peer_name_configurable} { ::qw::bug "907020030929213422" "Attempted to set the name of a [::eval [::list $_owner kid_type]]."; } ::set _name $Src; ::if {[::file extension $_name] eq ".pdf"} { ::return $this; } handle_property "SaveAs" $_name; ::return $this; } public method name_Get {} { ::if {[handle_Get] eq ""} {::qw::bug "907020030928213409" "Excel peer for $_id not been created yet.";} ::return [handle_property "Name"]; } public method handle_Get {} { ::if {![::qw::command_exists $_handle]} { } ::return $_handle; } public method handle_Set {Src} { ::set _handle $Src; ::if {$Src eq ""} { ::set ::qw::control(qw_com_handle_Set_count) [::expr {$::qw::control(qw_com_handle_Set_count)-1}]; ::if {[::info exists ::qw::_tcom_handle_count($this)]} { ::set ::qw::_tcom_handle_count($this) [::expr {$::qw::_tcom_handle_count($this)-1}]; } else { } ::return $this; } ::set ::qw::control(qw_com_handle_Set_count) [::expr {$::qw::control(qw_com_handle_Set_count)+1}]; ::if {[::info exists ::qw::_tcom_handle_count($this)]} { ::set ::qw::_tcom_handle_count($this) [::expr {$::qw::_tcom_handle_count($this)+1}]; } else { ::set ::qw::_tcom_handle_count($this) 1; } ::switch [[::tcom::info interface $_handle] name] { "_Application" {} "_Workbook" {} "_Worksheet" {} "PageSetup" {} "Window" {} "Range" { ::foreach Whatever [::lsort -dictionary -index 0 [[::tcom::info interface $_handle] properties]] { ::switch [::lindex $Whatever 3] { "Columns" { } } } } "Font" {} "Border" {} } set_bindings; ::return $this; } public method set_bindings {} { ::return; ::if {![has_bindings]} { ::return $this; } ::qw::try { ::tcom::bind $_handle [::list $this event_receive]; } catch Exception { ::if {[::sargs::get $Exception ".text"] ne "no event interface information"} { ::qw::throw $Exception } ::return $this; } ::return $this; } public method unbind {} { ::return; ::if {![has_bindings]} {::return $this;} ::if {$_handle eq ""} {::return $this;} ::tcom::unbind $_handle; ::return $this; } public method handle_method {args} { ::set Result [::eval [handle_Get] $args]; ::return $Result; } public method handle_property {args} { ::if {$::qw::com::package eq "optcl"} { ::set Result [::eval [handle_Get] ":" $args]; } else { ::set Result [::eval [handle_Get] $args]; } ::return $Result; } public method handle_command {args} { ::set Result [::eval [handle_Get] $args]; ::return $Result; } public method handle_property_number {Property Number} { ::set Result [[handle_Get] $Property [::expr $Number]]; ::return $Result; } public method handle_property_bool {Property Src} { ::set Result [[handle_Get] $Property [::qw::tcom_make_boolean $Src]]; ::return $Result; } public method handle_property_integer {Property Src} { ::set Result [[handle_Get] $Property $Src]; ::return $Result; } public method synchronized_peer_check {{Path ""} {ResultSoFar ""}} { ::sargs::var::set ResultSoFar ".$Path.handle_Get" [handle_Get]; ::sargs::var::set ResultSoFar ".$Path.handle_Get_name" [[::tcom::info interface [handle_Get]] name]; ::return $ResultSoFar; } public method application {} { ::if {$_owner eq ""} { ::return $this; } ::if {[::string first "::qw::com::application" $this]==0} { ::return $this; } ::return [$_owner application]; } } ::itcl::class ::qw::com::applications { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { ::eval configure $args; } destructor { } public method init {} { chain; ::return $this; } public method factory {args} { ::array set Args $args; ::if {![::info exists Args(-application)]} { ::qw::bug "907020030928213452" "-application not specified." } ::set Application $Args(-application); ::unset Args(-application); ::switch -- [::string toupper $Application] { "EXCEL" {::set Args(-kid_class) ::qw::com::application::excel;} "WORD" {::set Args(-kid_class) ::qw::com::application::word;} "INTERNETEXPLORER" {::set Args(-kid_class) ::qw::com::application::internetexplorer;} "ACCESS" {::set Args(-kid_class) ::qw::com::application::access;} default {::qw::bug "907020030928213508" "Unknown -application \"$Application\". -application must be \"excel\", \word\", \"access\", or \"internetexplorer\".";} } ::set Result [::eval chain [::array get Args]]; ::return $Result; } public method collection {} { ::error "Now what ma?"; } } ::itcl::class ::qw::com::application { inherit ::qw::com::collectionitem; protected variable _program_name ""; protected variable _program_identifier ""; protected variable _visible 0; protected variable _abort_application 0; protected variable _after_id ""; protected variable _version ""; public variable filename ""; public variable filename_handle ""; public variable destination ""; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 0; ::eval configure $args; ::return $this; } destructor { ::if {$_after_id ne ""} { ::after cancel $_after_id; ::set _after_id ""; } } public method init {} { handle_Set ""; ::if {$filename ne ""} { ::qw::try { ::set filename_handle [::tcom::ref getobject [::file nativename $filename]] } catch Exception { ::qw::throw "Could not open file $filename. $Exception"; } ::set Application [$filename_handle Application]; handle_Set $Application; ::set _version [version_Get]; ::if {$destination eq "display"} { visible_Set 1; } $filename_handle Activate; ::if {0} { [$filename_handle Windows] Add; } else { } ::return $this; } ::qw::try { ::qw::try { handle_Set [::tcom::ref getactiveobject $_program_identifier] } catch Exception { handle_Set [::tcom::ref createobject $_program_identifier]; } } catch Exception { ::qw::throw "Could not start $_program_name. Program not installed?"; } ::set _visible [handle_property "Visible"]; ::set _version [version_Get]; ::return $this; } method destroy_application {} { ::if {[handle_Get] eq ""} { ::return $this; } ::qw::try { handle_command "Quit"; } catch Exception { } handle_Set ""; ::return $this; } public method visible_Set {Src} { ::if {![::string is boolean $Src]} { ::qw::bug "907020030928213645" "Invalid visible value \"$Src\". Value must be boolean"; } ::if {[handle_Get] eq ""} { ::return $this; } ::set _visible $Src; handle_property "Visible" [::expr $_visible?1:0]; ::return $this; } public method visible_Get {} { ::return $_visible; } public method active_printer_Set {Src} { ::set Start [::clock clicks -milliseconds]; ::if {$Src ne [active_printer_Get]} { handle_property "ActivePrinter" $Src; } ::set End [::clock clicks -milliseconds]; ::return $this; } public method active_printer_Get {} { ::set Start [::clock clicks -milliseconds]; ::set Result [handle_property "ActivePrinter"]; ::set End [::clock clicks -milliseconds]; ::return $Result; } public method version_Get {} { ::return "unknown"; } public method event_receive {args} { ::if {[::string first "WorkbookDeactivate" $_event_args]>=0} { ::set _after_id [::after idle [::list $this check_application_status]]; } } public method activate_old {} { ::if {[catch {handle_property "Name"} errMsg]} { destroy_application; init; } else { } } public method activate {} { ::if {![check_application_status]} { destroy_application; init; } else { } } public method check_application_status_old {} { ::if {[catch {handle_property "Name"} errMsg]} { } else { } } public method check_application_status {} { ::qw::try { ::set Name [handle_property "Name"]; ::return 1; } catch Exception { ::return 0; } ::return 1; } public method event {} { ::return [chain]; } public method has_bindings {} { ::return 1; } public method display_alerts {{Src "get"}} { ::if {$Src eq "get"} { ::return [handle_property "DisplayAlerts"]; } handle_property_bool "DisplayAlerts" $Src; } public method version {} { ::return $_version; } public method language_version {} { ::return "Unknown"; } public method country_version {} { ::return "Unknown"; } protected variable _pdfWriterRegistryOptionPath {HKEY_LOCAL_MACHINE\Software\PDFCreator\Program}; ;#// server install (to aquire auto file save) public method create_pdf_file {s_args} { ::if {![$::nv2::print::printers exists "PDFCreator"]} { ::qw::throw "Cannot produce PDF file, the PDFCreator printer has not been installed."; } ::set ErrorList ""; ::set Option 1; ;#// Watch for the output files in the path the user configured PDF Creator to. ::set UseAutosave [::registry get $_pdfWriterRegistryOptionPath UseAutosave]; ::if {!$UseAutosave} { ::lappend ErrorList "The \"Use Auto-save\" option has not been checked."; } ::set AutosaveFormat [::registry get $_pdfWriterRegistryOptionPath AutosaveFormat]; ::if {$AutosaveFormat ne "0"} { ::lappend ErrorList "The \"Autosave Format\" is not set to \"PDF\"."; } ::if {$Option!=1} { ::set AutosaveFilename [::registry get $_pdfWriterRegistryOptionPath AutosaveFilename]; ::if {$AutosaveFilename ne ""} { ::lappend ErrorList "The \"Auto-save file name\" is not set to \"\"."; } } ::set UseAutosaveDirectory [::registry get $_pdfWriterRegistryOptionPath UseAutosaveDirectory]; ::if {$UseAutosaveDirectory ne "1"} { ::lappend ErrorList "The \"Use this directory for auto-save\" option has not been checked."; } ::set AutosaveDirectory [::registry get $_pdfWriterRegistryOptionPath AutosaveDirectory]; ::if {$ErrorList ne ""} { ::set Text [::llength $ErrorList]; ::if {[::llength $ErrorList]==1} { ::append Text " error was " } else { ::append Text " errors were " } ::append Text "encountered in the options for the PDF Creator printer." ::foreach Error $ErrorList { ::append Text "\n$Error"; } ::qw::throw [::sargs \ .text $Text \ .help_id 0 \ ]; } ::set PrintCommand [::sargs::get $s_args ".print_command"]; ::set DestinationFileName [::file nativename [::sargs::get $s_args ".filename"]]; ::if {$DestinationFileName ne ""} { ::set DestinationPath [::file dirname $DestinationFileName]; ::if {![::file exists $DestinationPath]} { ::qw::try { ::file mkdir $DestinationPath; } catch Exception { ::qw::throw "Could not create directory [::file nativename $DestinationPath]. $Exception"; } } } ::if {$Option==1} { ::set OldFileList [::glob -nocomplain -directory $AutosaveDirectory *.pdf]; ::eval $PrintCommand; ::set MillisecondsLimit "30000"; ::set MillisecondsIncrement "200"; ::set Milliseconds "0"; ::set NewFile ""; ::while {$Milliseconds<$MillisecondsLimit} { ::incr Milliseconds $MillisecondsIncrement; ::after $MillisecondsIncrement; ::set NewFileList [::glob -nocomplain -directory $AutosaveDirectory *.pdf]; ::set Result [::qw::intersect3 $OldFileList $NewFileList]; ::set NewFiles [::lindex $Result 2]; ::if {[::llength $NewFiles]==1} { ::set NewFile [::lindex $NewFiles 0]; ::break; } } ::if {[::llength $NewFiles]==0} { ::qw::throw [::sargs \ .text "Unable to find the output PDF file in $AutosaveDirectory" \ .help_id 0 \ ]; } ::if {[::llength $NewFiles]>1} { ::qw::throw [::sargs \ .text "More then one new PDF file in $AutosaveDirectory - $NewFile" \ .help_id 0 \ ]; } } ::set NewFile [::file normalize $NewFile]; ::if {$DestinationFileName eq ""} { ::return $NewFile; } ::set MillisecondsLimit "30000"; ::set MillisecondsIncrement "200"; ::set Milliseconds "0"; ::set Success 0; ::while {$Milliseconds<=$MillisecondsLimit} { ::after $MillisecondsIncrement; ::incr Milliseconds $MillisecondsIncrement; ::qw::try { ::file rename -force -- $NewFile $DestinationFileName; ::set Success 1; ::break; } catch Exception { ::qw::warning "907020060620131202" "$NewFile rename failed at $Milliseconds ms."; } } ::if {!$Success} { ::qw::throw [::sargs \ .text "Timeout waiting for PDF file $NewFile to become writeable." \ .help_id 0 \ ]; } ::return $DestinationFileName; } } ::itcl::class ::qw::com::application::excel { inherit ::qw::com::application; protected variable _title_bar ""; public variable callback ""; protected variable _workbooks ""; constructor {args} { ::eval ::qw::com::application::constructor $args; } { ::eval configure $args; ::set _program_identifier "Excel.Application"; ::set _program_name "Microsoft Excel"; ::set peer_name_configurable 0; ::set _workbooks [::qw::com::application::excel::objects::workbooks ::qw::com::application::excel::objects::workbooks::#auto]; $_workbooks owner_Set $this; ::return $this; } destructor { deinit; } public method deinit {} { ::if {$_workbooks ne ""} { ::if {[$_workbooks is_being_destroyed]} { ::qw::throw "$this attempted to destroy workbooks $_workbooks but it is already being destroyed."; } ::itcl::delete object $_workbooks; ::set _workbooks ""; } ::return $this; } public method init {} { chain; ::set _title_bar [handle_property "Caption"]; $_workbooks init; $_workbooks kids_create_from_collection; ::return $this; } public method title_bar_Set {Src} { ::if {[handle_Get] eq ""} {::return $this;} handle_property "Caption" $_title_bar; ::set _title_bar $Src; ::return $this; } public method version_Get {} { ::return [handle_command "Version"]; } public method title_bar_Get {} { ::return $_title_bar; } public method maximized {} { ::return [handle_command "DisplayFullScreen"]; } public method maximize {} { handle_command "DisplayFullScreen" "1"; ::return $this; } public method Workbooks {} { ::return [handle_property "Workbooks"]; } public method workbooks {} { ::return $_workbooks; } public method event {} { ::switch $_event { "WorkbookDeactivate" { ::foreach Handle $_event_handles { ::for {::set Kid [$_workbooks kidFirst]} {$Kid ne ""} {::set Kid [$_workbooks kidNext $Kid]} { ::set KidHandle [$Kid handle_Get]; ::if {[::tcom::ref equal $Handle $KidHandle]} { ::return $this; } } } } } ::return [chain]; } public method visible_Set {Src} { ::if {[handle_Get] eq ""} {::return $this;} ::if {$Src} {handle_property "DisplayFullScreen" 1;handle_property "DisplayFullScreen" 0;} ::return [chain $Src]; } public method calculation_mode {{Src "get"}} { ::if {$Src eq "get"} { ::switch [handle_property "Calculation"] { "-4105" {::return "automatic";} "-4135" {::return "manual";} "2.0" {::return "semi-automatic";} default { ::return ""; } } } ::switch $Src { "automatic" {handle_property_number "Calculation" -4105;} "manual" {handle_property_number "Calculation" -4135;} "semi-automatic" {handle_property_number "Calculation" 2.0;} default { ::return ""; } } } public method language_version {} { ::set CountryCode [::lindex [handle_property "International"] 0]; ::switch -- [::expr int($CountryCode)] { "1" {::return "English";} "7" {::return "Russian";} "30" {::return "Greek";} "31" {::return "Dutch";} "33" {::return "French";} "34" {::return "Spanish";} "36" {::return "Hungarian";} "39" {::return "Italian";} "42" {::return "Czech";} "45" {::return "Danish";} "46" {::return "Swedish";} "47" {::return "Norwegian";} "48" {::return "Polish";} "49" {::return "German";} "55" {::return "Portuguese (Brazil)";} "66" {::return "Thai";} "81" {::return "Japanese";} "82" {::return "Korean";} "84" {::return "Vietnamese";} "86" {::return "Simplified Chinese";} "90" {::return "Turkish";} "91" {::return "Indian";} "92" {::return "Urdu";} "98" {::return "Farsi";} "351" {::return "Portuguese";} "358" {::return "Finnish";} "886" {::return "Traditional Chinese";} "966" {::return "Arabic";} "972" {::return "Hebrew";} default {::return [chain];} } } public method country_version {} { ::set CountryCode [::lindex [handle_property "International"] 0]; ::switch -- [::expr int($CountryCode)] { "1" {::return "The United States of America";} "7" {::return "Russian Federation";} "30" {::return "Greece";} "31" {::return "The Netherlands";} "33" {::return "France";} "34" {::return "Spain";} "36" {::return "Hungary";} "39" {::return "Italy";} "42" {::return "Czech Republic";} "45" {::return "Denmark";} "46" {::return "Sweden";} "47" {::return "Norway";} "48" {::return "Poland";} "49" {::return "Germany";} "55" {::return "Brazil";} "66" {::return "Thailand";} "81" {::return "Japan";} "82" {::return "Korea";} "84" {::return "Vietnam";} "86" {::return "People's Republic of China";} "90" {::return "Turkey";} "91" {::return "India";} "92" {::return "Pakistan";} "98" {::return "Iran";} "351" {::return "Portugal";} "358" {::return "Finland";} "886" {::return "Taiwan";} "966" {::return "Saudi Arabia";} "972" {::return "Israel";} default {::return [chain];} } } public method active_printer_Set {Src} { ::set Language [language_version]; ::switch -- $Language { "English" {::return [chain $Src];} "French" {::set Word "sur";} default {::return [chain $Src];} } ::set Index [::string last " on " $Src]; ::if {$Index<0} {::return [chain $Src];} ::set Src [::string replace $Src $Index [::expr $Index+3] " $Word "]; ::return [chain $Src]; } public method active_printer_Get {} { ::set Result [chain]; ::set Language [language_version]; ::switch -- $Language { "English" {::return $Result;} "French" {::set Word "sur";} default {::return $Result;} } ::set Word " $Word "; ::set Index [::string last $Word $Result]; ::if {$Index<0} {::return $Result;} ::set Result [::string replace $Result $Index [::expr $Index+[::string length $Word]-1] " on "]; ::return $Result; } public method synchronized_peer_check {{Path ""} {ResultSoFar ""}} { ::set ResultSoFar [chain "[::string map {:: _} $this]" $ResultSoFar]; ::set ResultSoFar [$_workbooks synchronized_peer_check "[::string map {:: _} $this]_workbooks" $ResultSoFar]; ::return $ResultSoFar; } } ::itcl::class ::qw::com::application::excel::objects::builtindocumentproperties { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { ::eval configure $args; } destructor { } public method init {} { chain; ::return $this; } method kid_class {} {::return "::qw::com::application::excel::objects::builtindocumentproperty";} method kid_type {} {::return "property";} public method collection {} {::return [handle_property "BuiltinDocumentProperties"];} } ::itcl::class ::qw::com::application::excel::objects::builtindocumentproperty { inherit ::qw::com::collectionitem; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 0; ::eval configure $args; ::return $this; } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner collection] "Add"]; } chain; ::return $this; } destructor { } } ::itcl::class ::qw::com::application::excel::objects::workbooks { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { ::eval configure $args; } destructor { } public method init {} { chain; ::return $this; } method kid_class {} {::return "::qw::com::application::excel::objects::workbook";} method kid_type {} {::return "workbook";} public method collection {} {::return [handle_property "Workbooks"];} public method kids_create_from_collection {} { ::for {::set i 1;} {$i<=[[collection] "Count"]} {::incr i;} { ::set Kid [factory -item $i -createcommand [collection]]; ::if {[::tcom::ref equal [$Kid handle_Get] [[[application] handle_Get] ActiveWorkbook]]} { ::set _selected $Kid; } } } } ::itcl::class ::qw::com::application::excel::objects::workbook { inherit ::qw::com::collectionitem; public variable filename ""; private variable _sheets ""; private variable _windows ""; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 1; ::eval configure $args; ::set _sheets [::qw::com::application::excel::objects::sheets ::qw::com::application::excel::objects::sheets::#auto]; $_sheets owner_Set $this; $_sheets init; ::set _windows [::qw::com::application::excel::objects::windows ::qw::com::application::excel::objects::windows::#auto]; $_windows owner_Set $this; $_windows init; ::return $this; } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner collection] "Add"]; ::if {$filename ne ""} {::lappend createcommand [::file nativename $filename];} } ::if {1} { chain; ;#// factory the peer and handle_Set } else { handle_Set [[$_owner handle_Get] ActiveWorkbook]; } $_sheets kids_create_from_collection; $_windows kids_create_from_collection; clientdata [::sargs::set [clientdata] ".default_sheets" [$_sheets handles]]; ::return $this; } destructor { deinit; } public method deinit {} { ::if {$_sheets ne ""} { ::if {[$_sheets is_being_destroyed]} { ::qw::throw "$this attempted to destroy sheets $_sheets but it is already being destroyed."; } ::itcl::delete object $_sheets; ::set _sheets ""; } ::if {$_windows ne ""} { ::if {[$_windows is_being_destroyed]} { ::qw::throw "$this attempted to destroy windows $_windows but it is already being destroyed."; } ::itcl::delete object $_windows; ::set _windows ""; } ::return $this; } public method file_save {} { handle_method "Save"; } public method mark_file_saved {} { ::qw::com::debug_puts "$this mark_file_saved"; handle_property "Saved" [::expr 1]; ::return $this; } public method mark_file_unsaved {} { handle_property "Saved" [::expr 0]; ::return $this; } public method close {} { handle_method "Close"; ::return $this; } public method activate {} { handle_method "Activate"; ::for {::set Window [$_windows kidFirst]} {$Window ne ""} {::set Window [$_windows kidNext $Window]} { $Window activate; } ::return $this; } public method Sheets {} { ::return [handle_property "Sheets"]; } public method sheets {} { ::return $_sheets; } public method windows {} { ::return $_windows; } public method event {} { ::switch $_event { "Deactivate" { } } ::return [chain]; } public method has_bindings {} { ::return 0; } public method synchronized_peer_check {{Path ""} {ResultSoFar ""}} { ::set ResultSoFar [chain $Path $ResultSoFar]; ::set ResultSoFar [$_sheets synchronized_peer_check "[::string map {:: _} $this]_sheets" $ResultSoFar]; ::return $ResultSoFar; } } ::itcl::class ::qw::com::application::excel::objects::sheets { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } public method init {} { chain; ::return $this; } method kid_class {} {::return "::qw::com::application::excel::objects::sheet";} method kid_type {} {::return "sheet";} public method collection {} {::return [handle_property "Sheets"];} public method kids_create_from_collection {} { ::for {::set i 1;} {$i<=[[collection] "Count"]} {::incr i;} { factory -item $i -createcommand [collection]; } } } ::itcl::class ::qw::com::application::excel::objects::sheet { inherit ::qw::com::collectionitem; private variable _ranges ""; private variable _columns ""; private variable _rows ""; private variable _cells ""; private variable _pagesetups ""; private variable _pagesetup ""; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 1; ::eval configure $args; ::set _ranges [::qw::com::application::excel::objects::ranges ::qw::com::application::excel::objects::ranges::#auto]; $_ranges owner_Set $this; $_ranges init; ::set _rows [::qw::com::application::excel::objects::rows ::qw::com::application::excel::objects::rows::#auto]; $_rows owner_Set $this; $_rows init; ::set _columns [::qw::com::application::excel::objects::columns ::qw::com::application::excel::objects::columns::#auto]; $_columns owner_Set $this; $_columns init; ::set _cells [::qw::com::application::excel::objects::cells ::qw::com::application::excel::objects::cells::#auto]; $_cells owner_Set $this; $_cells init; ::set _pagesetups [::qw::com::application::excel::objects::pagesetups ::qw::com::application::excel::objects::pagesetups::#auto]; $_pagesetups owner_Set $this; $_pagesetups init; clientdata [::sargs::+= [clientdata] [::sargs ".current_row" 0 ".current_column" 0]]; ::return $this; } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner collection] "Add"]; } chain; ::set Sheets [owner_Get]; ::set Workbook [$Sheets owner_Get]; ::if {[$Workbook cget -filename] ne ""} { $_ranges kids_create_from_collection -handle [[[owner_Get] owner_Get] handle_Get]; } ::set _pagesetup [$_pagesetups factory]; ::return $this; } destructor { ::if {[$_ranges is_being_destroyed]} {::qw::throw "$this attempted to destroy ranges $_ranges but it is already being destroyed.";} ::itcl::delete object $_ranges; ::if {[$_rows is_being_destroyed]} {::qw::throw "$this attempted to destroy rows $_rows but it is already being destroyed.";} ::itcl::delete object $_rows; ::if {[$_columns is_being_destroyed]} {::qw::throw "$this attempted to destroy columns $_columns but it is already being destroyed.";} :::itcl::delete object $_columns; ::if {[$_cells is_being_destroyed]} {::qw::throw "$this attempted to destroy cells $_cells but it is already being destroyed.";} ::itcl::delete object $_cells; ::if {[$_pagesetups is_being_destroyed]} {::qw::throw "$this attempted to destroy pagesetups $_pagesetups but it is already being destroyed.";} ::itcl::delete object $_pagesetups; } public method destroy_peer {} { ::set Sheets [owner_Get]; ::set Workbook [$Sheets owner_Get]; ::set Workbooks [$Workbook owner_Get]; ::set Application [$Workbooks owner_Get]; ::set DisplayAlertsState [$Application display_alerts]; $Application display_alerts 0; handle_command "Delete"; $Application display_alerts $DisplayAlertsState; } public method visible {{Src "get"}} { ::if {$Src eq "get"} { ::return [handle_property "Visible"]; } ::if {![::string is boolean $Src]} { ::qw::bug "907020050214213645" "Invalid visible value \"$Src\". Value must be boolean"; } handle_property_integer "Visible" $Src; ::return $this; } public method activate {} { [$_owner handle_Get] "Activate"; handle_command "Activate"; ::return $this; } public method ranges {} {::return $_ranges;} public method rows {} {::return $_rows;} public method columns {} {::return $_columns;} public method cells {} {::return $_cells;} public method print_preview {} { handle_method "PrintPreview"; ::return $this; } public method print {} { handle_property "PrintOut"; ::return $this; } public method Names {} { ::return [handle_property "Names"]; } public method pages {} { ::if {$::qw::com::package eq "optcl"} { ::return [[handle_command ":" "HPageBreaks"] ":" "Count"]; } else { ::return [[handle_command "HPageBreaks"] "Count"]; } } public method print_range_Set {Src } { ::set PageSetup [handle_property "PageSetup"]; ::if {$::qw::com::package eq "optcl"} { $PageSetup ":" "PrintArea" [::qw::excel::toExcelRange $Src]; } else { $PageSetup PrintArea [::qw::excel::toExcelRange $Src]; } ::return $this; } public method print_range_Get {{Src {get}}} { ::set PageSetup [handle_property "PageSetup"]; ::if {$::qw::com::package eq "optcl"} { ::return [::qw::excel::fromExcelRange [$PageSetup ":" "PrintArea"]] } else { ::return [::qw::excel::fromExcelRange [$PageSetup "PrintArea"]] } } public method page_break_insert {Src} { ::set TempRange [$_ranges factory]; $TempRange rectangle_Set [::list .size [::list .x 1 .y 1] .position [::list .x 1 .y $Src]]; ::if {$::qw::com::package eq "optcl"} { ::set HPageBreaks [handle_command ":" "HPageBreaks"]; $HPageBreaks ":" Add Before [$TempRange handle_Get]; } else { ::set HPageBreaks [handle_command "HPageBreaks"]; $HPageBreaks -namedarg Add Before [$TempRange handle_Get]; } $_ranges destroy $TempRange; ::return $this; } public method pagesetup {} { ::return $_pagesetup; } public method name_Set {Src} { ::set Src [::string range [::string map {: {colon} \\ {backslash} / {slash} ? {question} * {asterisk} [ {leftbrace} ] {rightbrace}} $Src] 0 25]; ;#// allows for " (xxx)" ::set ExistingNames [$_owner names]; ::if {[::lsearch -exact $ExistingNames $Src]>=0} { ::set Suffix "2"; ::while {[::lsearch -exact $ExistingNames "$Src ($Suffix)"]>=0} { ::incr Suffix; } ::set Src "$Src ($Suffix)"; } ::set _name $Src; handle_property "Name" $_name; ::return $this; } public method create_pdf_file {s_args} { ::set Sheets [owner_Get]; ::set Workbook [$Sheets owner_Get]; ::set Workbooks [$Workbook owner_Get]; ::set Application [$Workbooks owner_Get]; ::if {[$Application version_Get]>=12.0} { ::set Filename [::file nativename [::sargs::get $s_args .filename]]; [handle_Get] ExportAsFixedFormat 0 $Filename; ::return [::sargs::get $s_args .filename]; } ::if {![$::nv2::print::printers exists "PDFCreator"]} { ::qw::throw [::sargs \ .text "Cannot produce a PDF file, the PDF Creator printer has not been installed." \ .help_id 271820091119115102 \ ]; } ::set PdfPrinter [[$::nv2::print::printers item "PDFCreator"] excelname]; ::set ActivePrinter [$Application active_printer_Get]; ::if {$ActivePrinter ne $PdfPrinter} { $Application active_printer_Set $PdfPrinter; } ::set Args ""; ::if {$Args eq ""} { ::set PrintCommand "$_handle PrintOut"; } else { ::set PrintCommand "$_handle -namedarg PrintOut $Args"; } ::sargs::var::set s_args ".print_command" $PrintCommand; ::qw::try { ::set PdfFile [$Application create_pdf_file $s_args]; } catch Exception { ::if {$ActivePrinter ne $PdfPrinter} { $Application active_printer_Set $ActivePrinter; } ::qw::throw $Exception; } ::if {$ActivePrinter ne $PdfPrinter} { $Application active_printer_Set $ActivePrinter; } ::return $PdfFile; } public method synchronized_peer_check {{Path ""} {ResultSoFar ""}} { ::set ResultSoFar [chain $Path $ResultSoFar]; ::set ResultSoFar [$_ranges synchronized_peer_check "[::string map {:: _} $this]_ranges" $ResultSoFar]; ::return $ResultSoFar; } } ::itcl::class ::qw::com::application::excel::objects::windows { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } public method init {} { chain; ::return $this; } method kid_class {} {::return "::qw::com::application::excel::objects::window";} method kid_type {} {::return "window";} public method collection {} {::return [handle_property "Windows"];} public method kids_create_from_collection {} { ::for {::set i 1;} {$i<=[[collection] "Count"]} {::incr i;} { factory -item $i -createcommand [collection]; } ::return $this; } } ::itcl::class ::qw::com::application::excel::objects::window { inherit ::qw::com::collectionitem; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 0; ::eval configure $args; ::return $this; } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner collection] "Add"]; } chain; ::return $this; } destructor { } public method state_Set {Src} { handle_command "WindowState" [::qw::excel::translate_text_to_windowstate $Src]; ::return $this; } public method state_Get {} { ::return [::qw::excel::translate_windowstate_to_text [handle_command "WindowState"]]; } public method scroll {Direction Distance} { ::set D 0; ::set U 0; ::set R 0; ::set L 0; ::switch [::string toupper [::string index $Direction 0]] { "D" {::set D $Distance;} "U" {::set U $Distance;} "L" {::set L $Distance;} "R" {::set R $Distance;} default {::qw::bug "907020030928213704" "Invalid direction arg to scroll method. Direction must be up, down, left, or right.";} } handle_command "SmallScroll" $D $U $R $L; ::return $this; } public method activate {} { [$_owner handle_Get] "Activate"; handle_command "Activate"; ::return $this; } } ::itcl::class ::qw::com::application::excel::objects::ranges { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::excel::objects::range";} method kid_type {} {::return "range";} public method kids_create_from_collection {args} { ::array set Args $args; ::if {$::qw::com::package eq "optcl"} { ::set Names [$Args(-handle) ":" "Names"]; ::set Count [$Names ":" "Count"]; } else { ::set Names [$Args(-handle) "Names"]; ::set Count [$Names "Count"]; } ::set OwnerName [$_owner name_Get]; ::for {::set i 1;} {$i<=$Count} {::incr i;} { ::if {$::qw::com::package eq "optcl"} { ::set NameItem [$Names "Item" $i]; ::set Name [$NameItem ":" "Name"]; ::set Range [$NameItem ":" "RefersToLocal"]; } else { ::set NameItem [$Names "Item" $i]; ::set Name [$NameItem "Name"]; ::set Range [$NameItem "RefersToLocal"]; } ::if {[::string first "=$OwnerName" $Range]<0} { ::continue; } ::if {[::string first "#REF!" $Range]>=0} { ::continue; } ::set NewKid [factory -excel_rectangle_override $Range]; $NewKid name_Set $Name; } } } ::itcl::class ::qw::com::application::excel::objects::range { inherit ::qw::com::collectionitem; public variable excel_rectangle_override "" { ::set _rectangle [validateRectangle [::qw::excel::fromExcelRange $excel_rectangle_override]]; } protected variable _rectangle {.position {.x 0 .y 0} .size {.x 1 .y 1}}; protected variable _cells_handle ""; protected variable _parent_handle ""; protected variable _clipboard_contents ""; protected variable _borders ""; protected variable _border_settings ""; protected variable _fonts ""; protected variable _font ""; protected variable _value_type_list ""; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 0; ::eval configure $args; ::return $this; } public method init {} { ::if {$createcommand eq ""} { ::if {$::qw::com::package eq "optcl"} { ::set createcommand [::list [$_owner handle_Get] ":" "Range([::qw::excel::toExcelRange [rectangle_Get]])"]; } else { ::set createcommand [::list [$_owner handle_Get] "Range" [::qw::excel::toExcelRange [rectangle_Get]]]; } } chain; ::return $this; } destructor { deinit; } public method deinit {} { ::if {$_borders ne ""} { ::if {[$_borders is_being_destroyed]} {::qw::throw "$this attempted to destroy borders $_borders but it is already being destroyed.";} ::itcl::delete object $_borders; ::set _borders ""; } ::if {$_fonts ne ""} { ::if {[$_fonts is_being_destroyed]} {::qw::throw "$this attempted to destroy fonts $_fonts but it is already being destroyed.";} ::itcl::delete object $_fonts; ::set _fonts ""; } ::return $this; } public method font {} { ::if {$_font ne ""} {::return $_font;} ::if {$_fonts eq ""} { ::set _fonts [::qw::com::application::excel::objects::fonts ::qw::com::application::excel::objects::fonts::#auto]; $_fonts owner_Set $this; $_fonts init; } ::set _font [$_fonts factory]; ::return $_font; } public method Borders {} { ::return [handle_property "Borders"]; } public method borders {} { ::if {$_borders ne ""} { ::return $_borders; } ::set _borders [::qw::com::application::excel::objects::borders ::qw::com::application::excel::objects::borders::#auto]; $_borders owner_Set $this; $_borders init; ::set _border_settings [border_defaults]; $_borders kids_create_from_collection; ::return $_borders; } public method border_Get {} { ::return $_border_settings; } public method border_Set {s_args} { ::foreach Name [::sargs::names .structure $s_args] { ::if {![::regexp {(^\.)(.*)} $Name match Dot Position]} { ::qw::throw "Encountered invalid position \"$Name\" in range border_Set command."; } ::set Arg [::sargs::get $s_args $Name]; ::switch $Position { "left" - "right" - "top" - "bottom" - "south-east" - "north-east" { [[borders] item $Position] set $Arg; } "outline" { ::if {[width_Get]==1&&[height_Get]==1} { ::foreach Side {.left .top .right .bottom} {$this border_Set [::list $Side $Arg];} } else { ::set Range [$_owner factory]; [[$Range rectangle_Set [rectangle_Get]] height_Set "1"] border_Set [::list .top $Arg]; ;#// Top [$Range move ".x 0 .y [::expr [height_Get]-1]"] border_Set [::list .bottom $Arg]; ;#// Bottom [[$Range rectangle_Set [rectangle_Get]] width_Set "1"] border_Set [::list .left $Arg]; ;#// Left [$Range move ".x [::expr [width_Get]-1] .y 0"] border_Set [::list .right $Arg]; ;#// Right $_owner destroy $Range; } } "grid" { ::foreach Side {.left .top .right .bottom} {$this border_Set [::list $Side $Arg];} } default { ::qw::throw "Encountered invalid position \"$Name\" in range border_Set command."; } } } ::sargs::var::+= _border_settings $s_args; ::return $this; } public method border_defaults {} { ::return { .left { .style none .weight medium .color black } .right { .style none .weight medium .color black } .top { .style none .weight medium .color black } .bottom { .style none .weight medium .color black } .north-east { .style none .weight medium .color black } .south-east { .style none .weight medium .color black } .outline { .style none .weight medium .color black } .grid { .style none .weight medium .color black } .rows { .style none .weight medium .color black } .columns { .style none .weight medium .color black } }; } private method reset {} { ::set createcommand ""; ::if {$_font ne ""} { $_fonts destroy $_font; ::set _font ""; } init; ::set _cells_handle ""; ::return $this; } private method cellsHandle {} { ::if {$_cells_handle ne ""} {::return $_cells_handle;} ::set _cells_handle [handle_property "Cells"]; ::return $_cells_handle; } private method parentHandle {} { ::if {$_parent_handle ne ""} {::return $_parent_handle;} ::set _parent_handle [handle_property "Parent"]; ::return $_parent_handle; } public method sheet {} { ::return [$_owner [owner_Get]]; } public method name_Set {Src} { ::if {[handle_Get] eq ""} {::qw::bug "907020030928213722" "Excel peer for $_id not been created yet.";} ::set _name $Src; ::return $this; } public method name_Get {} { ::if {[handle_Get] eq ""} {::qw::bug "907020030928213723" "Excel peer for $_id not been created yet.";} ::return $_name; } public method validateRectangle {Src} { ::foreach Item {.position.x .position.y .size.x .size.y} { ::if {![::sargs::exists $Src $Item]} { ::qw::bug "20031109092513" "Src rectangle \"$Src\" is invalid"; } } ::return $Src; } public method rectangle_Set {Src} { ::set _rectangle [validateRectangle $Src]; reset; ::return $this; } public method rectangle_Get {} { ::return [validateRectangle $_rectangle]; } public method owner_set_rectangle {Src} { ::set _rectangle [validateRectangle $Src]; ::return $this; } public method Columns {} { ::return [handle_command "Columns"]; } public method Rows {} { ::return [handle_command "Rows"]; } public method ClearContents {} { ::return [handle_command "ClearContents"]; } public method Clear {} { ::return [handle_command "Clear"]; } public method activate {} { [$_owner handle_Get] "Activate"; handle_command "Activate"; ::return $this; } public method select {} { handle_command "Select"; ::return $this; } public method clipboardSave {} { ::set _clipboard_contents ""; ::clipboard append ""; ::set _clipboard_contents [::clipboard get]; ::clipboard clear; ::return $this; } public method clipboardRestore {} { ::clipboard clear; ::clipboard append $_clipboard_contents; ::set _clipboard_contents ""; ::return $this; } public method copy {} { makeReady; clipboardSave; handle_command "Copy"; ::return $this; } public method paste {} { makeReady; [parentHandle] "Paste"; clipboardRestore; ::return $this; } public method cut {} { makeReady; clipboardSave; handle_command "Cut"; ::return $this; } public method value_type_list {Src} { ::set _value_type_list $Src; } public method value_filter_list {Src} { ::set Result ""; ::set Values [::split $Src \t]; ::for {::set i 0;} {$i<[::llength $Values]} {::incr i;} { ::set Value [::lindex $Values $i]; ::set Type [::lindex $_value_type_list $i]; ::switch -- $Type { "date" { ::qw::try { ::set Date [::qw::date::scan $Value]; ::set Value [::qw::date::format $Date $::qw::date::formats(yyyy-mm-dd)]; } catch Exception { } } "amount" {} default { ::set Value [::qw::excel::value_filter $Value]; } } ::lappend Result $Value; } ::return [::join $Result \t]; } public method value_Set {Src} { ::set Src [value_filter_list $Src]; ::for {::set x 0;} {$x<[::sargs::get [rectangle_Get] ".size.x"]} {::incr x;} { [cellsHandle] Item [::expr 1] [::qw::excel::numberToAlpha [::expr $x+1]] [::lindex [::split $Src \t] $x]; } ::return; } public method value_Get {{Src {get}}} { ::return [get]; } public method font_Set {args} { ::eval [font] set $args; } public method get {} { copy; ::set Data [::split [::clipboard get] \n]; clipboardRestore; ::set Result ""; ::for {::set i 0} {$i<[height_Get]} {::incr i;} { ::set RowResult ""; ::for {::set j 0} {$j<[width_Get]} {::incr j;} { ::lappend RowResult [::lindex [::lindex $Data $i] $j]; } ::lappend Result $RowResult; } ::return $Result; } public method heightIncrement {Src} { height_Set [::expr [height_Get]+$Src]; ::return $this; } public method height_Set {Src} { rectangle_Set [::sargs::set [rectangle_Get] ".size.y" $Src]; ::return $this; } public method height_Get {} { ::return [::sargs::get [rectangle_Get] ".size.y"]; } public method widthIncrement {Src} { width_Set [::expr [width_Get]+$Src]; ::return $this; } public method width_Set {Src} { rectangle_Set [::sargs::set [rectangle_Get] ".size.x" $Src]; ::return $this; } public method width_Get {} { ::return [::sargs::get [rectangle_Get] ".size.x"]; } public method move {Src} { rectangle_Set [::QW::GUI::RECTANGLE::moveBy [rectangle_Get] $Src]; ::return $this; } public method xIncrement {Src} { x_Set [::expr [x_Get]+$Src]; } public method x_Set {Src} { rectangle_Set [::sargs::set [rectangle_Get] ".position.x" $Src]; ::return $this; } public method x_Get {} { ::return [::sargs::get [rectangle_Get] ".position.x"]; } public method yIncrement {Src} { y_Set [::expr [y_Get]+$Src]; ::return $this; } public method y_Set {Src} { rectangle_Set [::sargs::set [rectangle_Get] ".position.y" $Src]; ::return $this; } public method y_Get {} { ::return [::sargs::get [rectangle_Get] ".position.y"]; } public method setLocationFromExcelRange {Src} { ::set Src [::qw::excel::fromExcelRange $Src]; ::set Position [::sargs::get $Src ".position"]; ::set Size [::sargs::get $Src ".size"]; rectangle_Set "$Position $Size"; ::return $this; } public method alignment_horizontal_Set {Src} { ::if {$::qw::com::package eq "optcl"} { [handle_Get] ":" "HorizontalAlignment" [::qw::excel::translate_alignment_to_number $Src]; } else { [handle_Get] "HorizontalAlignment" [::expr [::qw::excel::translate_alignment_to_number $Src]]; } ::return $this; } public method alignment_horizontal_Get {} { ::return [::qw::excel::translate_number_to_alignment [handle_property "HorizontalAlignment"]]; } public method format_Set {Src} { ::set Format ""; ::if {$Src eq ""} { ::set Format "@"; } else { ::if {[::info exists ::qw::number::formats($Src)]} { ::set Format [::qw::excel::qw_number_format_to_excel_format $Src]; } ::if {[::info exists ::qw::date::formats($Src)]} { ::set Format [::qw::excel::qw_date_format_to_excel_format $Src]; } ::if {[::info exists ::qw::time::formats($Src)]} { ::set Format "@"; } ::if {$Src eq "%hh:%mm:%ss"} { ::set Format "@"; } ::if {$Src eq "none"} { ::set Format "@"; } } ::if {$Format eq ""} { ::return $this; } [handle_Get] "NumberFormat" $Format; ::return $this; } public method properties {s_args} { ::set Result ""; ::if {[::sargs::boolean_get $s_args ".rectangle"]} { ::lappend Result "rectangle";::lappend Result [rectangle_Get]; ::set Merged [merged]; ::lappend Result "-merged";::lappend Result $Merged; ::if {$Merged} { ::set MergeRange [mergeRange]; ::set Size [sizePoints $MergeRange]; } else { ::set MergeRange ""; ::set Size [sizePoints [rectangle_Get]]; } ::lappend Result "-mergerange"; ::lappend Result $MergeRange; ::lappend Result "-size"; ::lappend Result $Size; } ::if {[::sargs::boolean_get $s_args ".font"]} { ::array set FontArray {}; ::set Font [handle_property "Font"]; ::set FontArray(-family) [$Font "Name"]; ::set FontSize [$Font "Size"]; ::if {$FontSize eq "::tcom::NULL"} { ::set FontSize 0; } else { ::set FontSize [::expr int([$Font "Size"])]; } ::set FontArray(-size) $FontSize; ::set Style [::string toupper [$Font "FontStyle"]]; ::set Underline [$Font "Underline"]; ::set FontArray(-weight) "normal"; ::set FontArray(-slant) "roman"; ::if {[::string first "BOLD" $Style]>=0} {::set FontArray(-weight) "bold";} ::if {[::string first "ITALIC" $Style]>=0} {::set FontArray(-slant) "italic";} ::set FontArray(-underline) [::qw::excel::translate_number_to_underline $Underline]; ::lappend Result "-font";::lappend Result [::array get FontArray]; } ::if {[::sargs::boolean_get $s_args ".borders"]} { } ::if {[::sargs::boolean_get $s_args ".shrinktofit"]} { ::lappend Result "-shrinktofit";::lappend Result [shrink_to_fit]; } ::return $Result; } public method shrink_to_fit {{Src "get"}} { ::if {$Src eq "get"} { ::return [handle_property "ShrinkToFit"]; } handle_property "ShrinkToFit" $Src; } public method sizePoints {Src} { ::if {$Src eq ""} {::set Src [rectangle_Get];} ::set Width 0; ::for {::set x 0;} {$x<[::sargs::get $Src ".size.x"]} {::incr x;} { ::set Point ".x $x .y 0"; ::foreach {Row Col} [::qw::excel::toExcelCoord2 $Point] {}; ::if {$::qw::com::package eq "optcl"} { ::set W [[[cellsHandle] ":" Item($Row,$Col)] ":" "Width"]; } else { ::set W [[[cellsHandle] Item $Row $Col] "Width"]; } ::set Width [::expr $Width+$W]; } ::set Height 0; ::for {::set y 0;} {$y<[::sargs::get $Src ".size.y"]} {::incr y;} { ::set Point ".x 0 .y $y"; ::foreach {Row Col} [::qw::excel::toExcelCoord2 $Point] {}; ::if {$::qw::com::package eq "optcl"} { ::set H [[[cellsHandle] ":" Item($Row,$Col)] ":" Height]; } else { ::set H [[[cellsHandle] Item $Row $Col] Height]; } ::set Height [::expr $Height+$H]; } ::return ".x $Width .y $Height"; } public method merge {{Src {get}}} { ::set Merged [handle_property "MergeCells"]; ::if {$Merged eq "::tcom::NULL"} {::set Merged 0;} ::if {![::string is boolean $Merged]} {::set Merged 0;} ::if {$Src eq "get"} {::return $Merged;} ::if {$Src eq $Merged} {::return;} ::if {![::string is boolean $Src]} {::qw::throw "merge method passed invalid boolean value \"$Src\".";} handle_property_number "MergeCells" $Src; } public method horizontal_justify {{Src {get}}} { ::if {$Src eq "get"} { ::return [::qw::excel::translate_number_to_alignment [handle_property "HorizontalAlignment"]]; } ::if {$Src eq "left"} {::set Src "left-indent";} ::switch -- $Src { "right" - "left-indent" - "justify" - "center" - "general" - "fill" - "center-across-selection" {;} default { ::qw::throw "horizontal_justify called with invalid arg \"$Src\". arg must be one of \"right\", \"left-indent\", \"justify\", \"center\", \"general\", \"fill\", or \"center-across-selection\"."; } } handle_property_number "HorizontalAlignment" [::qw::excel::translate_alignment_to_number $Src]; } public method vertical_justify {{Src {get}}} { ::if {$Src eq "get"} { ::return [::qw::excel::translate_number_to_alignment [handle_property "VerticalAlignment"]]; } ::switch -- $Src { "bottom" - "top" - "justify" - "center" - default { ::qw::throw "vertical_justify called with invalid arg \"$Src\". arg must be one of \"bottom\", \"top\", \"justify\", or \"center\"."; } } handle_property_number "VerticalAlignment" [::qw::excel::translate_alignment_to_number $Src]; } public method merged {} { ::set Result [handle_property "MergeCells"]; ::if {![::string is boolean $Result]} {::set Result 0;} ::return $Result; } public method mergeRange {} { ::if {$::qw::com::package eq "optcl"} { ::return [::qw::excel::fromExcelRange [[[handle_Get] ":" "MergeArea"] ":" "Address"]]; } else { ::if {[height_Get]==1} { ::return [::qw::excel::fromExcelRange [[[handle_Get] "MergeArea"] "Address"]]; } ::set Cells [[handle_Get] "Cells"]; ::set Result [::qw::excel::fromExcelRange [[[$Cells Item 1] "MergeArea"] "Address"]]; ::for {::set Cell 2;} {$Cell<=[$Cells Count]} {::incr Cell;} { ::set Result [::QW::GUI::RECTANGLE::| $Result [::qw::excel::fromExcelRange [[[$Cells Item $Cell] "MergeArea"] "Address"]]]; } ::return $Result; } } private method makeReady {} { ensureValid; ::return $this; } private method ensureValid {} { ::if {[height_Get]==0&&[width_Get]==0} {::qw::bug "907020030928213737" "range $id, width & height are 0. ([rectangle_Get])";} ::if {[height_Get]==0} {::qw::bug "907020030928213757" "range $id, height is 0. ([rectangle_Get])";} ::if {[width_Get]==0} {::qw::bug "907020030928213814" "range $id, width is 0. ([rectangle_Get])";} ::return $this; } public method autofit {} { [Columns] "AutoFit"; } public method synchronized_peer_check {{Path ""} {ResultSoFar ""}} { ::set ResultSoFar [chain $Path $ResultSoFar]; ::sargs::var::set ResultSoFar ".$Path.properties" [properties ".rectangle 1 .font 1 .shrinktofit 1"]; ::return $ResultSoFar; } } ::itcl::class ::qw::com::application::excel::objects::borders { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::excel::objects::border";} method kid_type {} {::return "border";} public method collection {} {::return [handle_property "Borders"];} public method kids_create_from_collection {} { ::foreach Border { {1 left} {2 right} {3 top} {4 bottom} {5 south-east} {6 north-east} } { ::set Number [::lindex $Border 0]; ::set Name [::lindex $Border 1]; [factory -item $Number -createcommand [collection]] name_Set $Name; } } } ::itcl::class ::qw::com::application::excel::objects::border { inherit ::qw::com::collectionitem; protected variable _styleArray ""; protected variable _style "none"; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::eval configure $args; ::catch {::unset _styleArray}; ::array set _styleArray { none 0 single 1 dash 2 dot 3 dash-dot 4 dash-dot-dot 5 slant-dash-dot 6 double 9 } ::return $this; } destructor { } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [$_owner collection]; } chain; ::return $this; } public method name_Set {Src} { ::set _name $Src; ::return $this; } public method name_Get {} { ::return $_name } public method set {s_args} { ::set Style [::sargs::get $s_args ".style"] ::if {![::info exists _styleArray($Style)]} {::qw::throw "Invalid border style \"$Src\"";} ::set Style $_styleArray($Style); [[$_owner collection] Item [::expr $item]] LineStyle [::expr $Style]; ::return $this; } public method get {Src} { ::set Number [handle_property "LineStyle"]; ::foreach Name [::array names _styleArray] { ::if {$_styleArray($Name) eq $Number} {::return $Name;} } ::qw::throw "Encountered unknown border style number $Number."; ::return ""; } } ::itcl::class ::qw::com::application::excel::objects::fonts { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::excel::objects::font";} method kid_type {} {::return "font";} public method collection {} {::return [handle_property "Font"];} } ::itcl::class ::qw::com::application::excel::objects::font { inherit ::qw::com::collectionitem; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::eval configure $args; ::return $this; } destructor { } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner handle_Get] "Font"]; } chain; ::return $this; } public method get {} { ::set Result ""; ::lappend Result "-family";::lappend Result [handle_property "Name"]; ::lappend Result "-size";::lappend Result [::expr int([handle_property "Size"])]; ::lappend Result "-weight"; ::if {[handle_property "Bold"]} { ::lappend Result "bold"; } else { ::lappend Result "normal"; } ::lappend Result "-slant"; ::if {[handle_property "Italic"]} { ::lappend Result "italic"; } else { ::lappend Result "roman"; } ::lappend Result "-underline";::lappend Result [::qw::excel::translate_number_to_underline [handle_property "Underline"]]; ::lappend Result "-overstrike";::lappend Result [handle_property "Strikethrough"]; ::return $Result; } public method set {args} { ::array set Args $args; ::foreach {Name Value} [::array get Args] { ::switch -- $Name { "-family" {handle_property "Name" $Value;} "-size" {handle_property "Size" [::expr $Value];} "-weight" {handle_property_number "Bold" [::expr [::string equal $Value "bold"]?1:0]} "-slant" {handle_property_number "Italic" [::expr [::string equal $Value "italic"]?1:0]} "-underline" {handle_property_number "Underline" [::qw::excel::translate_underline_to_number $Value];} "-overstrike" {handle_property_number "Strikethrough" $Value;} } } ::return $this; } } ::itcl::class ::qw::com::application::excel::objects::columns { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::excel::objects::column";} method kid_type {} {::return "column";} public method collection {} {::return [handle_property "Columns"];} } ::itcl::class ::qw::com::application::excel::objects::column { inherit ::qw::com::collectionitem; protected variable column 0; # Excel is 1 based, we are 0 based. constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::eval configure $args; ::if {$item eq ""} {::set item 1;::set column 0;} ::return $this; } destructor { } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [$_owner collection]; } chain; ::return $this; } public method column_Set {Src} { ::set column $Src; ::set Item [::expr $column+1]; ::set item [::qw::excel::numberToAlpha $Item]; init; ::set item $Item; ::return $this; } public method column_Get {} { ::return $column; } public method width_Set {Src} { ::return [width_characters_Set $Src]; } public method width_Get {} { ::return [width_characters_Get]; } public method width_characters_Set {Src} { ::if {$Src>255} {::set Src 255;} handle_property "ColumnWidth" $Src; ::return $this; } public method width_characters_Get {} { ::return [handle_property "ColumnWidth"]; } public method width_points_Set {Src} { handle_property "Width" $Src; ::return $this; } public method width_points_Get {} { ::return [handle_property "Width"]; } public method width_pixels_Set {Src} { handle_property "Width" $Src; ::return $this; } public method width_pixels_Get {} { ::return [handle_property "Width"]; } public method pixels_to_points {Src} { } public method points_to_pixels {Src} { } } ::itcl::class ::qw::com::application::excel::objects::rows { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::excel::objects::row";} method kid_type {} {::return "row";} public method collection {} {::return [handle_property "Rows"];} } ::itcl::class ::qw::com::application::excel::objects::row { inherit ::qw::com::collectionitem; protected variable row 0; # Excel is 1 based, we are 0 based. constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::eval configure $args; ::if {$item eq ""} {::set item 1;::set row 0;} ::return $this; } destructor { } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [$_owner collection]; } chain; ::return $this; } public method row_Set {Src} { ::set row $Src; ::set item [::expr $row+1]; init; } public method row_Get {} { ::return $row; } public method height_Set {Src} { ::if {$Src>409} {::set Src 409;} handle_property "RowHeight" $Src; ::return $this; } public method height_Get {} { ::return [handle_property "RowHeight"]; } } ::itcl::class ::qw::com::application::excel::objects::cells { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::excel::objects::cell";} method kid_type {} {::return "cell";} public method collection {} {::return [handle_property "Cells"];} } ::itcl::class ::qw::com::application::excel::objects::cell { inherit ::qw::com::collectionitem; public variable row 0; public variable column 0; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::eval configure $args; ::return $this; } destructor { } public method init {} { ::if {$createcommand eq ""} { ::if {$::qw::com::package eq "optcl"} { ::set createcommand [::list [$_owner handle_Get] ":" "Cells"]; } else { ::set createcommand [::list [$_owner handle_Get] "Cells"]; } } chain; ::return $this; } public method point_Set {Src} { ::set row [::sargs::get $Src ".y"]; ::set column [::sargs::get $Src ".x"]; ::return $this; } public method point_Get {{Src {get}}} { ::return ".x $column .y $row"; } public method value_Set {Src} { ::set Row [::expr $row+1]; ::set Col [::expr $column+1]; ::set Src [::qw::excel::value_filter $Src]; handle_property "Item" [::expr $Row] [::qw::excel::numberToAlpha $Col] $Src; ::return $this; } public method value_Get {} { ::set Row [::expr $row+1]; ::set Col [::expr $column+1]; ::return [[handle_property "Item" $Row [::qw::excel::numberToAlpha $Col]] Value]; } public method shrinkToFit {{Src {get}}} { ::if {$Src eq "get"} {::return [[handle_property "Item" $Row [::qw::excel::numberToAlpha $Col]] "ShrinkToFit"];} ::if {$Src} {::set Src 1;} else {::set Src 0;} handle_property "Item" [::expr $Row] [::qw::excel::numberToAlpha $Col] "ShrinkToFit" $Src; ::return $this; } public method font_Set {Src} { ::qw::throw "Cell font_Set not implemented yet."; } public method format_Set {Src} { ::set Row [::expr $row+1]; ::set Col [::expr $column+1]; [handle_property "Item" [::expr $Row] [::qw::excel::numberToAlpha $Col]] "NumberFormat" $Src; } } ::itcl::class ::qw::com::application::excel::objects::pagesetups { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::excel::objects::pagesetup";} method kid_type {} {::return "pagesetup";} public method collection {} {::return [handle_property "PageSetup"];} } ::itcl::class ::qw::com::application::excel::objects::pagesetup { inherit ::qw::com::collectionitem; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::eval configure $args; ::return $this; } destructor { } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner handle_Get] "PageSetup"]; } chain; ::return $this; } public method settingsget {} { ::set Result ""; ::lappend Result "blackandwhite"; ::lappend Result [blackandwhite]; ::lappend Result "bottommargin"; ::lappend Result [bottommargin]; ::lappend Result "centerfooter"; ::lappend Result [centerfooter]; ::lappend Result "centerheader"; ::lappend Result [centerheader]; ::lappend Result "centerhorizontally"; ::lappend Result [centerhorizontally]; ::lappend Result "centervertically"; ::lappend Result [centervertically]; ::lappend Result "draft"; ::lappend Result [draft]; ::lappend Result "firstpagenumber"; ::lappend Result [firstpagenumber]; ::lappend Result "fittopagestall"; ::lappend Result [fittopagestall]; ::lappend Result "fittopageswide"; ::lappend Result [fittopageswide]; ::lappend Result "footermargin"; ::lappend Result [footermargin]; ::lappend Result "headermargin"; ::lappend Result [headermargin]; ::lappend Result "leftfooter"; ::lappend Result [leftfooter]; ::lappend Result "leftheader"; ::lappend Result [leftheader]; ::lappend Result "leftmargin"; ::lappend Result [leftmargin]; ::lappend Result "order"; ::lappend Result [order]; ::lappend Result "orientation"; ::lappend Result [orientation]; ::lappend Result "papersize"; ::lappend Result [papersize]; ::lappend Result "printarea"; ::lappend Result [printarea]; ::lappend Result "printcomments"; ::lappend Result [printcomments]; ::lappend Result "printgridlines"; ::lappend Result [printgridlines]; ::lappend Result "printheadings"; ::lappend Result [printheadings]; ::lappend Result "printnotes"; ::lappend Result [printnotes]; ::lappend Result "printtitlecolumns"; ::lappend Result [printtitlecolumns]; ::lappend Result "printtitlerows"; ::lappend Result [printtitlerows]; ::lappend Result "rightfooter"; ::lappend Result [rightfooter]; ::lappend Result "rightheader"; ::lappend Result [rightheader]; ::lappend Result "rightmargin"; ::lappend Result [rightmargin]; ::lappend Result "topmargin"; ::lappend Result [topmargin]; ::lappend Result "zoom"; ::lappend Result [zoom]; ::return $Result; } public method settingsset {args} { ::foreach {Name Value} $args { ::if {[::eval $Name] ne $Value} { $Name $Value; } } ::return $this; } method marginset {Side Src} { ::set Side [::string totitle $Side]; handle_property "${Side}Margin" $Src; ::return $this; } method marginget {Side} { ::set Side [::string totitle $Side]; ::return [handle_property "${Side}Margin"]; } public method topmargin {{Src {get}}} { ::if {$Src eq "get"} {::return [marginget "Top"];} marginset "Top" $Src; ::return $this; } public method bottommargin {{Src {get}}} { ::if {$Src eq "get"} {::return [marginget "Bottom"];} marginset "Bottom" $Src; ::return $this; } public method leftmargin {{Src {get}}} { ::if {$Src eq "get"} {::return [marginget "Left"];} marginset "Left" $Src; ::return $this; } public method rightmargin {{Src {get}}} { ::if {$Src eq "get"} {::return [marginget "Right"];} marginset "Right" $Src; ::return $this; } public method blackandwhite {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "BlackAndWhite"]; } handle_property "BlackAndWhite" $Src; ::return $this; } public method centerfooter {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "CenterFooter"]; } handle_property "CenterFooter" $Src; ::return $this; } public method centerheader {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "CenterHeader"]; } handle_property "CenterHeader" $Src; ::return $this; } public method centerhorizontally {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "CenterHorizontally"]; } handle_property "CenterHorizontally" $Src; ::return $this; } public method centervertically {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "CenterVertically"]; } handle_property "CenterVertically" $Src; ::return $this; } public method chartsize {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "ChartSize"]; } handle_property "ChartSize" $Src; ::return $this; } public method creator {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "Creator"]; } handle_property "Creator" $Src; ::return $this; } public method draft {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "Draft"]; } handle_property "Draft" $Src; ::return $this; } public method firstpagenumber {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "FirstPageNumber"]; } handle_property "FirstPageNumber" $Src; ::return $this; } public method fittopagestall {{Src {get}}} { ::if {$Src eq "get"} { ::set Result [handle_property "FitToPagesTall"]; ::if {$Result eq ""||$Result eq "0"} {::set Result "1";} ::return $Result } handle_property_number "FitToPagesTall" $Src; ::return $this; } public method fittopageswide {{Src {get}}} { ::if {$Src eq "get"} { ::set Result [[handle_Get] "FitToPagesWide"]; ::if {$Result eq ""||$Result eq "0"} {::set Result "1";} ::return $Result } handle_property_number "FitToPagesWide" $Src; ::return $this; } public method footermargin {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "FooterMargin"]; } [handle_Get] "FooterMargin" $Src; ::return $this; } public method headermargin {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "HeaderMargin"]; } [handle_Get] "HeaderMargin" $Src; ::return $this; } public method leftfooter {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "LeftFooter"]; } [handle_Get] "LeftFooter" $Src; ::return $this; } public method leftheader {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "LeftHeader"]; } [handle_Get] "LeftHeader" $Src; ::return $this; } public method order {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "Order"]; } [handle_Get] "Order" $Src; ::return $this; } public method orientation {{Src {get}}} { ::if {$Src eq "get"} { ::set Result [[handle_Get] "Orientation"]; ::return [::qw::excel::translate_number_to_pagesetupOrientation $Result]; } [handle_Get] "Orientation" [::qw::excel::translate_pagesetupOrientation_to_number $Src]; ::return $this; } public method papersize {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "PaperSize"]; } [handle_Get] "PaperSize" $Src; ::return $this; } public method printarea {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "PrintArea"]; } [handle_Get] "PrintArea" $Src; ::return $this; } public method printcomments {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "PrintComments"]; } [handle_Get] "PrintComments" $Src; ::return $this; } public method printgridlines {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "PrintGridlines"]; } [handle_Get] "PrintGridlines" $Src; ::return $this; } public method printheadings {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "PrintHeadings"]; } [handle_Get] "PrintHeadings" $Src; ::return $this; } public method printnotes {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "PrintNotes"]; } [handle_Get] "PrintNotes" $Src; ::return $this; } public method printquality {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "PrintQuality"]; } [handle_Get] "PrintQuality" $Src; ::return $this; } public method printtitlecolumns {{Src {get}}} { ::if {$Src eq "get"} { ::set ExcelResult [[handle_Get] "PrintTitleColumns"]; ::if {$ExcelResult eq ""} {::return "";} ::if {![::regexp {^(\$)([A-Z]*)(:)(\$)([A-Z]*)$} $ExcelResult Match D1 StartColumn Colon D2 EndColumn]} {::return "";} ::set StartColumn [::qw::excel::alphaToNumber $StartColumn]; ::set EndColumn [::qw::excel::alphaToNumber $EndColumn]; ::incr StartColumn -1; ::incr EndColumn -1; ::return [::sargs ".start" $StartColumn ".end" $EndColumn]; } ::if {$Src eq ""} {::return $this;} ::set StartColumn [::sargs::get $Src ".start"]; ::set EndColumn [::sargs::get $Src ".end"]; ::incr StartColumn; ::incr EndColumn; ::set StartColumn [::qw::excel::numberToAlpha $StartColumn]; ::set EndColumn [::qw::excel::numberToAlpha $EndColumn]; [handle_Get] "PrintTitleColumns" "\$$StartColumn:\$$EndColumn"; ::return $this; } public method printtitlerows {{Src {get}}} { ::if {$Src eq "get"} { ::set ExcelResult [[handle_Get] "PrintTitleRows"]; ::if {$ExcelResult eq ""} { ::return ""; } ::if {![::regexp {^(\$)([0-9]*)(:)(\$)([0-9]*)$} $ExcelResult Match D1 StartRow Colon D2 EndRow]} { ::return ".start -1 .end -1"; } ::incr StartRow -1; ::incr EndRow -1; ::return [::sargs ".start" $StartRow ".end" $EndRow]; } ::if {$Src eq ""} { ::return $this; } ::set StartRow [::sargs::get $Src ".start"]; ::set EndRow [::sargs::get $Src ".end"]; ::incr StartRow; ::incr EndRow; [handle_Get] "PrintTitleRows" "\$$StartRow:\$$EndRow"; ::return $this; } public method rightfooter {{Src {get}}} { ::if {$Src eq "get"} { ::return [[handle_Get] "RightFooter"]; } [handle_Get] "RightFooter" $Src; ::return $this; } public method rightheader {{Src {get}}} { ::if {$Src eq "get"} { ::return [handle_property "RightHeader"]; } handle_property "RightHeader" $Src; ::return $this; } public method scaling {{Src {get}}} { ::if {$Src eq "get"} {::return [zoom];} ::return [zoom $Src]; } public method zoom {{Src {get}}} { ::if {$Src eq "get"} {::return [handle_property "Zoom"];} ::if {!$Src} { handle_property_bool "Zoom" $Src; } else { handle_property_number "Zoom" $Src; } ::return $this; } } ::itcl::class ::qw::com::application::internetexplorer { inherit ::qw::com::application; public variable callback ""; constructor {args} { ::eval ::qw::com::application::constructor $args; } { ::eval configure $args; ::set _program_identifier "InternetExplorer.Application"; ::set peer_name_configurable 0; ::return $this; } destructor { } public method init {} { chain; } public method currenturl {} { ::return [handle_command "LocationURL"]; } public method currenturlname {} { ::return [handle_command "LocationName"]; } public method goback {Src} { handle_command "GoBack"; } public method goforward {Src} { handle_command "GoForward"; } public method url {Src} { handle_command "Navigate" $Src; ::set Name [currenturlname]; ::if {[::string range $Name 0 5] eq "ERROR:"} { ::qw::throw "Error opening $Src: $Name"; } ::return $this; } } ::itcl::class ::qw::com::application::access { inherit ::qw::com::application; constructor {args} { ::eval ::qw::com::application::constructor $args; } { ::eval configure $args; ::set _program_identifier "Access.Application"; ::set _program_name "Microsoft Access"; set peer_name_configurable 0; ::return $this; } destructor { } public method init {} { chain; } } ::itcl::class ::qw::com::application::pdfcreator { inherit ::qw::com::application; public variable _pdfcreator ""; public variable _pdfcreator_is_running 0; constructor {args} { ::eval ::qw::com::application::constructor $args; } { ::eval configure $args; ::set _program_identifier "PDFCreator.Application"; ::set _program_name "PDFCreator"; set peer_name_configurable 0; ::return $this; } destructor { } public method init {} { chain; ::qw::try { ::tcom::ref getactiveobject "PDFCreator.Application"; ::set _pdfcreator_is_running 1; } catch Exception { ::set _pdfcreator_is_running 0; } ::if {$_pdfcreator eq ""} { ::qw::try { ::set _pdfcreator [[::qw::get_com_applications] factory -application "PDFCreator"]; } catch Exception { ::set _pdfcreator ""; ::qw::throw $Exception; } } else { $_pdfcreator activate; } ::foreach Whatever [::lsort -dictionary -index 0 [[::tcom::info interface $_handle] properties]] {::puts "properties==$Whatever";} ::foreach Whatever [::lsort -dictionary -index 0 [[::tcom::info interface $_handle] methods]] {::puts "methods==$Whatever";} } } ::itcl::class ::qw::com::application::word { inherit ::qw::com::application; protected variable _documents ""; public variable callback ""; constructor {args} { ::eval ::qw::com::application::constructor $args; } { ::eval configure $args; ::set _program_identifier "Word.Application"; ::set _program_name "Microsoft Word"; set peer_name_configurable 0; ::set _documents [::qw::com::application::word::objects::documents ::qw::com::application::word::objects::documents::#auto]; $_documents owner_Set $this; ::return $this; } destructor { ::itcl::delete object $_documents; } public method init {} { chain; ::if {$filename ne ""} { $_documents kids_create_from_collection; ::set filename_handle [$_documents find_item $filename_handle]; ::if {$filename_handle eq ""} { ::qw::throw "Could not find document handle for $filename"; } } } public method Documents {} { ::return [handle_property "Documents"]; } public method documents {} { ::return $_documents; } public method version_Get {} { ::return [handle_command "Version"]; } public method language_version {} { ::return "EnglishUS"; ::set LanguageCode [handle_property "Language"]; ::switch -- [::expr int($LanguageCode)] { "1078" {::return "Afrikaans";} "1052" {::return "Albanian";} "1118" {::return "Amharic";} "1025" {::return "Arabic";} "5121" {::return "ArabicAlgeria";} "15361" {::return "ArabicBahrain";} "3073" {::return "ArabicEgypt";} "2049" {::return "ArabicIraq";} "11265" {::return "ArabicJordan";} "13313" {::return "ArabicKuwait";} "12289" {::return "ArabicLebanon";} "4097" {::return "ArabicLibya";} "6145" {::return "ArabicMorocco";} "8193" {::return "ArabicOman";} "16385" {::return "ArabicQatar";} "10241" {::return "ArabicSyria";} "7169" {::return "ArabicTunisia";} "14337" {::return "ArabicUAE";} "9217" {::return "ArabicYemen";} "1067" {::return "Armenian";} "1101" {::return "Assamese";} "2092" {::return "AzeriCyrillic";} "1068" {::return "AzeriLatin";} "1069" {::return "Basque";} "2067" {::return "BelgianDutch";} "2060" {::return "BelgianFrench";} "1093" {::return "Bengali";} "4122" {::return "Bosnian";} "1046" {::return "BrazilianPortuguese";} "1026" {::return "Bulgarian";} "1109" {::return "Burmese";} "1059" {::return "Byelorussian";} "1027" {::return "Catalan";} "1116" {::return "Cherokee";} "3076" {::return "ChineseHongKongSAR";} "5124" {::return "ChineseMacaoSAR";} "4100" {::return "ChineseSingapore";} "1050" {::return "Croatian";} "1029" {::return "Czech";} "1030" {::return "Danish";} "1125" {::return "Divehi";} "1043" {::return "Dutch";} "2129" {::return "DzongkhaBhutan";} "1126" {::return "Edo";} "3081" {::return "EnglishAUS";} "10249" {::return "EnglishBelize";} "4105" {::return "EnglishCanadian";} "9225" {::return "EnglishCaribbean";} "14345" {::return "EnglishIndonesia";} "6153" {::return "EnglishIreland";} "8201" {::return "EnglishJamaica";} "5129" {::return "EnglishNewZealand";} "13321" {::return "EnglishPhilippines";} "7177" {::return "EnglishSouthAfrica";} "11273" {::return "EnglishTrinidadTobago";} "2057" {::return "EnglishUK";} "1033" {::return "EnglishUS";} "12297" {::return "EnglishZimbabwe";} "1061" {::return "Estonian";} "1080" {::return "Faeroese";} "1065" {::return "Farsi";} "1124" {::return "Filipino";} "1035" {::return "Finnish";} "1036" {::return "French";} "11276" {::return "FrenchCameroon";} "3084" {::return "FrenchCanadian";} "12300" {::return "FrenchCotedIvoire";} "15372" {::return "FrenchHaiti";} "5132" {::return "FrenchLuxembourg";} "13324" {::return "FrenchMali";} "6156" {::return "FrenchMonaco";} "14348" {::return "FrenchMorocco";} "8204" {::return "FrenchReunion";} "10252" {::return "FrenchSenegal";} "7180" {::return "FrenchWestIndies";} "9228" {::return "FrenchZaire";} "1122" {::return "FrisianNetherlands";} "1127" {::return "Fulfulde";} "2108" {::return "GaelicIreland";} "1084" {::return "GaelicScotland";} "1110" {::return "Galician";} "1079" {::return "Georgian";} "1031" {::return "German";} "3079" {::return "GermanAustria";} "5127" {::return "GermanLiechtenstein";} "4103" {::return "GermanLuxembourg";} "1032" {::return "Greek";} "1140" {::return "Guarani";} "1095" {::return "Gujarati";} "1128" {::return "Hausa";} "1141" {::return "Hawaiian";} "1037" {::return "Hebrew";} "1081" {::return "Hindi";} "1038" {::return "Hungarian";} "1129" {::return "Ibibio";} "1039" {::return "Icelandic";} "1136" {::return "Igbo";} "1057" {::return "Indonesian";} "1117" {::return "Inuktitut";} "1040" {::return "Italian";} "1041" {::return "Japanese";} "1099" {::return "Kannada";} "1137" {::return "Kanuri";} "1120" {::return "Kashmiri";} "2144" {::return "KashmiriDevanagari";} "1087" {::return "Kazakh";} "1107" {::return "Khmer";} "1088" {::return "Kirghiz";} "1111" {::return "Konkani";} "1042" {::return "Korean";} "1088" {::return "Kyrgyz";} "1108" {::return "Lao";} "1142" {::return "Latin";} "1062" {::return "Latvian";} "1063" {::return "Lithuanian";} "1071" {::return "Macedonian";} "1100" {::return "Malayalam";} "2110" {::return "MalayBruneiDarussalam";} "1086" {::return "Malaysian";} "1082" {::return "Maltese";} "1112" {::return "Manipuri";} "1153" {::return "Maori";} "1102" {::return "Marathi";} "2058" {::return "MexicanSpanish";} "-2" {::return "Mixed";} "1104" {::return "Mongolian";} "1121" {::return "Nepali";} "0" {::return "None";} "1024" {::return "NoProofing";} "1044" {::return "NorwegianBokmol";} "2068" {::return "NorwegianNynorsk";} "1096" {::return "Oriya";} "1138" {::return "Oromo";} "1123" {::return "Pashto";} "1045" {::return "Polish";} "2070" {::return "Portuguese";} "1094" {::return "Punjabi";} "1131" {::return "QuechuaBolivia";} "2155" {::return "QuechuaEcuador";} "3179" {::return "QuechuaPeru";} "1047" {::return "RhaetoRomanic";} "1048" {::return "Romanian";} "2072" {::return "RomanianMoldova";} "1049" {::return "Russian";} "2073" {::return "RussianMoldova";} "1083" {::return "SamiLappish";} "1103" {::return "Sanskrit";} "1132" {::return "Sepedi";} "3098" {::return "SerbianCyrillic";} "2074" {::return "SerbianLatin";} "1072" {::return "Sesotho";} "2052" {::return "SimplifiedChinese";} "1113" {::return "Sindhi";} "2137" {::return "SindhiPakistan";} "1115" {::return "Sinhalese";} "1051" {::return "Slovak";} "1060" {::return "Slovenian";} "1143" {::return "Somali";} "1070" {::return "Sorbian";} "1034" {::return "Spanish";} "11274" {::return "SpanishArgentina";} "16394" {::return "SpanishBolivia";} "13322" {::return "SpanishChile";} "9226" {::return "SpanishColombia";} "5130" {::return "SpanishCostaRica";} "7178" {::return "SpanishDominicanRepublic";} "12298" {::return "SpanishEcuador";} "17418" {::return "SpanishElSalvador";} "4106" {::return "SpanishGuatemala";} "18442" {::return "SpanishHonduras";} "3082" {::return "SpanishModernSort";} "19466" {::return "SpanishNicaragua";} "6154" {::return "SpanishPanama";} "15370" {::return "SpanishParaguay";} "10250" {::return "SpanishPeru";} "20490" {::return "SpanishPuertoRico";} "14346" {::return "SpanishUruguay";} "8202" {::return "SpanishVenezuela";} "1072" {::return "Sutu";} "1089" {::return "Swahili";} "1053" {::return "Swedish";} "2077" {::return "SwedishFinland";} "4108" {::return "SwissFrench";} "2055" {::return "SwissGerman";} "2064" {::return "SwissItalian";} "1114" {::return "Syriac";} "1064" {::return "Tajik";} "1119" {::return "Tamazight";} "2143" {::return "TamazightLatin";} "1097" {::return "Tamil";} "1092" {::return "Tatar";} "1098" {::return "Telugu";} "1054" {::return "Thai";} "1105" {::return "Tibetan";} "2163" {::return "TigrignaEritrea";} "1139" {::return "TigrignaEthiopic";} "1028" {::return "TraditionalChinese";} "1073" {::return "Tsonga";} "1074" {::return "Tswana";} "1055" {::return "Turkish";} "1090" {::return "Turkmen";} "1058" {::return "Ukrainian";} "1056" {::return "Urdu";} "2115" {::return "UzbekCyrillic";} "1091" {::return "UzbekLatin";} "1075" {::return "Venda";} "1066" {::return "Vietnamese";} "1106" {::return "Welsh";} "1076" {::return "Xhosa";} "1144" {::return "Yi";} "1085" {::return "Yiddish";} "1130" {::return "Yoruba";} "1077" {::return "Zulu";} default {::return [chain];} } } public method country_version {} { ::return "n.a."; } } ::itcl::class ::qw::com::application::word::objects::documents { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { ::eval configure $args; } destructor { } public method init {} { chain; ::return $this; } method kid_class {} {::return "::qw::com::application::word::objects::document";} method kid_type {} {::return "document";} public method collection {} { ::return [handle_property "Documents"]; } public method kids_create_from_collection {} { ::for {::set i 1;} {$i<=[[collection] "Count"]} {::incr i;} { factory -item $i -createcommand [collection]; } } public method find_item {Src} { ::foreach Handle [handles] { ::set KidHandle [$Handle handle_Get]; ::if {[::tcom::ref equal $KidHandle $Src]} { ::return $Handle; } } ::return ""; } public method find_new_item {} { ::set Handles [handles]; ::for {::set i 1;} {$i<=[[collection] "Count"]} {::incr i;} { ::set ItemHandle [[collection] "Item" $i]; ::set Found 0; ::foreach Handle $Handles { ::set KidHandle [$Handle handle_Get]; ::if {[::tcom::ref equal $ItemHandle $KidHandle]} { ::set Found 1; ::break; } } ::if {$Found} {::continue;} ::return [factory -item $i -createcommand [collection]]; } ::return ""; } } ::itcl::class ::qw::com::application::word::objects::document { inherit ::qw::com::collectionitem; protected variable _mailmerge ""; protected variable _mailmerges ""; protected variable _ranges ""; public variable filename ""; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 1; ::eval configure $args; ::set _ranges [::qw::com::application::word::objects::ranges ::qw::com::application::word::objects::ranges::#auto]; $_ranges owner_Set $this; $_ranges init; ::return $this; } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner collection] "Add"]; ::if {$filename ne ""} {::lappend createcommand [::file nativename $filename];} } chain; ::return $this; } public method deinit {} { ::if {$_mailmerges ne ""} { ::if {[$_mailmerges is_being_destroyed]} {::qw::throw "$this attempted to destroy mailmerges $_mailmerges but it is already being destroyed.";} ::itcl::delete object $_mailmerges; ::set _mailmerges ""; } ::return $this; } destructor { } public method ranges {} {::return $_ranges;} public method file_save {} { handle_method "Save"; } public method mark_file_saved {} { handle_property "Saved" "1"; } public method mark_file_unsaved {} { handle_property "Saved" "0"; } public method close {} { handle_property "Close" ; } public method activate {} { handle_method "Activate"; ::return $this; } public method mailmerge {} { ::if {$_mailmerge ne ""} { ::return $_mailmerge; } ::if {$_mailmerges eq ""} { ::set _mailmerges [::qw::com::application::word::objects::mailmerges ::qw::com::application::word::objects::mailmerges::#auto]; $_mailmerges owner_Set $this; $_mailmerges init; } ::set _mailmerge [$_mailmerges factory]; ::return $_mailmerge; } public method contents {} { ::return [[handle_method "Content"] "Text"]; } public method merge_fields {} { ::set Result ""; ::set Contents [::string map "\xc2 {}" [contents]]; ::while {[::regexp (\xab)(\[0-9a-zA-Z_\]*)(\xbb) $Contents match Char1 FieldName Char2]} { ::set Contents [::regsub -all $match $Contents ""]; ::lappend Result $FieldName; } ::return $Result; } public method create_pdf_file {s_args} { ::set Application [[owner_Get] owner_Get]; ::if {[$Application version_Get] >= 12.0} { ::set Filename [::file nativename [::sargs::get $s_args .filename]]; ::set SecStart [::sargs::get $s_args ".section_start"]; ::set SecEnd [::sargs::get $s_args ".section_end"]; ::if {$SecStart eq "" || $SecEnd eq ""} { [handle_Get] ExportAsFixedFormat $Filename 17; } else { ::set ThisRange [[[[handle_Get] Sections] Item $SecStart] Range]; ::set StartIndex [$ThisRange Start]; ::set EndIndex [::expr {[$ThisRange End] - 1}]; ::set NewRange [[handle_Get] Range $StartIndex $EndIndex]; $NewRange ExportAsFixedFormat $Filename 17; } ::return [::sargs::get $s_args .filename]; } ::if {![$::nv2::print::printers exists "PDFCreator"]} { ::qw::throw [::sargs \ .text "Cannot produce a PDF file, the PDF Creator printer has not been installed." \ .help_id 271820091119115102 \ ]; } ::set Application [[owner_Get] owner_Get]; ::set PdfPrinter [[$::nv2::print::printers item "PDFCreator"] excelname]; ::set ActivePrinter [$Application active_printer_Get]; ::if {$ActivePrinter ne $PdfPrinter} { $Application active_printer_Set $PdfPrinter; } ::set Args ""; ::switch -- [::sargs::get $s_args ".range"] { "all" { ::set Args [::list Range 1]; } "current_page" { ::set Args [::list Range 2]; } "from_to" { ::set Args [::list Range 3]; ::lappend Args "From"; ::lappend Args [::sargs::get $s_args ".page_start"]; ::lappend Args "To"; ::lappend Args [::sargs::get $s_args ".page_end"]; } "range" { ::set Args [::list Range 4 Pages]; ::set PageStart [::sargs::get $s_args ".page_start"]; ::set PageEnd [::sargs::get $s_args ".page_end"]; ::set SectionStart [::sargs::get $s_args ".section_start"]; ::set SectionEnd [::sargs::get $s_args ".section_end"]; ::set Start ""; ::set End ""; ::if {$PageStart ne ""} {::append Start "p$PageStart";} ::if {$PageEnd ne ""} {::append End "p$PageEnd";} ::if {$SectionStart ne ""} {::append Start "s$SectionStart";} ::if {$SectionEnd ne ""} {::append End "s$SectionEnd";} ::lappend Args $Start-$End; } "selection" { ::set Args [::list Range 5]; } } ::if {$Args eq ""} { ::set PrintCommand "$_handle PrintOut"; } else { ::if {1} { ::set PrintCommand "$_handle -namedarg PrintOut $Args"; } else { ::set PrintCommand "$_handle -namedarg PrintOut Background "; ::append PrintCommand {[::tcom::na] }; ::append PrintCommand "$Args"; } } ::sargs::var::set s_args ".print_command" $PrintCommand; ::qw::try { ::set PdfFile [$Application create_pdf_file $s_args]; } catch Exception { ::if {$ActivePrinter ne $PdfPrinter} { $Application active_printer_Set $ActivePrinter; } ::qw::throw $Exception; } ::if {$ActivePrinter ne $PdfPrinter} { $Application active_printer_Set $ActivePrinter; } ::return $PdfFile; } public method print {} { handle_property "PrintOut"; ::return $this; } } ::itcl::class ::qw::com::application::word::objects::mailmerges { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { ::eval configure $args; } destructor { } public method init {} { chain; ::return $this; } method kid_class {} {::return "::qw::com::application::word::objects::mailmerge";} method kid_type {} {::return "mailmerge";} public method collection {} { ::return [handle_property "MailMerge"]; } } ::itcl::class ::qw::com::application::word::objects::mailmerge { inherit ::qw::com::collectionitem; public variable datasource "" {configure_datasource $datasource} public variable destination "0" {configure_destination $destination} constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { set peer_name_configurable 0; ::eval configure $args; ::return $this; } destructor { } public method init {} { ::if {$createcommand eq ""} { ::set createcommand [::list [$_owner handle_Get] "MailMerge"]; } chain; ::return $this; } public method configure_datasource {Src} { ::if {$Src eq ""} {::return;} ::set datasource [::file nativename $datasource]; } public method configure_destination {Src} { ::if {$Src ne ""} { ::switch -- $Src { "document" {::set destination 0;} "printer" {::set destination 1;} "email" {::set destination 2;} default {::qw::throw "Invalid destination \"$destination\", -destination must be \"document\", \"printer\", or \"email\".";} } } } public method merge {} { ::if {$datasource eq ""} { ::qw::throw "Cannot merge, -datasource has not been configured."; } handle_command "OpenDataSource" $datasource; handle_command "Execute"; ::set MailMerges $_owner; ;#// The mailmerges collection; ::set Document [$MailMerges owner_Get]; ::set Documents [$Document owner_Get]; ::set NewDocument [$Documents find_new_item]; $Document mark_file_saved; ::if {$NewDocument ne ""} { $NewDocument mark_file_saved; ::return $NewDocument; } ::return $Document; } public method close {} { handle_property "Close" ; } } ::itcl::class ::qw::com::application::word::objects::ranges { inherit ::qw::com::collection; constructor {args} { ::eval ::qw::com::collection::constructor $args; } { } destructor { } method kid_class {} {::return "::qw::com::application::word::objects::range";} method kid_type {} {::return "range";} } ::itcl::class ::qw::com::application::word::objects::range { inherit ::qw::com::collectionitem; protected variable _position_start 0; protected variable _position_end 0; protected variable _cells_handle ""; protected variable _parent_handle ""; protected variable _clipboard_contents ""; protected variable _borders ""; protected variable _border_settings ""; constructor {args} { ::eval ::qw::com::collectionitem::constructor $args; } { ::set peer_name_configurable 0; ::eval configure $args; ::return $this; } public method init {} { ::if {$createcommand eq ""} { ::if {$::qw::com::package eq "optcl"} { ::set createcommand [::list [$_owner handle_Get] ":" "Range"]; } else { ::set createcommand [::list [$_owner handle_Get] "Range"]; } } chain; ::return $this; } destructor { deinit; } public method deinit {} { ::return $this; } private method reset {} { ::set createcommand ""; init; ::return $this; } public method range_value_Set {Position Src} { position_Set $Position; handle_property "InsertBefore" $Src; ::return $this; } public method position_Set {Src} { ::set _position_start [::sargs::get $Src ".start"]; ::set _position_end [::sargs::get $Src ".end"]; handle_property "Start" $_position_start; handle_property "End" $_position_end; ::return $this; } public method validateRectangle {Src} { ::foreach Item {.position.x .position.y .size.x .size.y} { ::if {![::sargs::exists $Src $Item]} { ::qw::bug "20031109092513" "Src rectangle \"$Src\" is invalid"; } } ::return $Src; } public method rectangle_Set {Src} { ::set _rectangle [validateRectangle $Src]; reset; ::return $this; } public method rectangle_Get {} { ::return [validateRectangle $_rectangle]; } public method owner_set_rectangle {Src} { ::set _rectangle [validateRectangle $Src]; ::return $this; } public method Columns {} { ::return [handle_command "Columns"]; } public method activate {} { [$_owner handle_Get] "Activate"; handle_command "Activate"; ::return $this; } public method select {} { handle_command "Select"; ::return $this; } public method clipboardSave {} { ::set _clipboard_contents ""; ::clipboard append ""; ::set _clipboard_contents [::clipboard get]; ::clipboard clear; ::return $this; } public method clipboardRestore {} { ::clipboard clear; ::clipboard append $_clipboard_contents; ::set _clipboard_contents ""; ::return $this; } public method copy {} { makeReady; clipboardSave; handle_command "Copy"; ::return $this; } public method paste {} { makeReady; [parentHandle] "Paste"; clipboardRestore; ::return $this; } public method value_filter_list {Src} { ::set Result ""; ::foreach Value [::split $Src \t] { ::lappend Result [::qw::excel::value_filter $Value]; } ::return [::join $Result \t]; } public method value_Set {Src} { handle_property "InsertBefore" $Src; ::return $this; clipboardSave; ::clipboard clear; ::clipboard append [value_filter_list $Src]; activate; ::update; paste; clipboardRestore; ::clipboard clear; ::return $this; } public method value_Get {{Src {get}}} { ::return [get]; } public method get {} { copy; ::set Data [::split [::clipboard get] \n]; clipboardRestore; ::set Result ""; ::for {::set i 0} {$i<[height_Get]} {::incr i;} { ::set RowResult ""; ::for {::set j 0} {$j<[width_Get]} {::incr j;} { ::lappend RowResult [::lindex [::lindex $Data $i] $j]; } ::lappend Result $RowResult; } ::return $Result; } public method alignment_horizontal_Set {Src} { ::if {$::qw::com::package eq "optcl"} { [handle_Get] ":" "HorizontalAlignment" [::qw::excel::translate_alignment_to_number $Src]; } else { [handle_Get] "HorizontalAlignment" [::expr [::qw::excel::translate_alignment_to_number $Src]]; } ::return $this; } public method alignment_horizontal_Get {} { ::return [::qw::excel::translate_number_to_alignment [handle_property "HorizontalAlignment"]]; } public method properties {} { ::set Result ""; ::lappend Result "rectangle";::lappend Result [rectangle_Get]; ::set Merged [merged]; ::lappend Result "-merged";::lappend Result $Merged; ::if {$Merged} { ::set MergeRange [mergeRange]; ::set Size [sizePoints $MergeRange]; } else { ::set MergeRange ""; ::set Size [sizePoints [rectangle_Get]]; } ::lappend Result "-mergerange"; ::lappend Result $MergeRange; ::lappend Result "-size"; ::lappend Result $Size; ::array set FontArray {}; ::set Font [handle_property "Font"]; ::if {$::qw::com::package eq "optcl"} { ::set FontArray(-family) [$Font ":" "Name"]; ::set FontArray(-size) [::expr int([$Font ":" "Size"])]; ::set Style [::string toupper [$Font ":" "FontStyle"]]; ::set Underline [$Font ":" "Underline"]; } else { ::set FontArray(-family) [$Font "Name"]; ::set FontArray(-size) [::expr int([$Font "Size"])]; ::set Style [::string toupper [$Font "FontStyle"]]; ::set Underline [$Font "Underline"]; } ::set FontArray(-weight) "normal"; ::set FontArray(-slant) "roman"; ::if {[::string first "BOLD" $Style]>=0} {::set FontArray(-weight) "bold";} ::if {[::string first "ITALIC" $Style]>=0} {::set FontArray(-slant) "italic";} ::set FontArray(-underline) [::qw::excel::translate_number_to_underline $Underline]; ::lappend Result "-font";::lappend Result [::array get FontArray]; ::return $Result; } } ::namespace eval ::qw {} ::namespace eval ::qw::excel { ::proc qw_date_format_to_excel_format {Src} { ::set TclFormat $::qw::date::formats($Src); ::set Result [::string map {%a ddd %A dddd %b mmm %B mmmm %d dd %D mm/dd/yy %e d %h mmm %H hh %I hh %k h %l h %m mm %M mm %p AM %R hh:mm %S ss %T hh:mm:ss %y yy %Y yyyy} $TclFormat]; ::return $Result; } ::proc translate_format_to_excel_format_accounting {args} { } ::proc translate_excel_format_accounting_to_format {Src} { } ::proc qw_number_format_to_excel_format {Src} { ::if {![::info exists ::qw::number::formats($Src)]} {::qw::throw "qw_number_format_to_excel_format called for unknown format \"$Src\"";} ::set QWFormat $::qw::number::formats($Src); ::switch $Src { "none" {::return "general;-general;0";} "none_minus_trailing" {::return "general;general-;0";} "none_minus_parentheses" {::return "general;(general);0";} } ::set Result ""; ::set Parenthesis 0; ::set DashPosition trailing; ::if {[::string trim [::sargs::get_poly $QWFormat /negative.left.text]] eq "("} { ::set Parenthesis 1; } else { ::if {[::string trim [::sargs::get_poly $QWFormat /negative.left.text]] eq "-"} { ::set DashPosition leading; } } ::foreach Sign {positive negative zero} { ::set Format "0"; ::if {[::sargs::get_poly $QWFormat /$Sign.group_size]==3} { ::set Format "#,##$Format"; } ::if {[::sargs::get_poly $QWFormat /$Sign.right.minimum]!=0} { ::set Decimals [::sargs::get_poly $QWFormat /$Sign.right.maximum]; ::if {$Decimals>0} {::append Format .[::string repeat "0" $Decimals];} } ::if {$Parenthesis} { ::switch $Sign { "negative" {::set Format ($Format);} "zero" - "positive" {::set Format ${Format}_);} } } else { ::switch $Sign { "negative" { ::switch $DashPosition { "leading" {::set Format -$Format;} "trailing" {::set Format $Format-;} } } "zero" - "positive" { ::switch $DashPosition { "trailing" {::set Format ${Format}_-;} } } } } ::set Color [::sargs::get_poly $QWFormat /$Sign.color]; ::if {$Color ne ""} { ::set Format "\[[::string totitle $Color]\]$Format"; } ::lappend Result $Format; } ::return [::join $Result ";"]; } ::proc translate_excel_format_number_to_format {Src} { ::if {[::regsub -all #,## $Src "" Src]} {::set Thousands 1;} else {::set Thousands 0;}; ::if {[::regsub -all \[Red\] $Src "" Src]} {::set Red 1;} else {::set Red 0;}; ::if {[::regsub -all \[()_\] $Src "" Src]} {::set Parentheses 1;} else {::set Parentheses 0;}; ::set Decimals 0; ::while {[::regsub ^0\\.0 $Src 0\. Src]} {::incr Decimals;} ::return ".thousands $Thousands .decimals $Decimals .parentheses $Parentheses .red $Red"; } ::proc translate_underline_to_number {Src} { ::switch -exact -- $Src { "0" {::return "-4142";} "1" {::return "2";} "2" {::return "-4119";} "3" {::return "4";} "4" {::return "4142";} } ::return "-4142"; } ::proc translate_number_to_underline {Src} { ::switch -exact -- $Src { "-4142" {::return 0;} "2" {::return 1;} "-4119" {::return 2;} "4" {::return 3;} "5" {::return 4;} } ::return "0"; } ::proc translate_pagesetupOrientation_to_number {Src} { ::switch -exact -- [::string toupper $Src] { "PORTRAIT" {::return "1.0";} "LANDSCAPE" {::return "2.0";} } ::qw::bug "907020030928213904" "Unknown pagesetup orientation $Src. Value must be \"portrait\" or \"landscape\"."; } ::proc translate_number_to_pagesetupOrientation {Src} { ::switch -exact -- $Src { 1.0 {::return "Portrait";} 2.0 {::return "Landscape";} } ::qw::bug "907020030928213918" "Unknown pagesetup orientation number $Src. Value must be \"1.0\" or \"2.0\"."; } ::foreach PageSizeItem {\ {LETTER 1 {Letter 8 1/2 x 11 in}} \ {LETTERSMALL 2 {Letter Small 8 1/2 x 11 in}} \ {TABLOID 3 {Tabloid 11 x 17 in}} \ {LEDGER 4 {Ledger 17 x 11 in}} \ {LEGAL 5 {Legal 8 1/2 x 14 in}} \ {STATEMENT 6 {Statement 5 1/2 x 8 1/2 in}} \ {EXECUTIVE 7 {Executive 7 1/4 x 10 1/2 in}} \ {A3 8 {A3 297 x 420 mm}} \ {A4 9 {A4 210 x 297 mm}} \ {A4SMALL 10 {A4 Small 210 x 297 mm}} \ {A5 11 {A5 148 x 210 mm}} \ {B4 12 {B4 (JIS) 250 x 354}} \ {B5 13 {B5 (JIS) 182 x 257 mm}} \ {FOLIO 14 {Folio 8 1/2 x 13 in}} \ {QUARTO 15 {Quarto 215 x 275 mm}} \ {10X14 16 {10x14 in}} \ {11X17 17 {11x17 in}} \ {NOTE 18 {Note 8 1/2 x 11 in}} \ {ENV_9 19 {Envelope #9 3 7/8 x 8 7/8}} \ {ENV_10 20 {Envelope #10 4 1/8 x 9 1/2}} \ {ENV_11 21 {Envelope #11 4 1/2 x 10 3/8}} \ {ENV_12 22 {Envelope #12 4 \276 x 11}} \ {ENV_14 23 {Envelope #14 5 x 11 1/2}} \ {CSHEET 24 {C size sheet}} \ {DSHEET 25 {D size sheet}} \ {ESHEET 26 {E size sheet}} \ {ENV_DL 27 {Envelope DL 110 x 220mm}} \ {ENV_C5 28 {Envelope C5 162 x 229 mm}} \ {ENV_C3 29 {Envelope C3 324 x 458 mm}} \ {ENV_C4 30 {Envelope C4 229 x 324 mm}} \ {ENV_C6 31 {Envelope C6 114 x 162 mm}} \ {ENV_C65 32 {Envelope C65 114 x 229 mm}} \ {ENV_B4 33 {Envelope B4 250 x 353 mm}} \ {ENV_B5 34 {Envelope B5 176 x 250 mm}} \ {ENV_B6 35 {Envelope B6 176 x 125 mm}} \ {ENV_ITALY 36 {Envelope 110 x 230 mm}} \ {ENV_MONARCH 37 {Envelope Monarch 3.875 x 7.5 in}} \ {ENV_PERSONAL 38 {6 3/4 Envelope 3 5/8 x 6 1/2 in}} \ {FANFOLD_US 39 {US Std Fanfold 14 7/8 x 11 in}} \ {FANFOLD_STD_GERMAN 40 {German Std Fanfold 8 1/2 x 12 in}} \ {FANFOLD_LGL_GERMAN 41 {German Legal Fanfold 8 1/2 x 13 in}} \ {ISO_B4 42 {B4 (ISO) 250 x 353 mm}} \ {JAPANESE_POSTCARD 43 {Japanese Postcard 100 x 148 mm}} \ {9X11 44 {9 x 11 in}} \ {10X11 45 {10 x 11 in}} \ {15X11 46 {15 x 11 in}} \ {ENV_INVITE 47 {Envelope Invite 220 x 220 mm}} \ {RESERVED_48 48 {RESERVED--DO NOT USE}} \ {RESERVED_49 49 {RESERVED--DO NOT USE}} \ {LETTER_EXTRA 50 {Letter Extra 9 \275 x 12 in}} \ {LEGAL_EXTRA 51 {Legal Extra 9 \275 x 15 in}} \ {TABLOID_EXTRA 52 {Tabloid Extra 11.69 x 18 in}} \ {A4_EXTRA 53 {A4 Extra 9.27 x 12.69 in}} \ {LETTER_TRANSVERSE 54 {Letter Transverse 8 \275 x 11 in}} \ {A4_TRANSVERSE 55 {A4 Transverse 210 x 297 mm}} \ {LETTER_EXTRA_TRANSVERSE 56 {Letter Extra Transverse 9\275 x 12 in}} \ {A_PLUS 57 {SuperA/SuperA/A4 227 x 356 mm}} \ {B_PLUS 58 {SuperB/SuperB/A3 305 x 487 mm}} \ {LETTER_PLUS 59 {Letter Plus 8.5 x 12.69 in}} \ {A4_PLUS 60 {A4 Plus 210 x 330 mm}} \ {A5_TRANSVERSE 61 {A5 Transverse 148 x 210 mm}} \ {B5_TRANSVERSE 62 {B5 (JIS) Transverse 182 x 257 mm}} \ {A3_EXTRA 63 {A3 Extra 322 x 445 mm}} \ {A5_EXTRA 64 {A5 Extra 174 x 235 mm}} \ {B5_EXTRA 65 {B5 (ISO) Extra 201 x 276 mm}} \ {A2 66 {A2 420 x 594 mm}} \ {A3_TRANSVERSE 67 {A3 Transverse 297 x 420 mm}} \ {A3_EXTRA_TRANSVERSE 68 {A3 Extra Transverse 322 x 445 mm}} \ } { ::foreach {Name Number Description} $PageSizeItem {}; ::append Number ".0"; ::set ::qw::excel::PrinterArray($Number-name) $Name; ::set ::qw::excel::PrinterArray($Number-description) $Description; ::set ::qw::excel::PrinterArray($Name-number) $Number; } ::proc translate_pagesetupPapersize_to_number {Src} { ::if {![::info exists ::qw::excel($Src-number)]} { ::qw::throw "Unknown pagesetup papersize name \"$Src\"."; } ::return $::qw::excel($Src-number); } ::proc translate_number_to_pagesetupPapersize {Src} { ::if {![::info exists ::qw::excel($Src-name)]} { ::qw::throw "Unknown pagesetup papersize number \"$Src\"."; } ::return $::qw::excel($Src-name); } ::proc translate_pagesetupPapersize_to_description {Src} { ::if {![::info exists ::qw::excel($Src-number)]} { ::qw::throw "Unknown pagesetup papersize name \"$Src\"."; } ::return $::qw::excel($::qw::excel($Src-number)-description); } ::proc translate_number_to_pagesetupPapersize_description {Src} { ::if {![::info exists ::qw::excel($Src-description)]} { ::qw::throw "Unknown pagesetup papersize number \"$Src\"."; } ::return $::qw::excel($Src-description); } ::proc translate_text_to_windowstate {Src} { ::switch -exact -- $Src { "maximized" {::return "-4137";} "minimized" {::return "-4140";} "normal" {::return "-4143";} default {::qw::throw "Unknown windowstate \"$Src\". windowstate must be maximized, minimized, or normal";} } } ::proc translate_windowstate_to_text {Src} { ::switch -exact -- $Src { "-4137" {::return "maximized";} "-4140" {::return "minimized";} "-4143" {::return "normal";} default {::qw::throw "Unknown WindowState value \"$Src\".";} } } ::proc translate_alignment_to_number {Src} { ::switch -exact -- $Src { "top" {::return -4160;} "right" {::return -4152;} "left-indent" {::return -4131;} "justify" {::return -4130;} "center" {::return -4108;} "bottom" {::return -4107;} "general" {::return 1;} "fill" {::return 5;} "center-across-selection" {::return 7;} default {::qw::throw "Unknown alignment specifier \"$Src\", must be one of right, general, left-indent, center, fill, justify, or center-across-selection";} } } ::proc translate_number_to_alignment {Src} { ::switch -exact -- $Src { -4160 {::return "top";} -4152 {::return "right";} -4131 {::return "left-indent";} -4130 {::return "justify";} -4108 {::return "center";} -4107 {::return "bottom";} 1 {::return "general";} 5 {::return "fill";} 7 {::return "center-across-selection";} default {::qw::throw "Unknown alignment number \"$Src\", must be one of -4131, -4130, -4108, -4152, 1, 5, or 7";} } } ::proc toExcelRange {Src} { ::set Position [::sargs::get $Src ".position"]; ::set Size [::sargs::get $Src ".size"]; ::set Result [::qw::excel::toExcelCoord $Position]; ::set R [::sargs::get $Size ".y"]; ::set C [::sargs::get $Size ".x"]; ::set Point ".x [::incr C -1] .y [::incr R -1]"; ::set Point [::QW::GUI::POINT::+ $Position $Point]; ::return "$Result:[::qw::excel::toExcelCoord $Point]"; } ::proc toExcelCoord {Src} { ::set Row [::sargs::get $Src ".y"]; ::set Col [::sargs::get $Src ".x"]; ::if {$Row eq "" || $Col eq ""} {::qw::bug "20031108092321" "Invalid coord arg \"$Src\" passed to toExcelCoord method.";} ::incr Row; ::incr Col; ::return "[::qw::excel::numberToAlpha $Col]$Row"; } ::proc toExcelCoord2 {Src} { ::set Row [::sargs::get $Src ".y"]; ::set Col [::sargs::get $Src ".x"]; ::if {$Row eq "" || $Col eq ""} {::qw::bug "20031108092356" "Invalid coord arg \"$Src\" passed to toExcelCoord2 method.";} ::incr Row; ::incr Col; ::return "$Row [::qw::excel::numberToAlpha $Col]"; } ::proc fromExcelRange {Src} { ::set Position ".x 0 .y 0"; ::set Size ".x 1 .y 1"; ::set Sheet ""; ::set Src [::regsub -all {\$} $Src ""]; ::if {[::llength [::split $Src "!"]]>1} { ::set Sheet [::lindex [::split $Src "!"] 0]; ::set Src [::lrange [::split $Src "!"] 1 end]; ::set Sheet [::string trimleft [::string tolower $Sheet] "="]; } ::set Count 0; ::foreach SrcRange [::split $Src ":"] { ::set Y ""; ::set X 0; ::foreach Char [::split $SrcRange ""] { ::if {[::regexp \[A-Z\] $Char]} { ::set X [::expr $X*26]; ::binary scan $Char c Value; ::incr X [::expr $Value-64]; ::continue; } ::if {[::regexp \[0-9\] $Char]} { ::append Y $Char; ::continue; } ::qw::throw "Invalid character \"$Char\" in range spec \"$SrcRange\""; } ::incr X -1; ::incr Y -1; ::set Point ".x $X .y $Y"; ::if {!$Count} { ::set Position $Point; } else { ::set Point [::QW::GUI::POINT::+ $Point ".x 1 .y 1"]; ::set Point [::QW::GUI::POINT::- $Point $Position]; ::set Size $Point; } ::incr Count; } ::if {$Count>2} { ::qw::throw "Excel range \"$Src\" contains more than two coordinates."; } ::set Result ""; ::set Result [::sargs::set $Result ".position" $Position]; ::set Result [::sargs::set $Result ".size" $Size]; ::return $Result; } ::proc alphaToNumber {Src} { ::set Result 0; ::foreach Char [::split [::string toupper $Src] ""] { ::if {[::regexp \[A-Z\] $Char]} { ::set Result [::expr $Result*26]; ::binary scan $Char c Value; ::incr Result [::expr $Value-64]; ::continue; } ::qw::throw "Invalid character \"$Char\" in alphaToNumber Src \"$Src\""; } ::return $Result; } ::proc numberToAlpha {Src} { ::if {$Src<=26} {::return [::lindex {{} A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} $Src];} ::set Result ""; ::while {$Src} { ::set Remainder [::expr $Src%26]; ::if {$Remainder} { ::set Char [::format %c [::expr $Remainder+64]]; } else { ::set Char "Z"; ::set Remainder 26; } ::set Result $Char$Result; ::set Src [::expr ($Src-$Remainder)/26]; } ::return $Result; } ::proc ccyymmdd_to_excel_date {Src} { ::qw::try { ::set Src [::qw::date::check $Src]; } catch Exception { ::return $Src; } ::return [::qw::date::format $Src $::qw::date::formats(month dd, yyyy)]; } ::proc value_filter_test {Src} { ::set Result [::qw::excel::value_filter_doit $Src]; ::return $Result; } ::proc value_filter {Src} { ::if {$Src eq ""} {::return $Src;} ::if {[::regexp {^[0-9\.-]*$} $Src]} { ::if {[::string is integer $Src]} {::return $Src;} ::if {[::string is double $Src]} {::return $Src;} ::return "'$Src"; } ::if {![::regexp {^[=@\-+\(]} $Src]} {::return $Src;} #//) ::if {[::regexp {^([0-9])([0-9])(/)([0-9])([0-9])(/)([0-9])([0-9])([0-9])([0-9])$} $Src]} {::return $Src;} ::if {[::regexp {^([0-9])([0-9])([0-9])([0-9])(-)([0-1])([0-9])(-)([0-3])([0-9])$} $Src]} {::return $Src;} ::set Number [::string map {, {}} $Src]; ::if {[::regexp {^(-?)([0-9]*)(\.?)([0-9]*)$} $Number match a b c d]} { ::if {$match eq $Number} {::return $Number;} } ::if {[::regexp {^([0-9]*)(\.?)([0-9]*)(-?)$} $Number match a b c d]} { ::if {$match eq $Number} { ::return -$a$b$c; } } ::if {[::regexp {^(\()([0-9]*)(\.?)([0-9]*)(\))$} $Number match a b c d e]} { ::if {$match eq $Number} { ::return -$b$c$d; } } ::if {[::regexp {^[=@+\-0-9]} $Src]} { ::return '$Src; } ::return $Src; } } ::namespace eval ::nv2 {}; ::namespace eval ::nv2::com {}; ::namespace eval ::nv2::com::applications {}; ::set ::nv2::com::applications [::qw::com::applications ::qw::com::applications::#auto]; ::proc ::qw::get_com_applications {} { ::return $::nv2::com::applications; }