diff options
author | Joachim Lingner <jl@openoffice.org> | 2010-04-06 17:15:01 +0200 |
---|---|---|
committer | Joachim Lingner <jl@openoffice.org> | 2010-04-06 17:15:01 +0200 |
commit | fb70a4cd3b77e0ea6bb5820b47bfd7ea39fa3228 (patch) | |
tree | 082773aabe43050f45bb05345331be41f32a7976 /xmlhelp | |
parent | jl152 import 263444 from native0jl:#i77196# disable now supported new from ex... (diff) | |
download | core-fb70a4cd3b77e0ea6bb5820b47bfd7ea39fa3228.tar.gz core-fb70a4cd3b77e0ea6bb5820b47bfd7ea39fa3228.zip |
jl152 import 263445 from native0jl:#i77196# supporting extension help
Diffstat (limited to 'xmlhelp')
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/databases.cxx | 178 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/databases.hxx | 19 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/urlparameter.cxx | 10 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/urlparameter.hxx | 3 |
4 files changed, 167 insertions, 43 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx index c5e2582b3905..5c164e08c100 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.cxx +++ b/xmlhelp/source/cxxhelp/provider/databases.cxx @@ -1162,7 +1162,8 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( const rtl::OUString& ja Reference< XHierarchicalNameAccess > Databases::findJarFileForPath ( const rtl::OUString& jar, const rtl::OUString& Language, - const rtl::OUString& path, rtl::OUString* o_pExtensionPath ) + const rtl::OUString& path, rtl::OUString* o_pExtensionPath, + rtl::OUString* o_pExtensionRegistryPath ) { Reference< XHierarchicalNameAccess > xNA; if( ! jar.getLength() || @@ -1174,7 +1175,7 @@ Reference< XHierarchicalNameAccess > Databases::findJarFileForPath JarFileIterator aJarFileIt( m_xContext, *this, jar, Language ); Reference< XHierarchicalNameAccess > xTestNA; Reference< deployment::XPackage > xParentPackageBundle; - while( (xTestNA = aJarFileIt.nextJarFile( xParentPackageBundle, o_pExtensionPath )).is() ) + while( (xTestNA = aJarFileIt.nextJarFile( xParentPackageBundle, o_pExtensionPath, o_pExtensionRegistryPath )).is() ) { if( xTestNA.is() && xTestNA->hasByHierarchicalName( path ) ) { @@ -1512,6 +1513,7 @@ void ExtensionIteratorBase::init() m_bSharedPackagesLoaded = false; m_iUserPackage = 0; m_iSharedPackage = 0; + m_iBundledPackage = 0; } Reference< deployment::XPackage > ExtensionIteratorBase::implGetHelpPackageFromPackage @@ -1635,6 +1637,36 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa return xHelpPackage; } +Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextBundledHelpPackage + ( Reference< deployment::XPackage >& o_xParentPackageBundle ) +{ + Reference< deployment::XPackage > xHelpPackage; + + if( !m_bBundledPackagesLoaded ) + { + Reference< XPackageManager > xBundledManager = + thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("bundled") ); + m_aBundledPackagesSeq = xBundledManager->getDeployedPackages + ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); + m_bBundledPackagesLoaded = true; + } + + if( m_iBundledPackage == m_aBundledPackagesSeq.getLength() ) + { + m_eState = END_REACHED; + } + else + { + const Reference< deployment::XPackage >* pBundledPackages = + m_aBundledPackagesSeq.getConstArray(); + Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage++ ]; + VOS_ENSURE( xPackage.is(), "ExtensionIteratorBase::implGetNextBundledHelpPackage(): Invalid package" ); + xHelpPackage = implGetHelpPackageFromPackage( xPackage, o_xParentPackageBundle ); + } + + return xHelpPackage; +} + rtl::OUString ExtensionIteratorBase::implGetFileFromPackage( const rtl::OUString& rFileExtension, Reference< deployment::XPackage > xPackage ) { @@ -1646,7 +1678,7 @@ rtl::OUString ExtensionIteratorBase::implGetFileFromPackage( for( sal_Int32 iPass = 0 ; iPass < 2 ; ++iPass ) { rtl::OUStringBuffer aStrBuf; - aStrBuf.append( xPackage->getURL() ); + aStrBuf.append( xPackage->getRegistrationDataURL().Value); aStrBuf.append( aSlash ); aStrBuf.append( aLanguage ); if( !bLangFolderOnly ) @@ -1720,7 +1752,7 @@ void ExtensionIteratorBase::implGetLanguageVectorFromPackage( ::std::vector< ::r //=================================================================== // class DataBaseIterator -Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) +Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { Db* pRetDb = NULL; @@ -1743,7 +1775,7 @@ Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) Reference< deployment::XPackage > xHelpPackage = implGetNextUserHelpPackage( xParentPackageBundle ); if( !xHelpPackage.is() ) break; - pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath ); + pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } @@ -1754,9 +1786,21 @@ Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) if( !xHelpPackage.is() ) break; - pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath ); + pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xParentPackageBundle; + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + pRetDb = implGetDbFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); + break; + } + case END_REACHED: VOS_ENSURE( false, "DataBaseIterator::nextDb(): Invalid case END_REACHED" ); break; @@ -1767,38 +1811,55 @@ Db* DataBaseIterator::nextDb( rtl::OUString* o_pExtensionPath ) } Db* DataBaseIterator::implGetDbFromPackage( Reference< deployment::XPackage > xPackage, - rtl::OUString* o_pExtensionPath ) + rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { - rtl::OUString aExtensionPath = xPackage->getURL(); - //if( o_pExtensionPath ) - //*o_pExtensionPath = aExtensionPath; - aExtensionPath += aSlash; - rtl::OUString aUsedLanguage = m_aLanguage; - Db* pRetDb = m_rDatabases.getBerkeley( aHelpFilesBaseName, aUsedLanguage, - m_bHelpText, &aExtensionPath ); + beans::Optional< ::rtl::OUString> optRegData; + try + { + optRegData = xPackage->getRegistrationDataURL(); + } + catch ( deployment::ExtensionRemovedException&) + { + return NULL; + } - // Language fallback - if( !pRetDb ) + Db* pRetDb = NULL; + if (optRegData.IsPresent && optRegData.Value.getLength() > 0) { - ::std::vector< ::rtl::OUString > av; - implGetLanguageVectorFromPackage( av, xPackage ); - ::std::vector< ::rtl::OUString >::const_iterator pFound = av.end(); - try - { - pFound = ::comphelper::Locale::getFallback( av, m_aLanguage ); - } - catch( ::comphelper::Locale::MalFormedLocaleException& ) - {} - if( pFound != av.end() ) + rtl::OUString aRegDataUrl(optRegData.Value); + aRegDataUrl += aSlash; + + rtl::OUString aUsedLanguage = m_aLanguage; + pRetDb = m_rDatabases.getBerkeley( + aHelpFilesBaseName, aUsedLanguage, m_bHelpText, &aRegDataUrl); + + // Language fallback + if( !pRetDb ) { - aUsedLanguage = *pFound; - pRetDb = m_rDatabases.getBerkeley( aHelpFilesBaseName, aUsedLanguage, m_bHelpText, &aExtensionPath ); + ::std::vector< ::rtl::OUString > av; + implGetLanguageVectorFromPackage( av, xPackage ); + ::std::vector< ::rtl::OUString >::const_iterator pFound = av.end(); + try + { + pFound = ::comphelper::Locale::getFallback( av, m_aLanguage ); + } + catch( ::comphelper::Locale::MalFormedLocaleException& ) + {} + if( pFound != av.end() ) + { + aUsedLanguage = *pFound; + pRetDb = m_rDatabases.getBerkeley( + aHelpFilesBaseName, aUsedLanguage, m_bHelpText, &aRegDataUrl); + } } - } - if( o_pExtensionPath ) - *o_pExtensionPath = aExtensionPath + aUsedLanguage; + if( o_pExtensionPath ) + *o_pExtensionPath = aRegDataUrl + aUsedLanguage; + + if( o_pExtensionRegistryPath ) + *o_pExtensionRegistryPath = xPackage->getURL() + aSlash + aUsedLanguage; + } return pRetDb; } @@ -1853,6 +1914,19 @@ rtl::OUString KeyDataBaseFileIterator::nextDbFile( bool& o_rbExtension ) o_rbExtension = true; break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xParentPackageBundle; + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + aRetFile = implGetDbFileFromPackage( xHelpPackage ); + o_rbExtension = true; + break; + } + case END_REACHED: VOS_ENSURE( false, "DataBaseIterator::nextDbFile(): Invalid case END_REACHED" ); break; @@ -1879,7 +1953,8 @@ rtl::OUString KeyDataBaseFileIterator::implGetDbFileFromPackage // class JarFileIterator Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile - ( Reference< deployment::XPackage >& o_xParentPackageBundle, rtl::OUString* o_pExtensionPath ) + ( Reference< deployment::XPackage >& o_xParentPackageBundle, + rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { Reference< XHierarchicalNameAccess > xNA; @@ -1902,7 +1977,7 @@ Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile if( !xHelpPackage.is() ) break; - xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath ); + xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } @@ -1912,9 +1987,20 @@ Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile if( !xHelpPackage.is() ) break; - xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath ); + xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( o_xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + xNA = implGetJarFromPackage( xHelpPackage, o_pExtensionPath, o_pExtensionRegistryPath ); + break; + } + case END_REACHED: VOS_ENSURE( false, "JarFileIterator::nextJarFile(): Invalid case END_REACHED" ); break; @@ -1925,7 +2011,7 @@ Reference< XHierarchicalNameAccess > JarFileIterator::nextJarFile } Reference< XHierarchicalNameAccess > JarFileIterator::implGetJarFromPackage - ( Reference< deployment::XPackage > xPackage, rtl::OUString* o_pExtensionPath ) +( Reference< deployment::XPackage > xPackage, rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ) { Reference< XHierarchicalNameAccess > xNA; @@ -1970,6 +2056,15 @@ Reference< XHierarchicalNameAccess > JarFileIterator::implGetJarFromPackage sal_Int32 nLastSlash = zipFile.lastIndexOf( '/' ); if( nLastSlash != -1 ) *o_pExtensionPath = zipFile.copy( 0, nLastSlash ); + + if( o_pExtensionRegistryPath != NULL ) + { + rtl::OUString& rPath = *o_pExtensionPath; + sal_Int32 nLastSlashInPath = rPath.lastIndexOf( '/', rPath.getLength() - 1 ); + + *o_pExtensionRegistryPath = xPackage->getURL(); + *o_pExtensionRegistryPath += rPath.copy( nLastSlashInPath); + } } return xNA; @@ -2026,6 +2121,19 @@ rtl::OUString IndexFolderIterator::nextIndexFolder( bool& o_rbExtension, bool& o o_rbExtension = true; break; } + + case BUNDLED_EXTENSIONS: + { + Reference< deployment::XPackage > xParentPackageBundle; + Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle ); + if( !xHelpPackage.is() ) + break; + + aIndexFolder = implGetIndexFolderFromPackage( o_rbTemporary, xHelpPackage ); + o_rbExtension = true; + break; + } + case END_REACHED: VOS_ENSURE( false, "IndexFolderIterator::nextIndexFolder(): Invalid case END_REACHED" ); break; diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx index 6468c5732c6b..aa80bf27405b 100644 --- a/xmlhelp/source/cxxhelp/provider/databases.hxx +++ b/xmlhelp/source/cxxhelp/provider/databases.hxx @@ -267,7 +267,8 @@ namespace chelp { com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess > findJarFileForPath( const rtl::OUString& jar, const rtl::OUString& Language, - const rtl::OUString& path, rtl::OUString* o_pExtensionPath = NULL ); + const rtl::OUString& path, rtl::OUString* o_pExtensionPath = NULL, + rtl::OUString* o_pExtensionRegistryPath = NULL ); /** * Maps a given language-locale combination to language. @@ -398,6 +399,7 @@ namespace chelp { //SHARED_MODULE, // Later, avoids redundancies in help compiling USER_EXTENSIONS, SHARED_EXTENSIONS, + BUNDLED_EXTENSIONS, END_REACHED }; @@ -433,6 +435,8 @@ namespace chelp { ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); + com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage + ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle ); rtl::OUString implGetFileFromPackage( const rtl::OUString& rFileExtension, com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage ); void implGetLanguageVectorFromPackage( ::std::vector< ::rtl::OUString > &rv, @@ -456,8 +460,13 @@ namespace chelp { < com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq; bool m_bSharedPackagesLoaded; + com::sun::star::uno::Sequence< com::sun::star::uno::Reference + < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq; + bool m_bBundledPackagesLoaded; + int m_iUserPackage; int m_iSharedPackage; + int m_iBundledPackage; }; // end class ExtensionIteratorBase @@ -477,13 +486,13 @@ namespace chelp { , m_bHelpText( bHelpText ) {} - berkeleydbproxy::Db* nextDb( rtl::OUString* o_pExtensionPath = NULL ); + berkeleydbproxy::Db* nextDb( rtl::OUString* o_pExtensionPath = NULL, rtl::OUString* o_pExtensionRegistryPath = NULL ); private: berkeleydbproxy::Db* implGetDbFromPackage( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage, - rtl::OUString* o_pExtensionPath ); + rtl::OUString* o_pExtensionPath, rtl::OUString* o_pExtensionRegistryPath ); bool m_bHelpText; @@ -517,12 +526,12 @@ namespace chelp { com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess > nextJarFile( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle, - rtl::OUString* o_pExtensionPath = NULL ); + rtl::OUString* o_pExtensionPath = NULL, rtl::OUString* o_pExtensionRegistryPath = NULL ); private: com::sun::star::uno::Reference< com::sun::star::container::XHierarchicalNameAccess > implGetJarFromPackage(com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage, - rtl::OUString* o_pExtensionPath = NULL ); + rtl::OUString* o_pExtensionPath = NULL, rtl::OUString* o_pExtensionRegistryPath = NULL ); }; // end class JarFileIterator diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx index 9268ec19cd7f..67735c4e0a6a 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx @@ -306,9 +306,10 @@ void URLParameter::readBerkeley() Dbt data; DBData aDBData; rtl::OUString aExtensionPath; + rtl::OUString aExtensionRegistryPath; while( true ) { - Db* db = aDbIt.nextDb( &aExtensionPath ); + Db* db = aDbIt.nextDb( &aExtensionPath, &aExtensionRegistryPath ); if( !db ) break; @@ -355,6 +356,7 @@ void URLParameter::readBerkeley() aExtendedJarStrBuf.append( aQuestionMark ); aExtendedJarStrBuf.append( m_aJar ); m_aJar = aExtendedJarStrBuf.makeStringAndClear(); + m_aExtensionRegistryPath = aExtensionRegistryPath; } m_aTag = converter.getHash(); } @@ -1004,18 +1006,20 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, rtl::OUString aJar = urlParam->get_jar(); bool bAddExtensionPath = false; + rtl::OUString aExtensionRegistryPath; sal_Int32 nQuestionMark1 = aJar.indexOf( sal_Unicode('?') ); sal_Int32 nQuestionMark2 = aJar.lastIndexOf( sal_Unicode('?') ); if( nQuestionMark1 != -1 && nQuestionMark2 != -1 && nQuestionMark1 != nQuestionMark2 ) { aExtensionPath = aJar.copy( nQuestionMark1 + 1, nQuestionMark2 - nQuestionMark1 - 1 ); + aExtensionRegistryPath = urlParam->get_ExtensionRegistryPath(); bAddExtensionPath = true; } else { // Path not yet specified, search directly Reference< XHierarchicalNameAccess > xNA = pDatabases->findJarFileForPath - ( aJar, urlParam->get_language(), urlParam->get_path(), &aExtensionPath ); + ( aJar, urlParam->get_language(), urlParam->get_path(), &aExtensionPath, &aExtensionRegistryPath ); if( xNA.is() && aExtensionPath.getLength() ) bAddExtensionPath = true; } @@ -1038,7 +1042,7 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam, Reference< XInterface >() ); } - rtl::OUString aOUExpandedExtensionPath = Databases::expandURL( aExtensionPath, xContext ); + rtl::OUString aOUExpandedExtensionPath = Databases::expandURL( aExtensionRegistryPath, xContext ); rtl::OString aExpandedExtensionPath = rtl::OUStringToOString( aOUExpandedExtensionPath, osl_getThreadTextEncoding() ); parString[last++] = "ExtensionPath"; diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx index d1dbf48132a7..5f73c930dcdb 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.hxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.hxx @@ -150,6 +150,8 @@ namespace chelp { rtl::OUString get_jar() { return get_the_jar(); } // BerkeleyDb + rtl::OUString get_ExtensionRegistryPath() { return m_aExtensionRegistryPath; } + rtl::OUString get_module() { return m_aModule; } rtl::OUString get_dbpar() { @@ -203,6 +205,7 @@ namespace chelp { rtl::OUString m_aModule; rtl::OUString m_aTitle; rtl::OUString m_aJar; + rtl::OUString m_aExtensionRegistryPath; rtl::OUString m_aEid; rtl::OUString m_aDbPar; |