1. Mosaic Fun with
OpenOffice Calc
imacat (Yang Shih-Ching)
<imacat@mail.imacat.idv.tw>
2012/11/6
2. “Mosaic Fun with OpenOffice Calc” is created by imacat (Yang Shih-Ching),
and licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
3. imacat / Yang Shih-Ching
● From Taiwan local OpenOffice community
● A graduate student from the Computer
Science Education Laboratory, National
Taiwan Normal University
● A member of Women in FOSS in Taiwan
● Was…
– A Sun/Oracle freelance lecturer
– An OpenOffice RD for 1 year
– A web application developer for 8 years
4. This session is all about multimedia and fun.
So please relax and enjoy!
5. After all, I’m not a show business professional.
I’m a developer.
Please forgive me if this is not cool enough. :p
6. Since this is all about multimedia,
before we start,
lets get some multimedia first! ^_*’
23. Creating mosaic art involves
calculating the average colors of image blocks.
Since neither OpenOffice BASIC nor UNO API
has any method
to obtain the colors of individual pixels,
I have use Java to do this.
28. No, that’s not cool.
It’s uglier than the original “Stop-Motion Excel”.
It’s not the “eye candy” that I imagined.
29. Why?
The original “Stop-Motion Excel”
was painted manually, cell by cell.
MysteryGuitarMan painted it with a fixed
palette, but not “average colors”.
It looks sharp. It feels like an animation.
33. The idea of Calc Mosaic
is not only to create mosaic arts,
but also to create stop-motion animations.
34. But it takes averagely 20 seconds
to create a spreadsheet of mosaic art
with the Java UNO application.
I cannot run the animation
by creating the mosaic art at real-time.
35. So I turn to another method,
to create each frame with a spreadsheet,
and play them in sequence,
as a stop-motion animation.
36. But then a spreadsheet document can only
contain a maximum of 256 spreadsheets.
37. Since I only have 256 frames,
this cannot be long.
48. As you can see,
Villeroy places the color values in the cells.
The OpenOffice BASIC macro can read and
update the cell background colors accordingly.
OpenOffice BASIC is a lot faster
than Java UNO.
This makes it possible to animate at real time.
50. Disadvantages of
Villeroy’s Approach
● You still need to have the color values first.
51. Disadvantages of
Villeroy’s Approach
● You still need to have the color values first.
● The frame rate is still low.
52. Disadvantages of
Villeroy’s Approach
● You still need to have the color values first.
● The frame rate is still low.
● Villeroy updates the colors with styles.
– A lot faster than painting the background
color cell by cell.
– The number of colors to use is limited.
That is why it is gray-scaled.
53. This is a different approach than me.
But I still got greatly inspired.
54. The color values can be saved in the sheets,
and painted with OpenOffice BASIC.
This can make it a lot faster.
55. And I know there is the setDataArray()
in the interface XCellRangeData.
I can populate all the color values at once
instead of hundreds of UNO calls
to set the CellBackColor property
Of SheetCell.
56. The New Process Will Be…
1.Calculates the average colors of mosaic
cells with the Java application.
57. The New Process Will Be…
1.Calculates the average colors of mosaic
cells with the Java application.
2.Passes the color values from Java to
OpenOffice BASIC.
58. The New Process Will Be…
1.Calculates the average colors of mosaic
cells with the Java application.
2.Passes the color values from Java to
OpenOffice BASIC.
3.Paints the background colors of the
spreadsheet cells with the OpenOffice
BASIC macro.
59. So the problem becomes:
Writing an application
both in Java and OpenOffice BASIC.
60. So the problem becomes:
Writing an application
both in Java and OpenOffice BASIC.
Or, simply,
Creating the OpenOffice BASIC macros
through the UNO API with Java.
61. In the unpublished UNO API,
there is a BasicLibraries property
in OfficeDocument
that application developers can
access, insert or delete the BASIC macros.
62. There’s also the XScriptProvider interface
that I can use it to invoke
the existing OpenOffice macros.
63. So I use them to “inject” the BASIC macros
into the newly-created spreadsheet document,
and run these macros.
64. In fact, I don’t even need to use setDataArray()
to paste the color values into the spreadsheets.
I can pass the color values as parameters
to the invoked BASIC macros.
65. This is troublesome,
but the result is amazing.
It is 8 times faster then before!
66. When I prepare for this presentation,
I became more and more greedy.
67. I want something new,
something hot,
something gets people excited!
72. The Gangnam Style song is 4:12 long.
That is 252 seconds.
With 10 FPS, it needs 2520 spreadsheets.
That is 10 spreadsheet documents.
(Each has a maximum of 256 spreadsheets.)
73. I can then concatenate the 10 recorded videos,
join them into one,
and create an OpenOffice Calc Style.