LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtablend.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 8 65 12.3 %
Date: 2014-11-03 Functions: 6 10 60.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        6962 : XLineEndList::XLineEndList( const OUString& rPath, const OUString& rReferer )
      39        6962 :     : XPropertyList( XLINE_END_LIST, rPath, rReferer )
      40             : {
      41        6962 : }
      42             : 
      43       13842 : XLineEndList::~XLineEndList()
      44             : {
      45       13842 : }
      46             : 
      47           0 : XLineEndEntry* XLineEndList::Remove(long nIndex)
      48             : {
      49           0 :     return static_cast<XLineEndEntry*>( XPropertyList::Remove(nIndex) );
      50             : }
      51             : 
      52           0 : XLineEndEntry* XLineEndList::GetLineEnd(long nIndex) const
      53             : {
      54           0 :     return static_cast<XLineEndEntry*>( XPropertyList::Get(nIndex) );
      55             : }
      56             : 
      57          36 : uno::Reference< container::XNameContainer > XLineEndList::createInstance()
      58             : {
      59             :     return uno::Reference< container::XNameContainer >(
      60          36 :         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           0 : Bitmap XLineEndList::CreateBitmapForUI( long nIndex )
      87             : {
      88           0 :     Bitmap aRetval;
      89             :     OSL_ENSURE(nIndex < Count(), "OOps, access out of range (!)");
      90             : 
      91           0 :     if(nIndex < Count())
      92             :     {
      93           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      94           0 :         const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
      95             : 
      96           0 :         const Size aSize(rSize.Width() * 2, rSize.Height());
      97             : 
      98             :         // prepare line geometry
      99           0 :         basegfx::B2DPolygon aLine;
     100           0 :         const double fBorderDistance(aSize.Height() * 0.1);
     101             : 
     102           0 :         aLine.append(basegfx::B2DPoint(fBorderDistance, aSize.Height() / 2));
     103           0 :         aLine.append(basegfx::B2DPoint(aSize.Width() - fBorderDistance, aSize.Height() / 2));
     104             : 
     105             :         // prepare LineAttribute
     106           0 :         const basegfx::BColor aLineColor(rStyleSettings.GetFieldTextColor().getBColor());
     107           0 :         const double fLineWidth(rStyleSettings.GetListBoxPreviewDefaultLineWidth() * 1.1);
     108             :         const drawinglayer::attribute::LineAttribute aLineAttribute(
     109             :             aLineColor,
     110           0 :             fLineWidth);
     111             : 
     112           0 :         const basegfx::B2DPolyPolygon aLineEnd(GetLineEnd(nIndex)->GetLineEnd());
     113           0 :         const double fArrowHeight(aSize.Height() - (2.0 * fBorderDistance));
     114             :         const drawinglayer::attribute::LineStartEndAttribute aLineStartEndAttribute(
     115             :             fArrowHeight,
     116             :             aLineEnd,
     117           0 :             false);
     118             : 
     119             :         // prepare line primitive
     120             :         const drawinglayer::primitive2d::Primitive2DReference aLineStartEndPrimitive(
     121             :             new drawinglayer::primitive2d::PolygonStrokeArrowPrimitive2D(
     122             :                 aLine,
     123             :                 aLineAttribute,
     124             :                 aLineStartEndAttribute,
     125           0 :                 aLineStartEndAttribute));
     126             : 
     127             :         // prepare VirtualDevice
     128           0 :         VirtualDevice aVirtualDevice;
     129           0 :         const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
     130             : 
     131           0 :         aVirtualDevice.SetOutputSizePixel(aSize);
     132           0 :         aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
     133             :             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
     134           0 :             : DRAWMODE_DEFAULT);
     135             : 
     136           0 :         if(rStyleSettings.GetPreviewUsesCheckeredBackground())
     137             :         {
     138           0 :             const Point aNull(0, 0);
     139             :             static const sal_uInt32 nLen(8);
     140           0 :             static const Color aW(COL_WHITE);
     141           0 :             static const Color aG(0xef, 0xef, 0xef);
     142           0 :             aVirtualDevice.DrawCheckered(aNull, aSize, nLen, aW, aG);
     143             :         }
     144             :         else
     145             :         {
     146           0 :             aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
     147           0 :             aVirtualDevice.Erase();
     148             :         }
     149             : 
     150             :         // create processor and draw primitives
     151             :         boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
     152             :             aVirtualDevice,
     153           0 :             aNewViewInformation2D));
     154             : 
     155           0 :         if(pProcessor2D)
     156             :         {
     157           0 :             const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aLineStartEndPrimitive, 1);
     158             : 
     159           0 :             pProcessor2D->process(aSequence);
     160           0 :             pProcessor2D.reset();
     161             :         }
     162             : 
     163             :         // get result bitmap and scale
     164           0 :         aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
     165             :     }
     166             : 
     167           0 :     return aRetval;
     168         651 : }
     169             : 
     170             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10