LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtablend.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 104 12.5 %
Date: 2012-08-25 Functions: 5 16 31.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 264 2.3 %

           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                 :            : #include <vcl/virdev.hxx>
      31                 :            : 
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <svl/itemset.hxx>
      34                 :            : 
      35                 :            : #include <svx/dialogs.hrc>
      36                 :            : #include <svx/dialmgr.hxx>
      37                 :            : 
      38                 :            : #include <svx/xtable.hxx>
      39                 :            : #include <svx/xpool.hxx>
      40                 :            : #include <svx/xfillit0.hxx>
      41                 :            : #include <svx/xflclit.hxx>
      42                 :            : #include <svx/xlnstwit.hxx>
      43                 :            : #include <svx/xlnedwit.hxx>
      44                 :            : #include <svx/xlnclit.hxx>
      45                 :            : #include <svx/xlineit0.hxx>
      46                 :            : #include <svx/xlnstit.hxx>
      47                 :            : #include <svx/xlnedit.hxx>
      48                 :            : #include <basegfx/point/b2dpoint.hxx>
      49                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      50                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      51                 :            : 
      52                 :            : #include <svx/svdorect.hxx>
      53                 :            : #include <svx/svdopath.hxx>
      54                 :            : #include <svx/svdmodel.hxx>
      55                 :            : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      56                 :            : #include <svx/sdr/contact/displayinfo.hxx>
      57                 :            : 
      58                 :            : using namespace com::sun::star;
      59                 :            : 
      60                 :            : class impXLineEndList
      61                 :            : {
      62                 :            : private:
      63                 :            :     VirtualDevice*          mpVirtualDevice;
      64                 :            :     SdrModel*               mpSdrModel;
      65                 :            :     SdrObject*              mpBackgroundObject;
      66                 :            :     SdrObject*              mpLineObject;
      67                 :            : 
      68                 :            : public:
      69                 :          0 :     impXLineEndList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pL)
      70                 :            :     :   mpVirtualDevice(pV),
      71                 :            :         mpSdrModel(pM),
      72                 :            :         mpBackgroundObject(pB),
      73                 :          0 :         mpLineObject(pL)
      74                 :          0 :     {}
      75                 :            : 
      76                 :          0 :     ~impXLineEndList()
      77                 :            :     {
      78         [ #  # ]:          0 :         delete mpVirtualDevice;
      79                 :          0 :         SdrObject::Free(mpBackgroundObject);
      80                 :          0 :         SdrObject::Free(mpLineObject);
      81         [ #  # ]:          0 :         delete mpSdrModel;
      82                 :          0 :     }
      83                 :            : 
      84                 :          0 :     VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
      85                 :          0 :     SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
      86                 :          0 :     SdrObject* getLineObject() const { return mpLineObject; }
      87                 :            : };
      88                 :            : 
      89                 :          0 : void XLineEndList::impCreate()
      90                 :            : {
      91         [ #  # ]:          0 :     if(!mpData)
      92                 :            :     {
      93                 :          0 :         const Point aZero(0, 0);
      94         [ #  # ]:          0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      95                 :            : 
      96 [ #  # ][ #  # ]:          0 :         VirtualDevice* pVirDev = new VirtualDevice;
      97                 :            :         OSL_ENSURE(0 != pVirDev, "XLineEndList: no VirtualDevice created!" );
      98                 :          0 :         const Size aSize(BITMAP_WIDTH * 2, BITMAP_HEIGHT);
      99         [ #  # ]:          0 :         pVirDev->SetOutputSize(aSize);
     100                 :          0 :         pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
     101                 :            :             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
     102 [ #  # ][ #  # ]:          0 :             : DRAWMODE_DEFAULT);
     103                 :            : 
     104 [ #  # ][ #  # ]:          0 :         SdrModel* pSdrModel = new SdrModel();
     105                 :            :         OSL_ENSURE(0 != pSdrModel, "XLineEndList: no SdrModel created!" );
     106         [ #  # ]:          0 :         pSdrModel->GetItemPool().FreezeIdRanges();
     107                 :            : 
     108         [ #  # ]:          0 :         const Rectangle aBackgroundSize(aZero, aSize);
     109 [ #  # ][ #  # ]:          0 :         SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
     110                 :            :         OSL_ENSURE(0 != pBackgroundObject, "XLineEndList: no BackgroundObject created!" );
     111         [ #  # ]:          0 :         pBackgroundObject->SetModel(pSdrModel);
     112 [ #  # ][ #  # ]:          0 :         pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID));
                 [ #  # ]
     113 [ #  # ][ #  # ]:          0 :         pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
                 [ #  # ]
     114 [ #  # ][ #  # ]:          0 :         pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor()));
         [ #  # ][ #  # ]
                 [ #  # ]
     115                 :            : 
     116                 :          0 :         const basegfx::B2DPoint aStart(0, aSize.Height() / 2);
     117                 :          0 :         const basegfx::B2DPoint aEnd(aSize.Width() - 1, aSize.Height() / 2);
     118         [ #  # ]:          0 :         basegfx::B2DPolygon aPolygon;
     119         [ #  # ]:          0 :         aPolygon.append(aStart);
     120         [ #  # ]:          0 :         aPolygon.append(aEnd);
     121 [ #  # ][ #  # ]:          0 :         SdrObject* pLineObject = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygon));
         [ #  # ][ #  # ]
     122                 :            :         OSL_ENSURE(0 != pLineObject, "XLineEndList: no LineObject created!" );
     123         [ #  # ]:          0 :         pLineObject->SetModel(pSdrModel);
     124 [ #  # ][ #  # ]:          0 :         pLineObject->SetMergedItem(XLineStartWidthItem(aSize.Height() - 2)); // fdo#48536: prevent the lineend from
                 [ #  # ]
     125 [ #  # ][ #  # ]:          0 :         pLineObject->SetMergedItem(XLineEndWidthItem(aSize.Height() - 2));   // exceeding the background area
                 [ #  # ]
     126 [ #  # ][ #  # ]:          0 :         pLineObject->SetMergedItem(XLineColorItem(String(), rStyleSettings.GetFieldTextColor()));
         [ #  # ][ #  # ]
                 [ #  # ]
     127                 :            : 
     128         [ #  # ]:          0 :         mpData = new impXLineEndList(pVirDev, pSdrModel, pBackgroundObject, pLineObject);
     129         [ #  # ]:          0 :         OSL_ENSURE(0 != mpData, "XLineEndList: data creation went wrong!" );
     130                 :            :     }
     131                 :          0 : }
     132                 :            : 
     133                 :       3234 : void XLineEndList::impDestroy()
     134                 :            : {
     135         [ -  + ]:       3234 :     delete mpData;
     136                 :       3234 :     mpData = NULL;
     137                 :       3234 : }
     138                 :            : 
     139                 :       3339 : XLineEndList::XLineEndList( const String& rPath, XOutdevItemPool* _pXPool )
     140                 :            :     : XPropertyList( XLINE_END_LIST, rPath, _pXPool ),
     141                 :       3339 :       mpData(NULL)
     142                 :            : {
     143 [ +  - ][ +  - ]:       3339 :     pBmpList = new BitmapList_impl();
     144                 :       3339 : }
     145                 :            : 
     146                 :       3234 : XLineEndList::~XLineEndList()
     147                 :            : {
     148         [ +  - ]:       3234 :     impDestroy();
     149         [ -  + ]:       6468 : }
     150                 :            : 
     151                 :          0 : XLineEndEntry* XLineEndList::Remove(long nIndex)
     152                 :            : {
     153                 :          0 :     return (XLineEndEntry*) XPropertyList::Remove(nIndex);
     154                 :            : }
     155                 :            : 
     156                 :          0 : XLineEndEntry* XLineEndList::GetLineEnd(long nIndex) const
     157                 :            : {
     158                 :          0 :     return (XLineEndEntry*) XPropertyList::Get(nIndex, 0);
     159                 :            : }
     160                 :            : 
     161                 :         11 : uno::Reference< container::XNameContainer > XLineEndList::createInstance()
     162                 :            : {
     163                 :            :     return uno::Reference< container::XNameContainer >(
     164         [ +  - ]:         11 :         SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY );
     165                 :            : }
     166                 :            : 
     167                 :          0 : sal_Bool XLineEndList::Create()
     168                 :            : {
     169         [ #  # ]:          0 :     basegfx::B2DPolygon aTriangle;
     170         [ #  # ]:          0 :     aTriangle.append(basegfx::B2DPoint(10.0, 0.0));
     171         [ #  # ]:          0 :     aTriangle.append(basegfx::B2DPoint(0.0, 30.0));
     172         [ #  # ]:          0 :     aTriangle.append(basegfx::B2DPoint(20.0, 30.0));
     173         [ #  # ]:          0 :     aTriangle.setClosed(true);
     174 [ #  # ][ #  # ]:          0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aTriangle), SVX_RESSTR( RID_SVXSTR_ARROW ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     175                 :            : 
     176         [ #  # ]:          0 :     basegfx::B2DPolygon aSquare;
     177         [ #  # ]:          0 :     aSquare.append(basegfx::B2DPoint(0.0, 0.0));
     178         [ #  # ]:          0 :     aSquare.append(basegfx::B2DPoint(10.0, 0.0));
     179         [ #  # ]:          0 :     aSquare.append(basegfx::B2DPoint(10.0, 10.0));
     180         [ #  # ]:          0 :     aSquare.append(basegfx::B2DPoint(0.0, 10.0));
     181         [ #  # ]:          0 :     aSquare.setClosed(true);
     182 [ #  # ][ #  # ]:          0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aSquare), SVX_RESSTR( RID_SVXSTR_SQUARE ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     183                 :            : 
     184         [ #  # ]:          0 :     basegfx::B2DPolygon aCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), 100.0));
     185 [ #  # ][ #  # ]:          0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aCircle), SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     186                 :            : 
     187 [ #  # ][ #  # ]:          0 :     return sal_True;
                 [ #  # ]
     188                 :            : }
     189                 :            : 
     190                 :          0 : sal_Bool XLineEndList::CreateBitmapsForUI()
     191                 :            : {
     192                 :          0 :     impCreate();
     193                 :            : 
     194         [ #  # ]:          0 :     for( long i = 0; i < Count(); i++)
     195                 :            :     {
     196         [ #  # ]:          0 :         Bitmap* pBmp = CreateBitmapForUI( i, sal_False );
     197                 :            :         OSL_ENSURE(0 != pBmp, "XLineEndList: Bitmap(UI) could not be created!" );
     198                 :            : 
     199         [ #  # ]:          0 :         if( pBmp )
     200                 :            :         {
     201         [ #  # ]:          0 :             if ( (size_t)i < pBmpList->size() ) {
     202 [ #  # ][ #  # ]:          0 :                 pBmpList->insert( pBmpList->begin() + i, pBmp );
     203                 :            :             } else {
     204         [ #  # ]:          0 :                 pBmpList->push_back( pBmp );
     205                 :            :             }
     206                 :            :         }
     207                 :            :     }
     208                 :            : 
     209                 :          0 :     impDestroy();
     210                 :            : 
     211                 :          0 :     return sal_True;
     212                 :            : }
     213                 :            : 
     214                 :          0 : Bitmap* XLineEndList::CreateBitmapForUI( long nIndex, sal_Bool bDelete )
     215                 :            : {
     216         [ #  # ]:          0 :     impCreate();
     217                 :          0 :     VirtualDevice* pVD = mpData->getVirtualDevice();
     218                 :          0 :     SdrObject* pLine = mpData->getLineObject();
     219                 :            : 
     220 [ #  # ][ #  # ]:          0 :     pLine->SetMergedItem(XLineStyleItem(XLINE_SOLID));
                 [ #  # ]
     221 [ #  # ][ #  # ]:          0 :     pLine->SetMergedItem(XLineStartItem(String(), GetLineEnd(nIndex)->GetLineEnd()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     222 [ #  # ][ #  # ]:          0 :     pLine->SetMergedItem(XLineEndItem(String(), GetLineEnd(nIndex)->GetLineEnd()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     223                 :            : 
     224         [ #  # ]:          0 :     sdr::contact::SdrObjectVector aObjectVector;
     225         [ #  # ]:          0 :     aObjectVector.push_back(mpData->getBackgroundObject());
     226         [ #  # ]:          0 :     aObjectVector.push_back(pLine);
     227         [ #  # ]:          0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
     228         [ #  # ]:          0 :     sdr::contact::DisplayInfo aDisplayInfo;
     229                 :            : 
     230         [ #  # ]:          0 :     aPainter.ProcessDisplay(aDisplayInfo);
     231                 :            : 
     232                 :          0 :     const Point aZero(0, 0);
     233 [ #  # ][ #  # ]:          0 :     Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
                 [ #  # ]
     234                 :            : 
     235         [ #  # ]:          0 :     if(bDelete)
     236         [ #  # ]:          0 :         impDestroy();
     237                 :            : 
     238 [ #  # ][ #  # ]:          0 :     return pBitmap;
     239                 :            : }
     240                 :            : 
     241                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10