rods 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +6 -3
- data/Rakefile +1 -1
- data/lib/rods.rb +67 -4
- data/rods.gemspec +2 -2
- metadata +4 -4
data/README
CHANGED
@@ -14,7 +14,11 @@
|
|
14
14
|
Licensed under the same terms as Ruby. No warranty is provided.
|
15
15
|
|
16
16
|
= Changelog
|
17
|
-
* 0.
|
17
|
+
* 0.6.1
|
18
|
+
* added new functions
|
19
|
+
* insertTableBefore()
|
20
|
+
* insertTableAfter()
|
21
|
+
* 0.6.0
|
18
22
|
* changed interface from
|
19
23
|
* getNextRow, getPreviousRow, getNextCell, getPreviousCell to
|
20
24
|
* getNextExistentRow, getPreviousExistentRow, getNextExistentCell, getPreviousExistentCell
|
@@ -298,7 +302,7 @@
|
|
298
302
|
This difference hardly matters while dealing with small documents, but degrades performance significantly when you
|
299
303
|
move up or down a sheet with a lot of rows and process several cells on the same row !
|
300
304
|
|
301
|
-
Provided you just want to read exisiting cells (
|
305
|
+
Provided you just want to read exisiting cells (cf. explanation above), the following is a real speed-buster.
|
302
306
|
|
303
307
|
# coding: UTF-8
|
304
308
|
#
|
@@ -320,7 +324,6 @@
|
|
320
324
|
# allow the XML-Parser to just continue from the "adjacent" node and
|
321
325
|
# return the previsous/next element without having to start from the top-node
|
322
326
|
# of the document over and over again !
|
323
|
-
#
|
324
327
|
#---------------------------------------------------------------------------------
|
325
328
|
while(row=mySheet.getNextExistentRow(row))
|
326
329
|
i+=1
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('rods', '0.6.
|
5
|
+
Echoe.new('rods', '0.6.1') do |p|
|
6
6
|
p.description = "OpenOffice.org oocalc: Fast automated batch-processing of spreadsheets (*.ods) conforming to Open Document Format v1.1. used by e.g. OpenOffice.org and LibreOffice. Please see screenshot and Rdoc-Documentation at http://ruby.homelinux.com/ruby/rods/. You can contact me at rodsdotrubyatonlinedotde (and drop me a line, if you like it ;-)"
|
7
7
|
p.summary = "Automation of OpenOffice/LibreOffice by batch-processing of spreadsheets conforming to Open Document v1.1"
|
8
8
|
p.url = "http://ruby.homelinux.com/ruby/rods/"
|
data/lib/rods.rb
CHANGED
@@ -73,6 +73,8 @@ class Rods
|
|
73
73
|
DUMMY="dummy"
|
74
74
|
WIDTH="width"
|
75
75
|
NODE="node"
|
76
|
+
BEFORE="before"
|
77
|
+
AFTER="after"
|
76
78
|
WIDTHEXCEEDED="exceeded"
|
77
79
|
##########################################################################
|
78
80
|
# Convenience-function to switch the default-style for the display of
|
@@ -468,6 +470,69 @@ class Rods
|
|
468
470
|
tell("setCurrentTable: setting #{tableName} as current table")
|
469
471
|
end
|
470
472
|
##########################################################################
|
473
|
+
# Inserts a table of the given name before the given spreadsheet and updates
|
474
|
+
# the internal table-administration.
|
475
|
+
# mySheet.insertTableBefore("table2","table1")
|
476
|
+
#-------------------------------------------------------------------------
|
477
|
+
def insertTableBefore(relativeTableName,tableName)
|
478
|
+
insertTableBeforeAfter(relativeTableName,tableName,BEFORE)
|
479
|
+
end
|
480
|
+
##########################################################################
|
481
|
+
# Inserts a table of the given name after the given spreadsheet and updates
|
482
|
+
# the internal table-administration.
|
483
|
+
# mySheet.insertTableAfter("table1","table2")
|
484
|
+
#-------------------------------------------------------------------------
|
485
|
+
def insertTableAfter(relativeTableName,tableName)
|
486
|
+
insertTableBeforeAfter(relativeTableName,tableName,AFTER)
|
487
|
+
end
|
488
|
+
##########################################################################
|
489
|
+
# Internal: Inserts a table of the given name before or after the given spreadsheet and updates
|
490
|
+
# the internal table-administration.
|
491
|
+
# mySheet.insertTableBeforeAfter("table1","table2",BEFORE)
|
492
|
+
#-------------------------------------------------------------------------
|
493
|
+
def insertTableBeforeAfter(relativeTableName,tableName,position="after")
|
494
|
+
die("insertTableAfter: table '#{relativeTableName}' does not exist") unless (@tables.has_key?(relativeTableName))
|
495
|
+
die("insertTableAfter: table '#{tableName}' already exists") if (@tables.has_key?(tableName))
|
496
|
+
#-----------------------------------------
|
497
|
+
# alte Tabelle ermitteln
|
498
|
+
#-----------------------------------------
|
499
|
+
@spreadSheet.elements["table:table"].each{ |element|
|
500
|
+
puts("Name: #{element.attributes['table:name']}")
|
501
|
+
}
|
502
|
+
relativeTable=@spreadSheet.elements["*[@table:name = '#{relativeTableName}']"]
|
503
|
+
die("insertTableAfter: internal error: Could not locate existing table #{relativeTableName}") unless (relativeTable)
|
504
|
+
#-----------------------------------------
|
505
|
+
# Neues Tabellenelement zunaecht per se (i.e. unverankert) erschaffen
|
506
|
+
#-----------------------------------------
|
507
|
+
newTable=REXML::Element.new("table:table")
|
508
|
+
newTable.add_attributes({"table:name" => tableName,
|
509
|
+
"table:print" => "false",
|
510
|
+
"table:style-name" => "myTable"})
|
511
|
+
#-----------------------------------------
|
512
|
+
# Unterelemente anlegen und neue Tabelle
|
513
|
+
# hinter vorherige einfuegen
|
514
|
+
#-----------------------------------------
|
515
|
+
writeXml(newTable,{TAG => "table:table-column",
|
516
|
+
"table:style" => "myColumn",
|
517
|
+
"table:default-cell-style-name" => "Default"})
|
518
|
+
writeXml(newTable,{TAG => "table:table-row",
|
519
|
+
"table:style-name" => "myRow",
|
520
|
+
CHILD => {TAG => "table:table-cell"}})
|
521
|
+
case position
|
522
|
+
when BEFORE then @spreadSheet.insert_before(relativeTable,newTable)
|
523
|
+
when AFTER then @spreadSheet.insert_after(relativeTable,newTable)
|
524
|
+
else die("insertTableBeforeAfter: invalid parameter #{position}")
|
525
|
+
end
|
526
|
+
#---------------------------------------------------------------------------
|
527
|
+
# Tabellen-Hash aktualisieren
|
528
|
+
#---------------------------------------------------------------------------
|
529
|
+
@tables[tableName]=Hash.new()
|
530
|
+
@tables[tableName][NODE]=newTable
|
531
|
+
@tables[tableName][WIDTH]=getTableWidth(newTable)
|
532
|
+
@tables[tableName][WIDTHEXCEEDED]=false
|
533
|
+
@numTables+=1
|
534
|
+
end
|
535
|
+
##########################################################################
|
471
536
|
# Inserts a table of the given name at the end of the spreadsheet and updates
|
472
537
|
# the internal table-administration.
|
473
538
|
# mySheet.insertTable("example")
|
@@ -1687,8 +1752,6 @@ class Rods
|
|
1687
1752
|
break
|
1688
1753
|
end
|
1689
1754
|
}
|
1690
|
-
else
|
1691
|
-
tell("writeStyleXml: leaving existing default-style #{styleName} untouched")
|
1692
1755
|
end
|
1693
1756
|
#-----------------------------------------------------------
|
1694
1757
|
# und schreiben, sofern nicht Default-Style
|
@@ -2512,7 +2575,7 @@ class Rods
|
|
2512
2575
|
:getCellFromRow, :getCell, :getRow, :renameTable, :setCurrentTable,
|
2513
2576
|
:insertTable, :deleteTable, :readCellFromRow, :readCell, :setAttributes, :writeStyleAbbr,
|
2514
2577
|
:setStyle, :printOfficeStyles, :printAutoStyles, :getNextExistentRow, :getPreviousExistentRow,
|
2515
|
-
:getNextExistentCell, :getPreviousExistentCell,
|
2578
|
+
:getNextExistentCell, :getPreviousExistentCell, :insertTableAfter, :insertTableBefore,
|
2516
2579
|
:writeComment, :save, :saveAs, :initialize, :writeText
|
2517
2580
|
|
2518
2581
|
private :tell, :die, :createCell, :createRow, :getChildByIndex, :createElement, :setRepetition, :initHousekeeping,
|
@@ -2520,5 +2583,5 @@ class Rods
|
|
2520
2583
|
:finalize, :init, :normalizeText, :getColor, :normStyleHash, :getStyle,
|
2521
2584
|
:getAppropriateStyle, :checkStyleAttributes, :insertStyleAttributes, :cloneNode,
|
2522
2585
|
:writeStyle, :writeStyleXml, :style2Hash, :writeDefaultStyles, :writeXml,
|
2523
|
-
:internalizeFormula, :getColorPalette, :open, :printStyles
|
2586
|
+
:internalizeFormula, :getColorPalette, :open, :printStyles, :insertTableBeforeAfter
|
2524
2587
|
end # Klassenende
|
data/rods.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rods}
|
5
|
-
s.version = "0.6.
|
5
|
+
s.version = "0.6.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Dr. Heinz Breinlinger"]
|
9
|
-
s.date = %q{2011-01-
|
9
|
+
s.date = %q{2011-01-10}
|
10
10
|
s.description = %q{OpenOffice.org oocalc: Fast automated batch-processing of spreadsheets (*.ods) conforming to Open Document Format v1.1. used by e.g. OpenOffice.org and LibreOffice. Please see screenshot and Rdoc-Documentation at http://ruby.homelinux.com/ruby/rods/. You can contact me at rodsdotrubyatonlinedotde (and drop me a line, if you like it ;-)}
|
11
11
|
s.email = %q{rods.ruby@online.de}
|
12
12
|
s.extra_rdoc_files = ["README", "lib/example.rb", "lib/rods.rb"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dr. Heinz Breinlinger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-10 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|