Search found 187 matches

by _savage
Mon Sep 26, 2022 12:57 am
Forum: Macros and UNO API
Topic: Trying to understand ContentControl text portions
Replies: 3
Views: 820

Trying to understand ContentControl text portions

Hello, I came across a TextPortion whose TextPortionType is ContentControl which I don’t see mentioned in the docs. This is for a text portion whose changes were tracked during document edit. Using MRI and following its ContentControl property leads me to an object whose implementation name is SwXCo...
by _savage
Thu May 12, 2022 12:49 pm
Forum: Macros and UNO API
Topic: [Solved] Accessing page header/footer of Writer docs
Replies: 8
Views: 2317

Re: Accessing page header/footer of Writer docs

Which LO version are you on, and is that an ODT or DOCX? I wonder if I have a funky DOCX version…
by _savage
Thu May 12, 2022 11:50 am
Forum: Macros and UNO API
Topic: [Solved] Accessing page header/footer of Writer docs
Replies: 8
Views: 2317

Re: Accessing page header/footer of Writer docs

JeJe wrote: Thu May 12, 2022 11:33 amWorks for me, […]
And when you save the file, has the header text changed?
by _savage
Wed May 11, 2022 2:57 am
Forum: Macros and UNO API
Topic: [Solved] Accessing page header/footer of Writer docs
Replies: 8
Views: 2317

Re: Accessing page header/footer of Writer docs

Hmm :? Is it possible that a header/foot is protected against modification? I can iterate over the TextRange objects in the header’s/footer’s paragraph, but when I call setString() on any one range it has no effect? Interestingly, if I call getString() on the owning paragraph then that string contai...
by _savage
Tue Mar 29, 2022 2:39 pm
Forum: Macros and UNO API
Topic: [Solved] Accessing page header/footer of Writer docs
Replies: 8
Views: 2317

Re: Programmatically accessing page header/footer of Writer

Assuming there is a header its text is part of the page style. Thanks JeJe! I think I found it… So, the 'PageStyles' provides a StyleFamily service to access styles for 'Standard', 'First Page', 'Left Page', 'Right Page', … which each provide the PageProperties service, which in turn has the Header...
by _savage
Tue Mar 29, 2022 1:01 pm
Forum: Macros and UNO API
Topic: [Solved] Accessing page header/footer of Writer docs
Replies: 8
Views: 2317

[Solved] Accessing page header/footer of Writer docs

Hello, is it possible to access the content (e.g. its paragraphs ) of the header and footer of each page of a loaded document in Writer? I found the HeaderFooterContent service but I’m not quite sure how to get from the loaded TextDocument to its page headers/footers… I’ll keep poking and MRI’ing ar...
by _savage
Mon Dec 21, 2020 11:19 pm
Forum: Macros and UNO API
Topic: How to detect row-spanning table cells
Replies: 15
Views: 5989

Re: How to detect row-spanning table cells

