LCOV - code coverage report
Current view: top level - oox/source/drawingml - scene3dcontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 52 55 94.5 %
Date: 2014-11-03 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         164 : Scene3DPropertiesContext::Scene3DPropertiesContext( ContextHandler2Helper& rParent, Shape3DProperties& r3DProperties ) throw()
      39             : : ContextHandler2( rParent )
      40         164 : , mr3DProperties( r3DProperties )
      41             : {
      42         164 : }
      43             : 
      44         328 : ContextHandlerRef Scene3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      45             : {
      46         328 :     switch( aElementToken )
      47             :     {
      48             :     case A_TOKEN( camera ):
      49         164 :         if( rAttribs.hasAttribute( XML_fov ) )
      50           0 :             mr3DProperties.mfFieldOfVision = rAttribs.getInteger( XML_fov, 0 ) / 60000.0; // 60000ths of degree
      51         164 :         if( rAttribs.hasAttribute( XML_zoom ) )
      52           6 :             mr3DProperties.mfZoom = rAttribs.getInteger( XML_zoom, 100000 ) / 100000.0;
      53         164 :         if( rAttribs.hasAttribute( XML_prst ) )
      54         164 :             mr3DProperties.mnPreset = rAttribs.getToken( XML_prst, XML_none );
      55             : 
      56         164 :         return new Scene3DRotationPropertiesContext( *this, mr3DProperties.maCameraRotation );
      57             : 
      58             :     case A_TOKEN( lightRig ):
      59         164 :         mr3DProperties.mnLightRigDirection = rAttribs.getToken( XML_dir, XML_none );
      60         164 :         mr3DProperties.mnLightRigType = rAttribs.getToken( XML_rig, XML_none );
      61             : 
      62         164 :         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         174 : Shape3DPropertiesContext::Shape3DPropertiesContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, Shape3DProperties& r3DProperties ) throw()
      72             : : ContextHandler2( rParent )
      73         174 : , mr3DProperties( r3DProperties )
      74             : {
      75         174 :     if( rAttribs.hasAttribute( XML_extrusionH ) )
      76          22 :         mr3DProperties.mnExtrusionH = rAttribs.getInteger( XML_extrusionH, 0 );
      77         174 :     if( rAttribs.hasAttribute( XML_contourW ) )
      78           6 :         mr3DProperties.mnContourW = rAttribs.getInteger( XML_contourW, 0 );
      79         174 :     if( rAttribs.hasAttribute( XML_z ) )
      80           6 :         mr3DProperties.mnShapeZ = rAttribs.getInteger( XML_z, 0 );
      81         174 :     if( rAttribs.hasAttribute( XML_prstMaterial ) )
      82         146 :         mr3DProperties.mnMaterial = rAttribs.getToken( XML_prstMaterial, XML_none );
      83         174 : }
      84             : 
      85         164 : ContextHandlerRef Shape3DPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      86             : {
      87         164 :     switch( aElementToken )
      88             :     {
      89             :     case A_TOKEN( bevelT ):
      90             :     case A_TOKEN( bevelB ):
      91             :     {
      92         142 :         BevelProperties aProps;
      93         142 :         if( rAttribs.hasAttribute( XML_w ) )
      94         134 :             aProps.mnWidth = rAttribs.getInteger( XML_w, 0 );
      95         142 :         if( rAttribs.hasAttribute( XML_h ) )
      96         140 :             aProps.mnHeight = rAttribs.getInteger( XML_h, 0 );
      97         142 :         if( rAttribs.hasAttribute( XML_prst ) )
      98          26 :             aProps.mnPreset = rAttribs.getToken( XML_prst, XML_none );
      99             : 
     100         142 :         if( aElementToken == A_TOKEN( bevelT ) )
     101         136 :             mr3DProperties.maTopBevelProperties.set( aProps );
     102             :         else
     103           6 :             mr3DProperties.maBottomBevelProperties.set( aProps );
     104             : 
     105         142 :         break;
     106             :     }
     107             :     case A_TOKEN( extrusionClr ):
     108          12 :         return new ColorContext( *this, mr3DProperties.maExtrusionColor );
     109             : 
     110             :     case A_TOKEN( contourClr ):
     111          10 :         return new ColorContext( *this, mr3DProperties.maContourColor );
     112             :     }
     113         142 :     return 0;
     114             : }
     115             : 
     116         328 : Scene3DRotationPropertiesContext::Scene3DRotationPropertiesContext( ContextHandler2Helper& rParent, RotationProperties& rRotationProperties ) throw()
     117             : : ContextHandler2( rParent )
     118         328 : , mrRotationProperties( rRotationProperties )
     119             : {
     120         328 : }
     121             : 
     122          40 : ContextHandlerRef Scene3DRotationPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     123             : {
     124          40 :     switch( aElementToken )
     125             :     {
     126             :     case A_TOKEN( rot ):
     127          40 :         mrRotationProperties.mnLatitude = rAttribs.getInteger( XML_lat, 0 );
     128          40 :         mrRotationProperties.mnLongitude = rAttribs.getInteger( XML_lon, 0 );
     129          40 :         mrRotationProperties.mnRevolution = rAttribs.getInteger( XML_rev, 0 );
     130          40 :         break;
     131             :     }
     132          40 :     return 0;
     133             : }
     134             : 
     135         408 : } }
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10