Re: WRITER : Extend support for RDF Metadata

2013-11-15 Thread Michael Stahl
On 15/11/13 19:03, arkarell wrote:

> I managed few days ago to implement the points 1 and 2 for text:table.
> I worked in analogy with what was done for sections.
> I used the SwTableFmt core object and the SwXTextTable UNO wrapper 
> object. But I also modified the SwXMLExport::ExportTable method in
> sw/source/filter/xml/xmltble.cxx in order to export xml:id. And it's 
> working, I can set and retrieve rdf metadata on tables !!!

wow, sounds great!

> I didn't treat any undo/copy/paste/merge, because first, as you said, 
> specifications are missing and needs could be very different,  and second
> because it doesn't seem to be already treated for yet supported 
> elements. For instance, if i set metadata on a paragraph and copy/paste 
> this paragraph,
> the rdf data are not copied.

yes... what is currently copied is just the xml:id, not the metadata.
that may still be useful, for example if you Cut and Paste in the same
document.

> My problem in my modifications is that I put some code at some place but 
> without knowledge of the purpose and links of impacted classes.
> And I'm not sure to use the good class : for instance for table support 
> in core object, why SwTableFmt and not SwTable ? Because SwSectionFmt ?

generally the UNO wrapper object is obvious, and the core object is the
one to which the UNO wrapper object has a pointer.

as you can see from code in untbl.cxx such as ...

  SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt)
  : SwClient( &rFrmFmt )


... and SwXTextTable::attachToRange ...

SwFrmFmt* pTblFmt = pTable->GetFrmFmt();
lcl_FormatTable( pTblFmt );

pTblFmt->Add(this);

... it is obvious (well it's obvious if you understand first that
SwClient/SwModify is the horribly deficient notification / observer
mechanism on which all of Writer is built) that you picked the right
class with SwTableFmt (which is a subclass of SwFrmFmt).

> Do you have some documentation to understand these objects (core, uno 
> wrapper, std or *Fmt, ...) and their relations ?

... not really ... you can look at the doxygen documentation[1] to get a
quick overview (especially useful to quickly see inheritance trees)...
and [2] is a useful article in general...  but usually for this purpose
it's a SwXFoo UNO wrapper class that is a SwClient of some core class,
which is sometimes a SwFrmFmt or subclass.  often there are several core
classes for different aspects of the entity.

things get especially tricky here if the core object is a SfxPoolItem,
like it is with SwXMeta and ::sw::Meta ... but i hope there aren't more
of these left that need an xml:id.

[1] http://docs.libreoffice.org/sw.html
[2] https://wiki.openoffice.org/wiki/Writer/Core_And_Layout

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: WRITER : Extend support for RDF Metadata

2013-11-15 Thread arkarell

Hi Michael,

Thanks a lot for your detailled answer.

Le 15/11/2013 18:26, Michael Stahl a écrit :

hi Arnaud,

