LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtabgrdt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 96 9.4 %
Date: 2012-08-25 Functions: 4 16 25.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 234 2.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "svx/XPropertyTable.hxx"
      30                 :            : 
      31                 :            : #include <vcl/virdev.hxx>
      32                 :            : #include <svl/itemset.hxx>
      33                 :            : #include <svx/dialogs.hrc>
      34                 :            : #include <svx/dialmgr.hxx>
      35                 :            : #include <svx/xtable.hxx>
      36                 :            : #include <svx/xpool.hxx>
      37                 :            : #include <svx/xfillit0.hxx>
      38                 :            : #include <svx/xflgrit.hxx>
      39                 :            : 
      40                 :            : #include <svx/svdorect.hxx>
      41                 :            : #include <svx/svdmodel.hxx>
      42                 :            : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      43                 :            : #include <svx/sdr/contact/displayinfo.hxx>
      44                 :            : #include <vcl/svapp.hxx>
      45                 :            : #include <svx/xlnclit.hxx>
      46                 :            : #include <svx/xgrscit.hxx>
      47                 :            : 
      48                 :            : using namespace com::sun::star;
      49                 :            : 
      50                 :            : class impXGradientList
      51                 :            : {
      52                 :            : private:
      53                 :            :     VirtualDevice*          mpVirtualDevice;
      54                 :            :     SdrModel*               mpSdrModel;
      55                 :            :     SdrObject*              mpBackgroundObject;
      56                 :            : 
      57                 :            : public:
      58                 :          0 :     impXGradientList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB)
      59                 :            :     :   mpVirtualDevice(pV),
      60                 :            :         mpSdrModel(pM),
      61                 :          0 :         mpBackgroundObject(pB)
      62                 :          0 :     {}
      63                 :            : 
      64                 :          0 :     ~impXGradientList()
      65                 :            :     {
      66         [ #  # ]:          0 :         delete mpVirtualDevice;
      67                 :          0 :         SdrObject::Free(mpBackgroundObject);
      68         [ #  # ]:          0 :         delete mpSdrModel;
      69                 :          0 :     }
      70                 :            : 
      71                 :          0 :     VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
      72                 :          0 :     SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
      73                 :            : };
      74                 :            : 
      75                 :          0 : void XGradientList::impCreate()
      76                 :            : {
      77         [ #  # ]:          0 :     if(!mpData)
      78                 :            :     {
      79                 :          0 :         const Point aZero(0, 0);
      80         [ #  # ]:          0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      81                 :            : 
      82 [ #  # ][ #  # ]:          0 :         VirtualDevice* pVirDev = new VirtualDevice;
      83                 :            :         OSL_ENSURE(0 != pVirDev, "XGradientList: no VirtualDevice created!" );
      84 [ #  # ][ #  # ]:          0 :         pVirDev->SetMapMode(MAP_100TH_MM);
                 [ #  # ]
      85         [ #  # ]:          0 :         const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH, BITMAP_HEIGHT)));
      86         [ #  # ]:          0 :         pVirDev->SetOutputSize(aSize);
      87                 :          0 :         pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
      88                 :            :             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
      89 [ #  # ][ #  # ]:          0 :             : DRAWMODE_DEFAULT);
      90                 :            : 
      91 [ #  # ][ #  # ]:          0 :         SdrModel* pSdrModel = new SdrModel();
      92                 :            :         OSL_ENSURE(0 != pSdrModel, "XGradientList: no SdrModel created!" );
      93         [ #  # ]:          0 :         pSdrModel->GetItemPool().FreezeIdRanges();
      94                 :            : 
      95         [ #  # ]:          0 :         const Size aSinglePixel(pVirDev->PixelToLogic(Size(1, 1)));
      96         [ #  # ]:          0 :         const Rectangle aBackgroundSize(aZero, Size(aSize.getWidth() - aSinglePixel.getWidth(), aSize.getHeight() - aSinglePixel.getHeight()));
      97 [ #  # ][ #  # ]:          0 :         SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
      98                 :            :         OSL_ENSURE(0 != pBackgroundObject, "XGradientList: no BackgroundObject created!" );
      99         [ #  # ]:          0 :         pBackgroundObject->SetModel(pSdrModel);
     100 [ #  # ][ #  # ]:          0 :         pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_GRADIENT));
                 [ #  # ]
     101 [ #  # ][ #  # ]:          0 :         pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_SOLID));
                 [ #  # ]
     102 [ #  # ][ #  # ]:          0 :         pBackgroundObject->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK)));
         [ #  # ][ #  # ]
                 [ #  # ]
     103 [ #  # ][ #  # ]:          0 :         pBackgroundObject->SetMergedItem(XGradientStepCountItem(sal_uInt16((BITMAP_WIDTH + BITMAP_HEIGHT) / 3)));
                 [ #  # ]
     104                 :            : 
     105         [ #  # ]:          0 :         mpData = new impXGradientList(pVirDev, pSdrModel, pBackgroundObject);
     106                 :            :         OSL_ENSURE(0 != mpData, "XGradientList: data creation went wrong!" );
     107                 :            :     }
     108                 :          0 : }
     109                 :            : 
     110                 :          0 : void XGradientList::impDestroy()
     111                 :            : {
     112         [ #  # ]:          0 :     if(mpData)
     113                 :            :     {
     114         [ #  # ]:          0 :         delete mpData;
     115                 :          0 :         mpData = 0;
     116                 :            :     }
     117                 :          0 : }
     118                 :            : 
     119                 :       3339 : XGradientList::XGradientList( const String& rPath, XOutdevItemPool* pInPool ) :
     120                 :            :     XPropertyList( XGRADIENT_LIST, rPath, pInPool ),
     121                 :       3339 :     mpData( NULL )
     122                 :            : {
     123 [ +  - ][ +  - ]:       3339 :     pBmpList = new BitmapList_impl();
     124                 :       3339 : }
     125                 :            : 
     126                 :       3234 : XGradientList::~XGradientList()
     127                 :            : {
     128         [ -  + ]:       3234 :     if(mpData)
     129                 :            :     {
     130 [ #  # ][ #  # ]:          0 :         delete mpData;
     131                 :          0 :         mpData = 0;
     132                 :            :     }
     133         [ -  + ]:       6468 : }
     134                 :            : 
     135                 :          0 : XGradientEntry* XGradientList::Replace(XGradientEntry* pEntry, long nIndex )
     136                 :            : {
     137                 :          0 :     return( (XGradientEntry*) XPropertyList::Replace( pEntry, nIndex ) );
     138                 :            : }
     139                 :            : 
     140                 :          0 : XGradientEntry* XGradientList::Remove(long nIndex)
     141                 :            : {
     142                 :          0 :     return( (XGradientEntry*) XPropertyList::Remove( nIndex ) );
     143                 :            : }
     144                 :            : 
     145                 :          0 : XGradientEntry* XGradientList::GetGradient(long nIndex) const
     146                 :            : {
     147                 :          0 :     return( (XGradientEntry*) XPropertyList::Get( nIndex, 0 ) );
     148                 :            : }
     149                 :            : 
     150                 :         11 : uno::Reference< container::XNameContainer > XGradientList::createInstance()
     151                 :            : {
     152                 :            :     return uno::Reference< container::XNameContainer >(
     153                 :            :         SvxUnoXGradientTable_createInstance( this ),
     154         [ +  - ]:         11 :         uno::UNO_QUERY );
     155                 :            : }
     156                 :            : 
     157                 :          0 : sal_Bool XGradientList::Create()
     158                 :            : {
     159 [ #  # ][ #  # ]:          0 :     XubString aStr( SVX_RES( RID_SVXSTR_GRADIENT ) );
     160                 :            :     xub_StrLen nLen;
     161                 :            : 
     162         [ #  # ]:          0 :     aStr.AppendAscii(" 1");
     163                 :          0 :     nLen = aStr.Len() - 1;
     164 [ #  # ][ #  # ]:          0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLACK  ),RGB_Color(COL_WHITE  ),XGRAD_LINEAR    ,    0,10,10, 0,100,100),aStr));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     165         [ #  # ]:          0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     166 [ #  # ][ #  # ]:          0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLUE   ),RGB_Color(COL_RED    ),XGRAD_AXIAL     ,  300,20,20,10,100,100),aStr));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     167         [ #  # ]:          0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     168 [ #  # ][ #  # ]:          0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_RED    ),RGB_Color(COL_YELLOW ),XGRAD_RADIAL    ,  600,30,30,20,100,100),aStr));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     169         [ #  # ]:          0 :     aStr.SetChar(nLen, sal_Unicode('4'));
     170 [ #  # ][ #  # ]:          0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_YELLOW ),RGB_Color(COL_GREEN  ),XGRAD_ELLIPTICAL,  900,40,40,30,100,100),aStr));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     171         [ #  # ]:          0 :     aStr.SetChar(nLen, sal_Unicode('5'));
     172 [ #  # ][ #  # ]:          0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_GREEN  ),RGB_Color(COL_MAGENTA),XGRAD_SQUARE    , 1200,50,50,40,100,100),aStr));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     173         [ #  # ]:          0 :     aStr.SetChar(nLen, sal_Unicode('6'));
     174 [ #  # ][ #  # ]:          0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_MAGENTA),RGB_Color(COL_YELLOW ),XGRAD_RECT      , 1900,60,60,50,100,100),aStr));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     175                 :            : 
     176         [ #  # ]:          0 :     return( sal_True );
     177                 :            : }
     178                 :            : 
     179                 :          0 : sal_Bool XGradientList::CreateBitmapsForUI()
     180                 :            : {
     181                 :          0 :     impCreate();
     182                 :            : 
     183         [ #  # ]:          0 :     for( long i = 0; i < Count(); i++)
     184                 :            :     {
     185         [ #  # ]:          0 :         Bitmap* pBmp = CreateBitmapForUI( i, sal_False );
     186                 :            :         DBG_ASSERT( pBmp, "XGradientList: Bitmap(UI) konnte nicht erzeugt werden!" );
     187                 :            : 
     188         [ #  # ]:          0 :         if( pBmp )
     189                 :            :         {
     190         [ #  # ]:          0 :             if ( (size_t)i < pBmpList->size() ) {
     191 [ #  # ][ #  # ]:          0 :                 pBmpList->insert( pBmpList->begin() + i, pBmp );
     192                 :            :             } else {
     193         [ #  # ]:          0 :                 pBmpList->push_back( pBmp );
     194                 :            :             }
     195                 :            :         }
     196                 :            :     }
     197                 :            : 
     198                 :          0 :     impDestroy();
     199                 :            : 
     200                 :          0 :     return( sal_False );
     201                 :            : }
     202                 :            : 
     203                 :          0 : Bitmap* XGradientList::CreateBitmapForUI( long nIndex, sal_Bool bDelete )
     204                 :            : {
     205         [ #  # ]:          0 :     impCreate();
     206                 :          0 :     VirtualDevice* pVD = mpData->getVirtualDevice();
     207                 :          0 :     SdrObject* pBackgroundObject = mpData->getBackgroundObject();
     208                 :            : 
     209 [ #  # ][ #  # ]:          0 :     pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_GRADIENT));
                 [ #  # ]
     210 [ #  # ][ #  # ]:          0 :     pBackgroundObject->SetMergedItem(XFillGradientItem(GetGradient(nIndex)->GetGradient()));
         [ #  # ][ #  # ]
     211                 :            : 
     212         [ #  # ]:          0 :     sdr::contact::SdrObjectVector aObjectVector;
     213         [ #  # ]:          0 :     aObjectVector.push_back(pBackgroundObject);
     214         [ #  # ]:          0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
     215         [ #  # ]:          0 :     sdr::contact::DisplayInfo aDisplayInfo;
     216                 :            : 
     217         [ #  # ]:          0 :     aPainter.ProcessDisplay(aDisplayInfo);
     218                 :            : 
     219                 :          0 :     const Point aZero(0, 0);
     220 [ #  # ][ #  # ]:          0 :     Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
                 [ #  # ]
     221                 :            : 
     222         [ #  # ]:          0 :     if(bDelete)
     223                 :            :     {
     224         [ #  # ]:          0 :         impDestroy();
     225                 :            :     }
     226                 :            : 
     227 [ #  # ][ #  # ]:          0 :     return pBitmap;
     228                 :            : }
     229                 :            : 
     230                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10