LibreOffice Module lotuswordpro (master) 1
xfcolumns.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
6 *
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
9 *
10 * Sun Microsystems Inc., October, 2000
11 *
12 * GNU Lesser General Public License Version 2.1
13 * =============================================
14 * Copyright 2000 by Sun Microsystems, Inc.
15 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License version 2.1, as published by the Free Software Foundation.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 * MA 02111-1307 USA
30 *
31 *
32 * Sun Industry Standards Source License Version 1.1
33 * =================================================
34 * The contents of this file are subject to the Sun Industry Standards
35 * Source License Version 1.1 (the "License"); You may not use this file
36 * except in compliance with the License. You may obtain a copy of the
37 * License at http://www.openoffice.org/license.html.
38 *
39 * Software provided under this License is provided on an "AS IS" basis,
40 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 * See the License for the specific provisions governing your rights and
44 * obligations concerning the Software.
45 *
46 * The Initial Developer of the Original Code is: IBM Corporation
47 *
48 * Copyright: 2008 by IBM Corporation
49 *
50 * All Rights Reserved.
51 *
52 * Contributor(s): _______________________________________
53 *
54 *
55 ************************************************************************/
56/*************************************************************************
57 * @file
58 * Columns styles for section, or paragraph.
59 ************************************************************************/
60#include <xfilter/xfcolumns.hxx>
62
63void XFColumn::SetRelWidth(sal_Int32 width)
64{
65 m_nRelWidth = width;
66}
67
68void XFColumn::SetMargins(double left, double right)
69{
72}
73
75{
76 IXFAttrList *pAttrList = pStrm->GetAttrList();
77 pAttrList->Clear();
78
79 pAttrList->AddAttribute( "style:rel-width", OUString::number(m_nRelWidth) + "*" );
80 pAttrList->AddAttribute( "fo:margin-left", OUString::number(m_fMarginLeft) + "cm" );
81 pAttrList->AddAttribute( "fo:margin-right", OUString::number(m_fMarginRight) + "cm" );
82
83 pStrm->StartElement( "style:column" );
84 pStrm->EndElement( "style:column" );
85}
86
87void XFColumnSep::SetRelHeight(sal_Int32 height)
88{
89 assert(height>=0&&height<=100);
90 m_nRelHeight = height;
91}
92void XFColumnSep::SetWidth(double width)
93{
94 m_fWidth = width;
95}
97{
99}
101{
102 m_eVertAlign = align;
103}
104
106{
107 IXFAttrList *pAttrList = pStrm->GetAttrList();
108
109 pAttrList->Clear();
110 pAttrList->AddAttribute( "style:width", OUString::number(m_fWidth) + "cm" );
111 if( m_aColor.IsValid() )
112 pAttrList->AddAttribute( "style:color", m_aColor.ToString() );
113 pAttrList->AddAttribute( "style:height", OUString::number(m_nRelHeight) + "%" );
114 //text align:
116 {
117 pAttrList->AddAttribute("style:vertical-align","top");
118 }
119 else if( m_eVertAlign == enumXFAlignMiddle )
120 {
121 pAttrList->AddAttribute("style:vertical-align","middle");
122 }
123 else if( m_eVertAlign == enumXFAlignBottom )
124 {
125 pAttrList->AddAttribute("style:vertical-align","bottom");
126 }
127
128 pStrm->StartElement( "style:column-sep" );
129 pStrm->EndElement( "style:column-sep" );
130}
131
132void XFColumns::SetSeparator(XFColumnSep const & aSeparator)
133{
134 m_aSeparator = aSeparator;
136}
137
138void XFColumns::AddColumn(XFColumn const & column)
139{
140 m_aColumns.push_back(column);
141}
142
143void XFColumns::SetGap(double fGap)
144{
145 m_fGap = fGap;
147}
148
149void XFColumns::SetCount(sal_uInt16 nCount)
150{
152}
153
155{
156 IXFAttrList *pAttrList = pStrm->GetAttrList();
157 pAttrList->Clear();
158
159 pAttrList->AddAttribute( "fo:column-count", OUString::number(m_nCount));
161 {
162 pAttrList->AddAttribute( "fo:column-gap", OUString::number(m_fGap)+"cm" );
163 }
164
165 pStrm->StartElement( "style:columns" );
166
167 if( m_nFlag&XFCOLUMNS_FLAG_SEPARATOR ) //column-sep:
168 {
169 m_aSeparator.ToXml(pStrm);
170 }
171
173 {
174 for (auto & column : m_aColumns)
175 {
176 column.ToXml(pStrm);
177 }
178 }
179 pStrm->EndElement( "style:columns" );
180}
181/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Attribute list interface for sax writer.
Definition: ixfattrlist.hxx:72
virtual void Clear()=0
@descr: Clear all the attributes in the attribute list.
virtual void AddAttribute(const OUString &name, const OUString &value)=0
@descr: Add an attribute to the attribute list.
Stream wrapper for sax writer.
Definition: ixfstream.hxx:72
virtual IXFAttrList * GetAttrList()=0
@descr return the Attribute list interface.
virtual void StartElement(const OUString &oustr)=0
@descr Wrap XDocumentHandler::startElement()
virtual void EndElement(const OUString &oustr)=0
@descr Wrap XDocumentHandler::endElement()
Color object.
Definition: xfcolor.hxx:70
bool IsValid() const
@descr helper function to assert whether a color is valid.
Definition: xfcolor.hxx:99
OUString ToString() const
Definition: xfcolor.cxx:63
void ToXml(IXFStream *pStrm)
Definition: xfcolumns.cxx:105
enumXFAlignType m_eVertAlign
Definition: xfcolumns.hxx:128
XFColor m_aColor
Definition: xfcolumns.hxx:127
double m_fWidth
Definition: xfcolumns.hxx:126
void SetColor(XFColor const &color)
Definition: xfcolumns.cxx:96
void SetRelHeight(sal_Int32 height)
Definition: xfcolumns.cxx:87
void SetWidth(double width)
Definition: xfcolumns.cxx:92
void SetVerticalAlign(enumXFAlignType align)
Definition: xfcolumns.cxx:100
sal_Int32 m_nRelHeight
Definition: xfcolumns.hxx:125
@descr Columns object for page or section.
Definition: xfcolumns.hxx:75
double m_fMarginRight
Definition: xfcolumns.hxx:104
void ToXml(IXFStream *pStrm)
@descr output column style as an xml node.
Definition: xfcolumns.cxx:74
sal_Int32 m_nRelWidth
Definition: xfcolumns.hxx:102
void SetRelWidth(sal_Int32 width)
@descr Set column relative width.
Definition: xfcolumns.cxx:63
void SetMargins(double left, double right)
@descr Set column margin left and margin right.
Definition: xfcolumns.cxx:68
double m_fMarginLeft
Definition: xfcolumns.hxx:103
void AddColumn(XFColumn const &column)
Definition: xfcolumns.cxx:138
void SetCount(sal_uInt16 nCount)
Definition: xfcolumns.cxx:149
sal_uInt16 m_nCount
Definition: xfcolumns.hxx:148
void SetSeparator(XFColumnSep const &aSeparator)
Definition: xfcolumns.cxx:132
void ToXml(IXFStream *pStrm)
Definition: xfcolumns.cxx:154
sal_Int32 m_nFlag
Definition: xfcolumns.hxx:147
std::vector< XFColumn > m_aColumns
Definition: xfcolumns.hxx:150
double m_fGap
Definition: xfcolumns.hxx:149
XFColumnSep m_aSeparator
Definition: xfcolumns.hxx:151
void SetGap(double fGap)
Definition: xfcolumns.cxx:143
int nCount
OString right
sal_uInt64 left
#define XFCOLUMNS_FLAG_SEPARATOR
Definition: xfcolumns.hxx:68
#define XFCOLUMNS_FLAG_GAP
Definition: xfcolumns.hxx:69
enumXFAlignType
Definition: xfdefs.hxx:172
@ enumXFAlignBottom
Definition: xfdefs.hxx:180
@ enumXFAlignMiddle
Definition: xfdefs.hxx:179
@ enumXFAlignTop
Definition: xfdefs.hxx:178