sorry for late reply, somehow i missed your mail initially :(

On 06/11/13 10:00, Miklos Vajna wrote:

Hi,

On Thu, Oct 31, 2013 at 02:37:21PM +0100, arkarell  
wrote:

I would like to extend support for "RDF metadata" in LibreOffice
Writer in order to be able to set metadata
on a lot of elements unsupported today like tables.
Is there anybody that could help me to find what source code are involved ?

unfortunately i don't have time to work on the implementation myself but
can point you to the relevant places in the code, answer questions and
review patches.

the main parts for adding an xml:id are:

1. derive the core object from sfx2::Metadatable
and implement the pure virtual methods
(see include/sfx2/Metadatable.hxx)

2. derive the UNO wrapper object from sfx2::MetadatableMixin
and implement the pure virtual methods

3. adapt all places that copy the core object to call
Metadatable::RegisterAsCopyOf

4. for Undo, insert calls to Metadatable::CreateUndo
and Metadatable::RestoreMetadata

5. in case the core object can be "merged" like paragraphs:
add call to Metadatable::JoinMetadatable

of course you can "git grep" for these functions and classes to see
usage examples.

well one thing that is still a sort of unresolved conceptual issue is
how to copy/paste the RDF metadata in case some content entity with an
xml:id is copied.  especially _which_ RDF statements should be copied in
that case.

I managed few days ago to implement the points 1 and 2 for text:table.
I worked in analogy with what was done for sections.
I used the SwTableFmt core object and the SwXTextTable UNO wrapper 
object. But I also modified the SwXMLExport::ExportTable method in
sw/source/filter/xml/xmltble.cxx in order to export xml:id. And it's 
working, I can set and retrieve rdf metadata on tables !!!


I didn't treat any undo/copy/paste/merge, because first, as you said, 
specifications are missing and needs could be very different,  and second
because it doesn't seem to be already treated for yet supported 
elements. For instance, if i set metadata on a paragraph and copy/paste 
this paragraph,

the rdf data are not copied.

My problem in my modifications is that I put some code at some place but 
without knowledge of the purpose and links of impacted classes.
And I'm not sure to use the good class : for instance for table support 
in core object, why SwTableFmt and not SwTable ? Because SwSectionFmt ?
Do you have some documentation to understand these objects (core, uno 
wrapper, std or *Fmt, ...) and their relations ?


Thanks

regards,

Arnaud
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: WRITER : Extend support for RDF Metadata

2013-11-15 Thread Michael Stahl
hi Arnaud,

sorry for late reply, somehow i missed your mail initially :(

On 06/11/13 10:00, Miklos Vajna wrote:
> Hi,
> 
> On Thu, Oct 31, 2013 at 02:37:21PM +0100, arkarell 
>  wrote:
>> I would like to extend support for "RDF metadata" in LibreOffice
>> Writer in order to be able to set metadata
>> on a lot of elements unsupported today like tables.
>> Is there anybody that could help me to find what source code are involved ?

unfortunately i don't have time to work on the implementation myself but
can point you to the relevant places in the code, answer questions and
review patches.

the main parts for adding an xml:id are:

1. derive the core object from sfx2::Metadatable
   and implement the pure virtual methods
   (see include/sfx2/Metadatable.hxx)

2. derive the UNO wrapper object from sfx2::MetadatableMixin
   and implement the pure virtual methods

3. adapt all places that copy the core object to call
   Metadatable::RegisterAsCopyOf

4. for Undo, insert calls to Metadatable::CreateUndo
   and Metadatable::RestoreMetadata

5. in case the core object can be "merged" like paragraphs:
   add call to Metadatable::JoinMetadatable

of course you can "git grep" for these functions and classes to see
usage examples.

well one thing that is still a sort of unresolved conceptual issue is
how to copy/paste the RDF metadata in case some content entity with an
xml:id is copied.  especially _which_ RDF statements should be copied in
that case.

>> For information, I use the API of LibreOffice/OpenOffice for many
>> years now but it would be my first contribution at the LO code.
> 
> There are two SfxPoolItems you can use to set metadata on items like
> paragraphs or tables:
> 
> - SvXMLAttrContainerItem is used to store unknown XML attributes from
>   ODF (so they survive a roundtrip)
> - SfxGrabBagItem is a string-any map, so can store nested structures,
>   etc. -- but explicitly runtime-only, so ODF filter intentionally
>   ignores it.

that's totally not the way to go... the xml:id must be unique in the
document and these classes don't ensure that; they also don't make the
content entity available in the UNO RDF API.

On 13/11/13 12:14, Jan Holesovsky wrote:
>
>
https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/RDF_metadata
>
> what you are searching for?  This applies to LibreOffice too if I am not
> mistaken.

yes that is still up to date since nothing has changed...

regards,
 michael
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: WRITER : Extend support for RDF Metadata

2013-11-13 Thread Jan Holesovsky
Hi,

arkarell píše v Čt 31. 10. 2013 v 14:37 +0100:

> I would like to extend support for "RDF metadata" in LibreOffice Writer 
> in order to be able to set metadata
> on a lot of elements unsupported today like tables.
> Is there anybody that could help me to find what source code are involved ?
> For information, I use the API of LibreOffice/OpenOffice for many years 
> now but it would be my first contribution at the LO code.

Is

https://wiki.openoffice.org/wiki/Documentation/DevGuide/OfficeDev/RDF_metadata

what you are searching for?  This applies to LibreOffice too if I am not
mistaken.

Regards,
Kendy

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: WRITER : Extend support for RDF Metadata

2013-11-06 Thread Miklos Vajna
Hi,

On Thu, Oct 31, 2013 at 02:37:21PM +0100, arkarell  
wrote:
> I would like to extend support for "RDF metadata" in LibreOffice
> Writer in order to be able to set metadata
> on a lot of elements unsupported today like tables.
> Is there anybody that could help me to find what source code are involved ?
> For information, I use the API of LibreOffice/OpenOffice for many
> years now but it would be my first contribution at the LO code.

There are two SfxPoolItems you can use to set metadata on items like
paragraphs or tables:

- SvXMLAttrContainerItem is used to store unknown XML attributes from
  ODF (so they survive a roundtrip)
- SfxGrabBagItem is a string-any map, so can store nested structures,
  etc. -- but explicitly runtime-only, so ODF filter intentionally
  ignores it.

See here for more info:

https://wiki.documentfoundation.org/Development/Writer#InteropGrabBag

Miklos


signature.asc
Description: Digital signature
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


WRITER : Extend support for RDF Metadata

2013-10-31 Thread arkarell

Hi,

I would like to extend support for "RDF metadata" in LibreOffice Writer 
in order to be able to set metadata

on a lot of elements unsupported today like tables.
Is there anybody that could help me to find what source code are involved ?
For information, I use the API of LibreOffice/OpenOffice for many years 
now but it would be my first contribution at the LO code.


Thanks.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice