LCOV - code coverage report
Current view: top level - oox/source/drawingml - hyperlinkcontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 71 1.4 %
Date: 2012-08-25 Functions: 2 6 33.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 117 1.7 %

           Branch data     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 "hyperlinkcontext.hxx"
      21                 :            : 
      22                 :            : #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
      23                 :            : 
      24                 :            : #include "oox/helper/propertymap.hxx"
      25                 :            : #include "oox/core/relations.hxx"
      26                 :            : #include "oox/core/xmlfilterbase.hxx"
      27                 :            : #include "oox/drawingml/embeddedwavaudiofile.hxx"
      28                 :            : 
      29                 :            : using ::rtl::OUString;
      30                 :            : using namespace ::oox::core;
      31                 :            : using namespace ::com::sun::star::uno;
      32                 :            : using namespace ::com::sun::star::xml::sax;
      33                 :            : 
      34                 :            : namespace oox {
      35                 :            : namespace drawingml {
      36                 :            : 
      37                 :          0 : HyperLinkContext::HyperLinkContext( ContextHandler& rParent,
      38                 :            :         const Reference< XFastAttributeList >& xAttributes, PropertyMap& aProperties )
      39                 :            :     : ContextHandler( rParent )
      40                 :          0 :     , maProperties(aProperties)
      41                 :            : {
      42                 :          0 :     OUString sURL, sHref;
      43 [ #  # ][ #  # ]:          0 :     OUString aRelId = xAttributes->getOptionalValue( R_TOKEN( id ) );
      44         [ #  # ]:          0 :     if ( !aRelId.isEmpty() )
      45                 :            :     {
      46                 :            :         OSL_TRACE("OOX: URI rId %s", ::rtl::OUStringToOString (aRelId, RTL_TEXTENCODING_UTF8).pData->buffer);
      47 [ #  # ][ #  # ]:          0 :         sHref = getRelations().getExternalTargetFromRelId( aRelId );
      48         [ #  # ]:          0 :         if( !sHref.isEmpty() )
      49                 :            :         {
      50                 :            :             OSL_TRACE("OOX: URI href %s", ::rtl::OUStringToOString (sHref, RTL_TEXTENCODING_UTF8).pData->buffer);
      51 [ #  # ][ #  # ]:          0 :             sURL = getFilter().getAbsoluteUrl( sHref );
      52                 :            :         }
      53                 :            :     }
      54 [ #  # ][ #  # ]:          0 :     OUString sTooltip = xAttributes->getOptionalValue( R_TOKEN( tooltip ) );
      55         [ #  # ]:          0 :     if ( !sTooltip.isEmpty() )
      56 [ #  # ][ #  # ]:          0 :         maProperties[ PROP_Representation ] <<= sTooltip;
      57 [ #  # ][ #  # ]:          0 :     OUString sFrame = xAttributes->getOptionalValue( R_TOKEN( tgtFrame ) );
      58         [ #  # ]:          0 :     if( !sFrame.isEmpty() )
      59 [ #  # ][ #  # ]:          0 :         maProperties[ PROP_TargetFrame ] <<= sFrame;
      60 [ #  # ][ #  # ]:          0 :     OUString aAction = xAttributes->getOptionalValue( XML_action );
      61         [ #  # ]:          0 :     if ( !aAction.isEmpty() )
      62                 :            :     {
      63                 :            :         // reserved values of the unrestricted string aAction:
      64                 :            :         // ppaction://customshow?id=SHOW_ID             // custom presentation
      65                 :            :         // ppaction://hlinkfile                         // external file via r:id
      66                 :            :         // ppaction://hlinkpres?slideindex=SLIDE_NUM    // external presentation via r:id
      67                 :            :         // ppaction://hlinkshowjump?jump=endshow
      68                 :            :         // ppaction://hlinkshowjump?jump=firstslide
      69                 :            :         // ppaction://hlinkshowjump?jump=lastslide
      70                 :            :         // ppaction://hlinkshowjump?jump=lastslideviewed
      71                 :            :         // ppaction://hlinkshowjump?jump=nextslide
      72                 :            :         // ppaction://hlinkshowjump?jump=previousslide
      73                 :            :         // ppaction://hlinksldjump
      74                 :            :         // ppaction://macro?name=MACRO_NAME
      75                 :            :         // ppaction://program
      76                 :            : 
      77         [ #  # ]:          0 :         const OUString sPPAction( CREATE_OUSTRING( "ppaction://" ) );
      78         [ #  # ]:          0 :         if ( aAction.matchIgnoreAsciiCase( sPPAction, 0 ) )
      79                 :            :         {
      80                 :          0 :             OUString aPPAct( aAction.copy( sPPAction.getLength() ) );
      81                 :          0 :             sal_Int32 nIndex = aPPAct.indexOf( '?', 0 );
      82         [ #  # ]:          0 :             OUString aPPAction( nIndex > 0 ? aPPAct.copy( 0, nIndex ) : aPPAct );
      83                 :            : 
      84         [ #  # ]:          0 :             const OUString sHlinkshowjump( CREATE_OUSTRING( "hlinkshowjump" ) );
      85         [ #  # ]:          0 :             const OUString sHlinksldjump( CREATE_OUSTRING( "hlinksldjump" ) );
      86         [ #  # ]:          0 :             if ( aPPAction.match( sHlinkshowjump ) )
      87                 :            :             {
      88         [ #  # ]:          0 :                 const OUString sJump( CREATE_OUSTRING( "jump=" ) );
      89         [ #  # ]:          0 :                 if ( aPPAct.match( sJump, nIndex + 1 ) )
      90                 :            :                 {
      91                 :          0 :                     OUString aDestination( aPPAct.copy( nIndex + 1 + sJump.getLength() ) );
      92         [ #  # ]:          0 :                     sURL = sURL.concat( CREATE_OUSTRING( "#action?jump=" ) );
      93                 :          0 :                     sURL = sURL.concat( aDestination );
      94                 :          0 :                 }
      95                 :            :             }
      96         [ #  # ]:          0 :             else if ( aPPAction.match( sHlinksldjump ) )
      97                 :            :             {
      98                 :          0 :                 sURL = OUString();
      99                 :            : 
     100                 :          0 :                 sal_Int32 nIndex2 = 0;
     101         [ #  # ]:          0 :                 while ( nIndex2 < sHref.getLength() )
     102                 :            :                 {
     103                 :          0 :                     sal_Unicode nChar = sHref[ nIndex2 ];
     104 [ #  # ][ #  # ]:          0 :                     if ( ( nChar >= '0' ) && ( nChar <= '9' ) )
     105                 :          0 :                         break;
     106                 :          0 :                     nIndex2++;
     107                 :            :                 }
     108 [ #  # ][ #  # ]:          0 :                 if ( nIndex2 && ( nIndex2 != sHref.getLength() ) )
                 [ #  # ]
     109                 :            :                 {
     110                 :          0 :                     sal_Int32 nLength = 1;
     111         [ #  # ]:          0 :                     while( ( nIndex2 + nLength ) < sHref.getLength() )
     112                 :            :                     {
     113                 :          0 :                         sal_Unicode nChar = sHref[ nIndex2 + nLength ];
     114 [ #  # ][ #  # ]:          0 :                         if ( ( nChar < '0' ) || ( nChar > '9' ) )
     115                 :          0 :                             break;
     116                 :          0 :                         nLength++;
     117                 :            :                     }
     118                 :          0 :                     sal_Int32 nPageNumber = sHref.copy( nIndex2, nLength ).toInt32();
     119         [ #  # ]:          0 :                     if ( nPageNumber )
     120                 :            :                     {
     121         [ #  # ]:          0 :                         const OUString sSlide( CREATE_OUSTRING( "slide" ) );
     122         [ #  # ]:          0 :                         const OUString sNotesSlide( CREATE_OUSTRING( "notesSlide" ) );
     123                 :          0 :                         const OUString aSlideType( sHref.copy( 0, nIndex2 ) );
     124         [ #  # ]:          0 :                         if ( aSlideType.match( sSlide ) )
     125         [ #  # ]:          0 :                             sURL = CREATE_OUSTRING( "#Slide " ).concat( rtl::OUString::valueOf( nPageNumber ) );
     126         [ #  # ]:          0 :                         else if ( aSlideType.match( sNotesSlide ) )
     127         [ #  # ]:          0 :                             sURL = CREATE_OUSTRING( "#Notes " ).concat( rtl::OUString::valueOf( nPageNumber ) );
     128                 :            : //                      else: todo for other types such as notesMaster or slideMaster as they can't be referenced easily
     129                 :            :                     }
     130                 :            :                 }
     131                 :          0 :             }
     132                 :          0 :         }
     133                 :            :     }
     134         [ #  # ]:          0 :     if ( !sURL.isEmpty() )
     135 [ #  # ][ #  # ]:          0 :         maProperties[ PROP_URL ] <<= sURL;
     136                 :            : 
     137                 :            :     // TODO unhandled
     138                 :            :     // XML_invalidUrl
     139                 :            :     // XML_history
     140                 :            :     // XML_highlightClick
     141                 :            :     // XML_endSnd
     142                 :          0 : }
     143                 :            : 
     144                 :          0 : HyperLinkContext::~HyperLinkContext()
     145                 :            : {
     146         [ #  # ]:          0 : }
     147                 :            : 
     148                 :          0 : Reference< XFastContextHandler > HyperLinkContext::createFastChildContext(
     149                 :            :         ::sal_Int32 aElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     150                 :            : {
     151                 :          0 :     Reference< XFastContextHandler > xRet;
     152      [ #  #  # ]:          0 :     switch( aElement )
     153                 :            :     {
     154                 :            :     case A_TOKEN( extLst ):
     155                 :            :         return xRet;
     156                 :            :     case A_TOKEN( snd ):
     157                 :          0 :         EmbeddedWAVAudioFile aAudio;
     158 [ #  # ][ #  # ]:          0 :         getEmbeddedWAVAudioFile( getRelations(), xAttribs, aAudio );
     159                 :          0 :         break;
     160                 :            :     }
     161         [ #  # ]:          0 :     if ( !xRet.is() )
     162         [ #  # ]:          0 :         xRet.set( this );
     163                 :          0 :     return xRet;
     164                 :            : }
     165                 :            : 
     166                 :            : } // namespace drawingml
     167 [ +  - ][ +  - ]:        285 : } // namespace oox
     168                 :            : 
     169                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10