~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to libs/kotext/KoTextInlineRdf.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#ifndef KO_TEXT_INLINE_RDF_H
 
21
#define KO_TEXT_INLINE_RDF_H
 
22
 
 
23
#include "kotext_export.h"
 
24
#include <KoXmlReaderForward.h>
 
25
 
 
26
#include <QTextBlockUserData>
 
27
#include <QTextTableCell>
 
28
 
 
29
class KoXmlWriter;
 
30
class KoShapeSavingContext;
 
31
class KoBookmark;
 
32
class KoTextMeta;
 
33
class KoTextInlineRdf;
 
34
class RdfSemanticItem;
 
35
class RdfFoaF;
 
36
class KoTextEditor;
 
37
 
 
38
/**
 
39
 * @short Store information from xhtml:property etc which are for inline Rdf
 
40
 *
 
41
 * @author Ben Martin <ben.martin@kogmbh.com>
 
42
 * @see KoDocumentRdf
 
43
 *
 
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.
 
47
 *
 
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.
 
54
 *
 
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.
 
60
 *
 
61
 * You can convert one of these to a Soprano::Statement using
 
62
 * KoDocumentRdf::toStatement().
 
63
 *
 
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
 
67
 * with a text block.
 
68
 *
 
69
 * FIXME: createXmlId() should consult with the KOffice codebase when
 
70
 * generating new xml:id values during save.
 
71
 */
 
72
class KOTEXT_EXPORT KoTextInlineRdf
 
73
{
 
74
public:
 
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);
 
79
 
 
80
    virtual ~KoTextInlineRdf();
 
81
 
 
82
    /**
 
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
 
86
     * with a text block.
 
87
     */
 
88
    static KoTextInlineRdf *tryToGetInlineRdf(QTextCursor &cursor);
 
89
    static KoTextInlineRdf *tryToGetInlineRdf(const QTextFormat &tf);
 
90
    static KoTextInlineRdf *tryToGetInlineRdf(KoTextEditor *handler);
 
91
    /**
 
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
 
95
     * with a text block.
 
96
     */
 
97
    static void attach(KoTextInlineRdf *inlineRdf, QTextCursor &cursor);
 
98
 
 
99
    bool loadOdf(const KoXmlElement &element);
 
100
    bool saveOdf(KoShapeSavingContext &context, KoXmlWriter *writer);
 
101
 
 
102
    /**
 
103
     * Get the RDF subject for this inline RDF
 
104
     */
 
105
    QString subject();
 
106
    /**
 
107
     * Get the RDF predicate for this inline RDF
 
108
     */
 
109
    QString predicate();
 
110
    /**
 
111
     * Get the RDF object for this inline RDF
 
112
     */
 
113
    QString object();
 
114
    /**
 
115
     * Get the type of RDF node (bnode, literal, uri etc) for this inline RDF
 
116
     */
 
117
    int sopranoObjectType();
 
118
 
 
119
    /**
 
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
 
123
     */
 
124
    QString xmlId();
 
125
 
 
126
    /**
 
127
     * Find the start and end position of this inline RDF object in the
 
128
     * document.
 
129
     */
 
130
    QPair<int, int> findExtent();
 
131
 
 
132
private:
 
133
 
 
134
    /**
 
135
     * Update the xml:id, using during cut and paste as well as document save.
 
136
     */
 
137
    void setXmlId(const QString &id);
 
138
 
 
139
    /**
 
140
     * Create a new and unique xml:id
 
141
     */
 
142
    QString createXmlId(KoXmlWriter *writer = 0);
 
143
 
 
144
    friend class KoRdfSemanticItem;
 
145
    friend class KoRdfFoaF;
 
146
    friend class KoDocumentRdf;
 
147
 
 
148
    class Private;
 
149
    Private* d;
 
150
};
 
151
 
 
152
Q_DECLARE_METATYPE(KoTextInlineRdf*)
 
153
#endif