Import/export or store/restore xShapes in LibreOffice/OpenOffice Draw via API - openoffice.org

I want – as the title says – extract programmatically a shape from a Draw document through the api interface. Beside I want to import such a shape into a document as well.
I saw some predefined shapes in XML form and the document is stored as XML structure as well. Is there a known way to anybody out there to allow the storage and load of one shape?
What is this good for?
I want to, for example, enable the programmatic deletion of objects. But to enable the undo/redo functionalities I need to “store” the deleted shape. Beyond that this would allow me to add user-defined objects programmatically, e.g. arrow heads, UML structures or unicorns.
Thanks in advance for any ideas,
J
P.S.: I work with LibreOffice Version: 5.2.1.2 . Access the interface through C# (so java and C++ would do it as well) but any ideas are welcome.

I'm not entirely sure what you are trying to do, but here are some ideas:
Instead of deleting an XShape, you could use the dispatcher to Cut it. That will store it in the clipboard, so if it needs to be added back then the dispatcher can Paste it, as long as no other copy or cut was performed.
To create a shape, see the example at https://wiki.openoffice.org/wiki/Documentation/DevGuide/Drawings/Shapes. This code will look different depending on what kind of shape it is. It sounds like you are asking for one code listing that will programmatically create any type of shape, but I do not think it is that easy.
Instead of using the UNO API, you could programmatically modify the XML files, which may make it easier to store and work with any shape. Be sure to use an XML parsing library, not just regular expressions.

Related

How to implement a user definable interactive map in Delphi 2010?

I'd like to have an interactive floor map (so they're not huge) in my application. The maps will be different for every user, but contain similar elements which only differ by quantity and location. The application will show the map, identify certain elements and link them to information from the database.
To design and store the map, I'd rather not roll my own editor and/or come up with some custom file format. However, it would be nice if the format were open and easily readable. SVG seems to be the perfect candidate for the job. All there needs to be is a convention of how to name the elements to make them identifiable. But how to go from there? I need something that can render the SVG and distinguish between the different layers.
TSVG can do exactly this but depends on FireMonkey which I'd rather avoid - it's not even present in Delphi 2010, so I'd have to use another version and do DLL tricks.
Another option would be to use the Chromium Embedded Framework and create the map using HTML, CSS and JavaScript. That feels very bulky, and would be hard to get right.
Are there any simpler ways to do this that I overlooked, either using SVG or perhaps something completely different?
I'm not sure if a GIS system is appropriate for this. It may very well be overkill.
In the end I decided to go for D3.js using Chromium Embedded, to have a flexible and more portable solution.

How to write a code to read .fla file?

