LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpoleobject.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 74 83 89.2 %
Date: 2012-08-25 Functions: 8 10 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 31 56 55.4 %

           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                 :            :  *  For LWP filter architecture prototype - OLE object
      59                 :            :  */
      60                 :            : /*************************************************************************
      61                 :            :  * Change History
      62                 :            :  Feb 2005           Created
      63                 :            :  ************************************************************************/
      64                 :            : #include <stdio.h>
      65                 :            : #include <tools/stream.hxx>
      66                 :            : #include "lwpglobalmgr.hxx"
      67                 :            : #include "lwpoleobject.hxx"
      68                 :            : #include "lwpobjfactory.hxx"
      69                 :            : #include "lwpidxmgr.hxx"
      70                 :            : #include "lwp9reader.hxx"
      71                 :            : #include "xfilter/xfparagraph.hxx"
      72                 :            : #include "lwpframelayout.hxx"
      73                 :            : #include "xfilter/xfstylemanager.hxx"
      74                 :            : #include "bento.hxx"
      75                 :            : 
      76                 :            : /**
      77                 :            :  * @descr:   construction function
      78                 :            :  * @param:  objHdr - object header, read before entering this function
      79                 :            :  * @param: pStrm - file stream
      80                 :            :  * @return:  None
      81                 :            :  * @date:    2/22/2005
      82                 :            :  */
      83                 :         75 : LwpGraphicOleObject::LwpGraphicOleObject(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
      84 [ +  - ][ +  - ]:         75 :     : LwpContent(objHdr, pStrm)
      85                 :         75 : {}
      86                 :            : /**
      87                 :            :  * @descr:   Read GraphicOleObject part
      88                 :            :  * @param:  None
      89                 :            :  * @return:  None
      90                 :            :  * @date:    2/22/2005
      91                 :            :  */
      92                 :         75 : void LwpGraphicOleObject::Read()
      93                 :            : {
      94                 :         75 :     LwpContent::Read();
      95                 :            : 
      96         [ +  - ]:         72 :     if (LwpFileHeader::m_nFileRevision >= 0x000b)
      97                 :            :     {
      98                 :            :         // I'm not sure about the read method
      99                 :         72 :         m_pNextObj.ReadIndexed(m_pObjStrm);
     100                 :         72 :         m_pPrevObj.ReadIndexed(m_pObjStrm);
     101                 :            :     }
     102                 :         72 :     m_pObjStrm->SkipExtra();
     103                 :            : 
     104                 :         72 : }
     105                 :            : 
     106                 :          0 : void LwpGraphicOleObject::GetGrafOrgSize(double & rWidth, double & rHeight)
     107                 :            : {
     108                 :          0 :     rWidth = 0;
     109                 :          0 :     rHeight = 0;
     110                 :          0 : }
     111                 :            : 
     112                 :         39 : void LwpGraphicOleObject::GetGrafScaledSize(double & fWidth, double & fHeight)
     113                 :            : {
     114                 :         39 :     GetGrafOrgSize(fWidth, fHeight);
     115                 :            :     // scaled image size
     116                 :         39 :     double fSclGrafWidth = fWidth;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
     117                 :         39 :     double fSclGrafHeight = fHeight;//LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
     118                 :            : 
     119                 :            : 
     120                 :         39 :     LwpVirtualLayout* pLayout = GetLayout(NULL);
     121 [ +  - ][ +  - ]:         39 :     if (pLayout && pLayout->IsFrame())
                 [ +  - ]
     122                 :            :     {
     123                 :         39 :         LwpFrameLayout* pMyFrameLayout = static_cast<LwpFrameLayout*>(pLayout);
     124                 :         39 :         LwpLayoutScale* pMyScale = pMyFrameLayout->GetLayoutScale();
     125                 :         39 :         LwpLayoutGeometry* pFrameGeo = pMyFrameLayout->GetGeometry();
     126                 :            : 
     127                 :            :         // original image size
     128                 :            :         //double fOrgGrafWidth = (double)m_Cache.Width/TWIPS_PER_CM;
     129                 :            :         //double fOrgGrafHeight = (double)m_Cache.Height/TWIPS_PER_CM;
     130                 :            : 
     131                 :            :         // get margin values
     132                 :         39 :         double fLeftMargin = pMyFrameLayout->GetMarginsValue(MARGIN_LEFT);
     133                 :         39 :         double fRightMargin = pMyFrameLayout->GetMarginsValue(MARGIN_RIGHT);
     134                 :         39 :         double fTopMargin = pMyFrameLayout->GetMarginsValue(MARGIN_TOP);
     135                 :         39 :         double fBottomMargin = pMyFrameLayout->GetMarginsValue(MARGIN_BOTTOM);
     136                 :            : 
     137 [ +  - ][ +  - ]:         39 :         if (pMyScale && pFrameGeo)
     138                 :            :         {
     139                 :            :             // frame size
     140                 :         39 :             double fFrameWidth = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetWidth());
     141                 :         39 :             double fFrameHeight = LwpTools::ConvertFromUnitsToMetric(pFrameGeo->GetHeight());
     142                 :            : 
     143                 :            :             // calculate the displayed size of the frame
     144                 :         39 :             double fDisFrameWidth = fFrameWidth - (fLeftMargin+fRightMargin);
     145                 :         39 :             double fDisFrameHeight = fFrameHeight - (fTopMargin+fBottomMargin);
     146                 :            : 
     147                 :            :             // get scale mode
     148                 :         39 :             sal_uInt16 nScalemode = pMyScale->GetScaleMode();
     149         [ +  + ]:         39 :             if (nScalemode & LwpLayoutScale::CUSTOM)
     150                 :            :             {
     151                 :          6 :                 fSclGrafWidth = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleWidth());
     152                 :          6 :                 fSclGrafHeight = LwpTools::ConvertFromUnitsToMetric(pMyScale->GetScaleHeight());
     153                 :            :             }
     154         [ +  + ]:         33 :             else if (nScalemode & LwpLayoutScale::PERCENTAGE)
     155                 :            :             {
     156                 :         15 :                 double fScalePercentage = (double)pMyScale->GetScalePercentage() / 1000;
     157                 :         15 :                 fSclGrafWidth = fScalePercentage * fWidth;
     158                 :         15 :                 fSclGrafHeight = fScalePercentage * fHeight;
     159                 :            :             }
     160         [ +  - ]:         18 :             else if (nScalemode & LwpLayoutScale::FIT_IN_FRAME)
     161                 :            :             {
     162         [ -  + ]:         18 :                 if (pMyFrameLayout->IsFitGraphic())
     163                 :            :                 {
     164                 :          0 :                     fSclGrafWidth = fWidth;
     165                 :          0 :                     fSclGrafHeight = fHeight;
     166                 :            :                 }
     167         [ +  + ]:         18 :                 else if (nScalemode & LwpLayoutScale::MAINTAIN_ASPECT_RATIO)
     168                 :            :                 {
     169         [ +  + ]:         12 :                     if (fWidth/fHeight >= fDisFrameWidth/fDisFrameHeight)
     170                 :            :                     {
     171                 :          3 :                         fSclGrafWidth = fDisFrameWidth;
     172                 :          3 :                         fSclGrafHeight = (fDisFrameWidth/fWidth) * fHeight;
     173                 :            :                     }
     174                 :            :                     else
     175                 :            :                     {
     176                 :          9 :                         fSclGrafHeight = fDisFrameHeight;
     177                 :          9 :                         fSclGrafWidth = (fDisFrameHeight/fHeight) * fWidth;
     178                 :            :                     }
     179                 :            :                 }
     180                 :            :                 else
     181                 :            :                 {
     182                 :          6 :                     fSclGrafWidth = fDisFrameWidth;
     183                 :          6 :                     fSclGrafHeight = fDisFrameHeight;
     184                 :            :                 }
     185                 :            :             }
     186                 :            :         }
     187                 :            :     }
     188                 :         39 :     fWidth = fSclGrafWidth ;
     189                 :         39 :     fHeight =  fSclGrafHeight ;
     190                 :            : 
     191                 :         39 : }
     192                 :            : 
     193                 :            : /**
     194                 :            :  * @descr:   construction function
     195                 :            :  * @param:  objHdr - object header, read before entering this function
     196                 :            :  * @param: pStrm - file stream
     197                 :            :  * @return:  None
     198                 :            :  * @date:    2/22/2005
     199                 :            :  */
     200                 :         54 : LwpOleObject::LwpOleObject(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     201         [ +  - ]:         54 :     : LwpGraphicOleObject(objHdr, pStrm),m_SizeRect(0,0,5,5)
     202                 :            : {
     203                 :         54 : }
     204                 :            : /**
     205                 :            :  * @descr:   Read VO_OLEOBJECT record
     206                 :            :  * @param:  None
     207                 :            :  * @return:  None
     208                 :            :  * @date:    2/22/2005
     209                 :            :  */
     210                 :         54 : void LwpOleObject::Read()
     211                 :            : {
     212         [ +  - ]:         54 :     LwpGraphicOleObject::Read();
     213                 :            : 
     214         [ +  - ]:         54 :     cPersistentFlags = m_pObjStrm->QuickReaduInt16();
     215                 :            : 
     216                 :            :     // qCMarker read
     217         [ +  - ]:         54 :     LwpObjectID ID;
     218                 :            : 
     219         [ +  - ]:         54 :     if (LwpFileHeader::m_nFileRevision >= 0x0004)
     220                 :            :     {
     221         [ +  - ]:         54 :         m_pObjStrm->QuickReaduInt16();
     222                 :            : 
     223         [ +  - ]:         54 :         OUString sFormat = m_pObjStrm->QuickReadStringPtr();
     224                 :            : 
     225         [ -  + ]:         54 :         if (LwpFileHeader::m_nFileRevision < 0x000B)
     226                 :            :         {
     227                 :            :             // null pointers have a VO_INVALID type
     228                 :            :             //if (VO_INVALID == m_pObjStrm->QuickReaduInt16())
     229                 :            :             //  return;
     230                 :            : 
     231         [ #  # ]:          0 :             ID.Read(m_pObjStrm);
     232                 :            :             //return m_pObjStrm->Locate(ID);
     233                 :            :         }
     234                 :            :         else
     235                 :            :         {
     236         [ +  - ]:         54 :             ID.ReadIndexed(m_pObjStrm);
     237                 :            :             //if (ID.IsNull())
     238                 :            :             //  return;
     239                 :            : 
     240                 :            :             //return m_pObjStrm->Locate(ID);
     241                 :         54 :         }
     242                 :            :     }
     243                 :            : 
     244 [ +  - ][ +  - ]:         54 :     if (m_pObjStrm->CheckExtra())
     245                 :            :     {
     246         [ +  - ]:         54 :         m_pObjStrm->QuickReaduInt16();
     247         [ +  - ]:         54 :         m_pObjStrm->SkipExtra();
     248                 :            :     }
     249                 :            : 
     250                 :         54 : }
     251                 :            : 
     252                 :            : /**
     253                 :            :  * @descr:   Parse VO_OLEOBJECT and dump to XML stream only on WIN32 platform
     254                 :            :  * @param:  pOutputStream - stream to dump OLE object
     255                 :            :  * @param:  pFrameLayout -  framlayout object used to dump OLE object
     256                 :            :  * @return:  None
     257                 :            :  * @date:    2/22/2005
     258                 :            :  */
     259                 :          0 : void LwpOleObject::Parse(IXFStream* /*pOutputStream*/)
     260                 :            : {
     261                 :          0 : }
     262                 :            : 
     263                 :         27 : void LwpOleObject::XFConvert(XFContentContainer * /*pCont*/)
     264                 :            : {
     265                 :         27 : }
     266                 :            : 
     267                 :         27 : void LwpOleObject::GetGrafOrgSize(double & rWidth, double & rHeight)
     268                 :            : {
     269                 :         27 :     rWidth = (double)m_SizeRect.GetWidth()/1000;//cm unit
     270                 :         27 :     rHeight = (double)m_SizeRect.GetHeight()/1000;//cm unit
     271                 :         27 : }
     272                 :            : 
     273                 :         54 : void LwpOleObject::RegisterStyle()
     274                 :            : {
     275                 :         54 : }
     276                 :            : 
     277                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10