SectionStyle.cpp
1/* SectionStyle: Stores (and writes) section-based information (e.g.: a column
2 * break needs a new section) that is needed at the head of an OO document and
3 * is referenced throughout the entire document
4 *
5 * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
6 * Copyright (c) 2004 Fridrich Strba (fridrich.strba@bluewin.ch)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 * For further information visit http://libwpd.sourceforge.net
24 *
25 */
26
27/* "This product is not manufactured, approved, or supported by
28 * Corel Corporation or Corel Corporation Limited."
29 */
30#include "FilterInternal.h"
31#include "SectionStyle.h"
32#include "DocumentElement.h"
33#include <math.h>
34
35#ifdef _MSC_VER
36double rint(double x);
37#endif /* _WIN32 */
38
39
40SectionStyle::SectionStyle(const _SH_PropertyList &xPropList,
41 const _SH_PropertyListVector &xColumns,
42 const char *psName) :
43 Style(psName),
44 mPropList(xPropList),
45 mColumns(xColumns)
46{
47}
48
49void SectionStyle::write(DocumentHandler &xHandler) const
50{
51 TagOpenElement styleOpen("style:style");
52 styleOpen.addAttribute("style:name", getName());
53 styleOpen.addAttribute("style:family", "section");
54 styleOpen.write(xHandler);
55
56 // if the number of columns is <= 1, we will never come here. This is only an additional check
57 if (mColumns.count() > 1)
58 {
59 // style properties
60 xHandler.startElement("style:properties", mPropList);
61
62 // column properties
63 _SH_PropertyList columnProps;
64 columnProps.insert("fo:column-count", (int)mColumns.count());
65 xHandler.startElement("style:columns", columnProps);
66
67 _SH_PropertyListVector::Iter i(mColumns);
68 for (i.rewind(); i.next();)
69 {
70 xHandler.startElement("style:column", i());
71 xHandler.endElement("style:column");
72 }
73
74 xHandler.endElement("style:columns");
75 xHandler.endElement("style:properties");
76 }
77
78 xHandler.endElement("style:style");
79}