LibreOffice Module lotuswordpro (master) 1
xfdrawstyle.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 * Style for all draw object.
59 ************************************************************************/
62#include <xfilter/xfglobal.hxx>
63#include "xfdrawareastyle.hxx"
65#include "xffontworkstyle.hxx"
66#include <lwpglobalmgr.hxx>
68 : m_pLineStyle(nullptr)
69 , m_pAreaStyle(nullptr)
70 , m_fArrowStartSize(0.3)
71 , m_fArrowEndSize(0.3)
72 , m_bArrowStartCenter(false)
73 , m_bArrowEndCenter(false)
74 , m_bLineStyleRegistered(false)
75 , m_bAreaStyleRegistered(false)
76{}
77
79{
80 // normally don't delete m_pLineStyle, it was managed by XFStyleManager.
82 delete m_pLineStyle;
83 // normally don't delete m_pAreaStyle, it was managed by XFStyleManager.
85 delete m_pAreaStyle;
86}
87
89{
90 if( !m_pLineStyle )
91 {
94 }
95 m_pLineStyle->SetWidth(width);
98}
99
100void XFDrawStyle::SetLineDashStyle(enumXFLineStyle style, double len1, double len2, double space )
101{
102 if( !m_pLineStyle )
103 {
106 }
112 m_pLineStyle->SetSpace(space);
115 pXFStyleManager->AddStyle(std::unique_ptr<IXFStyle>(m_pLineStyle));
116}
117
119{
120 if (!m_pFontWorkStyle)
121 {
122 m_pFontWorkStyle.reset( new XFFontWorkStyle() );
123 }
124
125 m_pFontWorkStyle->SetButtonForm(0);
126 m_pFontWorkStyle->SetFWStyleType(eStyle);
127 m_pFontWorkStyle->SetFWAdjustType(eAdjust);
128}
129
131{
132 if( !m_pAreaStyle )
133 {
136 }
138}
139
140void XFDrawStyle::SetAreaLineStyle(enumXFAreaLineStyle style, sal_Int32 angle, double space, XFColor lineColor)
141{
142 if( !m_pAreaStyle )
143 {
146 }
148
152 m_pAreaStyle->SetLineColor(lineColor);
155 pXFStyleManager->AddStyle(std::unique_ptr<IXFStyle>(m_pAreaStyle));
156}
157
159{
160 return enumXFStyleGraphics;
161}
162
163/**************************************************************************
164 *************************************************************************/
166{
167 IXFAttrList *pAttrList = pStrm->GetAttrList();
168
169 pAttrList->Clear();
170
171 pAttrList->AddAttribute( "style:name", GetStyleName() );
172 pAttrList->AddAttribute( "style:family", "graphics" );
173 pStrm->StartElement( "style:style" );
174
175 pAttrList->Clear();
176
177 pAttrList->AddAttribute( "style:run-through", "foreground" );
178 pAttrList->AddAttribute( "style:wrap", "none" );
179
180 //line style:
181 if( m_pLineStyle )
182 {
183 //1. if is a dash style, register the stroke-dash style first.
184 if( !m_pLineStyle->IsSolid() )
185 {
186// pAttrList->Clear();
187 pAttrList->AddAttribute( "draw:stroke", "dash" );
188 pAttrList->AddAttribute( "draw:stroke-dash", m_pLineStyle->GetStyleName() );
189 }
190 else
191 {
192 pAttrList->AddAttribute( "draw:stroke", "solid" );
193 }
194
195 if( m_pLineStyle->GetWidth() > 0 )
196 pAttrList->AddAttribute( "svg:stroke-width", OUString::number(m_pLineStyle->GetWidth()) + "cm" );
197
199 if( color.IsValid() )
200 pAttrList->AddAttribute( "svg:stroke-color", color.ToString() );
201
203 pAttrList->AddAttribute( "svg:stroke-opacity", OUString::number(m_pLineStyle->GetTransparency()) + "%" );
204 }
205 else
206 pAttrList->AddAttribute( "draw:stroke", "none" );
207 //area style:
208 if( m_pAreaStyle )
209 {
211 {
212 pAttrList->AddAttribute( "draw:fill", "solid" );
214 if( color.IsValid() )
215 pAttrList->AddAttribute( "draw:fill-color", color.ToString() );
216 }
218 {
219 pAttrList->AddAttribute( "draw:fill", "hatch" );
220 pAttrList->AddAttribute( "draw:fill-hatch-name", m_pAreaStyle->GetStyleName() );
222 if( color.IsValid() )
223 {
224 pAttrList->AddAttribute( "draw:fill-hatch-solid", "true" );
225 pAttrList->AddAttribute( "draw:fill-color", color.ToString() );
226 }
227 }
228 }
229 else
230 pAttrList->AddAttribute( "draw:fill", "none" );
231
232 if( !m_strArrowStart.isEmpty() )
233 {
234 pAttrList->AddAttribute( "draw:marker-start", m_strArrowStart );
235 pAttrList->AddAttribute( "draw:marker-start-width", OUString::number(m_fArrowStartSize)+"cm" );
237 pAttrList->AddAttribute( "draw:draw:marker-start-center", "true" );
238 }
239 if( !m_strArrowEnd.isEmpty() )
240 {
241 pAttrList->AddAttribute( "draw:marker-end", m_strArrowEnd );
242 pAttrList->AddAttribute( "draw:marker-end-width", OUString::number(m_fArrowEndSize)+"cm" );
244 pAttrList->AddAttribute( "draw:draw:marker-end-center", "true" );
245 }
247 {
248 // style
249 OUString aStr = "";
250 switch (m_pFontWorkStyle->GetStyleType())
251 {
252 default: // fall through!
253 case enumXFFWOff:
254 break;
255 case enumXFFWRotate:
256 aStr = "rotate";
257 break;
258 case enumXFFWUpright:
259 aStr = "upright";
260 break;
261 case enumXFFWSlantX:
262 aStr = "slant-x";
263 break;
264 case enumXFFWSlantY:
265 aStr = "slant-y";
266 break;
267 }
268 if (!aStr.isEmpty())
269 {
270 pAttrList->AddAttribute("draw:fontwork-style", aStr);
271 }
272
273 //adjust
274 aStr.clear();
275 switch (m_pFontWorkStyle->GetAdjustType())
276 {
277 default: // fall through
279 aStr = "autosize";
280 break;
282 aStr = "left";
283 break;
285 aStr = "center";
286 break;
288 aStr = "right";
289 break;
290 }
291 if (!aStr.isEmpty())
292 {
293 pAttrList->AddAttribute("draw:fontwork-adjust", aStr);
294 }
295
296 //form
297 aStr.clear();
298 switch (m_pFontWorkStyle->GetButtonForm())
299 {
300 default: // fall through!
301 case -1:
302 break;
303 case 4:
304 aStr = "top-arc";
305 break;
306 case 5:
307 aStr = "bottom-arc";
308 break;
309 }
310 if (!aStr.isEmpty())
311 {
312 pAttrList->AddAttribute("draw:fontwork-form", aStr);
313 }
314
315 // distance
316 //pAttrList->AddAttribute("draw:fontwork-distance",
317 // OUString::number(m_pFontWorkStyle->GetFWDistance())+"cm");
318 }
319
320 pStrm->StartElement( "style:properties" );
321
322 pStrm->EndElement( "style:properties" );
323
324 pStrm->EndElement( "style:style" );
325}
326
327/* 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()
XFStyleManager * GetXFStyleManager()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
Color object.
Definition: xfcolor.hxx:70
void SetLineColor(XFColor const &color)
void SetBackColor(XFColor const &color)
void SetLineStyle(enumXFAreaLineStyle style)
enumXFAreaStyle GetAreaStyle() const
const XFColor & GetBackColor() const
void SetLineSpace(double space)
void SetLineAngle(sal_Int32 angle)
void SetAreaStyle(enumXFAreaStyle style)
Border line style for drawing object.
void SetSpace(double space)
@descr Set space between dash dot.
void SetWidth(double width)
@descr Set line width.
const XFColor & GetColor() const
double GetWidth() const
void SetDot2Length(double length)
@descr Set second dot length.
bool IsSolid() const
@descr decide whether it's a solid line.
void SetDot1Length(double length)
@descr Set first dot length.
sal_Int32 GetTransparency() const
void SetColor(const XFColor &color)
@descr Set line color.
void SetDot1Number(sal_Int32 number)
@descr Set first dot number of dash line.
void SetLineStyle(enumXFLineStyle style)
@descr Set line type, solid,dash,dot?
void SetDot2Number(sal_Int32 number)
@descr Set second dot number of dash line.
void SetTransparency(sal_Int32 transparency)
@descr Set line transparency.
bool m_bLineStyleRegistered
std::unique_ptr< XFFontWorkStyle > m_pFontWorkStyle
bool m_bArrowEndCenter
bool m_bArrowStartCenter
double m_fArrowStartSize
double m_fArrowEndSize
OUString m_strArrowEnd
virtual enumXFStyle GetStyleFamily() override
@descr get style family.
virtual void ToXml(IXFStream *pStrm) override
virtual ~XFDrawStyle() override
Definition: xfdrawstyle.cxx:78
void SetLineDashStyle(enumXFLineStyle style, double len1, double len2, double space)
@descr Set drawing object dash border style.
XFDrawLineStyle * m_pLineStyle
void SetLineStyle(double width, XFColor color)
@descr Set drawing object border line.
Definition: xfdrawstyle.cxx:88
OUString m_strArrowStart
void SetAreaColor(XFColor const &color)
@descr Set drawing object area fill color.
XFDrawAreaStyle * m_pAreaStyle
void SetFontWorkStyle(enumXFFWStyle eStyle, enumXFFWAdjust eAdjust)
void SetAreaLineStyle(enumXFAreaLineStyle style, sal_Int32 angle, double space, XFColor lineColor)
@descr Set drawing object area grid style.
bool m_bAreaStyleRegistered
static OUString GenAreaName()
@descr Generate a name for the area fill style.
Definition: xfglobal.cxx:102
static OUString GenStrokeDashName()
@descr Generate a name for the stroke style.
Definition: xfglobal.cxx:96
Style manager for the filter.
IXFStyleRet AddStyle(std::unique_ptr< IXFStyle > pStyle)
virtual OUString GetStyleName() override
@descr get style name.
Definition: xfstyle.cxx:70
virtual void SetStyleName(const OUString &styleName) override
@descr set style name.
Definition: xfstyle.cxx:75
aStr
enumXFFWStyle
Definition: xfdefs.hxx:472
@ enumXFFWOff
Definition: xfdefs.hxx:473
@ enumXFFWRotate
Definition: xfdefs.hxx:474
@ enumXFFWSlantY
Definition: xfdefs.hxx:477
@ enumXFFWSlantX
Definition: xfdefs.hxx:476
@ enumXFFWUpright
Definition: xfdefs.hxx:475
@ enumXFAreaHatch
Definition: xfdefs.hxx:377
@ enumXFAreaSolid
Definition: xfdefs.hxx:374
enumXFStyle
Definition: xfdefs.hxx:80
@ enumXFStyleGraphics
Definition: xfdefs.hxx:86
enumXFFWAdjust
Definition: xfdefs.hxx:481
@ enumXFFWAdjustCenter
Definition: xfdefs.hxx:484
@ enumXFFWAdustRight
Definition: xfdefs.hxx:485
@ enumXFFWAdjustLeft
Definition: xfdefs.hxx:483
@ enumXFFWAdjustAutosize
Definition: xfdefs.hxx:482
enumXFAreaLineStyle
Definition: xfdefs.hxx:381
enumXFLineStyle
Definition: xfdefs.hxx:362