LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtabgrdt.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 83 0.0 %
Date: 2014-04-14 Functions: 0 9 0.0 %
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/virdev.hxx>
      23             : #include <svx/dialogs.hrc>
      24             : #include <svx/dialmgr.hxx>
      25             : #include <svx/xtable.hxx>
      26             : 
      27             : #include <vcl/svapp.hxx>
      28             : #include <vcl/settings.hxx>
      29             : 
      30             : #include <drawinglayer/attribute/fillgradientattribute.hxx>
      31             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      32             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      33             : #include <drawinglayer/processor2d/processor2dtools.hxx>
      34             : #include <basegfx/polygon/b2dpolygontools.hxx>
      35             : 
      36             : using namespace com::sun::star;
      37             : 
      38           0 : XGradientList::XGradientList( const OUString& rPath, const OUString& rReferer )
      39           0 : :   XPropertyList( XGRADIENT_LIST, rPath, rReferer )
      40             : {
      41           0 : }
      42             : 
      43           0 : XGradientList::~XGradientList()
      44             : {
      45           0 : }
      46             : 
      47           0 : XGradientEntry* XGradientList::Replace(XGradientEntry* pEntry, long nIndex )
      48             : {
      49           0 :     return( (XGradientEntry*) XPropertyList::Replace( pEntry, nIndex ) );
      50             : }
      51             : 
      52           0 : XGradientEntry* XGradientList::Remove(long nIndex)
      53             : {
      54           0 :     return( (XGradientEntry*) XPropertyList::Remove( nIndex ) );
      55             : }
      56             : 
      57           0 : XGradientEntry* XGradientList::GetGradient(long nIndex) const
      58             : {
      59           0 :     return( (XGradientEntry*) XPropertyList::Get( nIndex ) );
      60             : }
      61             : 
      62           0 : uno::Reference< container::XNameContainer > XGradientList::createInstance()
      63             : {
      64             :     return uno::Reference< container::XNameContainer >(
      65             :         SvxUnoXGradientTable_createInstance( this ),
      66           0 :         uno::UNO_QUERY );
      67             : }
      68             : 
      69           0 : bool XGradientList::Create()
      70             : {
      71           0 :     rtl::OUStringBuffer aStr(SVX_RESSTR(RID_SVXSTR_GRADIENT));
      72           0 :     aStr.append(" 1");
      73           0 :     sal_Int32 nLen = aStr.getLength() - 1;
      74           0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLACK  ),RGB_Color(COL_WHITE  ),XGRAD_LINEAR    ,    0,10,10, 0,100,100),aStr.toString()));
      75           0 :     aStr[nLen] = '2';
      76           0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLUE   ),RGB_Color(COL_RED    ),XGRAD_AXIAL     ,  300,20,20,10,100,100),aStr.toString()));
      77           0 :     aStr[nLen] = '3';
      78           0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_RED    ),RGB_Color(COL_YELLOW ),XGRAD_RADIAL    ,  600,30,30,20,100,100),aStr.toString()));
      79           0 :     aStr[nLen] = '4';
      80           0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_YELLOW ),RGB_Color(COL_GREEN  ),XGRAD_ELLIPTICAL,  900,40,40,30,100,100),aStr.toString()));
      81           0 :     aStr[nLen] = '5';
      82           0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_GREEN  ),RGB_Color(COL_MAGENTA),XGRAD_SQUARE    , 1200,50,50,40,100,100),aStr.toString()));
      83           0 :     aStr[nLen] = '6';
      84           0 :     Insert(new XGradientEntry(XGradient(RGB_Color(COL_MAGENTA),RGB_Color(COL_YELLOW ),XGRAD_RECT      , 1900,60,60,50,100,100),aStr.toString()));
      85             : 
      86           0 :     return true;
      87             : }
      88             : 
      89           0 : Bitmap XGradientList::CreateBitmapForUI( long nIndex )
      90             : {
      91           0 :     Bitmap aRetval;
      92             : 
      93             :     OSL_ENSURE(nIndex < Count(), "OOps, access out of range (!)");
      94             : 
      95           0 :     if(nIndex < Count())
      96             :     {
      97           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      98           0 :         const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
      99             : 
     100             :         // prepare polygon geometry for rectangle
     101             :         const basegfx::B2DPolygon aRectangle(
     102             :             basegfx::tools::createPolygonFromRect(
     103           0 :                 basegfx::B2DRange(0.0, 0.0, rSize.Width(), rSize.Height())));
     104             : 
     105           0 :         const XGradient& rGradient = GetGradient(nIndex)->GetGradient();
     106           0 :         const sal_uInt16 nStartIntens(rGradient.GetStartIntens());
     107           0 :         basegfx::BColor aStart(rGradient.GetStartColor().getBColor());
     108             : 
     109           0 :         if(nStartIntens != 100)
     110             :         {
     111           0 :             const basegfx::BColor aBlack;
     112           0 :             aStart = interpolate(aBlack, aStart, (double)nStartIntens * 0.01);
     113             :         }
     114             : 
     115           0 :         const sal_uInt16 nEndIntens(rGradient.GetEndIntens());
     116           0 :         basegfx::BColor aEnd(rGradient.GetEndColor().getBColor());
     117             : 
     118           0 :         if(nEndIntens != 100)
     119             :         {
     120           0 :             const basegfx::BColor aBlack;
     121           0 :             aEnd = interpolate(aBlack, aEnd, (double)nEndIntens * 0.01);
     122             :         }
     123             : 
     124           0 :         drawinglayer::attribute::GradientStyle aGradientStyle(drawinglayer::attribute::GRADIENTSTYLE_RECT);
     125             : 
     126           0 :         switch(rGradient.GetGradientStyle())
     127             :         {
     128             :             case XGRAD_LINEAR :
     129             :             {
     130           0 :                 aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_LINEAR;
     131           0 :                 break;
     132             :             }
     133             :             case XGRAD_AXIAL :
     134             :             {
     135           0 :                 aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_AXIAL;
     136           0 :                 break;
     137             :             }
     138             :             case XGRAD_RADIAL :
     139             :             {
     140           0 :                 aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_RADIAL;
     141           0 :                 break;
     142             :             }
     143             :             case XGRAD_ELLIPTICAL :
     144             :             {
     145           0 :                 aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_ELLIPTICAL;
     146           0 :                 break;
     147             :             }
     148             :             case XGRAD_SQUARE :
     149             :             {
     150           0 :                 aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_SQUARE;
     151           0 :                 break;
     152             :             }
     153             :             default :
     154             :             {
     155           0 :                 aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_RECT; // XGRAD_RECT
     156           0 :                 break;
     157             :             }
     158             :         }
     159             : 
     160           0 :         const sal_uInt16 nSteps((rSize.Width() + rSize.Height()) / 3);
     161             :         const drawinglayer::attribute::FillGradientAttribute aFillGradient(
     162             :             aGradientStyle,
     163           0 :             (double)rGradient.GetBorder() * 0.01,
     164           0 :             (double)rGradient.GetXOffset() * 0.01,
     165           0 :             (double)rGradient.GetYOffset() * 0.01,
     166           0 :             (double)rGradient.GetAngle() * F_PI1800,
     167             :             aStart,
     168             :             aEnd,
     169           0 :             nSteps);
     170             : 
     171             :         const drawinglayer::primitive2d::Primitive2DReference aGradientPrimitive(
     172             :             new drawinglayer::primitive2d::PolyPolygonGradientPrimitive2D(
     173             :                 basegfx::B2DPolyPolygon(aRectangle),
     174           0 :                 aFillGradient));
     175             : 
     176           0 :         const basegfx::BColor aBlack(0.0, 0.0, 0.0);
     177             :         const drawinglayer::primitive2d::Primitive2DReference aBlackRectanglePrimitive(
     178             :             new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
     179             :                 aRectangle,
     180           0 :                 aBlack));
     181             : 
     182             :         // prepare VirtualDevice
     183           0 :         VirtualDevice aVirtualDevice;
     184           0 :         const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
     185             : 
     186           0 :         aVirtualDevice.SetOutputSizePixel(rSize);
     187           0 :         aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
     188             :             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
     189           0 :             : DRAWMODE_DEFAULT);
     190             : 
     191             :         // create processor and draw primitives
     192             :         drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
     193             :             aVirtualDevice,
     194           0 :             aNewViewInformation2D);
     195             : 
     196           0 :         if(pProcessor2D)
     197             :         {
     198           0 :             drawinglayer::primitive2d::Primitive2DSequence aSequence(2);
     199             : 
     200           0 :             aSequence[0] = aGradientPrimitive;
     201           0 :             aSequence[1] = aBlackRectanglePrimitive;
     202             : 
     203           0 :             pProcessor2D->process(aSequence);
     204           0 :             delete pProcessor2D;
     205             :         }
     206             : 
     207             :         // get result bitmap and scale
     208           0 :         aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
     209             :     }
     210             : 
     211           0 :     return aRetval;
     212             : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10