use more officecfg in xmlhelp::TVChildTarget
Change-Id: I3d5762e275317937c4ce3aafaf9e3a359efc2907 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167703 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
This commit is contained in:
committed by
Noel Grandin
parent
8cda679913
commit
f3cced4ab2
@@ -178,7 +178,7 @@ namespace treeview {
|
|||||||
|
|
||||||
TVChildTarget( const ConfigData& configData,TVDom* tvDom );
|
TVChildTarget( const ConfigData& configData,TVDom* tvDom );
|
||||||
|
|
||||||
TVChildTarget( const css::uno::Reference< css::uno::XComponentContext >& xContext );
|
TVChildTarget();
|
||||||
|
|
||||||
virtual ~TVChildTarget() override;
|
virtual ~TVChildTarget() override;
|
||||||
|
|
||||||
@@ -202,25 +202,7 @@ namespace treeview {
|
|||||||
private:
|
private:
|
||||||
std::vector< rtl::Reference< TVRead > > Elements;
|
std::vector< rtl::Reference< TVRead > > Elements;
|
||||||
|
|
||||||
static ConfigData init(
|
static ConfigData init();
|
||||||
const css::uno::Reference< css::uno::XComponentContext >& xContext );
|
|
||||||
|
|
||||||
static css::uno::Reference< css::lang::XMultiServiceFactory >
|
|
||||||
getConfiguration(
|
|
||||||
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
|
|
||||||
|
|
||||||
static css::uno::Reference< css::container::XHierarchicalNameAccess >
|
|
||||||
getHierAccess( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxProvider,
|
|
||||||
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 );
|
static void subst( OUString& instpath );
|
||||||
|
|
||||||
|
@@ -84,7 +84,7 @@ TVFactory::createInstanceWithArguments(
|
|||||||
{
|
{
|
||||||
if( ! m_xHDS.is() )
|
if( ! m_xHDS.is() )
|
||||||
{
|
{
|
||||||
m_xHDS = cppu::getXWeak(new TVChildTarget( m_xContext ));
|
m_xHDS = cppu::getXWeak(new TVChildTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
OUString hierview;
|
OUString hierview;
|
||||||
|
@@ -39,6 +39,8 @@
|
|||||||
#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
|
#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
|
||||||
#include <i18nlangtag/languagetag.hxx>
|
#include <i18nlangtag/languagetag.hxx>
|
||||||
#include <unotools/pathoptions.hxx>
|
#include <unotools/pathoptions.hxx>
|
||||||
|
#include <officecfg/Office/Common.hxx>
|
||||||
|
#include <officecfg/Setup.hxx>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -367,9 +369,9 @@ TVChildTarget::TVChildTarget( const ConfigData& configData,TVDom* tvDom )
|
|||||||
Elements[i] = new TVRead( configData,tvDom->children[i].get() );
|
Elements[i] = new TVRead( configData,tvDom->children[i].get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
TVChildTarget::TVChildTarget( const Reference< XComponentContext >& xContext )
|
TVChildTarget::TVChildTarget()
|
||||||
{
|
{
|
||||||
ConfigData configData = init( xContext );
|
ConfigData configData = init();
|
||||||
|
|
||||||
if( configData.locale.isEmpty() || configData.system.isEmpty() )
|
if( configData.locale.isEmpty() || configData.system.isEmpty() )
|
||||||
return;
|
return;
|
||||||
@@ -572,20 +574,17 @@ TVChildTarget::hasByHierarchicalName( const OUString& aName )
|
|||||||
return hasByName( aName );
|
return hasByName( aName );
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigData TVChildTarget::init( const Reference< XComponentContext >& xContext )
|
ConfigData TVChildTarget::init()
|
||||||
{
|
{
|
||||||
ConfigData configData;
|
ConfigData configData;
|
||||||
Reference< XMultiServiceFactory > sProvider( getConfiguration(xContext) );
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* reading Office.Common */
|
/* reading Office.Common */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
Reference< XHierarchicalNameAccess > xHierAccess( getHierAccess( sProvider,
|
configData.system = officecfg::Office::Common::Help::System::get();
|
||||||
"org.openoffice.Office.Common" ) );
|
bool showBasic = officecfg::Office::Common::Help::ShowBasic::get();
|
||||||
configData.system = getKey(xHierAccess,"Help/System");
|
OUString instPath = officecfg::Office::Common::Path::Current::Help::get();
|
||||||
bool showBasic( getBooleanKey(xHierAccess,"Help/ShowBasic") );
|
|
||||||
OUString instPath( getKey( xHierAccess,"Path/Current/Help" ) );
|
|
||||||
if( instPath.isEmpty() )
|
if( instPath.isEmpty() )
|
||||||
// try to determine path from default
|
// try to determine path from default
|
||||||
instPath = "$(instpath)/help";
|
instPath = "$(instpath)/help";
|
||||||
@@ -597,40 +596,14 @@ ConfigData TVChildTarget::init( const Reference< XComponentContext >& xContext )
|
|||||||
/* reading setup */
|
/* reading setup */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
xHierAccess = getHierAccess( sProvider,
|
OUString setupversion = officecfg::Setup::Product::ooSetupVersion::get();
|
||||||
"org.openoffice.Setup" );
|
OUString setupextension = officecfg::Setup::Product::ooSetupExtension::get();
|
||||||
|
|
||||||
OUString setupversion( getKey( xHierAccess,"Product/ooSetupVersion" ) );
|
|
||||||
OUString setupextension;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Reference< lang::XMultiServiceFactory > xConfigProvider = theDefaultProvider::get( xContext );
|
|
||||||
|
|
||||||
uno::Sequence<uno::Any> lParams(comphelper::InitAnyPropertySequence(
|
|
||||||
{
|
|
||||||
{"nodepath", uno::Any(u"/org.openoffice.Setup/Product"_ustr)}
|
|
||||||
}));
|
|
||||||
|
|
||||||
// open it
|
|
||||||
uno::Reference< uno::XInterface > xCFG( xConfigProvider->createInstanceWithArguments(
|
|
||||||
u"com.sun.star.configuration.ConfigurationAccess"_ustr,
|
|
||||||
lParams) );
|
|
||||||
|
|
||||||
uno::Reference< container::XNameAccess > xDirectAccess(xCFG, uno::UNO_QUERY);
|
|
||||||
uno::Any aRet = xDirectAccess->getByName(u"ooSetupExtension"_ustr);
|
|
||||||
|
|
||||||
aRet >>= setupextension;
|
|
||||||
}
|
|
||||||
catch ( uno::Exception& )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
configData.m_vReplacement[0] = utl::ConfigManager::getProductName();
|
configData.m_vReplacement[0] = utl::ConfigManager::getProductName();
|
||||||
configData.m_vReplacement[1] = setupversion + " " + setupextension; // productVersion
|
configData.m_vReplacement[1] = setupversion + " " + setupextension; // productVersion
|
||||||
// m_vReplacement[2...4] (vendorName/-Version/-Short) are empty strings
|
// m_vReplacement[2...4] (vendorName/-Version/-Short) are empty strings
|
||||||
|
|
||||||
configData.locale = getKey(xHierAccess,"L10N/ooLocale");
|
configData.locale = officecfg::Setup::L10N::ooLocale::get();
|
||||||
|
|
||||||
// Determine fileurl from url and locale
|
// Determine fileurl from url and locale
|
||||||
OUString url;
|
OUString url;
|
||||||
@@ -730,92 +703,6 @@ ConfigData TVChildTarget::init( const Reference< XComponentContext >& xContext )
|
|||||||
return configData;
|
return configData;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference< XMultiServiceFactory >
|
|
||||||
TVChildTarget::getConfiguration(const Reference< XComponentContext >& rxContext)
|
|
||||||
{
|
|
||||||
Reference< XMultiServiceFactory > xProvider;
|
|
||||||
if( rxContext.is() )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
xProvider = theDefaultProvider::get( rxContext );
|
|
||||||
}
|
|
||||||
catch( const css::uno::Exception& )
|
|
||||||
{
|
|
||||||
OSL_ENSURE( xProvider.is(),"can not instantiate configuration" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return xProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference< XHierarchicalNameAccess >
|
|
||||||
TVChildTarget::getHierAccess( const Reference< XMultiServiceFactory >& sProvider,
|
|
||||||
const char* file )
|
|
||||||
{
|
|
||||||
Reference< XHierarchicalNameAccess > xHierAccess;
|
|
||||||
|
|
||||||
if( sProvider.is() )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
xHierAccess =
|
|
||||||
Reference< XHierarchicalNameAccess >
|
|
||||||
( sProvider->createInstanceWithArguments( u"com.sun.star.configuration.ConfigurationAccess"_ustr, { Any(OUString::createFromAscii(file)) }),
|
|
||||||
UNO_QUERY );
|
|
||||||
}
|
|
||||||
catch( const css::uno::Exception& )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return xHierAccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
OUString
|
|
||||||
TVChildTarget::getKey( const Reference< XHierarchicalNameAccess >& xHierAccess,
|
|
||||||
const char* key )
|
|
||||||
{
|
|
||||||
OUString instPath;
|
|
||||||
if( xHierAccess.is() )
|
|
||||||
{
|
|
||||||
Any aAny;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
aAny =
|
|
||||||
xHierAccess->getByHierarchicalName( OUString::createFromAscii( key ) );
|
|
||||||
}
|
|
||||||
catch( const css::container::NoSuchElementException& )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
aAny >>= instPath;
|
|
||||||
}
|
|
||||||
return instPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
TVChildTarget::getBooleanKey(const Reference<
|
|
||||||
XHierarchicalNameAccess >& xHierAccess,
|
|
||||||
const char* key)
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
if( xHierAccess.is() )
|
|
||||||
{
|
|
||||||
Any aAny;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
aAny =
|
|
||||||
xHierAccess->getByHierarchicalName(
|
|
||||||
OUString::createFromAscii(key));
|
|
||||||
}
|
|
||||||
catch( const css::container::NoSuchElementException& )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
aAny >>= ret;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TVChildTarget::subst( OUString& instpath )
|
void TVChildTarget::subst( OUString& instpath )
|
||||||
{
|
{
|
||||||
SvtPathOptions aOptions;
|
SvtPathOptions aOptions;
|
||||||
|
Reference in New Issue
Block a user