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

Generated by: LCOV version 1.10