Warning, file /office/calligra/filters/libmsooxml/MsooXmlTableStyle.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2010-2011 Carlos Licea <carlos@kdab.com>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef MSOOXMLTABLESTYLE_H
0021 #define MSOOXMLTABLESTYLE_H
0022 
0023 #include "komsooxml_export.h"
0024 
0025 #include <KoCellStyle.h>
0026 #include <KoBorder.h>
0027 #include <KoGenStyle.h>
0028 
0029 #include <QColor>
0030 #include <QFlags>
0031 #include <QMap>
0032 
0033 namespace MSOOXML {
0034 
0035 /// Reading and storage
0036 
0037 struct KOMSOOXML_EXPORT TableStyleProperties
0038 {
0039     TableStyleProperties()
0040     :    target(Table)
0041     {}
0042 
0043     enum TargetLevel {
0044         Table,
0045         TableRow,
0046         TableColumn,
0047         TableCell
0048     };
0049 
0050     enum Property {
0051         BottomBorder = 1,
0052         InsideHBorder = 2,
0053         InsideVBorder = 4,
0054         LeftBorder = 8,
0055         RightBorder = 16,
0056         Tl2brBorder = 32,
0057         TopBorder = 64,
0058         Tr2blBorder = 128,
0059         BackgroundColor = 256,
0060         TopMargin = 512,
0061         RightMargin = 1024,
0062         BottomMargin = 2048,
0063         LeftMargin = 4096,
0064         VerticalAlign = 8192,
0065         GlyphOrientation = 16384,
0066         BackgroundOpacity = 32768
0067     };
0068 
0069     TargetLevel target;
0070 
0071     Q_DECLARE_FLAGS(Properties, Property)
0072     Properties setProperties;
0073 
0074     KoBorder::BorderData bottom;
0075     KoBorder::BorderData insideH;
0076     KoBorder::BorderData insideV;
0077     KoBorder::BorderData left;
0078     KoBorder::BorderData right;
0079     KoBorder::BorderData tl2br;
0080     KoBorder::BorderData top;
0081     KoBorder::BorderData tr2bl;
0082 
0083     QColor backgroundColor;
0084     qreal backgroundOpacity;
0085 
0086     qreal topMargin;
0087     qreal rightMargin;
0088     qreal bottomMargin;
0089     qreal leftMargin;
0090 
0091     QString verticalAlign;
0092     bool glyphOrientation;
0093 
0094     KoGenStyle textStyle;
0095     KoGenStyle paragraphStyle;
0096 };
0097 
0098 class KOMSOOXML_EXPORT TableStyle
0099 {
0100 public:
0101 
0102     TableStyle();
0103     virtual ~TableStyle();
0104 
0105     void setId(const QString& id);
0106     QString id() const;
0107 
0108 private:
0109     QString m_id;
0110 };
0111 
0112 /// Instantiation classes
0113 
0114 class KOMSOOXML_EXPORT LocalTableStyles
0115 {
0116 public:
0117     LocalTableStyles();
0118     ~LocalTableStyles();
0119 
0120     TableStyleProperties* localStyle(int row, int column);
0121     void setLocalStyle(MSOOXML::TableStyleProperties* properties, int row, int column);
0122 
0123 private:
0124     QMap<QPair<int,int>, TableStyleProperties*> m_properties;
0125 };
0126 
0127 class KOMSOOXML_EXPORT TableStyleConverterProperties
0128 {
0129 public:
0130     TableStyleConverterProperties();
0131     virtual ~TableStyleConverterProperties();
0132 
0133     void setRowCount(int rowCount);
0134     int rowCount() const;
0135 
0136     void setColumnCount(int columnCount);
0137     int columnCount() const;
0138 
0139     void setRowBandSize(int size);
0140     int rowBandSize() const;
0141 
0142     void setColumnBandSize(int size);
0143     int columnBandSize() const;
0144 
0145     ///LocalStyles is a collection of cell<->style relationships
0146     void setLocalStyles(const LocalTableStyles& localStyles);
0147     LocalTableStyles localStyles() const;
0148 
0149     ///LocalTableStyle is a style defined to be the default style of a table. Defined locally.
0150     void setLocalDefaulCelltStyle(MSOOXML::TableStyleProperties* properties);
0151     TableStyleProperties* localDefaultCellStyle() const;
0152 
0153 private:
0154     int m_rowCount;
0155     int m_columnCount;
0156     int m_rowBandSize;
0157     int m_columnBandSize;
0158     LocalTableStyles m_localStyles;
0159     MSOOXML::TableStyleProperties* m_localDefaultCellStyle;
0160 };
0161 
0162 class KOMSOOXML_EXPORT TableStyleConverter
0163 {
0164 public:
0165     TableStyleConverter(int row, int column);
0166     virtual ~TableStyleConverter();
0167 
0168     virtual KoCellStyle::Ptr style(int row, int column, const QPair<int, int> &spans) = 0;
0169 
0170 protected:
0171     void applyStyle(MSOOXML::TableStyleProperties* styleProperties, KoCellStyle::Ptr& style,
0172                     int row, int column, const QPair<int, int> &spans);
0173 
0174     //NOTE: TESTING
0175     void reapplyTableLevelBordersStyle(MSOOXML::TableStyleProperties* properties,
0176                                        MSOOXML::TableStyleProperties* localProperties,
0177                                        MSOOXML::TableStyleProperties* exceptionProperties,
0178                                        KoCellStyle::Ptr& style,
0179                                        int row, int column, const QPair<int, int> &spans);
0180 
0181 private:
0182     void applyTableLevelBordersStyle(MSOOXML::TableStyleProperties* properties, KoCellStyle::Ptr& style,
0183                                      int row, int column, const QPair<int, int> &spans);
0184 
0185     void applyRowLevelBordersStyle(MSOOXML::TableStyleProperties* properties, KoCellStyle::Ptr& style,
0186                                    int row, int column, const QPair<int, int> &spans);
0187 
0188     void applyColumnLevelBordersStyle(MSOOXML::TableStyleProperties* properties, KoCellStyle::Ptr& style,
0189                                       int row, int column, const QPair<int, int> &spans);
0190 
0191     void applyCellLevelBordersStyle(MSOOXML::TableStyleProperties* properties, KoCellStyle::Ptr& style);
0192 
0193     void applyBackground(MSOOXML::TableStyleProperties* properties, KoCellStyle::Ptr& style,
0194                          int row, int column);
0195 
0196     int m_row;
0197     int m_column;
0198 };
0199 
0200 }
0201 
0202 Q_DECLARE_OPERATORS_FOR_FLAGS(MSOOXML::TableStyleProperties::Properties)
0203 
0204 #endif