LCOV - code coverage report
Current view: top level - xmlhelp/source/cxxhelp/provider - urlparameter.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 8 50 16.0 %
Date: 2014-04-11 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 _URLPARAMETER_HXX_
      21             : #define _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             : 
      47           0 :         OUString getHash()
      48             :         {
      49           0 :             if( m_ptr )
      50             :             {
      51           0 :                 sal_Int32 sizeOfFile = ( sal_Int32 ) m_ptr[0];
      52           0 :                 OUString Hash( m_ptr+1,sizeOfFile,RTL_TEXTENCODING_UTF8 );
      53             :                 sal_Int32 idx;
      54           0 :                 if( ( idx = Hash.indexOf( sal_Unicode( '#' ) ) ) != -1 )
      55           0 :                     return Hash.copy( 1+idx );
      56             :             }
      57           0 :             return OUString();
      58             :         }
      59             : 
      60             : 
      61           0 :         OUString getFile()
      62             :         {
      63           0 :             if( ! m_ptr )
      64           0 :                 return OUString();
      65             : 
      66           0 :             sal_Int32 sizeOfFile = ( sal_Int32 ) m_ptr[0];
      67           0 :             OUString File( m_ptr+1,sizeOfFile,RTL_TEXTENCODING_UTF8 );
      68             :             sal_Int32 idx;
      69           0 :             if( ( idx = File.indexOf( sal_Unicode( '#' ) ) ) != -1 )
      70           0 :                 return File.copy( 0,idx );
      71             :             else
      72           0 :                 return File;
      73             :         }
      74             : 
      75             : 
      76           0 :         OUString getDatabase()
      77             :         {
      78           0 :             if( ! m_ptr )
      79           0 :                 return OUString();
      80             : 
      81           0 :             sal_Int32 sizeOfDatabase = ( int ) m_ptr[ 1+ ( sal_Int32 ) m_ptr[0] ];
      82           0 :             return OUString( m_ptr + 2 + ( sal_Int32 ) m_ptr[0],sizeOfDatabase,RTL_TEXTENCODING_UTF8 );
      83             :         }
      84             : 
      85             : 
      86           0 :         OUString getTitle()
      87             :         {
      88           0 :             if( ! m_ptr )
      89           0 :                 return OUString();
      90             : 
      91             :             sal_Int32 sizeOfTitle =
      92           0 :                 ( sal_Int32 ) m_ptr[  2 + m_ptr[0] +  ( sal_Int32 ) m_ptr[ 1+ ( sal_Int32 ) m_ptr[0] ] ];
      93           0 :             return OUString( m_ptr + 3 + m_ptr[0] +  ( sal_Int32 ) m_ptr[ 1+ ( sal_Int32 ) m_ptr[0] ],
      94             :                                   sizeOfTitle,
      95           0 :                                   RTL_TEXTENCODING_UTF8 );
      96             :         }
      97             : 
      98             : 
      99             :     private:
     100             : 
     101             :         const sal_Char* m_ptr;
     102             : 
     103             :     };
     104             : 
     105             : 
     106             : 
     107             : 
     108         633 :     class URLParameter
     109             :     {
     110             :     public:
     111             : 
     112             :         URLParameter( const OUString& aURL,
     113             :                       Databases* pDatabases )
     114             :             throw( com::sun::star::ucb::IllegalIdentifierException );
     115             : 
     116         375 :         bool isPicture() const { return m_aModule == "picture"; }
     117         375 :         bool isActive() const { return !m_aActive.isEmpty() && m_aActive == "true"; }
     118         375 :         bool isQuery() const { return m_aId.isEmpty() && !m_aQuery.isEmpty(); }
     119             :         bool isEntryForModule() const { return m_aId == "start" || m_bStart; }
     120         869 :         bool isFile() const { return !m_aId.isEmpty(); }
     121         247 :         bool isModule() const { return m_aId.isEmpty() && !m_aModule.isEmpty(); }
     122         752 :         bool isRoot() const { return m_aModule.isEmpty(); }
     123             :         bool isErrorDocument();
     124             : 
     125             :         OUString get_url() const { return m_aURL; }
     126             : 
     127             :         OUString get_id();
     128             : 
     129             :         OUString get_tag();
     130             : 
     131             :         //  Not called for an directory
     132             : 
     133           0 :         OUString get_path()   { return get_the_path(); }
     134             : 
     135           0 :         OUString get_eid() const   { return m_aEid; }
     136             : 
     137             :         OUString get_title();
     138             : 
     139           0 :         OUString get_jar()      { return get_the_jar(); }
     140             : 
     141           0 :         OUString get_ExtensionRegistryPath() const { return m_aExtensionRegistryPath; }
     142             : 
     143         750 :         OUString get_module() const { return m_aModule; }
     144             : 
     145           0 :         OUString get_dbpar() const
     146             :         {
     147           0 :             if( !m_aDbPar.isEmpty() )
     148           0 :                 return m_aDbPar;
     149             :             else
     150           0 :                 return m_aModule;
     151             :         }
     152             : 
     153           0 :         OUString get_prefix() const { return m_aPrefix; }
     154             : 
     155             :         OUString get_language();
     156             : 
     157             :         OUString get_device() const { return m_aDevice; }
     158             : 
     159             :         OUString get_program();
     160             : 
     161           0 :         OUString get_query() const { return m_aQuery; }
     162             : 
     163           0 :         OUString get_scope() const { return m_aScope; }
     164             : 
     165           0 :         OUString get_system() const { return m_aSystem; }
     166             : 
     167           0 :         sal_Int32     get_hitCount() const { return m_nHitCount; }
     168             : 
     169             :         OString getByName( const char* par );
     170             : 
     171             :         void open( const com::sun::star::ucb::Command& aCommand,
     172             :                    sal_Int32 CommandId,
     173             :                    const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment,
     174             :                    const com::sun::star::uno::Reference< com::sun::star::io::XActiveDataSink >& xDataSink );
     175             : 
     176             :         void open( const com::sun::star::ucb::Command& aCommand,
     177             :                    sal_Int32 CommandId,
     178             :                    const com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment >& Environment,
     179             :                    const com::sun::star::uno::Reference< com::sun::star::io::XOutputStream >& xDataSink );
     180             : 
     181             :     private:
     182             : 
     183             :         Databases* m_pDatabases;
     184             : 
     185             :         bool m_bHelpDataFileRead;
     186             :         bool m_bStart;
     187             :         bool m_bUseDB;
     188             : 
     189             :         OUString  m_aURL;
     190             : 
     191             :         OUString  m_aTag;
     192             :         OUString  m_aId;
     193             :         OUString  m_aPath;
     194             :         OUString  m_aModule;
     195             :         OUString  m_aTitle;
     196             :         OUString  m_aJar;
     197             :         OUString  m_aExtensionRegistryPath;
     198             :         OUString  m_aEid;
     199             :         OUString  m_aDbPar;
     200             : 
     201             :         OUString  m_aDefaultLanguage;
     202             :         OUString  m_aLanguage;
     203             : 
     204             :         OUString  m_aPrefix;
     205             :         OUString  m_aDevice;
     206             :         OUString  m_aProgram;
     207             :         OUString  m_aSystem;
     208             :         OUString  m_aActive;
     209             : 
     210             :         OUString  m_aQuery;
     211             :         OUString  m_aScope;
     212             : 
     213             :         OUString m_aExpr;
     214             : 
     215             :         sal_Int32      m_nHitCount;                // The default maximum hitcount
     216             : 
     217             : 
     218             :         // private methods
     219             : 
     220             :         void init( bool bDefaultLanguageIsInitialized );
     221             : 
     222             :         OUString get_the_tag();
     223             : 
     224             :         OUString get_the_path();
     225             : 
     226             :         OUString get_the_title();
     227             : 
     228             :         OUString get_the_jar();
     229             : 
     230             :         void readHelpDataFile();
     231             : 
     232             :         void parse() throw( com::sun::star::ucb::IllegalIdentifierException );
     233             : 
     234             :         bool scheme();
     235             : 
     236             :         bool module();
     237             : 
     238             :         bool name( bool modulePresent );
     239             : 
     240             :         bool query();
     241             : 
     242             :     };   // end class URLParameter
     243             : 
     244             : 
     245             : }  // end namespace chelp
     246             : 
     247             : #endif
     248             : 
     249             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10