LibreOffice Module lotuswordpro (master) 1
xfcellstyle.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 * Table cell style. Number format, string value, and so on...
59 ************************************************************************/
61#include <xfilter/xfborders.hxx>
62#include <xfilter/xffont.hxx>
63#include <xfilter/xfbgimage.hxx>
64#include <xfilter/xfutil.hxx>
65
67 : m_eHoriAlign(enumXFAlignNone)
68 , m_eVertAlign(enumXFAlignNone)
69{}
70
72{
73}
74
75void XFCellStyle::SetPadding(double left, double right,double top, double bottom)
76{
77 if( left != -1 )
79 if( right != -1 )
81 if( top != -1 )
83 if( bottom != -1 )
85}
86
88{
90}
91
92void XFCellStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
93{
94 m_xBackImage = std::move(rImage);
95}
96
98{
99 m_pBorders.reset( pBorders );
100}
101
103{
105}
106
111{
112 if( this == pStyle )
113 return true;
114 if( !pStyle || pStyle->GetStyleFamily() != enumXFStyleTableCell )
115 return false;
116
117 XFCellStyle *pOther = dynamic_cast<XFCellStyle*>(pStyle);
118 if( !pOther )
119 return false;
120
121 if( m_strDataStyle != pOther->m_strDataStyle )
122 return false;
123
125 return false;
126
127 //align:
128 if( m_eHoriAlign != pOther->m_eHoriAlign )
129 return false;
130 if( m_eVertAlign != pOther->m_eVertAlign )
131 return false;
132
133 if( m_aBackColor != pOther->m_aBackColor )
134 return false;
135 //shadow:
136 if( m_aShadow != pOther->m_aShadow )
137 return false;
138 //margin:
139 if( m_aMargin != pOther->m_aMargin )
140 return false;
141 //padding:
142 if( m_aPadding != pOther->m_aPadding )
143 return false;
144
145 //font:
146 if( m_pFont.is() )
147 {
148 if( !pOther->m_pFont.is() )
149 return false;
150 if(*m_pFont != *pOther->m_pFont )
151 return false;
152 }
153 else if( pOther->m_pFont.is() )
154 return false;
155
156 //border:
157 if( m_pBorders )
158 {
159 if( !pOther->m_pBorders )
160 return false;
161 if( *m_pBorders != *pOther->m_pBorders )
162 return false;
163 }
164 else if( pOther->m_pBorders )
165 return false;
166
167 //if there is backimage
168 if (m_xBackImage)
169 {
170 if( !pOther->m_xBackImage )
171 return false;
172 if( !m_xBackImage->Equal(pOther) )
173 return false;
174 }
175 else
176 {
177 if( pOther->m_xBackImage )
178 return false;
179 }
180
181 return true;
182}
183
185{
186 IXFAttrList *pAttrList = pStrm->GetAttrList();
187 OUString style = GetStyleName();
188
189 pAttrList->Clear();
190 if( !style.isEmpty() )
191 pAttrList->AddAttribute("style:name",GetStyleName());
192 if( !GetParentStyleName().isEmpty() )
193 pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
194
195 pAttrList->AddAttribute("style:family", "table-cell");
196 if( !m_strParentStyleName.isEmpty() )
197 pAttrList->AddAttribute("style:parent-style-name",m_strParentStyleName);
198 if( !m_strDataStyle.isEmpty() )
199 pAttrList->AddAttribute( "style:data-style-name", m_strDataStyle );
200
201 pStrm->StartElement("style:style");
202
203 //Paragraph properties:
204 pAttrList->Clear();
205
206 //padding:
207 m_aPadding.ToXml(pStrm);
208 //margin:
209 m_aMargin.ToXml(pStrm);
210
211 //text horizontal align:
213 {
214 pAttrList->AddAttribute("fo:text-align", GetAlignName(m_eHoriAlign) );
215 }
216 //text vertical align
218 pAttrList->AddAttribute( "fo:vertical-align", GetAlignName(m_eVertAlign) );
219
220 //shadow:
221 m_aShadow.ToXml(pStrm);
222 //borders:
223 if( m_pBorders )
224 m_pBorders->ToXml(pStrm);
225
226 //background color:
228 {
229 pAttrList->AddAttribute("fo:background-color", m_aBackColor.ToString() );
230 }
231 //Font properties:
232 if( m_pFont.is() )
233 m_pFont->ToXml(pStrm);
234
235 pStrm->StartElement("style:properties");
236
237 if( m_xBackImage )
238 m_xBackImage->ToXml(pStrm);
239
240 pStrm->EndElement("style:properties");
241
242 pStrm->EndElement("style:style");
243}
244
245/* 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()
@descr Interface for all style object.
Definition: ixfstyle.hxx:71
virtual enumXFStyle GetStyleFamily()=0
@descr: return the style family.
Borders for object with borders.
Definition: xfborders.hxx:134
@descr Style object for cell.
Definition: xfcellstyle.hxx:85
OUString m_strDataStyle
XFShadow m_aShadow
enumXFAlignType m_eVertAlign
void SetBackImage(std::unique_ptr< XFBGImage > &rImage)
descr: set cell background image.
Definition: xfcellstyle.cxx:92
void SetBackColor(XFColor const &color)
@descr: Set background color of the cell.
Definition: xfcellstyle.cxx:87
void SetBorders(XFBorders *pBorders)
@descr: The borders are complex, so you have to create one before use.
Definition: xfcellstyle.cxx:97
virtual bool Equal(IXFStyle *pStyle) override
Affirm whether two XFCellStyle objects are equal.
enumXFAlignType m_eHoriAlign
rtl::Reference< XFFont > m_pFont
std::unique_ptr< XFBorders > m_pBorders
XFColor m_aBackColor
XFMargins m_aMargin
XFPadding m_aPadding
virtual void ToXml(IXFStream *pStrm) override
virtual enumXFStyle GetStyleFamily() override
@descr get style family.
virtual ~XFCellStyle() override
Definition: xfcellstyle.cxx:71
void SetPadding(double left, double right, double top, double bottom)
@descr: Set the padding of the paragraph.This is the distance between the border and the top of the t...
Definition: xfcellstyle.cxx:75
std::unique_ptr< XFBGImage > m_xBackImage
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: xfmargins.cxx:78
void ToXml(IXFStream *pStrm)
@descr Output padding properties.
Definition: xfpadding.hxx:159
void SetBottom(double bottom)
@descr Set padding bottom.
Definition: xfpadding.hxx:153
void SetLeft(double left)
@descr Set padding left.
Definition: xfpadding.hxx:135
void SetTop(double top)
@descr Set padding top.
Definition: xfpadding.hxx:147
void SetRight(double right)
@descr Set padding right.
Definition: xfpadding.hxx:141
void ToXml(IXFStream *pStrm)
Definition: xfshadow.cxx:96
virtual OUString GetStyleName() override
@descr get style name.
Definition: xfstyle.cxx:70
OUString m_strParentStyleName
Definition: xfstyle.hxx:114
virtual OUString GetParentStyleName() override
@descr set parent style name.
Definition: xfstyle.cxx:80
OString right
OString top
OString bottom
sal_uInt64 left
enumXFStyle
Definition: xfdefs.hxx:80
@ enumXFStyleTableCell
Definition: xfdefs.hxx:95
@ enumXFAlignNone
Definition: xfdefs.hxx:173
OUString GetAlignName(enumXFAlignType align)
Definition: xfutil.cxx:296