1 /*
2  *  Copyright (c) 2010 Carlos Licea <carlos@kdab.com>
3  *
4  *  This library is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU Lesser General Public License as published
6  *  by the Free Software Foundation; either version 2.1 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This library is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include "KoRow.h"
20 
21 #include <KoXmlWriter.h>
22 
23 #include <QMap>
24 #include <QString>
25 
26 namespace {
27     class VisibilityMap : public QMap<KoRow::Visibility, QString>
28     {
29     public:
VisibilityMap()30         VisibilityMap()
31         : QMap<KoRow::Visibility, QString>()
32         {
33             insert(KoRow::Collapse, "colapse");
34             insert(KoRow::Filter, "filter");
35             insert(KoRow::Visible, "visible");
36         }
37     } visibilityMap;
38 }
39 
40 
KoRow()41 KoRow::KoRow()
42 : m_defaultCellStyle(0)
43 , m_style(0)
44 , m_visibility(Visible)
45 {
46 }
47 
~KoRow()48 KoRow::~KoRow()
49 {
50 }
51 
setStyle(KoRowStyle::Ptr style)52 void KoRow::setStyle(KoRowStyle::Ptr style)
53 {
54     m_style = style;
55 }
56 
style()57 KoRowStyle::Ptr KoRow::style()
58 {
59     return m_style;
60 }
61 
defualtCellStyle() const62 KoCellStyle::Ptr KoRow::defualtCellStyle() const
63 {
64     return m_defaultCellStyle;
65 }
66 
setDefaultCellStyle(KoCellStyle::Ptr defaultStyle)67 void KoRow::setDefaultCellStyle(KoCellStyle::Ptr defaultStyle)
68 {
69     m_defaultCellStyle = defaultStyle;
70 }
71 
setVisibility(KoRow::Visibility visibility)72 void KoRow::setVisibility(KoRow::Visibility visibility)
73 {
74     m_visibility = visibility;
75 }
76 
visibility()77 KoRow::Visibility KoRow::visibility()
78 {
79     return m_visibility;
80 }
81 
saveOdf(KoXmlWriter & writer,KoGenStyles & styles)82 void KoRow::saveOdf(KoXmlWriter& writer, KoGenStyles& styles)
83 {
84     writer.startElement("table:table-row");
85     if(m_style) {
86         writer.addAttribute("table:style-name", m_style->saveOdf(styles));
87     }
88     if(m_defaultCellStyle) {
89         writer.addAttribute("table:default-cell-style-name", m_defaultCellStyle->saveOdf(styles));
90     }
91     writer.addAttribute("table:visibility", visibilityMap.value(m_visibility));
92 }
93 
finishSaveOdf(KoXmlWriter & writer,KoGenStyles & styles)94 void KoRow::finishSaveOdf(KoXmlWriter& writer, KoGenStyles& styles)
95 {
96     Q_UNUSED(styles)
97     writer.endElement();//table:row
98 }
99