[Libreoffice-commits] core.git: 2 commits - xmlhelp/Library_ucpchelp1.mk xmlhelp/source
Stephan Bergmann
sbergman at redhat.com
Tue Jan 5 03:25:51 PST 2016
xmlhelp/Library_ucpchelp1.mk | 4
xmlhelp/source/cxxhelp/provider/databases.cxx | 23 +--
xmlhelp/source/cxxhelp/provider/provider.cxx | 171 ++------------------------
xmlhelp/source/cxxhelp/provider/provider.hxx | 17 --
4 files changed, 28 insertions(+), 187 deletions(-)
New commits:
commit e9aa3c99d2ae577d9e2fbddc95f10d6230cf1e68
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Jan 4 17:49:08 2016 +0100
Simplify code
Change-Id: I28cff254d2cc1e2abe6fc893d918bd84bfc8645c
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index c09f2d7..14e5c1c 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -316,8 +316,6 @@ const std::vector< OUString >& Databases::getModuleList( const OUString& Languag
osl::DirectoryItem aDirItem;
osl::FileStatus aStatus( osl_FileStatus_Mask_FileName );
- sal_Int32 idx;
-
if( osl::FileBase::E_None != dirFile.open() )
return m_avModules;
@@ -330,22 +328,17 @@ const std::vector< OUString >& Databases::getModuleList( const OUString& Languag
fileName = aStatus.getFileName();
// Check, whether fileName is of the form *.cfg
- idx = fileName.lastIndexOf( '.' );
-
- if( idx == -1 )
+ if (!fileName.endsWithIgnoreAsciiCase(".cfg", &fileName)) {
continue;
-
- const sal_Unicode* str = fileName.getStr();
-
- if( fileName.getLength() == idx + 4 &&
- ( str[idx + 1] == 'c' || str[idx + 1] == 'C' ) &&
- ( str[idx + 2] == 'f' || str[idx + 2] == 'F' ) &&
- ( str[idx + 3] == 'g' || str[idx + 3] == 'G' ) &&
- ( fileName = fileName.copy(0,idx).toAsciiLowerCase() ) != "picture" ) {
- if(! m_bShowBasic && fileName == "sbasic" )
+ }
+ fileName = fileName.toAsciiLowerCase();
+ if (fileName == "picture"
+ || (!m_bShowBasic && fileName == "sbasic"))
+ {
continue;
- m_avModules.push_back( fileName );
}
+
+ m_avModules.push_back( fileName );
}
}
return m_avModules;
commit ce3dd82ca83eb9f3ec89f0e6eaae4e170febec3a
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Jan 4 17:42:02 2016 +0100
Clean up configuration access
Change-Id: I0662e8ddb24f2c6a7197b8a5f23c219484628b78
diff --git a/xmlhelp/Library_ucpchelp1.mk b/xmlhelp/Library_ucpchelp1.mk
index 8109e5e..0eb7d85 100644
--- a/xmlhelp/Library_ucpchelp1.mk
+++ b/xmlhelp/Library_ucpchelp1.mk
@@ -16,6 +16,10 @@ $(eval $(call gb_Library_set_include,ucpchelp1,\
$$(INCLUDE) \
))
+$(eval $(call gb_Library_use_custom_headers,ucpchelp1, \
+ officecfg/registry \
+))
+
$(eval $(call gb_Library_use_sdk_api,ucpchelp1))
$(eval $(call gb_Library_use_externals,ucpchelp1,\
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx
index ffac57d..56a14e4 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.cxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.cxx
@@ -20,16 +20,14 @@
#include <config_folders.h>
#include <stdio.h>
+#include <officecfg/Office/Common.hxx>
+#include <officecfg/Setup.hxx>
#include <osl/file.hxx>
#include <osl/diagnose.h>
#include <ucbhelper/contentidentifier.hxx>
-#include <com/sun/star/frame/XConfigManager.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/container/XContainer.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/supportsservice.hxx>
@@ -259,73 +257,32 @@ void ContentProvider::init()
osl::MutexGuard aGuard( m_aMutex );
isInitialized = true;
- uno::Reference< lang::XMultiServiceFactory > sProvider(
- getConfiguration() );
- uno::Reference< container::XHierarchicalNameAccess > xHierAccess(
- getHierAccess( sProvider,
- "org.openoffice.Office.Common" ) );
- OUString instPath( getKey( xHierAccess,"Path/Current/Help" ) );
+ OUString instPath(
+ officecfg::Office::Common::Path::Current::Help::get(m_xContext));
if( instPath.isEmpty() )
// try to determine path from default
instPath = "$(instpath)/" LIBO_SHARE_HELP_FOLDER;
// replace anything like $(instpath);
subst( instPath );
- OUString stylesheet( getKey( xHierAccess,"Help/HelpStyleSheet" ) );
- try
- {
- // now adding as configuration change listener for the stylesheet
- uno::Reference< container::XNameAccess> xAccess(
- xHierAccess, uno::UNO_QUERY );
- if( xAccess.is() )
- {
- uno::Any aAny =
- xAccess->getByName("Help");
- aAny >>= m_xContainer;
- if( m_xContainer.is() )
- m_xContainer->addContainerListener( this );
- }
- }
- catch( uno::Exception const & )
- {
- }
+ OUString stylesheet(
+ officecfg::Office::Common::Help::HelpStyleSheet::get(m_xContext));
- xHierAccess = getHierAccess( sProvider, "org.openoffice.Setup" );
+ // now adding as configuration change listener for the stylesheet
+ m_xContainer.set(
+ officecfg::Office::Common::Help::get(m_xContext),
+ css::uno::UNO_QUERY_THROW);
+ m_xContainer->addContainerListener( this );
OUString setupversion(
- getKey( xHierAccess,"Product/ooSetupVersion" ) );
- OUString setupextension;
-
- try
- {
- uno::Reference< lang::XMultiServiceFactory > xConfigProvider =
- configuration::theDefaultProvider::get( m_xContext );
-
- uno::Sequence < uno::Any > lParams(1);
- beans::PropertyValue aParam ;
- aParam.Name = "nodepath";
- aParam.Value <<= OUString("/org.openoffice.Setup/Product");
- lParams[0] = uno::makeAny(aParam);
-
- // open it
- uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments(
- "com.sun.star.configuration.ConfigurationAccess",
- lParams) );
-
- uno::Reference< container::XNameAccess > xDirectAccess(xCFG, uno::UNO_QUERY);
- uno::Any aRet = xDirectAccess->getByName("ooSetupExtension");
-
- aRet >>= setupextension;
- }
- catch ( uno::Exception& )
- {
- }
-
+ officecfg::Setup::Product::ooSetupVersion::get(m_xContext));
+ OUString setupextension(
+ officecfg::Setup::Product::ooSetupExtension::get(m_xContext));
OUString productversion( setupversion + " " + setupextension );
- xHierAccess = getHierAccess( sProvider, "org.openoffice.Office.Common" );
- bool showBasic = getBooleanKey(xHierAccess,"Help/ShowBasic");
+ bool showBasic = officecfg::Office::Common::Help::ShowBasic::get(
+ m_xContext);
m_pDatabases = new Databases( showBasic,
instPath,
utl::ConfigManager::getProductName(),
@@ -334,102 +291,6 @@ void ContentProvider::init()
m_xContext );
}
-uno::Reference< lang::XMultiServiceFactory >
-ContentProvider::getConfiguration() const
-{
- uno::Reference< lang::XMultiServiceFactory > xProvider;
- if( m_xContext.is() )
- {
- try
- {
- xProvider = configuration::theDefaultProvider::get( m_xContext );
- }
- catch( const uno::Exception& )
- {
- OSL_ENSURE( xProvider.is(), "can not instantiate configuration" );
- }
- }
-
- return xProvider;
-}
-
-uno::Reference< container::XHierarchicalNameAccess >
-ContentProvider::getHierAccess(
- const uno::Reference< lang::XMultiServiceFactory >& sProvider,
- const char* file )
-{
- uno::Reference< container::XHierarchicalNameAccess > xHierAccess;
-
- if( sProvider.is() )
- {
- uno::Sequence< uno::Any > seq( 1 );
- OUString sReaderService(
- OUString(
- "com.sun.star.configuration.ConfigurationAccess" ) );
-
- seq[ 0 ] <<= OUString::createFromAscii( file );
-
- try
- {
- xHierAccess =
- uno::Reference< container::XHierarchicalNameAccess >(
- sProvider->createInstanceWithArguments(
- sReaderService, seq ),
- uno::UNO_QUERY );
- }
- catch( const uno::Exception& )
- {
- }
- }
- return xHierAccess;
-}
-
-OUString
-ContentProvider::getKey(
- const uno::Reference< container::XHierarchicalNameAccess >& xHierAccess,
- const char* key )
-{
- OUString instPath;
- if( xHierAccess.is() )
- {
- uno::Any aAny;
- try
- {
- aAny =
- xHierAccess->getByHierarchicalName(
- OUString::createFromAscii( key ) );
- }
- catch( const container::NoSuchElementException& )
- {
- }
- aAny >>= instPath;
- }
- return instPath;
-}
-
-bool
-ContentProvider::getBooleanKey(
- const uno::Reference< container::XHierarchicalNameAccess >& xHierAccess,
- const char* key )
-{
- bool ret = false;
- if( xHierAccess.is() )
- {
- uno::Any aAny;
- try
- {
- aAny =
- xHierAccess->getByHierarchicalName(
- OUString::createFromAscii( key ) );
- }
- catch( const container::NoSuchElementException& )
- {
- }
- aAny >>= ret;
- }
- return ret;
-}
-
void ContentProvider::subst( OUString& instpath )
{
SvtPathOptions aOptions;
diff --git a/xmlhelp/source/cxxhelp/provider/provider.hxx b/xmlhelp/source/cxxhelp/provider/provider.hxx
index 202c6da..e8e4968 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.hxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.hxx
@@ -23,7 +23,6 @@
#include <rtl/ustring.hxx>
#include <osl/mutex.hxx>
#include <ucbhelper/providerhelper.hxx>
-#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/container/XContainerListener.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/lang/XComponent.hpp>
@@ -156,22 +155,6 @@ namespace chelp {
void init();
- css::uno::Reference< css::lang::XMultiServiceFactory >
- getConfiguration() const;
-
- static css::uno::Reference< css::container::XHierarchicalNameAccess >
- getHierAccess( const css::uno::Reference< css::lang::XMultiServiceFactory >& sProvider,
- const char* file );
-
- static OUString
- getKey( const css::uno::Reference< css::container::XHierarchicalNameAccess >& xHierAccess,
- const char* key );
-
- static bool
- getBooleanKey(
- const css::uno::Reference< css::container::XHierarchicalNameAccess >& xHierAccess,
- const char* key);
-
static void subst( OUString& instpath );
};
More information about the Libreoffice-commits
mailing list