diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2006-03-14 10:28:00 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2006-03-14 10:28:00 +0000 |
commit | b26a04ce79ad4894d67284c46747d57ecf48bd6a (patch) | |
tree | 31aa597c6c3751dddf7920c0472a98c1083f397d /extensions/source/propctrlr/pcrcomponentcontext.cxx | |
parent | 1b362a9304634769d2c7f37ec4fc1091cc3f8dfa (diff) |
INTEGRATION: CWS pbrwuno (1.1.2); FILE ADDED
2005/10/24 08:41:58 fs 1.1.2.3: start making the handlers full-fledged components, with using a new infrastructure replacing extensions/source/inc/componentmodule.*
2005/10/13 13:01:06 fs 1.1.2.2: #i53095# introduce an XObjectInspector/Model
2005/08/18 12:44:32 fs 1.1.2.1: #i53095#, phase 2
moved (nearly) all property handling to dedicated handlers, the controller is
now simply managing a set of handlers
open issues for making the property browser completely generic:
- target page for a property - at the moment, the pbrw uses form-specific
knowledge
- relative position of properties. Again, the pbrw uses the OPropertyInfoService
which is not generic
- isComposeable for a given property. Also OPropertyInfoService-dependent ATM
- help ids of pages and the pbrw as a whole. They're hard-coded at the moment
other open issues:
everything in the code which is tagged with TOD/UNOize. Those are items which
do not immediately hinder phase 3 (real UNOization, i.e. definition of new
UNO interfaces for the handlers, the controller, and so on), but need to be
addressed in phase 4 (knit lose ends)
Diffstat (limited to 'extensions/source/propctrlr/pcrcomponentcontext.cxx')
-rw-r--r-- | extensions/source/propctrlr/pcrcomponentcontext.cxx | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/extensions/source/propctrlr/pcrcomponentcontext.cxx b/extensions/source/propctrlr/pcrcomponentcontext.cxx new file mode 100644 index 000000000000..53756ec8b08e --- /dev/null +++ b/extensions/source/propctrlr/pcrcomponentcontext.cxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: pcrcomponentcontext.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2006-03-14 11:28:00 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX +#include "pcrcomponentcontext.hxx" +#endif + +/** === begin UNO includes === **/ +#ifndef _COM_SUN_STAR_LANG_NULLPOINTEREXCEPTION_HPP_ +#include <com/sun/star/lang/NullPointerException.hpp> +#endif +#ifndef _COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HPP_ +#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> +#endif +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +/** === end UNO includes === **/ + +//........................................................................ +namespace pcr +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XComponentContext; + using ::com::sun::star::lang::NullPointerException; + using ::com::sun::star::lang::ServiceNotRegisteredException; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::RuntimeException; + /** === end UNO using === **/ + + //==================================================================== + //= ComponentContext + //==================================================================== + //-------------------------------------------------------------------- + ComponentContext::ComponentContext( const Reference< XComponentContext >& _rxContext ) + :m_xContext( _rxContext ) + { + if ( m_xContext.is() ) + m_xORB = m_xContext->getServiceManager(); + if ( !m_xORB.is() ) + throw NullPointerException(); + } + + //------------------------------------------------------------------------ + ComponentContext::ComponentContext( const Reference< XMultiServiceFactory >& _rxLegacyFactory ) + { + if ( !_rxLegacyFactory.is() ) + throw NullPointerException(); + + try + { + Reference< XPropertySet > xFactoryProperties( _rxLegacyFactory, UNO_QUERY_THROW ); + m_xContext = Reference< XComponentContext >( + xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), + UNO_QUERY ); + } + catch( const RuntimeException& ) { throw; } + catch( const Exception& ) + { + throw RuntimeException(); + } + + if ( m_xContext.is() ) + m_xORB = m_xContext->getServiceManager(); + if ( !m_xORB.is() ) + throw NullPointerException(); + } + + //------------------------------------------------------------------------ + Any ComponentContext::getContextValueByName( const ::rtl::OUString& _rName ) const + { + Any aReturn; + try + { + aReturn = m_xContext->getValueByName( _rName ); + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "PropertyHandler::getContextValueByName: caught an exception!" ); + } + return aReturn; + } + + //------------------------------------------------------------------------ + Reference< XInterface > ComponentContext::createComponent( const ::rtl::OUString& _rServiceName ) const + { + Reference< XInterface > xComponent( + m_xORB->createInstanceWithContext( _rServiceName, m_xContext ) + ); + if ( !xComponent.is() ) + throw ServiceNotRegisteredException( _rServiceName, NULL ); + return xComponent; + } + + //------------------------------------------------------------------------ + Reference< XMultiServiceFactory > ComponentContext::getLegacyServiceFactory() const + { + return Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY_THROW ); + } + +//........................................................................ +} // namespace pcr +//........................................................................ + |