LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpdrawobj.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 719 0.0 %
Date: 2014-11-03 Functions: 0 69 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10