File indexing completed on 2024-05-12 16:35:39

0001 /* This file is part of the KDE project
0002    Copyright 1998-2016 The Calligra Team <calligra-devel@kde.org>
0003    Copyright 2016 Tomas Mecir <mecirt@gmail.com>
0004    Copyright 2010 Marijn Kruisselbrink <mkruisselbrink@kde.org>
0005    Copyright 2007 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
0006    Copyright 2007 Thorsten Zachmann <zachmann@kde.org>
0007    Copyright 2005-2006 Inge Wallin <inge@lysator.liu.se>
0008    Copyright 2004 Ariya Hidayat <ariya@kde.org>
0009    Copyright 2002-2003 Norbert Andres <nandres@web.de>
0010    Copyright 2000-2002 Laurent Montel <montel@kde.org>
0011    Copyright 2002 John Dailey <dailey@vt.edu>
0012    Copyright 2002 Phillip Mueller <philipp.mueller@gmx.de>
0013    Copyright 2000 Werner Trobin <trobin@kde.org>
0014    Copyright 1999-2000 Simon Hausmann <hausmann@kde.org>
0015    Copyright 1999 David Faure <faure@kde.org>
0016    Copyright 1998-2000 Torben Weis <weis@kde.org>
0017 
0018    This library is free software; you can redistribute it and/or
0019    modify it under the terms of the GNU Library General Public
0020    License as published by the Free Software Foundation; either
0021    version 2 of the License, or (at your option) any later version.
0022 
0023    This library is distributed in the hope that it will be useful,
0024    but WITHOUT ANY WARRANTY; without even the implied warranty of
0025    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0026    Library General Public License for more details.
0027 
0028    You should have received a copy of the GNU Library General Public License
0029    along with this library; see the file COPYING.LIB.  If not, write to
0030    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0031    Boston, MA 02110-1301, USA.
0032 */
0033 
0034 #ifndef SHEETS_ODF_PRIVATE
0035 #define SHEETS_ODF_PRIVATE
0036 
0037 // This should only be included by files inside the odf/ subdir
0038 
0039 #include <KoOdfLoadingContext.h>
0040 #include <KoOasisSettings.h>
0041 #include <KoShapeLoadingContext.h>
0042 #include <KoShapeSavingContext.h>
0043 
0044 #include "OdfLoadingContext.h"
0045 #include "OdfSavingContext.h"
0046 
0047 namespace Calligra {
0048 namespace Sheets {
0049 
0050 class CalculationSettings;
0051 class NamedAreaManager;
0052 class Conditions;
0053 class Conditional;
0054 
0055 namespace Odf {
0056 
0057     // SheetsOdfDoc
0058     void loadCalculationSettings(CalculationSettings *settings, const KoXmlElement& body);
0059     bool saveCalculationSettings(const CalculationSettings *settings, KoXmlWriter &settingsWriter);
0060 
0061     // SheetsOdfMap
0062     bool loadMap(Map *map, const KoXmlElement& body, KoOdfLoadingContext& odfContext);
0063     void loadMapSettings(Map *map, const KoOasisSettings &settingsDoc);
0064     bool saveMap(Map *map, KoXmlWriter & xmlWriter, KoShapeSavingContext & savingContext);
0065     void loadNamedAreas(NamedAreaManager *manager, const KoXmlElement& body);
0066     void saveNamedAreas(const NamedAreaManager *manager, KoXmlWriter& xmlWriter);
0067 
0068     // SheetsOdfSheet
0069     bool loadSheet(Sheet *sheet, const KoXmlElement& sheetElement, OdfLoadingContext& tableContext, const Styles& autoStyles, const QHash<QString, Conditions>& conditionalStyles);
0070     void loadSheetSettings(Sheet *sheet, const KoOasisSettings::NamedMap &settings);
0071     bool saveSheet(Sheet *sheet, OdfSavingContext& tableContext);
0072     void saveSheetSettings(Sheet *sheet, KoXmlWriter &settingsWriter);
0073 
0074     // SheetsOdfCell
0075     bool loadCell(Cell *cell, const KoXmlElement& element, OdfLoadingContext& tableContext,
0076             const Styles& autoStyles, const QString& cellStyleName,
0077             QList<ShapeLoadingData>& shapeData);
0078     bool saveCell(Cell *cell, int &repeated, OdfSavingContext& tableContext);
0079 
0080     // SheetsOdfStyle
0081 
0082     /**
0083      * Loads OpenDocument auto styles.
0084      * The auto styles are preloaded, because an auto style could be shared
0085      * among cells. So, preloading prevents a multiple loading of the same
0086      * auto style.
0087      * This method is called before the cell loading process.
0088      * @param styles the styles
0089      * @param stylesReader repository of styles
0090      * @param conditionalStyles the conditional styles
0091      * @param parser the parser
0092      * @return a hash of styles with the OpenDocument internal name as key
0093      */
0094     Styles loadAutoStyles(StyleManager *styles, KoOdfStylesReader& stylesReader,
0095                              QHash<QString, Conditions>& conditionalStyles,
0096                              const ValueParser *parser);
0097     void loadStyleTemplate(StyleManager *styles, KoOdfStylesReader& stylesReader, Map* map = 0);
0098     void saveStyles(StyleManager *manager, KoGenStyles &mainStyles);
0099     QString saveStyle(const Style *style, KoGenStyle& xmlstyle, KoGenStyles& mainStyles,
0100                        const StyleManager* manager);
0101 
0102     void loadDataStyle(Style *style, KoOdfStylesReader& stylesReader, const KoXmlElement& element,
0103                              Conditions& conditions, const StyleManager* styleManager,
0104                              const ValueParser *parser);
0105 
0106     // SheetsOdfCondition
0107     Conditional loadCondition(Conditions *conditions, const QString &conditionValue, const QString &applyStyleName,
0108                                  const QString &baseCellAddress, const ValueParser *parser);
0109     void loadConditions(Conditions *conditions, const KoXmlElement &element, const ValueParser *parser, const StyleManager* styleManager);
0110     void saveConditions(const Conditions *conditions, KoGenStyle &currentCellStyle, ValueConverter *converter);
0111 
0112     // SheetsOdfValidity
0113     void loadValidation(Validity *validity, Cell* const cell, const QString& validationName, OdfLoadingContext& tableContext);
0114 
0115 }
0116 
0117 }
0118 }
0119 
0120 #endif