Warning, file /office/calligra/filters/libmsooxml/MsooXmlDrawingTableStyle.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 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 MSOOXMLDRAWINGTABLESTYLE_H 0021 #define MSOOXMLDRAWINGTABLESTYLE_H 0022 0023 #include <MsooXmlTableStyle.h> 0024 #include <KoTblStyle.h> 0025 0026 /** 0027 * The idea behind these classes is the following: 0028 * > A document has a list of table styles identifiable by ID. 0029 * > A table style has a number of properties to be used if the 0030 * table that references the style toggles them on. 0031 * > Those are stored on a table style properties. 0032 * 0033 * > Now the way a style for a cell is composed can be quite complex 0034 * depending on a lot of things. Mainly: 0035 * > The properties toggled and their precedence, 0036 * the rule of thumb for the precedence is that it's higher 0037 * the more more specific it is. 0038 * > The position in which the cell is. The styles have a 0039 * particularly tricky property: borders. The styles can 0040 * specify (in the same style) the style for a border 0041 * depending whether is in the outside of the table or 0042 * if it's an inside border. That's why the size of the 0043 * table is needed. 0044 * 0045 * Also, we might need to apply local styles (styles to one cell,) 0046 * or default styles for all the cells in a table. Defined in the very 0047 * table. 0048 * 0049 * For these reasons we don't apply styles directly but we use a style 0050 * converter for a specific table with a specific togglers for styles, 0051 * specific local styles or specific default styles and size. This converter 0052 * will give a KoCellStyle back. 0053 */ 0054 0055 namespace MSOOXML 0056 { 0057 0058 /// Reading and storage 0059 0060 class KOMSOOXML_EXPORT DrawingTableStyle : public TableStyle 0061 { 0062 public: 0063 enum Type { 0064 NoType, 0065 FirstRow, 0066 FirstCol, 0067 LastCol, 0068 LastRow, 0069 NeCell, 0070 NwCell, 0071 SeCell, 0072 SwCell, 0073 Band1Horizontal, 0074 Band2Horizontal, 0075 Band1Vertical, 0076 Band2Vertical, 0077 WholeTbl 0078 }; 0079 0080 DrawingTableStyle(); 0081 ~DrawingTableStyle() override; 0082 0083 //the style takes ownership of the properties 0084 void addProperties(Type type, TableStyleProperties* properties); 0085 TableStyleProperties* properties(Type type) const; 0086 0087 //Style of the whole table, not cell styles 0088 KoTblStyle::Ptr mainStyle; 0089 0090 private: 0091 QMap<Type, TableStyleProperties*> m_properties; 0092 //TODO: handle the table background stored in the element TblBg 0093 }; 0094 0095 class KOMSOOXML_EXPORT DrawingTableStyleConverterProperties : public TableStyleConverterProperties 0096 { 0097 public: 0098 DrawingTableStyleConverterProperties(); 0099 ~DrawingTableStyleConverterProperties() override; 0100 0101 enum Role { 0102 FirstRow = 1, 0103 FirstCol = 2, 0104 LastCol = 4, 0105 LastRow = 8, 0106 NeCell = 16, 0107 NwCell = 32, 0108 SeCell = 64, 0109 SwCell = 128, 0110 RowBanded = 256, 0111 ColumnBanded = 512, 0112 WholeTbl = 1024 0113 }; 0114 Q_DECLARE_FLAGS(Roles, Role) 0115 0116 void setRoles(Roles roles); 0117 Roles roles() const; 0118 0119 private: 0120 Roles m_role; 0121 }; 0122 0123 class KOMSOOXML_EXPORT DrawingTableStyleConverter : public TableStyleConverter 0124 { 0125 public: 0126 explicit DrawingTableStyleConverter(DrawingTableStyleConverterProperties const& properties, DrawingTableStyle* style =0); 0127 ~DrawingTableStyleConverter() override; 0128 0129 KoCellStyle::Ptr style(int row, int column, const QPair<int, int> &spans) override; 0130 0131 private: 0132 void applyStyle(MSOOXML::DrawingTableStyle::Type type, KoCellStyle::Ptr& style, int row, int column, const QPair<int, int> &spans); 0133 0134 DrawingTableStyle * const m_style; 0135 DrawingTableStyleConverterProperties const& m_properties; 0136 }; 0137 0138 } 0139 0140 Q_DECLARE_OPERATORS_FOR_FLAGS(MSOOXML::DrawingTableStyleConverterProperties::Roles) 0141 0142 #endif