1 | /* This file is part of the KDE project |
2 | Copyright 2010 Marijn Kruisselbrink <mkruisselbrink@kde.org> |
3 | Copyright 2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net> |
4 | Copyright 1998,1999 Torben Weis <weis@kde.org> |
5 | Copyright 1999-2007 The KSpread Team <calligra-devel@kde.org> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef CALLIGRA_SHEETS_SHEET |
24 | #define CALLIGRA_SHEETS_SHEET |
25 | |
26 | #include <QClipboard> |
27 | #include <QHash> |
28 | #include <QList> |
29 | #include <QRect> |
30 | |
31 | #include <KoDocument.h> |
32 | #include <KoOasisSettings.h> // for KoOasisSettings::NamedMap |
33 | #include <KoShapeBasedDocumentBase.h> |
34 | #include <KoShapeUserData.h> |
35 | #include <KoXmlReader.h> |
36 | |
37 | #include "Cell.h" |
38 | #include "Style.h" |
39 | #include "Global.h" |
40 | #include "ProtectableObject.h" |
41 | #include "calligra_sheets_limits.h" |
42 | |
43 | class QAbstractItemModel; |
44 | class QDomElement; |
45 | class KUndo2Command; |
46 | class QWidget; |
47 | |
48 | class KoDataCenterBase; |
49 | class KoDocumentEntry; |
50 | class KoStyleStack; |
51 | class KoGenStyles; |
52 | class KoOasisSettings; |
53 | class KoOdfStylesReader; |
54 | class KoShape; |
55 | class KoShapeSavingContext; |
56 | class KoXmlWriter; |
57 | |
58 | namespace Calligra |
59 | { |
60 | namespace Sheets |
61 | { |
62 | class Cell; |
63 | class CellStorage; |
64 | class ColumnFormat; |
65 | class ; |
66 | class ConditionsStorage; |
67 | class FormulaStorage; |
68 | class DocBase; |
69 | class FusionStorage; |
70 | class LinkStorage; |
71 | class ; |
72 | class Map; |
73 | class OdfLoadingContext; |
74 | class OdfSavingContext; |
75 | class PrintSettings; |
76 | class Region; |
77 | class RowFormat; |
78 | class RowFormatStorage; |
79 | class Sheet; |
80 | class SheetPrint; |
81 | class Style; |
82 | class StyleStorage; |
83 | class Validity; |
84 | class ValidityStorage; |
85 | class ValueStorage; |
86 | class View; |
87 | class SheetTest; |
88 | template<typename T> class IntervalMap; |
89 | |
90 | /** |
91 | * A sheet contains several cells. |
92 | */ |
93 | class CALLIGRA_SHEETS_ODF_EXPORT Sheet : public KoShapeUserData, public KoShapeBasedDocumentBase, |
94 | public ProtectableObject |
95 | { |
96 | Q_OBJECT |
97 | Q_PROPERTY(QString sheetName READ sheetName) |
98 | Q_PROPERTY(bool autoCalc READ isAutoCalculationEnabled WRITE setAutoCalculationEnabled) |
99 | Q_PROPERTY(bool showGrid READ getShowGrid WRITE setShowGrid) |
100 | |
101 | public: |
102 | enum ChangeRef { ColumnInsert, ColumnRemove, RowInsert, RowRemove }; |
103 | enum TestType { Text, Validity, , ConditionalCellAttribute }; |
104 | |
105 | /** |
106 | * Creates a sheet in \p map with the name \p sheetName. |
107 | */ |
108 | Sheet(Map* map, const QString& sheetName); |
109 | |
110 | /** |
111 | * Copy constructor. |
112 | * Creates a sheet with the contents and the settings of \p other. |
113 | */ |
114 | Sheet(const Sheet& other); |
115 | |
116 | /** |
117 | * Destructor. |
118 | */ |
119 | ~Sheet(); |
120 | |
121 | /** |
122 | * \return a model for this sheet |
123 | */ |
124 | QAbstractItemModel *model() const; |
125 | |
126 | /** |
127 | * \return the map this sheet belongs to |
128 | */ |
129 | Map* map() const; |
130 | |
131 | /** |
132 | * \return the document this sheet belongs to |
133 | */ |
134 | DocBase* doc() const; |
135 | |
136 | // KoShapeBasedDocumentBase interface |
137 | virtual void addShape(KoShape* shape); |
138 | virtual void removeShape(KoShape* shape); |
139 | virtual KoDocumentResourceManager* resourceManager() const; |
140 | |
141 | /** |
142 | * Deletes all shapes without emitting shapeRemoved() |
143 | */ |
144 | void deleteShapes(); |
145 | |
146 | /** |
147 | * \ingroup Embedding |
148 | * Returns the sheet's shapes. |
149 | * \return the shapes this sheet contains |
150 | */ |
151 | QList<KoShape*> shapes() const; |
152 | |
153 | ////////////////////////////////////////////////////////////////////////// |
154 | // |
155 | //BEGIN Methods related to sheet properties |
156 | // |
157 | |
158 | /** |
159 | * \return the name of this sheet |
160 | */ |
161 | QString sheetName() const; |
162 | |
163 | /** |
164 | * Renames a sheet. This will automatically adapt all formulas |
165 | * in all sheets and all cells to reflect the new name. |
166 | * |
167 | * If the name really changed then sig_nameChanged is emitted |
168 | * and the GUI will reflect the change. |
169 | * |
170 | * @param name The new sheet name. |
171 | * @param init If set to true then no formula will be changed and no signal |
172 | * will be emitted and no undo action created. Usually you do not |
173 | * want to do that. |
174 | * |
175 | * @return @c true if the sheet was renamed successfully |
176 | * @return @c false if the sheet could not be renamed. Usually the reason is |
177 | * that this name is already used. |
178 | * |
179 | * @see changeCellTabName |
180 | * @see TabBar::renameTab |
181 | * @see sheetName |
182 | */ |
183 | bool setSheetName(const QString& name, bool init = false); |
184 | |
185 | /** |
186 | * \return \c true , if a document is currently loading |
187 | */ |
188 | bool isLoading(); |
189 | |
190 | /** |
191 | * Returns the layout direction of the sheet. |
192 | */ |
193 | Qt::LayoutDirection layoutDirection() const; |
194 | |
195 | /** |
196 | * Sets the layout direction of the sheet. For example, for Arabic or Hebrew |
197 | * documents, it is possibly to layout the sheet from right to left. |
198 | */ |
199 | void setLayoutDirection(Qt::LayoutDirection dir); |
200 | |
201 | /** |
202 | * Returns, if the grid shall be shown on the screen |
203 | */ |
204 | bool getShowGrid() const; |
205 | |
206 | /** |
207 | * Sets, if the grid shall be shown on the screen |
208 | */ |
209 | void setShowGrid(bool _showGrid); |
210 | |
211 | /** |
212 | * Sets, if formula shall be shown instead of the result |
213 | */ |
214 | bool getShowFormula() const; |
215 | |
216 | void setShowFormula(bool _showFormula); |
217 | |
218 | /** |
219 | * Sets, if indicator must be shown when the cell holds a formula |
220 | */ |
221 | bool getShowFormulaIndicator() const; |
222 | |
223 | void setShowFormulaIndicator(bool _showFormulaIndicator); |
224 | |
225 | /** |
226 | * Returns true if comment indicator is visible. |
227 | */ |
228 | bool () const; |
229 | |
230 | /** |
231 | * If b is true, comment indicator is visible, otherwise |
232 | * it will be hidden. |
233 | */ |
234 | void (bool b); |
235 | |
236 | bool getLcMode() const; |
237 | |
238 | void setLcMode(bool _lcMode); |
239 | |
240 | bool isAutoCalculationEnabled() const; |
241 | |
242 | void setAutoCalculationEnabled(bool enable); |
243 | |
244 | bool getShowColumnNumber() const; |
245 | |
246 | void setShowColumnNumber(bool _showColumnNumber); |
247 | |
248 | bool getHideZero() const; |
249 | |
250 | void setHideZero(bool _hideZero); |
251 | |
252 | bool getFirstLetterUpper() const; |
253 | |
254 | void setFirstLetterUpper(bool _firstUpper); |
255 | |
256 | /** |
257 | * @return true if this sheet is hidden |
258 | */ |
259 | bool isHidden()const; |
260 | |
261 | /** |
262 | * Hides or shows this sheets |
263 | */ |
264 | void setHidden(bool hidden); |
265 | |
266 | /** |
267 | * @return a flag that indicates whether the sheet should paint the page breaks. |
268 | * |
269 | * @see setShowPageOutline |
270 | * @see Sheet::Private::showPageOutline |
271 | */ |
272 | bool isShowPageOutline() const; |
273 | |
274 | /** |
275 | * Turns the page break lines on or off. |
276 | * |
277 | * @see isShowPageOutline |
278 | * @see Sheet::Private::showPageOutline |
279 | */ |
280 | void setShowPageOutline(bool _b); |
281 | |
282 | struct BackgroundImageProperties { |
283 | BackgroundImageProperties() |
284 | : repeat(Repeat) |
285 | , opacity(1.0) |
286 | , horizontalPosition(HorizontalCenter) |
287 | , verticalPosition(VerticalCenter) |
288 | {} |
289 | |
290 | enum Repetition { |
291 | NoRepeat, |
292 | Repeat, |
293 | Stretch |
294 | }; |
295 | Repetition repeat; |
296 | |
297 | float opacity; |
298 | |
299 | enum HorizontalPosition { |
300 | Left, |
301 | HorizontalCenter, |
302 | Right |
303 | }; |
304 | HorizontalPosition horizontalPosition; |
305 | |
306 | enum VerticalPosition { |
307 | Top, |
308 | VerticalCenter, |
309 | Bottom |
310 | }; |
311 | VerticalPosition verticalPosition; |
312 | |
313 | //TODO filterName |
314 | }; |
315 | |
316 | /** |
317 | * Set background image for this sheet |
318 | */ |
319 | void setBackgroundImage( const QImage& image ); |
320 | |
321 | /** |
322 | * @return The QImage used as the background picture for this sheet |
323 | */ |
324 | QImage backgroundImage() const; |
325 | |
326 | void setBackgroundImageProperties( const BackgroundImageProperties& properties ); |
327 | |
328 | BackgroundImageProperties backgroundImageProperties() const; |
329 | |
330 | // |
331 | //END Methods related to sheet properties |
332 | // |
333 | ////////////////////////////////////////////////////////////////////////// |
334 | // |
335 | //BEGIN Methods related to KSpread's old file format |
336 | // |
337 | |
338 | /** |
339 | * \ingroup NativeFormat |
340 | * Saves the sheet and all it's children in XML format |
341 | */ |
342 | QDomElement saveXML(QDomDocument&); |
343 | |
344 | /** |
345 | * \ingroup NativeFormat |
346 | * Loads the sheet and all it's children in XML format |
347 | */ |
348 | bool loadXML(const KoXmlElement&); |
349 | |
350 | /** |
351 | * \ingroup NativeFormat |
352 | * Loads a children |
353 | */ |
354 | bool loadChildren(KoStore* _store); |
355 | |
356 | // |
357 | //END Methods related to KSpread's old file format |
358 | // |
359 | ////////////////////////////////////////////////////////////////////////// |
360 | // |
361 | //BEGIN Methods related to the OpenDocument file format |
362 | // |
363 | |
364 | /** |
365 | * \ingroup OpenDocument |
366 | */ |
367 | bool loadOdf(const KoXmlElement& sheet, |
368 | OdfLoadingContext& odfContext, |
369 | const Styles& autoStyles, |
370 | const QHash<QString, Conditions>& conditionalStyles); |
371 | |
372 | /** |
373 | * \ingroup OpenDocument |
374 | */ |
375 | bool saveOdf(OdfSavingContext& tableContext); |
376 | |
377 | /** |
378 | * \ingroup OpenDocument |
379 | */ |
380 | void (KoXmlWriter &xmlWriter) const; |
381 | |
382 | /** |
383 | * \ingroup OpenDocument |
384 | */ |
385 | void saveOdfBackgroundImage(KoXmlWriter& xmlWriter) const; |
386 | |
387 | /** |
388 | * \ingroup OpenDocument |
389 | */ |
390 | void loadOdfSettings(const KoOasisSettings::NamedMap &settings); |
391 | |
392 | /** |
393 | * \ingroup OpenDocument |
394 | */ |
395 | void saveOdfSettings(KoXmlWriter &settingsWriter) const; |
396 | |
397 | void loadOdfObject(const KoXmlElement& element, KoShapeLoadingContext& shapeContext); |
398 | // |
399 | //END Methods related to the OpenDocument file format |
400 | // |
401 | ////////////////////////////////////////////////////////////////////////// |
402 | // |
403 | //BEGIN Methods related to row formats |
404 | // |
405 | |
406 | /** |
407 | * \ingroup ColumnRowFormat |
408 | * \return the row format storage for this sheet. |
409 | */ |
410 | const RowFormatStorage* rowFormats() const; |
411 | RowFormatStorage* rowFormats(); |
412 | |
413 | // |
414 | //END Methods related to row formats |
415 | // |
416 | ////////////////////////////////////////////////////////////////////////// |
417 | // |
418 | //BEGIN Methods related to column formats |
419 | // |
420 | |
421 | /** |
422 | * \ingroup ColumnRowFormat |
423 | * \return the column format of column \p _column . The default column format, |
424 | * if no special one exists. |
425 | */ |
426 | const ColumnFormat* columnFormat(int _column) const; |
427 | |
428 | /** |
429 | * \ingroup ColumnRowFormat |
430 | * If no special ColumnFormat exists for this column, then a new one is created. |
431 | * |
432 | * @return a non default ColumnFormat for this column. |
433 | */ |
434 | ColumnFormat* nonDefaultColumnFormat(int _column, bool force_creation = true); |
435 | |
436 | /** |
437 | * \ingroup ColumnRowFormat |
438 | * \return the first non-default row format |
439 | */ |
440 | ColumnFormat* firstCol() const; |
441 | |
442 | /** |
443 | * \ingroup ColumnRowFormat |
444 | */ |
445 | void setDefaultWidth(double width); |
446 | |
447 | // |
448 | //END Methods related to column formats |
449 | // |
450 | ////////////////////////////////////////////////////////////////////////// |
451 | // |
452 | //BEGIN Methods for Storage access |
453 | // |
454 | |
455 | /** |
456 | * \ingroup Storage |
457 | * \return the cell storage |
458 | */ |
459 | CellStorage* cellStorage() const; |
460 | |
461 | const CommentStorage* () const; |
462 | const ConditionsStorage* conditionsStorage() const; |
463 | const FormulaStorage* formulaStorage() const; |
464 | const FusionStorage* fusionStorage() const; |
465 | const LinkStorage* linkStorage() const; |
466 | const StyleStorage* styleStorage() const; |
467 | const ValidityStorage* validityStorage() const; |
468 | const ValueStorage* valueStorage() const; |
469 | |
470 | /** |
471 | * \ingroup Coordinates |
472 | * \ingroup Storage |
473 | * Determines the used area, i.e. the area spanning from A1 to the maximum |
474 | * occupied column and row. |
475 | * \return the used area |
476 | */ |
477 | QRect usedArea(bool onlyContent = false) const; |
478 | |
479 | // |
480 | //END Methods for Storage access |
481 | // |
482 | ////////////////////////////////////////////////////////////////////////// |
483 | // |
484 | //BEGIN UNSORTED METHODS !!! |
485 | // |
486 | |
487 | /** |
488 | * \ingroup Coordinates |
489 | * Determines the row for a given position \p _ypos . If the position is |
490 | * on the border between two cells, the upper row is returned. Also, the offset |
491 | * between the coordinate system root and the upper row border is determined. |
492 | * |
493 | * \param _ypos the position for which the row should be determined |
494 | * \param _top the offset between the coordinate system root and the upper row border |
495 | * |
496 | * \return the row for the given position \p _ypos |
497 | */ |
498 | int topRow(qreal _ypos, qreal &_top) const; |
499 | |
500 | /** |
501 | * \ingroup Coordinates |
502 | * Determines the row for a given position \p _ypos . If the position is |
503 | * on the border between two cells, the lower row is returned. |
504 | * |
505 | * \param _ypos the position for which the row should be determined |
506 | * |
507 | * \return the row for the given position \p _ypos |
508 | */ |
509 | int bottomRow(double _ypos) const; |
510 | |
511 | /** |
512 | * \ingroup Coordinates |
513 | * Determines the column for a given position \p _xpos . If the position is |
514 | * on the border between two cells, the left column is returned. Also, the offset |
515 | * between the coordinate system root and the left column border is determined. |
516 | * |
517 | * \param _xpos the position for which the column should be determined |
518 | * \param _left the offset between the coordinate system root and the left column border |
519 | * |
520 | * \return the column for the given position \p _xpos |
521 | */ |
522 | int leftColumn(qreal _xpos, qreal &_left) const; |
523 | |
524 | /** |
525 | * \ingroup Coordinates |
526 | * Determines the column for a given position \p _xpos . If the position is |
527 | * on the border between two cells, the right column is returned. |
528 | * |
529 | * \param _xpos the position for which the column should be determined |
530 | * |
531 | * \return the column for the given position \p _xpos |
532 | */ |
533 | int rightColumn(double _xpos) const; |
534 | |
535 | /** |
536 | * \ingroup Coordinates |
537 | * Calculates the region in document coordinates occupied by a range of cells. |
538 | * \param cellRange the range of cells |
539 | * \return the document area covered by the cells |
540 | */ |
541 | QRectF cellCoordinatesToDocument(const QRect& cellRange) const; |
542 | |
543 | /** |
544 | * \ingroup Coordinates |
545 | * Calculates the cell range covering a document area. |
546 | * \param area the document area |
547 | * \return the cell range covering the area |
548 | */ |
549 | QRect documentToCellCoordinates(const QRectF& area) const; |
550 | |
551 | /** |
552 | * \ingroup Coordinates |
553 | * @return the left corner of the column as double. |
554 | * Use this method, when you later calculate other positions depending on this one |
555 | * to avoid rounding problems |
556 | * @param col the column's index |
557 | */ |
558 | double columnPosition(int col) const; |
559 | |
560 | /** |
561 | * \ingroup Coordinates |
562 | * @return the top corner of the row as double. |
563 | * Use this method, when you later calculate other positions depending on this one |
564 | * to avoid rounding problems |
565 | * @param _row the row's index |
566 | */ |
567 | double rowPosition(int _row) const; |
568 | |
569 | /** |
570 | * \ingroup Coordinates |
571 | * \return the document size |
572 | */ |
573 | QSizeF documentSize() const; |
574 | |
575 | /** |
576 | * \ingroup Coordinates |
577 | * Adjusts the internal reference of the sum of the widths of all columns. |
578 | * Used in resizing of columns. |
579 | */ |
580 | void adjustDocumentWidth(double deltaWidth); |
581 | |
582 | /** |
583 | * \ingroup Coordinates |
584 | * Adjusts the internal reference of the sum of the heights of all rows. |
585 | * Used in resizing of rows. |
586 | */ |
587 | void adjustDocumentHeight(double deltaHeight); |
588 | |
589 | /** |
590 | * Adjusts the position of cell anchored shapes as a result of a column size change/insertion/removal. |
591 | * All cell anchored shapes with x coordinates >= minX and < maxX will be moved by delta. |
592 | */ |
593 | void adjustCellAnchoredShapesX(qreal minX, qreal maxX, qreal delta); |
594 | void adjustCellAnchoredShapesX(qreal delta, int firstCol, int lastCol = KS_colMax); |
595 | |
596 | /** |
597 | * Adjusts the position of cell anchored shapes as a result of a row size change/insertion/removal. |
598 | * All cell anchored shapes with y coordinates >= minY and < maxY will be moved by delta. |
599 | */ |
600 | void adjustCellAnchoredShapesY(qreal minY, qreal maxY, qreal delta); |
601 | void adjustCellAnchoredShapesY(qreal delta, int firstRow, int lastRow = KS_rowMax); |
602 | |
603 | // |
604 | //END UNSORTED METHODS |
605 | // |
606 | ////////////////////////////////////////////////////////////////////////// |
607 | // |
608 | //BEGIN Methods related to manipulations of selected cells |
609 | // |
610 | |
611 | /** |
612 | * \ingroup Commands |
613 | */ |
614 | bool areaIsEmpty(const Region& area, TestType _type = Text) ; |
615 | |
616 | // |
617 | //END Methods related to manipulations of selected cells |
618 | // |
619 | ////////////////////////////////////////////////////////////////////////// |
620 | // |
621 | //BEGIN Methods related to column/row operations |
622 | // |
623 | |
624 | /** |
625 | * \ingroup Commands |
626 | * Helper method. |
627 | * \see ShiftManipulator |
628 | */ |
629 | void insertShiftRight(const QRect& rect); |
630 | |
631 | /** |
632 | * \ingroup Commands |
633 | * Helper method. |
634 | * \see ShiftManipulator |
635 | */ |
636 | void insertShiftDown(const QRect& rect); |
637 | |
638 | /** |
639 | * \ingroup Commands |
640 | * Helper method. |
641 | * \see ShiftManipulator |
642 | */ |
643 | void removeShiftUp(const QRect& rect); |
644 | |
645 | /** |
646 | * \ingroup Commands |
647 | * Helper method. |
648 | * \see ShiftManipulator |
649 | */ |
650 | void removeShiftLeft(const QRect& rect); |
651 | |
652 | /** |
653 | * \ingroup ColumnRowFormat |
654 | * Helper method. |
655 | * \see InsertDeleteColumnManipulator |
656 | * Moves all columns which are >= \p col \p number positions to the right |
657 | * and inserts a new and empty column. |
658 | */ |
659 | void insertColumns(int row, int numbers); |
660 | |
661 | /** |
662 | * Helper method. |
663 | * \see InsertDeleteRowManipulator |
664 | * Moves all rows which are >= \p row \p number positions down |
665 | * and inserts a new and empty row. |
666 | */ |
667 | void insertRows(int row, int numbers); |
668 | |
669 | /** |
670 | * \ingroup ColumnRowFormat |
671 | * Helper method. |
672 | * \see InsertDeleteColumnManipulator |
673 | * Deletes \p number columns beginning at \p col . |
674 | */ |
675 | void removeColumns(int row, int numbers); |
676 | |
677 | /** |
678 | * \ingroup ColumnRowFormat |
679 | * Helper method. |
680 | * \see InsertDeleteRowManipulator |
681 | * Deletes \p number rows beginning at \p row . |
682 | */ |
683 | void removeRows(int row, int number); |
684 | |
685 | // |
686 | //END Methods related column/row operations |
687 | // |
688 | ////////////////////////////////////////////////////////////////////////// |
689 | // |
690 | //BEGIN UNSORTED METHODS !!! |
691 | // |
692 | |
693 | void hideSheet(bool _hide); |
694 | |
695 | /** |
696 | * \ingroup Value |
697 | * Change name of reference when the user inserts or removes a column, |
698 | * a row or a cell (= insertion of a row [or column] on a single column [or row]). |
699 | * For example the formula =Sheet1!A1 is changed into =Sheet1!B1 if a Column |
700 | * is inserted before A. |
701 | * |
702 | * @param pos the point of insertion (only one coordinate may be used, depending |
703 | * on the other parameters). |
704 | * @param fullRowOrColumn if true, a whole row or column has been inserted/removed. |
705 | * if false, we inserted or removed a cell |
706 | * @param ref see ChangeRef |
707 | * @param sheetName completes the pos specification by giving the sheet name |
708 | * @param number number of columns which were inserted |
709 | */ |
710 | void changeNameCellRef(const QPoint& pos, bool fullRowOrColumn, ChangeRef ref, |
711 | const QString& sheetName, int number); |
712 | |
713 | /** |
714 | * \ingroup ColumnRowFormat |
715 | * Insert the non-default column format \p columnFormat. |
716 | */ |
717 | void insertColumnFormat(ColumnFormat* columnFormat); |
718 | |
719 | /** |
720 | * \ingroup ColumnRowFormat |
721 | * Inserts the non-default row format \p rowFormat. |
722 | */ |
723 | void insertRowFormat(RowFormat* rowFormat); |
724 | |
725 | /** |
726 | * \ingroup ColumnRowFormat |
727 | * Deletes the column format at \p column. |
728 | */ |
729 | void deleteColumnFormat(int column); |
730 | |
731 | /** |
732 | * \ingroup ColumnRowFormat |
733 | * Deletes the row format at \p row (changes the format of that row to be the default format). |
734 | */ |
735 | void deleteRowFormat(int row); |
736 | |
737 | // |
738 | //END UNSORTED METHODS |
739 | // |
740 | ////////////////////////////////////////////////////////////////////////// |
741 | // |
742 | //BEGIN UNSORTED METHODS !!! |
743 | // |
744 | |
745 | /** |
746 | * Shows a status \p message in the status bar for \p timeout msecs. |
747 | */ |
748 | void showStatusMessage(const QString &message, int timeout = 3000); |
749 | |
750 | void updateLocale(); |
751 | |
752 | |
753 | /** |
754 | * \ingroup Page |
755 | * The page layout manager. |
756 | */ |
757 | SheetPrint *print() const; |
758 | |
759 | /** |
760 | * \ingroup Page |
761 | * Print settings. |
762 | */ |
763 | PrintSettings* printSettings() const; |
764 | |
765 | /** |
766 | * \ingroup Page |
767 | * Sets the print settings. |
768 | */ |
769 | void setPrintSettings(const PrintSettings& settings); |
770 | |
771 | /** |
772 | * \ingroup Page |
773 | * \return the header & footer object |
774 | */ |
775 | HeaderFooter *() const; |
776 | |
777 | /** |
778 | * Applies a database filter. |
779 | */ |
780 | void applyDatabaseFilter(const Database& database); |
781 | #ifndef NDEBUG |
782 | void printDebug(); |
783 | #endif |
784 | |
785 | // |
786 | //END UNSORTED METHODS |
787 | // |
788 | ////////////////////////////////////////////////////////////////////////// |
789 | |
790 | signals: |
791 | /** |
792 | * Emitted, if the document size changed. |
793 | * E.g. if some columns were inserted. |
794 | * \param size new size |
795 | */ |
796 | void documentSizeChanged(const QSizeF &size); |
797 | |
798 | /** |
799 | * Emitted, if the visible size changed. |
800 | * E.g. if the document size changed or the user selected an area, |
801 | * which was not visible before. |
802 | */ |
803 | void visibleSizeChanged(); |
804 | |
805 | /** |
806 | * Emitted, if a status \p message should be shown in the status bar |
807 | * for \p timeout msecs. |
808 | */ |
809 | void statusMessage(const QString& message, int timeout); |
810 | |
811 | /** |
812 | * \ingroup Embedding |
813 | * Emitted, if a \p shape was added. |
814 | * \param sheet this sheet (for the View to determine, if it's the active one) |
815 | */ |
816 | void shapeAdded(Sheet *sheet, KoShape *shape); |
817 | |
818 | /** |
819 | * \ingroup Embedding |
820 | * Emitted, if a \p shape was removed. |
821 | * \param sheet this sheet (for the View to determine, if it's the active one) |
822 | */ |
823 | void shapeRemoved(Sheet *sheet, KoShape *shape); |
824 | |
825 | protected: |
826 | /** |
827 | * \ingroup Value |
828 | * Change the name of a sheet in all formulas. |
829 | * When you change name sheet Sheet1 -> Price |
830 | * for all cell which refere to Sheet1, this function changes the name. |
831 | */ |
832 | void changeCellTabName(QString const & old_name, QString const & new_name); |
833 | |
834 | // |
835 | ////////////////////////////////////////////////////////////////////////// |
836 | // |
837 | //BEGIN Methods related to the OpenDocument file format |
838 | // |
839 | |
840 | void loadColumnNodes(const KoXmlElement& parent, int& indexCol, |
841 | int& maxColumn, KoOdfLoadingContext& odfContext, |
842 | QHash<QString, QRegion>& columnStyleRegions, |
843 | IntervalMap<QString>& columnStyles); |
844 | void loadRowNodes(const KoXmlElement& parent, int& rowIndex, |
845 | int& maxColumn, OdfLoadingContext& tableContext, |
846 | QHash<QString, QRegion>& rowStyleRegions, |
847 | QHash<QString, QRegion>& cellStyleRegions, |
848 | const IntervalMap<QString>& columnStyles, |
849 | const Styles& autoStyles, |
850 | QList<ShapeLoadingData>& shapeData); |
851 | |
852 | /** |
853 | * \ingroup OpenDocument |
854 | */ |
855 | int loadRowFormat(const KoXmlElement& row, int &rowIndex, |
856 | OdfLoadingContext& odfContext, |
857 | QHash<QString, QRegion>& rowStyleRegions, |
858 | QHash<QString, QRegion>& cellStyleRegions, |
859 | const IntervalMap<QString>& columnStyles, |
860 | const Styles& autoStyles, |
861 | QList<ShapeLoadingData>& shapeData); |
862 | |
863 | /** |
864 | * \ingroup OpenDocument |
865 | * Loads the properties of a column from a table:table-column element in an OASIS XML file |
866 | * defaultColumnCellStyles is a map from column indicies to the default cell style for that column |
867 | */ |
868 | bool loadColumnFormat(const KoXmlElement& row, |
869 | const KoOdfStylesReader& stylesReader, int & indexCol, |
870 | QHash<QString, QRegion>& columnStyleRegions, |
871 | IntervalMap<QString>& columnStyles); |
872 | |
873 | /** |
874 | * \ingroup OpenDocument |
875 | * Inserts the styles contained in \p styleRegions into the style storage. |
876 | * Looks automatic styles up in the map of preloaded automatic styles, |
877 | * \p autoStyles , and custom styles in the StyleManager. |
878 | * The region is restricted to \p usedArea . |
879 | */ |
880 | void loadOdfInsertStyles(const Styles& autoStyles, |
881 | const QHash<QString, QRegion>& styleRegions, |
882 | const QHash<QString, Conditions>& conditionalStyles, |
883 | const QRect& usedArea, |
884 | QList<QPair<QRegion, Style> >& outStyleRegions, |
885 | QList<QPair<QRegion, Conditions> >& outConditionalStyles); |
886 | |
887 | /** |
888 | * \ingroup OpenDocument |
889 | */ |
890 | bool loadSheetStyleFormat(KoXmlElement *style); |
891 | |
892 | /** |
893 | * \ingroup OpenDocument |
894 | */ |
895 | void loadOdfMasterLayoutPage(KoStyleStack &styleStack); |
896 | |
897 | /** |
898 | * \ingroup OpenDocument |
899 | */ |
900 | QString saveOdfSheetStyleName(KoGenStyles &mainStyles); |
901 | |
902 | /** |
903 | * \ingroup OpenDocument |
904 | */ |
905 | void saveOdfColRowCell(int maxCols, int maxRows, OdfSavingContext& tableContext); |
906 | |
907 | /** |
908 | * \ingroup OpenDocument |
909 | */ |
910 | void saveOdfCells(int row, int maxCols, OdfSavingContext& tableContext); |
911 | |
912 | /** |
913 | * \ingroup OpenDocument |
914 | */ |
915 | void convertPart(const QString & part, KoXmlWriter & writer) const; |
916 | |
917 | /** |
918 | * \ingroup OpenDocument |
919 | */ |
920 | void addText(const QString & text, KoXmlWriter & writer) const; |
921 | |
922 | /** |
923 | * \ingroup OpenDocument |
924 | */ |
925 | bool compareRows(int row1, int row2, int maxCols, OdfSavingContext& tableContext) const; |
926 | |
927 | /** |
928 | * \ingroup OpenDocument |
929 | */ |
930 | QString getPart(const KoXmlNode & part); |
931 | |
932 | /** |
933 | * \ingroup OpenDocument |
934 | */ |
935 | void replaceMacro(QString & text, const QString & old, const QString & newS); |
936 | |
937 | // |
938 | //END Methods related to the OpenDocument file format |
939 | // |
940 | ////////////////////////////////////////////////////////////////////////// |
941 | // |
942 | |
943 | /** |
944 | * \ingroup Commands |
945 | * \see areaIsEmpty() |
946 | */ |
947 | bool cellIsEmpty(const Cell& cell, TestType _type); |
948 | |
949 | /** |
950 | * \ingroup Value |
951 | * \see changeNameCellRef() |
952 | */ |
953 | QString changeNameCellRefHelper(const QPoint& pos, bool fullRowOrColumn, ChangeRef ref, |
954 | int NbCol, const QPoint& point, bool isColumnFixed, |
955 | bool isRowFixed); |
956 | QString changeNameCellRefHelper(const QPoint& pos, const QRect& rect, bool fullRowOrColumn, ChangeRef ref, |
957 | int NbCol, const QPoint& point, bool isColumnFixed, |
958 | bool isRowFixed); |
959 | |
960 | private: |
961 | /** |
962 | * \ingroup NativeFormat |
963 | */ |
964 | void convertObscuringBorders(); |
965 | |
966 | /** |
967 | * \ingroup NativeFormat |
968 | */ |
969 | void checkContentDirection(QString const & name); |
970 | |
971 | // disable assignment operator |
972 | void operator=(const Sheet& other); |
973 | |
974 | friend class SheetTest; |
975 | |
976 | class Private; |
977 | Private * const d; |
978 | }; |
979 | |
980 | } // namespace Sheets |
981 | } // namespace Calligra |
982 | |
983 | #endif // CALLIGRA_SHEETS_SHEET |
984 | |