1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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,
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
58 * The file declares the LwpDrawObjects and associated class like LwpDrawGroup, LwpDrawRectangle
64 #include <sal/config.h>
66 #include <rtl/ref.hxx>
67 #include <rtl/ustring.hxx>
69 #include "lwpsdwdrawheader.hxx"
79 * Lwp-base-draw object.
84 DrawObjectType m_eType
;
86 SdwDrawObjHeader m_aObjHeader
;
87 SdwClosedObjStyleRec m_aClosedObjStyleRec
;
88 DrawingOffsetAndScale
* m_pTransData
;
91 LwpDrawObj(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
= nullptr);
92 virtual ~LwpDrawObj() {}
95 void ReadObjHeaderRecord();
98 void ReadClosedObjStyle();
99 void SetFillStyle(XFDrawStyle
* pStyle
);
100 static void SetLineStyle(XFDrawStyle
* pStyle
, sal_uInt8 nWidth
, sal_uInt8 nLineStyle
,
101 const SdwColor
& rColor
);
102 void SetPosition(XFFrame
* pObj
);
103 static void SetArrowHead(XFDrawStyle
* pOpenedObjStyle
, sal_uInt8 nArrowFlag
, sal_uInt8 nLineWidth
);
104 static OUString
GetArrowName(sal_uInt8 nArrowStyle
);
108 * @descr read out the record of a draw object.
110 virtual void Read() = 0;
113 * @descr register styles of a draw object according to the saved records data.
114 * @return the style name which has been registered.
116 virtual OUString
RegisterStyle() = 0;
119 * @descr create XF-draw object and assign the style name to it.
121 * @return pointer of the created XF-draw object.
123 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) = 0;
126 * @descr create XF-draw object and assign the style name to it.
128 * @return pointer of the created XF-draw object.
130 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) = 0;
134 * @descr create a completed XF-draw object(read data, register styles and create XF-draw object)
135 * @return pointer of the created completed XF-draw object.
137 rtl::Reference
<XFFrame
> CreateXFDrawObject();
140 * @param type of the object.
141 * @descr set the type to the draw object.
143 void SetObjectType(DrawObjectType eType
) { m_eType
= eType
; }
148 * Lwp-draw-group object.
150 class LwpDrawGroup
: public LwpDrawObj
153 explicit LwpDrawGroup(SvStream
* pStream
) : LwpDrawObj(pStream
) {}
156 virtual void Read() override
{}
157 virtual OUString
RegisterStyle() override
161 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& /*rStyleName*/) override
{ return nullptr; }
162 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& /*rStyleName*/) override
{ return nullptr; }
167 * Lwp-draw-line object.
169 class LwpDrawLine
: public LwpDrawObj
172 SdwLineRecord m_aLineRec
;
175 LwpDrawLine(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
);
178 virtual void Read() override
;
179 virtual OUString
RegisterStyle() override
;
180 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
181 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
186 * Lwp-draw-polyline object.
188 class LwpDrawPolyLine
: public LwpDrawObj
191 SdwPolyLineRecord m_aPolyLineRec
;
192 std::unique_ptr
<SdwPoint
[]> m_pVector
;
195 LwpDrawPolyLine(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
);
196 virtual ~LwpDrawPolyLine() override
;
199 virtual void Read() override
;
200 virtual OUString
RegisterStyle() override
;
201 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
202 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
207 * Lwp-draw-polygon object.
209 class LwpDrawPolygon
: public LwpDrawObj
212 sal_uInt16 m_nNumPoints
;
213 std::unique_ptr
<SdwPoint
[]> m_pVector
;
216 LwpDrawPolygon(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
);
217 virtual ~LwpDrawPolygon() override
;
220 virtual void Read() override
;
221 virtual OUString
RegisterStyle() override
;
222 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
223 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
228 * Lwp-draw-rectangle(rounded-corner rectangle) object.
230 class LwpDrawRectangle
: public LwpDrawObj
233 SdwPoint m_aVector
[16];
236 LwpDrawRectangle(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
);
239 virtual void Read() override
;
240 virtual OUString
RegisterStyle() override
;
241 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
242 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
245 XFFrame
* CreateRoundedRect(const OUString
& rStyleName
);
250 * Lwp-draw-ellipse object.
252 class LwpDrawEllipse
: public LwpDrawObj
255 SdwPoint m_aVector
[13];
258 LwpDrawEllipse(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
);
261 virtual void Read() override
;
262 virtual OUString
RegisterStyle() override
;
263 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
264 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
269 * Lwp-draw-arc object.
271 class LwpDrawArc
: public LwpDrawObj
274 SdwArcRecord m_aArcRec
;
275 SdwPoint m_aVector
[4];
278 LwpDrawArc(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
);
281 virtual void Read() override
;
282 virtual OUString
RegisterStyle() override
;
283 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
284 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
289 * Lwp-draw-textbox object.
292 class LwpDrawTextBox
: public LwpDrawObj
295 SdwTextBoxRecord m_aTextRec
;
299 explicit LwpDrawTextBox(SvStream
* pStream
);
300 virtual ~LwpDrawTextBox() override
;
301 static void SetFontStyle(rtl::Reference
<XFFont
> const & pFont
, SdwTextBoxRecord
const * pRec
);
304 virtual void Read() override
;
305 virtual OUString
RegisterStyle() override
;
306 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
307 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
312 * Lwp-draw-curved-text object.
315 class LwpDrawTextArt
: public LwpDrawObj
318 SdwTextArt m_aTextArtRec
;
319 SdwPoint m_aVector
[4];
322 void CreateFWPath(XFDrawPath
* pPath
);
325 LwpDrawTextArt(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
);
326 virtual ~LwpDrawTextArt() override
;
329 virtual void Read() override
;
330 virtual OUString
RegisterStyle() override
;
331 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
332 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
337 * Lwp-draw-metafile object.
339 class LwpDrawMetafile
: public LwpDrawObj
342 explicit LwpDrawMetafile(SvStream
* pStream
);
345 virtual void Read() override
;
346 virtual OUString
RegisterStyle() override
350 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& /*rStyleName*/) override
{return nullptr;}
351 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& /*rStyleName*/) override
{return nullptr;}
356 * Lwp-draw-bitmap object.
358 class LwpDrawBitmap
: public LwpDrawObj
361 SdwBmpRecord m_aBmpRec
;
362 std::unique_ptr
<sal_uInt8
[]> m_pImageData
;
364 explicit LwpDrawBitmap(SvStream
* pStream
);
365 virtual ~LwpDrawBitmap() override
;
368 virtual void Read() override
;
369 virtual OUString
RegisterStyle() override
;
370 virtual rtl::Reference
<XFFrame
> CreateDrawObj(const OUString
& rStyleName
) override
;
371 virtual rtl::Reference
<XFFrame
> CreateStandardDrawObj(const OUString
& rStyleName
) override
;
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */