Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* SectionStyle: Stores (and writes) section-based information (e.g.: a column
3 : * break needs a new section) that is needed at the head of an OO document and
4 : * is referenced throughout the entire document
5 : *
6 : * This Source Code Form is subject to the terms of the Mozilla Public
7 : * License, v. 2.0. If a copy of the MPL was not distributed with this
8 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 : *
10 : * For further information visit http://libwpd.sourceforge.net
11 : */
12 :
13 : /* "This product is not manufactured, approved, or supported by
14 : * Corel Corporation or Corel Corporation Limited."
15 : */
16 : #include "FilterInternal.hxx"
17 : #include "SectionStyle.hxx"
18 : #include "DocumentElement.hxx"
19 : #include <math.h>
20 :
21 : #ifdef _MSC_VER
22 : double rint(double x);
23 : #endif /* _WIN32 */
24 :
25 0 : SectionStyle::SectionStyle(const WPXPropertyList &xPropList,
26 : const WPXPropertyListVector &xColumns,
27 : const char *psName) :
28 : Style(psName),
29 : mPropList(xPropList),
30 0 : mColumns(xColumns)
31 : {
32 0 : }
33 :
34 0 : void SectionStyle::write(OdfDocumentHandler *pHandler) const
35 : {
36 0 : TagOpenElement styleOpen("style:style");
37 0 : styleOpen.addAttribute("style:name", getName());
38 0 : styleOpen.addAttribute("style:family", "section");
39 0 : styleOpen.write(pHandler);
40 :
41 : // if the number of columns is <= 1, we will never come here. This is only an additional check
42 : // style properties
43 0 : pHandler->startElement("style:section-properties", mPropList);
44 :
45 : // column properties
46 0 : WPXPropertyList columnProps;
47 :
48 0 : if (mColumns.count() > 1)
49 : {
50 0 : columnProps.insert("fo:column-count", (int)mColumns.count());
51 0 : pHandler->startElement("style:columns", columnProps);
52 :
53 0 : WPXPropertyListVector::Iter i(mColumns);
54 0 : for (i.rewind(); i.next();)
55 : {
56 0 : pHandler->startElement("style:column", i());
57 0 : pHandler->endElement("style:column");
58 0 : }
59 : }
60 : else
61 : {
62 0 : columnProps.insert("fo:column-count", 0);
63 0 : columnProps.insert("fo:column-gap", 0.0);
64 0 : pHandler->startElement("style:columns", columnProps);
65 : }
66 :
67 0 : pHandler->endElement("style:columns");
68 :
69 :
70 0 : pHandler->endElement("style:section-properties");
71 :
72 0 : pHandler->endElement("style:style");
73 0 : }
74 :
75 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|