File indexing completed on 2024-12-08 12:56:11
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 #include "KoRow.h" 0020 0021 #include <KoXmlWriter.h> 0022 0023 #include <QMap> 0024 #include <QString> 0025 0026 namespace { 0027 class VisibilityMap : public QMap<KoRow::Visibility, QString> 0028 { 0029 public: 0030 VisibilityMap() 0031 : QMap<KoRow::Visibility, QString>() 0032 { 0033 insert(KoRow::Collapse, "colapse"); 0034 insert(KoRow::Filter, "filter"); 0035 insert(KoRow::Visible, "visible"); 0036 } 0037 } visibilityMap; 0038 } 0039 0040 0041 KoRow::KoRow() 0042 : m_defaultCellStyle(0) 0043 , m_style(0) 0044 , m_visibility(Visible) 0045 { 0046 } 0047 0048 KoRow::~KoRow() 0049 { 0050 } 0051 0052 void KoRow::setStyle(KoRowStyle::Ptr style) 0053 { 0054 m_style = style; 0055 } 0056 0057 KoRowStyle::Ptr KoRow::style() 0058 { 0059 return m_style; 0060 } 0061 0062 KoCellStyle::Ptr KoRow::defualtCellStyle() const 0063 { 0064 return m_defaultCellStyle; 0065 } 0066 0067 void KoRow::setDefaultCellStyle(KoCellStyle::Ptr defaultStyle) 0068 { 0069 m_defaultCellStyle = defaultStyle; 0070 } 0071 0072 void KoRow::setVisibility(KoRow::Visibility visibility) 0073 { 0074 m_visibility = visibility; 0075 } 0076 0077 KoRow::Visibility KoRow::visibility() 0078 { 0079 return m_visibility; 0080 } 0081 0082 void KoRow::saveOdf(KoXmlWriter& writer, KoGenStyles& styles) 0083 { 0084 writer.startElement("table:table-row"); 0085 if(m_style) { 0086 writer.addAttribute("table:style-name", m_style->saveOdf(styles)); 0087 } 0088 if(m_defaultCellStyle) { 0089 writer.addAttribute("table:default-cell-style-name", m_defaultCellStyle->saveOdf(styles)); 0090 } 0091 writer.addAttribute("table:visibility", visibilityMap.value(m_visibility)); 0092 } 0093 0094 void KoRow::finishSaveOdf(KoXmlWriter& writer, KoGenStyles& styles) 0095 { 0096 Q_UNUSED(styles) 0097 writer.endElement();//table:row 0098 }