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( A2OUSTR("style:name"), GetStyleName() );
88 4 : if( !GetParentStyleName().isEmpty() )
89 0 : pAttrList->AddAttribute(A2OUSTR("style:parent-style-name"),GetParentStyleName());
90 4 : pAttrList->AddAttribute( A2OUSTR("style:family"), A2OUSTR("graphics") );
91 : //parent style name ignore now.
92 4 : pStrm->StartElement( A2OUSTR("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( A2OUSTR("style:run-through"), A2OUSTR("background") );
101 : }
102 : else
103 : {
104 4 : pAttrList->AddAttribute( A2OUSTR("style:run-through"), A2OUSTR("foreground") );
105 :
106 4 : if( m_eWrap == enumXFWrapNone )
107 4 : pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("none") );
108 0 : else if( m_eWrap == enumXFWrapLeft )
109 0 : pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("left") );
110 0 : else if( m_eWrap == enumXFWrapRight )
111 0 : pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("right") );
112 0 : else if( m_eWrap == enumXFWrapParallel )
113 0 : pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("parallel") );
114 0 : else if( m_eWrap == enumXFWrapRunThrough )
115 0 : pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("run-through") );
116 0 : else if( m_eWrap == enumXFWrapBest )
117 0 : pAttrList->AddAttribute( A2OUSTR("style:wrap"), A2OUSTR("dynamic") );
118 : }
119 : //background
120 4 : if( m_aBackColor.IsValid() )
121 0 : pAttrList->AddAttribute( A2OUSTR("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( A2OUSTR("style:mirror"), A2OUSTR("horizontal-on-right-pages vertical") );
131 0 : else if( m_bHoriFlip && !m_bVertFlip )
132 0 : pAttrList->AddAttribute( A2OUSTR("style:mirror"), A2OUSTR("horizontal-on-right-pages") );
133 0 : else if( !m_bHoriFlip && m_bVertFlip )
134 0 : pAttrList->AddAttribute( A2OUSTR("style:mirror"), A2OUSTR("vertical") );
135 : }
136 : //color adjust
137 4 : if( m_nAdjustRed )
138 0 : pAttrList->AddAttribute( A2OUSTR("draw:red"), Int32ToOUString(m_nAdjustRed) + A2OUSTR("%") );
139 4 : if( m_nAdjustGreen )
140 0 : pAttrList->AddAttribute( A2OUSTR("draw:green"), Int32ToOUString(m_nAdjustGreen) + A2OUSTR("%") );
141 4 : if( m_nAdjustBlue )
142 0 : pAttrList->AddAttribute( A2OUSTR("draw:blue"), Int32ToOUString(m_nAdjustBlue) + A2OUSTR("%") );
143 :
144 4 : if( m_nGamma )
145 0 : pAttrList->AddAttribute( A2OUSTR("draw:gamma"), Int32ToOUString(m_nGamma) );
146 4 : if( m_nBrightness )
147 0 : pAttrList->AddAttribute( A2OUSTR("draw:luminance"), Int32ToOUString(m_nBrightness) + A2OUSTR("%") );
148 4 : if( m_nContrast )
149 0 : pAttrList->AddAttribute( A2OUSTR("draw:contrast"), Int32ToOUString(m_nContrast) + A2OUSTR("%") );
150 :
151 4 : if( m_nTransparent )
152 0 : pAttrList->AddAttribute( A2OUSTR("draw:transparency"), Int32ToOUString(m_nTransparent) + A2OUSTR("%") );
153 :
154 4 : pAttrList->AddAttribute(A2OUSTR("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( A2OUSTR("style:print-content"), A2OUSTR("true") );
164 : //protect:
165 4 : if( m_bProtectContent || m_bProtectSize || m_bProtectPos )
166 : {
167 0 : rtl::OUString protect;
168 0 : if( m_bProtectContent )
169 0 : protect += A2OUSTR("content");
170 0 : if( m_bProtectSize )
171 : {
172 0 : if( !protect.isEmpty() )
173 0 : protect += A2OUSTR(" ");
174 0 : protect += A2OUSTR("size");
175 : }
176 0 : if( m_bProtectPos )
177 : {
178 0 : if( !protect.isEmpty() )
179 0 : protect += A2OUSTR(" ");
180 0 : protect += A2OUSTR("position");
181 : }
182 0 : pAttrList->AddAttribute( A2OUSTR("style:protect"), protect );
183 : }
184 : //vertical pos and horizon pos:
185 4 : pAttrList->AddAttribute( A2OUSTR("style:vertical-pos"), GetFrameYPos(m_eYPos) );
186 4 : pAttrList->AddAttribute( A2OUSTR("style:vertical-rel"), GetFrameYRel(m_eYRel) );
187 4 : pAttrList->AddAttribute( A2OUSTR("style:horizontal-pos"), GetFrameXPos(m_eXPos) );
188 4 : pAttrList->AddAttribute( A2OUSTR("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 : rtl::OUString clip = A2OUSTR("rect(");
194 0 : clip += DoubleToOUString(m_fClipTop) + A2OUSTR("cm ");
195 0 : clip += DoubleToOUString(m_fClipRight) + A2OUSTR("cm ");
196 0 : clip += DoubleToOUString(m_fClipBottom) + A2OUSTR("cm ");
197 0 : clip += DoubleToOUString(m_fClipLeft) + A2OUSTR("cm");
198 0 : clip += A2OUSTR(")");
199 0 : pAttrList->AddAttribute(A2OUSTR("fo:clip"),clip);
200 : }
201 :
202 : //
203 4 : pStrm->StartElement( A2OUSTR("style:properties") );
204 4 : pStrm->EndElement( A2OUSTR("style:properties") );
205 :
206 4 : pStrm->EndElement( A2OUSTR("style:style") );
207 :
208 4 : }
209 :
210 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|