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 * Implementation file of LwpDrawObjcts and associated class like LwpDrawGroup, LwpDrawRectange
61 #include "lwpglobalmgr.hxx"
62 #include "lwpdrawobj.hxx"
63 #include "lwptools.hxx"
64 #include <tools/stream.hxx>
66 #include "xfilter/xfframe.hxx"
68 #include "xfilter/xfstylemanager.hxx"
69 #include "xfilter/xfdrawstyle.hxx"
70 #include "xfilter/xftextstyle.hxx"
71 #include "xfilter/xfparastyle.hxx"
72 #include "xfilter/xfimagestyle.hxx"
73 #include "xfilter/xftextboxstyle.hxx"
74 #include "xfilter/xfparagraph.hxx"
75 #include "xfilter/xftextspan.hxx"
76 #include "xfilter/xffont.hxx"
78 #include "xfilter/xfdrawrect.hxx"
79 #include "xfilter/xfdrawpath.hxx"
80 #include "xfilter/xfdrawline.hxx"
81 #include "xfilter/xfdrawpolygon.hxx"
82 #include "xfilter/xfimage.hxx"
84 #include "lwpcharsetmgr.hxx"
85 #include "lwpsdwrect.hxx"
88 * @descr Constructor of class LwpDrawObj
89 * @param pStream The memory stream which contains the lwp-sdw draw objects
91 LwpDrawObj::LwpDrawObj(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
92 : m_eType(OT_UNDEFINED
)
94 , m_pTransData(pTransData
)
96 this->ReadObjHeaderRecord();
100 * @descr read the header record data of lwp-sdw-object
102 void LwpDrawObj::ReadObjHeaderRecord()
105 m_pStream
->SeekRel(1);
108 *m_pStream
>> m_aObjHeader
.nRecLen
;
111 *m_pStream
>> m_aObjHeader
.nLeft
;
112 *m_pStream
>> m_aObjHeader
.nTop
;
113 *m_pStream
>> m_aObjHeader
.nRight
;
114 *m_pStream
>> m_aObjHeader
.nBottom
;
117 m_pStream
->SeekRel(4);
121 * @descr read the style of closed lwp-sdw-object like: rectangle, ellipse and so on.
123 void LwpDrawObj::ReadClosedObjStyle()
125 if ((m_eType
!= OT_POLYGON
) && (m_eType
!= OT_TEXTART
))
127 m_pStream
->SeekRel(8);
130 *m_pStream
>> m_aClosedObjStyleRec
.nLineWidth
;
131 *m_pStream
>> m_aClosedObjStyleRec
.nLineStyle
;
134 *m_pStream
>> m_aClosedObjStyleRec
.aPenColor
.nR
;
135 *m_pStream
>> m_aClosedObjStyleRec
.aPenColor
.nG
;
136 *m_pStream
>> m_aClosedObjStyleRec
.aPenColor
.nB
;
137 *m_pStream
>> m_aClosedObjStyleRec
.aPenColor
.unused
;
140 *m_pStream
>> m_aClosedObjStyleRec
.aForeColor
.nR
;
141 *m_pStream
>> m_aClosedObjStyleRec
.aForeColor
.nG
;
142 *m_pStream
>> m_aClosedObjStyleRec
.aForeColor
.nB
;
143 *m_pStream
>> m_aClosedObjStyleRec
.aForeColor
.unused
;
146 *m_pStream
>> m_aClosedObjStyleRec
.aBackColor
.nR
;
147 *m_pStream
>> m_aClosedObjStyleRec
.aBackColor
.nG
;
148 *m_pStream
>> m_aClosedObjStyleRec
.aBackColor
.nB
;
149 *m_pStream
>> m_aClosedObjStyleRec
.aBackColor
.unused
;
152 *m_pStream
>> m_aClosedObjStyleRec
.nFillType
;
153 m_pStream
->Read(m_aClosedObjStyleRec
.pFillPattern
,
154 sizeof(m_aClosedObjStyleRec
.pFillPattern
));
158 * @descr set fill style of drawing objects
159 * @param pStyle pointer of the drawing xfstyle.
161 void LwpDrawObj::SetFillStyle(XFDrawStyle
* pStyle
)
169 XFColor
aForeColor(m_aClosedObjStyleRec
.aForeColor
.nR
,
170 m_aClosedObjStyleRec
.aForeColor
.nG
, m_aClosedObjStyleRec
.aForeColor
.nB
);
171 XFColor
aBackColor(m_aClosedObjStyleRec
.aBackColor
.nR
,
172 m_aClosedObjStyleRec
.aBackColor
.nG
, m_aClosedObjStyleRec
.aBackColor
.nB
);
174 switch (m_aClosedObjStyleRec
.nFillType
)
176 default: //fall through!
179 // set fill style : none
184 pStyle
->SetAreaColor(aForeColor
);
189 pStyle
->SetAreaColor(aBackColor
);
190 pStyle
->SetAreaLineStyle(enumXFAreaLineSingle
, 0, 0.12, aForeColor
);
195 pStyle
->SetAreaColor(aBackColor
);
196 pStyle
->SetAreaLineStyle(enumXFAreaLineSingle
, 90, 0.12, aForeColor
);
201 pStyle
->SetAreaColor(aBackColor
);
202 pStyle
->SetAreaLineStyle(enumXFAreaLineSingle
, 135, 0.09, aForeColor
);
207 pStyle
->SetAreaColor(aBackColor
);
208 pStyle
->SetAreaLineStyle(enumXFAreaLineSingle
, 45, 0.09, aForeColor
);
213 pStyle
->SetAreaColor(aBackColor
);
214 pStyle
->SetAreaLineStyle(enumXFAreaLineCrossed
, 0, 0.12, aForeColor
);
217 case FT_DIAGCROSSHATCH
:
219 pStyle
->SetAreaColor(aBackColor
);
220 pStyle
->SetAreaLineStyle(enumXFAreaLineCrossed
, 45, 0.095, aForeColor
);
227 * @descr set line/border style of drawing objects.
228 * @param pStyle pointer of the drawing xfstyle.
229 * @param nWidth width of line/border.
230 * @param nLineStyle flag of line/border style: none, dot or solid.
231 * @param rColor color of line/border.
233 void LwpDrawObj::SetLineStyle(XFDrawStyle
* pStyle
, sal_uInt8 nWidth
, sal_uInt8 nLineStyle
,
234 const SdwColor
& rColor
)
243 nLineStyle
= LS_NULL
;
246 if (nLineStyle
== LS_NULL
)
252 if (nLineStyle
== LS_DOT
)
254 pStyle
->SetLineDashStyle(enumXFLineDash
, 1, 1, 0.05, 0.05, 0.05);
258 double fWidth
= (double)nWidth
/TWIPS_PER_CM
;
261 XFColor
aXFColor(rColor
.nR
, rColor
.nG
, rColor
.nB
);
263 pStyle
->SetLineStyle(fWidth
, aXFColor
);
267 * @descr set position of a drawing object in the frame.
268 * @param pObj pointer of the xf-drawing object
270 void LwpDrawObj::SetPosition(XFFrame
* pObj
)
272 double fOffsetX
= 0.00, fOffsetY
= 0.00;
273 double fScaleX
= 1.00, fScaleY
= 1.00;
276 fOffsetX
= m_pTransData
->fOffsetX
;
277 fOffsetY
= m_pTransData
->fOffsetY
;
278 fScaleX
= m_pTransData
->fScaleX
;
279 fScaleY
= m_pTransData
->fScaleY
;
282 pObj
->SetPosition((double)m_aObjHeader
.nLeft
/TWIPS_PER_CM
* fScaleX
+ fOffsetX
,
283 (double)m_aObjHeader
.nTop
/TWIPS_PER_CM
* fScaleY
+ fOffsetY
,
284 (double)(m_aObjHeader
.nRight
-m_aObjHeader
.nLeft
)/TWIPS_PER_CM
* fScaleX
,
285 (double)(m_aObjHeader
.nBottom
-m_aObjHeader
.nTop
)/TWIPS_PER_CM
* fScaleY
);
289 * @descr set arrowhead of a xf-drawing object. only opened drawing objects can be assigned arrowheads
290 * @param pOpenedObjStyle the xf-drawing object which will be set arrowhead.
291 * @param nArrowFlag arrowhead flags of the object.
293 void LwpDrawObj::SetArrowHead(XFDrawStyle
* pOpenedObjStyle
, sal_uInt8 nArrowFlag
, sal_uInt8 nLineWidth
)
301 if (!pOpenedObjStyle
)
307 // arrowhead flag of an object's start side
308 sal_uInt8 nLeftArrow
= nArrowFlag
& 0x0F;
310 // arrowhead flag of an object's end side
311 sal_uInt8 nRightArrow
= (nArrowFlag
& 0xF0) >> 4;
313 double fWidth_inch
= (double)nLineWidth
/TWIPS_PER_CM
;
314 double fArrowSize_inch
= fWidth_inch
+ 0.08;
315 double fArrowSize
= fArrowSize_inch
* CM_PER_INCH
;
319 pOpenedObjStyle
->SetArrowStart( this->GetArrowName(nLeftArrow
), fArrowSize
, sal_True
);
323 pOpenedObjStyle
->SetArrowEnd( this->GetArrowName(nRightArrow
), fArrowSize
, sal_True
);
329 * @descr get arrow style name according to the flag.
330 * @param nArrowStyle style of the arrowhead.
331 * @return nWhichSide style name of the arrowhead.
333 OUString
LwpDrawObj::GetArrowName(sal_uInt8 nArrowStyle
)
335 // style name of arrowhead
341 case AH_ARROW_FULLARROW
:
342 aArrowName
= OUString("Symmetric arrow");
344 case AH_ARROW_HALFARROW
:
345 aArrowName
= OUString("Arrow concave");
347 case AH_ARROW_LINEARROW
:
348 aArrowName
= OUString("arrow100");
350 case AH_ARROW_INVFULLARROW
:
351 aArrowName
= OUString("reverse arrow");
353 case AH_ARROW_INVHALFARROW
:
354 aArrowName
= OUString("reverse concave arrow");
356 case AH_ARROW_INVLINEARROW
:
357 aArrowName
= OUString("reverse line arrow");
360 aArrowName
= OUString("Dimension lines");
362 case AH_ARROW_SQUARE
:
363 aArrowName
= OUString("Square");
365 case AH_ARROW_CIRCLE
:
366 aArrowName
= OUString("Circle");
374 * @descr template method of creating drawing object from Lwp-Model to XF-Model
375 * @return pointer of the drawing object of XF-Model.
377 XFFrame
* LwpDrawObj::CreateXFDrawObject()
383 OUString aStyleName
= this->RegisterStyle();
386 XFFrame
* pXFObj
= NULL
;
388 && FABS(m_pTransData
->fOffsetX
- m_pTransData
->fLeftMargin
) < THRESHOLD
389 && FABS(m_pTransData
->fOffsetY
- m_pTransData
->fTopMargin
) < THRESHOLD
390 && FABS(m_pTransData
->fScaleX
- 1.0) < THRESHOLD
391 && FABS(m_pTransData
->fScaleY
- 1.0) < THRESHOLD
)
393 pXFObj
= this->CreateStandardDrawObj(aStyleName
);
397 pXFObj
= this->CreateDrawObj(aStyleName
);
403 pXFObj
->SetAnchorType(enumXFAnchorFrame
);
410 * @descr Constructor of class LwpDrawLine
411 * @param pStream The memory stream which contains the lwp-sdw draw objects
413 LwpDrawLine::LwpDrawLine(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
414 : LwpDrawObj(pStream
, pTransData
)
419 * @descr reading function of class LwpDrawLine
421 void LwpDrawLine::Read()
423 *m_pStream
>> m_aLineRec
.nStartX
;
424 *m_pStream
>> m_aLineRec
.nStartY
;
425 *m_pStream
>> m_aLineRec
.nEndX
;
426 *m_pStream
>> m_aLineRec
.nEndY
;
427 *m_pStream
>> m_aLineRec
.nLineWidth
;
428 *m_pStream
>> m_aLineRec
.nLineEnd
;
429 *m_pStream
>> m_aLineRec
.nLineStyle
;
431 *m_pStream
>> m_aLineRec
.aPenColor
.nR
;
432 *m_pStream
>> m_aLineRec
.aPenColor
.nG
;
433 *m_pStream
>> m_aLineRec
.aPenColor
.nB
;
434 *m_pStream
>> m_aLineRec
.aPenColor
.unused
;
437 OUString
LwpDrawLine::RegisterStyle()
439 XFDrawStyle
* pStyle
= new XFDrawStyle();
442 this->SetLineStyle(pStyle
, m_aLineRec
.nLineWidth
, m_aLineRec
.nLineStyle
, m_aLineRec
.aPenColor
);
445 this->SetArrowHead(pStyle
, m_aLineRec
.nLineEnd
, m_aLineRec
.nLineWidth
);
447 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
448 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
452 XFFrame
* LwpDrawLine::CreateDrawObj(const OUString
& rStyleName
)
454 XFDrawPath
* pLine
= new XFDrawPath();
455 pLine
->MoveTo(XFPoint((double)(m_aLineRec
.nStartX
)/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
456 (double)(m_aLineRec
.nStartY
)/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
457 pLine
->LineTo(XFPoint((double)(m_aLineRec
.nEndX
)/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
458 (double)(m_aLineRec
.nEndY
)/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
459 this->SetPosition(pLine
);
461 pLine
->SetStyleName(rStyleName
);
466 XFFrame
* LwpDrawLine::CreateStandardDrawObj(const OUString
& rStyleName
)
468 XFDrawLine
* pLine
= new XFDrawLine();
469 pLine
->SetStartPoint((double)(m_aLineRec
.nStartX
)/TWIPS_PER_CM
,(double)(m_aLineRec
.nStartY
)/TWIPS_PER_CM
);
470 pLine
->SetEndPoint((double)(m_aLineRec
.nEndX
)/TWIPS_PER_CM
,(double)(m_aLineRec
.nEndY
)/TWIPS_PER_CM
);
472 pLine
->SetStyleName(rStyleName
);
477 * @descr Constructor of class LwpDrawPolyLine
478 * @param pStream The memory stream which contains the lwp-sdw draw objects
480 LwpDrawPolyLine::LwpDrawPolyLine(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
481 : LwpDrawObj(pStream
, pTransData
), m_pVector(NULL
)
484 LwpDrawPolyLine::~LwpDrawPolyLine()
494 * @descr reading function of class LwpDrawPolyLine
496 void LwpDrawPolyLine::Read()
498 *m_pStream
>> m_aPolyLineRec
.nLineWidth
;
499 *m_pStream
>> m_aPolyLineRec
.nLineEnd
;
500 *m_pStream
>> m_aPolyLineRec
.nLineStyle
;
501 *m_pStream
>> m_aPolyLineRec
.aPenColor
.nR
;
502 *m_pStream
>> m_aPolyLineRec
.aPenColor
.nG
;
503 *m_pStream
>> m_aPolyLineRec
.aPenColor
.nB
;
504 *m_pStream
>> m_aPolyLineRec
.aPenColor
.unused
;
505 *m_pStream
>> m_aPolyLineRec
.nNumPoints
;
507 m_pVector
= new SdwPoint
[m_aPolyLineRec
.nNumPoints
];
509 for (sal_uInt16 nC
= 0; nC
< m_aPolyLineRec
.nNumPoints
; nC
++)
511 *m_pStream
>> m_pVector
[nC
].x
;
512 *m_pStream
>> m_pVector
[nC
].y
;
516 OUString
LwpDrawPolyLine::RegisterStyle()
518 XFDrawStyle
* pStyle
= new XFDrawStyle();
521 this->SetLineStyle(pStyle
, m_aPolyLineRec
.nLineWidth
, m_aPolyLineRec
.nLineStyle
,
522 m_aPolyLineRec
.aPenColor
);
525 this->SetArrowHead(pStyle
, m_aPolyLineRec
.nLineEnd
, m_aPolyLineRec
.nLineWidth
);
527 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
528 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
531 XFFrame
* LwpDrawPolyLine::CreateDrawObj(const OUString
& rStyleName
)
533 XFDrawPath
* pPolyline
= new XFDrawPath();
534 pPolyline
->MoveTo(XFPoint((double)m_pVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
535 (double)m_pVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
536 for (sal_uInt8 nC
= 1; nC
< m_aPolyLineRec
.nNumPoints
; nC
++)
538 pPolyline
->LineTo(XFPoint((double)m_pVector
[nC
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
539 (double)m_pVector
[nC
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
541 this->SetPosition(pPolyline
);
543 pPolyline
->SetStyleName(rStyleName
);
548 XFFrame
* LwpDrawPolyLine::CreateStandardDrawObj(const OUString
& rStyleName
)
550 XFDrawPolyline
* pPolyline
= new XFDrawPolyline();
551 for (sal_uInt8 nC
= 0; nC
< m_aPolyLineRec
.nNumPoints
; nC
++)
553 pPolyline
->AddPoint((double)m_pVector
[nC
].x
/TWIPS_PER_CM
,
554 (double)m_pVector
[nC
].y
/TWIPS_PER_CM
);
557 pPolyline
->SetStyleName(rStyleName
);
563 * @descr Constructor of class LwpDrawPolygon
564 * @param pStream The memory stream which contains the lwp-sdw draw objects
566 LwpDrawPolygon::LwpDrawPolygon(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
567 : LwpDrawObj(pStream
, pTransData
)
570 LwpDrawPolygon::~LwpDrawPolygon()
580 * @descr reading function of class LwpDrawPolygon
582 void LwpDrawPolygon::Read()
584 this->ReadClosedObjStyle();
585 *m_pStream
>> m_nNumPoints
;
587 m_pVector
= new SdwPoint
[m_nNumPoints
];
589 for (sal_uInt16 nC
= 0; nC
< m_nNumPoints
; nC
++)
591 *m_pStream
>> m_pVector
[nC
].x
;
592 *m_pStream
>> m_pVector
[nC
].y
;
596 OUString
LwpDrawPolygon::RegisterStyle()
598 XFDrawStyle
* pStyle
= new XFDrawStyle();
601 this->SetLineStyle(pStyle
, m_aClosedObjStyleRec
.nLineWidth
, m_aClosedObjStyleRec
.nLineStyle
,
602 m_aClosedObjStyleRec
.aPenColor
);
605 this->SetFillStyle(pStyle
);
607 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
608 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
611 XFFrame
* LwpDrawPolygon::CreateDrawObj(const OUString
& rStyleName
)
613 XFDrawPath
* pPolygon
= new XFDrawPath();
614 pPolygon
->MoveTo(XFPoint((double)m_pVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
615 (double)m_pVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
616 for (sal_uInt16 nC
= 1; nC
< m_nNumPoints
; nC
++)
618 pPolygon
->LineTo(XFPoint((double)m_pVector
[nC
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
619 (double)m_pVector
[nC
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
621 pPolygon
->ClosePath();
622 this->SetPosition(pPolygon
);
623 pPolygon
->SetStyleName(rStyleName
);
628 XFFrame
* LwpDrawPolygon::CreateStandardDrawObj(const OUString
& rStyleName
)
630 XFDrawPolygon
* pPolygon
= new XFDrawPolygon();
631 for (sal_uInt16 nC
= 0; nC
< m_nNumPoints
; nC
++)
633 pPolygon
->AddPoint((double)m_pVector
[nC
].x
/TWIPS_PER_CM
,
634 (double)m_pVector
[nC
].y
/TWIPS_PER_CM
);
637 pPolygon
->SetStyleName(rStyleName
);
643 * @descr Constructor of class LwpDrawRectangle
644 * @param pStream The memory stream which contains the lwp-sdw draw objects
646 LwpDrawRectangle::LwpDrawRectangle(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
647 : LwpDrawObj(pStream
, pTransData
)
652 * @descr reading function of class LwpDrawRectangle
654 void LwpDrawRectangle::Read()
656 this->ReadClosedObjStyle();
658 sal_uInt8 nPointsCount
;
659 if (m_eType
== OT_RNDRECT
)
662 m_pStream
->SeekRel(4); // corner points
669 for (sal_uInt8 nC
= 0; nC
< nPointsCount
; nC
++)
671 *m_pStream
>> m_aVector
[nC
].x
;
672 *m_pStream
>> m_aVector
[nC
].y
;
676 OUString
LwpDrawRectangle::RegisterStyle()
678 XFDrawStyle
* pStyle
= new XFDrawStyle();
681 this->SetLineStyle(pStyle
, m_aClosedObjStyleRec
.nLineWidth
, m_aClosedObjStyleRec
.nLineStyle
,
682 m_aClosedObjStyleRec
.aPenColor
);
685 this->SetFillStyle(pStyle
);
687 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
688 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
691 XFFrame
* LwpDrawRectangle::CreateDrawObj(const OUString
& rStyleName
)
693 if (m_eType
== OT_RNDRECT
)
695 return this->CreateRoundedRect(rStyleName
);
699 XFDrawPath
* pRect
= new XFDrawPath();
700 pRect
->MoveTo(XFPoint((double)m_aVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
701 (double)m_aVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
702 for (sal_uInt8 nC
= 1; nC
< 4; nC
++)
704 pRect
->LineTo(XFPoint((double)m_aVector
[nC
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
705 (double)m_aVector
[nC
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
707 pRect
->LineTo(XFPoint((double)m_aVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
708 (double)m_aVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
709 pRect
->ClosePath(sal_True
);
710 this->SetPosition(pRect
);
712 pRect
->SetStyleName(rStyleName
);
718 XFFrame
* LwpDrawRectangle::CreateRoundedRect(const OUString
& rStyleName
)
720 XFDrawPath
* pRoundedRect
= new XFDrawPath();
721 pRoundedRect
->MoveTo(XFPoint((double)m_aVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
722 (double)m_aVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
724 sal_uInt8 nPtIndex
= 1;
725 for (sal_uInt8 nC
= 0; nC
< 7; nC
++)
729 XFPoint
aCtrl1((double)m_aVector
[nPtIndex
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
730 (double)m_aVector
[nPtIndex
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
732 XFPoint
aCtrl2((double)m_aVector
[nPtIndex
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
733 (double)m_aVector
[nPtIndex
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
735 XFPoint
aDest((double)m_aVector
[nPtIndex
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
736 (double)m_aVector
[nPtIndex
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
739 pRoundedRect
->CurveTo(aDest
, aCtrl1
, aCtrl2
);
743 XFPoint
aDest((double)m_aVector
[nPtIndex
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
744 (double)m_aVector
[nPtIndex
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
747 pRoundedRect
->LineTo(aDest
);
751 pRoundedRect
->LineTo(XFPoint((double)m_aVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
752 (double)m_aVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
753 pRoundedRect
->ClosePath(sal_True
);
754 this->SetPosition(pRoundedRect
);
756 pRoundedRect
->SetStyleName(rStyleName
);
761 XFFrame
* LwpDrawRectangle::CreateStandardDrawObj(const OUString
& rStyleName
)
763 if (m_eType
== OT_RNDRECT
)
765 return this->CreateRoundedRect(rStyleName
);
769 XFDrawRect
* pRect
= new XFDrawRect();
770 double fStartX
, fStartY
, fWidth
, fHeight
;
771 double fRotAngle
= 0.0;
772 SdwRectangle aSdwRect
;
773 Rectangle aOriginalRect
;
774 Point aPt0
, aPt1
, aPt2
, aPt3
;
776 aPt0
.setX(m_aVector
[0].x
); aPt0
.setY(m_aVector
[0].y
);
777 aPt1
.setX(m_aVector
[1].x
); aPt1
.setY(m_aVector
[1].y
);
778 aPt2
.setX(m_aVector
[2].x
); aPt2
.setY(m_aVector
[2].y
);
779 aPt3
.setX(m_aVector
[3].x
); aPt3
.setY(m_aVector
[3].y
);
781 aSdwRect
= SdwRectangle(aPt0
, aPt1
, aPt2
, aPt3
);
782 if (aSdwRect
.IsRectRotated())
784 aOriginalRect
= aSdwRect
.GetOriginalRect();
785 fRotAngle
= aSdwRect
.GetRotationAngle();
789 aOriginalRect
= Rectangle(aPt0
, aPt2
);
792 fStartX
= aOriginalRect
.TopLeft().X();
793 fStartY
= aOriginalRect
.TopLeft().Y();
794 fWidth
= aOriginalRect
.GetWidth();
795 fHeight
= aOriginalRect
.GetHeight();
797 pRect
->SetStartPoint(XFPoint(fStartX
/TWIPS_PER_CM
+ m_pTransData
->fOffsetX
,
798 fStartY
/TWIPS_PER_CM
+ m_pTransData
->fOffsetY
));
799 pRect
->SetSize(fWidth
/TWIPS_PER_CM
, fHeight
/TWIPS_PER_CM
);
801 if (aSdwRect
.IsRectRotated())
803 pRect
->SetRotate( fRotAngle
/ PI
* 180);// aXFCenter);
806 pRect
->SetStyleName(rStyleName
);
813 * @descr Constructor of class LwpDrawEllipse
814 * @param pStream The memory stream which contains the lwp-sdw draw objects
816 LwpDrawEllipse::LwpDrawEllipse(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
817 : LwpDrawObj(pStream
, pTransData
)
822 * @descr reading function of class LwpDrawEllipse
824 void LwpDrawEllipse::Read()
826 this->ReadClosedObjStyle();
828 for (sal_uInt8 nC
= 0; nC
< 13; nC
++)
830 *m_pStream
>> m_aVector
[nC
].x
;
831 *m_pStream
>> m_aVector
[nC
].y
;
835 OUString
LwpDrawEllipse::RegisterStyle()
837 XFDrawStyle
* pStyle
= new XFDrawStyle();
840 this->SetLineStyle(pStyle
, m_aClosedObjStyleRec
.nLineWidth
, m_aClosedObjStyleRec
.nLineStyle
,
841 m_aClosedObjStyleRec
.aPenColor
);
844 this->SetFillStyle(pStyle
);
846 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
847 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
850 XFFrame
* LwpDrawEllipse::CreateDrawObj(const OUString
& rStyleName
)
852 XFDrawPath
* pEllipse
= new XFDrawPath();
853 pEllipse
->MoveTo(XFPoint((double)m_aVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
854 (double)m_aVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
855 sal_uInt8 nPtIndex
= 1;
856 for (sal_uInt8 nC
= 0; nC
< 4; nC
++)
858 XFPoint
aCtrl1((double)m_aVector
[nPtIndex
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
859 (double)m_aVector
[nPtIndex
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
861 XFPoint
aCtrl2((double)m_aVector
[nPtIndex
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
862 (double)m_aVector
[nPtIndex
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
864 XFPoint
aDest((double)m_aVector
[nPtIndex
].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
865 (double)m_aVector
[nPtIndex
].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
868 pEllipse
->CurveTo(aDest
, aCtrl1
, aCtrl2
);
870 pEllipse
->ClosePath(sal_True
);
871 this->SetPosition(pEllipse
);
873 pEllipse
->SetStyleName(rStyleName
);
878 XFFrame
* LwpDrawEllipse::CreateStandardDrawObj(const OUString
& rStyleName
)
880 return this->CreateDrawObj(rStyleName
);
884 * @descr Constructor of class LwpDrawArc
885 * @param pStream The memory stream which contains the lwp-sdw draw objects
887 LwpDrawArc::LwpDrawArc(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
888 : LwpDrawObj(pStream
, pTransData
)
893 * @descr reading function of class LwpDrawArc
895 void LwpDrawArc::Read()
897 m_pStream
->SeekRel(16);// arcRect, startPt, endPt
899 *m_pStream
>> m_aArcRec
.nLineWidth
;
900 *m_pStream
>> m_aArcRec
.nLineStyle
;
901 *m_pStream
>> m_aArcRec
.aPenColor
.nR
;
902 *m_pStream
>> m_aArcRec
.aPenColor
.nG
;
903 *m_pStream
>> m_aArcRec
.aPenColor
.nB
;
904 *m_pStream
>> m_aArcRec
.aPenColor
.unused
;
905 *m_pStream
>> m_aArcRec
.nLineEnd
;
907 for (sal_uInt8 nC
= 0; nC
< 4; nC
++)
909 *m_pStream
>> m_aVector
[nC
].x
;
910 *m_pStream
>> m_aVector
[nC
].y
;
914 OUString
LwpDrawArc::RegisterStyle()
916 XFDrawStyle
* pStyle
= new XFDrawStyle();
919 this->SetLineStyle(pStyle
, m_aArcRec
.nLineWidth
, m_aArcRec
.nLineStyle
,
920 m_aArcRec
.aPenColor
);
923 this->SetArrowHead(pStyle
, m_aArcRec
.nLineEnd
, m_aArcRec
.nLineWidth
);
925 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
926 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
929 XFFrame
* LwpDrawArc::CreateDrawObj(const OUString
& rStyleName
)
931 XFDrawPath
* pArc
= new XFDrawPath();
932 pArc
->MoveTo(XFPoint((double)m_aVector
[0].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
933 (double)m_aVector
[0].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
));
934 XFPoint
aDest((double)m_aVector
[3].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
935 (double)m_aVector
[3].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
936 XFPoint
aCtl1((double)m_aVector
[1].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
937 (double)m_aVector
[1].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
938 XFPoint
aCtl2((double)m_aVector
[2].x
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
939 (double)m_aVector
[2].y
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
940 pArc
->CurveTo(aDest
, aCtl1
, aCtl2
);
942 this->SetPosition(pArc
);
944 pArc
->SetStyleName(rStyleName
);
949 XFFrame
* LwpDrawArc::CreateStandardDrawObj(const OUString
& rStyleName
)
951 return this->CreateDrawObj(rStyleName
);
955 * @descr Constructor of class LwpDrawTextBox
956 * @param pStream The memory stream which contains the lwp-sdw draw objects
958 LwpDrawTextBox::LwpDrawTextBox(SvStream
* pStream
) : LwpDrawObj(pStream
)
962 LwpDrawTextBox::~LwpDrawTextBox()
964 if (m_aTextRec
.pTextString
)
966 delete [] m_aTextRec
.pTextString
;
967 m_aTextRec
.pTextString
= NULL
;
971 void LwpDrawTextBox::SetFontStyle(XFFont
* pFont
, SdwTextBoxRecord
* pRec
)
974 XFColor
aXFColor(pRec
->aTextColor
.nR
, pRec
->aTextColor
.nG
,
975 pRec
->aTextColor
.nB
);
976 pFont
->SetColor(aXFColor
);
978 pFont
->SetFontSize(pRec
->nTextSize
/20);
980 pFont
->SetBold((sal_Bool
)((pRec
->nTextAttrs
& TA_BOLD
) != 0));
982 pFont
->SetItalic((sal_Bool
)((pRec
->nTextAttrs
& TA_ITALIC
) != 0));
984 if (pRec
->nTextAttrs
& TA_STRIKETHRU
)
986 pFont
->SetCrossout(enumXFCrossoutSignel
);
990 pFont
->SetCrossout(enumXFCrossoutNone
);
993 if (pRec
->nTextAttrs
& TA_UNDERLINE
)
995 pFont
->SetUnderline(enumXFUnderlineSingle
);
997 else if (pRec
->nTextAttrs
& TA_WORDUNDERLINE
)
999 pFont
->SetUnderline(enumXFUnderlineSingle
, sal_True
);
1001 else if (pRec
->nTextAttrs
& TA_DOUBLEUNDER
)
1003 pFont
->SetUnderline(enumXFUnderlineDouble
);
1007 pFont
->SetUnderline(enumXFUnderlineNone
);
1010 if (pRec
->nTextAttrs
& TA_SMALLCAPS
)
1012 pFont
->SetTransform(enumXFTransformSmallCaps
);
1017 * @descr reading function of class LwpDrawTextBox
1019 void LwpDrawTextBox::Read()
1021 *m_pStream
>> m_aVector
.x
;
1022 *m_pStream
>> m_aVector
.y
;
1023 *m_pStream
>> m_aTextRec
.nTextWidth
;
1025 if (m_aTextRec
.nTextWidth
== 0)
1026 m_aTextRec
.nTextWidth
= 1;
1028 *m_pStream
>> m_aTextRec
.nTextHeight
;
1029 m_pStream
->Read(m_aTextRec
.tmpTextFaceName
, DRAW_FACESIZE
);
1030 m_pStream
->SeekRel(1);// PitchAndFamily
1032 *m_pStream
>> m_aTextRec
.nTextSize
;
1034 if (m_aTextRec
.nTextSize
< 0)
1035 m_aTextRec
.nTextSize
= -m_aTextRec
.nTextSize
;
1038 *m_pStream
>> m_aTextRec
.aTextColor
.nR
;
1039 *m_pStream
>> m_aTextRec
.aTextColor
.nG
;
1040 *m_pStream
>> m_aTextRec
.aTextColor
.nB
;
1041 *m_pStream
>> m_aTextRec
.aTextColor
.unused
;
1043 *m_pStream
>> m_aTextRec
.nTextAttrs
;
1044 *m_pStream
>> m_aTextRec
.nTextCharacterSet
;
1045 *m_pStream
>> m_aTextRec
.nTextRotation
;
1046 *m_pStream
>> m_aTextRec
.nTextExtraSpacing
;
1048 // some draw files in version 1.2 have an extra byte following '\0'.
1049 // can't rely on that, so read in the whole string into memory.
1051 // the 71 is the fixed length before text content in textbox record
1052 sal_Int16 TextLength
= m_aObjHeader
.nRecLen
- 71;
1053 m_aTextRec
.pTextString
= new sal_uInt8
[TextLength
];
1055 m_pStream
->Read(m_aTextRec
.pTextString
, TextLength
);
1058 OUString
LwpDrawTextBox::RegisterStyle()
1060 XFParaStyle
* pStyle
= new XFParaStyle();
1063 // the pFont need to be deleted myself?
1064 XFFont
* pFont
= new XFFont();
1066 rtl_TextEncoding aEncoding
= RTL_TEXTENCODING_MS_1252
;
1067 OUString aFontName
= OUString((sal_Char
*)m_aTextRec
.tmpTextFaceName
,
1068 strlen((char*)m_aTextRec
.tmpTextFaceName
), aEncoding
);
1069 pFont
->SetFontName(aFontName
);
1071 this->SetFontStyle(pFont
, &m_aTextRec
);
1073 pStyle
->SetFont(pFont
);
1075 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1076 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
1079 XFFrame
* LwpDrawTextBox::CreateDrawObj(const OUString
& rStyleName
)
1081 XFFrame
* pTextBox
= new XFFrame(sal_True
);
1083 sal_Int16 TextLength
= m_aObjHeader
.nRecLen
- 71;
1084 rtl_TextEncoding aEncoding
;
1085 if (!m_aTextRec
.nTextCharacterSet
)
1087 aEncoding
= osl_getThreadTextEncoding();
1091 // temporary code, need to create Encoding from the value of nTextCharacterSet
1092 aEncoding
= LwpCharSetMgr::GetInstance()->GetTextCharEncoding();
1095 XFParagraph
* pXFPara
= new XFParagraph();
1096 pXFPara
->Add(OUString((sal_Char
*)m_aTextRec
.pTextString
, (TextLength
-2), aEncoding
));
1097 pXFPara
->SetStyleName(rStyleName
);
1099 pTextBox
->Add(pXFPara
);
1100 this->SetPosition(pTextBox
);
1102 XFTextBoxStyle
* pBoxStyle
= new XFTextBoxStyle();
1104 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1105 OUString sName
= pXFStyleManager
->AddStyle(pBoxStyle
)->GetStyleName();
1106 pTextBox
->SetStyleName(sName
);
1108 //todo: add the interface for rotating textbox
1109 // if (m_aTextRec.nTextRotation)
1111 // double fAngle = double(3600-m_aTextRec.nTextRotation)/10;
1112 // pTextBox->SetRotate(fAngle);
1118 XFFrame
* LwpDrawTextBox::CreateStandardDrawObj(const OUString
& rStyleName
)
1120 return this->CreateDrawObj(rStyleName
);
1124 * @descr Constructor of class LwpDrawTextBox
1125 * @param pStream The memory stream which contains the lwp-sdw draw objects
1127 LwpDrawTextArt::LwpDrawTextArt(SvStream
* pStream
, DrawingOffsetAndScale
* pTransData
)
1128 : LwpDrawObj(pStream
, pTransData
)
1132 LwpDrawTextArt::~LwpDrawTextArt()
1134 if (m_aTextArtRec
.aPath
[0].pPts
)
1136 delete [] m_aTextArtRec
.aPath
[0].pPts
;
1137 m_aTextArtRec
.aPath
[0].pPts
= NULL
;
1139 if (m_aTextArtRec
.aPath
[1].pPts
)
1141 delete [] m_aTextArtRec
.aPath
[1].pPts
;
1142 m_aTextArtRec
.aPath
[1].pPts
= NULL
;
1144 if (m_aTextArtRec
.pTextString
)
1146 delete [] m_aTextArtRec
.pTextString
;
1147 m_aTextArtRec
.pTextString
= NULL
;
1152 void LwpDrawTextArt::CreateFWPath(XFDrawPath
* pPath
)
1155 nX
= (m_aTextArtRec
.aPath
[0].pPts
[0].x
+ m_aTextArtRec
.aPath
[1].pPts
[0].x
) / 2;
1156 nY
= (m_aTextArtRec
.aPath
[0].pPts
[0].y
+ m_aTextArtRec
.aPath
[1].pPts
[0].y
) / 2;
1157 XFPoint
aStart((double)nX
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
1158 (double)nY
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
1159 pPath
->MoveTo(aStart
);
1161 sal_uInt8 nPtIndex
= 1;
1162 for (sal_uInt8 nC
= 1; nC
<= m_aTextArtRec
.aPath
[0].n
; nC
++)
1164 nX
= (m_aTextArtRec
.aPath
[0].pPts
[nPtIndex
].x
+ m_aTextArtRec
.aPath
[1].pPts
[nPtIndex
].x
) / 2;
1165 nY
= (m_aTextArtRec
.aPath
[0].pPts
[nPtIndex
].y
+ m_aTextArtRec
.aPath
[1].pPts
[nPtIndex
].y
) / 2;
1166 XFPoint
aCtrl1((double)nX
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
1167 (double)nY
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
1170 nX
= (m_aTextArtRec
.aPath
[0].pPts
[nPtIndex
].x
+ m_aTextArtRec
.aPath
[1].pPts
[nPtIndex
].x
) / 2;
1171 nY
= (m_aTextArtRec
.aPath
[0].pPts
[nPtIndex
].y
+ m_aTextArtRec
.aPath
[1].pPts
[nPtIndex
].y
) / 2;
1172 XFPoint
aCtrl2((double)nX
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
1173 (double)nY
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
1176 nX
= (m_aTextArtRec
.aPath
[0].pPts
[nPtIndex
].x
+ m_aTextArtRec
.aPath
[1].pPts
[nPtIndex
].x
) / 2;
1177 nY
= (m_aTextArtRec
.aPath
[0].pPts
[nPtIndex
].y
+ m_aTextArtRec
.aPath
[1].pPts
[nPtIndex
].y
) / 2;
1178 XFPoint
aDest((double)nX
/TWIPS_PER_CM
* m_pTransData
->fScaleX
,
1179 (double)nY
/TWIPS_PER_CM
* m_pTransData
->fScaleY
);
1181 pPath
->CurveTo(aDest
, aCtrl1
, aCtrl2
);
1185 void LwpDrawTextArt::Read()
1187 for (sal_uInt8 nC
= 0; nC
< 4; nC
++)
1189 *m_pStream
>> m_aVector
[nC
].x
;
1190 *m_pStream
>> m_aVector
[nC
].y
;
1193 this->ReadClosedObjStyle();
1194 m_aTextArtRec
.aTextColor
= m_aClosedObjStyleRec
.aForeColor
;
1196 *m_pStream
>> m_aTextArtRec
.nIndex
;
1197 *m_pStream
>> m_aTextArtRec
.nRotation
;
1199 sal_uInt16 nPointNumber
;
1201 *m_pStream
>> nPointNumber
;
1202 m_aTextArtRec
.aPath
[0].n
= nPointNumber
;
1203 m_aTextArtRec
.aPath
[0].pPts
= new SdwPoint
[nPointNumber
*3+1];
1205 for ( nPt
= 0; nPt
<= nPointNumber
*3; nPt
++)
1209 m_aTextArtRec
.aPath
[0].pPts
[nPt
].x
= nX
;
1210 m_aTextArtRec
.aPath
[0].pPts
[nPt
].y
= nY
;
1213 *m_pStream
>> nPointNumber
;
1214 m_aTextArtRec
.aPath
[1].n
= nPointNumber
;
1215 m_aTextArtRec
.aPath
[1].pPts
= new SdwPoint
[nPointNumber
*3+1];
1216 for (nPt
= 0; nPt
<= nPointNumber
*3; nPt
++)
1220 m_aTextArtRec
.aPath
[1].pPts
[nPt
].x
= nX
;
1221 m_aTextArtRec
.aPath
[1].pPts
[nPt
].y
= nY
;
1224 m_pStream
->SeekRel(1);
1226 m_pStream
->Read(m_aTextArtRec
.tmpTextFaceName
, DRAW_FACESIZE
);
1227 m_pStream
->SeekRel(1);// PitchAndFamily
1229 *m_pStream
>> m_aTextArtRec
.nTextSize
;
1231 if (m_aTextArtRec
.nTextSize
< 0)
1232 m_aTextArtRec
.nTextSize
= -m_aTextArtRec
.nTextSize
;
1234 *m_pStream
>> m_aTextArtRec
.nTextAttrs
;
1235 *m_pStream
>> m_aTextArtRec
.nTextCharacterSet
;
1236 m_aTextArtRec
.nTextRotation
= 0;
1237 *m_pStream
>> m_aTextArtRec
.nTextExtraSpacing
;
1239 const sal_uInt16 nTextArtFixedLength
= 105;
1240 m_aTextArtRec
.nTextLen
= m_aObjHeader
.nRecLen
- nTextArtFixedLength
1241 - (m_aTextArtRec
.aPath
[0].n
*3 + 1)*4
1242 - (m_aTextArtRec
.aPath
[1].n
*3 + 1)*4;
1244 m_aTextArtRec
.pTextString
= new sal_uInt8
[m_aTextArtRec
.nTextLen
];
1245 m_pStream
->Read(m_aTextArtRec
.pTextString
, m_aTextArtRec
.nTextLen
);
1246 m_aTextArtRec
.pTextString
[m_aTextArtRec
.nTextLen
-1] = 0;
1250 OUString
LwpDrawTextArt::RegisterStyle()
1252 XFParaStyle
* pStyle
= new XFParaStyle();
1255 // the pFont need to be deleted myself?
1256 XFFont
* pFont
= new XFFont();
1258 rtl_TextEncoding aEncoding
= RTL_TEXTENCODING_MS_1252
;
1259 OUString aFontName
= OUString((sal_Char
*)m_aTextArtRec
.tmpTextFaceName
,
1260 strlen((char*)m_aTextArtRec
.tmpTextFaceName
), aEncoding
);
1261 pFont
->SetFontName(aFontName
);
1263 LwpDrawTextBox::SetFontStyle(pFont
, &m_aTextArtRec
);
1265 pStyle
->SetFont(pFont
);
1267 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1268 return pXFStyleManager
->AddStyle(pStyle
)->GetStyleName();
1271 XFFrame
* LwpDrawTextArt::CreateDrawObj(const OUString
& rStyleName
)
1273 XFFrame
* pRetObj
= NULL
;
1274 XFDrawStyle
* pStyle
= new XFDrawStyle();
1276 pRetObj
= new XFDrawPath();
1277 XFDrawPath
* pFWPath
= static_cast<XFDrawPath
*>(pRetObj
);
1278 this->CreateFWPath(pFWPath
);
1279 pStyle
->SetFontWorkStyle(0, enumXFFWSlantY
, enumXFFWAdjustAutosize
);
1281 this->SetPosition(pRetObj
);
1283 rtl_TextEncoding aEncoding
;
1284 if (!m_aTextArtRec
.nTextCharacterSet
)
1286 aEncoding
= osl_getThreadTextEncoding();
1290 // temporary code, need to create Encoding from the value of nTextCharacterSet
1291 aEncoding
= LwpCharSetMgr::GetInstance()->GetTextCharEncoding();
1294 XFParagraph
* pXFPara
= new XFParagraph();
1295 pXFPara
->Add(OUString((sal_Char
*)m_aTextArtRec
.pTextString
, (m_aTextArtRec
.nTextLen
-1), aEncoding
));
1296 pXFPara
->SetStyleName(rStyleName
);
1297 pRetObj
->Add(pXFPara
);
1299 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1300 pRetObj
->SetStyleName(pXFStyleManager
->AddStyle(pStyle
)->GetStyleName());
1305 XFFrame
* LwpDrawTextArt::CreateStandardDrawObj(const OUString
& rStyleName
)
1307 return this->CreateDrawObj(rStyleName
);
1312 * @descr Constructor of class LwpDrawMetafile
1313 * @param pStream The memory stream which contains the lwp-sdw draw objects
1315 LwpDrawMetafile::LwpDrawMetafile(SvStream
* pStream
) : LwpDrawObj(pStream
)
1320 * @descr reading function of class LwpDrawMetafile
1322 void LwpDrawMetafile::Read()
1324 m_pStream
->SeekRel(m_aObjHeader
.nRecLen
-16);
1328 * @descr Constructor of class LwpDrawBitmap
1329 * @param pStream The memory stream which contains the lwp-sdw draw objects
1331 LwpDrawBitmap::LwpDrawBitmap(SvStream
* pStream
) : LwpDrawObj(pStream
), m_pImageData(NULL
)
1335 LwpDrawBitmap::~LwpDrawBitmap()
1339 delete [] m_pImageData
;
1340 m_pImageData
= NULL
;
1345 * @descr reading function of class LwpDrawBitmap
1347 void LwpDrawBitmap::Read()
1349 *m_pStream
>> m_aBmpRec
.nTranslation
;
1350 *m_pStream
>> m_aBmpRec
.nRotation
;
1352 // 20 == length of draw-specific fields.
1353 // 14 == length of bmp file header.
1354 m_aBmpRec
.nFileSize
= m_aObjHeader
.nRecLen
- 20 + 14;
1355 m_pImageData
= new sal_uInt8
[m_aBmpRec
.nFileSize
];
1357 BmpInfoHeader2 aInfoHeader2
;
1358 *m_pStream
>> aInfoHeader2
.nHeaderLen
;
1361 sal_uInt32 rgbTableSize
;
1363 if (aInfoHeader2
.nHeaderLen
== sizeof(BmpInfoHeader
))
1365 *m_pStream
>> aInfoHeader2
.nWidth
;
1366 *m_pStream
>> aInfoHeader2
.nHeight
;
1367 *m_pStream
>> aInfoHeader2
.nPlanes
;
1368 *m_pStream
>> aInfoHeader2
.nBitCount
;
1370 N
= aInfoHeader2
.nPlanes
* aInfoHeader2
.nBitCount
;
1377 rgbTableSize
= 3 * (1 << N
);
1382 *m_pStream
>> aInfoHeader2
.nWidth
;
1383 *m_pStream
>> aInfoHeader2
.nHeight
;
1384 *m_pStream
>> aInfoHeader2
.nPlanes
;
1385 *m_pStream
>> aInfoHeader2
.nBitCount
;
1386 N
= aInfoHeader2
.nPlanes
* aInfoHeader2
.nBitCount
;
1393 rgbTableSize
= 4 * (1 << N
);
1398 sal_uInt32 nOffBits
= 14 + aInfoHeader2
.nHeaderLen
+ rgbTableSize
;
1399 m_pImageData
[0] = 'B';
1400 m_pImageData
[1] = 'M';
1401 m_pImageData
[2] = (sal_uInt8
)m_aBmpRec
.nFileSize
;
1402 m_pImageData
[3] = (sal_uInt8
)(m_aBmpRec
.nFileSize
>> 8);
1403 m_pImageData
[4] = (sal_uInt8
)(m_aBmpRec
.nFileSize
>> 16);
1404 m_pImageData
[5] = (sal_uInt8
)(m_aBmpRec
.nFileSize
>> 24);
1405 m_pImageData
[6] = 0;
1406 m_pImageData
[7] = 0;
1407 m_pImageData
[8] = 0;
1408 m_pImageData
[9] = 0;
1409 m_pImageData
[10] = (sal_uInt8
)nOffBits
;
1410 m_pImageData
[11] = (sal_uInt8
)(nOffBits
>> 8);
1411 m_pImageData
[12] = (sal_uInt8
)(nOffBits
>> 16);
1412 m_pImageData
[13] = (sal_uInt8
)(nOffBits
>> 24);
1414 sal_uInt32 nDIBRemaining
;
1415 sal_uInt8
* pPicData
= m_pImageData
;
1416 if (aInfoHeader2
.nHeaderLen
== sizeof(BmpInfoHeader
))
1418 m_pImageData
[14] = (sal_uInt8
)aInfoHeader2
.nHeaderLen
;
1419 m_pImageData
[15] = (sal_uInt8
)(aInfoHeader2
.nHeaderLen
>> 8);
1420 m_pImageData
[16] = (sal_uInt8
)(aInfoHeader2
.nHeaderLen
>> 16);
1421 m_pImageData
[17] = (sal_uInt8
)(aInfoHeader2
.nHeaderLen
>> 24);
1422 m_pImageData
[18] = (sal_uInt8
)aInfoHeader2
.nWidth
;
1423 m_pImageData
[19] = (sal_uInt8
)(aInfoHeader2
.nWidth
>> 8);
1424 m_pImageData
[20] = (sal_uInt8
)aInfoHeader2
.nHeight
;
1425 m_pImageData
[21] = (sal_uInt8
)(aInfoHeader2
.nHeight
>> 8);
1426 m_pImageData
[22] = (sal_uInt8
)aInfoHeader2
.nPlanes
;
1427 m_pImageData
[23] = (sal_uInt8
)(aInfoHeader2
.nPlanes
>> 8);
1428 m_pImageData
[24] = (sal_uInt8
)aInfoHeader2
.nBitCount
;
1429 m_pImageData
[25] = (sal_uInt8
)(aInfoHeader2
.nBitCount
>> 8);
1431 nDIBRemaining
= m_aBmpRec
.nFileSize
- 26;
1432 pPicData
+= 26*sizeof(sal_uInt8
);
1436 m_pImageData
[14] = (sal_uInt8
)aInfoHeader2
.nHeaderLen
;
1437 m_pImageData
[15] = (sal_uInt8
)(aInfoHeader2
.nHeaderLen
>> 8);
1438 m_pImageData
[16] = (sal_uInt8
)(aInfoHeader2
.nHeaderLen
>> 16);
1439 m_pImageData
[17] = (sal_uInt8
)(aInfoHeader2
.nHeaderLen
>> 24);
1440 m_pImageData
[18] = (sal_uInt8
)aInfoHeader2
.nWidth
;
1441 m_pImageData
[19] = (sal_uInt8
)(aInfoHeader2
.nWidth
>> 8);
1442 m_pImageData
[20] = (sal_uInt8
)(aInfoHeader2
.nWidth
>> 16);
1443 m_pImageData
[21] = (sal_uInt8
)(aInfoHeader2
.nWidth
>> 24);
1444 m_pImageData
[22] = (sal_uInt8
)aInfoHeader2
.nHeight
;
1445 m_pImageData
[23] = (sal_uInt8
)(aInfoHeader2
.nHeight
>> 8);
1446 m_pImageData
[24] = (sal_uInt8
)(aInfoHeader2
.nHeight
>> 16);
1447 m_pImageData
[25] = (sal_uInt8
)(aInfoHeader2
.nHeight
>> 24);
1448 m_pImageData
[26] = (sal_uInt8
)aInfoHeader2
.nPlanes
;
1449 m_pImageData
[27] = (sal_uInt8
)(aInfoHeader2
.nPlanes
>> 8);
1450 m_pImageData
[28] = (sal_uInt8
)aInfoHeader2
.nBitCount
;
1451 m_pImageData
[29] = (sal_uInt8
)(aInfoHeader2
.nBitCount
>> 8);
1453 nDIBRemaining
= m_aBmpRec
.nFileSize
- 30;
1454 pPicData
+= 30*sizeof(sal_uInt8
);
1457 m_pStream
->Read(pPicData
, nDIBRemaining
);
1460 OUString
LwpDrawBitmap::RegisterStyle()
1462 XFImageStyle
* pBmpStyle
= new XFImageStyle();
1463 pBmpStyle
->SetYPosType(enumXFFrameYPosFromTop
, enumXFFrameYRelFrame
);
1464 pBmpStyle
->SetXPosType(enumXFFrameXPosFromLeft
, enumXFFrameXRelFrame
);
1466 XFStyleManager
* pXFStyleManager
= LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1467 return pXFStyleManager
->AddStyle(pBmpStyle
)->GetStyleName();
1470 XFFrame
* LwpDrawBitmap::CreateDrawObj(const OUString
& rStyleName
)
1472 XFImage
* pImage
= new XFImage();
1473 pImage
->SetImageData(m_pImageData
, m_aBmpRec
.nFileSize
);
1474 this->SetPosition(pImage
);
1476 pImage
->SetStyleName(rStyleName
);
1481 XFFrame
* LwpDrawBitmap::CreateStandardDrawObj(const OUString
& rStyleName
)
1483 return this->CreateDrawObj(rStyleName
);
1486 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */