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

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 #include "MsooXmlTableStyle.h"
0021 
0022 using namespace MSOOXML;
0023 
0024 TableStyleConverterProperties::TableStyleConverterProperties()
0025 : m_rowCount(1)
0026 , m_columnCount(1)
0027 , m_rowBandSize(1)
0028 , m_columnBandSize(1)
0029 , m_localStyles()
0030 , m_localDefaultCellStyle(0)
0031 {
0032 }
0033 
0034 TableStyleConverterProperties::~TableStyleConverterProperties()
0035 {
0036 }
0037 
0038 void TableStyleConverterProperties::setRowCount(int rowCount)
0039 {
0040     m_rowCount = rowCount;
0041 }
0042 
0043 int TableStyleConverterProperties::rowCount() const
0044 {
0045     return m_rowCount;
0046 }
0047 
0048 
0049 void TableStyleConverterProperties::setColumnCount(int columnCount)
0050 {
0051     m_columnCount = columnCount;
0052 }
0053 
0054 int TableStyleConverterProperties::columnCount() const
0055 {
0056     return m_columnCount;
0057 }
0058 
0059 void TableStyleConverterProperties::setColumnBandSize(int size)
0060 {
0061     Q_ASSERT(size >= 0);
0062     m_columnBandSize = size;
0063 }
0064 
0065 int TableStyleConverterProperties::columnBandSize() const
0066 {
0067     return m_columnBandSize;
0068 }
0069 
0070 void TableStyleConverterProperties::setRowBandSize(int size)
0071 {
0072     m_rowBandSize = size;
0073 }
0074 
0075 int TableStyleConverterProperties::rowBandSize() const
0076 {
0077     return m_rowBandSize;
0078 }
0079 
0080 void TableStyleConverterProperties::setLocalStyles(const MSOOXML::LocalTableStyles& localStyles)
0081 {
0082     m_localStyles = localStyles;
0083 }
0084 
0085 LocalTableStyles TableStyleConverterProperties::localStyles() const
0086 {
0087     return m_localStyles;
0088 }
0089 
0090 void TableStyleConverterProperties::setLocalDefaulCelltStyle(TableStyleProperties* properties)
0091 {
0092     m_localDefaultCellStyle = properties;
0093 }
0094 
0095 TableStyleProperties* TableStyleConverterProperties::localDefaultCellStyle() const
0096 {
0097     return m_localDefaultCellStyle;
0098 }
0099 
0100 TableStyleConverter::TableStyleConverter(int row, int column)
0101 : m_row(row)
0102 , m_column(column)
0103 {
0104 }
0105 
0106 TableStyleConverter::~TableStyleConverter()
0107 {
0108 }
0109 // TODO: Table-level exception properties, tblCellSpacing
0110 //
0111 // ECMA-376:
0112 //
0113 // The appearance of a table cell border in the document shall be determined by
0114 // the following settings:
0115 //
0116 // * If the tblCellSpacing element value (§17.4.45;§17.4.44;§17.4.46) applied
0117 // to the cell is non-zero, then the cell border shall always be displayed
0118 //
0119 // * Otherwise, the display of the border is subject to the conflict resolution
0120 // algorithm defined by the tcBorders element (§17.4.67) and the tblBorders
0121 // element (§17.4.40;§17.4.39)
0122 //
0123 //
0124 // 17.4.39 tblBorders (Table Borders)
0125 //
0126 // If the cell spacing is zero, then there is a conflict [Example: Between the
0127 // left border of all cells in the first column and the left border of the
0128 // table. end example], which shall be resolved as follows:
0129 //
0130 // * If there is a cell border, then the cell border shall be displayed
0131 //
0132 // * If there is no cell border but there is a table-level exception border on
0133 // this table row, then the table-level exception border shall be displayed
0134 //
0135 // * If there is no cell or table-level exception border, then the table border
0136 // shall be displayed
0137 //
0138 //
0139 // 17.4.67 tcBorders (Table Cell Borders)
0140 //
0141 // If the cell spacing is zero, then there can be a conflict between two
0142 // adjacent cell borders [Example: Between the left border of all cells in the
0143 // second column and the right border of all cells in the first column of the
0144 // table. end example], which shall be resolved as follows:
0145 //
0146 // * If either conflicting table cell border is nil or none (no border), then
0147 // the opposing border shall be displayed.
0148 //
0149 // * If a cell border conflicts with a table border, the cell border always
0150 // wins.
0151 //
0152 // * Each border shall then be assigned a weight using the formula described in
0153 // the spec, and the border value using this calculation shall be displayed
0154 // over the alternative border:
0155 //
0156 void TableStyleConverter::applyStyle(TableStyleProperties* styleProperties, KoCellStyle::Ptr& style,
0157                                      int row, int column, const QPair<int, int> &spans)
0158 {
0159     if(!styleProperties) {
0160         return;
0161     }
0162 
0163     switch (styleProperties->target) {
0164     case TableStyleProperties::TableRow:
0165         applyRowLevelBordersStyle(styleProperties, style, row, column, spans);
0166         break;
0167     case TableStyleProperties::TableColumn:
0168         applyColumnLevelBordersStyle(styleProperties, style, row, column, spans);
0169         break;
0170     case TableStyleProperties::TableCell:
0171         applyCellLevelBordersStyle(styleProperties, style);
0172         break;
0173     default:
0174         applyTableLevelBordersStyle(styleProperties, style, row, column, spans);
0175         break;
0176     }
0177 
0178     //TODO: A similar logic to borders should be used for all other properties!
0179 
0180     applyBackground(styleProperties, style, row, column);
0181 
0182     if (styleProperties->setProperties & TableStyleProperties::VerticalAlign) {
0183         style->setVerticalAlign(styleProperties->verticalAlign);
0184     }
0185 
0186     if (styleProperties->setProperties & TableStyleProperties::GlyphOrientation) {
0187         style->setGlyphOrientation(styleProperties->glyphOrientation);
0188     }
0189 
0190     if (!styleProperties->textStyle.isEmpty() || !styleProperties->textStyle.parentName().isEmpty()) {
0191         style->setTextStyle(styleProperties->textStyle);
0192     }
0193 
0194     if (!styleProperties->paragraphStyle.isEmpty() || !styleProperties->paragraphStyle.parentName().isEmpty()) {
0195         style->setParagraphStyle(styleProperties->paragraphStyle);
0196     }
0197 
0198     TableStyleProperties::Properties setProperties = styleProperties->setProperties;
0199 
0200     if (setProperties & TableStyleProperties::TopMargin) {
0201         style->setTopPadding(styleProperties->topMargin);
0202     }
0203     if (setProperties & TableStyleProperties::BottomMargin) {
0204         style->setBottomPadding(styleProperties->bottomMargin);
0205     }
0206     if (setProperties & TableStyleProperties::LeftMargin) {
0207         style->setLeftPadding(styleProperties->leftMargin);
0208     }
0209     if (setProperties & TableStyleProperties::RightMargin) {
0210         style->setRightPadding(styleProperties->rightMargin);
0211     }
0212 }
0213 
0214 void TableStyleConverter::applyBackground(TableStyleProperties* styleProperties, KoCellStyle::Ptr& style, int row, int column)
0215 {
0216     Q_UNUSED(row);
0217     Q_UNUSED(column);
0218 
0219     if (styleProperties->setProperties & TableStyleProperties::BackgroundColor) {
0220         style->setBackgroundColor(styleProperties->backgroundColor);
0221     }
0222     if (styleProperties->setProperties & TableStyleProperties::BackgroundOpacity) {
0223         style->setBackgroundOpacity(styleProperties->backgroundOpacity);
0224     }
0225 }
0226 
0227 void TableStyleConverter::applyTableLevelBordersStyle(TableStyleProperties* styleProperties, KoCellStyle::Ptr& style,
0228                                                       int row, int column, const QPair<int, int> &spans)
0229 {
0230     const int lastRow = m_row;
0231     const int lastColumn = m_column;
0232 
0233     TableStyleProperties::Properties setProperties = styleProperties->setProperties;
0234 
0235     if (setProperties & TableStyleProperties::TopBorder) {
0236         if (row == 0) {
0237             KoBorder::BorderData* topData;
0238             topData = &styleProperties->top;
0239             style->borders()->setBorderData(KoBorder::TopBorder, *topData);
0240         }
0241     }
0242 
0243     if (setProperties & TableStyleProperties::BottomBorder) {
0244         if ((row + spans.first) == lastRow) {
0245             KoBorder::BorderData* bottomData;
0246             bottomData = &styleProperties->bottom;
0247             style->borders()->setBorderData(KoBorder::BottomBorder, *bottomData);
0248         }
0249     }
0250 
0251     if (setProperties & TableStyleProperties::LeftBorder) {
0252         if (column == 0) {
0253             KoBorder::BorderData* leftData;
0254             leftData = &styleProperties->left;
0255             style->borders()->setBorderData(KoBorder::LeftBorder, *leftData);
0256         }
0257     }
0258 
0259     if (setProperties & TableStyleProperties::RightBorder) {
0260         if ((column + spans.second) == lastColumn) {
0261             KoBorder::BorderData* rightData;
0262             rightData = &styleProperties->right;
0263             style->borders()->setBorderData(KoBorder::RightBorder, *rightData);
0264         }
0265     }
0266 
0267     if (setProperties & TableStyleProperties::InsideVBorder) {
0268         KoBorder::BorderData* insideVData;
0269         insideVData = &styleProperties->insideV;
0270         if (column != 0) {
0271             style->borders()->setBorderData(KoBorder::LeftBorder, *insideVData);
0272         }
0273         if ((column + spans.second) != lastColumn) {
0274             style->borders()->setBorderData(KoBorder::RightBorder, *insideVData);
0275         }
0276     }
0277 
0278     if (setProperties & TableStyleProperties::InsideHBorder) {
0279         KoBorder::BorderData* insideHData;
0280         insideHData = &styleProperties->insideH;
0281         if (row != 0) {
0282             style->borders()->setBorderData(KoBorder::TopBorder, *insideHData);
0283         }
0284         if ((row + spans.first) != lastRow) {
0285             style->borders()->setBorderData(KoBorder::BottomBorder, *insideHData);
0286         }
0287     }
0288 
0289     if (setProperties & TableStyleProperties::Tl2brBorder) {
0290         style->borders()->setBorderData(KoBorder::TlbrBorder, styleProperties->tl2br);
0291     }
0292     if (setProperties & TableStyleProperties::Tr2blBorder) {
0293         style->borders()->setBorderData(KoBorder::BltrBorder, styleProperties->tr2bl);
0294     }
0295 }
0296 
0297 void TableStyleConverter::reapplyTableLevelBordersStyle(TableStyleProperties* properties,
0298                                                         TableStyleProperties* localProperties,
0299                                                         TableStyleProperties* exceptionProperties,
0300                                                         KoCellStyle::Ptr& style,
0301                                                         int row, int column, const QPair<int, int> &spans)
0302 {
0303     const int lastRow = m_row;
0304     const int lastColumn = m_column;
0305 
0306     TableStyleProperties::Properties setProperties;
0307     if (properties) {
0308         setProperties = properties->setProperties;
0309     }
0310     TableStyleProperties::Properties setLocalProperties;
0311     if (localProperties) {
0312         setLocalProperties = localProperties->setProperties;
0313     }
0314     TableStyleProperties::Properties setExceptionProperties;
0315     if (exceptionProperties) {
0316         setExceptionProperties = exceptionProperties->setProperties;
0317     }
0318     KoBorder::BorderData data;
0319 
0320     //TopBorder
0321     if (row == 0) {
0322         data = style->borders()->borderData(KoBorder::TopBorder);
0323         //cell-level border set to "None"
0324         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0325             if (setProperties & TableStyleProperties::TopBorder) {
0326                 style->borders()->setBorderData(KoBorder::TopBorder, properties->top);
0327             }
0328             if (setLocalProperties & TableStyleProperties::TopBorder) {
0329                 style->borders()->setBorderData(KoBorder::TopBorder, localProperties->top);
0330             }
0331             if (setExceptionProperties & TableStyleProperties::TopBorder) {
0332                 style->borders()->setBorderData(KoBorder::TopBorder, exceptionProperties->top);
0333             }
0334         }
0335     }
0336 
0337     //BottomBorder
0338     if ((row + spans.first) == lastRow) {
0339         data = style->borders()->borderData(KoBorder::BottomBorder);
0340         //cell-level border set to "None"
0341         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0342             if (setProperties & TableStyleProperties::BottomBorder) {
0343                 style->borders()->setBorderData(KoBorder::BottomBorder, properties->bottom);
0344             }
0345             if (setLocalProperties & TableStyleProperties::BottomBorder) {
0346                 style->borders()->setBorderData(KoBorder::BottomBorder, localProperties->bottom);
0347             }
0348             if (setExceptionProperties & TableStyleProperties::BottomBorder) {
0349                 style->borders()->setBorderData(KoBorder::BottomBorder, exceptionProperties->bottom);
0350             }
0351         }
0352     }
0353 
0354     //LeftBorder
0355     if (column == 0) {
0356         data = style->borders()->borderData(KoBorder::LeftBorder);
0357         //cell-level border set to "None"
0358         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0359             if (setProperties & TableStyleProperties::LeftBorder) {
0360                 style->borders()->setBorderData(KoBorder::LeftBorder, properties->left);
0361             }
0362             if (setLocalProperties & TableStyleProperties::LeftBorder) {
0363                 style->borders()->setBorderData(KoBorder::LeftBorder, localProperties->left);
0364             }
0365             if (setExceptionProperties & TableStyleProperties::LeftBorder) {
0366                 style->borders()->setBorderData(KoBorder::LeftBorder, exceptionProperties->left);
0367             }
0368         }
0369     }
0370 
0371     //RightBorder
0372     if ((column + spans.second) == lastColumn) {
0373         data = style->borders()->borderData(KoBorder::RightBorder);
0374         //cell-level border set to "None"
0375         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0376             if (setProperties & TableStyleProperties::RightBorder) {
0377                 style->borders()->setBorderData(KoBorder::RightBorder, properties->right);
0378             }
0379             if (setLocalProperties & TableStyleProperties::RightBorder) {
0380                 style->borders()->setBorderData(KoBorder::RightBorder, localProperties->right);
0381             }
0382             if (setExceptionProperties & TableStyleProperties::RightBorder) {
0383                 style->borders()->setBorderData(KoBorder::RightBorder, exceptionProperties->right);
0384             }
0385         }
0386     }
0387 
0388     //InsideVBorder
0389     if (column != 0) {
0390         data = style->borders()->borderData(KoBorder::LeftBorder);
0391         //cell-level border set to "None"
0392         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0393             if (setProperties & TableStyleProperties::InsideVBorder) {
0394                 style->borders()->setBorderData(KoBorder::LeftBorder, properties->insideV);
0395             }
0396             if (setLocalProperties & TableStyleProperties::InsideVBorder) {
0397                 style->borders()->setBorderData(KoBorder::LeftBorder, localProperties->insideV);
0398             }
0399             if (setExceptionProperties & TableStyleProperties::InsideVBorder) {
0400                 style->borders()->setBorderData(KoBorder::LeftBorder, exceptionProperties->insideV);
0401             }
0402         }
0403     }
0404 
0405     if ((column + spans.second) != lastColumn) {
0406         data = style->borders()->borderData(KoBorder::RightBorder);
0407         //cell-level border set to "None"
0408         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0409             if (setProperties & TableStyleProperties::InsideVBorder) {
0410                 style->borders()->setBorderData(KoBorder::RightBorder, properties->insideV);
0411             }
0412             if (setLocalProperties & TableStyleProperties::InsideVBorder) {
0413                 style->borders()->setBorderData(KoBorder::RightBorder, localProperties->insideV);
0414             }
0415             if (setExceptionProperties & TableStyleProperties::InsideVBorder) {
0416                 style->borders()->setBorderData(KoBorder::RightBorder, exceptionProperties->insideV);
0417             }
0418         }
0419     }
0420 
0421     //InsideHBorder
0422     if (row != 0) {
0423         data = style->borders()->borderData(KoBorder::TopBorder);
0424         //cell-level border set to "None"
0425         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0426             if (setProperties & TableStyleProperties::InsideHBorder) {
0427                 style->borders()->setBorderData(KoBorder::TopBorder, properties->insideH);
0428             }
0429             if (setLocalProperties & TableStyleProperties::InsideHBorder) {
0430                 style->borders()->setBorderData(KoBorder::TopBorder, localProperties->insideH);
0431             }
0432             if (setExceptionProperties & TableStyleProperties::InsideHBorder) {
0433                 style->borders()->setBorderData(KoBorder::TopBorder, exceptionProperties->insideH);
0434             }
0435         }
0436     }
0437 
0438     if ((row + spans.first) != lastRow) {
0439         data = style->borders()->borderData(KoBorder::BottomBorder);
0440         //cell-level border set to "None"
0441         if ((data.outerPen.widthF() == 0) && (data.style == KoBorder::BorderSolid)) {
0442             if (setProperties & TableStyleProperties::InsideHBorder) {
0443                 style->borders()->setBorderData(KoBorder::BottomBorder, properties->insideH);
0444             }
0445             if (setLocalProperties & TableStyleProperties::InsideHBorder) {
0446                 style->borders()->setBorderData(KoBorder::BottomBorder, localProperties->insideH);
0447             }
0448             if (setExceptionProperties & TableStyleProperties::InsideHBorder) {
0449                 style->borders()->setBorderData(KoBorder::BottomBorder, exceptionProperties->insideH);
0450             }
0451         }
0452     }
0453 
0454     //TODO: Tl2brBorder, Tr2blBorder
0455 }
0456 
0457 void TableStyleConverter::applyRowLevelBordersStyle(TableStyleProperties* props, KoCellStyle::Ptr& style,
0458                                                     int row, int column, const QPair<int, int> &spans)
0459 {
0460     const int lastColumn = m_column;
0461     const int lastRow = m_row;
0462 
0463     TableStyleProperties::Properties setProperties = props->setProperties;
0464 
0465     if (setProperties & TableStyleProperties::TopBorder) {
0466         style->borders()->setBorderData(KoBorder::TopBorder, props->top);
0467     }
0468 
0469     if (setProperties & TableStyleProperties::BottomBorder) {
0470         style->borders()->setBorderData(KoBorder::BottomBorder, props->bottom);
0471     }
0472 
0473     if (setProperties & TableStyleProperties::LeftBorder) {
0474         if (column == 0) {
0475             style->borders()->setBorderData(KoBorder::LeftBorder, props->left);
0476         }
0477     }
0478 
0479     if (setProperties & TableStyleProperties::RightBorder) {
0480         if ((column + spans.second) == lastColumn) {
0481             style->borders()->setBorderData(KoBorder::RightBorder, props->right);
0482         }
0483     }
0484 
0485     if (setProperties & TableStyleProperties::InsideHBorder) {
0486         KoBorder::BorderData* insideHData;
0487         insideHData = &props->insideH;
0488         if (row != 0) {
0489             style->borders()->setBorderData(KoBorder::TopBorder, *insideHData);
0490         }
0491         if ((row + spans.first) != lastRow) {
0492             style->borders()->setBorderData(KoBorder::BottomBorder, *insideHData);
0493         }
0494     }
0495 
0496     if (setProperties & TableStyleProperties::InsideVBorder) {
0497         KoBorder::BorderData* insideVData;
0498         insideVData = &props->insideV;
0499         if (column != 0) {
0500             style->borders()->setBorderData(KoBorder::LeftBorder, *insideVData);
0501         }
0502         if ((column + spans.second) != lastColumn) {
0503             style->borders()->setBorderData(KoBorder::RightBorder, *insideVData);
0504         }
0505     }
0506 
0507     if (setProperties & TableStyleProperties::Tl2brBorder) {
0508         style->borders()->setBorderData(KoBorder::TlbrBorder, props->tl2br);
0509     }
0510     if (setProperties & TableStyleProperties::Tr2blBorder) {
0511         style->borders()->setBorderData(KoBorder::BltrBorder, props->tr2bl);
0512     }
0513 }
0514 
0515 void TableStyleConverter::applyColumnLevelBordersStyle(TableStyleProperties* props, KoCellStyle::Ptr& style,
0516                                                        int row, int column, const QPair<int, int> &spans)
0517 {
0518     const int lastColumn = m_column;
0519     const int lastRow = m_row;
0520 
0521     TableStyleProperties::Properties setProperties = props->setProperties;
0522 
0523     if (setProperties & TableStyleProperties::TopBorder) {
0524         if (row == 0) {
0525             style->borders()->setBorderData(KoBorder::TopBorder, props->top);
0526         }
0527     }
0528 
0529     if (setProperties & TableStyleProperties::BottomBorder) {
0530         if ((row + spans.first) == lastRow) {
0531             style->borders()->setBorderData(KoBorder::BottomBorder, props->bottom);
0532         }
0533     }
0534 
0535     if (setProperties & TableStyleProperties::LeftBorder) {
0536         style->borders()->setBorderData(KoBorder::LeftBorder, props->left);
0537     }
0538 
0539     if (setProperties & TableStyleProperties::RightBorder) {
0540         style->borders()->setBorderData(KoBorder::RightBorder, props->right);
0541     }
0542 
0543     if (setProperties & TableStyleProperties::InsideHBorder) {
0544         KoBorder::BorderData* insideHData;
0545         insideHData = &props->insideH;
0546         if (row != 0) {
0547             style->borders()->setBorderData(KoBorder::TopBorder, *insideHData);
0548         }
0549         if ((row + spans.first) != lastRow) {
0550             style->borders()->setBorderData(KoBorder::BottomBorder, *insideHData);
0551         }
0552     }
0553 
0554     if (setProperties & TableStyleProperties::InsideVBorder) {
0555         KoBorder::BorderData* insideVData;
0556         insideVData = &props->insideV;
0557         if (column != 0) {
0558             style->borders()->setBorderData(KoBorder::LeftBorder, *insideVData);
0559         }
0560         if ((column + spans.second) != lastColumn) {
0561             style->borders()->setBorderData(KoBorder::RightBorder, *insideVData);
0562         }
0563     }
0564 
0565     if (setProperties & TableStyleProperties::Tl2brBorder) {
0566         style->borders()->setBorderData(KoBorder::TlbrBorder, props->tl2br);
0567     }
0568     if (setProperties & TableStyleProperties::Tr2blBorder) {
0569         style->borders()->setBorderData(KoBorder::BltrBorder, props->tr2bl);
0570     }
0571 }
0572 
0573 void TableStyleConverter::applyCellLevelBordersStyle(TableStyleProperties* props, KoCellStyle::Ptr& style)
0574 {
0575     //NOTE: Let's keep the local variables until it's unstable.
0576 
0577     TableStyleProperties::Properties setProperties = props->setProperties;
0578 
0579     if (setProperties & TableStyleProperties::TopBorder) {
0580         KoBorder::BorderData* data = &props->top;
0581         style->borders()->setBorderData(KoBorder::TopBorder, *data);
0582     }
0583 
0584     if (setProperties & TableStyleProperties::BottomBorder) {
0585         KoBorder::BorderData* data = &props->bottom;
0586         style->borders()->setBorderData(KoBorder::BottomBorder, *data);
0587     }
0588 
0589     if (setProperties & TableStyleProperties::LeftBorder) {
0590         KoBorder::BorderData* data = &props->left;
0591         style->borders()->setBorderData(KoBorder::LeftBorder,*data);
0592     }
0593 
0594     if (setProperties & TableStyleProperties::RightBorder) {
0595         KoBorder::BorderData* data = &props->right;
0596         style->borders()->setBorderData(KoBorder::RightBorder, *data);
0597     }
0598 
0599     if (setProperties & TableStyleProperties::Tl2brBorder) {
0600         KoBorder::BorderData* data = &props->tl2br;
0601         style->borders()->setBorderData(KoBorder::TlbrBorder, *data);
0602     }
0603     if (setProperties & TableStyleProperties::Tr2blBorder) {
0604         KoBorder::BorderData* data = &props->tr2bl;
0605         style->borders()->setBorderData(KoBorder::BltrBorder,*data);
0606     }
0607     //TODO: process InsideHBorder, InsideVBorder
0608 }
0609 
0610 TableStyle::TableStyle()
0611 : m_id()
0612 {
0613 }
0614 
0615 TableStyle::~TableStyle()
0616 {
0617 //     qDeleteAll(m_properties.values());
0618 }
0619 
0620 void TableStyle::setId(const QString& id)
0621 {
0622     m_id = id;
0623 }
0624 
0625 QString TableStyle::id() const
0626 {
0627     return m_id;
0628 }
0629 
0630 LocalTableStyles::LocalTableStyles()
0631 {
0632 }
0633 
0634 LocalTableStyles::~LocalTableStyles()
0635 {
0636 }
0637 
0638 TableStyleProperties* LocalTableStyles::localStyle(int row, int column)
0639 {
0640     const QPair<int,int> key(row,column);
0641     return m_properties.value(key);
0642 }
0643 
0644 void LocalTableStyles::setLocalStyle(TableStyleProperties* properties, int row, int column)
0645 {
0646     const QPair<int,int> key(row,column);
0647     m_properties.insert(key, properties);
0648 }