Changeset View
Changeset View
Standalone View
Standalone View
karbon/ui/KarbonDocument.h
Show All 33 Lines | |||||
34 | #define KARBON_DOCUMENT_H | 34 | #define KARBON_DOCUMENT_H | ||
35 | 35 | | |||
36 | #include <QString> | 36 | #include <QString> | ||
37 | #include <QMap> | 37 | #include <QMap> | ||
38 | #include <QRectF> | 38 | #include <QRectF> | ||
39 | 39 | | |||
40 | #include <KoShapeBasedDocumentBase.h> | 40 | #include <KoShapeBasedDocumentBase.h> | ||
41 | 41 | | |||
42 | #include <KoDocument.h> | 42 | #include <KoPADocument.h> | ||
43 | #include <KoShapeLoadingContext.h> | 43 | #include <KoShapeLoadingContext.h> | ||
44 | #include <KoXmlReader.h> | 44 | #include <KoXmlReader.h> | ||
45 | 45 | | |||
46 | #include <karbonui_export.h> | 46 | #include <karbonui_export.h> | ||
47 | 47 | | |||
48 | class QRect; | 48 | class QRect; | ||
49 | class KarbonPart; | 49 | class KarbonPart; | ||
50 | class KarbonCanvas; | 50 | class KarbonCanvas; | ||
51 | class KoDataCenterBase; | 51 | class KoDataCenterBase; | ||
52 | class KoShape; | 52 | class KoShape; | ||
53 | class KoShapeSavingContext; | 53 | class KoShapeSavingContext; | ||
54 | class KoShapeLayer; | 54 | class KoShapeLayer; | ||
55 | class KoImageCollection; | 55 | class KoImageCollection; | ||
56 | class KoStore; | 56 | class KoStore; | ||
57 | 57 | | |||
58 | #define KARBON_MIME_TYPE "application/vnd.oasis.opendocument.graphics" | 58 | #define KARBON_MIME_TYPE "application/vnd.oasis.opendocument.graphics" | ||
59 | 59 | | |||
60 | /** | 60 | /** | ||
61 | * Keeps track of visual per document properties. | 61 | * Keeps track of visual per document properties. | ||
62 | * It loads initial settings and applies them to the document and its views. | 62 | * It loads initial settings and applies them to the document and its views. | ||
63 | */ | 63 | */ | ||
64 | class KARBONUI_EXPORT KarbonDocument : public KoDocument, public KoShapeBasedDocumentBase | 64 | class KARBONUI_EXPORT KarbonDocument : public KoPADocument | ||
65 | { | 65 | { | ||
66 | Q_OBJECT | 66 | Q_OBJECT | ||
67 | public: | 67 | public: | ||
68 | explicit KarbonDocument(KarbonPart *part); | 68 | explicit KarbonDocument(KarbonPart *part); | ||
69 | virtual ~KarbonDocument(); | 69 | virtual ~KarbonDocument(); | ||
70 | 70 | | |||
71 | /// reimplemented form KoDocument | 71 | KoOdf::DocumentType documentType() const; | ||
72 | virtual void paintContent(QPainter& painter, const QRect& rect); | | |||
73 | /// reimplemented form KoDocument | | |||
74 | virtual bool loadXML(const KoXmlDocument& document, KoStore *store); | | |||
75 | /// reimplemented form KoDocument | | |||
76 | virtual bool loadOdf(KoOdfReadStore & odfStore); | | |||
77 | /// reimplemented form KoDocument | | |||
78 | virtual bool completeLoading(KoStore* store); | | |||
79 | /// reimplemented form KoDocument | | |||
80 | virtual bool saveOdf(SavingContext &documentContext); | | |||
81 | 72 | | |||
82 | /// reimplemented from KoDocument | 73 | /// reimplemented from KoDocument | ||
83 | virtual QByteArray nativeFormatMimeType() const { return KARBON_MIME_TYPE; } | 74 | virtual QByteArray nativeFormatMimeType() const { return KARBON_MIME_TYPE; } | ||
84 | /// reimplemented from KoDocument | 75 | /// reimplemented from KoDocument | ||
85 | virtual QByteArray nativeOasisMimeType() const { return KARBON_MIME_TYPE; } | 76 | virtual QByteArray nativeOasisMimeType() const { return KARBON_MIME_TYPE; } | ||
86 | /// reimplemented from KoDocument | 77 | /// reimplemented from KoDocument | ||
87 | virtual QStringList extraNativeMimeTypes() const | 78 | virtual QStringList extraNativeMimeTypes() const | ||
88 | { | 79 | { | ||
89 | return QStringList() << "application/vnd.oasis.opendocument.graphics" | 80 | return QStringList() << "application/vnd.oasis.opendocument.graphics-template"; | ||
90 | << "application/vnd.oasis.opendocument.graphics-template"; | | |||
91 | } | 81 | } | ||
92 | 82 | | |||
93 | /// implemented from KoShapeController | | |||
94 | virtual void addShape(KoShape* shape); | | |||
95 | /// implemented from KoShapeController | | |||
96 | virtual void removeShape(KoShape* shape); | | |||
97 | | ||||
98 | /// Returns if status bar is shown | 83 | /// Returns if status bar is shown | ||
99 | bool showStatusBar() const; | 84 | bool showStatusBar() const; | ||
100 | /// Shows/hides status bar | 85 | /// Shows/hides status bar | ||
101 | void setShowStatusBar(bool b); | 86 | void setShowStatusBar(bool b); | ||
102 | /// update attached view(s) on the current doc settings | 87 | /// update attached view(s) on the current doc settings | ||
103 | /// at this time only the status bar is handled | 88 | /// at this time only the status bar is handled | ||
104 | void reorganizeGUI(); | 89 | void reorganizeGUI(); | ||
105 | 90 | | |||
106 | /// Returns maximum number of recent files | 91 | /// Returns maximum number of recent files | ||
107 | uint maxRecentFiles() const; | 92 | uint maxRecentFiles() const; | ||
108 | 93 | | |||
109 | /// Sets page layout of the document | | |||
110 | virtual void setPageLayout(const KoPageLayout& layout); | | |||
111 | | ||||
112 | bool mergeNativeFormat(const QString & file); | 94 | bool mergeNativeFormat(const QString & file); | ||
113 | 95 | | |||
114 | // merged from original KarbonDocument | | |||
115 | | ||||
116 | /** | | |||
117 | * Checks if specified layer can be raised. | | |||
118 | * | | |||
119 | * A layer can be raised if there is more than one layer and the specified layer | | |||
120 | * is not already at the top. | | |||
121 | * | | |||
122 | * @param layer the layer to check | | |||
123 | * @return true if layer can be raised, else false | | |||
124 | */ | | |||
125 | bool canRaiseLayer(KoShapeLayer* layer); | | |||
126 | | ||||
127 | /** | | |||
128 | * Checks if specified layer can be lowered. | | |||
129 | * | | |||
130 | * A layer can be lowered if there is more than one layer and the specified layer | | |||
131 | * is not already at the bottom. | | |||
132 | * | | |||
133 | * @param layer the layer to check | | |||
134 | * @return true if layer can be lowered, else false | | |||
135 | */ | | |||
136 | bool canLowerLayer(KoShapeLayer* layer); | | |||
137 | | ||||
138 | /** | | |||
139 | * Raises the layer. | | |||
140 | * | | |||
141 | * @param layer the layer to raise | | |||
142 | */ | | |||
143 | void raiseLayer(KoShapeLayer* layer); | | |||
144 | | ||||
145 | /** | | |||
146 | * Lowers the layer. | | |||
147 | * | | |||
148 | * @param layer the layer to lower | | |||
149 | */ | | |||
150 | void lowerLayer(KoShapeLayer* layer); | | |||
151 | | ||||
152 | /** | | |||
153 | * Returns the position of the specified layer. | | |||
154 | * | | |||
155 | * @param layer the layer to retrieve the position for | | |||
156 | * @return the layer position | | |||
157 | */ | | |||
158 | int layerPos(KoShapeLayer* layer); | | |||
159 | | ||||
160 | /** | | |||
161 | * Inserts a new layer. | | |||
162 | * | | |||
163 | * The layer is appended at the end, on top of all other layers, and is activated. | | |||
164 | * | | |||
165 | * @param layer the layer to insert | | |||
166 | */ | | |||
167 | void insertLayer(KoShapeLayer* layer); | | |||
168 | | ||||
169 | /** | | |||
170 | * Removes the layer. | | |||
171 | * | | |||
172 | * If there is no layer left, a new layer is created, inserted and activated. | | |||
173 | * | | |||
174 | * @param layer the layer to remove | | |||
175 | */ | | |||
176 | void removeLayer(KoShapeLayer* layer); | | |||
177 | | ||||
178 | /** | | |||
179 | * Returns the list of layers. | | |||
180 | * The layer list provides a hierarchical view/access of the document data. | | |||
181 | * All the documents shapes are children of a shape container, where a layer | | |||
182 | * resembles a root container which can contain other containers in an | | |||
183 | * arbitrary nesting depth. | | |||
184 | */ | | |||
185 | const QList<KoShapeLayer*> layers() const; | | |||
186 | | ||||
187 | /** | | |||
188 | * Returns the list of all shapes of the document. | | |||
189 | * This list provides a flat view/access to all the documents shapes. | | |||
190 | * For an hierarchical view/access one should retrieve the documents | | |||
191 | * layers with layers(). | | |||
192 | */ | | |||
193 | const QList<KoShape*> shapes() const; | | |||
194 | | ||||
195 | void saveOasis(KoShapeSavingContext & context) const; | | |||
196 | bool loadOasis(const KoXmlElement &element, KoShapeLoadingContext &context); | | |||
197 | void loadOdfStyles(KoShapeLoadingContext & context); | | |||
198 | void saveOdfStyles(KoShapeSavingContext & context); | | |||
199 | | ||||
200 | /** | | |||
201 | * Adds an object to the document. | | |||
202 | * | | |||
203 | * @param shape the object to append | | |||
204 | */ | | |||
205 | void add(KoShape* shape); | | |||
206 | | ||||
207 | /** | | |||
208 | * Removes an object from the document. | | |||
209 | * | | |||
210 | * @param shape the object to append | | |||
211 | */ | | |||
212 | void remove(KoShape* shape); | | |||
213 | | ||||
214 | /// Returns the united bounding rectangle of the documents content and the document page | | |||
215 | QRectF boundingRect() const; | | |||
216 | | ||||
217 | /// Returns the bounding rectangle of the documents content | | |||
218 | QRectF contentRect() const; | | |||
219 | | ||||
220 | /// Returns the documents page size | | |||
221 | QSizeF pageSize() const; | | |||
222 | | ||||
223 | /// Sets given page size to all attached views/canvases | | |||
224 | void setPageSize(const QSizeF &pageSize); | | |||
225 | | ||||
226 | /// Sets the documents page size | | |||
227 | //void setDocumentPageSize(QSizeF pageSize); | | |||
228 | | ||||
229 | /// Returns the documents image collection | | |||
230 | KoImageCollection * imageCollection(); | | |||
231 | | ||||
232 | /// Returns the documents data centers | | |||
233 | QMap<QString, KoDataCenterBase*> dataCenterMap() const; | | |||
234 | | ||||
235 | /// Sets the data centers to be used by this document | | |||
236 | void useExternalDataCenterMap(const QMap<QString, KoDataCenterBase*> &dataCenters); | | |||
237 | | ||||
238 | void addToDataCenterMap(const QString &key, KoDataCenterBase* dataCenter); | | |||
239 | | ||||
240 | public Q_SLOTS: | 96 | public Q_SLOTS: | ||
241 | void slotDocumentRestored(); | 97 | void slotDocumentRestored(); | ||
242 | 98 | | |||
243 | Q_SIGNALS: | 99 | Q_SIGNALS: | ||
244 | void shapeCountChanged(); | | |||
245 | void applyCanvasConfiguration(KarbonCanvas *canvas); | 100 | void applyCanvasConfiguration(KarbonCanvas *canvas); | ||
246 | 101 | | |||
247 | protected: | 102 | protected: | ||
248 | 103 | virtual const char *odfTagName(bool withNamespace); | |||
249 | /// Loads settings like grid and guide lines from given xml document | | |||
250 | void loadOasisSettings(const KoXmlDocument & settingsDoc); | | |||
251 | /// Saves settings like grid and guide lines to store | | |||
252 | void saveOasisSettings(KoStore * store); | | |||
253 | | ||||
254 | /// Reads settings from config file | 104 | /// Reads settings from config file | ||
255 | void initConfig(); | 105 | void initConfig(); | ||
256 | 106 | | |||
257 | 107 | | |||
258 | private: | 108 | private: | ||
259 | class Private; | 109 | class Private; | ||
260 | Private * const d; | 110 | Private * const d; | ||
261 | }; | 111 | }; | ||
262 | 112 | | |||
263 | #endif // KARBON_DOCUMENT_H | 113 | #endif // KARBON_DOCUMENT_H | ||
264 | 114 | |