LibreOffice Module lotuswordpro (master) 1
xfpagemaster.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 * Page master used bye XFMasterPage.
59 * It is the real object to define header and footer of pages.
60 ************************************************************************/
62#include <xfilter/ixfstream.hxx>
64#include <xfilter/xfborders.hxx>
65#include <xfilter/xfshadow.hxx>
66#include <xfilter/xfcolumns.hxx>
69#include <xfilter/xfbgimage.hxx>
70#include <xfilter/xfutil.hxx>
71
72XFPageMaster::XFPageMaster() : m_fPageWidth(0), m_fPageHeight(0), m_eUsage(enumXFPageUsageNone),
73m_eTextDir(enumXFTextDirNone),
74m_eSepAlign(enumXFAlignNone), m_fSepWidth(0), m_aSepColor(0), m_fSepSpaceAbove(0),
75m_fSepSpaceBelow(0), m_nSepLengthPercent(0)
76{
77}
78
80{
81}
82
84{
86}
87
89{
90 m_fPageWidth = width;
91}
92
93void XFPageMaster::SetPageHeight(double height)
94{
95 m_fPageHeight = height;
96}
97
98void XFPageMaster::SetMargins(double left, double right,double top, double bottom)
99{
100 if( left != -1 )
102 if( right != -1 )
104 if( top != -1 )
106 if( bottom != -1 )
108}
109
110void XFPageMaster::SetBorders(std::unique_ptr<XFBorders> pBorders)
111{
112 m_pBorders = std::move( pBorders );
113}
114
116{
117 if( pShadow == m_pShadow.get() )
118 return;
119 m_pShadow.reset( pShadow );
120}
121
123{
125}
126
127void XFPageMaster::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
128{
129 m_pBGImage = std::move(rImage);
130}
131
133{
134 if( pColumns == m_pColumns.get() )
135 return;
136 m_pColumns.reset(pColumns);
137}
138
140{
141 if( pHeaderStyle == m_pHeaderStyle.get() )
142 return;
143 m_pHeaderStyle.reset( pHeaderStyle );
144}
145
147{
148 if( pFooterStyle == m_pFooterStyle.get() )
149 return;
150 m_pFooterStyle.reset( pFooterStyle );
151}
152
154 enumXFAlignType align,
155 double width,
156 sal_Int32 lengthPercent,
157 double spaceAbove,
158 double spaceBelow,
160 )
161{
162 m_eSepAlign = align;
163 m_fSepWidth = width;
164 m_nSepLengthPercent = lengthPercent;
165 m_fSepSpaceAbove = spaceAbove;
166 m_fSepSpaceBelow = spaceBelow;
168}
169
193{
194 IXFAttrList *pAttrList = pStream->GetAttrList();
195
196 pAttrList->Clear();
197 pAttrList->AddAttribute("style:name",GetStyleName());
198
200 pAttrList->AddAttribute("style:page-usage", GetPageUsageName(m_eUsage));
201
202 pStream->StartElement( "style:page-master" );
203
204 //style:properties
205 pAttrList->Clear();
206 if( m_fPageWidth != 0 )
207 pAttrList->AddAttribute( "fo:page-width", OUString::number(m_fPageWidth) + "cm" );
208 if( m_fPageHeight != 0 )
209 pAttrList->AddAttribute( "fo:page-height", OUString::number(m_fPageHeight) + "cm" );
210
211 m_aMargin.ToXml(pStream);
212
213 pAttrList->AddAttribute( "style:print-orientation", "portrait" );
214
215 if( m_pBorders )
216 m_pBorders->ToXml(pStream);
217 if( m_pShadow )
218 pAttrList->AddAttribute( "style:shadow", m_pShadow->ToString() );
219
220 if( m_aBackColor.IsValid() )
221 pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
222
223 //text directory
225 pAttrList->AddAttribute( "style:writing-mode", GetTextDirName(m_eTextDir) );
226
227 pStream->StartElement( "style:properties" );
228 if( m_pColumns )
229 m_pColumns->ToXml(pStream);
230
231 if( m_pBGImage )
232 m_pBGImage->ToXml(pStream);
233
235 {
236 pAttrList->Clear();
237 pAttrList->AddAttribute( "style:width", OUString::number(m_fSepWidth) + "cm" );
238 pAttrList->AddAttribute( "style:distance-before-sep", OUString::number(m_fSepSpaceAbove) + "cm" );
239 pAttrList->AddAttribute( "style:distance-after-sep", OUString::number(m_fSepSpaceBelow) + "cm" );
240 pAttrList->AddAttribute( "style:color", m_aSepColor.ToString() );
242 pAttrList->AddAttribute( "style:adjustment", "left" );
243 else if( m_eSepAlign == enumXFAlignCenter )
244 pAttrList->AddAttribute( "style:adjustment", "center" );
245 else if( m_eSepAlign == enumXFAlignEnd )
246 pAttrList->AddAttribute( "style:adjustment", "right" );
247 pAttrList->AddAttribute( "style:rel-width", OUString::number(m_nSepLengthPercent) + "%" );
248 pStream->StartElement( "style:footnote-sep" );
249 pStream->EndElement( "style:footnote-sep" );
250 }
251
252 pStream->EndElement( "style:properties" );
253
254 //header style:
255 if( m_pHeaderStyle )
256 m_pHeaderStyle->ToXml(pStream);
257 //footer style:
258 if( m_pFooterStyle )
259 m_pFooterStyle->ToXml(pStream);
260
261 pStream->EndElement( "style:page-master" );
262
263}
264
265/* 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 SetLeft(double left)
Definition: xfmargins.hxx:96
void SetRight(double right)
Definition: xfmargins.hxx:102
void SetBottom(double bottom)
Definition: xfmargins.hxx:114
void SetTop(double top)
Definition: xfmargins.hxx:108
void ToXml(IXFStream *pStrm)
Definition: xfmargins.cxx:78
void SetBackImage(std::unique_ptr< XFBGImage > &rImage)
double m_fSepSpaceAbove
double m_fSepSpaceBelow
std::unique_ptr< XFShadow > m_pShadow
XFMargins m_aMargin
void SetHeaderStyle(XFHeaderStyle *pHeaderStyle)
std::unique_ptr< XFBorders > m_pBorders
void SetBackColor(XFColor color)
void SetMargins(double left, double right, double top, double bottom)
void SetPageWidth(double width)
enumXFTextDir m_eTextDir
void SetFooterStyle(XFFooterStyle *pFooterStyle)
enumXFAlignType m_eSepAlign
std::unique_ptr< XFBGImage > m_pBGImage
sal_Int32 m_nSepLengthPercent
double m_fSepWidth
XFColor m_aSepColor
std::unique_ptr< XFColumns > m_pColumns
virtual void ToXml(IXFStream *pStream) override
<style:page-master style:name="pm1"> <style:properties fo:page-width="20.999cm" fo:page-height="29....
XFColor m_aBackColor
void SetFootNoteSeparator(enumXFAlignType align, double width, sal_Int32 lengthPercent, double spaceAbove, double spaceBelow, XFColor color)
std::unique_ptr< XFHeaderStyle > m_pHeaderStyle
virtual enumXFStyle GetStyleFamily() override
@descr get style family.
void SetBorders(std::unique_ptr< XFBorders > pBorders)
void SetShadow(XFShadow *pShadow)
void SetPageHeight(double height)
virtual ~XFPageMaster() override
std::unique_ptr< XFFooterStyle > m_pFooterStyle
double m_fPageWidth
enumXFPageUsage m_eUsage
double m_fPageHeight
void SetColumns(XFColumns *pColumns)
Shadow object.
Definition: xfshadow.hxx:72
virtual OUString GetStyleName() override
@descr get style name.
Definition: xfstyle.cxx:70
OString right
OString top
OString bottom
sal_uInt64 left
enumXFStyle
Definition: xfdefs.hxx:80
@ enumXFStylePageMaster
Definition: xfdefs.hxx:87
@ enumXFPageUsageNone
Definition: xfdefs.hxx:397
enumXFAlignType
Definition: xfdefs.hxx:172
@ enumXFAlignStart
Definition: xfdefs.hxx:174
@ enumXFAlignEnd
Definition: xfdefs.hxx:176
@ enumXFAlignCenter
Definition: xfdefs.hxx:175
@ enumXFAlignNone
Definition: xfdefs.hxx:173
@ enumXFTextDirNone
Definition: xfdefs.hxx:278
OUString GetTextDirName(enumXFTextDir dir)
Definition: xfutil.cxx:170
OUString GetPageUsageName(enumXFPageUsage usage)
Definition: xfutil.cxx:318