Branch data 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 : : * Implementation file of LwpDrawObjcts and associated class like LwpDrawGroup, LwpDrawRectange
59 : : * and so on.
60 : : */
61 : : #include "lwpglobalmgr.hxx"
62 : : #include "lwpdrawobj.hxx"
63 : : #include "lwptools.hxx"
64 : : #include <tools/stream.hxx>
65 : :
66 : : #include "xfilter/xfframe.hxx"
67 : :
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"
77 : :
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"
83 : :
84 : : #include "lwpcharsetmgr.hxx"
85 : : #include "lwpsdwrect.hxx"
86 : :
87 : : /**
88 : : * @descr Constructor of class LwpDrawObj
89 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
90 : : */
91 : 0 : LwpDrawObj::LwpDrawObj(SvStream * pStream, DrawingOffsetAndScale* pTransData)
92 : : : m_eType(OT_UNDEFINED)
93 : : , m_pStream(pStream)
94 : 0 : , m_pTransData(pTransData)
95 : : {
96 : 0 : this->ReadObjHeaderRecord();
97 : 0 : }
98 : :
99 : : /**
100 : : * @descr read the header record data of lwp-sdw-object
101 : : */
102 : 0 : void LwpDrawObj::ReadObjHeaderRecord()
103 : : {
104 : : //flags
105 : 0 : m_pStream->SeekRel(1);
106 : :
107 : : //record Length
108 : 0 : *m_pStream >> m_aObjHeader.nRecLen;
109 : :
110 : : //boundrect
111 : 0 : *m_pStream >> m_aObjHeader.nLeft;
112 : 0 : *m_pStream >> m_aObjHeader.nTop;
113 : 0 : *m_pStream >> m_aObjHeader.nRight;
114 : 0 : *m_pStream >> m_aObjHeader.nBottom;
115 : :
116 : : //nextObj, prevObj
117 : 0 : m_pStream->SeekRel(4);
118 : 0 : }
119 : :
120 : : /**
121 : : * @descr read the style of closed lwp-sdw-object like: rectangle, ellipse and so on.
122 : : */
123 : 0 : void LwpDrawObj::ReadClosedObjStyle()
124 : : {
125 [ # # ][ # # ]: 0 : if ((m_eType != OT_POLYGON) && (m_eType != OT_TEXTART))
126 : : {
127 : 0 : m_pStream->SeekRel(8);
128 : : }
129 : :
130 : 0 : *m_pStream >> m_aClosedObjStyleRec.nLineWidth;
131 : 0 : *m_pStream >> m_aClosedObjStyleRec.nLineStyle;
132 : :
133 : : // pen color
134 : 0 : *m_pStream >> m_aClosedObjStyleRec.aPenColor.nR;
135 : 0 : *m_pStream >> m_aClosedObjStyleRec.aPenColor.nG;
136 : 0 : *m_pStream >> m_aClosedObjStyleRec.aPenColor.nB;
137 : 0 : *m_pStream >> m_aClosedObjStyleRec.aPenColor.unused;
138 : :
139 : : // foreground color
140 : 0 : *m_pStream >> m_aClosedObjStyleRec.aForeColor.nR;
141 : 0 : *m_pStream >> m_aClosedObjStyleRec.aForeColor.nG;
142 : 0 : *m_pStream >> m_aClosedObjStyleRec.aForeColor.nB;
143 : 0 : *m_pStream >> m_aClosedObjStyleRec.aForeColor.unused;
144 : :
145 : : // background color
146 : 0 : *m_pStream >> m_aClosedObjStyleRec.aBackColor.nR;
147 : 0 : *m_pStream >> m_aClosedObjStyleRec.aBackColor.nG;
148 : 0 : *m_pStream >> m_aClosedObjStyleRec.aBackColor.nB;
149 : 0 : *m_pStream >> m_aClosedObjStyleRec.aBackColor.unused;
150 : :
151 : : // fill style
152 : 0 : *m_pStream >> m_aClosedObjStyleRec.nFillType;
153 : : m_pStream->Read(m_aClosedObjStyleRec.pFillPattern,
154 : 0 : sizeof(m_aClosedObjStyleRec.pFillPattern));
155 : 0 : }
156 : :
157 : : /**
158 : : * @descr set fill style of drawing objects
159 : : * @param pStyle pointer of the drawing xfstyle.
160 : : */
161 : 0 : void LwpDrawObj::SetFillStyle(XFDrawStyle* pStyle)
162 : : {
163 [ # # ]: 0 : if (!pStyle)
164 : : {
165 : : assert(false);
166 : 0 : return;
167 : : }
168 : :
169 : : XFColor aForeColor(m_aClosedObjStyleRec.aForeColor.nR,
170 : 0 : m_aClosedObjStyleRec.aForeColor.nG, m_aClosedObjStyleRec.aForeColor.nB);
171 : : XFColor aBackColor(m_aClosedObjStyleRec.aBackColor.nR,
172 : 0 : m_aClosedObjStyleRec.aBackColor.nG, m_aClosedObjStyleRec.aBackColor.nB);
173 : :
174 [ # # # # : 0 : switch (m_aClosedObjStyleRec.nFillType)
# # # # ]
175 : : {
176 : : default: //fall through!
177 : : case FT_TRANSPARENT:
178 : : {
179 : : // set fill style : none
180 : 0 : break;
181 : : }
182 : : case FT_SOLID:
183 : : {
184 [ # # ]: 0 : pStyle->SetAreaColor(aForeColor);
185 : 0 : break;
186 : : }
187 : : case FT_HORZHATCH:
188 : : {
189 [ # # ]: 0 : pStyle->SetAreaColor(aBackColor);
190 [ # # ]: 0 : pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 0, 0.12, aForeColor);
191 : 0 : break;
192 : : }
193 : : case FT_VERTHATCH:
194 : : {
195 [ # # ]: 0 : pStyle->SetAreaColor(aBackColor);
196 [ # # ]: 0 : pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 90, 0.12, aForeColor);
197 : 0 : break;
198 : : }
199 : : case FT_FDIAGHATCH:
200 : : {
201 [ # # ]: 0 : pStyle->SetAreaColor(aBackColor);
202 [ # # ]: 0 : pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 135, 0.09, aForeColor);
203 : 0 : break;
204 : : }
205 : : case FT_BDIAGHATCH:
206 : : {
207 [ # # ]: 0 : pStyle->SetAreaColor(aBackColor);
208 [ # # ]: 0 : pStyle->SetAreaLineStyle(enumXFAreaLineSingle, 45, 0.09, aForeColor);
209 : 0 : break;
210 : : }
211 : : case FT_CROSSHATCH:
212 : : {
213 [ # # ]: 0 : pStyle->SetAreaColor(aBackColor);
214 [ # # ]: 0 : pStyle->SetAreaLineStyle(enumXFAreaLineCrossed, 0, 0.12, aForeColor);
215 : 0 : break;
216 : : }
217 : : case FT_DIAGCROSSHATCH:
218 : : {
219 [ # # ]: 0 : pStyle->SetAreaColor(aBackColor);
220 [ # # ]: 0 : pStyle->SetAreaLineStyle(enumXFAreaLineCrossed, 45, 0.095, aForeColor);
221 : 0 : break;
222 : : }
223 : : }
224 : : }
225 : :
226 : : /**
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.
232 : : */
233 : 0 : void LwpDrawObj::SetLineStyle(XFDrawStyle* pStyle, sal_uInt8 nWidth, sal_uInt8 nLineStyle,
234 : : const SdwColor& rColor)
235 : : {
236 [ # # ]: 0 : if (!pStyle)
237 : : {
238 : : assert(false);
239 : : return;
240 : : }
241 [ # # ]: 0 : if (nWidth == 0)
242 : : {
243 : 0 : nLineStyle = LS_NULL;
244 : : }
245 : :
246 [ # # ]: 0 : if (nLineStyle == LS_NULL)
247 : : {
248 : : // set stroke:none
249 : : return;
250 : : }
251 : :
252 [ # # ]: 0 : if (nLineStyle == LS_DOT)
253 : : {
254 [ # # ]: 0 : pStyle->SetLineDashStyle(enumXFLineDash, 1, 1, 0.05, 0.05, 0.05);
255 : : }
256 : :
257 : : // line width
258 : 0 : double fWidth = (double)nWidth/TWIPS_PER_CM;
259 : :
260 : : // line color
261 : 0 : XFColor aXFColor(rColor.nR, rColor.nG, rColor.nB);
262 : :
263 [ # # ]: 0 : pStyle->SetLineStyle(fWidth, aXFColor);
264 : : }
265 : :
266 : : /**
267 : : * @descr set position of a drawing object in the frame.
268 : : * @param pObj pointer of the xf-drawing object
269 : : */
270 : 0 : void LwpDrawObj::SetPosition(XFFrame* pObj)
271 : : {
272 : 0 : double fOffsetX = 0.00, fOffsetY = 0.00;
273 : 0 : double fScaleX = 1.00, fScaleY = 1.00;
274 [ # # ]: 0 : if (m_pTransData)
275 : : {
276 : 0 : fOffsetX = m_pTransData->fOffsetX;
277 : 0 : fOffsetY = m_pTransData->fOffsetY;
278 : 0 : fScaleX = m_pTransData->fScaleX;
279 : 0 : fScaleY = m_pTransData->fScaleY;
280 : : }
281 : :
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 : 0 : (double)(m_aObjHeader.nBottom-m_aObjHeader.nTop)/TWIPS_PER_CM * fScaleY);
286 : 0 : }
287 : :
288 : : /**
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.
292 : : */
293 : 0 : void LwpDrawObj::SetArrowHead(XFDrawStyle* pOpenedObjStyle, sal_uInt8 nArrowFlag, sal_uInt8 nLineWidth)
294 : : {
295 : : // no arrowhead
296 [ # # ]: 0 : if (!nArrowFlag)
297 : : {
298 : 0 : return;
299 : : }
300 : :
301 [ # # ]: 0 : if (!pOpenedObjStyle)
302 : : {
303 : : assert(false);
304 : 0 : return;
305 : : }
306 : :
307 : : // arrowhead flag of an object's start side
308 : 0 : sal_uInt8 nLeftArrow = nArrowFlag & 0x0F;
309 : :
310 : : // arrowhead flag of an object's end side
311 : 0 : sal_uInt8 nRightArrow = (nArrowFlag & 0xF0) >> 4;
312 : :
313 : 0 : double fWidth_inch = (double)nLineWidth/TWIPS_PER_CM;
314 : 0 : double fArrowSize_inch = fWidth_inch + 0.08;
315 : 0 : double fArrowSize = fArrowSize_inch * CM_PER_INCH;
316 : :
317 [ # # ]: 0 : if (nLeftArrow)
318 : : {
319 : 0 : pOpenedObjStyle->SetArrowStart( this->GetArrowName(nLeftArrow), fArrowSize, sal_True);
320 : : }
321 [ # # ]: 0 : if (nRightArrow)
322 : : {
323 : 0 : pOpenedObjStyle->SetArrowEnd( this->GetArrowName(nRightArrow), fArrowSize, sal_True);
324 : : }
325 : :
326 : : }
327 : :
328 : : /**
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.
332 : : */
333 : 0 : rtl::OUString LwpDrawObj::GetArrowName(sal_uInt8 nArrowStyle)
334 : : {
335 : : // style name of arrowhead
336 : 0 : rtl::OUString aArrowName;
337 : :
338 [ # # # # : 0 : switch(nArrowStyle)
# # # #
# ]
339 : : {
340 : : default:
341 : : case AH_ARROW_FULLARROW:
342 : 0 : aArrowName = rtl::OUString("Symmetric arrow");
343 : 0 : break;
344 : : case AH_ARROW_HALFARROW:
345 : 0 : aArrowName = rtl::OUString("Arrow concave");
346 : 0 : break;
347 : : case AH_ARROW_LINEARROW:
348 : 0 : aArrowName = rtl::OUString("arrow100");
349 : 0 : break;
350 : : case AH_ARROW_INVFULLARROW:
351 : 0 : aArrowName = rtl::OUString("reverse arrow");
352 : 0 : break;
353 : : case AH_ARROW_INVHALFARROW:
354 : 0 : aArrowName = rtl::OUString("reverse concave arrow");
355 : 0 : break;
356 : : case AH_ARROW_INVLINEARROW:
357 : 0 : aArrowName = rtl::OUString("reverse line arrow");
358 : 0 : break;
359 : : case AH_ARROW_TEE:
360 : 0 : aArrowName = rtl::OUString("Dimension lines");
361 : 0 : break;
362 : : case AH_ARROW_SQUARE:
363 : 0 : aArrowName = rtl::OUString("Square");
364 : 0 : break;
365 : : case AH_ARROW_CIRCLE:
366 : 0 : aArrowName = rtl::OUString("Circle");
367 : 0 : break;
368 : : }
369 : :
370 : 0 : return aArrowName;
371 : : }
372 : :
373 : : /**
374 : : * @descr template method of creating drawing object from Lwp-Model to XF-Model
375 : : * @return pointer of the drawing object of XF-Model.
376 : : */
377 : 0 : XFFrame* LwpDrawObj::CreateXFDrawObject()
378 : : {
379 : : // read records
380 [ # # ]: 0 : this->Read();
381 : :
382 : : // register style
383 [ # # ]: 0 : rtl::OUString aStyleName = this->RegisterStyle();
384 : :
385 : : // create XF-Objects
386 : 0 : XFFrame* pXFObj = NULL;
387 [ # # ][ # # ]: 0 : if (m_pTransData
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
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)
392 : : {
393 [ # # ]: 0 : pXFObj = this->CreateStandardDrawObj(aStyleName);
394 : : }
395 : : else
396 : : {
397 [ # # ]: 0 : pXFObj = this->CreateDrawObj(aStyleName);
398 : : }
399 : :
400 : : // set anchor type
401 [ # # ]: 0 : if (pXFObj)
402 : : {
403 : 0 : pXFObj->SetAnchorType(enumXFAnchorFrame);
404 : : }
405 : :
406 : 0 : return pXFObj;
407 : : }
408 : :
409 : : /**
410 : : * @descr Constructor of class LwpDrawLine
411 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
412 : : */
413 : 0 : LwpDrawLine::LwpDrawLine(SvStream * pStream, DrawingOffsetAndScale* pTransData)
414 : 0 : : LwpDrawObj(pStream, pTransData)
415 : : {
416 : 0 : }
417 : :
418 : : /**
419 : : * @descr reading function of class LwpDrawLine
420 : : */
421 : 0 : void LwpDrawLine::Read()
422 : : {
423 : 0 : *m_pStream >> m_aLineRec.nStartX;
424 : 0 : *m_pStream >> m_aLineRec.nStartY;
425 : 0 : *m_pStream >> m_aLineRec.nEndX;
426 : 0 : *m_pStream >> m_aLineRec.nEndY;
427 : 0 : *m_pStream >> m_aLineRec.nLineWidth;
428 : 0 : *m_pStream >> m_aLineRec.nLineEnd;
429 : 0 : *m_pStream >> m_aLineRec.nLineStyle;
430 : :
431 : 0 : *m_pStream >> m_aLineRec.aPenColor.nR;
432 : 0 : *m_pStream >> m_aLineRec.aPenColor.nG;
433 : 0 : *m_pStream >> m_aLineRec.aPenColor.nB;
434 : 0 : *m_pStream >> m_aLineRec.aPenColor.unused;
435 : 0 : }
436 : :
437 : 0 : rtl::OUString LwpDrawLine::RegisterStyle()
438 : : {
439 [ # # ]: 0 : XFDrawStyle* pStyle = new XFDrawStyle();
440 : :
441 : : // set line style
442 : 0 : this->SetLineStyle(pStyle, m_aLineRec.nLineWidth, m_aLineRec.nLineStyle, m_aLineRec.aPenColor);
443 : :
444 : : // set arrow head
445 : 0 : this->SetArrowHead(pStyle, m_aLineRec.nLineEnd, m_aLineRec.nLineWidth);
446 : :
447 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
448 : 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
449 : :
450 : : }
451 : :
452 : 0 : XFFrame* LwpDrawLine::CreateDrawObj(const rtl::OUString& rStyleName )
453 : : {
454 [ # # ]: 0 : XFDrawPath* pLine = new XFDrawPath();
455 : : pLine->MoveTo(XFPoint((double)(m_aLineRec.nStartX)/TWIPS_PER_CM * m_pTransData->fScaleX,
456 [ # # ]: 0 : (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 [ # # ]: 0 : (double)(m_aLineRec.nEndY)/TWIPS_PER_CM * m_pTransData->fScaleY));
459 : 0 : this->SetPosition(pLine);
460 : :
461 [ # # ]: 0 : pLine->SetStyleName(rStyleName);
462 : :
463 : 0 : return pLine;
464 : : }
465 : :
466 : 0 : XFFrame* LwpDrawLine::CreateStandardDrawObj(const OUString& rStyleName)
467 : : {
468 [ # # ]: 0 : XFDrawLine* pLine = new XFDrawLine();
469 : 0 : pLine->SetStartPoint((double)(m_aLineRec.nStartX)/TWIPS_PER_CM,(double)(m_aLineRec.nStartY)/TWIPS_PER_CM);
470 : 0 : pLine->SetEndPoint((double)(m_aLineRec.nEndX)/TWIPS_PER_CM,(double)(m_aLineRec.nEndY)/TWIPS_PER_CM);
471 : :
472 [ # # ]: 0 : pLine->SetStyleName(rStyleName);
473 : 0 : return pLine;
474 : : }
475 : :
476 : : /**
477 : : * @descr Constructor of class LwpDrawPolyLine
478 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
479 : : */
480 : 0 : LwpDrawPolyLine::LwpDrawPolyLine(SvStream * pStream, DrawingOffsetAndScale* pTransData)
481 : 0 : : LwpDrawObj(pStream, pTransData), m_pVector(NULL)
482 : : {
483 : 0 : }
484 : 0 : LwpDrawPolyLine::~LwpDrawPolyLine()
485 : : {
486 [ # # ]: 0 : if (m_pVector)
487 : : {
488 [ # # ]: 0 : delete [] m_pVector;
489 : 0 : m_pVector = NULL;
490 : : }
491 [ # # ]: 0 : }
492 : :
493 : : /**
494 : : * @descr reading function of class LwpDrawPolyLine
495 : : */
496 : 0 : void LwpDrawPolyLine::Read()
497 : : {
498 : 0 : *m_pStream >> m_aPolyLineRec.nLineWidth;
499 : 0 : *m_pStream >> m_aPolyLineRec.nLineEnd;
500 : 0 : *m_pStream >> m_aPolyLineRec.nLineStyle;
501 : 0 : *m_pStream >> m_aPolyLineRec.aPenColor.nR;
502 : 0 : *m_pStream >> m_aPolyLineRec.aPenColor.nG;
503 : 0 : *m_pStream >> m_aPolyLineRec.aPenColor.nB;
504 : 0 : *m_pStream >> m_aPolyLineRec.aPenColor.unused;
505 : 0 : *m_pStream >> m_aPolyLineRec.nNumPoints;
506 : :
507 : 0 : m_pVector= new SdwPoint [m_aPolyLineRec.nNumPoints];
508 : :
509 [ # # ]: 0 : for (sal_uInt16 nC = 0; nC < m_aPolyLineRec.nNumPoints; nC++)
510 : : {
511 : 0 : *m_pStream >> m_pVector[nC].x;
512 : 0 : *m_pStream >> m_pVector[nC].y;
513 : : }
514 : 0 : }
515 : :
516 : 0 : rtl::OUString LwpDrawPolyLine::RegisterStyle()
517 : : {
518 [ # # ]: 0 : XFDrawStyle* pStyle = new XFDrawStyle();
519 : :
520 : : // set line style
521 : : this->SetLineStyle(pStyle, m_aPolyLineRec.nLineWidth, m_aPolyLineRec.nLineStyle,
522 : 0 : m_aPolyLineRec.aPenColor);
523 : :
524 : : // set arrow head
525 : 0 : this->SetArrowHead(pStyle, m_aPolyLineRec.nLineEnd, m_aPolyLineRec.nLineWidth);
526 : :
527 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
528 : 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
529 : : }
530 : :
531 : 0 : XFFrame* LwpDrawPolyLine::CreateDrawObj(const rtl::OUString& rStyleName )
532 : : {
533 [ # # ]: 0 : XFDrawPath* pPolyline = new XFDrawPath();
534 : 0 : pPolyline->MoveTo(XFPoint((double)m_pVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
535 [ # # ]: 0 : (double)m_pVector[0].y/TWIPS_PER_CM * m_pTransData->fScaleY));
536 [ # # ]: 0 : for (sal_uInt8 nC = 1; nC < m_aPolyLineRec.nNumPoints; nC++)
537 : : {
538 : 0 : pPolyline->LineTo(XFPoint((double)m_pVector[nC].x/TWIPS_PER_CM * m_pTransData->fScaleX,
539 [ # # ]: 0 : (double)m_pVector[nC].y/TWIPS_PER_CM * m_pTransData->fScaleY));
540 : : }
541 : 0 : this->SetPosition(pPolyline);
542 : :
543 [ # # ]: 0 : pPolyline->SetStyleName(rStyleName);
544 : :
545 : 0 : return pPolyline;
546 : : }
547 : :
548 : 0 : XFFrame* LwpDrawPolyLine::CreateStandardDrawObj(const OUString& rStyleName)
549 : : {
550 [ # # ]: 0 : XFDrawPolyline* pPolyline = new XFDrawPolyline();
551 [ # # ]: 0 : for (sal_uInt8 nC = 0; nC < m_aPolyLineRec.nNumPoints; nC++)
552 : : {
553 : 0 : pPolyline->AddPoint((double)m_pVector[nC].x/TWIPS_PER_CM,
554 : 0 : (double)m_pVector[nC].y/TWIPS_PER_CM);
555 : : }
556 : :
557 [ # # ]: 0 : pPolyline->SetStyleName(rStyleName);
558 : :
559 : 0 : return pPolyline;
560 : : }
561 : :
562 : : /**
563 : : * @descr Constructor of class LwpDrawPolygon
564 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
565 : : */
566 : 0 : LwpDrawPolygon::LwpDrawPolygon(SvStream * pStream, DrawingOffsetAndScale* pTransData)
567 : 0 : : LwpDrawObj(pStream, pTransData)
568 : : {
569 : 0 : }
570 : 0 : LwpDrawPolygon::~LwpDrawPolygon()
571 : : {
572 [ # # ]: 0 : if (m_pVector)
573 : : {
574 [ # # ]: 0 : delete [] m_pVector;
575 : 0 : m_pVector = NULL;
576 : : }
577 [ # # ]: 0 : }
578 : :
579 : : /**
580 : : * @descr reading function of class LwpDrawPolygon
581 : : */
582 : 0 : void LwpDrawPolygon::Read()
583 : : {
584 : 0 : this->ReadClosedObjStyle();
585 : 0 : *m_pStream >> m_nNumPoints;
586 : :
587 : 0 : m_pVector = new SdwPoint [m_nNumPoints];
588 : :
589 [ # # ]: 0 : for (sal_uInt16 nC = 0; nC < m_nNumPoints; nC++)
590 : : {
591 : 0 : *m_pStream >> m_pVector[nC].x;
592 : 0 : *m_pStream >> m_pVector[nC].y;
593 : : }
594 : 0 : }
595 : :
596 : 0 : rtl::OUString LwpDrawPolygon::RegisterStyle()
597 : : {
598 [ # # ]: 0 : XFDrawStyle* pStyle = new XFDrawStyle();
599 : :
600 : : // set line style
601 : : this->SetLineStyle(pStyle, m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
602 : 0 : m_aClosedObjStyleRec.aPenColor);
603 : :
604 : : // set fill style
605 : 0 : this->SetFillStyle(pStyle);
606 : :
607 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
608 : 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
609 : : }
610 : :
611 : 0 : XFFrame* LwpDrawPolygon::CreateDrawObj(const rtl::OUString& rStyleName)
612 : : {
613 [ # # ]: 0 : XFDrawPath* pPolygon = new XFDrawPath();
614 : 0 : pPolygon->MoveTo(XFPoint((double)m_pVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
615 [ # # ]: 0 : (double)m_pVector[0].y/TWIPS_PER_CM * m_pTransData->fScaleY));
616 [ # # ]: 0 : for (sal_uInt16 nC = 1; nC < m_nNumPoints; nC++)
617 : : {
618 : 0 : pPolygon->LineTo(XFPoint((double)m_pVector[nC].x/TWIPS_PER_CM * m_pTransData->fScaleX,
619 [ # # ]: 0 : (double)m_pVector[nC].y/TWIPS_PER_CM * m_pTransData->fScaleY));
620 : : }
621 : 0 : pPolygon->ClosePath();
622 : 0 : this->SetPosition(pPolygon);
623 [ # # ]: 0 : pPolygon->SetStyleName(rStyleName);
624 : :
625 : 0 : return pPolygon;
626 : : }
627 : :
628 : 0 : XFFrame* LwpDrawPolygon::CreateStandardDrawObj(const OUString& rStyleName)
629 : : {
630 [ # # ]: 0 : XFDrawPolygon* pPolygon = new XFDrawPolygon();
631 [ # # ]: 0 : for (sal_uInt16 nC = 0; nC < m_nNumPoints; nC++)
632 : : {
633 : 0 : pPolygon->AddPoint((double)m_pVector[nC].x/TWIPS_PER_CM,
634 : 0 : (double)m_pVector[nC].y/TWIPS_PER_CM);
635 : : }
636 : :
637 [ # # ]: 0 : pPolygon->SetStyleName(rStyleName);
638 : :
639 : 0 : return pPolygon;
640 : : }
641 : :
642 : : /**
643 : : * @descr Constructor of class LwpDrawRectangle
644 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
645 : : */
646 : 0 : LwpDrawRectangle::LwpDrawRectangle(SvStream * pStream, DrawingOffsetAndScale* pTransData)
647 : 0 : : LwpDrawObj(pStream, pTransData)
648 : : {
649 : 0 : }
650 : :
651 : : /**
652 : : * @descr reading function of class LwpDrawRectangle
653 : : */
654 : 0 : void LwpDrawRectangle::Read()
655 : : {
656 : 0 : this->ReadClosedObjStyle();
657 : :
658 : : sal_uInt8 nPointsCount;
659 [ # # ]: 0 : if (m_eType == OT_RNDRECT)
660 : : {
661 : 0 : nPointsCount = 16;
662 : 0 : m_pStream->SeekRel(4); // corner points
663 : : }
664 : : else
665 : : {
666 : 0 : nPointsCount = 4;
667 : : }
668 : :
669 [ # # ]: 0 : for (sal_uInt8 nC = 0; nC < nPointsCount; nC++)
670 : : {
671 : 0 : *m_pStream >> m_aVector[nC].x;
672 : 0 : *m_pStream >> m_aVector[nC].y;
673 : : }
674 : 0 : }
675 : :
676 : 0 : rtl::OUString LwpDrawRectangle::RegisterStyle()
677 : : {
678 [ # # ]: 0 : XFDrawStyle* pStyle = new XFDrawStyle();
679 : :
680 : : // set line style
681 : : this->SetLineStyle(pStyle, m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
682 : 0 : m_aClosedObjStyleRec.aPenColor);
683 : :
684 : : // set fill style
685 : 0 : this->SetFillStyle(pStyle);
686 : :
687 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
688 : 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
689 : : }
690 : :
691 : 0 : XFFrame* LwpDrawRectangle::CreateDrawObj(const rtl::OUString& rStyleName)
692 : : {
693 [ # # ]: 0 : if (m_eType == OT_RNDRECT)
694 : : {
695 : 0 : return this->CreateRoundedRect(rStyleName);
696 : : }
697 : : else
698 : : {
699 [ # # ]: 0 : XFDrawPath* pRect = new XFDrawPath();
700 : : pRect->MoveTo(XFPoint((double)m_aVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
701 [ # # ]: 0 : (double)m_aVector[0].y/TWIPS_PER_CM * m_pTransData->fScaleY));
702 [ # # ]: 0 : for (sal_uInt8 nC = 1; nC < 4; nC++)
703 : : {
704 : : pRect->LineTo(XFPoint((double)m_aVector[nC].x/TWIPS_PER_CM * m_pTransData->fScaleX,
705 [ # # ]: 0 : (double)m_aVector[nC].y/TWIPS_PER_CM * m_pTransData->fScaleY));
706 : : }
707 : : pRect->LineTo(XFPoint((double)m_aVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
708 [ # # ]: 0 : (double)m_aVector[0].y/TWIPS_PER_CM * m_pTransData->fScaleY));
709 : 0 : pRect->ClosePath(sal_True);
710 : 0 : this->SetPosition(pRect);
711 : :
712 [ # # ]: 0 : pRect->SetStyleName(rStyleName);
713 : :
714 : 0 : return pRect;
715 : : }
716 : : }
717 : :
718 : 0 : XFFrame* LwpDrawRectangle::CreateRoundedRect(const rtl::OUString& rStyleName)
719 : : {
720 [ # # ]: 0 : XFDrawPath* pRoundedRect = new XFDrawPath();
721 : : pRoundedRect->MoveTo(XFPoint((double)m_aVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
722 [ # # ]: 0 : (double)m_aVector[0].y/TWIPS_PER_CM * m_pTransData->fScaleY));
723 : :
724 : 0 : sal_uInt8 nPtIndex = 1;
725 [ # # ]: 0 : for (sal_uInt8 nC = 0; nC < 7; nC++)
726 : : {
727 [ # # ]: 0 : if (nC%2 == 0)
728 : : {
729 : : XFPoint aCtrl1((double)m_aVector[nPtIndex].x/TWIPS_PER_CM * m_pTransData->fScaleX,
730 : 0 : (double)m_aVector[nPtIndex].y/TWIPS_PER_CM * m_pTransData->fScaleY);
731 : 0 : nPtIndex++;
732 : : XFPoint aCtrl2((double)m_aVector[nPtIndex].x/TWIPS_PER_CM * m_pTransData->fScaleX,
733 : 0 : (double)m_aVector[nPtIndex].y/TWIPS_PER_CM * m_pTransData->fScaleY);
734 : 0 : nPtIndex++;
735 : : XFPoint aDest((double)m_aVector[nPtIndex].x/TWIPS_PER_CM * m_pTransData->fScaleX,
736 : 0 : (double)m_aVector[nPtIndex].y/TWIPS_PER_CM * m_pTransData->fScaleY);
737 : 0 : nPtIndex++;
738 : :
739 [ # # ]: 0 : pRoundedRect->CurveTo(aDest, aCtrl1, aCtrl2);
740 : : }
741 : : else
742 : : {
743 : : XFPoint aDest((double)m_aVector[nPtIndex].x/TWIPS_PER_CM * m_pTransData->fScaleX,
744 : 0 : (double)m_aVector[nPtIndex].y/TWIPS_PER_CM * m_pTransData->fScaleY);
745 : 0 : nPtIndex++;
746 : :
747 [ # # ]: 0 : pRoundedRect->LineTo(aDest);
748 : : }
749 : : }
750 : :
751 : : pRoundedRect->LineTo(XFPoint((double)m_aVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
752 [ # # ]: 0 : (double)m_aVector[0].y/TWIPS_PER_CM * m_pTransData->fScaleY));
753 : 0 : pRoundedRect->ClosePath(sal_True);
754 : 0 : this->SetPosition(pRoundedRect);
755 : :
756 [ # # ]: 0 : pRoundedRect->SetStyleName(rStyleName);
757 : :
758 : 0 : return pRoundedRect;
759 : : }
760 : :
761 : 0 : XFFrame* LwpDrawRectangle::CreateStandardDrawObj(const OUString& rStyleName)
762 : : {
763 [ # # ]: 0 : if (m_eType == OT_RNDRECT)
764 : : {
765 : 0 : return this->CreateRoundedRect(rStyleName);
766 : : }
767 : : else
768 : : {
769 [ # # ][ # # ]: 0 : XFDrawRect* pRect = new XFDrawRect();
770 : : double fStartX, fStartY, fWidth, fHeight;
771 : 0 : double fRotAngle = 0.0;
772 [ # # ]: 0 : SdwRectangle aSdwRect;
773 [ # # ]: 0 : Rectangle aOriginalRect;
774 : 0 : Point aPt0, aPt1, aPt2, aPt3;
775 : :
776 : 0 : aPt0.setX(m_aVector[0].x); aPt0.setY(m_aVector[0].y);
777 : 0 : aPt1.setX(m_aVector[1].x); aPt1.setY(m_aVector[1].y);
778 : 0 : aPt2.setX(m_aVector[2].x); aPt2.setY(m_aVector[2].y);
779 : 0 : aPt3.setX(m_aVector[3].x); aPt3.setY(m_aVector[3].y);
780 : :
781 [ # # ][ # # ]: 0 : aSdwRect = SdwRectangle(aPt0, aPt1, aPt2, aPt3);
782 [ # # ][ # # ]: 0 : if (aSdwRect.IsRectRotated())
783 : : {
784 [ # # ]: 0 : aOriginalRect = aSdwRect.GetOriginalRect();
785 [ # # ]: 0 : fRotAngle = aSdwRect.GetRotationAngle();
786 : : }
787 : : else
788 : : {
789 [ # # ]: 0 : aOriginalRect = Rectangle(aPt0, aPt2);
790 : : }
791 : :
792 : 0 : fStartX = aOriginalRect.TopLeft().X();
793 : 0 : fStartY = aOriginalRect.TopLeft().Y();
794 [ # # ]: 0 : fWidth = aOriginalRect.GetWidth();
795 [ # # ]: 0 : fHeight = aOriginalRect.GetHeight();
796 : :
797 : : pRect->SetStartPoint(XFPoint(fStartX/TWIPS_PER_CM + m_pTransData->fOffsetX,
798 : 0 : fStartY/TWIPS_PER_CM + m_pTransData->fOffsetY));
799 : 0 : pRect->SetSize(fWidth/TWIPS_PER_CM, fHeight/TWIPS_PER_CM);
800 : :
801 [ # # ][ # # ]: 0 : if (aSdwRect.IsRectRotated())
802 : : {
803 : 0 : pRect->SetRotate( fRotAngle / PI * 180);// aXFCenter);
804 : : }
805 : :
806 [ # # ]: 0 : pRect->SetStyleName(rStyleName);
807 : :
808 [ # # ]: 0 : return pRect;
809 : : }
810 : : }
811 : :
812 : : /**
813 : : * @descr Constructor of class LwpDrawEllipse
814 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
815 : : */
816 : 0 : LwpDrawEllipse::LwpDrawEllipse(SvStream * pStream, DrawingOffsetAndScale* pTransData)
817 : 0 : : LwpDrawObj(pStream, pTransData)
818 : : {
819 : 0 : }
820 : :
821 : : /**
822 : : * @descr reading function of class LwpDrawEllipse
823 : : */
824 : 0 : void LwpDrawEllipse::Read()
825 : : {
826 : 0 : this->ReadClosedObjStyle();
827 : :
828 [ # # ]: 0 : for (sal_uInt8 nC = 0; nC < 13; nC++)
829 : : {
830 : 0 : *m_pStream >> m_aVector[nC].x;
831 : 0 : *m_pStream >> m_aVector[nC].y;
832 : : }
833 : 0 : }
834 : :
835 : 0 : rtl::OUString LwpDrawEllipse::RegisterStyle()
836 : : {
837 [ # # ]: 0 : XFDrawStyle* pStyle = new XFDrawStyle();
838 : :
839 : : // set line style
840 : : this->SetLineStyle(pStyle, m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
841 : 0 : m_aClosedObjStyleRec.aPenColor);
842 : :
843 : : // set fill style
844 : 0 : this->SetFillStyle(pStyle);
845 : :
846 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
847 : 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
848 : : }
849 : :
850 : 0 : XFFrame* LwpDrawEllipse::CreateDrawObj(const rtl::OUString& rStyleName )
851 : : {
852 [ # # ]: 0 : XFDrawPath* pEllipse = new XFDrawPath();
853 : : pEllipse->MoveTo(XFPoint((double)m_aVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
854 [ # # ]: 0 : (double)m_aVector[0].y/TWIPS_PER_CM * m_pTransData->fScaleY));
855 : 0 : sal_uInt8 nPtIndex = 1;
856 [ # # ]: 0 : for (sal_uInt8 nC = 0; nC < 4; nC++)
857 : : {
858 : : XFPoint aCtrl1((double)m_aVector[nPtIndex].x/TWIPS_PER_CM * m_pTransData->fScaleX,
859 : 0 : (double)m_aVector[nPtIndex].y/TWIPS_PER_CM * m_pTransData->fScaleY);
860 : 0 : nPtIndex++;
861 : : XFPoint aCtrl2((double)m_aVector[nPtIndex].x/TWIPS_PER_CM * m_pTransData->fScaleX,
862 : 0 : (double)m_aVector[nPtIndex].y/TWIPS_PER_CM * m_pTransData->fScaleY);
863 : 0 : nPtIndex++;
864 : : XFPoint aDest((double)m_aVector[nPtIndex].x/TWIPS_PER_CM * m_pTransData->fScaleX,
865 : 0 : (double)m_aVector[nPtIndex].y/TWIPS_PER_CM * m_pTransData->fScaleY);
866 : 0 : nPtIndex++;
867 : :
868 [ # # ]: 0 : pEllipse->CurveTo(aDest, aCtrl1, aCtrl2);
869 : : }
870 : 0 : pEllipse->ClosePath(sal_True);
871 : 0 : this->SetPosition(pEllipse);
872 : :
873 [ # # ]: 0 : pEllipse->SetStyleName(rStyleName);
874 : :
875 : 0 : return pEllipse;
876 : : }
877 : :
878 : 0 : XFFrame* LwpDrawEllipse::CreateStandardDrawObj(const OUString& rStyleName)
879 : : {
880 : 0 : return this->CreateDrawObj(rStyleName);
881 : : }
882 : :
883 : : /**
884 : : * @descr Constructor of class LwpDrawArc
885 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
886 : : */
887 : 0 : LwpDrawArc::LwpDrawArc(SvStream * pStream, DrawingOffsetAndScale* pTransData)
888 : 0 : : LwpDrawObj(pStream, pTransData)
889 : : {
890 : 0 : }
891 : :
892 : : /**
893 : : * @descr reading function of class LwpDrawArc
894 : : */
895 : 0 : void LwpDrawArc::Read()
896 : : {
897 : 0 : m_pStream->SeekRel(16);// arcRect, startPt, endPt
898 : :
899 : 0 : *m_pStream >> m_aArcRec.nLineWidth;
900 : 0 : *m_pStream >> m_aArcRec.nLineStyle;
901 : 0 : *m_pStream >> m_aArcRec.aPenColor.nR;
902 : 0 : *m_pStream >> m_aArcRec.aPenColor.nG;
903 : 0 : *m_pStream >> m_aArcRec.aPenColor.nB;
904 : 0 : *m_pStream >> m_aArcRec.aPenColor.unused;
905 : 0 : *m_pStream >> m_aArcRec.nLineEnd;
906 : :
907 [ # # ]: 0 : for (sal_uInt8 nC = 0; nC < 4; nC++)
908 : : {
909 : 0 : *m_pStream >> m_aVector[nC].x;
910 : 0 : *m_pStream >> m_aVector[nC].y;
911 : : }
912 : 0 : }
913 : :
914 : 0 : rtl::OUString LwpDrawArc::RegisterStyle()
915 : : {
916 [ # # ]: 0 : XFDrawStyle* pStyle = new XFDrawStyle();
917 : :
918 : : // set line style
919 : : this->SetLineStyle(pStyle, m_aArcRec.nLineWidth, m_aArcRec.nLineStyle,
920 : 0 : m_aArcRec.aPenColor);
921 : :
922 : : // set arrow head
923 : 0 : this->SetArrowHead(pStyle, m_aArcRec.nLineEnd, m_aArcRec.nLineWidth);
924 : :
925 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
926 : 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
927 : : }
928 : :
929 : 0 : XFFrame* LwpDrawArc::CreateDrawObj(const rtl::OUString& rStyleName )
930 : : {
931 [ # # ][ # # ]: 0 : XFDrawPath* pArc = new XFDrawPath();
932 : : pArc->MoveTo(XFPoint((double)m_aVector[0].x/TWIPS_PER_CM * m_pTransData->fScaleX,
933 [ # # ]: 0 : (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 : 0 : (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 : 0 : (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 : 0 : (double)m_aVector[2].y/TWIPS_PER_CM * m_pTransData->fScaleY);
940 [ # # ]: 0 : pArc->CurveTo(aDest, aCtl1, aCtl2);
941 : :
942 : 0 : this->SetPosition(pArc);
943 : :
944 [ # # ]: 0 : pArc->SetStyleName(rStyleName);
945 : :
946 : 0 : return pArc;
947 : : }
948 : :
949 : 0 : XFFrame* LwpDrawArc::CreateStandardDrawObj(const OUString& rStyleName)
950 : : {
951 : 0 : return this->CreateDrawObj(rStyleName);
952 : : }
953 : :
954 : : /**
955 : : * @descr Constructor of class LwpDrawTextBox
956 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
957 : : */
958 : 0 : LwpDrawTextBox::LwpDrawTextBox(SvStream* pStream) : LwpDrawObj(pStream)
959 : : {
960 : 0 : }
961 : :
962 : 0 : LwpDrawTextBox::~LwpDrawTextBox()
963 : : {
964 [ # # ]: 0 : if (m_aTextRec.pTextString)
965 : : {
966 [ # # ]: 0 : delete [] m_aTextRec.pTextString;
967 : 0 : m_aTextRec.pTextString = NULL;
968 : : }
969 [ # # ]: 0 : }
970 : :
971 : 0 : void LwpDrawTextBox::SetFontStyle(XFFont* pFont, SdwTextBoxRecord* pRec)
972 : : {
973 : : // color
974 : : XFColor aXFColor(pRec->aTextColor.nR, pRec->aTextColor.nG,
975 : 0 : pRec->aTextColor.nB);
976 : 0 : pFont->SetColor(aXFColor);
977 : : //size
978 [ # # ]: 0 : pFont->SetFontSize(pRec->nTextSize/20);
979 : : // bold
980 [ # # ]: 0 : pFont->SetBold((sal_Bool)((pRec->nTextAttrs & TA_BOLD) != 0));
981 : : // italic
982 [ # # ]: 0 : pFont->SetItalic((sal_Bool)((pRec->nTextAttrs & TA_ITALIC) != 0));
983 : : // strike-through
984 [ # # ]: 0 : if (pRec->nTextAttrs & TA_STRIKETHRU)
985 : : {
986 : 0 : pFont->SetCrossout(enumXFCrossoutSignel);
987 : : }
988 : : else
989 : : {
990 : 0 : pFont->SetCrossout(enumXFCrossoutNone);
991 : : }
992 : : // underline
993 [ # # ]: 0 : if (pRec->nTextAttrs & TA_UNDERLINE)
994 : : {
995 : 0 : pFont->SetUnderline(enumXFUnderlineSingle);
996 : : }
997 [ # # ]: 0 : else if (pRec->nTextAttrs & TA_WORDUNDERLINE)
998 : : {
999 : 0 : pFont->SetUnderline(enumXFUnderlineSingle, sal_True);
1000 : : }
1001 [ # # ]: 0 : else if (pRec->nTextAttrs & TA_DOUBLEUNDER)
1002 : : {
1003 : 0 : pFont->SetUnderline(enumXFUnderlineDouble);
1004 : : }
1005 : : else
1006 : : {
1007 : 0 : pFont->SetUnderline(enumXFUnderlineNone);
1008 : : }
1009 : : // small-caps
1010 [ # # ]: 0 : if (pRec->nTextAttrs & TA_SMALLCAPS)
1011 : : {
1012 : 0 : pFont->SetTransform(enumXFTransformSmallCaps);
1013 : : }
1014 : 0 : }
1015 : :
1016 : : /**
1017 : : * @descr reading function of class LwpDrawTextBox
1018 : : */
1019 : 0 : void LwpDrawTextBox::Read()
1020 : : {
1021 : 0 : *m_pStream >> m_aVector.x;
1022 : 0 : *m_pStream >> m_aVector.y;
1023 : 0 : *m_pStream >> m_aTextRec.nTextWidth;
1024 : :
1025 [ # # ]: 0 : if (m_aTextRec.nTextWidth == 0)
1026 : 0 : m_aTextRec.nTextWidth = 1;
1027 : :
1028 : 0 : *m_pStream >> m_aTextRec.nTextHeight;
1029 : 0 : m_pStream->Read(m_aTextRec.tmpTextFaceName, DRAW_FACESIZE);
1030 : 0 : m_pStream->SeekRel(1);// PitchAndFamily
1031 : :
1032 : 0 : *m_pStream >> m_aTextRec.nTextSize;
1033 : :
1034 [ # # ]: 0 : if (m_aTextRec.nTextSize < 0)
1035 : 0 : m_aTextRec.nTextSize = -m_aTextRec.nTextSize;
1036 : :
1037 : : //color
1038 : 0 : *m_pStream >> m_aTextRec.aTextColor.nR;
1039 : 0 : *m_pStream >> m_aTextRec.aTextColor.nG;
1040 : 0 : *m_pStream >> m_aTextRec.aTextColor.nB;
1041 : 0 : *m_pStream >> m_aTextRec.aTextColor.unused;
1042 : :
1043 : 0 : *m_pStream >> m_aTextRec.nTextAttrs;
1044 : 0 : *m_pStream >> m_aTextRec.nTextCharacterSet;
1045 : 0 : *m_pStream >> m_aTextRec.nTextRotation;
1046 : 0 : *m_pStream >> m_aTextRec.nTextExtraSpacing;
1047 : :
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.
1050 : :
1051 : : // the 71 is the fixed length before text content in textbox record
1052 : 0 : sal_Int16 TextLength = m_aObjHeader.nRecLen - 71;
1053 : 0 : m_aTextRec.pTextString = new sal_uInt8 [TextLength];
1054 : :
1055 : 0 : m_pStream->Read(m_aTextRec.pTextString, TextLength);
1056 : 0 : }
1057 : :
1058 : 0 : rtl::OUString LwpDrawTextBox::RegisterStyle()
1059 : : {
1060 [ # # ][ # # ]: 0 : XFParaStyle* pStyle = new XFParaStyle();
1061 : :
1062 : : // font style
1063 : : // the pFont need to be deleted myself?
1064 [ # # ][ # # ]: 0 : XFFont* pFont = new XFFont();
1065 : :
1066 : 0 : rtl_TextEncoding aEncoding = RTL_TEXTENCODING_MS_1252;
1067 : : rtl::OUString aFontName = rtl::OUString((sal_Char*)m_aTextRec.tmpTextFaceName,
1068 [ # # ]: 0 : strlen((char*)m_aTextRec.tmpTextFaceName), aEncoding);
1069 [ # # ]: 0 : pFont->SetFontName(aFontName);
1070 : :
1071 [ # # ]: 0 : this->SetFontStyle(pFont, &m_aTextRec);
1072 : :
1073 [ # # ]: 0 : pStyle->SetFont(pFont);
1074 : :
1075 [ # # ]: 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1076 [ # # ][ # # ]: 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
1077 : : }
1078 : :
1079 : 0 : XFFrame* LwpDrawTextBox::CreateDrawObj(const rtl::OUString& rStyleName )
1080 : : {
1081 [ # # ][ # # ]: 0 : XFFrame* pTextBox = new XFFrame(sal_True);
1082 : :
1083 : 0 : sal_Int16 TextLength = m_aObjHeader.nRecLen - 71;
1084 : : rtl_TextEncoding aEncoding;
1085 [ # # ]: 0 : if (!m_aTextRec.nTextCharacterSet)
1086 : : {
1087 [ # # ]: 0 : aEncoding = osl_getThreadTextEncoding();
1088 : : }
1089 : : else
1090 : : {
1091 : : // temporary code, need to create Encoding from the value of nTextCharacterSet
1092 [ # # ][ # # ]: 0 : aEncoding = LwpCharSetMgr::GetInstance()->GetTextCharEncoding();
1093 : : }
1094 : :
1095 [ # # ][ # # ]: 0 : XFParagraph* pXFPara = new XFParagraph();
1096 [ # # ][ # # ]: 0 : pXFPara->Add(rtl::OUString((sal_Char*)m_aTextRec.pTextString, (TextLength-2), aEncoding));
1097 [ # # ]: 0 : pXFPara->SetStyleName(rStyleName);
1098 : :
1099 [ # # ]: 0 : pTextBox->Add(pXFPara);
1100 : 0 : this->SetPosition(pTextBox);
1101 : :
1102 [ # # ][ # # ]: 0 : XFTextBoxStyle* pBoxStyle = new XFTextBoxStyle();
1103 : :
1104 [ # # ]: 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1105 [ # # ][ # # ]: 0 : OUString sName = pXFStyleManager->AddStyle(pBoxStyle)->GetStyleName();
1106 [ # # ]: 0 : pTextBox->SetStyleName(sName);
1107 : :
1108 : : //todo: add the interface for rotating textbox
1109 : : // if (m_aTextRec.nTextRotation)
1110 : : // {
1111 : : // double fAngle = double(3600-m_aTextRec.nTextRotation)/10;
1112 : : // pTextBox->SetRotate(fAngle);
1113 : : // }
1114 : :
1115 : 0 : return pTextBox;
1116 : : }
1117 : :
1118 : 0 : XFFrame* LwpDrawTextBox::CreateStandardDrawObj(const OUString& rStyleName)
1119 : : {
1120 : 0 : return this->CreateDrawObj(rStyleName);
1121 : : }
1122 : :
1123 : : /**
1124 : : * @descr Constructor of class LwpDrawTextBox
1125 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
1126 : : */
1127 : 0 : LwpDrawTextArt::LwpDrawTextArt(SvStream* pStream, DrawingOffsetAndScale* pTransData)
1128 : 0 : : LwpDrawObj(pStream, pTransData)
1129 : : {
1130 : 0 : }
1131 : :
1132 : 0 : LwpDrawTextArt::~LwpDrawTextArt()
1133 : : {
1134 [ # # ]: 0 : if (m_aTextArtRec.aPath[0].pPts)
1135 : : {
1136 [ # # ]: 0 : delete [] m_aTextArtRec.aPath[0].pPts;
1137 : 0 : m_aTextArtRec.aPath[0].pPts = NULL;
1138 : : }
1139 [ # # ]: 0 : if (m_aTextArtRec.aPath[1].pPts)
1140 : : {
1141 [ # # ]: 0 : delete [] m_aTextArtRec.aPath[1].pPts;
1142 : 0 : m_aTextArtRec.aPath[1].pPts = NULL;
1143 : : }
1144 [ # # ]: 0 : if (m_aTextArtRec.pTextString)
1145 : : {
1146 [ # # ]: 0 : delete [] m_aTextArtRec.pTextString;
1147 : 0 : m_aTextArtRec.pTextString = NULL;
1148 : : }
1149 : :
1150 [ # # ]: 0 : }
1151 : :
1152 : 0 : void LwpDrawTextArt::CreateFWPath(XFDrawPath* pPath)
1153 : : {
1154 : : sal_Int16 nX, nY;
1155 : 0 : nX = (m_aTextArtRec.aPath[0].pPts[0].x + m_aTextArtRec.aPath[1].pPts[0].x) / 2;
1156 : 0 : 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 : 0 : (double)nY/TWIPS_PER_CM * m_pTransData->fScaleY);
1159 [ # # ]: 0 : pPath->MoveTo(aStart);
1160 : :
1161 : 0 : sal_uInt8 nPtIndex = 1;
1162 [ # # ]: 0 : for (sal_uInt8 nC = 1; nC <= m_aTextArtRec.aPath[0].n; nC++)
1163 : : {
1164 : 0 : nX = (m_aTextArtRec.aPath[0].pPts[nPtIndex].x + m_aTextArtRec.aPath[1].pPts[nPtIndex].x) / 2;
1165 : 0 : 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 : 0 : (double)nY/TWIPS_PER_CM * m_pTransData->fScaleY);
1168 : :
1169 : 0 : nPtIndex++;
1170 : 0 : nX = (m_aTextArtRec.aPath[0].pPts[nPtIndex].x + m_aTextArtRec.aPath[1].pPts[nPtIndex].x) / 2;
1171 : 0 : 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 : 0 : (double)nY/TWIPS_PER_CM * m_pTransData->fScaleY);
1174 : :
1175 : 0 : nPtIndex++;
1176 : 0 : nX = (m_aTextArtRec.aPath[0].pPts[nPtIndex].x + m_aTextArtRec.aPath[1].pPts[nPtIndex].x) / 2;
1177 : 0 : 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 : 0 : (double)nY/TWIPS_PER_CM * m_pTransData->fScaleY);
1180 : :
1181 [ # # ]: 0 : pPath->CurveTo(aDest, aCtrl1, aCtrl2);
1182 : : }
1183 : 0 : }
1184 : :
1185 : 0 : void LwpDrawTextArt::Read()
1186 : : {
1187 [ # # ]: 0 : for (sal_uInt8 nC = 0; nC < 4; nC++)
1188 : : {
1189 [ # # ]: 0 : *m_pStream >> m_aVector[nC].x;
1190 [ # # ]: 0 : *m_pStream >> m_aVector[nC].y;
1191 : : }
1192 : :
1193 [ # # ]: 0 : this->ReadClosedObjStyle();
1194 : 0 : m_aTextArtRec.aTextColor = m_aClosedObjStyleRec.aForeColor;
1195 : :
1196 [ # # ]: 0 : *m_pStream >> m_aTextArtRec.nIndex;
1197 [ # # ]: 0 : *m_pStream >> m_aTextArtRec.nRotation;
1198 : :
1199 : : sal_uInt16 nPointNumber;
1200 : : sal_Int16 nX, nY;
1201 [ # # ]: 0 : *m_pStream >> nPointNumber;
1202 : 0 : m_aTextArtRec.aPath[0].n = nPointNumber;
1203 [ # # ]: 0 : m_aTextArtRec.aPath[0].pPts = new SdwPoint [nPointNumber*3+1];
1204 : 0 : sal_uInt16 nPt = 0;
1205 [ # # ]: 0 : for ( nPt = 0; nPt <= nPointNumber*3; nPt++)
1206 : : {
1207 [ # # ]: 0 : *m_pStream >> nX;
1208 [ # # ]: 0 : *m_pStream >> nY;
1209 : 0 : m_aTextArtRec.aPath[0].pPts[nPt].x = nX;
1210 : 0 : m_aTextArtRec.aPath[0].pPts[nPt].y = nY;
1211 : : }
1212 : :
1213 [ # # ]: 0 : *m_pStream >> nPointNumber;
1214 : 0 : m_aTextArtRec.aPath[1].n = nPointNumber;
1215 [ # # ]: 0 : m_aTextArtRec.aPath[1].pPts = new SdwPoint [nPointNumber*3+1];
1216 [ # # ]: 0 : for (nPt = 0; nPt <= nPointNumber*3; nPt++)
1217 : : {
1218 [ # # ]: 0 : *m_pStream >> nX;
1219 [ # # ]: 0 : *m_pStream >> nY;
1220 : 0 : m_aTextArtRec.aPath[1].pPts[nPt].x = nX;
1221 : 0 : m_aTextArtRec.aPath[1].pPts[nPt].y = nY;
1222 : : }
1223 : :
1224 [ # # ]: 0 : m_pStream->SeekRel(1);
1225 : :
1226 [ # # ]: 0 : m_pStream->Read(m_aTextArtRec.tmpTextFaceName, DRAW_FACESIZE);
1227 [ # # ]: 0 : m_pStream->SeekRel(1);// PitchAndFamily
1228 : :
1229 [ # # ]: 0 : *m_pStream >> m_aTextArtRec.nTextSize;
1230 : :
1231 [ # # ]: 0 : if (m_aTextArtRec.nTextSize < 0)
1232 : 0 : m_aTextArtRec.nTextSize = -m_aTextArtRec.nTextSize;
1233 : :
1234 [ # # ]: 0 : *m_pStream >> m_aTextArtRec.nTextAttrs;
1235 [ # # ]: 0 : *m_pStream >> m_aTextArtRec.nTextCharacterSet;
1236 : 0 : m_aTextArtRec.nTextRotation = 0;
1237 [ # # ]: 0 : *m_pStream >> m_aTextArtRec.nTextExtraSpacing;
1238 : :
1239 : 0 : const sal_uInt16 nTextArtFixedLength = 105;
1240 : : m_aTextArtRec.nTextLen = m_aObjHeader.nRecLen - nTextArtFixedLength
1241 : : - (m_aTextArtRec.aPath[0].n*3 + 1)*4
1242 : 0 : - (m_aTextArtRec.aPath[1].n*3 + 1)*4;
1243 : :
1244 [ # # ]: 0 : m_aTextArtRec.pTextString = new sal_uInt8 [m_aTextArtRec.nTextLen];
1245 [ # # ]: 0 : m_pStream->Read(m_aTextArtRec.pTextString, m_aTextArtRec.nTextLen);
1246 : 0 : m_aTextArtRec.pTextString[m_aTextArtRec.nTextLen-1] = 0;
1247 : :
1248 : 0 : }
1249 : :
1250 : 0 : rtl::OUString LwpDrawTextArt::RegisterStyle()
1251 : : {
1252 [ # # ][ # # ]: 0 : XFParaStyle* pStyle = new XFParaStyle();
1253 : :
1254 : : // font style
1255 : : // the pFont need to be deleted myself?
1256 [ # # ][ # # ]: 0 : XFFont* pFont = new XFFont();
1257 : :
1258 : 0 : rtl_TextEncoding aEncoding = RTL_TEXTENCODING_MS_1252;
1259 : : rtl::OUString aFontName = rtl::OUString((sal_Char*)m_aTextArtRec.tmpTextFaceName,
1260 [ # # ]: 0 : strlen((char*)m_aTextArtRec.tmpTextFaceName), aEncoding);
1261 [ # # ]: 0 : pFont->SetFontName(aFontName);
1262 : :
1263 [ # # ]: 0 : LwpDrawTextBox::SetFontStyle(pFont, &m_aTextArtRec);
1264 : :
1265 [ # # ]: 0 : pStyle->SetFont(pFont);
1266 : :
1267 [ # # ]: 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1268 [ # # ][ # # ]: 0 : return pXFStyleManager->AddStyle(pStyle)->GetStyleName();
1269 : : }
1270 : :
1271 : 0 : XFFrame* LwpDrawTextArt::CreateDrawObj(const rtl::OUString& rStyleName)
1272 : : {
1273 : 0 : XFFrame* pRetObj = NULL;
1274 [ # # ]: 0 : XFDrawStyle* pStyle = new XFDrawStyle();
1275 : :
1276 [ # # ]: 0 : pRetObj = new XFDrawPath();
1277 : 0 : XFDrawPath* pFWPath = static_cast<XFDrawPath*>(pRetObj);
1278 : 0 : this->CreateFWPath(pFWPath);
1279 : 0 : pStyle->SetFontWorkStyle(0, enumXFFWSlantY, enumXFFWAdjustAutosize);
1280 : :
1281 : 0 : this->SetPosition(pRetObj);
1282 : :
1283 : : rtl_TextEncoding aEncoding;
1284 [ # # ]: 0 : if (!m_aTextArtRec.nTextCharacterSet)
1285 : : {
1286 : 0 : aEncoding = osl_getThreadTextEncoding();
1287 : : }
1288 : : else
1289 : : {
1290 : : // temporary code, need to create Encoding from the value of nTextCharacterSet
1291 : 0 : aEncoding = LwpCharSetMgr::GetInstance()->GetTextCharEncoding();
1292 : : }
1293 : :
1294 [ # # ]: 0 : XFParagraph* pXFPara = new XFParagraph();
1295 [ # # ]: 0 : pXFPara->Add(rtl::OUString((sal_Char*)m_aTextArtRec.pTextString, (m_aTextArtRec.nTextLen-1), aEncoding));
1296 [ # # ]: 0 : pXFPara->SetStyleName(rStyleName);
1297 : 0 : pRetObj->Add(pXFPara);
1298 : :
1299 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1300 [ # # ]: 0 : pRetObj->SetStyleName(pXFStyleManager->AddStyle(pStyle)->GetStyleName());
1301 : :
1302 : 0 : return pRetObj;
1303 : : }
1304 : :
1305 : 0 : XFFrame* LwpDrawTextArt::CreateStandardDrawObj(const rtl::OUString& rStyleName )
1306 : : {
1307 : 0 : return this->CreateDrawObj(rStyleName);
1308 : : }
1309 : :
1310 : :
1311 : : /**
1312 : : * @descr Constructor of class LwpDrawMetafile
1313 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
1314 : : */
1315 : 0 : LwpDrawMetafile::LwpDrawMetafile(SvStream* pStream) : LwpDrawObj(pStream)
1316 : : {
1317 : 0 : }
1318 : :
1319 : : /**
1320 : : * @descr reading function of class LwpDrawMetafile
1321 : : */
1322 : 0 : void LwpDrawMetafile::Read()
1323 : : {
1324 : 0 : m_pStream->SeekRel(m_aObjHeader.nRecLen -16);
1325 : 0 : }
1326 : :
1327 : : /**
1328 : : * @descr Constructor of class LwpDrawBitmap
1329 : : * @param pStream The memory stream which contains the lwp-sdw draw objects
1330 : : */
1331 : 0 : LwpDrawBitmap::LwpDrawBitmap(SvStream* pStream) : LwpDrawObj(pStream), m_pImageData(NULL)
1332 : : {
1333 : 0 : }
1334 : :
1335 : 0 : LwpDrawBitmap::~LwpDrawBitmap()
1336 : : {
1337 [ # # ]: 0 : if (m_pImageData)
1338 : : {
1339 [ # # ]: 0 : delete [] m_pImageData;
1340 : 0 : m_pImageData = NULL;
1341 : : }
1342 [ # # ]: 0 : }
1343 : :
1344 : : /**
1345 : : * @descr reading function of class LwpDrawBitmap
1346 : : */
1347 : 0 : void LwpDrawBitmap::Read()
1348 : : {
1349 [ # # ]: 0 : *m_pStream >> m_aBmpRec.nTranslation;
1350 [ # # ]: 0 : *m_pStream >> m_aBmpRec.nRotation;
1351 : :
1352 : : // 20 == length of draw-specific fields.
1353 : : // 14 == length of bmp file header.
1354 : 0 : m_aBmpRec.nFileSize = m_aObjHeader.nRecLen - 20 + 14;
1355 [ # # ]: 0 : m_pImageData = new sal_uInt8 [m_aBmpRec.nFileSize];
1356 : :
1357 : : BmpInfoHeader2 aInfoHeader2;
1358 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nHeaderLen;
1359 : :
1360 : : sal_uInt32 N;
1361 : : sal_uInt32 rgbTableSize;
1362 : :
1363 [ # # ]: 0 : if (aInfoHeader2.nHeaderLen == sizeof(BmpInfoHeader))
1364 : : {
1365 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nWidth;
1366 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nHeight;
1367 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nPlanes;
1368 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nBitCount;
1369 : :
1370 : 0 : N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
1371 [ # # ]: 0 : if (N == 24)
1372 : : {
1373 : 0 : rgbTableSize = 0;
1374 : : }
1375 : : else
1376 : : {
1377 : 0 : rgbTableSize = 3 * (1 << N);
1378 : : }
1379 : : }
1380 : : else
1381 : : {
1382 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nWidth;
1383 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nHeight;
1384 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nPlanes;
1385 [ # # ]: 0 : *m_pStream >> aInfoHeader2.nBitCount;
1386 : 0 : N = aInfoHeader2.nPlanes * aInfoHeader2.nBitCount;
1387 [ # # ]: 0 : if (N == 24)
1388 : : {
1389 : 0 : rgbTableSize = 0;
1390 : : }
1391 : : else
1392 : : {
1393 : 0 : rgbTableSize = 4 * (1 << N);
1394 : : }
1395 : :
1396 : : }
1397 : :
1398 : 0 : sal_uInt32 nOffBits = 14 + aInfoHeader2.nHeaderLen + rgbTableSize;
1399 : 0 : m_pImageData[0] = 'B';
1400 : 0 : m_pImageData[1] = 'M';
1401 : 0 : m_pImageData[2] = (sal_uInt8)m_aBmpRec.nFileSize;
1402 : 0 : m_pImageData[3] = (sal_uInt8)(m_aBmpRec.nFileSize >> 8);
1403 : 0 : m_pImageData[4] = (sal_uInt8)(m_aBmpRec.nFileSize >> 16);
1404 : 0 : m_pImageData[5] = (sal_uInt8)(m_aBmpRec.nFileSize >> 24);
1405 : 0 : m_pImageData[6] = 0;
1406 : 0 : m_pImageData[7] = 0;
1407 : 0 : m_pImageData[8] = 0;
1408 : 0 : m_pImageData[9] = 0;
1409 : 0 : m_pImageData[10] = (sal_uInt8)nOffBits;
1410 : 0 : m_pImageData[11] = (sal_uInt8)(nOffBits >> 8);
1411 : 0 : m_pImageData[12] = (sal_uInt8)(nOffBits >> 16);
1412 : 0 : m_pImageData[13] = (sal_uInt8)(nOffBits >> 24);
1413 : :
1414 : : sal_uInt32 nDIBRemaining;
1415 : 0 : sal_uInt8* pPicData = m_pImageData;
1416 [ # # ]: 0 : if (aInfoHeader2.nHeaderLen== sizeof(BmpInfoHeader))
1417 : : {
1418 : 0 : m_pImageData[14] = (sal_uInt8)aInfoHeader2.nHeaderLen;
1419 : 0 : m_pImageData[15] = (sal_uInt8)(aInfoHeader2.nHeaderLen >> 8);
1420 : 0 : m_pImageData[16] = (sal_uInt8)(aInfoHeader2.nHeaderLen >> 16);
1421 : 0 : m_pImageData[17] = (sal_uInt8)(aInfoHeader2.nHeaderLen >> 24);
1422 : 0 : m_pImageData[18] = (sal_uInt8)aInfoHeader2.nWidth;
1423 : 0 : m_pImageData[19] = (sal_uInt8)(aInfoHeader2.nWidth >> 8);
1424 : 0 : m_pImageData[20] = (sal_uInt8)aInfoHeader2.nHeight;
1425 : 0 : m_pImageData[21] = (sal_uInt8)(aInfoHeader2.nHeight >> 8);
1426 : 0 : m_pImageData[22] = (sal_uInt8)aInfoHeader2.nPlanes;
1427 : 0 : m_pImageData[23] = (sal_uInt8)(aInfoHeader2.nPlanes >> 8);
1428 : 0 : m_pImageData[24] = (sal_uInt8)aInfoHeader2.nBitCount;
1429 : 0 : m_pImageData[25] = (sal_uInt8)(aInfoHeader2.nBitCount >> 8);
1430 : :
1431 : 0 : nDIBRemaining = m_aBmpRec.nFileSize - 26;
1432 : 0 : pPicData += 26*sizeof(sal_uInt8);
1433 : : }
1434 : : else
1435 : : {
1436 : 0 : m_pImageData[14] = (sal_uInt8)aInfoHeader2.nHeaderLen;
1437 : 0 : m_pImageData[15] = (sal_uInt8)(aInfoHeader2.nHeaderLen >> 8);
1438 : 0 : m_pImageData[16] = (sal_uInt8)(aInfoHeader2.nHeaderLen >> 16);
1439 : 0 : m_pImageData[17] = (sal_uInt8)(aInfoHeader2.nHeaderLen >> 24);
1440 : 0 : m_pImageData[18] = (sal_uInt8)aInfoHeader2.nWidth;
1441 : 0 : m_pImageData[19] = (sal_uInt8)(aInfoHeader2.nWidth >> 8);
1442 : 0 : m_pImageData[20] = (sal_uInt8)(aInfoHeader2.nWidth >> 16);
1443 : 0 : m_pImageData[21] = (sal_uInt8)(aInfoHeader2.nWidth >> 24);
1444 : 0 : m_pImageData[22] = (sal_uInt8)aInfoHeader2.nHeight;
1445 : 0 : m_pImageData[23] = (sal_uInt8)(aInfoHeader2.nHeight >> 8);
1446 : 0 : m_pImageData[24] = (sal_uInt8)(aInfoHeader2.nHeight >> 16);
1447 : 0 : m_pImageData[25] = (sal_uInt8)(aInfoHeader2.nHeight >> 24);
1448 : 0 : m_pImageData[26] = (sal_uInt8)aInfoHeader2.nPlanes;
1449 : 0 : m_pImageData[27] = (sal_uInt8)(aInfoHeader2.nPlanes >> 8);
1450 : 0 : m_pImageData[28] = (sal_uInt8)aInfoHeader2.nBitCount;
1451 : 0 : m_pImageData[29] = (sal_uInt8)(aInfoHeader2.nBitCount >> 8);
1452 : :
1453 : 0 : nDIBRemaining = m_aBmpRec.nFileSize - 30;
1454 : 0 : pPicData += 30*sizeof(sal_uInt8);
1455 : : }
1456 : :
1457 [ # # ]: 0 : m_pStream->Read(pPicData, nDIBRemaining);
1458 : 0 : }
1459 : :
1460 : 0 : rtl::OUString LwpDrawBitmap::RegisterStyle()
1461 : : {
1462 [ # # ]: 0 : XFImageStyle* pBmpStyle = new XFImageStyle();
1463 : 0 : pBmpStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelFrame);
1464 : 0 : pBmpStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
1465 : :
1466 : 0 : XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
1467 : 0 : return pXFStyleManager->AddStyle(pBmpStyle)->GetStyleName();
1468 : : }
1469 : :
1470 : 0 : XFFrame* LwpDrawBitmap::CreateDrawObj(const rtl::OUString& rStyleName)
1471 : : {
1472 [ # # ]: 0 : XFImage* pImage = new XFImage();
1473 : 0 : pImage->SetImageData(m_pImageData, m_aBmpRec.nFileSize);
1474 : 0 : this->SetPosition(pImage);
1475 : :
1476 [ # # ]: 0 : pImage->SetStyleName(rStyleName);
1477 : :
1478 : 0 : return pImage;
1479 : : }
1480 : :
1481 : 0 : XFFrame* LwpDrawBitmap::CreateStandardDrawObj(const OUString& rStyleName)
1482 : : {
1483 : 0 : return this->CreateDrawObj(rStyleName);
1484 : : }
1485 : :
1486 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|