Line data Source code
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 : ************************************************************************/
60 : #include "xfimagestyle.hxx"
61 : #include "xfborders.hxx"
62 : #include "xfshadow.hxx"
63 :
64 6 : XFImageStyle::XFImageStyle()
65 : {
66 6 : m_nBrightness = 0;
67 6 : m_nContrast = 0;
68 6 : m_nGamma = 0;
69 6 : m_nTransparent = 0;
70 6 : m_nAdjustRed = 0;
71 6 : m_nAdjustGreen = 0;
72 6 : m_nAdjustBlue = 0;
73 6 : m_fClipLeft = 0;
74 6 : m_fClipRight = 0;
75 6 : m_fClipTop = 0;
76 6 : m_fClipBottom = 0;
77 6 : m_bHoriFlip = sal_False;
78 6 : m_bVertFlip = sal_False;
79 6 : m_eColorMode = enumXFColorStandard;
80 6 : }
81 :
82 4 : void XFImageStyle::ToXml(IXFStream *pStrm)
83 : {
84 4 : IXFAttrList *pAttrList = pStrm->GetAttrList();
85 :
86 4 : pAttrList->Clear();
87 4 : pAttrList->AddAttribute( "style:name", GetStyleName() );
88 4 : if( !GetParentStyleName().isEmpty() )
89 0 : pAttrList->AddAttribute("style:parent-style-name",GetParentStyleName());
90 4 : pAttrList->AddAttribute( "style:family", "graphics" );
91 : //parent style name ignore now.
92 4 : pStrm->StartElement( "style:style" );
93 :
94 4 : m_aMargins.ToXml(pStrm);
95 :
96 4 : pAttrList->Clear();
97 :
98 4 : if( m_eWrap == enumXFWrapBackground )
99 : {
100 0 : pAttrList->AddAttribute( "style:run-through", "background" );
101 : }
102 : else
103 : {
104 4 : pAttrList->AddAttribute( "style:run-through", "foreground" );
105 :
106 4 : if( m_eWrap == enumXFWrapNone )
107 4 : pAttrList->AddAttribute( "style:wrap", "none" );
108 0 : else if( m_eWrap == enumXFWrapLeft )
109 0 : pAttrList->AddAttribute( "style:wrap", "left" );
110 0 : else if( m_eWrap == enumXFWrapRight )
111 0 : pAttrList->AddAttribute( "style:wrap", "right" );
112 0 : else if( m_eWrap == enumXFWrapParallel )
113 0 : pAttrList->AddAttribute( "style:wrap", "parallel" );
114 0 : else if( m_eWrap == enumXFWrapRunThrough )
115 0 : pAttrList->AddAttribute( "style:wrap", "run-through" );
116 0 : else if( m_eWrap == enumXFWrapBest )
117 0 : pAttrList->AddAttribute( "style:wrap", "dynamic" );
118 : }
119 : //background
120 4 : if( m_aBackColor.IsValid() )
121 0 : pAttrList->AddAttribute( "fo:background-color", m_aBackColor.ToString() );
122 : //pad
123 4 : m_aPad.ToXml(pStrm);
124 : //margin:
125 4 : m_aMargins.ToXml(pStrm);
126 : //flip
127 4 : if( m_bHoriFlip || m_bVertFlip )
128 : {
129 0 : if( m_bHoriFlip && m_bVertFlip )
130 0 : pAttrList->AddAttribute( "style:mirror", "horizontal-on-right-pages vertical" );
131 0 : else if( m_bHoriFlip && !m_bVertFlip )
132 0 : pAttrList->AddAttribute( "style:mirror", "horizontal-on-right-pages" );
133 0 : else if( !m_bHoriFlip && m_bVertFlip )
134 0 : pAttrList->AddAttribute( "style:mirror", "vertical" );
135 : }
136 : //color adjust
137 4 : if( m_nAdjustRed )
138 0 : pAttrList->AddAttribute( "draw:red", OUString::number(m_nAdjustRed) + "%" );
139 4 : if( m_nAdjustGreen )
140 0 : pAttrList->AddAttribute( "draw:green", OUString::number(m_nAdjustGreen) + "%" );
141 4 : if( m_nAdjustBlue )
142 0 : pAttrList->AddAttribute( "draw:blue", OUString::number(m_nAdjustBlue) + "%" );
143 :
144 4 : if( m_nGamma )
145 0 : pAttrList->AddAttribute( "draw:gamma", OUString::number(m_nGamma) );
146 4 : if( m_nBrightness )
147 0 : pAttrList->AddAttribute( "draw:luminance", OUString::number(m_nBrightness) + "%" );
148 4 : if( m_nContrast )
149 0 : pAttrList->AddAttribute( "draw:contrast", OUString::number(m_nContrast) + "%" );
150 :
151 4 : if( m_nTransparent )
152 0 : pAttrList->AddAttribute( "draw:transparency", OUString::number(m_nTransparent) + "%" );
153 :
154 4 : pAttrList->AddAttribute("draw:color-mode", GetColorMode(m_eColorMode));
155 : //border
156 4 : if( m_pBorders )
157 0 : m_pBorders->ToXml(pStrm);
158 : //shadow
159 4 : if( m_pShadow )
160 0 : m_pShadow->ToXml(pStrm);
161 :
162 4 : if( m_bPrintable )
163 4 : pAttrList->AddAttribute( "style:print-content", "true" );
164 : //protect:
165 4 : if( m_bProtectContent || m_bProtectSize || m_bProtectPos )
166 : {
167 0 : OUString protect;
168 0 : if( m_bProtectContent )
169 0 : protect += "content";
170 0 : if( m_bProtectSize )
171 : {
172 0 : if( !protect.isEmpty() )
173 0 : protect += " ";
174 0 : protect += "size";
175 : }
176 0 : if( m_bProtectPos )
177 : {
178 0 : if( !protect.isEmpty() )
179 0 : protect += " ";
180 0 : protect += "position";
181 : }
182 0 : pAttrList->AddAttribute( "style:protect", protect );
183 : }
184 : //vertical pos and horizon pos:
185 4 : pAttrList->AddAttribute( "style:vertical-pos", GetFrameYPos(m_eYPos) );
186 4 : pAttrList->AddAttribute( "style:vertical-rel", GetFrameYRel(m_eYRel) );
187 4 : pAttrList->AddAttribute( "style:horizontal-pos", GetFrameXPos(m_eXPos) );
188 4 : pAttrList->AddAttribute( "style:horizontal-rel", GetFrameXRel(m_eXRel) );
189 :
190 : //clip:
191 4 : if( FABS(m_fClipLeft)>FLOAT_MIN || FABS(m_fClipRight)>FLOAT_MIN || FABS(m_fClipTop)>FLOAT_MIN || FABS(m_fClipBottom)>FLOAT_MIN )
192 : {
193 0 : OUString clip = "rect(" + OUString::number(m_fClipTop) + "cm " +
194 0 : OUString::number(m_fClipRight) + "cm " +
195 0 : OUString::number(m_fClipBottom) + "cm " +
196 0 : OUString::number(m_fClipLeft) + "cm" + ")";
197 0 : pAttrList->AddAttribute("fo:clip",clip);
198 : }
199 :
200 4 : pStrm->StartElement( "style:properties" );
201 4 : pStrm->EndElement( "style:properties" );
202 :
203 4 : pStrm->EndElement( "style:style" );
204 :
205 4 : }
206 :
207 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|