File indexing completed on 2024-05-12 16:29:18

0001 /*
0002  *  Copyright (c) 2010 Carlos Licea <carlos@kdab.com>
0003  *
0004  *  This library is free software; you can redistribute it and/or modify
0005  *  it under the terms of the GNU Lesser General Public License as published
0006  *  by the Free Software Foundation; either version 2.1 of the License, or
0007  *  (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
0012  *  GNU Lesser General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU Lesser General Public License
0015  *  along with this program; if not, write to the Free Software
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  */
0018 
0019 #ifndef KOTBLSTYLE_H
0020 #define KOTBLSTYLE_H
0021 
0022 #include "KoStyle.h"
0023 #include "koodf2_export.h"
0024 
0025 #include <QColor>
0026 
0027 /**
0028  * \class KoTblStyle
0029  * \brief This class represents a style for a Table in
0030  * a ODF document.
0031  *
0032  * As all the styles it can be shared.
0033  **/
0034 
0035 class KOODF2_EXPORT KoTblStyle : public KoStyle
0036 {
0037     KoTblStyle();
0038 
0039 public:
0040     KOSTYLE_DECLARE_SHARED_POINTER(KoTblStyle)
0041 
0042     ~KoTblStyle() override;
0043 
0044     void setBackgroundColor(const QColor& color);
0045     QColor backgroundColor() const;
0046 
0047     enum BreakType {
0048         NoBreak,
0049         AutoBreak,
0050         ColumnBreak,
0051         PageBreak
0052     };
0053     void setBreakBefore(BreakType breakBefore);
0054     BreakType breakBefore() const;
0055 
0056     void setBreakAfter(BreakType breakAfter);
0057     BreakType breakAfter() const;
0058 
0059     void setAllowBreakBetweenRows(bool allow);
0060     bool allowBreakBetweenRows() const;
0061 
0062     void setMasterPageName(const QString& name);
0063     void setMasterPageName(const char* name);
0064     QString masterPageName() const;
0065 
0066     void setLeftMargin(qreal left);
0067     qreal leftMargin() const;
0068 
0069     void setTopMargin(qreal top);
0070     qreal topMargin() const;
0071 
0072     void setRightMargin(qreal right);
0073     qreal rightMargin() const;
0074 
0075     void setBottomMargin(qreal bottom);
0076     qreal bottomMargin() const;
0077 
0078     enum WidthUnit {
0079         PercentageUnit,
0080         PointsUnit
0081     };
0082     void setWidth(qreal width, WidthUnit unit = PointsUnit);
0083     qreal width() const;
0084     WidthUnit widthUnit() const;
0085 
0086     enum HorizontalAlign {
0087         CenterAlign,
0088         LeftAlign,
0089         MarginsAlign,
0090         RightAlign
0091     };
0092     void setHorizontalAlign(HorizontalAlign align);
0093     HorizontalAlign horizontalAlign() const;
0094 
0095     enum BorderModel {
0096         CollapsingModel,
0097         SeparatingModel
0098     };
0099     void setBorderModel(BorderModel bordelModel);
0100     BorderModel borderModel() const;
0101 
0102     void setDisplay(bool display);
0103     bool display() const;
0104 
0105     enum KeepWithNext {
0106         AutoKeepWithNext,
0107         AlwaysKeepWithNext
0108     };
0109     void setKeepWithNext(KeepWithNext keepWithNext);
0110     KeepWithNext keepWithNext() const;
0111 
0112     enum WritingMode {
0113         LrTbWritingMode,
0114         RlTbWritingMode,
0115         TbRlWritingMode,
0116         TbLrWritingMode,
0117         LrWritingMode,
0118         RlWritingMode,
0119         TbWritingMode,
0120         PageWritingMode
0121     };
0122     void setWritingMode(WritingMode writingMode);
0123     WritingMode writingMode() const;
0124 
0125 protected:
0126     void prepareStyle(KoGenStyle& style) const override;
0127     KoGenStyle::Type automaticstyleType() const override;
0128     KoGenStyle::Type styleType() const override;
0129     const char* styleFamilyName() const override;
0130     QString defaultPrefix() const override;
0131 
0132 private:
0133     QColor m_backgroundColor;
0134     BreakType m_breakAfter;
0135     BreakType m_breakBefore;
0136     bool m_allowBreakBetweenRows;
0137 
0138     QString m_masterPageName;
0139 
0140     qreal m_leftMargin;
0141     qreal m_topMargin;
0142     qreal m_rightMargin;
0143     qreal m_bottomMargin;
0144 
0145     qreal m_width;
0146     WidthUnit m_widthUnit;
0147 
0148     HorizontalAlign m_horizontalAlign;
0149     BorderModel m_borderModel;
0150     KeepWithNext m_keepWithNext;
0151     WritingMode m_writingMode;
0152 
0153     bool m_display;
0154     //TODO style:page-number
0155     //TODO style:shadow
0156     //TODO style:background-image
0157 };
0158 
0159 #endif