Tag: cws_src680_odbmacros2 User: fs Date: 2008-02-06 08:35:14+0000 Modified: dba/dbaccess/source/ui/browser/dbloader.cxx
Log: copying the fix for #i85879# into this CWS: cleanup the toolbar mess in the data source browser File Changes: Directory: /dba/dbaccess/source/ui/browser/ =========================================== File [changed]: dbloader.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/dbloader.cxx?r1=1.31.64.4&r2=1.31.64.5 Delta lines: +96 -101 ---------------------- --- dbloader.cxx 2007-12-19 19:53:01+0000 1.31.64.4 +++ dbloader.cxx 2008-02-06 08:35:12+0000 1.31.64.5 @@ -4,9 +4,9 @@ * * $RCSfile: dbloader.cxx,v $ * - * $Revision: 1.31.64.4 $ + * $Revision: 1.31.64.5 $ * - * last change: $Author: fs $ $Date: 2007/12/19 19:53:01 $ + * last change: $Author: fs $ $Date: 2008/02/06 08:35:12 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,79 +36,37 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ -#include <toolkit/helper/vclunohelper.hxx> -#endif -#ifndef _URLOBJ_HXX //autogen -#include <tools/urlobj.hxx> -#endif -#ifndef TOOLS_DIAGNOSE_EX_H -#include <tools/diagnose_ex.h> -#endif -#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_ -#include <toolkit/awt/vclxwindow.hxx> -#endif -#ifndef _COM_SUN_STAR_FRAME_XCONTROLLER_HPP_ +#include "dbu_reghelper.hxx" +#include "dbustrings.hrc" +#include "UITools.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XSet.hpp> +#include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/frame/XController.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XFRAME_HPP_ #include <com/sun/star/frame/XFrame.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XFRAMELOADER_HPP_ #include <com/sun/star/frame/XFrameLoader.hpp> -#endif -#ifndef _COM_SUN_STAR_FRAME_XLOADEVENTLISTENER_HPP_ #include <com/sun/star/frame/XLoadEventListener.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ -#include <com/sun/star/lang/XServiceInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> -#endif -#include <com/sun/star/document/XEventListener.hpp> -#ifndef _COM_SUN_STAR_CONTAINER_XSET_HPP_ -#include <com/sun/star/container/XSet.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ -#include <com/sun/star/container/XNameAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_ #include <com/sun/star/registry/XRegistryKey.hpp> -#endif -#ifndef _CPPUHELPER_IMPLBASE2_HXX_ -#include <cppuhelper/implbase2.hxx> -#endif -#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX -#include <comphelper/namedvaluecollection.hxx> -#endif -#ifndef _DBU_REGHELPER_HXX_ -#include "dbu_reghelper.hxx" -#endif -#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_ -#include <com/sun/star/lang/XInitialization.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_ -#include <com/sun/star/container/XChild.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_ -#include <com/sun/star/sdbc/XDataSource.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ #include <com/sun/star/sdbc/XConnection.hpp> -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC -#include "dbustrings.hrc" -#endif -#ifndef _SV_SVAPP_HXX +#include <com/sun/star/frame/XModule.hpp> +/** === end UNO includes === **/ + +#include <com/sun/star/sdbc/XDataSource.hpp> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/componentcontext.hxx> +#include <cppuhelper/implbase2.hxx> +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/diagnose_ex.h> +#include <tools/urlobj.hxx> #include <vcl/svapp.hxx> -#endif -#ifndef DBAUI_TOOLS_HXX -#include "UITools.hxx" -#endif using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -242,21 +200,60 @@ m_aURL = rURL; m_aArgs = rArgs; - INetURLObject aParser(rURL); - // ich benutze nicht maURL, sondern rURL, denn zwischen dem Constructor und diesem Load hier kann sich die URL des Objektes - // schon geaendert haben (zum Beispiel durch Umbenennen) + ::comphelper::ComponentContext aContext( m_xServiceFactory ); + + struct ServiceNameToImplName + { + const sal_Char* pAsciiServiceName; + const sal_Char* pAsciiImplementationName; + ServiceNameToImplName( const sal_Char* _pService, const sal_Char* _pImpl ) + :pAsciiServiceName( _pService ) + ,pAsciiImplementationName( _pImpl ) + { + } + } aImplementations[] = { + ServiceNameToImplName( URL_COMPONENT_FORMGRIDVIEW, "org.openoffice.comp.dbu.OFormGridView" ), + ServiceNameToImplName( URL_COMPONENT_DATASOURCEBROWSER, "org.openoffice.comp.dbu.ODatasourceBrowser" ), + ServiceNameToImplName( URL_COMPONENT_QUERYDESIGN, "org.openoffice.comp.dbu.OQueryDesign" ), + ServiceNameToImplName( URL_COMPONENT_TABLEDESIGN, "org.openoffice.comp.dbu.OTableDesign" ), + ServiceNameToImplName( URL_COMPONENT_RELATIONDESIGN, "org.openoffice.comp.dbu.ORelationDesign" ) + }; + + INetURLObject aParser( rURL ); Reference< XController > xController; - if(aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == URL_COMPONENT_FORMGRIDVIEW) - xController.set(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OFormGridView")),UNO_QUERY); - else if(aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == URL_COMPONENT_DATASOURCEBROWSER ) - xController.set(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ODatasourceBrowser")),UNO_QUERY); - else if ( aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == URL_COMPONENT_QUERYDESIGN ) - xController.set(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OQueryDesign")),UNO_QUERY); - else if ( aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == URL_COMPONENT_TABLEDESIGN ) - xController.set(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.OTableDesign")),UNO_QUERY); - else if ( aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == URL_COMPONENT_RELATIONDESIGN ) - xController.set(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.ORelationDesign")),UNO_QUERY); - else if ( aParser.GetMainURL(INetURLObject::DECODE_TO_IURI) == URL_COMPONENT_REPORTDESIGN ) + + const ::rtl::OUString sComponentURL( aParser.GetMainURL( INetURLObject::DECODE_TO_IURI ) ); + for ( size_t i=0; i < sizeof( aImplementations ) / sizeof( aImplementations[0] ); ++i ) + { + if ( sComponentURL.equalsAscii( aImplementations[i].pAsciiServiceName ) ) + { + aContext.createComponent( aImplementations[i].pAsciiImplementationName, xController ); + break; + } + } + + // if a data source browser is loaded without its tree pane, then we assume it to be a + // table data view, effectively. In this case, we need to adjust the module identifier. + // 2008-02-05 / i85879 / [EMAIL PROTECTED] + ::comphelper::NamedValueCollection aArgs( rArgs ); + if ( ( sComponentURL == URL_COMPONENT_DATASOURCEBROWSER ) + && ( ( sal_False == aArgs.getOrDefault( (::rtl::OUString)PROPERTY_SHOWTREEVIEW, sal_True ) ) + || ( sal_False == aArgs.getOrDefault( (::rtl::OUString)PROPERTY_SHOWTREEVIEWBUTTON, sal_True ) ) + ) + ) + { + try + { + Reference< XModule > xModule( xController, UNO_QUERY_THROW ); + xModule->setIdentifier( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.TableDataView" ) ) ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + if ( sComponentURL == URL_COMPONENT_REPORTDESIGN ) { ::comphelper::NamedValueCollection aArgs( rArgs ); sal_Bool bPreview = aArgs.getOrDefault( "Preview", sal_False ); @@ -279,8 +276,6 @@ } } } - else - OSL_ENSURE(0,"wrong dispatch url!"); sal_Bool bSuccess = xController.is(); Reference< XModel > xDatabaseDocument; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
