LCOV - code coverage report
Current view: top level - oox/source/drawingml - scene3dcontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 52 55 94.5 %
Date: 2015-06-13 12:38:46 Functions: 8 8 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 "drawingml/scene3dcontext.hxx"
      21             : #include <com/sun/star/io/XInputStream.hpp>
      22             : #include <com/sun/star/graphic/XGraphicProvider.hpp>
      23             : #include <cppuhelper/exc_hlp.hxx>
      24             : #include <comphelper/anytostring.hxx>
      25             : #include "drawingml/colorchoicecontext.hxx"
      26             : #include "oox/drawingml/drawingmltypes.hxx"
      27             : #include "oox/drawingml/fillproperties.hxx"
      28             : #include "oox/core/xmlfilterbase.hxx"
      29             : #include "oox/helper/attributelist.hxx"
      30             : 
      31             : using namespace ::oox::core;
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::xml::sax;
      35             : 
      36             : namespace oox { namespace drawingml {
      37             : 
      38          82 : Scene3DPropertiesContext::Scene3DPropertiesContext( ContextHandler2Helper& rParent, Shape3DProperties& r3DProperties ) throw()
      39             : : ContextHandler2( rParent )
      40          82 : , mr3DProperties( r3DProperties )
      41             : {
      42          82 : }
      43             : 
      44         164 : ContextHandlerRef Scene3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      45             : {
      46         164 :     switch( aElementToken )
      47             :     {
      48             :     case A_TOKEN( camera ):
      49          82 :         if( rAttribs.hasAttribute( XML_fov ) )
      50           0 :             mr3DProperties.mfFieldOfVision = rAttribs.getInteger( XML_fov, 0 ) / 60000.0; // 60000ths of degree
      51          82 :         if( rAttribs.hasAttribute( XML_zoom ) )
      52           3 :             mr3DProperties.mfZoom = rAttribs.getInteger( XML_zoom, 100000 ) / 100000.0;
      53          82 :         if( rAttribs.hasAttribute( XML_prst ) )
      54          82 :             mr3DProperties.mnPreset = rAttribs.getToken( XML_prst, XML_none );
      55             : 
      56          82 :         return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maCameraRotation );
      57             : 
      58             :     case A_TOKEN( lightRig ):
      59          82 :         mr3DProperties.mnLightRigDirection = rAttribs.getToken( XML_dir, XML_none );
      60          82 :         mr3DProperties.mnLightRigType = rAttribs.getToken( XML_rig, XML_none );
      61             : 
      62          82 :         return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maLightRigRotation );
      63             : 
      64             :     case A_TOKEN( backdrop ):
      65             :     case A_TOKEN( extLst ):
      66           0 :         return 0; // TODO: later (backdrop is not supported by core anyway)
      67             :     }
      68           0 :     return 0;
      69             : }
      70             : 
      71          87 : Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, Shape3DProperties& r3DProperties ) throw()
      72             : : ContextHandler2( rParent )
      73          87 : , mr3DProperties( r3DProperties )
      74             : {
      75          87 :     if( rAttribs.hasAttribute( XML_extrusionH ) )
      76          11 :         mr3DProperties.mnExtrusionH = rAttribs.getInteger( XML_extrusionH, 0 );
      77          87 :     if( rAttribs.hasAttribute( XML_contourW ) )
      78           3 :         mr3DProperties.mnContourW = rAttribs.getInteger( XML_contourW, 0 );
      79          87 :     if( rAttribs.hasAttribute( XML_z ) )
      80           3 :         mr3DProperties.mnShapeZ = rAttribs.getInteger( XML_z, 0 );
      81          87 :     if( rAttribs.hasAttribute( XML_prstMaterial ) )
      82          73 :         mr3DProperties.mnMaterial = rAttribs.getToken( XML_prstMaterial, XML_none );
      83          87 : }
      84             : 
      85          82 : ContextHandlerRef Shape3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      86             : {
      87          82 :     switch( aElementToken )
      88             :     {
      89             :     case A_TOKEN( bevelT ):
      90             :     case A_TOKEN( bevelB ):
      91             :     {
      92          71 :         BevelProperties aProps;
      93          71 :         if( rAttribs.hasAttribute( XML_w ) )
      94          67 :             aProps.mnWidth = rAttribs.getInteger( XML_w, 0 );
      95          71 :         if( rAttribs.hasAttribute( XML_h ) )
      96          70 :             aProps.mnHeight = rAttribs.getInteger( XML_h, 0 );
      97          71 :         if( rAttribs.hasAttribute( XML_prst ) )
      98          13 :             aProps.mnPreset = rAttribs.getToken( XML_prst, XML_none );
      99             : 
     100          71 :         if( aElementToken == A_TOKEN( bevelT ) )
     101          68 :             mr3DProperties.maTopBevelProperties.set( aProps );
     102             :         else
     103           3 :             mr3DProperties.maBottomBevelProperties.set( aProps );
     104             : 
     105          71 :         break;
     106             :     }
     107             :     case A_TOKEN( extrusionClr ):
     108           6 :         return new ColorContext( *this, mr3DProperties.maExtrusionColor );
     109             : 
     110             :     case A_TOKEN( contourClr ):
     111           5 :         return new ColorContext( *this, mr3DProperties.maContourColor );
     112             :     }
     113          71 :     return 0;
     114             : }
     115             : 
     116         164 : Scene3DRotationPropertiesContext::Scene3DRotationPropertiesContext( ContextHandler2Helper& rParent, RotationProperties& rRotationProperties ) throw()
     117             : : ContextHandler2( rParent )
     118         164 : , mrRotationProperties( rRotationProperties )
     119             : {
     120         164 : }
     121             : 
     122          20 : ContextHandlerRef Scene3DRotationPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     123             : {
     124          20 :     switch( aElementToken )
     125             :     {
     126             :     case A_TOKEN( rot ):
     127          20 :         mrRotationProperties.mnLatitude = rAttribs.getInteger( XML_lat, 0 );
     128          20 :         mrRotationProperties.mnLongitude = rAttribs.getInteger( XML_lon, 0 );
     129          20 :         mrRotationProperties.mnRevolution = rAttribs.getInteger( XML_rev, 0 );
     130          20 :         break;
     131             :     }
     132          20 :     return 0;
     133             : }
     134             : 
     135         246 : } }
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11