merge the formfield patch from ooo-build
[ooovba.git] / writerperfect / source / filter / SectionStyle.cxx
blobde94e9cfd8b56109058b5ebc4dce1b305350d439
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
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * For further information visit http://libwpd.sourceforge.net
26 /* "This product is not manufactured, approved, or supported by
27 * Corel Corporation or Corel Corporation Limited."
29 #include "FilterInternal.hxx"
30 #include "SectionStyle.hxx"
31 #include "DocumentElement.hxx"
32 #include <math.h>
34 #ifdef _MSC_VER
35 double rint(double x);
36 #endif /* _MSC_VER */
38 SectionStyle::SectionStyle(const WPXPropertyList &xPropList,
39 const WPXPropertyListVector &xColumns,
40 const char *psName) :
41 Style(psName),
42 mPropList(xPropList),
43 mColumns(xColumns)
47 void SectionStyle::write(DocumentHandler *pHandler) const
49 TagOpenElement styleOpen("style:style");
50 styleOpen.addAttribute("style:name", getName());
51 styleOpen.addAttribute("style:family", "section");
52 styleOpen.write(pHandler);
54 // if the number of columns is <= 1, we will never come here. This is only an additional check
55 // style properties
56 pHandler->startElement("style:properties", mPropList);
58 // column properties
59 WPXPropertyList columnProps;
61 if (mColumns.count() > 1)
63 columnProps.insert("fo:column-count", (int)mColumns.count());
64 pHandler->startElement("style:columns", columnProps);
66 WPXPropertyListVector::Iter i(mColumns);
67 for (i.rewind(); i.next();)
69 pHandler->startElement("style:column", i());
70 pHandler->endElement("style:column");
73 else
75 columnProps.insert("fo:column-count", 0);
76 columnProps.insert("fo:column-gap", 0.0f);
77 pHandler->startElement("style:columns", columnProps);
80 pHandler->endElement("style:columns");
83 pHandler->endElement("style:properties");
85 pHandler->endElement("style:style");