I was wondering so long that how can people analyze the trait of each file extension (of course open it in notepad is not readable)
For example, I want to write a program that can read everything from .fla file like timeline, movie clips, position of each MCs or all the motion tween values. And get the image embeded in it. (I'm planning to use flash as IDE for another project.)
(The reason that I tried to read proprietary format is I want to utilize their awesome editor. What I actually want to do is, I want to make an iOS game with cocos2d. There is a code to move things around in cocos2d but there is no decent editor. So I'd like to use Flash as an editor, then convert the motion to objective-C cocos2D code by reading the .fla file.)
If you would like to be able to import timeline animation from flash into cocos2d, this tool might help. More information in this thread.
The grapefrukt-exporter might also help as it can export keyframe data, and various other formats for animation.
Instead of creating the tool yourself, it might be much easier (and time saving) to use one of these and integrate it into your workflow :)
Finally, if none of the above works, how about just exporting the flash animation as an animated GIF or a movie file?
Im assuming you want to write a decompiler, this is possible and there are several available on the internet, price varies.
It is not possible for flash to achieve this, Most programs, software are built on a native language such as C, Native meaning it can independly run in its own with out initially setting up an invironment to support it.
Flash is not independent enough to be available to have this much power.
Try looking at c++ or C# as this would be possible, also these languages are a lot more powerful.

EverNote OCR feature?

I downloaded the EverNote API Xcode Project but I have a question regarding the OCR feature. With their OCR service, can I take a picture and show the extracted text in a UILabel or does it not work like that?
Or is the text that is extracted not shown to me but only is for the search function of photos?
Has anyone ever had any experience with this or any ideas?
Thanks!
Yes, but it looks like it's going to be a bit of work.
When you get an EDAMResource that corresponds to an image, it has a property called recognition that returns an EDAMData object that contains the XML that defines the recognition info. For example, I attached this image to a note:
I inspected the recognition info that was attached to the corresponding EDAMResource object, and found this:
the xml i found on pastie.org, because it's too big to fit in an answer
As you can see, there's a LOT of information here. The XML is defined in the API documentation, so this would be where you parse the XML and extract the relevant information yourself. Fortunately, the structure of the XML is quite simple (you could write a parser in a few minutes). The hard part will be to figure out what parts you want to use.
It doesn't really work like that. Evernote doesn't really do "OCR" in the pure sense of turning document images into coherent paragraphs of text.
Evernote's recognition XML (which you can retrieve after via the technique that #DaveDeLong shows above) is most useful as an index to search against; the service will provide you sets of rectangles and sets of possible words/text fragments with probability scores attached. This makes a great basis for matching search terms, but a terrible one for constructing a single string that represents the document.
(I know this answer is like 4 years late, but Dave's excellent description doesn't really address this philosophical distinction that you'll run up against if you try to actually do what you were suggesting in the question.)

Draw and manipulate shapes at run time

What's the best way to draw shapes interactively at run time using Delphi? I need to be able to select, drag and resize the shapes. This will be used to mark up existing images and documents.
This looks like a good starting point, but I'm wondering if there's a more complete library (preferably free) available that will save some time.
Update:
If you're going with a custom solution from scratch, I've seen another example on Delphi Central that might be an even better starting point.
I will recommend you, read some links on my site. Are explained and all the source code is available; You can see and get some usefull for you.
Plugin system in Delphi - Part 2
Not directly what you need, is a plugin system for Delphi. But all the samples are based on a drawing tool that uses Shapes (Creating, selecting, resizing). You can review the code and extract what you need.
Sample manipulating of "Maps and Figures"
Sample of how to create, select and move components at runtime (in this case with TImage).
- Select shapes visually: Shows different ways to select shapes visually.
The web is in Spanish, but you can generate an authomatic translation on the web itself.
Anyway the code is commented.
Regards.
Excuse-me for my bad english.
One freeware option would be TssControlSizer. Just change the "control" property to the control you want to manipulate resize/move.
Not sure if you've moved on now with this Bruce but if you haven't, it might be worth looking at TMS Components Diagram Studio - it's certainly cheap, and looks quite powerful from the demo.
I would use Flex Graphics (commercial, $499 for one developer, with sources, $1500 for site-license, with source code). When I bought it, it was a lot less than that. So I guess, I wouldn't pay that now. It's a lightweight 'drawing/cad' package.
But as I already own it, I could import a page from the original document as an image, perhaps rendered in PNG or WMF, and then mark it up with lines, etc.
You could think of it as a light "cad" package. It has most primitive shapes, and you can easily create your own new objects or shapes in Delphi classes, that could be "smart shapes" like the ones in Visio.
http://www.flex-graphics.com/
Another commercial component set that I have heard only good things about is TRichView. They have a TRichViewEdit that looks like you could emulate a document markup environment easily with it.
Please check here:
TCAD -2d graphics component for delphi
http://www.codeidea.com
wish can help you.

How can I process a -dynamic- videostream and find the (relative) location of a "match" in that videostream?

As the question states: how is it possible to process some dynamic videostream? By saying dynamic, i actually mean I would like to just process stuff on my screen. So the imagearray should be some sort of "continuous screenshot".
I'd like to process the video / images based on certain patterns. How would I go about this?
It would be perfect if there already was (and there probably is) existing components. I need to be able to use the location of the matches (or partial matches). A .NET component for the different requirements could also be useful I guess...
You will probably need to read up on Computer Visual before you attempt this. There is nothing really special about video that seperates it from still imgaes. The process you might want to look at is:
Acquire the data
Split the data into individual frames
Remove noise (Use a Gaussian filter)
Segment the image into the sections you want
Remove the connected components of the image
Find a way to quantize the image for comparison
Store/match the components to a database of previously found components
With this database/datastore you'll have information on matches later in the database. Do what you like with it.
As far as software goes:
Most of these algorithms are not too difficult. You can write them yourself. They do take a bit of work though.
OpenCV does a lot of the basic stuff, but it won't do everything for you
Java: JAI, JHLabs [for filters], Various other 3rd party libraries
C#: AForge.net

Resources