LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtabhtch.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 68 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             : #include <vcl/svapp.hxx>
      22             : 
      23             : #include <vcl/virdev.hxx>
      24             : #include <vcl/settings.hxx>
      25             : #include <svx/dialogs.hrc>
      26             : #include <svx/dialmgr.hxx>
      27             : #include <svx/xpool.hxx>
      28             : 
      29             : #include <drawinglayer/attribute/fillhatchattribute.hxx>
      30             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.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             : using namespace ::rtl;
      37             : 
      38           0 : XHatchList::XHatchList(const OUString& rPath, const OUString& rReferer)
      39           0 :   : XPropertyList( XHATCH_LIST, rPath, rReferer )
      40             : {
      41           0 : }
      42             : 
      43           0 : XHatchList::~XHatchList()
      44             : {
      45           0 : }
      46             : 
      47           0 : XHatchEntry* XHatchList::Replace(XHatchEntry* pEntry, long nIndex )
      48             : {
      49           0 :     return (XHatchEntry*) XPropertyList::Replace(pEntry, nIndex);
      50             : }
      51             : 
      52           0 : XHatchEntry* XHatchList::Remove(long nIndex)
      53             : {
      54           0 :     return (XHatchEntry*) XPropertyList::Remove(nIndex);
      55             : }
      56             : 
      57           0 : XHatchEntry* XHatchList::GetHatch(long nIndex) const
      58             : {
      59           0 :     return (XHatchEntry*) XPropertyList::Get(nIndex);
      60             : }
      61             : 
      62           0 : uno::Reference< container::XNameContainer > XHatchList::createInstance()
      63             : {
      64             :     return uno::Reference< container::XNameContainer >(
      65           0 :         SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY );
      66             : }
      67             : 
      68           0 : bool XHatchList::Create()
      69             : {
      70           0 :     OUStringBuffer aStr(SVX_RESSTR(RID_SVXSTR_HATCH));
      71           0 :     aStr.append(" 1");
      72             : 
      73           0 :     sal_Int32 nLen = aStr.getLength() - 1;
      74           0 :     Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLACK),XHATCH_SINGLE,100,  0),aStr.toString()));
      75           0 :     aStr[nLen] = '2';
      76           0 :     Insert(new XHatchEntry(XHatch(RGB_Color(COL_RED  ),XHATCH_DOUBLE, 80,450),aStr.toString()));
      77           0 :     aStr[nLen] = '3';
      78           0 :     Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLUE ),XHATCH_TRIPLE,120,  0),aStr.toString()));
      79             : 
      80           0 :     return true;
      81             : }
      82             : 
      83           0 : Bitmap XHatchList::CreateBitmapForUI( long nIndex )
      84             : {
      85           0 :     Bitmap aRetval;
      86             :     OSL_ENSURE(nIndex < Count(), "OOps, access out of range (!)");
      87             : 
      88           0 :     if(nIndex < Count())
      89             :     {
      90           0 :         const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      91           0 :         const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
      92             : 
      93             :         // prepare polygon geometry for rectangle
      94             :         const basegfx::B2DPolygon aRectangle(
      95             :             basegfx::tools::createPolygonFromRect(
      96           0 :                 basegfx::B2DRange(0.0, 0.0, rSize.Width(), rSize.Height())));
      97             : 
      98           0 :         const XHatch& rHatch = GetHatch(nIndex)->GetHatch();
      99           0 :         drawinglayer::attribute::HatchStyle aHatchStyle(drawinglayer::attribute::HATCHSTYLE_TRIPLE);
     100             : 
     101           0 :         switch(rHatch.GetHatchStyle())
     102             :         {
     103             :             case XHATCH_SINGLE :
     104             :             {
     105           0 :                 aHatchStyle = drawinglayer::attribute::HATCHSTYLE_SINGLE;
     106           0 :                 break;
     107             :             }
     108             :             case XHATCH_DOUBLE :
     109             :             {
     110           0 :                 aHatchStyle = drawinglayer::attribute::HATCHSTYLE_DOUBLE;
     111           0 :                 break;
     112             :             }
     113             :             default :
     114             :             {
     115           0 :                 aHatchStyle = drawinglayer::attribute::HATCHSTYLE_TRIPLE; // XHATCH_TRIPLE
     116           0 :                 break;
     117             :             }
     118             :         }
     119             : 
     120           0 :         const basegfx::B2DHomMatrix aScaleMatrix(OutputDevice::LogicToLogic(MAP_100TH_MM, MAP_PIXEL));
     121           0 :         const basegfx::B2DVector aScaleVector(aScaleMatrix * basegfx::B2DVector(1.0, 0.0));
     122           0 :         const double fScaleValue(aScaleVector.getLength());
     123             : 
     124             :         const drawinglayer::attribute::FillHatchAttribute aFillHatch(
     125             :             aHatchStyle,
     126           0 :             (double)rHatch.GetDistance() * fScaleValue,
     127           0 :             (double)rHatch.GetAngle() * F_PI1800,
     128             :             rHatch.GetColor().getBColor(),
     129             :             3, // same default as VCL, a minimum of three discrete units (pixels) offset
     130           0 :             false);
     131             : 
     132           0 :         const basegfx::BColor aBlack(0.0, 0.0, 0.0);
     133             :         const drawinglayer::primitive2d::Primitive2DReference aHatchPrimitive(
     134             :             new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(
     135             :                 basegfx::B2DPolyPolygon(aRectangle),
     136             :                 aBlack,
     137           0 :                 aFillHatch));
     138             : 
     139             :         const drawinglayer::primitive2d::Primitive2DReference aBlackRectanglePrimitive(
     140             :             new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
     141             :                 aRectangle,
     142           0 :                 aBlack));
     143             : 
     144             :         // prepare VirtualDevice
     145           0 :         VirtualDevice aVirtualDevice;
     146           0 :         const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
     147             : 
     148           0 :         aVirtualDevice.SetOutputSizePixel(rSize);
     149           0 :         aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
     150             :             ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
     151           0 :             : DRAWMODE_DEFAULT);
     152             : 
     153           0 :         if(rStyleSettings.GetPreviewUsesCheckeredBackground())
     154             :         {
     155           0 :             const Point aNull(0, 0);
     156             :             static const sal_uInt32 nLen(8);
     157           0 :             static const Color aW(COL_WHITE);
     158           0 :             static const Color aG(0xef, 0xef, 0xef);
     159           0 :             aVirtualDevice.DrawCheckered(aNull, rSize, nLen, aW, aG);
     160             :         }
     161             :         else
     162             :         {
     163           0 :             aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
     164           0 :             aVirtualDevice.Erase();
     165             :         }
     166             : 
     167             :         // create processor and draw primitives
     168             :         drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
     169             :             aVirtualDevice,
     170           0 :             aNewViewInformation2D);
     171             : 
     172           0 :         if(pProcessor2D)
     173             :         {
     174           0 :             drawinglayer::primitive2d::Primitive2DSequence aSequence(2);
     175             : 
     176           0 :             aSequence[0] = aHatchPrimitive;
     177           0 :             aSequence[1] = aBlackRectanglePrimitive;
     178           0 :             pProcessor2D->process(aSequence);
     179           0 :             delete pProcessor2D;
     180             :         }
     181             : 
     182             :         // get result bitmap and scale
     183           0 :         aRetval = aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel());
     184             :     }
     185             : 
     186           0 :     return aRetval;
     187             : }
     188             : 
     189             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10