LCOV - code coverage report
Current view: top level - libreoffice/svx/source/xoutdev - xtablend.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 104 12.5 %
Date: 2012-12-27 Functions: 5 16 31.2 %
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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "svx/XPropertyTable.hxx"
      21             : #include <vcl/virdev.hxx>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : #include <svl/itemset.hxx>
      25             : 
      26             : #include <svx/dialogs.hrc>
      27             : #include <svx/dialmgr.hxx>
      28             : 
      29             : #include <svx/xtable.hxx>
      30             : #include <svx/xpool.hxx>
      31             : #include <svx/xfillit0.hxx>
      32             : #include <svx/xflclit.hxx>
      33             : #include <svx/xlnstwit.hxx>
      34             : #include <svx/xlnedwit.hxx>
      35             : #include <svx/xlnclit.hxx>
      36             : #include <svx/xlineit0.hxx>
      37             : #include <svx/xlnstit.hxx>
      38             : #include <svx/xlnedit.hxx>
      39             : #include <basegfx/point/b2dpoint.hxx>
      40             : #include <basegfx/polygon/b2dpolygon.hxx>
      41             : #include <basegfx/polygon/b2dpolygontools.hxx>
      42             : 
      43             : #include <svx/svdorect.hxx>
      44             : #include <svx/svdopath.hxx>
      45             : #include <svx/svdmodel.hxx>
      46             : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      47             : #include <svx/sdr/contact/displayinfo.hxx>
      48             : 
      49             : using namespace com::sun::star;
      50             : 
      51             : class impXLineEndList
      52             : {
      53             : private:
      54             :     VirtualDevice*          mpVirtualDevice;
      55             :     SdrModel*               mpSdrModel;
      56             :     SdrObject*              mpBackgroundObject;
      57             :     SdrObject*              mpLineObject;
      58             : 
      59             : public:
      60           0 :     impXLineEndList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pL)
      61             :     :   mpVirtualDevice(pV),
      62             :         mpSdrModel(pM),
      63             :         mpBackgroundObject(pB),
      64           0 :         mpLineObject(pL)
      65           0 :     {}
      66             : 
      67           0 :     ~impXLineEndList()
      68             :     {
      69           0 :         delete mpVirtualDevice;
      70           0 :         SdrObject::Free(mpBackgroundObject);
      71           0 :         SdrObject::Free(mpLineObject);
      72           0 :         delete mpSdrModel;
      73           0 :     }
      74             : 
      75           0 :     VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
      76           0 :     SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
      77           0 :     SdrObject* getLineObject() const { return mpLineObject; }
      78             : };
      79             : 
      80           0 : void XLineEndList::impCreate()
      81             : {
      82           0 :     if(!mpData)
      83             :     {
      84           0 :         const Point aZero(0, 0);
      85           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      86             : 
      87           0 :         VirtualDevice* pVirDev = new VirtualDevice;
      88             :         OSL_ENSURE(0 != pVirDev, "XLineEndList: no VirtualDevice created!" );
      89           0 :         const Size aSize(BITMAP_WIDTH * 2, BITMAP_HEIGHT);
      90           0 :         pVirDev->SetOutputSize(aSize);
      91           0 :         pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
      92             :             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
      93           0 :             : DRAWMODE_DEFAULT);
      94             : 
      95           0 :         SdrModel* pSdrModel = new SdrModel();
      96             :         OSL_ENSURE(0 != pSdrModel, "XLineEndList: no SdrModel created!" );
      97           0 :         pSdrModel->GetItemPool().FreezeIdRanges();
      98             : 
      99           0 :         const Rectangle aBackgroundSize(aZero, aSize);
     100           0 :         SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
     101             :         OSL_ENSURE(0 != pBackgroundObject, "XLineEndList: no BackgroundObject created!" );
     102           0 :         pBackgroundObject->SetModel(pSdrModel);
     103           0 :         pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID));
     104           0 :         pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
     105           0 :         pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor()));
     106             : 
     107           0 :         const basegfx::B2DPoint aStart(0, aSize.Height() / 2);
     108           0 :         const basegfx::B2DPoint aEnd(aSize.Width() - 1, aSize.Height() / 2);
     109           0 :         basegfx::B2DPolygon aPolygon;
     110           0 :         aPolygon.append(aStart);
     111           0 :         aPolygon.append(aEnd);
     112           0 :         SdrObject* pLineObject = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygon));
     113             :         OSL_ENSURE(0 != pLineObject, "XLineEndList: no LineObject created!" );
     114           0 :         pLineObject->SetModel(pSdrModel);
     115           0 :         pLineObject->SetMergedItem(XLineStartWidthItem(aSize.Height() - 2)); // fdo#48536: prevent the lineend from
     116           0 :         pLineObject->SetMergedItem(XLineEndWidthItem(aSize.Height() - 2));   // exceeding the background area
     117           0 :         pLineObject->SetMergedItem(XLineColorItem(String(), rStyleSettings.GetFieldTextColor()));
     118             : 
     119           0 :         mpData = new impXLineEndList(pVirDev, pSdrModel, pBackgroundObject, pLineObject);
     120           0 :         OSL_ENSURE(0 != mpData, "XLineEndList: data creation went wrong!" );
     121             :     }
     122           0 : }
     123             : 
     124         182 : void XLineEndList::impDestroy()
     125             : {
     126         182 :     delete mpData;
     127         182 :     mpData = NULL;
     128         182 : }
     129             : 
     130         363 : XLineEndList::XLineEndList( const String& rPath, XOutdevItemPool* _pXPool )
     131             :     : XPropertyList( XLINE_END_LIST, rPath, _pXPool ),
     132         363 :       mpData(NULL)
     133             : {
     134         363 :     pBmpList = new BitmapList_impl();
     135         363 : }
     136             : 
     137         546 : XLineEndList::~XLineEndList()
     138             : {
     139         182 :     impDestroy();
     140         364 : }
     141             : 
     142           0 : XLineEndEntry* XLineEndList::Remove(long nIndex)
     143             : {
     144           0 :     return (XLineEndEntry*) XPropertyList::Remove(nIndex);
     145             : }
     146             : 
     147           0 : XLineEndEntry* XLineEndList::GetLineEnd(long nIndex) const
     148             : {
     149           0 :     return (XLineEndEntry*) XPropertyList::Get(nIndex, 0);
     150             : }
     151             : 
     152           2 : uno::Reference< container::XNameContainer > XLineEndList::createInstance()
     153             : {
     154             :     return uno::Reference< container::XNameContainer >(
     155           2 :         SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY );
     156             : }
     157             : 
     158           0 : sal_Bool XLineEndList::Create()
     159             : {
     160           0 :     basegfx::B2DPolygon aTriangle;
     161           0 :     aTriangle.append(basegfx::B2DPoint(10.0, 0.0));
     162           0 :     aTriangle.append(basegfx::B2DPoint(0.0, 30.0));
     163           0 :     aTriangle.append(basegfx::B2DPoint(20.0, 30.0));
     164           0 :     aTriangle.setClosed(true);
     165           0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aTriangle), SVX_RESSTR( RID_SVXSTR_ARROW ) ) );
     166             : 
     167           0 :     basegfx::B2DPolygon aSquare;
     168           0 :     aSquare.append(basegfx::B2DPoint(0.0, 0.0));
     169           0 :     aSquare.append(basegfx::B2DPoint(10.0, 0.0));
     170           0 :     aSquare.append(basegfx::B2DPoint(10.0, 10.0));
     171           0 :     aSquare.append(basegfx::B2DPoint(0.0, 10.0));
     172           0 :     aSquare.setClosed(true);
     173           0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aSquare), SVX_RESSTR( RID_SVXSTR_SQUARE ) ) );
     174             : 
     175           0 :     basegfx::B2DPolygon aCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), 100.0));
     176           0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aCircle), SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) );
     177             : 
     178           0 :     return sal_True;
     179             : }
     180             : 
     181           0 : sal_Bool XLineEndList::CreateBitmapsForUI()
     182             : {
     183           0 :     impCreate();
     184             : 
     185           0 :     for( long i = 0; i < Count(); i++)
     186             :     {
     187           0 :         Bitmap* pBmp = CreateBitmapForUI( i, sal_False );
     188             :         OSL_ENSURE(0 != pBmp, "XLineEndList: Bitmap(UI) could not be created!" );
     189             : 
     190           0 :         if( pBmp )
     191             :         {
     192           0 :             if ( (size_t)i < pBmpList->size() ) {
     193           0 :                 pBmpList->insert( pBmpList->begin() + i, pBmp );
     194             :             } else {
     195           0 :                 pBmpList->push_back( pBmp );
     196             :             }
     197             :         }
     198             :     }
     199             : 
     200           0 :     impDestroy();
     201             : 
     202           0 :     return sal_True;
     203             : }
     204             : 
     205           0 : Bitmap* XLineEndList::CreateBitmapForUI( long nIndex, sal_Bool bDelete )
     206             : {
     207           0 :     impCreate();
     208           0 :     VirtualDevice* pVD = mpData->getVirtualDevice();
     209           0 :     SdrObject* pLine = mpData->getLineObject();
     210             : 
     211           0 :     pLine->SetMergedItem(XLineStyleItem(XLINE_SOLID));
     212           0 :     pLine->SetMergedItem(XLineStartItem(String(), GetLineEnd(nIndex)->GetLineEnd()));
     213           0 :     pLine->SetMergedItem(XLineEndItem(String(), GetLineEnd(nIndex)->GetLineEnd()));
     214             : 
     215           0 :     sdr::contact::SdrObjectVector aObjectVector;
     216           0 :     aObjectVector.push_back(mpData->getBackgroundObject());
     217           0 :     aObjectVector.push_back(pLine);
     218           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
     219           0 :     sdr::contact::DisplayInfo aDisplayInfo;
     220             : 
     221           0 :     aPainter.ProcessDisplay(aDisplayInfo);
     222             : 
     223           0 :     const Point aZero(0, 0);
     224           0 :     Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
     225             : 
     226           0 :     if(bDelete)
     227           0 :         impDestroy();
     228             : 
     229           0 :     return pBitmap;
     230             : }
     231             : 
     232             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10