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

Generated by: LCOV version 1.10