LibreOffice Module lotuswordpro (master) 1
xfframestyle.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 * Frame style include position,size,rotation and so on.
59 ************************************************************************/
61#include <xfilter/xfcolumns.hxx>
62#include <xfilter/xfborders.hxx>
63#include <xfilter/xfshadow.hxx>
64#include <xfilter/xfbgimage.hxx>
65#include <xfilter/xfutil.hxx>
66
68 : m_eWrap(enumXFWrapNone)
69 , m_bProtectContent(false)
70 , m_bProtectSize(false)
71 , m_bProtectPos(false)
72 , m_nTransparency(0)
73 , m_eTextDir(enumXFTextDirNone)
74 , m_eXPos(enumXFFrameXPosCenter)
76 , m_eYPos(enumXFFrameYPosTop)
77 , m_eYRel(enumXFFrameYRelPage)
78{}
79
81{
82}
83
84void XFFrameStyle::SetBorders(std::unique_ptr<XFBorders> pBorders)
85{
86 m_pBorders = std::move(pBorders);
87}
88
90{
91 m_pColumns.reset(pColumns);
92}
93
95{
96 m_pShadow.reset(pShadow);
97}
98
99void XFFrameStyle::SetBackImage(std::unique_ptr<XFBGImage>& rImage)
100{
101 m_pBGImage = std::move(rImage);
102}
103
105{
106 return enumXFStyleGraphics;
107}
108
110{
111 IXFAttrList *pAttrList = pStrm->GetAttrList();
112
113 pAttrList->Clear();
114 pAttrList->AddAttribute( "style:name", GetStyleName() );
115 if( GetParentStyleName().getLength() > 0 )
116 pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
117 pAttrList->AddAttribute( "style:family", "graphics" );
118 //parent style name ignore now.
119 pStrm->StartElement( "style:style" );
120
121 m_aMargins.ToXml(pStrm);
122
123 pAttrList->Clear();
124
125 pAttrList->AddAttribute( "style:run-through", "foreground" );
126
127 if( m_eWrap == enumXFWrapNone )
128 pAttrList->AddAttribute( "style:wrap", "none" );
129 else if( m_eWrap == enumXFWrapLeft )
130 pAttrList->AddAttribute( "style:wrap", "left" );
131 else if( m_eWrap == enumXFWrapRight )
132 pAttrList->AddAttribute( "style:wrap", "right" );
133 else if( m_eWrap == enumXFWrapParallel )
134 pAttrList->AddAttribute( "style:wrap", "parallel" );
135 else if( m_eWrap == enumXFWrapRunThrough )
136 pAttrList->AddAttribute( "style:wrap", "run-through" );
137 else if( m_eWrap == enumXFWrapBest )
138 pAttrList->AddAttribute( "style:wrap", "dynamic" );
139 //}
140 //background
141 if( m_aBackColor.IsValid() )
142 {
143 pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
144 pAttrList->AddAttribute( "style:background-transparency", OUString::number(static_cast<sal_Int32>(m_nTransparency)) + "%");
145 }
146
147 //pad
148 m_aPad.ToXml(pStrm);
149 //margin:
150 m_aMargins.ToXml(pStrm);
151 //border
152 if( m_pBorders )
153 m_pBorders->ToXml(pStrm);
154 else
155 pAttrList->AddAttribute( "fo:border", "none" );
156 //shadow
157 if( m_pShadow )
158 m_pShadow->ToXml(pStrm);
159 //print
160 pAttrList->AddAttribute( "style:print-content", "true" );
161 //text directory
163 pAttrList->AddAttribute( "style:writing-mode", GetTextDirName(m_eTextDir) );
164 //protect:
166 {
167 OUString protect;
169 protect += "content";
170 if( m_bProtectSize )
171 {
172 if( protect.getLength()>0 )
173 protect += " ";
174 protect += "size";
175 }
176 if( m_bProtectPos )
177 {
178 if( protect.getLength()>0 )
179 protect += " ";
180 protect += "position";
181 }
182 pAttrList->AddAttribute( "style:protect", protect );
183 }
184 //vertical pos and horizon pos:
185 pAttrList->AddAttribute( "style:vertical-pos", GetFrameYPos(m_eYPos) );
186 pAttrList->AddAttribute( "style:vertical-rel", GetFrameYRel(m_eYRel) );
187 pAttrList->AddAttribute( "style:horizontal-pos", GetFrameXPos(m_eXPos) );
188 pAttrList->AddAttribute( "style:horizontal-rel", GetFrameXRel(m_eXRel) );
189
190 pStrm->StartElement( "style:properties" );
191 if( m_pColumns )
192 m_pColumns->ToXml(pStrm);
193 if( m_pBGImage )
194 m_pBGImage->ToXml(pStrm);
195 pStrm->EndElement( "style:properties" );
196
197 pStrm->EndElement( "style:style" );
198}
199/* 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()
bool IsValid() const
@descr helper function to assert whether a color is valid.
Definition: xfcolor.hxx:99
OUString ToString() const
Definition: xfcolor.cxx:63
std::unique_ptr< XFBorders > m_pBorders
XFColor m_aBackColor
bool m_bProtectContent
void SetColumns(XFColumns *pColumns)
@descr: set the column property of the frame.
std::unique_ptr< XFColumns > m_pColumns
enumXFFrameXPos m_eXPos
sal_Int16 m_nTransparency
XFMargins m_aMargins
std::unique_ptr< XFShadow > m_pShadow
enumXFTextDir m_eTextDir
std::unique_ptr< XFBGImage > m_pBGImage
void SetShadow(XFShadow *pShadow)
@descr: set the shadow object the frame.
XFPadding m_aPad
virtual void ToXml(IXFStream *pStrm) override
enumXFFrameYPos m_eYPos
virtual ~XFFrameStyle() override
void SetBorders(std::unique_ptr< XFBorders > pBorders)
@descr: set the border property of the frame.
void SetBackImage(std::unique_ptr< XFBGImage > &rImage)
@descr: set the background image of the frame.
enumXFFrameXRel m_eXRel
enumXFWrap m_eWrap
enumXFFrameYRel m_eYRel
virtual enumXFStyle GetStyleFamily() override
@descr get style family.
void ToXml(IXFStream *pStrm)
Definition: xfmargins.cxx:78
void ToXml(IXFStream *pStrm)
@descr Output padding properties.
Definition: xfpadding.hxx:159
Shadow object.
Definition: xfshadow.hxx:72
virtual OUString GetStyleName() override
@descr get style name.
Definition: xfstyle.cxx:70
virtual OUString GetParentStyleName() override
@descr set parent style name.
Definition: xfstyle.cxx:80
double getLength(const B2DPolygon &rCandidate)
@ enumXFWrapBest
Definition: xfdefs.hxx:272
@ enumXFWrapNone
Definition: xfdefs.hxx:267
@ enumXFWrapLeft
Definition: xfdefs.hxx:268
@ enumXFWrapRunThrough
Definition: xfdefs.hxx:271
@ enumXFWrapRight
Definition: xfdefs.hxx:269
@ enumXFWrapParallel
Definition: xfdefs.hxx:270
enumXFStyle
Definition: xfdefs.hxx:80
@ enumXFStyleGraphics
Definition: xfdefs.hxx:86
@ enumXFFrameYPosTop
Definition: xfdefs.hxx:330
@ enumXFFrameYRelPage
Definition: xfdefs.hxx:321
@ enumXFFrameXPosCenter
Definition: xfdefs.hxx:310
@ enumXFTextDirNone
Definition: xfdefs.hxx:278
@ enumXFFrameXRelParaContent
Definition: xfdefs.hxx:296
OUString GetFrameXRel(enumXFFrameXRel rel)
Definition: xfutil.cxx:214
OUString GetFrameYRel(enumXFFrameYRel rel)
Definition: xfutil.cxx:268
OUString GetFrameXPos(enumXFFrameXPos pos)
Definition: xfutil.cxx:196
OUString GetTextDirName(enumXFTextDir dir)
Definition: xfutil.cxx:170
OUString GetFrameYPos(enumXFFrameYPos pos)
Definition: xfutil.cxx:250