LCOV - code coverage report
Current view: top level - oox/source/core - relationshandler.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 27 0.0 %
Date: 2014-04-14 Functions: 0 3 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/core/relationshandler.hxx"
      21             : 
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include "oox/helper/attributelist.hxx"
      24             : 
      25             : namespace oox {
      26             : namespace core {
      27             : 
      28             : 
      29             : 
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::xml::sax;
      32             : 
      33             : 
      34             : 
      35             : 
      36             : namespace {
      37             : 
      38             : /*  Build path to relations file from passed fragment path, e.g.:
      39             :         'path/path/file.xml'    -> 'path/path/_rels/file.xml.rels'
      40             :         'file.xml'              -> '_rels/file.xml.rels'
      41             :         ''                      -> '_rels/.rels'
      42             :  */
      43           0 : OUString lclGetRelationsPath( const OUString& rFragmentPath )
      44             : {
      45           0 :     sal_Int32 nPathLen = ::std::max< sal_Int32 >( rFragmentPath.lastIndexOf( '/' ) + 1, 0 );
      46             :     return
      47             :         OUStringBuffer( rFragmentPath.copy( 0, nPathLen ) ).    // file path including slash
      48           0 :         appendAscii( "_rels/" ).                                // additional '_rels/' path
      49           0 :         append( rFragmentPath.copy( nPathLen ) ).               // file name after path
      50           0 :         appendAscii( ".rels" ).                                 // '.rels' suffix
      51           0 :         makeStringAndClear();
      52             : }
      53             : 
      54             : } // namespace
      55             : 
      56             : 
      57             : 
      58           0 : RelationsFragment::RelationsFragment( XmlFilterBase& rFilter, RelationsRef xRelations ) :
      59           0 :     FragmentHandler( rFilter, lclGetRelationsPath( xRelations->getFragmentPath() ), xRelations ),
      60           0 :     mxRelations( xRelations )
      61             : {
      62           0 : }
      63             : 
      64           0 : Reference< XFastContextHandler > RelationsFragment::createFastChildContext(
      65             :         sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw (SAXException, RuntimeException, std::exception)
      66             : {
      67           0 :     Reference< XFastContextHandler > xRet;
      68           0 :     AttributeList aAttribs( rxAttribs );
      69           0 :     switch( nElement )
      70             :     {
      71             :         case PR_TOKEN( Relationship ):
      72             :         {
      73           0 :             Relation aRelation;
      74           0 :             aRelation.maId     = aAttribs.getString( XML_Id, OUString() );
      75           0 :             aRelation.maType   = aAttribs.getString( XML_Type, OUString() );
      76           0 :             aRelation.maTarget = aAttribs.getString( XML_Target, OUString() );
      77           0 :             if( !aRelation.maId.isEmpty() && !aRelation.maType.isEmpty() && !aRelation.maTarget.isEmpty() )
      78             :             {
      79           0 :                 sal_Int32 nTargetMode = aAttribs.getToken( XML_TargetMode, XML_Internal );
      80             :                 OSL_ENSURE( (nTargetMode == XML_Internal) || (nTargetMode == XML_External),
      81             :                     "RelationsFragment::createFastChildContext - unexpected target mode, assuming external" );
      82           0 :                 aRelation.mbExternal = nTargetMode != XML_Internal;
      83             : 
      84             :                 OSL_ENSURE( mxRelations->count( aRelation.maId ) == 0,
      85             :                     "RelationsFragment::createFastChildContext - relation identifier exists already" );
      86           0 :                 mxRelations->insert( Relations::value_type( aRelation.maId, aRelation ) );
      87           0 :             }
      88             :         }
      89           0 :         break;
      90             :         case PR_TOKEN( Relationships ):
      91           0 :             xRet = getFastContextHandler();
      92           0 :         break;
      93             :     }
      94           0 :     return xRet;
      95             : }
      96             : 
      97             : 
      98             : 
      99             : } // namespace core
     100             : } // namespace oox
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10