LCOV - code coverage report
Current view: top level - libreoffice/xmlhelp/source/cxxhelp/provider - urlparameter.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 50 0.0 %
Date: 2012-12-27 Functions: 0 24 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             : #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 :         rtl::OUString getHash()
      48             :         {
      49           0 :             if( m_ptr )
      50             :             {
      51           0 :                 sal_Int32 sizeOfFile = ( sal_Int32 ) m_ptr[0];
      52           0 :                 rtl::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 rtl::OUString();
      58             :         }
      59             : 
      60             : 
      61           0 :         rtl::OUString getFile()
      62             :         {
      63           0 :             if( ! m_ptr )
      64           0 :                 return rtl::OUString();
      65             : 
      66           0 :             sal_Int32 sizeOfFile = ( sal_Int32 ) m_ptr[0];
      67           0 :             rtl::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 :         rtl::OUString getDatabase()
      77             :         {
      78           0 :             if( ! m_ptr )
      79           0 :                 return rtl::OUString();
      80             : 
      81           0 :             sal_Int32 sizeOfDatabase = ( int ) m_ptr[ 1+ ( sal_Int32 ) m_ptr[0] ];
      82           0 :             return rtl::OUString( m_ptr + 2 + ( sal_Int32 ) m_ptr[0],sizeOfDatabase,RTL_TEXTENCODING_UTF8 );
      83             :         }
      84             : 
      85             : 
      86           0 :         rtl::OUString getTitle()
      87             :         {
      88           0 :             if( ! m_ptr )
      89           0 :                 return rtl::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 rtl::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           0 :     class URLParameter
     109             :     {
     110             :     public:
     111             : 
     112             :         URLParameter( const rtl::OUString& aURL,
     113             :                       Databases* pDatabases )
     114             :             throw( com::sun::star::ucb::IllegalIdentifierException );
     115             : 
     116           0 :         bool isPicture() const { return m_aModule == "picture"; }
     117           0 :         bool isActive() const { return !m_aActive.isEmpty() && m_aActive == "true"; }
     118           0 :         bool isQuery() const { return m_aId.isEmpty() && !m_aQuery.isEmpty(); }
     119             :         bool isEntryForModule() const { return m_aId == "start" || m_bStart; }
     120           0 :         bool isFile() const { return !m_aId.isEmpty(); }
     121           0 :         bool isModule() const { return m_aId.isEmpty() && !m_aModule.isEmpty(); }
     122           0 :         bool isRoot() const { return m_aModule.isEmpty(); }
     123             :         bool isErrorDocument();
     124             : 
     125             :         rtl::OUString get_url() const { return m_aURL; }
     126             : 
     127             :         rtl::OUString get_id();
     128             : 
     129             :         rtl::OUString get_tag();
     130             : 
     131             :         //  Not called for an directory
     132             : 
     133           0 :         rtl::OUString get_path()   { return get_the_path(); }
     134             : 
     135           0 :         rtl::OUString get_eid() const   { return m_aEid; }
     136             : 
     137             :         rtl::OUString get_title();
     138             : 
     139           0 :         rtl::OUString get_jar()      { return get_the_jar(); }
     140             : 
     141           0 :         rtl::OUString get_ExtensionRegistryPath() const { return m_aExtensionRegistryPath; }
     142             : 
     143           0 :         rtl::OUString get_module() const { return m_aModule; }
     144             : 
     145           0 :         rtl::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 :         rtl::OUString get_prefix() const { return m_aPrefix; }
     154             : 
     155             :         rtl::OUString get_language();
     156             : 
     157             :         rtl::OUString get_device() const { return m_aDevice; }
     158             : 
     159             :         rtl::OUString get_program();
     160             : 
     161           0 :         rtl::OUString get_query() const { return m_aQuery; }
     162             : 
     163           0 :         rtl::OUString get_scope() const { return m_aScope; }
     164             : 
     165           0 :         rtl::OUString get_system() const { return m_aSystem; }
     166             : 
     167           0 :         sal_Int32     get_hitCount() const { return m_nHitCount; }
     168             : 
     169             :         rtl::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             :         rtl::OUString  m_aURL;
     190             : 
     191             :         rtl::OUString  m_aTag;
     192             :         rtl::OUString  m_aId;
     193             :         rtl::OUString  m_aPath;
     194             :         rtl::OUString  m_aModule;
     195             :         rtl::OUString  m_aTitle;
     196             :         rtl::OUString  m_aJar;
     197             :         rtl::OUString  m_aExtensionRegistryPath;
     198             :         rtl::OUString  m_aEid;
     199             :         rtl::OUString  m_aDbPar;
     200             : 
     201             :         rtl::OUString  m_aDefaultLanguage;
     202             :         rtl::OUString  m_aLanguage;
     203             : 
     204             :         rtl::OUString  m_aPrefix;
     205             :         rtl::OUString  m_aDevice;
     206             :         rtl::OUString  m_aProgram;
     207             :         rtl::OUString  m_aSystem;
     208             :         rtl::OUString  m_aActive;
     209             : 
     210             :         rtl::OUString  m_aQuery;
     211             :         rtl::OUString  m_aScope;
     212             : 
     213             :         rtl::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             :         rtl::OUString get_the_tag();
     223             : 
     224             :         rtl::OUString get_the_path();
     225             : 
     226             :         rtl::OUString get_the_title();
     227             : 
     228             :         rtl::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