LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter - lwpbackgroundstuff.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 52 17.3 %
Date: 2015-06-13 12:38:46 Functions: 2 4 50.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             :  * For LWP filter architecture prototype
      59             :  *  Implemention of class LwpBackgroundStuff.
      60             :  */
      61             : 
      62             : #include "lwpbackgroundstuff.hxx"
      63             : #include "lwppttntbl.hxx"
      64             : #include "xfilter/xfbgimage.hxx"
      65             : 
      66             : #include <tools/stream.hxx>
      67             : #include <vcl/dibtools.hxx>
      68             : #include <vcl/bmpacc.hxx>
      69             : #include <svx/xbitmap.hxx>
      70             : 
      71          11 : void LwpBackgroundStuff::Read(LwpObjectStream* pStrm)
      72             : {
      73          11 :     m_nID = pStrm->QuickReaduInt16();
      74          11 :     m_aFillColor.Read(pStrm);
      75          11 :     m_aPatternColor.Read(pStrm);
      76          11 :     pStrm->SkipExtra();
      77          11 : }
      78             : 
      79           0 : void LwpBackgroundStuff::GetPattern(sal_uInt16 btPttnIndex, sal_uInt8* pPttnArray)
      80             : {
      81           0 :     if (btPttnIndex > 71)
      82             :     {
      83             :         assert(false);
      84           0 :         return;
      85             :     }
      86             :     assert((2 < btPttnIndex) && (btPttnIndex < 72));
      87           0 :     const sal_uInt8* pTempArray = s_pLwpPatternTab[btPttnIndex];
      88           0 :     for(sal_uInt8 i = 0; i < 32; i++)
      89             :     {
      90           0 :         pPttnArray[i] = (i%4 == 0) ? pTempArray[7-i/4] : 0;
      91             :     }
      92             : }
      93             : 
      94          37 : LwpColor* LwpBackgroundStuff::GetFillColor()
      95             : {
      96          37 :     if (m_nID == BACK_PATTERN)
      97             :     {
      98           0 :         return &m_aPatternColor;
      99             :     }
     100             : 
     101          37 :     return &m_aFillColor;
     102             : }
     103             : 
     104           0 : XFBGImage* LwpBackgroundStuff::GetFillPattern()
     105             : {
     106             :     // not pattern fill?
     107           0 :     if (!this->IsPatternFill())
     108             :     {
     109           0 :         return NULL;
     110             :     }
     111             : 
     112             :     // get pattern array from pattern table
     113             :     sal_uInt8 aPttnArray[32];
     114           0 :     GetPattern(m_nID, aPttnArray);
     115             : 
     116             :     // create bitmap object from the pattern array
     117           0 :     Bitmap aBmp( Size(8, 8), 1 );
     118           0 :     BitmapWriteAccess* pWA = aBmp.AcquireWriteAccess();
     119           0 :     sal_uInt8* pBuf = pWA->GetBuffer();
     120           0 :     memcpy(pBuf, aPttnArray, 32);
     121           0 :     Bitmap::ReleaseAccess(pWA);
     122             : 
     123             :     // create XOBitmap object from bitmap object
     124           0 :     XOBitmap aXOBitmap( aBmp );
     125           0 :     aXOBitmap.Bitmap2Array();
     126           0 :     aXOBitmap.SetBitmapType( XBITMAP_8X8 );
     127             : 
     128             :     // set back/fore-ground colors
     129           0 :     if (m_aFillColor.IsValidColor() && m_aPatternColor.IsValidColor())
     130             :     {
     131           0 :         Color aBackColor(static_cast<sal_uInt8>(m_aFillColor.GetRed()),
     132           0 :             static_cast<sal_uInt8>(m_aFillColor.GetGreen()),
     133           0 :             static_cast<sal_uInt8>(m_aFillColor.GetBlue()));
     134           0 :         Color aForeColor(static_cast<sal_uInt8>(m_aPatternColor.GetRed()),
     135           0 :             static_cast<sal_uInt8>(m_aPatternColor.GetGreen()),
     136           0 :             static_cast<sal_uInt8>(m_aPatternColor.GetBlue()));
     137             : 
     138           0 :         if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
     139             :         {
     140           0 :             aXOBitmap.SetPixelColor( aBackColor );
     141           0 :             aXOBitmap.SetBackgroundColor( aForeColor );
     142             :         }
     143             :         else
     144             :         {
     145           0 :             aXOBitmap.SetPixelColor( aForeColor );
     146           0 :             aXOBitmap.SetBackgroundColor( aBackColor );
     147             :         }
     148             :     }
     149             : 
     150             :     // transfer image data from XOBitmap->SvStream->BYTE-Array
     151           0 :     SvMemoryStream aPicMemStream;
     152           0 :     aXOBitmap.Array2Bitmap();
     153           0 :     WriteDIB(aXOBitmap.GetBitmap(), aPicMemStream, true, true);
     154           0 :     sal_uInt32 nSize = aPicMemStream.GetEndOfData();
     155           0 :     sal_uInt8* pImageBuff = new sal_uInt8 [nSize];
     156           0 :     memcpy(pImageBuff, aPicMemStream.GetData(), nSize);
     157             : 
     158             :     // create XFBGImage object.
     159           0 :     XFBGImage* pXFBGImage = new XFBGImage();
     160           0 :     pXFBGImage->SetImageData(pImageBuff, nSize);
     161             : 
     162           0 :     delete [] pImageBuff;
     163           0 :     pImageBuff = NULL;
     164             : 
     165           0 :     pXFBGImage->SetRepeate();
     166             :     // end of add
     167             : 
     168           0 :     return pXFBGImage;
     169             : }
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11