LCOV - code coverage report
Current view: top level - xmlhelp/source/cxxhelp/provider - urlparameter.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 8 49 16.3 %
Date: 2014-11-03 Functions: 9 24 37.5 %
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             : #ifndef INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_URLPARAMETER_HXX
      21             : #define INCLUDED_XMLHELP_SOURCE_CXXHELP_PROVIDER_URLPARAMETER_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <rtl/string.hxx>
      25             : #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
      26             : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      27             : #include <com/sun/star/io/XActiveDataSink.hpp>
      28             : #include <com/sun/star/io/XOutputStream.hpp>
      29             : #include <com/sun/star/ucb/Command.hpp>
      30             : 
      31             : namespace chelp {
      32             : 
      33             : 
      34             :     class Databases;
      35             : 
      36             : 
      37             :     class DbtToStringConverter
      38             :     {
      39             :     public:
      40             : 
      41           0 :         DbtToStringConverter( const sal_Char* ptr )
      42           0 :             : m_ptr( ptr )
      43             :         {
      44           0 :         }
      45             : 
      46           0 :         OUString getHash()
      47             :         {
      48           0 :             if( m_ptr )
      49             :             {
      50           0 :                 sal_Int32 sizeOfFile = ( sal_Int32 ) m_ptr[0];
      51           0 :                 OUString Hash( m_ptr+1,sizeOfFile,RTL_TEXTENCODING_UTF8 );
      52             :                 sal_Int32 idx;
      53           0 :                 if( ( idx = Hash.indexOf( sal_Unicode( '#' ) ) ) != -1 )
      54           0 :                     return Hash.copy( 1+idx );
      55             :             }
      56           0 :             return OUString();
      57             :         }
      58             : 
      59             : 
      60           0 :         OUString getFile()
      61             :         {
      62           0 :             if( ! m_ptr )
      63           0 :                 return OUString();
      64             : 
      65           0 :             sal_Int32 sizeOfFile = ( sal_Int32 ) m_ptr[0];
      66           0 :             OUString File( m_ptr+1,sizeOfFile,RTL_TEXTENCODING_UTF8 );
      67             :             sal_Int32 idx;
      68           0 :             if( ( idx = File.indexOf( sal_Unicode( '#' ) ) ) != -1 )
      69           0 :                 return File.copy( 0,idx );
      70             :             else
      71           0 :                 return File;
      72             :         }
      73             : 
      74             : 
      75           0 :         OUString getDatabase()
      76             :         {
      77           0 :             if( ! m_ptr )
      78           0 :                 return OUString();
      79             : 
      80           0 :             sal_Int32 sizeOfDatabase = ( int ) m_ptr[ 1+ ( sal_Int32 ) m_ptr[0] ];
      81           0 :             return OUString( m_ptr + 2 + ( sal_Int32 ) m_ptr[0],sizeOfDatabase,RTL_TEXTENCODING_UTF8 );
      82             :         }
      83             : 
      84             : 
      85           0 :         OUString getTitle()
      86             :         {
      87           0 :             if( ! m_ptr )
      88           0 :                 return OUString();
      89             : 
      90             :             //fdo#82025 - use strlen instead of stored length byte to determine string len
      91             :             //There is a one byte length field at m_ptr[2 + m_ptr[0] +  m_ptr[1
      92             :             //+ m_ptr[0]]] but by default sal_Char is signed so anything larger
      93             :             //than 127 defaults to a negative value, casting it would allow up
      94             :             //to 255 but instead make use of the null termination to avoid
      95             :             //running into a later problem with strings >= 255
      96           0 :             const sal_Char* pTitle = m_ptr + 3 + m_ptr[0] +  ( sal_Int32 ) m_ptr[ 1+ ( sal_Int32 ) m_ptr[0] ];
      97             : 
      98           0 :             return OUString(pTitle, rtl_str_getLength(pTitle), RTL_TEXTENCODING_UTF8);
      99             :         }
     100             : 
     101             : 
     102             :     private:
     103             : 
     104             :         const sal_Char* m_ptr;
     105             : 
     106             :     };
     107             : 
     108             : 
     109             : 
     110             : 
     111        5294 :     class URLParameter
     112             :     {
     113             :     public:
     114             : 
     115             :         URLParameter( const OUString& aURL,
     116             :                       Databases* pDatabases )
     117             :             throw( com::sun::star::ucb::IllegalIdentifierException );
     118             : 
     119        2908 :         bool isPicture() const { return m_aModule == "picture"; }
     120        2908 :         bool isActive() const { return !m_aActive.isEmpty() && m_aActive == "true"; }
     121        2908 :         bool isQuery() const { return m_aId.isEmpty() && !m_aQuery.isEmpty(); }
     122             :         bool isEntryForModule() const { return m_aId == "start" || m_bStart; }
     123        7336 :         bool isFile() const { return !m_aId.isEmpty(); }
     124        2214 :         bool isModule() const { return m_aId.isEmpty() && !m_aModule.isEmpty(); }
     125        5850 :         bool isRoot() const { return m_aModule.isEmpty(); }
     126             :         bool isErrorDocument();
     127             : 
     128             :         OUString get_url() const { return m_aURL; }
     129             : 
     130             :         OUString get_id();
     131             : 
     132             :         OUString get_tag();
     133             : 
     134             :         //  Not called for an directory
     135             : 
     136           0 :         OUString get_path()   { return get_the_path(); }
     137             : 
     138           0 :         OUString get_eid() const   { return m_aEid; }
     139             : 
     140             :         OUString get_title();
     141             : 
     142           0 :         OUString get_jar()      { return get_the_jar(); }
     143             : 
     144           0 :         OUString get_ExtensionRegistryPath() const { return m_aExtensionRegistryPath; }
     145             : 
     146        5816 :         OUString get_module() const { return m_aModule; }
     147             : 
     148           0 :         OUString get_dbpar() const
     149             :         {
     150           0 :             if( !m_aDbPar.isEmpty() )
     151           0 :                 return m_aDbPar;
     152             :             else
     153           0 :                 return m_aModule;
     154             :         }
     155             : 
     156           0 :         OUString get_prefix() const { return m_aPrefix; }
     157             : 
     158             :         OUString get_language();
     159             : 
     160             :         OUString get_device() const { return m_aDevice; }
     161             : 
     162             :         OUString get_program();
     163             : 
     164           0 :         OUString get_query() const { return m_aQuery; }
     165             : 
     166           0 :         OUString get_scope() const { return m_aScope; }
     167             : 
     168           0 :         OUString get_system() const { return m_aSystem; }
     169             : 
     170           0 :         sal_Int32     get_hitCount() const { return m_nHitCount; }
     171             : 
     172             :         OString getByName( const char* par );
     173             : 
     174             :         void open( const com::sun::star::ucb::Command& aCommand,
     175             :                    sal_Int32 CommandId,
     176             :                    const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment,
     177             :                    const com::sun::star::uno::Reference< com::sun::star::io::XActiveDataSink >& xDataSink );
     178             : 
     179             :         void open( const com::sun::star::ucb::Command& aCommand,
     180             :                    sal_Int32 CommandId,
     181             :                    const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment,
     182             :                    const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xDataSink );
     183             : 
     184             :     private:
     185             : 
     186             :         Databases* m_pDatabases;
     187             : 
     188             :         bool m_bHelpDataFileRead;
     189             :         bool m_bStart;
     190             :         bool m_bUseDB;
     191             : 
     192             :         OUString  m_aURL;
     193             : 
     194             :         OUString  m_aTag;
     195             :         OUString  m_aId;
     196             :         OUString  m_aPath;
     197             :         OUString  m_aModule;
     198             :         OUString  m_aTitle;
     199             :         OUString  m_aJar;
     200             :         OUString  m_aExtensionRegistryPath;
     201             :         OUString  m_aEid;
     202             :         OUString  m_aDbPar;
     203             : 
     204             :         OUString  m_aDefaultLanguage;
     205             :         OUString  m_aLanguage;
     206             : 
     207             :         OUString  m_aPrefix;
     208             :         OUString  m_aDevice;
     209             :         OUString  m_aProgram;
     210             :         OUString  m_aSystem;
     211             :         OUString  m_aActive;
     212             : 
     213             :         OUString  m_aQuery;
     214             :         OUString  m_aScope;
     215             : 
     216             :         OUString m_aExpr;
     217             : 
     218             :         sal_Int32      m_nHitCount;                // The default maximum hitcount
     219             : 
     220             : 
     221             :         // private methods
     222             : 
     223             :         void init( bool bDefaultLanguageIsInitialized );
     224             : 
     225             :         OUString get_the_tag();
     226             : 
     227             :         OUString get_the_path();
     228             : 
     229             :         OUString get_the_title();
     230             : 
     231             :         OUString get_the_jar();
     232             : 
     233             :         void readHelpDataFile();
     234             : 
     235             :         void parse() throw( com::sun::star::ucb::IllegalIdentifierException );
     236             : 
     237             :         bool scheme();
     238             : 
     239             :         bool module();
     240             : 
     241             :         bool name( bool modulePresent );
     242             : 
     243             :         bool query();
     244             : 
     245             :     };   // end class URLParameter
     246             : 
     247             : 
     248             : }  // end namespace chelp
     249             : 
     250             : #endif
     251             : 
     252             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10