LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtablend.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 45 66 68.2 %
Date: 2015-06-13 12:38:46 Functions: 6 8 75.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             : #include <vcl/virdev.hxx>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/settings.hxx>
      25             : 
      26             : #include <svx/dialogs.hrc>
      27             : #include <svx/dialmgr.hxx>
      28             : 
      29             : #include <svx/xtable.hxx>
      30             : #include <drawinglayer/attribute/linestartendattribute.hxx>
      31             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      32             : #include <drawinglayer/processor2d/processor2dtools.hxx>
      33             : #include <basegfx/polygon/b2dpolygontools.hxx>
      34             : #include <boost/scoped_ptr.hpp>
      35             : 
      36             : using namespace com::sun::star;
      37             : 
      38        4192 : XLineEndList::XLineEndList( const OUString& rPath, const OUString& rReferer )
      39        4192 :     : XPropertyList( XLINE_END_LIST, rPath, rReferer )
      40             : {
      41        4192 : }
      42             : 
      43        8304 : XLineEndList::~XLineEndList()
      44             : {
      45        8304 : }
      46             : 
      47           0 : XLineEndEntry* XLineEndList::Remove(long nIndex)
      48             : {
      49           0 :     return static_cast<XLineEndEntry*>( XPropertyList::Remove(nIndex) );
      50             : }
      51             : 
      52          40 : XLineEndEntry* XLineEndList::GetLineEnd(long nIndex) const
      53             : {
      54          40 :     return static_cast<XLineEndEntry*>( XPropertyList::Get(nIndex) );
      55             : }
      56             : 
      57          46 : uno::Reference< container::XNameContainer > XLineEndList::createInstance()
      58             : {
      59             :     return uno::Reference< container::XNameContainer >(
      60          46 :         SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY );
      61             : }
      62             : 
      63           0 : bool XLineEndList::Create()
      64             : {
      65           0 :     basegfx::B2DPolygon aTriangle;
      66           0 :     aTriangle.append(basegfx::B2DPoint(10.0, 0.0));
      67           0 :     aTriangle.append(basegfx::B2DPoint(0.0, 30.0));
      68           0 :     aTriangle.append(basegfx::B2DPoint(20.0, 30.0));
      69           0 :     aTriangle.setClosed(true);
      70           0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aTriangle), SVX_RESSTR( RID_SVXSTR_ARROW ) ) );
      71             : 
      72           0 :     basegfx::B2DPolygon aSquare;
      73           0 :     aSquare.append(basegfx::B2DPoint(0.0, 0.0));
      74           0 :     aSquare.append(basegfx::B2DPoint(10.0, 0.0));
      75           0 :     aSquare.append(basegfx::B2DPoint(10.0, 10.0));
      76           0 :     aSquare.append(basegfx::B2DPoint(0.0, 10.0));
      77           0 :     aSquare.setClosed(true);
      78           0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aSquare), SVX_RESSTR( RID_SVXSTR_SQUARE ) ) );
      79             : 
      80           0 :     basegfx::B2DPolygon aCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), 100.0));
      81           0 :     Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aCircle), SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) );
      82             : 
      83           0 :     return true;
      84             : }
      85             : 
      86          20 : Bitmap XLineEndList::CreateBitmapForUI( long nIndex )
      87             : {
      88          20 :     Bitmap aRetval;
      89             :     OSL_ENSURE(nIndex < Count(), "OOps, access out of range (!)");
      90             : 
      91          20 :     if(nIndex < Count())
      92             :     {
      93          20 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      94          20 :         const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
      95             : 
      96          20 :         const Size aSize(rSize.Width() * 2, rSize.Height());
      97             : 
      98             :         // prepare line geometry
      99          20 :         basegfx::B2DPolygon aLine;
     100          20 :         const double fBorderDistance(aSize.Height() * 0.1);
     101             : 
     102          20 :         aLine.append(basegfx::B2DPoint(fBorderDistance, aSize.Height() / 2));
     103          20 :         aLine.append(basegfx::B2DPoint(aSize.Width() - fBorderDistance, aSize.Height() / 2));
     104             : 
     105             :         // prepare LineAttribute
     106          40 :         const basegfx::BColor aLineColor(rStyleSettings.GetFieldTextColor().getBColor());
     107          20 :         const double fLineWidth(rStyleSettings.GetListBoxPreviewDefaultLineWidth() * 1.1);
     108             :         const drawinglayer::attribute::LineAttribute aLineAttribute(
     109             :             aLineColor,
     110          40 :             fLineWidth);
     111             : 
     112          40 :         const basegfx::B2DPolyPolygon aLineEnd(GetLineEnd(nIndex)->GetLineEnd());
     113          20 :         const double fArrowHeight(aSize.Height() - (2.0 * fBorderDistance));
     114             :         const drawinglayer::attribute::LineStartEndAttribute aLineStartEndAttribute(
     115             :             fArrowHeight,
     116             :             aLineEnd,
     117          40 :             false);
     118             : 
     119             :         // prepare line primitive
     120             :         const drawinglayer::primitive2d::Primitive2DReference aLineStartEndPrimitive(
     121             :             new drawinglayer::primitive2d::PolygonStrokeArrowPrimitive2D(
     122             :                 aLine,
     123             :                 aLineAttribute,
     124             :                 aLineStartEndAttribute,
     125          40 :                 aLineStartEndAttribute));
     126             : 
     127             :         // prepare VirtualDevice
     128          40 :         ScopedVclPtrInstance< VirtualDevice > pVirtualDevice;
     129          40 :         const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
     130             : 
     131          20 :         pVirtualDevice->SetOutputSizePixel(aSize);
     132          40 :         pVirtualDevice->SetDrawMode(rStyleSettings.GetHighContrastMode()
     133          20 :             ? DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient
     134          60 :             : DrawModeFlags::Default);
     135             : 
     136          20 :         if(rStyleSettings.GetPreviewUsesCheckeredBackground())
     137             :         {
     138          20 :             const Point aNull(0, 0);
     139             :             static const sal_uInt32 nLen(8);
     140          20 :             static const Color aW(COL_WHITE);
     141          20 :             static const Color aG(0xef, 0xef, 0xef);
     142          20 :             pVirtualDevice->DrawCheckered(aNull, aSize, nLen, aW, aG);
     143             :         }
     144             :         else
     145             :         {
     146           0 :             pVirtualDevice->SetBackground(rStyleSettings.GetFieldColor());
     147           0 :             pVirtualDevice->Erase();
     148             :         }
     149             : 
     150             :         // create processor and draw primitives
     151             :         boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
     152          20 :             *pVirtualDevice.get(),
     153          40 :             aNewViewInformation2D));
     154             : 
     155          20 :         if(pProcessor2D)
     156             :         {
     157          20 :             const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aLineStartEndPrimitive, 1);
     158             : 
     159          20 :             pProcessor2D->process(aSequence);
     160          20 :             pProcessor2D.reset();
     161             :         }
     162             : 
     163             :         // get result bitmap and scale
     164          40 :         aRetval = pVirtualDevice->GetBitmap(Point(0, 0), pVirtualDevice->GetOutputSizePixel());
     165             :     }
     166             : 
     167          20 :     return aRetval;
     168             : }
     169             : 
     170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11