LibreOffice Module lotuswordpro (master) 1
xfimagestyle.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 * Image style object.
59 ************************************************************************/
61#include <xfilter/xfborders.hxx>
62#include <xfilter/xfglobal.hxx>
63#include <xfilter/xfshadow.hxx>
64#include <xfilter/xfutil.hxx>
65
67 : m_nBrightness(0)
68 , m_nContrast(0)
69 , m_fClipLeft(0)
70 , m_fClipRight(0)
71 , m_fClipTop(0)
72 , m_fClipBottom(0)
73{}
74
76{
77 IXFAttrList *pAttrList = pStrm->GetAttrList();
78
79 pAttrList->Clear();
80 pAttrList->AddAttribute( "style:name", GetStyleName() );
81 if( !GetParentStyleName().isEmpty() )
82 pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
83 pAttrList->AddAttribute( "style:family", "graphics" );
84 //parent style name ignore now.
85 pStrm->StartElement( "style:style" );
86
87 m_aMargins.ToXml(pStrm);
88
89 pAttrList->Clear();
90
92 {
93 pAttrList->AddAttribute( "style:run-through", "background" );
94 }
95 else
96 {
97 pAttrList->AddAttribute( "style:run-through", "foreground" );
98
99 if( m_eWrap == enumXFWrapNone )
100 pAttrList->AddAttribute( "style:wrap", "none" );
101 else if( m_eWrap == enumXFWrapLeft )
102 pAttrList->AddAttribute( "style:wrap", "left" );
103 else if( m_eWrap == enumXFWrapRight )
104 pAttrList->AddAttribute( "style:wrap", "right" );
105 else if( m_eWrap == enumXFWrapParallel )
106 pAttrList->AddAttribute( "style:wrap", "parallel" );
107 else if( m_eWrap == enumXFWrapRunThrough )
108 pAttrList->AddAttribute( "style:wrap", "run-through" );
109 else if( m_eWrap == enumXFWrapBest )
110 pAttrList->AddAttribute( "style:wrap", "dynamic" );
111 }
112 //background
113 if( m_aBackColor.IsValid() )
114 pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
115 //pad
116 m_aPad.ToXml(pStrm);
117 //margin:
118 m_aMargins.ToXml(pStrm);
119
120 if( m_nBrightness )
121 pAttrList->AddAttribute( "draw:luminance", OUString::number(m_nBrightness) + "%" );
122 if( m_nContrast )
123 pAttrList->AddAttribute( "draw:contrast", OUString::number(m_nContrast) + "%" );
124
125 pAttrList->AddAttribute("draw:color-mode", GetColorMode(enumXFColorStandard));
126 //border
127 if( m_pBorders )
128 m_pBorders->ToXml(pStrm);
129 //shadow
130 if( m_pShadow )
131 m_pShadow->ToXml(pStrm);
132
133 pAttrList->AddAttribute( "style:print-content", "true" );
134 //protect:
136 {
137 OUString protect;
139 protect += "content";
140 if( m_bProtectSize )
141 {
142 if( !protect.isEmpty() )
143 protect += " ";
144 protect += "size";
145 }
146 if( m_bProtectPos )
147 {
148 if( !protect.isEmpty() )
149 protect += " ";
150 protect += "position";
151 }
152 pAttrList->AddAttribute( "style:protect", protect );
153 }
154 //vertical pos and horizon pos:
155 pAttrList->AddAttribute( "style:vertical-pos", GetFrameYPos(m_eYPos) );
156 pAttrList->AddAttribute( "style:vertical-rel", GetFrameYRel(m_eYRel) );
157 pAttrList->AddAttribute( "style:horizontal-pos", GetFrameXPos(m_eXPos) );
158 pAttrList->AddAttribute( "style:horizontal-rel", GetFrameXRel(m_eXRel) );
159
160 //clip:
162 {
163 OUString clip = "rect(" + OUString::number(m_fClipTop) + "cm " +
164 OUString::number(m_fClipRight) + "cm " +
165 OUString::number(m_fClipBottom) + "cm " +
166 OUString::number(m_fClipLeft) + "cm)";
167 pAttrList->AddAttribute("fo:clip",clip);
168 }
169
170 pStrm->StartElement( "style:properties" );
171 pStrm->EndElement( "style:properties" );
172
173 pStrm->EndElement( "style:style" );
174
175}
176
177/* 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
enumXFFrameXPos m_eXPos
XFMargins m_aMargins
std::unique_ptr< XFShadow > m_pShadow
XFPadding m_aPad
enumXFFrameYPos m_eYPos
enumXFFrameXRel m_eXRel
enumXFWrap m_eWrap
enumXFFrameYRel m_eYRel
double m_fClipRight
sal_Int32 m_nContrast
double m_fClipBottom
double m_fClipLeft
double m_fClipTop
virtual void ToXml(IXFStream *pStrm) override
sal_Int32 m_nBrightness
void ToXml(IXFStream *pStrm)
Definition: xfmargins.cxx:78
void ToXml(IXFStream *pStrm)
@descr Output padding properties.
Definition: xfpadding.hxx:159
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
@ enumXFWrapBest
Definition: xfdefs.hxx:272
@ enumXFWrapNone
Definition: xfdefs.hxx:267
@ enumXFWrapLeft
Definition: xfdefs.hxx:268
@ enumXFWrapBackground
Definition: xfdefs.hxx:273
@ enumXFWrapRunThrough
Definition: xfdefs.hxx:271
@ enumXFWrapRight
Definition: xfdefs.hxx:269
@ enumXFWrapParallel
Definition: xfdefs.hxx:270
@ enumXFColorStandard
Definition: xfdefs.hxx:389
#define FABS(f)
Definition: xfglobal.hxx:71
#define FLOAT_MIN
Definition: xfglobal.hxx:66
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 GetColorMode(enumXFColorMode mode)
Definition: xfutil.cxx:375
OUString GetFrameYPos(enumXFFrameYPos pos)
Definition: xfutil.cxx:250