Accessing Attributes for Drawing Objects in a Base Form

In Base, is it possible using a macro to manipulate objects other than forms, labels and fields (controls)? For example, can shapes like rectangles, lines, ellipses, callouts, symbols, stars or images be "seen" in the DOM (I'm referring to the tree of objects in LO as a DOM because it's the term I'm familiar with as a web developer) and manipulated somehow? For example, if there is a rectangle in a Form, can I access the shape, change its fill & outline, or toggle its visibility based on user actions?

On a somewhat related topic, what is the purpose for every object in a form having a "Name", "Description" and "Title"? Are these related to the fact that Base uses Writer as it's layout engine? What I mean is, you can right-click on any label or field in your Form, and two options always exist: Description... and Name... If you click on Name, sometimes buttons and list boxes have names such as "Shape1' or "Shape3" - but not always. It's weird that only some objects have a "name." This is probably meaningless for my original question... but if the "name" was somehow similar to the concept of "id" in HTML/CSS, then perhaps a shape like a rectangle or ellipse could be given a unique name as an identifier and then show up in the LO Base DOM under that name? Wouldn't that be great.

Another similar question is whether grouped objects can be accessed along with any properties such as visibility. If a whole bunch of fields and labels can be grouped, then given a "name"... then maybe the whole group can be toggled?

Only dreaming, my guess is that these things cannot be done in Base. But one never knows until one asks.

If you are tempted to ask the question "Why?"... It's because I use rectangles in a visual manner to surround logical groupings of fields, and there are circumstances when I want to show or hide that rectangle along with the fields it visibly contains depending on whether entry in those fields makes sense for particular records, and so on and so forth. :) For example, if I have an expenses table represented by a form, if the category is "gas," I would show a group of fields that allows entry of "mileage", "price per gallon," etc. But for all other expenses, these fields would be invisible. I know it's possible to show and hide fields, but what about rectangles and images? I suppose someone could get very creative and insert symbols into a custom font and use those as "images" inside a label and show/hide that. But that doesn't really serve the rectangle question unless you make the font size HUGE with a rectangle font :D I bet no one has thought of that before! Total hack.

The only other way to accomplish something similar I can think of is to create a label with no text ...

edit retag close merge delete

If there's documentation for this kind of stuff online somewhere, I don't mind being pointed to it rather than receiving a lengthy answer. I just don't know where to look. I skimmed Andrew Pitonyak's Macros Explained book, but it seems like the drawing object attribute stuff he mentions is more for Draw and Impress rather than Base. But maybe it's all the same across all the apps?

( 2018-11-05 11:06:49 +0200 )edit

Use the control Group Boxto put things visually together. For manipulating shapes depending on content of data base records, you need macros. https://wiki.documentfoundation.org/M....

( 2018-11-05 14:18:12 +0200 )edit

I'm aware of the Group Box, but it doesn't seem to add any functional benefit I'm aware of - just a weak visual. From what I can determine, it has zero styling capabilities. The reason I chose to draw a rectangle is because I can choose to color it differently with a background, line, line thickness, line style (like dotted), etc. None of this can be done to a Group Box, which I find strange. Also, the Label at the top cannot be formatted either - like bigger font, different color, etc. Boo.

( 2018-11-05 14:46:07 +0200 )edit

Also, I'm aware of Macro documentation, but with hundreds of pages to hunt through, it's hard to find a section about editing drawing object properties within Base. So far I haven't found anything. I'll keep hunting though... or give up and not get hung up on visual details for the moment.

( 2018-11-05 14:47:19 +0200 )edit

Sort by » oldest newest most voted

Hello,

Please keep questions to one item. Multiple items are lost to other looking for answers.

Just some general comments without a lot of specifics. Yes OOME is quite large but you would be surprised just what is buried within. Have spent many hours going through many of the samples in all modules even though my specific target is Base. It is amazing how much other areas can be used in Base if you don't know it is there.

Something else which helps in locating various Properties, Methods, Interfaces and Services for objects is an Inspection Tool. Two most used are MRI and XRay. It is personal preference but I have stuck with MRI. You can find various links for each on this post -> To learn LibreOffice Base are there introductions or tutorials?.

And yes you can with macros access shapes and modify them. For me they are a pain since you need to be careful to protect them from user access. They are not the same as controls and if not done correctly the user can move them or even delete them. These shapes are located on the Draw Page. The Draw Page is a little tougher to deal with since you first access objects by index & then check say a name to see if it the object you are looking for. If I recall correctly they are indexed according to the sequence they were inserted in.

As for toggling grouped items, I had a link to an example years ago. If I find it will post back here. It's basically using a loop in a group control. Don't remember the details. However you may also be interested in sections. Hiding & revealing entire sections. For an example see my answer in this post -> Tabbed forms within a Main Form.

Edit:

Found two items. Toggling mentioned earlier, see my answer here -> Libreoffice Base - Display Form based on Group Box Option selected. The link to the sample is in the first comment. Also note some translation in my later comment.

In my answer here -> How can I hide/show a shape of my spreadsheet using a macro? is a macro looping through shapes on the DrawPage looking for one in particular.

more