LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtabdash.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 85 99 85.9 %
Date: 2012-08-25 Functions: 14 17 82.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 100 212 47.2 %

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

Generated by: LCOV version 1.10