summaryrefslogtreecommitdiff
path: root/svtools/source/filter.vcl/filter/FilterConfigItem.cxx
diff options
context:
space:
mode:
authorSven Jacobi <sj@openoffice.org>2001-03-08 12:46:54 +0000
committerSven Jacobi <sj@openoffice.org>2001-03-08 12:46:54 +0000
commit689e46b2f846ec35d6001dc03d2250a2bebe4ebc (patch)
treebaafed41715ca488d8049e90843b99ec73d05980 /svtools/source/filter.vcl/filter/FilterConfigItem.cxx
parent46f8d98c1bdab1877db481aba096f30e44c5be62 (diff)
now testing nodepath availability
Diffstat (limited to 'svtools/source/filter.vcl/filter/FilterConfigItem.cxx')
-rw-r--r--svtools/source/filter.vcl/filter/FilterConfigItem.cxx127
1 files changed, 100 insertions, 27 deletions
diff --git a/svtools/source/filter.vcl/filter/FilterConfigItem.cxx b/svtools/source/filter.vcl/filter/FilterConfigItem.cxx
index 01a0315aec64..5861268e4354 100644
--- a/svtools/source/filter.vcl/filter/FilterConfigItem.cxx
+++ b/svtools/source/filter.vcl/filter/FilterConfigItem.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FilterConfigItem.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: sj $ $Date: 2001-03-05 20:35:59 $
+ * last change: $Author: sj $ $Date: 2001-03-08 13:46:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,6 +81,9 @@
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#endif
using namespace ::rtl;
using namespace ::utl ; // getProcessServiceFactory
@@ -89,49 +92,119 @@ using namespace ::com::sun::star::beans ; // PropertyValue
using namespace ::com::sun::star::uno ; // Reference
using namespace ::com::sun::star::util ; // XChangesBatch
using namespace ::com::sun::star::awt ; // Size
+using namespace ::com::sun::star::container ; //
-FilterConfigItem::FilterConfigItem( const OUString& rSubTree ) :
- bModified ( sal_False )
+static sal_Bool ImpIsTreeAvailable( Reference< XMultiServiceFactory >& rXCfgProv, const String& rTree )
{
- OUString sTree( ConfigManager::GetConfigBaseURL() );
- sTree += rSubTree;
- Reference< XMultiServiceFactory > xSMGR = getProcessServiceFactory(); // get global uno service manager
+ sal_Bool bAvailable = rTree.Len() != 0;
+ if ( bAvailable )
+ {
+ xub_StrLen nTokenCount = rTree.GetTokenCount( (sal_Unicode)'/' );
+ xub_StrLen i = 0;
- Reference< XMultiServiceFactory > xCfgProv(
- xSMGR->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
- UNO_QUERY );
+ if ( rTree.GetChar( 0 ) == (sal_Unicode)'/' )
+ i++;
- if ( xCfgProv.is() )
- {
Any aAny;
+ aAny <<= (OUString)rTree.GetToken( i++, (sal_Unicode)'/' );
+
// creation arguments: nodepath
PropertyValue aPathArgument;
- aAny <<= sTree;
aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
aPathArgument.Value = aAny;
- // creation arguments: commit mode
- PropertyValue aModeArgument;
- sal_Bool bAsyncron = sal_True;
- aAny <<= bAsyncron;
- aModeArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) );
- aModeArgument.Value = aAny;
-
- Sequence< Any > aArguments( 2 );
+ Sequence< Any > aArguments( 1 );
aArguments[ 0 ] <<= aPathArgument;
- aArguments[ 1 ] <<= aModeArgument;
+ Reference< XInterface > xReadAccess;
try
{
- xUpdatableView = xCfgProv->createInstanceWithArguments(
- OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
+ xReadAccess = rXCfgProv->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ),
aArguments );
- if ( xUpdatableView.is() )
- xPropSet = Reference< XPropertySet >( xUpdatableView, UNO_QUERY );
}
catch ( ::com::sun::star::uno::Exception& )
{
- DBG_ERROR( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" );
+ bAvailable = sal_False;
+ }
+ if ( xReadAccess.is() )
+ {
+ for ( ; bAvailable && ( i < nTokenCount ); i++ )
+ {
+ Reference< XHierarchicalNameAccess > xHierarchicalNameAccess
+ ( xReadAccess, UNO_QUERY );
+
+ if ( !xHierarchicalNameAccess.is() )
+ bAvailable = sal_False;
+ else
+ {
+ String aNode( rTree.GetToken( i, (sal_Unicode)'/' ) );
+ if ( !xHierarchicalNameAccess->hasByHierarchicalName( aNode ) )
+ bAvailable = sal_False;
+ else
+ {
+ Any aAny( xHierarchicalNameAccess->getByHierarchicalName( aNode ) );
+ try
+ {
+ aAny >>= xReadAccess;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ bAvailable = sal_False;
+ }
+ }
+ }
+ }
+ }
+ }
+ return bAvailable;
+}
+
+FilterConfigItem::FilterConfigItem( const OUString& rSubTree ) :
+ bModified ( sal_False )
+{
+ OUString sTree( ConfigManager::GetConfigBaseURL() );
+ sTree += rSubTree;
+ Reference< XMultiServiceFactory > xSMGR = getProcessServiceFactory(); // get global uno service manager
+
+ Reference< XMultiServiceFactory > xCfgProv(
+ xSMGR->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
+ UNO_QUERY );
+
+ if ( xCfgProv.is() )
+ {
+ if ( ImpIsTreeAvailable( xCfgProv, String( sTree ) ) )
+ {
+ Any aAny;
+ // creation arguments: nodepath
+ PropertyValue aPathArgument;
+ aAny <<= sTree;
+ aPathArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aPathArgument.Value = aAny;
+
+ // creation arguments: commit mode
+ PropertyValue aModeArgument;
+ sal_Bool bAsyncron = sal_True;
+ aAny <<= bAsyncron;
+ aModeArgument.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ) );
+ aModeArgument.Value = aAny;
+
+ Sequence< Any > aArguments( 2 );
+ aArguments[ 0 ] <<= aPathArgument;
+ aArguments[ 1 ] <<= aModeArgument;
+
+ try
+ {
+ xUpdatableView = xCfgProv->createInstanceWithArguments(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
+ aArguments );
+ if ( xUpdatableView.is() )
+ xPropSet = Reference< XPropertySet >( xUpdatableView, UNO_QUERY );
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ DBG_ERROR( "FilterConfigItem::FilterConfigItem - Could not access configuration Key" );
+ }
}
}
};