LCOV - code coverage report
Current view: top level - svx/source/xoutdev - xtabdash.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 80 0.0 %
Date: 2014-04-14 Functions: 0 13 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/svapp.hxx>
      23             : #include <vcl/settings.hxx>
      24             : 
      25             : #include <vcl/virdev.hxx>
      26             : #include <svx/dialogs.hrc>
      27             : #include <svx/dialmgr.hxx>
      28             : #include <svx/xtable.hxx>
      29             : 
      30             : #include <drawinglayer/attribute/lineattribute.hxx>
      31             : #include <drawinglayer/attribute/strokeattribute.hxx>
      32             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      33             : #include <drawinglayer/processor2d/processor2dtools.hxx>
      34             : 
      35             : using namespace com::sun::star;
      36             : 
      37           0 : XDashList::XDashList(const OUString& rPath, const OUString& rReferer)
      38             :     : XPropertyList(XDASH_LIST, rPath, rReferer)
      39             :     , maBitmapSolidLine()
      40             :     , maStringSolidLine()
      41           0 :     , maStringNoLine()
      42             : {
      43           0 : }
      44             : 
      45           0 : XDashList::~XDashList()
      46             : {
      47           0 : }
      48             : 
      49           0 : XDashEntry* XDashList::Replace(XDashEntry* pEntry, long nIndex )
      50             : {
      51           0 :     return (XDashEntry*) XPropertyList::Replace(pEntry, nIndex);
      52             : }
      53             : 
      54           0 : XDashEntry* XDashList::Remove(long nIndex)
      55             : {
      56           0 :     return (XDashEntry*) XPropertyList::Remove(nIndex);
      57             : }
      58             : 
      59           0 : XDashEntry* XDashList::GetDash(long nIndex) const
      60             : {
      61           0 :     return (XDashEntry*) XPropertyList::Get(nIndex);
      62             : }
      63             : 
      64           0 : uno::Reference< container::XNameContainer > XDashList::createInstance()
      65             : {
      66             :     return uno::Reference< container::XNameContainer >(
      67           0 :         SvxUnoXDashTable_createInstance( this ), uno::UNO_QUERY );
      68             : }
      69             : 
      70           0 : bool XDashList::Create()
      71             : {
      72           0 :     const OUString aStr(SVX_RESSTR(RID_SVXSTR_LINESTYLE));
      73             : 
      74           0 :     Insert(new XDashEntry(XDash(XDASH_RECT,1, 50,1, 50, 50),aStr + " 1"));
      75           0 :     Insert(new XDashEntry(XDash(XDASH_RECT,1,500,1,500,500),aStr + " 2"));
      76           0 :     Insert(new XDashEntry(XDash(XDASH_RECT,2, 50,3,250,120),aStr + " 3"));
      77             : 
      78           0 :     return true;
      79             : }
      80             : 
      81           0 : Bitmap XDashList::ImpCreateBitmapForXDash(const XDash* pDash)
      82             : {
      83           0 :     const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
      84           0 :     const Size& rSize = rStyleSettings.GetListBoxPreviewDefaultPixelSize();
      85           0 :     const sal_uInt32 nFactor(2);
      86           0 :     const Size aSize((rSize.Width() * 5 * 2) / 2, rSize.Height() * nFactor);
      87             : 
      88             :     // prepare polygon geometry for line
      89           0 :     basegfx::B2DPolygon aLine;
      90             : 
      91           0 :     aLine.append(basegfx::B2DPoint(0.0, aSize.Height() / 2.0));
      92           0 :     aLine.append(basegfx::B2DPoint(aSize.Width(), aSize.Height() / 2.0));
      93             : 
      94             :     // prepare LineAttribute
      95           0 :     const basegfx::BColor aLineColor(rStyleSettings.GetFieldTextColor().getBColor());
      96           0 :     const double fLineWidth(rStyleSettings.GetListBoxPreviewDefaultLineWidth() * (nFactor * 1.1));
      97             :     const drawinglayer::attribute::LineAttribute aLineAttribute(
      98             :         aLineColor,
      99           0 :         fLineWidth);
     100             : 
     101             :     // prepare StrokeAttribute
     102           0 :     ::std::vector< double > aDotDashArray;
     103           0 :     double fFullDotDashLen(0.0);
     104             : 
     105           0 :     if(pDash && (pDash->GetDots() || pDash->GetDashes()))
     106             :     {
     107           0 :         const basegfx::B2DHomMatrix aScaleMatrix(OutputDevice::LogicToLogic(MAP_100TH_MM, MAP_PIXEL));
     108           0 :         const basegfx::B2DVector aScaleVector(aScaleMatrix * basegfx::B2DVector(1.0, 0.0));
     109           0 :         const double fScaleValue(aScaleVector.getLength() * (nFactor * (1.4 / 2.0)));
     110           0 :         const double fLineWidthInUnits(fLineWidth / fScaleValue);
     111             : 
     112           0 :         fFullDotDashLen = pDash->CreateDotDashArray(aDotDashArray, fLineWidthInUnits);
     113             : 
     114           0 :         if(!aDotDashArray.empty())
     115             :         {
     116           0 :             for(sal_uInt32 a(0); a < aDotDashArray.size(); a++)
     117             :             {
     118           0 :                 aDotDashArray[a] *= fScaleValue;
     119             :             }
     120             : 
     121           0 :             fFullDotDashLen *= fScaleValue;
     122           0 :         }
     123             :     }
     124             : 
     125             :     const drawinglayer::attribute::StrokeAttribute aStrokeAttribute(
     126             :         aDotDashArray,
     127           0 :         fFullDotDashLen);
     128             : 
     129             :     // cerate LinePrimitive
     130             :     const drawinglayer::primitive2d::Primitive2DReference aLinePrimitive(
     131             :         new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
     132             :             aLine,
     133             :             aLineAttribute,
     134           0 :             aStrokeAttribute));
     135             : 
     136             :     // prepare VirtualDevice
     137           0 :     VirtualDevice aVirtualDevice;
     138           0 :     const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D;
     139             : 
     140           0 :     aVirtualDevice.SetOutputSizePixel(aSize);
     141           0 :     aVirtualDevice.SetDrawMode(rStyleSettings.GetHighContrastMode()
     142             :         ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
     143           0 :         : DRAWMODE_DEFAULT);
     144             : 
     145           0 :     if(rStyleSettings.GetPreviewUsesCheckeredBackground())
     146             :     {
     147           0 :         const Point aNull(0, 0);
     148             :         static const sal_uInt32 nLen(8 * nFactor);
     149           0 :         static const Color aW(COL_WHITE);
     150           0 :         static const Color aG(0xef, 0xef, 0xef);
     151             : 
     152           0 :         aVirtualDevice.DrawCheckered(aNull, aSize, nLen, aW, aG);
     153             :     }
     154             :     else
     155             :     {
     156           0 :         aVirtualDevice.SetBackground(rStyleSettings.GetFieldColor());
     157           0 :         aVirtualDevice.Erase();
     158             :     }
     159             : 
     160             :     // create processor and draw primitives
     161             :     drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
     162             :         aVirtualDevice,
     163           0 :         aNewViewInformation2D);
     164             : 
     165           0 :     if(pProcessor2D)
     166             :     {
     167           0 :         const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aLinePrimitive, 1);
     168             : 
     169           0 :         pProcessor2D->process(aSequence);
     170           0 :         delete pProcessor2D;
     171             :     }
     172             : 
     173             :     // get result bitmap and scale
     174           0 :     Bitmap aRetval(aVirtualDevice.GetBitmap(Point(0, 0), aVirtualDevice.GetOutputSizePixel()));
     175             : 
     176             :     if(1 != nFactor)
     177             :     {
     178           0 :         aRetval.Scale(Size((rSize.Width() * 5) / 2, rSize.Height()), BMP_SCALE_DEFAULT);
     179             :     }
     180             : 
     181           0 :     return aRetval;
     182             : }
     183             : 
     184           0 : Bitmap XDashList::CreateBitmapForUI( long nIndex )
     185             : {
     186           0 :     const XDash& rDash = GetDash(nIndex)->GetDash();
     187             : 
     188           0 :     return ImpCreateBitmapForXDash(&rDash);
     189             : }
     190             : 
     191           0 : Bitmap XDashList::GetBitmapForUISolidLine() const
     192             : {
     193           0 :     if(maBitmapSolidLine.IsEmpty())
     194             :     {
     195           0 :         const_cast< XDashList* >(this)->maBitmapSolidLine = const_cast< XDashList* >(this)->ImpCreateBitmapForXDash(0);
     196             :     }
     197             : 
     198           0 :     return maBitmapSolidLine;
     199             : }
     200             : 
     201           0 : OUString XDashList::GetStringForUiSolidLine() const
     202             : {
     203           0 :     if(maStringSolidLine.isEmpty())
     204             :     {
     205           0 :         const_cast< XDashList* >(this)->maStringSolidLine = ResId(RID_SVXSTR_SOLID, DIALOG_MGR()).toString();
     206             :     }
     207             : 
     208           0 :     return maStringSolidLine;
     209             : }
     210             : 
     211           0 : OUString XDashList::GetStringForUiNoLine() const
     212             : {
     213           0 :     if(maStringNoLine.isEmpty())
     214             :     {
     215             :         // formally was RID_SVXSTR_INVISIBLE, but tomake equal
     216             :         // everywhere, use RID_SVXSTR_NONE
     217           0 :         const_cast< XDashList* >(this)->maStringNoLine = ResId(RID_SVXSTR_NONE, DIALOG_MGR()).toString();
     218             :     }
     219             : 
     220           0 :     return maStringNoLine;
     221             : }
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10