LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/text - XMLTextFrameHyperlinkContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-12-27 Functions: 0 13 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             : 
      21             : #include <sax/tools/converter.hxx>
      22             : 
      23             : #include <xmloff/xmlimp.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include "xmloff/xmlnmspe.hxx"
      26             : #include <xmloff/xmltoken.hxx>
      27             : #include "XMLTextFrameContext.hxx"
      28             : #include "XMLTextFrameHyperlinkContext.hxx"
      29             : 
      30             : // OD 2004-04-21 #i26791#
      31             : #include <txtparaimphint.hxx>
      32             : 
      33             : using ::rtl::OUString;
      34             : using ::rtl::OUStringBuffer;
      35             : 
      36             : using namespace ::com::sun::star::uno;
      37             : using namespace ::com::sun::star::text;
      38             : using namespace ::com::sun::star::xml::sax;
      39             : using namespace ::com::sun::star::beans;
      40             : using namespace ::xmloff::token;
      41             : 
      42           0 : TYPEINIT1( XMLTextFrameHyperlinkContext, SvXMLImportContext );
      43             : 
      44           0 : XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(
      45             :         SvXMLImport& rImport,
      46             :         sal_uInt16 nPrfx, const OUString& rLName,
      47             :         const Reference< XAttributeList > & xAttrList,
      48             :         TextContentAnchorType eATyp ) :
      49             :     SvXMLImportContext( rImport, nPrfx, rLName ),
      50             :     eDefaultAnchorType( eATyp ),
      51           0 :     bMap( sal_False )
      52             : {
      53           0 :     OUString sShow;
      54             :     const SvXMLTokenMap& rTokenMap =
      55           0 :         GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
      56             : 
      57           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      58           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      59             :     {
      60           0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      61           0 :         const OUString& rValue = xAttrList->getValueByIndex( i );
      62             : 
      63           0 :         OUString aLocalName;
      64             :         sal_uInt16 nPrefix =
      65           0 :             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      66           0 :                                                             &aLocalName );
      67           0 :         switch( rTokenMap.Get( nPrefix, aLocalName ) )
      68             :         {
      69             :         case XML_TOK_TEXT_HYPERLINK_HREF:
      70           0 :             sHRef = GetImport().GetAbsoluteReference( rValue );
      71           0 :             break;
      72             :         case XML_TOK_TEXT_HYPERLINK_NAME:
      73           0 :             sName = rValue;
      74           0 :             break;
      75             :         case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
      76           0 :             sTargetFrameName = rValue;
      77           0 :             break;
      78             :         case XML_TOK_TEXT_HYPERLINK_SHOW:
      79           0 :             sShow = rValue;
      80           0 :             break;
      81             :         case XML_TOK_TEXT_HYPERLINK_SERVER_MAP:
      82             :             {
      83           0 :                 bool bTmp(false);
      84           0 :                 if (::sax::Converter::convertBool( bTmp, rValue ))
      85             :                 {
      86           0 :                     bMap = bTmp;
      87             :                 }
      88             :             }
      89           0 :             break;
      90             :         }
      91           0 :     }
      92             : 
      93           0 :     if( !sShow.isEmpty() && sTargetFrameName.isEmpty() )
      94             :     {
      95           0 :         if( IsXMLToken( sShow, XML_NEW ) )
      96             :             sTargetFrameName =
      97           0 :                     OUString( RTL_CONSTASCII_USTRINGPARAM("_blank" ) );
      98           0 :         else if( IsXMLToken( sShow, XML_REPLACE ) )
      99             :             sTargetFrameName =
     100           0 :                     OUString( RTL_CONSTASCII_USTRINGPARAM("_self" ) );
     101           0 :     }
     102           0 : }
     103             : 
     104           0 : XMLTextFrameHyperlinkContext::~XMLTextFrameHyperlinkContext()
     105             : {
     106           0 : }
     107             : 
     108           0 : void XMLTextFrameHyperlinkContext::EndElement()
     109             : {
     110           0 : }
     111             : 
     112           0 : SvXMLImportContext *XMLTextFrameHyperlinkContext::CreateChildContext(
     113             :         sal_uInt16 nPrefix,
     114             :         const OUString& rLocalName,
     115             :         const Reference< XAttributeList > & xAttrList )
     116             : {
     117           0 :     SvXMLImportContext *pContext = 0;
     118           0 :     XMLTextFrameContext *pTextFrameContext = 0;
     119             : 
     120           0 :     if( XML_NAMESPACE_DRAW == nPrefix )
     121             :     {
     122           0 :         if( IsXMLToken( rLocalName, XML_FRAME ) )
     123           0 :             pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
     124             :                                                 rLocalName, xAttrList,
     125           0 :                                                 eDefaultAnchorType );
     126             :     }
     127             : 
     128           0 :     if( pTextFrameContext )
     129             :     {
     130           0 :         pTextFrameContext->SetHyperlink( sHRef, sName, sTargetFrameName, bMap );
     131           0 :         pContext = pTextFrameContext;
     132           0 :         xFrameContext = pContext;
     133             :     }
     134             :     else
     135           0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     136             : 
     137           0 :     return pContext;
     138             : }
     139             : 
     140             : 
     141           0 : TextContentAnchorType XMLTextFrameHyperlinkContext::GetAnchorType() const
     142             : {
     143           0 :     if( xFrameContext.Is() )
     144             :     {
     145           0 :         SvXMLImportContext *pContext = &xFrameContext;
     146           0 :         return PTR_CAST( XMLTextFrameContext, pContext ) ->GetAnchorType();
     147             :     }
     148             :     else
     149           0 :         return eDefaultAnchorType;
     150             : 
     151             : }
     152             : 
     153           0 : Reference < XTextContent > XMLTextFrameHyperlinkContext::GetTextContent() const
     154             : {
     155           0 :     Reference <XTextContent > xTxt;
     156           0 :     if( xFrameContext.Is() )
     157             :     {
     158           0 :         SvXMLImportContext *pContext = &xFrameContext;
     159           0 :         xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
     160             :     }
     161             : 
     162           0 :     return xTxt;
     163             : }
     164             : 
     165             : // Frame "to character": anchor moves from first to last char after saving (#i33242#)
     166           0 : Reference < drawing::XShape > XMLTextFrameHyperlinkContext::GetShape() const
     167             : {
     168           0 :     Reference < drawing::XShape > xShape;
     169           0 :     if( xFrameContext.Is() )
     170             :     {
     171           0 :         SvXMLImportContext *pContext = &xFrameContext;
     172           0 :         xShape = PTR_CAST( XMLTextFrameContext, pContext )->GetShape();
     173             :     }
     174             : 
     175           0 :     return xShape;
     176             : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10