LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLTextFrameHyperlinkContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-08-25 Functions: 0 13 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 110 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <sax/tools/converter.hxx>
      31                 :            : 
      32                 :            : #include <xmloff/xmlimp.hxx>
      33                 :            : #include <xmloff/nmspmap.hxx>
      34                 :            : #include "xmloff/xmlnmspe.hxx"
      35                 :            : #include <xmloff/xmltoken.hxx>
      36                 :            : #include "XMLTextFrameContext.hxx"
      37                 :            : #include "XMLTextFrameHyperlinkContext.hxx"
      38                 :            : 
      39                 :            : // OD 2004-04-21 #i26791#
      40                 :            : #include <txtparaimphint.hxx>
      41                 :            : 
      42                 :            : using ::rtl::OUString;
      43                 :            : using ::rtl::OUStringBuffer;
      44                 :            : 
      45                 :            : using namespace ::com::sun::star::uno;
      46                 :            : using namespace ::com::sun::star::text;
      47                 :            : using namespace ::com::sun::star::xml::sax;
      48                 :            : using namespace ::com::sun::star::beans;
      49                 :            : using namespace ::xmloff::token;
      50                 :            : 
      51 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLTextFrameHyperlinkContext, SvXMLImportContext );
      52                 :            : 
      53                 :          0 : XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(
      54                 :            :         SvXMLImport& rImport,
      55                 :            :         sal_uInt16 nPrfx, const OUString& rLName,
      56                 :            :         const Reference< XAttributeList > & xAttrList,
      57                 :            :         TextContentAnchorType eATyp ) :
      58                 :            :     SvXMLImportContext( rImport, nPrfx, rLName ),
      59                 :            :     eDefaultAnchorType( eATyp ),
      60                 :          0 :     bMap( sal_False )
      61                 :            : {
      62                 :          0 :     OUString sShow;
      63                 :            :     const SvXMLTokenMap& rTokenMap =
      64 [ #  # ][ #  # ]:          0 :         GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
         [ #  # ][ #  # ]
      65                 :            : 
      66 [ #  # ][ #  # ]:          0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ #  # ]
      67         [ #  # ]:          0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      68                 :            :     {
      69 [ #  # ][ #  # ]:          0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      70 [ #  # ][ #  # ]:          0 :         const OUString& rValue = xAttrList->getValueByIndex( i );
      71                 :            : 
      72                 :          0 :         OUString aLocalName;
      73                 :            :         sal_uInt16 nPrefix =
      74                 :          0 :             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      75         [ #  # ]:          0 :                                                             &aLocalName );
      76 [ #  # ][ #  #  :          0 :         switch( rTokenMap.Get( nPrefix, aLocalName ) )
             #  #  #  # ]
      77                 :            :         {
      78                 :            :         case XML_TOK_TEXT_HYPERLINK_HREF:
      79         [ #  # ]:          0 :             sHRef = GetImport().GetAbsoluteReference( rValue );
      80                 :          0 :             break;
      81                 :            :         case XML_TOK_TEXT_HYPERLINK_NAME:
      82                 :          0 :             sName = rValue;
      83                 :          0 :             break;
      84                 :            :         case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
      85                 :          0 :             sTargetFrameName = rValue;
      86                 :          0 :             break;
      87                 :            :         case XML_TOK_TEXT_HYPERLINK_SHOW:
      88                 :          0 :             sShow = rValue;
      89                 :          0 :             break;
      90                 :            :         case XML_TOK_TEXT_HYPERLINK_SERVER_MAP:
      91                 :            :             {
      92                 :          0 :                 bool bTmp(false);
      93 [ #  # ][ #  # ]:          0 :                 if (::sax::Converter::convertBool( bTmp, rValue ))
      94                 :            :                 {
      95                 :          0 :                     bMap = bTmp;
      96                 :            :                 }
      97                 :            :             }
      98                 :          0 :             break;
      99                 :            :         }
     100                 :          0 :     }
     101                 :            : 
     102 [ #  # ][ #  # ]:          0 :     if( !sShow.isEmpty() && sTargetFrameName.isEmpty() )
                 [ #  # ]
     103                 :            :     {
     104 [ #  # ][ #  # ]:          0 :         if( IsXMLToken( sShow, XML_NEW ) )
     105                 :            :             sTargetFrameName =
     106         [ #  # ]:          0 :                     OUString( RTL_CONSTASCII_USTRINGPARAM("_blank" ) );
     107 [ #  # ][ #  # ]:          0 :         else if( IsXMLToken( sShow, XML_REPLACE ) )
     108                 :            :             sTargetFrameName =
     109         [ #  # ]:          0 :                     OUString( RTL_CONSTASCII_USTRINGPARAM("_self" ) );
     110                 :          0 :     }
     111                 :          0 : }
     112                 :            : 
     113         [ #  # ]:          0 : XMLTextFrameHyperlinkContext::~XMLTextFrameHyperlinkContext()
     114                 :            : {
     115         [ #  # ]:          0 : }
     116                 :            : 
     117                 :          0 : void XMLTextFrameHyperlinkContext::EndElement()
     118                 :            : {
     119                 :          0 : }
     120                 :            : 
     121                 :          0 : SvXMLImportContext *XMLTextFrameHyperlinkContext::CreateChildContext(
     122                 :            :         sal_uInt16 nPrefix,
     123                 :            :         const OUString& rLocalName,
     124                 :            :         const Reference< XAttributeList > & xAttrList )
     125                 :            : {
     126                 :          0 :     SvXMLImportContext *pContext = 0;
     127                 :          0 :     XMLTextFrameContext *pTextFrameContext = 0;
     128                 :            : 
     129         [ #  # ]:          0 :     if( XML_NAMESPACE_DRAW == nPrefix )
     130                 :            :     {
     131         [ #  # ]:          0 :         if( IsXMLToken( rLocalName, XML_FRAME ) )
     132                 :          0 :             pTextFrameContext = new XMLTextFrameContext( GetImport(), nPrefix,
     133                 :            :                                                 rLocalName, xAttrList,
     134         [ #  # ]:          0 :                                                 eDefaultAnchorType );
     135                 :            :     }
     136                 :            : 
     137         [ #  # ]:          0 :     if( pTextFrameContext )
     138                 :            :     {
     139                 :          0 :         pTextFrameContext->SetHyperlink( sHRef, sName, sTargetFrameName, bMap );
     140                 :          0 :         pContext = pTextFrameContext;
     141                 :          0 :         xFrameContext = pContext;
     142                 :            :     }
     143                 :            :     else
     144         [ #  # ]:          0 :         pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
     145                 :            : 
     146                 :          0 :     return pContext;
     147                 :            : }
     148                 :            : 
     149                 :            : 
     150                 :          0 : TextContentAnchorType XMLTextFrameHyperlinkContext::GetAnchorType() const
     151                 :            : {
     152         [ #  # ]:          0 :     if( xFrameContext.Is() )
     153                 :            :     {
     154                 :          0 :         SvXMLImportContext *pContext = &xFrameContext;
     155 [ #  # ][ #  # ]:          0 :         return PTR_CAST( XMLTextFrameContext, pContext ) ->GetAnchorType();
     156                 :            :     }
     157                 :            :     else
     158                 :          0 :         return eDefaultAnchorType;
     159                 :            : 
     160                 :            : }
     161                 :            : 
     162                 :          0 : Reference < XTextContent > XMLTextFrameHyperlinkContext::GetTextContent() const
     163                 :            : {
     164                 :          0 :     Reference <XTextContent > xTxt;
     165         [ #  # ]:          0 :     if( xFrameContext.Is() )
     166                 :            :     {
     167                 :          0 :         SvXMLImportContext *pContext = &xFrameContext;
     168 [ #  # ][ #  # ]:          0 :         xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     169                 :            :     }
     170                 :            : 
     171                 :          0 :     return xTxt;
     172                 :            : }
     173                 :            : 
     174                 :            : // Frame "to character": anchor moves from first to last char after saving (#i33242#)
     175                 :          0 : Reference < drawing::XShape > XMLTextFrameHyperlinkContext::GetShape() const
     176                 :            : {
     177                 :          0 :     Reference < drawing::XShape > xShape;
     178         [ #  # ]:          0 :     if( xFrameContext.Is() )
     179                 :            :     {
     180                 :          0 :         SvXMLImportContext *pContext = &xFrameContext;
     181 [ #  # ][ #  # ]:          0 :         xShape = PTR_CAST( XMLTextFrameContext, pContext )->GetShape();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     182                 :            :     }
     183                 :            : 
     184                 :          0 :     return xShape;
     185                 :            : }
     186                 :            : 
     187                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10