Hi Nuno,
Nuno Rocha wrote:
> Hi,
>
> I'm using the current version from the CVS which I
compiled into a dll
> library to include in my project.
>
> After your hints, I think I've reached the
bookmarks...you know, my
> documents can be very complex, with bookmarks inside
tables that are inside
> headers and/or footers and it's really complicated to
access bookmarks in
> this way...(you have to go through a lot of objects
that you aren't even
> guaranteed that exist - for example, what if we have a
bookmark inside a
> table that is inside another table?? If we know nothing
about the
> document's
> structure - that is the case - we have to prepare an
algorithm that can
> access the correct data...and this is just an example
of how things may get
> complicated).
> I think that it would be easier to have a collection
with all the bookmarks
> of a document (both in the main document and in the
headers/footers) but
> this is just a thought.
Yes, in this case it would be easier if AODL offers a
collection of all
Bookmarks within the document. Such a feature was already on
the planed
feature list, but I can't tell you a implementation date :(
I hope the
current way will work for you for the first time ;)
>
> Anyway, just an extra question (more related with
OpenOffice): I'm using
> the
> bookmarks to mark certain text/images of a document. In
Word I can select a
> text, insert a bookmark and then access and edit the
marked text. In
> OpenOffice, the text is between a text:bookmark-start
and a
> text:bookmark-end and I have to manually access the
nodes between the two
> tags and get the other nodes to obtain the text. In
OpenOffice, this is the
> way to do it, right?
Yes, that's right. If you e.g. select a text portion and
then insert a
bookmark a bookmark-start element will be inserted at the
selection
start and a bookmark-end element at the selection end. If
you insert a
bookmark without having any thing selected a bookmark
element will be
inserted at the current cursor position.
Regards
Lars
>
> Thanks for all the info.
>
> Regards,
> Nuno Rocha
>
> On 7/24/07, lars behrmann - Sun Microsystems - Hamburg
Germany <
> Lars.Behrmann sun.com> wrote:
>>
>> Hi Nuna,
>>
>> Nuno Rocha wrote:
>> > Hi all,
>> >
>> > following my last post ("Accessing odt
document content"), I've been
>> trying
>> > to access the things I want directly from the
XML source (as I didn't
>> > figure
>> > out how to do it with the current state of
AODL).
>> >
>> > One thing that I noticed is that the property
XmlDoc of a TextDocument
>> > doesn't hold the content of the content.xml
file...I loaded a
>> TextDocument
>> > from a file (td.Load(filename)) and the XmlDoc
property has what I
>> think
>> > are
>> > the master styles defined in the styles.xml
file...After some debugging
>> > steps, I figured out that in
MainContentProcessor.cs there is a method
>> > named
>> > ReadContentNodes() that is called by the
importer
>> (OpenDocumentImporter).
>> > Inside this method there are the following
lines:
>> >
>> > "//Remove all existing
content will be created new
>> > node.RemoveAll();"
>> >
>> > After this call, the original content of
content.xml (inside
>> office:text
>> > element) is erased.
>> >
>> > Strangely (for me that I'm a noob with this
library, of course), when I
>> > save
>> > the document with td.SaveTo() method,
everything seems to be fine and
>> the
>> > file is correctly saved...
>> >
>> > Another issue that I found was that if I add
an image to a header or a
>> > footer, the Graphics.Count property is 2 and
not 1 as expected. Does
>> this
>> > have anything to do with the fact that the
master styles from the
>> > style.xmlfile are being added to the
>> > content.xml and thus the image appears twice
(one for the original -
>> > defined
>> > in the styles.xml - and another for the
"copy" made to content.xml)?
>> >
>> > So, after this "boring" description,
can anyone tell me:
>> > 1 - How can I access the XML source of the
content.xml?
>> > 2 - Is the behaviour I just described above
(about the deletion of the
>> > contents and insertion of the master styles in
the content.xml file)
>> > "normal" or is it a bug?
>> > 3 - If it's a bug, how is it possible that
the saving is seemingly OK?
>>
>> 1 -> 3
>> With AODL you can't access the xml files of an ODF
file directly. This
>> depends on the library design. When a ODF file is
loaded with AODL all
>> nodes will be mapped on their corresponding Mapper
classes e.g. a
>> paragraph is mapped to a Paragraph object, .... .
At least this doesn't
>> mean that the content, styles, .. will be lost when
you save the file
>> back, because AODL will create/recreate this files
from object model on
>> saving. So with AODL you're not working on the XML
document you work
>> with a object model which is representing the
document structure and its
>> styles.
>>
>> > 4 - Can anyone reply to my previous post,
please? I need to
>> know as
>> > fast as possible if it's possible to get
bookmarks and user-defined
>> fields
>> > from a document...
>>
>> You have to iterate recursively through the loaded
content objects and
>> check the content against the type you're searching
for. The content
>> objects of a document are stored inside the Content
property.
>>
>> e.g.
>> if( object is
AODL.Document.Content.Text.Indexes.Bookmark )
>> // do something: object as
AODL.Document.Content.Text.Indexes.Bookmark
>>
>> Since there isn't a implementation of user defined
fields yet. This
>> fields should be mapped to an UnknowContent object.
Through its Node
>> property you can access its XML content.
>>
>> Youre notice about the duplicated graphic inside
the header sounds like
>> bug. I will check this. Did you check out the
current version from the
>> CVS or do you use the download package?
>>
>> Hope this info will help you a little bit.
>>
>> Regards
>> Lars
>>
>> >
>> > Best regards,
>> > Nuno Rocha
>> >
>>
>>
------------------------------------------------------------
---------
>> To unsubscribe, e-mail: dev-unsubscribe odftoolkit.openoffice.org
>> For additional commands, e-mail: dev-help odftoolkit.openoffice.org
>>
>>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe odftoolkit.openoffice.org
For additional commands, e-mail: dev-help odftoolkit.openoffice.org
|