LCOV - code coverage report
Current view: top level - svx/source/sdr/primitive3d - sdrattributecreator3d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 38 45 84.4 %
Date: 2014-11-03 Functions: 3 3 100.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 <sdr/primitive3d/sdrattributecreator3d.hxx>
      21             : #include <svx/svx3ditems.hxx>
      22             : #include <svl/itemset.hxx>
      23             : #include <com/sun/star/drawing/NormalsKind.hpp>
      24             : #include <com/sun/star/drawing/TextureProjectionMode.hpp>
      25             : #include <com/sun/star/drawing/TextureKind2.hpp>
      26             : #include <com/sun/star/drawing/TextureMode.hpp>
      27             : #include <svx/xflclit.hxx>
      28             : #include <drawinglayer/attribute/materialattribute3d.hxx>
      29             : #include <drawinglayer/attribute/sdrobjectattribute3d.hxx>
      30             : 
      31             : 
      32             : 
      33             : namespace drawinglayer
      34             : {
      35             :     namespace primitive2d
      36             :     {
      37        7476 :         attribute::Sdr3DObjectAttribute* createNewSdr3DObjectAttribute(const SfxItemSet& rSet)
      38             :         {
      39             :             // get NormalsKind
      40        7476 :             ::com::sun::star::drawing::NormalsKind aNormalsKind(::com::sun::star::drawing::NormalsKind_SPECIFIC);
      41        7476 :             const sal_uInt16 nNormalsValue(static_cast<const Svx3DNormalsKindItem&>(rSet.Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue());
      42             : 
      43        7476 :             if(1L == nNormalsValue)
      44             :             {
      45        3271 :                 aNormalsKind = ::com::sun::star::drawing::NormalsKind_FLAT;
      46             :             }
      47        4205 :             else if(2L == nNormalsValue)
      48             :             {
      49           0 :                 aNormalsKind = ::com::sun::star::drawing::NormalsKind_SPHERE;
      50             :             }
      51             : 
      52             :             // get NoermalsInvert flag
      53        7476 :             const bool bInvertNormals(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue());
      54             : 
      55             :             // get TextureProjectionX
      56        7476 :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC);
      57        7476 :             const sal_uInt16 nTextureValueX(static_cast<const Svx3DTextureProjectionXItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue());
      58             : 
      59        7476 :             if(1L == nTextureValueX)
      60             :             {
      61        3520 :                 aTextureProjectionX = ::com::sun::star::drawing::TextureProjectionMode_PARALLEL;
      62             :             }
      63        3956 :             else if(2L == nTextureValueX)
      64             :             {
      65           0 :                 aTextureProjectionX = ::com::sun::star::drawing::TextureProjectionMode_SPHERE;
      66             :             }
      67             : 
      68             :             // get TextureProjectionY
      69        7476 :             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC);
      70        7476 :             const sal_uInt16 nTextureValueY(static_cast<const Svx3DTextureProjectionYItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue());
      71             : 
      72        7476 :             if(1L == nTextureValueY)
      73             :             {
      74        3456 :                 aTextureProjectionY = ::com::sun::star::drawing::TextureProjectionMode_PARALLEL;
      75             :             }
      76        4020 :             else if(2L == nTextureValueY)
      77             :             {
      78           0 :                 aTextureProjectionY = ::com::sun::star::drawing::TextureProjectionMode_SPHERE;
      79             :             }
      80             : 
      81             :             // get DoubleSided flag
      82        7476 :             const bool bDoubleSided(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue());
      83             : 
      84             :             // get Shadow3D flag
      85        7476 :             const bool bShadow3D(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue());
      86             : 
      87             :             // get TextureFilter flag
      88        7476 :             const bool bTextureFilter(static_cast<const SfxBoolItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue());
      89             : 
      90             :             // get texture kind
      91             :             // TextureKind: 1 == Base3DTextureLuminance, 2 == Base3DTextureIntensity, 3 == Base3DTextureColor
      92        7476 :             ::com::sun::star::drawing::TextureKind2 aTextureKind(::com::sun::star::drawing::TextureKind2_LUMINANCE);
      93        7476 :             const sal_uInt16 nTextureKind(static_cast<const Svx3DTextureKindItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_KIND)).GetValue());
      94             : 
      95        7476 :             if(2 == nTextureKind)
      96             :             {
      97           0 :                 aTextureKind = ::com::sun::star::drawing::TextureKind2_INTENSITY;
      98             :             }
      99        7476 :             else if(3 == nTextureKind)
     100             :             {
     101        7476 :                 aTextureKind = ::com::sun::star::drawing::TextureKind2_COLOR;
     102             :             }
     103             : 
     104             :             // get texture mode
     105             :             // TextureMode: 1 == Base3DTextureReplace, 2 == Base3DTextureModulate, 3 == Base3DTextureBlend
     106        7476 :             ::com::sun::star::drawing::TextureMode aTextureMode(::com::sun::star::drawing::TextureMode_REPLACE);
     107        7476 :             const sal_uInt16 nTextureMode(static_cast<const Svx3DTextureModeItem&>(rSet.Get(SDRATTR_3DOBJ_TEXTURE_MODE)).GetValue());
     108             : 
     109        7476 :             if(2 == nTextureMode)
     110             :             {
     111        7476 :                 aTextureMode = ::com::sun::star::drawing::TextureMode_MODULATE;
     112             :             }
     113           0 :             else if(3 == nTextureMode)
     114             :             {
     115           0 :                 aTextureMode = ::com::sun::star::drawing::TextureMode_BLEND;
     116             :             }
     117             : 
     118             :             // get object color
     119        7476 :             const ::basegfx::BColor aObjectColor(static_cast<const XFillColorItem&>(rSet.Get(XATTR_FILLCOLOR)).GetColorValue().getBColor());
     120             : 
     121             :             // get specular color
     122       14952 :             const ::basegfx::BColor aSpecular(static_cast<const SvxColorItem&>(rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue().getBColor());
     123             : 
     124             :             // get emissive color
     125       14952 :             const ::basegfx::BColor aEmission(static_cast<const SvxColorItem&>(rSet.Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue().getBColor());
     126             : 
     127             :             // get specular intensity
     128        7476 :             sal_uInt16 nSpecularIntensity(static_cast<const SfxUInt16Item&>(rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue());
     129             : 
     130        7476 :             if(nSpecularIntensity > 128)
     131             :             {
     132           0 :                 nSpecularIntensity = 128;
     133             :             }
     134             : 
     135             :             // get reduced line geometry
     136        7476 :             const bool bReducedLineGeometry(static_cast<const Svx3DReducedLineGeometryItem&>(rSet.Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY)).GetValue());
     137             : 
     138             :             // prepare material
     139       14952 :             attribute::MaterialAttribute3D aMaterial(aObjectColor, aSpecular, aEmission, nSpecularIntensity);
     140             : 
     141             :             return new attribute::Sdr3DObjectAttribute(
     142             :                 aNormalsKind, aTextureProjectionX, aTextureProjectionY,
     143             :                 aTextureKind, aTextureMode, aMaterial,
     144       14952 :                 bInvertNormals, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry);
     145             :         }
     146             :     } // end of namespace primitive2d
     147         651 : } // end of namespace sdr
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10