filters

SectionStyle.cxx

00001 /* SectionStyle: Stores (and writes) section-based information (e.g.: a column
00002  * break needs a new section) that is needed at the head of an OO document and
00003  * is referenced throughout the entire document
00004  *
00005  * Copyright (C) 2002-2003 William Lachance (william.lachance@sympatico.ca)
00006  * Copyright (c) 2004 Fridrich Strba (fridrich.strba@bluewin.ch)
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Library General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Library General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022  *
00023  * For further information visit http://libwpd.sourceforge.net
00024  *
00025  */
00026 
00027 /* "This product is not manufactured, approved, or supported by
00028  * Corel Corporation or Corel Corporation Limited."
00029  */
00030 #include "FilterInternal.hxx"
00031 #include "SectionStyle.hxx"
00032 #include "DocumentElement.hxx"
00033 #include <math.h>
00034 
00035 #ifdef _MSC_VER
00036 double rint(double x);
00037 #endif /* _WIN32 */
00038 
00039 
00040 SectionStyle::SectionStyle(const WPXPropertyList &xPropList,
00041                            const WPXPropertyListVector &xColumns,
00042                            const char *psName) :
00043         Style(psName),
00044         mPropList(xPropList),
00045         mColumns(xColumns)
00046 {
00047 }
00048 
00049 void SectionStyle::write(DocumentHandler &xHandler) const
00050 {
00051     TagOpenElement styleOpen("style:style");
00052     styleOpen.addAttribute("style:name", getName());
00053     styleOpen.addAttribute("style:family", "section");
00054     styleOpen.write(xHandler);
00055 
00056     // if the number of columns is <= 1, we will never come here. This is only an additional check
00057     if (mColumns.count() > 1)
00058     {
00059         // style properties
00060                 xHandler.startElement("style:properties", mPropList);
00061 
00062         // column properties
00063                 WPXPropertyList columnProps;
00064                 columnProps.insert("fo:column-count", (int)mColumns.count());
00065                 xHandler.startElement("style:columns", columnProps);
00066 
00067                 WPXPropertyListVector::Iter i(mColumns);
00068                 for (i.rewind(); i.next();)
00069         {
00070                         xHandler.startElement("style:column", i());
00071                         xHandler.endElement("style:column");
00072         }
00073 
00074                 xHandler.endElement("style:columns");
00075                 xHandler.endElement("style:properties");
00076     }
00077 
00078     xHandler.endElement("style:style");
00079 }
KDE Home | KDE Accessibility Home | Description of Access Keys