LCOV - code coverage report
Current view: top level - oox/source/ole - axcontrolfragment.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 55 0.0 %
Date: 2014-04-14 Functions: 0 6 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 "oox/ole/axcontrolfragment.hxx"
      21             : 
      22             : #include "oox/core/xmlfilterbase.hxx"
      23             : #include "oox/helper/binaryinputstream.hxx"
      24             : #include "oox/helper/binaryoutputstream.hxx"
      25             : #include "oox/ole/axcontrol.hxx"
      26             : #include "oox/ole/olehelper.hxx"
      27             : #include "oox/ole/olestorage.hxx"
      28             : 
      29             : namespace oox {
      30             : namespace ole {
      31             : 
      32             : 
      33             : 
      34             : using namespace ::com::sun::star::io;
      35             : using namespace ::com::sun::star::uno;
      36             : 
      37             : using ::oox::core::ContextHandler2;
      38             : using ::oox::core::ContextHandlerRef;
      39             : using ::oox::core::FragmentHandler2;
      40             : using ::oox::core::XmlFilterBase;
      41             : 
      42             : 
      43             : 
      44           0 : AxControlPropertyContext::AxControlPropertyContext( FragmentHandler2& rFragment, ControlModelBase& rModel ) :
      45             :     ContextHandler2( rFragment ),
      46             :     mrModel( rModel ),
      47           0 :     mnPropId( XML_TOKEN_INVALID )
      48             : {
      49           0 : }
      50             : 
      51           0 : ContextHandlerRef AxControlPropertyContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      52             : {
      53           0 :     switch( getCurrentElement() )
      54             :     {
      55             :         case AX_TOKEN( ocx ):
      56           0 :             if( nElement == AX_TOKEN( ocxPr ) )
      57             :             {
      58           0 :                 mnPropId = rAttribs.getToken( AX_TOKEN( name ), XML_TOKEN_INVALID );
      59           0 :                 switch( mnPropId )
      60             :                 {
      61             :                     case XML_TOKEN_INVALID:
      62           0 :                         return 0;
      63             :                     case XML_Picture:
      64             :                     case XML_MouseIcon:
      65           0 :                         return this;        // import picture path from ax:picture child element
      66             :                     default:
      67           0 :                         mrModel.importProperty( mnPropId, rAttribs.getString( AX_TOKEN( value ), OUString() ) );
      68             :                 }
      69             :             }
      70           0 :         break;
      71             : 
      72             :         case AX_TOKEN( ocxPr ):
      73           0 :             if( nElement == AX_TOKEN( picture ) )
      74             :             {
      75           0 :                 OUString aPicturePath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
      76           0 :                 if( !aPicturePath.isEmpty() )
      77             :                 {
      78           0 :                     BinaryXInputStream aInStrm( getFilter().openInputStream( aPicturePath ), true );
      79           0 :                     mrModel.importPictureData( mnPropId, aInStrm );
      80           0 :                 }
      81             :             }
      82           0 :         break;
      83             :     }
      84           0 :     return 0;
      85             : }
      86             : 
      87             : 
      88             : 
      89           0 : AxControlFragment::AxControlFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, EmbeddedControl& rControl ) :
      90             :     FragmentHandler2( rFilter, rFragmentPath, true ),
      91           0 :     mrControl( rControl )
      92             : {
      93           0 : }
      94             : 
      95           0 : ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      96             : {
      97           0 :     if( isRootElement() && (nElement == AX_TOKEN( ocx )) )
      98             :     {
      99           0 :         OUString aClassId = rAttribs.getString( AX_TOKEN( classid ), OUString() );
     100           0 :         switch( rAttribs.getToken( AX_TOKEN( persistence ), XML_TOKEN_INVALID ) )
     101             :         {
     102             :             case XML_persistPropertyBag:
     103           0 :                 if( ControlModelBase* pModel = mrControl.createModelFromGuid( aClassId ) )
     104           0 :                     return new AxControlPropertyContext( *this, *pModel );
     105           0 :             break;
     106             : 
     107             :             case XML_persistStreamInit:
     108             :             {
     109           0 :                 OUString aFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     110           0 :                 if( !aFragmentPath.isEmpty() )
     111             :                 {
     112           0 :                     BinaryXInputStream aInStrm( getFilter().openInputStream( aFragmentPath ), true );
     113           0 :                     if( !aInStrm.isEof() )
     114             :                     {
     115             :                         // binary stream contains a copy of the class ID, must be equal to attribute value
     116           0 :                         OUString aStrmClassId = OleHelper::importGuid( aInStrm );
     117             :                         OSL_ENSURE( aClassId.equalsIgnoreAsciiCase( aStrmClassId ),
     118             :                             "AxControlFragment::importBinaryControl - form control class ID mismatch" );
     119           0 :                         if( ControlModelBase* pModel = mrControl.createModelFromGuid( aStrmClassId ) )
     120           0 :                             pModel->importBinaryModel( aInStrm );
     121           0 :                     }
     122           0 :                 }
     123             :             }
     124           0 :             break;
     125             : 
     126             :             case XML_persistStorage:
     127             :             {
     128           0 :                 OUString aFragmentPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
     129           0 :                 if( !aFragmentPath.isEmpty() )
     130             :                 {
     131           0 :                     Reference< XInputStream > xStrgStrm = getFilter().openInputStream( aFragmentPath );
     132           0 :                     if( xStrgStrm.is() )
     133             :                     {
     134           0 :                         OleStorage aStorage( getFilter().getComponentContext(), xStrgStrm, false );
     135           0 :                         BinaryXInputStream aInStrm( aStorage.openInputStream( "f" ), true );
     136           0 :                         if( !aInStrm.isEof() )
     137           0 :                             if( AxContainerModelBase* pModel = dynamic_cast< AxContainerModelBase* >( mrControl.createModelFromGuid( aClassId ) ) )
     138           0 :                                 pModel->importBinaryModel( aInStrm );
     139           0 :                     }
     140           0 :                 }
     141             :             }
     142           0 :             break;
     143           0 :         }
     144             :     }
     145           0 :     return 0;
     146             : }
     147             : 
     148             : 
     149             : 
     150             : } // namespace ole
     151           0 : } // namespace oox
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10