[Solved] Adding a Checkbox on a Stylesheet on Calc with Java

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
rafael.alvamar
Posts: 7
Joined: Wed Oct 28, 2020 9:40 am

[Solved] Adding a Checkbox on a Stylesheet on Calc with Java

Post by rafael.alvamar »

Hi guys,

I would like to add a checkbox on a Sheet on Calc program using Java code.

Now, I have all the code to connect to the file, but I don't know how add a checkbox on the sheet and using after that in my code.

I will be so happy if you could say how do it and where I could find a good reference of the API for Java.

Thanks.
Last edited by Hagar Delest on Fri Oct 30, 2020 12:33 pm, edited 1 time in total.
Reason: tagged solved
OpenOffice 4.1.17 on Windows 10
Java developer
User avatar
Zizi64
Volunteer
Posts: 11352
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by Zizi64 »

Put it onto the sheet manually, and control the visibility of it by your code.

The LO API is same for every programming languages. (maybe you can not control/handle some feature in one or the other IDE/language, but the API functions, procedures and objects are same.)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by JeJe »

There appear to be very few people using OO with Java and therefore relatively few resources available and few people to help you. You'll usually be able to find what you want to do in Basic and will have to translate.

https://wiki.openoffice.org/wiki/Docume ... and_Shapes
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
rafael.alvamar
Posts: 7
Joined: Wed Oct 28, 2020 9:40 am

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by rafael.alvamar »

Zizi64 wrote:Put it onto the sheet manually, and control the visibility of it by your code.

The LO API is same for every programming languages. (maybe you can not control/handle some feature in one or the other IDE/language, but the API functions, procedures and objects are same.)
How can I control the visibility of it by code? Sorry, but I'm learning this API.

Thanks for your help.
OpenOffice 4.1.17 on Windows 10
Java developer
rafael.alvamar
Posts: 7
Joined: Wed Oct 28, 2020 9:40 am

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by rafael.alvamar »

JeJe wrote:There appear to be very few people using OO with Java and therefore relatively few resources available and few people to help you. You'll usually be able to find what you want to do in Basic and will have to translate.

https://wiki.openoffice.org/wiki/Docume ... and_Shapes
This link is wonderfull for my needs. Thank you so much.
OpenOffice 4.1.17 on Windows 10
Java developer
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by JeJe »

Setting the visibility is an example of what I was saying about finding it in Basic and translating. The API is the same for all languages

viewtopic.php?f=20&t=27081

.setvisible(false) or .setvisible(true)
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
JeJe
Volunteer
Posts: 2763
Joined: Wed Mar 09, 2016 2:40 pm

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by JeJe »

You might find MRI helps. You can inspect an object and easily see all its properties and methods such as setvisible.

https://extensions.openoffice.org/en/pr ... ction-tool

It can help you write your code, for example

viewtopic.php?t=55835#p245258
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by Villeroy »

Generating complex form documents by code is a misconception. Simply use templates. Templates provide the core functionality of any office suite.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
rafael.alvamar
Posts: 7
Joined: Wed Oct 28, 2020 9:40 am

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by rafael.alvamar »

JeJe wrote:You might find MRI helps. You can inspect an object and easily see all its properties and methods such as setvisible.

https://extensions.openoffice.org/en/pr ... ction-tool

It can help you write your code, for example

viewtopic.php?t=55835#p245258
Very useful. I will try it.
OpenOffice 4.1.17 on Windows 10
Java developer
rafael.alvamar
Posts: 7
Joined: Wed Oct 28, 2020 9:40 am

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by rafael.alvamar »

Villeroy wrote:Generating complex form documents by code is a misconception. Simply use templates. Templates provide the core functionality of any office suite.
I will study this option. Thanks.
OpenOffice 4.1.17 on Windows 10
Java developer
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by Villeroy »

A template is an almost normal office document with all the layout, formatting, form controls and contents except for content that needs to be added by a user. A template opens as a new document with a document title like "Untitled 1". When the user saves it, he will be prompted for the path name of a new document. You open a letter template for a new letter and type in the letter text. You open a productivity template for a new profit calculation with all layout, formatting, input cells and formulas predefined. SInce more than 30 years, this is the core of office software and it does not require any kind of programming skills.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by UnklDonald418 »

Look at this link for using the LO/OO API in JAVA
http://fivedots.coe.psu.ac.th/~ad/jlop/#contents
I believe chapter 40 discusses checkboxes
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
rafael.alvamar
Posts: 7
Joined: Wed Oct 28, 2020 9:40 am

Re: Adding a Checkbox on a Stylesheet on Calc with Java

Post by rafael.alvamar »

Wow you're awsome! Thanks a lot for your help. Now I have how start my study.
OpenOffice 4.1.17 on Windows 10
Java developer
Post Reply