LCOV - code coverage report
Current view: top level - libreoffice/svx/source/xoutdev - xtabhtch.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 95 10.5 %
Date: 2012-12-27 Functions: 4 17 23.5 %
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/svapp.hxx>
      22             : 
      23             : #include <vcl/virdev.hxx>
      24             : #include <svl/itemset.hxx>
      25             : #include <svx/dialogs.hrc>
      26             : #include <svx/dialmgr.hxx>
      27             : #include <svx/xtable.hxx>
      28             : #include <svx/xpool.hxx>
      29             : #include "svx/dlgutil.hxx"
      30             : #include <svx/xflhtit.hxx>
      31             : #include <svx/xflclit.hxx>
      32             : #include <svx/xfillit0.hxx>
      33             : 
      34             : #include <svx/svdorect.hxx>
      35             : #include <svx/svdmodel.hxx>
      36             : #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
      37             : #include <svx/sdr/contact/displayinfo.hxx>
      38             : #include <svx/xlnclit.hxx>
      39             : 
      40             : using namespace ::com::sun::star;
      41             : using namespace ::rtl;
      42             : 
      43             : class impXHatchList
      44             : {
      45             : private:
      46             :     VirtualDevice*          mpVirtualDevice;
      47             :     SdrModel*               mpSdrModel;
      48             :     SdrObject*              mpBackgroundObject;
      49             :     SdrObject*              mpHatchObject;
      50             : 
      51             : public:
      52           0 :     impXHatchList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pH)
      53             :     :   mpVirtualDevice(pV),
      54             :         mpSdrModel(pM),
      55             :         mpBackgroundObject(pB),
      56           0 :         mpHatchObject(pH)
      57           0 :     {}
      58             : 
      59           0 :     ~impXHatchList()
      60             :     {
      61           0 :         delete mpVirtualDevice;
      62           0 :         SdrObject::Free(mpBackgroundObject);
      63           0 :         SdrObject::Free(mpHatchObject);
      64           0 :         delete mpSdrModel;
      65           0 :     }
      66             : 
      67           0 :     VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
      68           0 :     SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
      69           0 :     SdrObject* getHatchObject() const { return mpHatchObject; }
      70             : };
      71             : 
      72           0 : void XHatchList::impCreate()
      73             : {
      74           0 :     if(!mpData)
      75             :     {
      76           0 :         const Point aZero(0, 0);
      77           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      78             : 
      79           0 :         VirtualDevice* pVirDev = new VirtualDevice;
      80             :         OSL_ENSURE(0 != pVirDev, "XDashList: no VirtualDevice created!" );
      81           0 :         pVirDev->SetMapMode(MAP_100TH_MM);
      82           0 :         const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH, BITMAP_HEIGHT)));
      83           0 :         pVirDev->SetOutputSize(aSize);
      84           0 :         pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
      85             :             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
      86           0 :             : DRAWMODE_DEFAULT);
      87             : 
      88           0 :         SdrModel* pSdrModel = new SdrModel();
      89             :         OSL_ENSURE(0 != pSdrModel, "XDashList: no SdrModel created!" );
      90           0 :         pSdrModel->GetItemPool().FreezeIdRanges();
      91             : 
      92           0 :         const Size aSinglePixel(pVirDev->PixelToLogic(Size(1, 1)));
      93           0 :         const Rectangle aBackgroundSize(aZero, Size(aSize.getWidth() - aSinglePixel.getWidth(), aSize.getHeight() - aSinglePixel.getHeight()));
      94           0 :         SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
      95             :         OSL_ENSURE(0 != pBackgroundObject, "XDashList: no BackgroundObject created!" );
      96           0 :         pBackgroundObject->SetModel(pSdrModel);
      97           0 :         pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID));
      98           0 :         pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor()));
      99           0 :         pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_SOLID));
     100           0 :         pBackgroundObject->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK)));
     101             : 
     102           0 :         SdrObject* pHatchObject = new SdrRectObj(aBackgroundSize);
     103             :         OSL_ENSURE(0 != pHatchObject, "XDashList: no HatchObject created!" );
     104           0 :         pHatchObject->SetModel(pSdrModel);
     105           0 :         pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH));
     106           0 :         pHatchObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
     107             : 
     108           0 :         mpData = new impXHatchList(pVirDev, pSdrModel, pBackgroundObject, pHatchObject);
     109             :         OSL_ENSURE(0 != mpData, "XDashList: data creation went wrong!" );
     110             :     }
     111           0 : }
     112             : 
     113           0 : void XHatchList::impDestroy()
     114             : {
     115           0 :     delete mpData;
     116           0 :     mpData = NULL;
     117           0 : }
     118             : 
     119         363 : XHatchList::XHatchList( const String& rPath,
     120             :                         XOutdevItemPool* pInPool )
     121             :   : XPropertyList( XHATCH_LIST, rPath, pInPool ),
     122         363 :     mpData( NULL )
     123             : {
     124         363 :     pBmpList = new BitmapList_impl();
     125         363 : }
     126             : 
     127         546 : XHatchList::~XHatchList()
     128             : {
     129         182 :     delete mpData;
     130         182 :     mpData = NULL;
     131         364 : }
     132             : 
     133           0 : XHatchEntry* XHatchList::Replace(XHatchEntry* pEntry, long nIndex )
     134             : {
     135           0 :     return (XHatchEntry*) XPropertyList::Replace(pEntry, nIndex);
     136             : }
     137             : 
     138           0 : XHatchEntry* XHatchList::Remove(long nIndex)
     139             : {
     140           0 :     return (XHatchEntry*) XPropertyList::Remove(nIndex);
     141             : }
     142             : 
     143           0 : XHatchEntry* XHatchList::GetHatch(long nIndex) const
     144             : {
     145           0 :     return (XHatchEntry*) XPropertyList::Get(nIndex, 0);
     146             : }
     147             : 
     148           2 : uno::Reference< container::XNameContainer > XHatchList::createInstance()
     149             : {
     150             :     return uno::Reference< container::XNameContainer >(
     151           2 :         SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY );
     152             : }
     153             : 
     154           0 : sal_Bool XHatchList::Create()
     155             : {
     156           0 :     XubString aStr( SVX_RES( RID_SVXSTR_HATCH ) );
     157             :     xub_StrLen nLen;
     158             : 
     159           0 :     aStr.AppendAscii(" 1");
     160           0 :     nLen = aStr.Len() - 1;
     161           0 :     Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLACK),XHATCH_SINGLE,100,  0),aStr));
     162           0 :     aStr.SetChar(nLen, sal_Unicode('2'));
     163           0 :     Insert(new XHatchEntry(XHatch(RGB_Color(COL_RED  ),XHATCH_DOUBLE, 80,450),aStr));
     164           0 :     aStr.SetChar(nLen, sal_Unicode('3'));
     165           0 :     Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLUE ),XHATCH_TRIPLE,120,  0),aStr));
     166             : 
     167           0 :     return( sal_True );
     168             : }
     169             : 
     170           0 : sal_Bool XHatchList::CreateBitmapsForUI()
     171             : {
     172           0 :     impCreate();
     173             : 
     174           0 :     for( long i = 0; i < Count(); i++)
     175             :     {
     176           0 :         Bitmap* pBmp = CreateBitmapForUI( i, sal_False );
     177             :         DBG_ASSERT( pBmp, "XHatchList: Bitmap(UI) konnte nicht erzeugt werden!" );
     178             : 
     179           0 :         if( pBmp )
     180             :         {
     181           0 :             if ( (size_t)i < pBmpList->size() ) {
     182           0 :                 pBmpList->insert( pBmpList->begin() + i, pBmp );
     183             :             } else {
     184           0 :                 pBmpList->push_back( pBmp );
     185             :             }
     186             :         }
     187             :     }
     188             : 
     189           0 :     impDestroy();
     190             : 
     191           0 :     return( sal_True );
     192             : }
     193             : 
     194           0 : Bitmap* XHatchList::CreateBitmapForUI( long nIndex, sal_Bool bDelete )
     195             : {
     196           0 :     impCreate();
     197           0 :     VirtualDevice* pVD = mpData->getVirtualDevice();
     198           0 :     SdrObject* pHatchObject = mpData->getHatchObject();
     199             : 
     200           0 :     pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH));
     201           0 :     pHatchObject->SetMergedItem(XFillHatchItem(String(), GetHatch(nIndex)->GetHatch()));
     202             : 
     203           0 :     sdr::contact::SdrObjectVector aObjectVector;
     204           0 :     aObjectVector.push_back(mpData->getBackgroundObject());
     205           0 :     aObjectVector.push_back(pHatchObject);
     206           0 :     sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
     207           0 :     sdr::contact::DisplayInfo aDisplayInfo;
     208             : 
     209           0 :     aPainter.ProcessDisplay(aDisplayInfo);
     210             : 
     211           0 :     const Point aZero(0, 0);
     212           0 :     Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
     213             : 
     214           0 :     if(bDelete)
     215           0 :         impDestroy();
     216             : 
     217           0 :     return pBitmap;
     218             : }
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10