LCOV - code coverage report
Current view: top level - xmlhelp/source/cxxhelp/provider - databases.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 44 0.0 %
Date: 2014-04-14 Functions: 0 31 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 _DATABASES_HXX_
      21             : #define _DATABASES_HXX_
      22             : 
      23             : #include <config_global.h>
      24             : 
      25             : #include <set>
      26             : #include <vector>
      27             : #if !HAVE_CXX11
      28             : #define BOOST_NO_0X_HDR_TYPEINDEX
      29             : #endif
      30             : #include <boost/unordered_map.hpp>
      31             : #include <boost/unordered_set.hpp>
      32             : #include <osl/mutex.hxx>
      33             : #include <rtl/ustring.hxx>
      34             : #include <rtl/string.hxx>
      35             : #include <com/sun/star/uno/Sequence.hxx>
      36             : #include <com/sun/star/ucb/XContent.hpp>
      37             : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      38             : #include <com/sun/star/io/XInputStream.hpp>
      39             : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      40             : #include <com/sun/star/uno/XComponentContext.hpp>
      41             : #include <com/sun/star/i18n/XCollator.hpp>
      42             : #include <com/sun/star/deployment/XPackage.hpp>
      43             : #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
      44             : 
      45             : // Forward declaration
      46             : 
      47             : namespace helpdatafileproxy {
      48             : 
      49             :     class Hdf;
      50             : 
      51             : }
      52             : 
      53             : namespace chelp {
      54             : 
      55             :     class Databases;
      56             :     class URLParameter;
      57             : 
      58             :     class StaticModuleInformation
      59             :     {
      60             :     private:
      61             : 
      62             :         OUString m_aStartId;
      63             :         OUString m_aProgramSwitch;
      64             :         OUString m_aTitle;
      65             :         OUString m_aHeading;
      66             :         OUString m_aFulltext;
      67             :         int m_nOrder;
      68             : 
      69             :     public:
      70             : 
      71           0 :         StaticModuleInformation( const OUString& aTitle,
      72             :                                  const OUString& aStartId,
      73             :                                  const OUString& aProgramSwitch,
      74             :                                  const OUString& aHeading,
      75             :                                  const OUString& aFulltext,
      76             :                                  const OUString& aOrder )
      77             :             : m_aStartId( aStartId ),
      78             :               m_aProgramSwitch( aProgramSwitch ),
      79             :               m_aTitle( aTitle ),
      80             :               m_aHeading( aHeading ),
      81             :               m_aFulltext( aFulltext ),
      82           0 :               m_nOrder( aOrder.toInt32() )
      83             :         {
      84           0 :         }
      85             : 
      86           0 :         ~StaticModuleInformation() { }
      87             : 
      88           0 :         OUString get_title() const { return m_aTitle; }
      89           0 :         OUString get_id() const { return m_aStartId; }
      90           0 :         OUString get_program() const { return m_aProgramSwitch; }
      91             :         OUString get_heading() const { return m_aHeading; }
      92             :         OUString get_fulltext() const { return m_aFulltext; }
      93           0 :         int get_order() const { return m_nOrder; }
      94             :     };  // end class StaticModuleInformation
      95             : 
      96             :     class KeywordInfo
      97             :     {
      98             :     public:
      99             : 
     100           0 :         class KeywordElement
     101             :         {
     102             :             friend struct KeywordElementComparator;
     103             :             friend class KeywordInfo;
     104             : 
     105             :         public:
     106             : 
     107             :             KeywordElement( Databases* pDatabases,
     108             :                             helpdatafileproxy::Hdf* pHdf,
     109             :                             OUString& key,
     110             :                             OUString& ids );
     111             : 
     112             :         private:
     113             : 
     114             :             OUString key;
     115             :             com::sun::star::uno::Sequence< OUString > listId;
     116             :             com::sun::star::uno::Sequence< OUString > listAnchor;
     117             :             com::sun::star::uno::Sequence< OUString > listTitle;
     118             : 
     119             :             void init( Databases *pDatabases,helpdatafileproxy::Hdf* pHdf,const OUString& ids );
     120             :         };
     121             : 
     122             :         KeywordInfo( const std::vector< KeywordElement >& aVector );
     123             : 
     124           0 :         ~KeywordInfo() { };
     125             : 
     126             :         com::sun::star::uno::Sequence< OUString >&
     127           0 :         getKeywordList() { return listKey; }
     128             : 
     129             :         com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< OUString > >&
     130           0 :         getIdList() { return listId; }
     131             : 
     132             :         com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< OUString > >&
     133           0 :         getAnchorList() { return listAnchor; }
     134             : 
     135             :         com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< OUString > >&
     136           0 :         getTitleList() { return listTitle; }
     137             : 
     138             :     private:
     139             : 
     140             :         com::sun::star::uno::Sequence< OUString > listKey;
     141             :         com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< OUString > > listId,listAnchor,listTitle;
     142             :     };  // end class KeywordInfo
     143             : 
     144             :     class Databases
     145             :     {
     146             :     public:
     147             : 
     148             :         struct eq
     149             :         {
     150           0 :             bool operator()( const OUString& rKey1, const OUString& rKey2 ) const
     151             :             {
     152           0 :                 return (rKey1 == rKey2);
     153             :             }
     154             :         };
     155             : 
     156             :         struct ha
     157             :         {
     158           0 :             size_t operator()( const OUString& rName ) const
     159             :             {
     160           0 :                 return rName.hashCode();
     161             :             }
     162             :         };
     163             : 
     164             :         /**
     165             :          *  Input is the installdirectory in system dependent notation
     166             :          */
     167             : 
     168             :         Databases( sal_Bool showBasic,
     169             :                  const OUString& instPath,
     170             :                  const com::sun::star::uno::Sequence< OUString >& imagesZipPaths,
     171             :                  const OUString& productName,
     172             :                  const OUString& productVersion,
     173             :                  const OUString& styleSheet,
     174             :                  com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext );
     175             : 
     176             :         ~Databases();
     177             : 
     178             :         OString getImagesZipFileURL();
     179             : 
     180             :         OUString getInstallPathAsURL();
     181             : 
     182             :         const std::vector< OUString >& getModuleList( const OUString& Language );
     183             : 
     184             :         StaticModuleInformation* getStaticInformationForModule( const OUString& Module,
     185             :                                                                 const OUString& Language );
     186             : 
     187             :         bool checkModuleMatchForExtension( const OUString& Database, const OUString& doclist );
     188             :         KeywordInfo* getKeyword( const OUString& Module,
     189             :                                  const OUString& Language );
     190             : 
     191             :         helpdatafileproxy::Hdf* getHelpDataFile( const OUString& Module,
     192             :                          const OUString& Language, bool helpText = false,
     193             :                          const OUString* pExtensionPath = NULL );
     194             : 
     195             :         /**
     196             :          *  The following method returns the Collator for the given language-country combination
     197             :          */
     198             : 
     199             :         com::sun::star::uno::Reference< com::sun::star::i18n::XCollator >
     200             :         getCollator( const OUString& Language,
     201             :                      const OUString& System );   // System not used by current implementation
     202             :         //                                            // of XCollator
     203             : 
     204             :         /**
     205             :          *  Returns the cascading stlye sheet used to format the HTML-output.
     206             :          *  First try is language directory, second try is main installation directory.
     207             :          */
     208             : 
     209             :         void cascadingStylesheet( const OUString& Language,
     210             :                                   char** buffer,
     211             :                                   int* byteCount );
     212             : 
     213             :         /**
     214             :          *  Changes the stylesheet for further reads.
     215             :          */
     216             : 
     217             :         void changeCSS(const OUString& newStyleSheet);
     218             : 
     219             :         /**
     220             :          *  Returns the active help text for the given module, language and id.
     221             :          */
     222             : 
     223             :         void setActiveText( const OUString& Module,
     224             :                             const OUString& Language,
     225             :                             const OUString& Id,
     226             :                             char** buffer,
     227             :                             int* byteCount );
     228             : 
     229             :         /**
     230             :          *  Has the purpose of forcing the jarfile to stay open
     231             :          */
     232             : 
     233             :         com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess >
     234             :         jarFile( const OUString& jar,
     235             :                  const OUString& Language );
     236             : 
     237             :         com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess >
     238             :         findJarFileForPath( const OUString& jar, const OUString& Language,
     239             :             const OUString& path, OUString* o_pExtensionPath = NULL,
     240             :             OUString* o_pExtensionRegistryPath = NULL );
     241             : 
     242             :         /**
     243             :          *  Maps a given language-locale combination to language.
     244             :          */
     245             : 
     246             :         OUString processLang( const OUString& Language );
     247             : 
     248             :         /**
     249             :          *  Maps a given language-locale combination to locale.
     250             :          *  The returned string maybe empty
     251             :          */
     252             : 
     253             :         OUString country( const OUString& Language );
     254             : 
     255             :         void replaceName( OUString& oustring ) const;
     256             : 
     257           0 :         OUString getProductName() const { return m_vReplacement[0]; }
     258           0 :         OUString getProductVersion() const { return m_vReplacement[1]; }
     259             : 
     260             :         OUString expandURL( const OUString& aURL );
     261             : 
     262             :         static OUString expandURL( const OUString& aURL,
     263             :             com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext );
     264             : 
     265             :     private:
     266             : 
     267             :         osl::Mutex                                                                     m_aMutex;
     268             :         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >       m_xContext;
     269             :         com::sun::star::uno::Reference< com::sun::star::lang::XMultiComponentFactory > m_xSMgr;
     270             :         com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 >      m_xSFA;
     271             : 
     272             :         bool   m_bShowBasic;
     273             :         char*  m_pErrorDoc;
     274             : 
     275             :         int    m_nCustomCSSDocLength;
     276             :         char*  m_pCustomCSSDoc;
     277             :         OUString m_aCSS;
     278             : 
     279             :         enum {
     280             :             PRODUCTNAME = 0,
     281             :             PRODUCTVERSION,
     282             :             VENDORNAME,
     283             :             VENDORVERSION,
     284             :             VENDORSHORT,
     285             :             NEWPRODUCTNAME,
     286             :             NEWPRODUCTVERSION
     287             :         };
     288             : 
     289             :         int                    m_vAdd[7];
     290             :         OUString          m_vReplacement[7];
     291             :         OUString          newProdName,newProdVersion,
     292             :             prodName,prodVersion,vendName,vendVersion,vendShort;
     293             : 
     294             :         OUString          m_aInstallDirectory;                // Installation directory
     295             :         com::sun::star::uno::Sequence< OUString > m_aImagesZipPaths;
     296             :         OString           m_aImagesZipFileURL;
     297             :         OUString          m_aSymbolsStyleName;
     298             : 
     299             :         std::vector< OUString >    m_avModules;
     300             : 
     301             :         typedef boost::unordered_map< OUString,helpdatafileproxy::Hdf*,ha,eq >   DatabasesTable;
     302             :         DatabasesTable m_aDatabases;         // Language and module dependent databases
     303             : 
     304             :         typedef  boost::unordered_map< OUString,OUString,ha,eq > LangSetTable;
     305             :         LangSetTable m_aLangSet;   // Mapping to of lang-country to lang
     306             : 
     307             :         typedef boost::unordered_map< OUString,StaticModuleInformation*,ha,eq > ModInfoTable;
     308             :         ModInfoTable m_aModInfo;   // Module information
     309             : 
     310             :         typedef boost::unordered_map< OUString,KeywordInfo*,ha,eq > KeywordInfoTable;
     311             :         KeywordInfoTable m_aKeywordInfo;   // Module information
     312             : 
     313             :         typedef
     314             :         boost::unordered_map<
     315             :         OUString,
     316             :              ::com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess >,
     317             :             ha,
     318             :             eq >         ZipFileTable;
     319             :         ZipFileTable m_aZipFileTable;   // No closing of an once opened jarfile
     320             : 
     321             :         typedef
     322             :         boost::unordered_map<
     323             :         OUString,
     324             :              ::com::sun::star::uno::Reference< com::sun::star::i18n::XCollator >,
     325             :             ha,
     326             :             eq >      CollatorTable;
     327             :         CollatorTable    m_aCollatorTable;
     328             : 
     329             :         struct ostring_eq
     330             :         {
     331           0 :             bool operator()( const OString& rKey1, const OString& rKey2 ) const
     332             :             {
     333           0 :                 return (rKey1 == rKey2);
     334             :             }
     335             :         };
     336             : 
     337             :         struct ostring_ha
     338             :         {
     339           0 :             size_t operator()( const OString& rName ) const
     340             :             {
     341           0 :                 return rName.hashCode();
     342             :             }
     343             :         };
     344             : 
     345             :         typedef
     346             :         boost::unordered_set<
     347             :             OString,
     348             :             ostring_ha,
     349             :             ostring_eq >      EmptyActiveTextSet;
     350             :         EmptyActiveTextSet  m_aEmptyActiveTextSet;
     351             : 
     352             :         // methods
     353             : 
     354             :         void setInstallPath( const OUString& aInstallDirectory );
     355             : 
     356             :     }; // end class Databases
     357             : 
     358             :     enum IteratorState
     359             :     {
     360             :         INITIAL_MODULE,
     361             :         //SHARED_MODULE,        // Later, avoids redundancies in help compiling
     362             :         USER_EXTENSIONS,
     363             :         SHARED_EXTENSIONS,
     364             :         BUNDLED_EXTENSIONS,
     365             :         END_REACHED
     366             :     };
     367             : 
     368             :     // Hashtable to cache extension help status
     369             :     typedef boost::unordered_map
     370             :     <
     371             :         OUString,
     372             :         bool,
     373             :         Databases::ha,
     374             :         Databases::eq
     375             :     >
     376             :     ExtensionHelpExistanceMap;
     377             : 
     378           0 :     class ExtensionIteratorBase
     379             :     {
     380             :         static ExtensionHelpExistanceMap    aHelpExistanceMap;
     381             : 
     382             :     public:
     383             :         ExtensionIteratorBase( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext,
     384             :             Databases& rDatabases, const OUString& aInitialModule, const OUString& aLanguage );
     385             :         ExtensionIteratorBase( Databases& rDatabases, const OUString& aInitialModule,
     386             :             const OUString& aLanguage );
     387             :         void init( void );
     388             : 
     389             :     private:
     390             :         com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetHelpPackageFromPackage
     391             :             ( const com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage,
     392             :               com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
     393             : 
     394             :     protected:
     395             :         com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextUserHelpPackage
     396             :             ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
     397             :         com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage
     398             :             ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
     399             :         com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage
     400             :         ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
     401             :         OUString implGetFileFromPackage( const OUString& rFileExtension,
     402             :             com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
     403             :         void implGetLanguageVectorFromPackage( ::std::vector< OUString > &rv,
     404             :             com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
     405             : 
     406             :         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >    m_xContext;
     407             :         com::sun::star::uno::Reference< com::sun::star::ucb::XSimpleFileAccess3 >   m_xSFA;
     408             :         Databases&                                                                  m_rDatabases;
     409             : 
     410             :         IteratorState                                                               m_eState;
     411             :         OUString                                                               m_aExtensionPath;
     412             : 
     413             :         OUString                                                               m_aInitialModule;
     414             :         OUString                                                               m_aLanguage;
     415             : 
     416             :         com::sun::star::uno::Sequence< com::sun::star::uno::Reference
     417             :             < com::sun::star::deployment::XPackage > >                              m_aUserPackagesSeq;
     418             :         bool                                                                        m_bUserPackagesLoaded;
     419             : 
     420             :         com::sun::star::uno::Sequence< com::sun::star::uno::Reference
     421             :             < com::sun::star::deployment::XPackage > >                              m_aSharedPackagesSeq;
     422             :         bool                                                                        m_bSharedPackagesLoaded;
     423             : 
     424             :         com::sun::star::uno::Sequence< com::sun::star::uno::Reference
     425             :             < com::sun::star::deployment::XPackage > >                              m_aBundledPackagesSeq;
     426             :         bool                                                                        m_bBundledPackagesLoaded;
     427             : 
     428             :         int                                                                         m_iUserPackage;
     429             :         int                                                                         m_iSharedPackage;
     430             :         int                                                                         m_iBundledPackage;
     431             : 
     432             :     }; // end class ExtensionIteratorBase
     433             : 
     434           0 :     class DataBaseIterator : public ExtensionIteratorBase
     435             :     {
     436             :     public:
     437           0 :         DataBaseIterator( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext,
     438             :             Databases& rDatabases, const OUString& aInitialModule, const OUString& aLanguage, bool bHelpText )
     439             :                 : ExtensionIteratorBase( xContext, rDatabases, aInitialModule, aLanguage )
     440           0 :                 , m_bHelpText( bHelpText )
     441           0 :         {}
     442           0 :         DataBaseIterator( Databases& rDatabases, const OUString& aInitialModule,
     443             :             const OUString& aLanguage, bool bHelpText )
     444             :                 : ExtensionIteratorBase( rDatabases, aInitialModule, aLanguage )
     445           0 :                 , m_bHelpText( bHelpText )
     446           0 :         {}
     447             : 
     448             :         helpdatafileproxy::Hdf* nextHdf( OUString* o_pExtensionPath = NULL, OUString* o_pExtensionRegistryPath = NULL );
     449             : 
     450             :     private:
     451             :         helpdatafileproxy::Hdf* implGetHdfFromPackage(
     452             :             com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage,
     453             :             OUString* o_pExtensionPath, OUString* o_pExtensionRegistryPath );
     454             : 
     455             :         bool                                                                        m_bHelpText;
     456             : 
     457             :     }; // end class DataBaseIterator
     458             : 
     459           0 :     class KeyDataBaseFileIterator : public ExtensionIteratorBase
     460             :     {
     461             :     public:
     462           0 :         KeyDataBaseFileIterator( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext,
     463             :             Databases& rDatabases, const OUString& aInitialModule, const OUString& aLanguage )
     464           0 :                 : ExtensionIteratorBase( xContext, rDatabases, aInitialModule, aLanguage )
     465           0 :         {}
     466             :         //Returns a file URL
     467             :         OUString nextDbFile( bool& o_rbExtension );
     468             : 
     469             :     private:
     470             :         OUString implGetDbFileFromPackage(
     471             :             com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
     472             : 
     473             :     }; // end class KeyDataBaseFileIterator
     474             : 
     475           0 :     class JarFileIterator : public ExtensionIteratorBase
     476             :     {
     477             :     public:
     478           0 :         JarFileIterator( com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xContext,
     479             :             Databases& rDatabases, const OUString& aInitialModule, const OUString& aLanguage )
     480           0 :                 : ExtensionIteratorBase( xContext, rDatabases, aInitialModule, aLanguage )
     481           0 :         {}
     482             : 
     483             :         com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess >
     484             :             nextJarFile( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle,
     485             :                             OUString* o_pExtensionPath = NULL, OUString* o_pExtensionRegistryPath = NULL );
     486             : 
     487             :     private:
     488             :         com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess >
     489             :             implGetJarFromPackage(com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage,
     490             :                 OUString* o_pExtensionPath = NULL, OUString* o_pExtensionRegistryPath = NULL );
     491             : 
     492             :     }; // end class JarFileIterator
     493             : 
     494           0 :     class IndexFolderIterator : public ExtensionIteratorBase
     495             :     {
     496             :     public:
     497           0 :         IndexFolderIterator( Databases& rDatabases, const OUString& aInitialModule, const OUString& aLanguage )
     498           0 :             : ExtensionIteratorBase( rDatabases, aInitialModule, aLanguage )
     499           0 :         {}
     500             : 
     501             :         OUString nextIndexFolder( bool& o_rbExtension, bool& o_rbTemporary );
     502             :         void deleteTempIndexFolder( const OUString& aIndexFolder );
     503             : 
     504             :     private:
     505             :         OUString implGetIndexFolderFromPackage( bool& o_rbTemporary,
     506             :             com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
     507             : 
     508             :     }; // end class KeyDataBaseFileIterator
     509             : 
     510             : }      // end namespace chelp
     511             : 
     512             : #endif
     513             : 
     514             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10