1
/* This file is part of the KDE project
2
Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#ifndef KO_TEXT_INLINE_RDF_H
21
#define KO_TEXT_INLINE_RDF_H
23
#include "kotext_export.h"
24
#include <KoXmlReaderForward.h>
26
#include <QTextBlockUserData>
27
#include <QTextTableCell>
30
class KoShapeSavingContext;
33
class KoTextInlineRdf;
34
class RdfSemanticItem;
39
* @short Store information from xhtml:property etc which are for inline Rdf
41
* @author Ben Martin <ben.martin@kogmbh.com>
44
* The easiest way to handle inline Rdf from content.xml is to attach these
45
* objects to the document's C++ objects. As you can see from the constructors
46
* there are methods which can attach to bookmarks, textmeta, table cells etc.
48
* The main reason why the inlineRdf wants these document objects
49
* passed in is so that object() can work out what the current value
50
* is from the document. For example, when a KoTextInlineRdf is
51
* attached to a bookmark-start, then when object() is called the
52
* bookmark is inspected to find out the value currently between
53
* bookmark-start and bookmark-end.
55
* The xmlId() method returns the xml:id that was associated with the
56
* inline Rdf if there was one. For example,
57
* <bookmark-start xml:id="foo" xhtml:property="uri:baba" ...>
58
* the KoTextInlineRdf object will be attached to the KoBookmark
59
* for the bookmark-start location and xmlId() will return foo.
61
* You can convert one of these to a Soprano::Statement using
62
* KoDocumentRdf::toStatement().
64
* The attach() and tryToGetInlineRdf() are used by the ODF load and
65
* save codepaths respectively. They associate an inlineRdf object
66
* with the cursor and fetch back the inline Rdf if one is associated
69
* FIXME: createXmlId() should consult with the KOffice codebase when
70
* generating new xml:id values during save.
72
class KOTEXT_EXPORT KoTextInlineRdf
75
KoTextInlineRdf(QTextDocument *doc, const QTextBlock &b);
76
KoTextInlineRdf(QTextDocument *doc, KoBookmark *b);
77
KoTextInlineRdf(QTextDocument *doc, KoTextMeta *b);
78
KoTextInlineRdf(QTextDocument *doc, const QTextTableCell &b);
80
virtual ~KoTextInlineRdf();
83
* The attach() and tryToGetInlineRdf() are used by the ODF load and
84
* save codepaths respectively. They associate an inlineRdf object
85
* with the cursor and fetch back the inline Rdf if one is associated
88
static KoTextInlineRdf *tryToGetInlineRdf(QTextCursor &cursor);
89
static KoTextInlineRdf *tryToGetInlineRdf(const QTextFormat &tf);
90
static KoTextInlineRdf *tryToGetInlineRdf(KoTextEditor *handler);
92
* The attach() and tryToGetInlineRdf() are used by the ODF load and
93
* save codepaths respectively. They associate an inlineRdf object
94
* with the cursor and fetch back the inline Rdf if one is associated
97
static void attach(KoTextInlineRdf *inlineRdf, QTextCursor &cursor);
99
bool loadOdf(const KoXmlElement &element);
100
bool saveOdf(KoShapeSavingContext &context, KoXmlWriter *writer);
103
* Get the RDF subject for this inline RDF
107
* Get the RDF predicate for this inline RDF
111
* Get the RDF object for this inline RDF
115
* Get the type of RDF node (bnode, literal, uri etc) for this inline RDF
117
int sopranoObjectType();
120
* Because RDF is linked to the xml id attribute of elements in
121
* content.xml the xml:id attribute that was read from the
122
* content.xml file is available here
127
* Find the start and end position of this inline RDF object in the
130
QPair<int, int> findExtent();
135
* Update the xml:id, using during cut and paste as well as document save.
137
void setXmlId(const QString &id);
140
* Create a new and unique xml:id
142
QString createXmlId(KoXmlWriter *writer = 0);
144
friend class KoRdfSemanticItem;
145
friend class KoRdfFoaF;
146
friend class KoDocumentRdf;
152
Q_DECLARE_METATYPE(KoTextInlineRdf*)