try running this - make sure your table is on screen. Thank you, JeJe and Villeroy for the code suggestions. I ended up with this Python snippet: def print_accessible_context(ac): nonlocal indent print(indent, "name", ac.AccessibleName, "role", ac.AccessibleRole, "children&...
by _savage
Sat Dec 19, 2020 12:33 pm
Forum: Macros and UNO API
Topic: How to detect row-spanning table cells
Replies: 15
Views: 5989

Re: How to detect row-spanning table cells

(you'll need to find that from searching through the accessible children of the componentwindow) I’ve just spent the last hour trying to get access to some form of accessible context but no dice. I open the Desktop and the TextDocument … and then? Where’s the hook to the Accessibility Tree of a Wri...
by _savage
Fri Dec 18, 2020 3:27 pm
Forum: Macros and UNO API
Topic: How to detect row-spanning table cells
Replies: 15
Views: 5989

Re: How to detect row-spanning table cells

A text table has method getCellNames() returning an array of strings (A1, A2, A3 etc) where the names of the submerged cells are missing. I think the cell names alone are not enough. For example, these two tables tables.jpg both have the following cell names: ('A1', 'B1', 'C1', 'B2'). It’s not poss...
by _savage
Thu Dec 17, 2020 1:23 pm
Forum: Macros and UNO API
Topic: How to detect row-spanning table cells
Replies: 15
Views: 5989

Re: How to detect row-spanning table cells

A text table has method getCellNames() returning an array of strings (A1, A2, A3 etc) […] Right, I came across that function but I seem to remember that cell names can be modified? But maybe that’s a symbolic cell name for Calc ( thread ) independent of the constant (?) “coordinate” cell names we’r...
by _savage
Thu Dec 17, 2020 9:49 am
Forum: Macros and UNO API
Topic: How to detect row-spanning table cells
Replies: 15
Views: 5989

How to detect row-spanning table cells

Hello, Suppose I have the following two tables: tables.jpg and I’d like to iterate over their cells and determine the row & column span for each cell. It looks like I can create very irregular tables that don’t map well to HTML tables but let’s not worry about that for now. So, I can iterate ove...
by _savage
Thu Apr 02, 2020 8:40 pm
Forum: Macros and UNO API
Topic: [Solved] Save a draw shape as DIB bitmap?
Replies: 39
Views: 18450

Re: [Solved] Save a draw shape as DIB bitmap?

Thank you! Above in teh full code there is a comparison of full DIB. (Don't know why also for only 5000 bytes later) Trying to find out how to compare these byte arrays in BASIC. Searching sthg like comparebytes() etc. I think the 5000 is just a random assumption: if the first 5000 bytes are the sa...
by _savage
Thu Apr 02, 2020 3:03 pm
Forum: Macros and UNO API
Topic: [Solved] Save a draw shape as DIB bitmap?
Replies: 39
Views: 18450

Re: [Solved] Save a draw shape as DIB bitmap?

The above works only for ODT files, correct? The Pictures folder does not exist in e.g. DOCX files and it’s not a virtual folder either… […] tried to translate it into BASIC but am stuck at props[0].Value = "{}/Pictures/{}".format(cid, picture) That’s a string formatting, you could also us...
by _savage
Tue Mar 10, 2020 6:15 am
Forum: Macros and UNO API
Topic: [Solved] Save a draw shape as DIB bitmap?
Replies: 39
Views: 18450

Re: [Solved] Save a draw shape as DIB bitmap?

Thank you, musikai! I think some of the code in your answer is very similar to your previous answer above . Regarding the OriginURL property, it’s an empty string for all embedded images in different documents that I’ve tried. Furthermore, accessing DocumentStorage.getByName("Pictures") se...
by _savage
Thu Mar 05, 2020 11:47 pm
Forum: Macros and UNO API
Topic: [Solved] Save a draw shape as DIB bitmap?
Replies: 39
Views: 18450

Re: [Solved] Save a draw shape as DIB bitmap?

There is a new toolbar under the main menu (this is the default location after the installing the extension) You are correct, I didn’t see that :D However, running the extension throws an exception that confirms my suspicion above: the code might be outdated: An exception occurred Type: com.sun.sta...
by _savage
Thu Mar 05, 2020 12:54 pm
Forum: Macros and UNO API
Topic: [Solved] Save a draw shape as DIB bitmap?
Replies: 39
Views: 18450

Re: [Solved] Save a draw shape as DIB bitmap?

I can't say, but searching in the API might help; One can programatically extract anything from a .zip archive - python in particular is good for this. Rory, I’m familiar with Python’s zipfile module. Using that would still require finding that mapping between the image file in the zip and the inte...
by _savage
Tue Mar 03, 2020 3:28 pm
Forum: Macros and UNO API
Topic: [Solved] Save a draw shape as DIB bitmap?
Replies: 39
Views: 18450

Re: [Solved] Save a draw shape as DIB bitmap?

You can access the internal copy of the picture by Saving the file in ODF format (,odt. .odg etc), opening it with an archive utility (it is a .zip file in disguise), then copying the image from the folder Pictures in that archive. Thanks Rory! No way to access that through the DOM programmatically...
by _savage
Tue Mar 03, 2020 2:59 pm
Forum: Macros and UNO API
Topic: Writer's tables, read a cell column span
Replies: 10
Views: 3443

Re: Writer's tables, read a cell column span

Hello blu, did you ever figure this out? Just curious… ;)
by _savage
Tue Mar 03, 2020 2:53 pm
Forum: Macros and UNO API
Topic: [Solved] Save a draw shape as DIB bitmap?
Replies: 39
Views: 18450

Re: Save a draw shape as DIB bitmap?

The AOO and LO have .PNG and .BMP export filters, and you can control those filters by a macro code. I am still somewhat unclear on this. Suppose somebody drops a GIF, a JPG, and a PNG image in a document, how do I get hold of these original image files? Using an export filter I can retrieve the im...
by _savage
Sat Aug 10, 2019 11:48 am
Forum: Macros and UNO API
Topic: How to find an image’s dimension and other manipulation info
Replies: 3
Views: 5368

How to find an image’s dimension and other manipulation info

Hi, I’ve been digging around the documentation and inspecting examples, but I can’t quite gather the information I look for. This is about images and how they’re represented from UNO’s perspective; let’s look at TextGraphicObject for now: Dimensions. I thought that ActualSize contains the original d...
by _savage
Fri Jul 12, 2019 9:01 am
Forum: Macros and UNO API
Topic: Alt Text and Description for draw shapes?
Replies: 2
Views: 1263

Re: Alt Text and Description for draw shapes?

I’m using MRI for inspection. When I draw a shape then it seems that that’s a com.sun.star.drawing.ShapeCollection with a single member; that single member is a XShape which indeed sports Description and Title. I’m wondering though, if that collection contains more than one shape then each shape has...
by _savage
Fri Jul 12, 2019 8:43 am
Forum: Macros and UNO API
Topic: Alt Text and Description for draw shapes?
Replies: 2
Views: 1263

Alt Text and Description for draw shapes?

When I drop a JPG image in my Writer document, right-click on it, and go into the “Options” tab of the image properties, then I can edit the Name, Alternative Text, and Description for that image. The Alternative next is then accessible through the SwXTextGraphicObject Title property, and the Descri...
by _savage
Thu May 09, 2019 12:57 am
Forum: Macros and UNO API
Topic: Where is a Shape’s alignment stored?
Replies: 2
Views: 1255

Where is a Shape’s alignment stored?

Hello, Suppose I have a document and iterate over its DrawPage objects like so: shapeobjenum = document.DrawPage.createEnumeration() while shapeobjenum.hasMoreElements(): shapeobj = shapeobjenum.nextElement() # shapeobj.Size, shapeobj.ActualSize give me the object’s size on the page in 100th/mm Some...
by _savage
Mon Dec 10, 2018 2:22 pm
Forum: Macros and UNO API
Topic: Where does HTML 'id' attribute map to in the DOM?
Replies: 5
Views: 8699

Re: Where does HTML 'id' attribute map to in the DOM?

I wasn’t asking about producing HTML code, but about reading HTML code into Office. To answer the above question, it seems that HTML elements with an `id` attribute produce a bookmark in the DOM.
by _savage
Fri Dec 07, 2018 11:51 pm
Forum: Macros and UNO API
Topic: Where does HTML 'id' attribute map to in the DOM?
Replies: 5
Views: 8699

Where does HTML 'id' attribute map to in the DOM?

Suppose I have a simple HTML file like so: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title</title...
by _savage
Tue Jul 31, 2018 7:35 pm
Forum: Macros and UNO API
Topic: How to check if image on DrawPage and TextPortion is same?
Replies: 8
Views: 1743

Re: How to check if image on DrawPage and TextPortion is sam

Check whether the object supports the right service and you should be done. I did ;) It doesn’t :( pyuno object (com.sun.star.drawing.XShape)0x7feee6c24c98{implementationName=SwXShape, supportedServices={com.sun.star.drawing.CustomShape,com.sun.star.drawing.Shape,com.sun.star.drawing.CustomShapePro...
by _savage
Tue Jul 31, 2018 5:14 pm
Forum: Macros and UNO API
Topic: How to check if image on DrawPage and TextPortion is same?
Replies: 8
Views: 1743

Re: How to check if image on DrawPage and TextPortion is sam

No. XShape objects of type SwXTextGraphicObject support the TextGraphicObject service. Thus you can easily check if the source image (return by the GraphicURL property) is the same. I guess you’re correct. However, I just had a document where the following code: drawobjenum = document.DrawPage.crea...
by _savage
Tue Jul 31, 2018 3:53 pm
Forum: Macros and UNO API
Topic: How to check if image on DrawPage and TextPortion is same?
Replies: 8
Views: 1743

Re: How to check if image on DrawPage and TextPortion is sam

I ended up md5-hashing the bitmap data of images, and comparing the hashes. Shapes are converted to png first (see this thread).

Not pretty, resource-hungry, but it works.
by _savage
Tue Jul 31, 2018 3:48 pm
Forum: Macros and UNO API
Topic: How to check if image on DrawPage and TextPortion is same?
Replies: 8
Views: 1743

Re: How to check if image on DrawPage and TextPortion is sam

hubert lambert wrote:What about comparing the GraphicURL property?
The GraphicURL is a property of the TextGraphicService and would’t work for objects with Shape service support.
by _savage
Mon Jul 30, 2018 9:33 pm
Forum: Macros and UNO API
Topic: How to check if image on DrawPage and TextPortion is same?
Replies: 8
Views: 1743

How to check if image on DrawPage and TextPortion is same?

I’ve got a document with five (bitmap) images. When I iterate over document.DrawPage.createEnumeration() then I get five references to these images, e.g. pyuno object (com.sun.star.drawing.XShape)0x7fe063487c28{implementationName=SwXTextGraphicObject, supportedServices={…}, supportedInterfaces={…}} ...