diff options
author | Kurt Zenker <kz@openoffice.org> | 2004-02-25 16:53:04 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2004-02-25 16:53:04 +0000 |
commit | 3c8decf4fdb1f3e5efffe993a207567a24792c9b (patch) | |
tree | a57caff411142020b3e7ebbdb0b1119bc53b9888 /framework/source/uifactory/menubarfactory.cxx | |
parent | ab2653f57884901bade68900980569cf3150fd6e (diff) |
INTEGRATION: CWS layoutmanager (1.1.2); FILE ADDED
2004/02/03 07:43:26 cd 1.1.2.5: #111899# Support special creation mode to have only a toolkit menu bar without menubarmanager interaction. Is needed for inplace editing of our own modules
2004/01/28 16:25:57 cd 1.1.2.4: #111899# Adapt code for new index container implementation
2004/01/26 09:12:28 as 1.1.2.3: #i19488# use long names instead of short names
2004/01/20 11:08:16 cd 1.1.2.2: #111899# Lock solar mutex
2004/01/19 13:19:31 cd 1.1.2.1: #111899# Factories for ui elements
Diffstat (limited to 'framework/source/uifactory/menubarfactory.cxx')
-rw-r--r-- | framework/source/uifactory/menubarfactory.cxx | 275 |
1 files changed, 275 insertions, 0 deletions
diff --git a/framework/source/uifactory/menubarfactory.cxx b/framework/source/uifactory/menubarfactory.cxx new file mode 100644 index 0000000000..7157132c99 --- /dev/null +++ b/framework/source/uifactory/menubarfactory.cxx @@ -0,0 +1,275 @@ +/************************************************************************* + * + * $RCSfile: menubarfactory.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: kz $ $Date: 2004-02-25 17:53:04 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef __FRAMEWORK_UIFACTORY_MENUBARFACTORY_HXX_ +#include <uifactory/menubarfactory.hxx> +#endif + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#ifndef __FRAMEWORK_THREADHELP_RESETABLEGUARD_HXX_ +#include <threadhelp/resetableguard.hxx> +#endif + +#ifndef __FRAMEWORK_SERVICES_H_ +#include "services.h" +#endif + +#ifndef __FRAMEWORK_UIELEMENT_MENUBARWRAPPER_HXX_ +#include <uielement/menubarwrapper.hxx> +#endif + +#ifndef __FRAMEWORK_HELPER_MODULEIDENTIFIER_HXX_ +#include <helper/moduleidentifier.hxx> +#endif + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_ +#include <com/sun/star/util/XURLTransformer.hpp> +#endif + +#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ +#include <com/sun/star/frame/XFrame.hpp> +#endif + +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include <com/sun/star/frame/XModel.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> +#endif + +#ifndef _DRAFTS_COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_ +#include <drafts/com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> +#endif + +#ifndef _DRAFTS_COM_SUN_STAR_UI_XUICONFIGURATIONMANAGERSUPLLIER_HPP_ +#include <drafts/com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> +#endif + +//_________________________________________________________________________________________________________________ +// includes of other projects +//_________________________________________________________________________________________________________________ + +#ifndef _VCL_MENU_HXX_ +#include <vcl/menu.hxx> +#endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif +#ifndef _URLOBJ_HXX +#include <tools/urlobj.hxx> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +//_________________________________________________________________________________________________________________ +// Defines +//_________________________________________________________________________________________________________________ +// + +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::frame; +using namespace com::sun::star::beans; +using namespace com::sun::star::util; +using namespace drafts::com::sun::star::ui; + +namespace framework +{ + +//***************************************************************************************************************** +// XInterface, XTypeProvider, XServiceInfo +//***************************************************************************************************************** +DEFINE_XINTERFACE_3 ( MenuBarFactory , + OWeakObject , + DIRECT_INTERFACE( css::lang::XTypeProvider ), + DIRECT_INTERFACE( css::lang::XServiceInfo ), + DIRECT_INTERFACE( drafts::com::sun::star::ui::XUIElementFactory ) + ) + +DEFINE_XTYPEPROVIDER_3 ( MenuBarFactory , + css::lang::XTypeProvider , + css::lang::XServiceInfo , + drafts::com::sun::star::ui::XUIElementFactory + ) + +DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( MenuBarFactory , + ::cppu::OWeakObject , + SERVICENAME_MENUBARFACTORY , + IMPLEMENTATIONNAME_MENUBARFACTORY + ) + +DEFINE_INIT_SERVICE ( MenuBarFactory, {} ) + +MenuBarFactory::MenuBarFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : + ThreadHelpBase() + , m_xServiceManager( xServiceManager ) + , m_xModuleManager( xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY ) +{ +} + +MenuBarFactory::~MenuBarFactory() +{ +} + +// XUIElementFactory +Reference< XUIElement > SAL_CALL MenuBarFactory::createUIElement( + const ::rtl::OUString& ResourceURL, + const Sequence< PropertyValue >& Args ) +throw ( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ) +{ + // SAFE + ResetableGuard aLock( m_aLock ); + + Reference< XUIConfigurationManager > xConfigSource; + Reference< XFrame > xFrame; + rtl::OUString aResourceURL( ResourceURL ); + sal_Bool bPersistent( sal_True ); + sal_Bool bMenuOnly( sal_False ); + + for ( sal_Int32 n = 0; n < Args.getLength(); n++ ) + { + if ( Args[n].Name.equalsAscii( "ConfigurationSource" )) + Args[n].Value >>= xConfigSource; + else if ( Args[n].Name.equalsAscii( "Frame" )) + Args[n].Value >>= xFrame; + else if ( Args[n].Name.equalsAscii( "ResourceURL" )) + Args[n].Value >>= aResourceURL; + else if ( Args[n].Name.equalsAscii( "Persistent" )) + Args[n].Value >>= bPersistent; + else if ( Args[n].Name.equalsAscii( "MenuOnly" )) + Args[n].Value >>= bMenuOnly; + } + + Reference< XUIConfigurationManager > xCfgMgr; + if ( aResourceURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/" ))) != 0 ) + throw IllegalArgumentException(); + else + { + // Identify frame and determine document based ui configuration manager/module ui configuration manager + if ( xFrame.is() && !xConfigSource.is() ) + { + bool bHasSettings( false ); + Reference< XModel > xModel; + + Reference< XController > xController = xFrame->getController(); + if ( xController.is() ) + xModel = xController->getModel(); + + if ( xModel.is() ) + { + Reference< XUIConfigurationManagerSupplier > xUIConfigurationManagerSupplier( xModel, UNO_QUERY ); + if ( xUIConfigurationManagerSupplier.is() ) + { + xCfgMgr = xUIConfigurationManagerSupplier->getUIConfigurationManager(); + bHasSettings = xCfgMgr->hasSettings( aResourceURL ); + } + } + + if ( !bHasSettings ) + { + rtl::OUString aModuleIdentifier = m_xModuleManager->identify( Reference< XInterface >( xFrame, UNO_QUERY )); + if ( aModuleIdentifier.getLength() ) + { + Reference< ::drafts::com::sun::star::ui::XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier( + m_xServiceManager->createInstance( SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ), UNO_QUERY ); + xCfgMgr = xModuleCfgSupplier->getUIConfigurationManager( aModuleIdentifier ); + bHasSettings = xCfgMgr->hasSettings( aResourceURL ); + } + } + } + } + + PropertyValue aPropValue; + Sequence< Any > aPropSeq( 5 ); + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); + aPropValue.Value <<= xFrame; + aPropSeq[0] <<= aPropValue; + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" )); + aPropValue.Value <<= xCfgMgr; + aPropSeq[1] <<= aPropValue; + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" )); + aPropValue.Value <<= aResourceURL; + aPropSeq[2] <<= aPropValue; + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" )); + aPropValue.Value <<= bPersistent; + aPropSeq[3] <<= aPropValue; + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MenuOnly" )); + aPropValue.Value <<= bMenuOnly; + aPropSeq[4] <<= aPropValue; + + vos::OGuard aGuard( Application::GetSolarMutex() ); + MenuBarWrapper* pMenuBarWrapper = new MenuBarWrapper( m_xServiceManager ); + Reference< drafts::com::sun::star::ui::XUIElement > xMenuBar( (OWeakObject *)pMenuBarWrapper, UNO_QUERY ); + Reference< XInitialization > xInit( xMenuBar, UNO_QUERY ); + xInit->initialize( aPropSeq ); + return xMenuBar; +} + +} // namespace framework |