2000-10-26 08:46:14 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 08:28:44 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
2005-09-08 08:28:44 -05:00
|
|
|
* $RCSfile: exsrcbrw.cxx,v $
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
2005-09-23 06:20:58 -05:00
|
|
|
* $Revision: 1.28 $
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
2005-09-23 06:20:58 -05:00
|
|
|
* last change: $Author: hr $ $Date: 2005-09-23 12:20:58 $
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
2005-09-08 08:28:44 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 08:28:44 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
2005-09-08 08:28:44 -05:00
|
|
|
* 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.
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
2005-09-08 08:28:44 -05:00
|
|
|
* 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.
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
2005-09-08 08:28:44 -05:00
|
|
|
* 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
|
2000-10-26 08:46:14 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _SBA_EXTCTRLR_HXX
|
|
|
|
#include "exsrcbrw.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_FORM_FORMCOMPONENTTYPE_HPP_
|
|
|
|
#include <com/sun/star/form/FormComponentType.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
|
|
|
|
#include <com/sun/star/util/XURLTransformer.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_FORM_XGRIDCOLUMNFACTORY_HPP_
|
|
|
|
#include <com/sun/star/form/XGridColumnFactory.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_FORM_XFORMCONTROLLER_HPP_
|
|
|
|
#include <com/sun/star/form/XFormController.hpp>
|
|
|
|
#endif
|
2001-08-16 04:39:55 -05:00
|
|
|
#ifndef _COM_SUN_STAR_FORM_XLOADABLE_HPP_
|
|
|
|
#include <com/sun/star/form/XLoadable.hpp>
|
|
|
|
#endif
|
2001-10-16 08:43:19 -05:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HPP_
|
|
|
|
#include <com/sun/star/frame/FrameSearchFlag.hpp>
|
|
|
|
#endif
|
2000-10-26 08:46:14 -05:00
|
|
|
#ifndef _SBA_FORMADAPTER_HXX
|
|
|
|
#include "formadapter.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
|
|
|
|
#include "dbustrings.hrc"
|
|
|
|
#endif
|
2000-12-15 08:54:12 -06:00
|
|
|
#ifndef _DBU_REGHELPER_HXX_
|
|
|
|
#include "dbu_reghelper.hxx"
|
2000-10-26 08:46:14 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::lang;
|
2001-08-16 04:39:55 -05:00
|
|
|
using namespace ::com::sun::star::form;
|
2001-10-16 08:43:19 -05:00
|
|
|
using namespace ::com::sun::star::frame;
|
2000-10-26 08:46:14 -05:00
|
|
|
using namespace dbaui;
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//= SbaExternalSourceBrowser
|
|
|
|
//==============================================================================
|
|
|
|
extern "C" void SAL_CALL createRegistryInfo_OFormGridView()
|
|
|
|
{
|
|
|
|
static OMultiInstanceAutoRegistration< SbaExternalSourceBrowser > aAutoRegistration;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL SbaExternalSourceBrowser::queryInterface(const Type& _rType) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
Any aRet = SbaXDataBrowserController::queryInterface(_rType);
|
|
|
|
if(!aRet.hasValue())
|
|
|
|
aRet = ::cppu::queryInterface(_rType,
|
|
|
|
(::com::sun::star::util::XModifyBroadcaster*)this,
|
|
|
|
(::com::sun::star::form::XLoadListener*)this);
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
2005-09-23 06:20:58 -05:00
|
|
|
DBG_NAME(SbaExternalSourceBrowser)
|
2000-10-26 08:46:14 -05:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
SbaExternalSourceBrowser::SbaExternalSourceBrowser(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rM)
|
|
|
|
:SbaXDataBrowserController(_rM)
|
|
|
|
,m_pDataSourceImpl(NULL)
|
2001-08-14 06:12:43 -05:00
|
|
|
,m_aModifyListeners(getMutex())
|
2004-02-04 06:53:58 -06:00
|
|
|
,m_bInQueryDispatch( sal_False )
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
2005-09-23 06:20:58 -05:00
|
|
|
DBG_CTOR(SbaExternalSourceBrowser,NULL);
|
|
|
|
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
SbaExternalSourceBrowser::~SbaExternalSourceBrowser()
|
|
|
|
{
|
2005-09-23 06:20:58 -05:00
|
|
|
|
|
|
|
DBG_DTOR(SbaExternalSourceBrowser,NULL);
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
2001-05-16 08:28:02 -05:00
|
|
|
|
2000-10-26 08:46:14 -05:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
::comphelper::StringSequence SAL_CALL SbaExternalSourceBrowser::getSupportedServiceNames() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getSupportedServiceNames_Static();
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SbaExternalSourceBrowser::getImplementationName_Static() throw(RuntimeException)
|
|
|
|
{
|
2004-08-02 09:34:10 -05:00
|
|
|
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.OFormGridView"));
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
::comphelper::StringSequence SbaExternalSourceBrowser::getSupportedServiceNames_Static() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
::comphelper::StringSequence aSupported(1);
|
2004-08-02 09:34:10 -05:00
|
|
|
aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.FormGridView"));
|
2000-10-26 08:46:14 -05:00
|
|
|
return aSupported;
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > SAL_CALL SbaExternalSourceBrowser::Create(const Reference<XMultiServiceFactory >& _rxFactory)
|
|
|
|
{
|
|
|
|
return *(new SbaExternalSourceBrowser(_rxFactory));
|
|
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL SbaExternalSourceBrowser::getImplementationName() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getImplementationName_Static();
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XRowSet > SbaExternalSourceBrowser::CreateForm()
|
|
|
|
{
|
|
|
|
m_pDataSourceImpl = new SbaXFormAdapter();
|
|
|
|
return m_pDataSourceImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool SbaExternalSourceBrowser::InitializeForm(const Reference< XRowSet > & xForm)
|
|
|
|
{
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
sal_Bool SbaExternalSourceBrowser::LoadForm()
|
|
|
|
{
|
|
|
|
// as we don't have a main form (yet), we have nothing to do
|
|
|
|
// we don't call FormLoaded, because this expects a working data source
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SbaExternalSourceBrowser::modified(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
SbaXDataBrowserController::modified(aEvent);
|
|
|
|
|
|
|
|
// multiplex this event to all my listeners
|
|
|
|
::com::sun::star::lang::EventObject aEvt(*this);
|
|
|
|
::cppu::OInterfaceIteratorHelper aIt(m_aModifyListeners);
|
|
|
|
while (aIt.hasMoreElements())
|
|
|
|
((::com::sun::star::util::XModifyListener*)aIt.next())->modified(aEvt);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2001-09-13 08:15:52 -05:00
|
|
|
void SAL_CALL SbaExternalSourceBrowser::dispatch(const ::com::sun::star::util::URL& aURL, const Sequence< ::com::sun::star::beans::PropertyValue>& aArgs) throw(::com::sun::star::uno::RuntimeException)
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
|
|
|
const ::com::sun::star::beans::PropertyValue* pArguments = aArgs.getConstArray();
|
|
|
|
if (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AddGridColumn")))
|
|
|
|
{
|
|
|
|
// search the argument describing the column to create
|
|
|
|
::rtl::OUString sControlType;
|
2001-03-19 05:38:43 -06:00
|
|
|
sal_Int32 nControlPos = -1;
|
2000-10-26 08:46:14 -05:00
|
|
|
Sequence< ::com::sun::star::beans::PropertyValue> aControlProps;
|
2003-12-01 11:01:46 -06:00
|
|
|
sal_uInt16 i;
|
|
|
|
for ( i = 0; i < aArgs.getLength(); ++i, ++pArguments )
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
|
|
|
if (pArguments->Name.equals(::rtl::OUString::createFromAscii("ColumnType")))
|
|
|
|
{
|
|
|
|
sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const ::rtl::OUString*)0));
|
2001-03-23 06:33:59 -06:00
|
|
|
OSL_ENSURE(bCorrectType, "invalid type for argument \"ColumnType\" !");
|
2000-10-26 08:46:14 -05:00
|
|
|
if (bCorrectType)
|
|
|
|
sControlType = ::comphelper::getString(pArguments->Value);
|
|
|
|
}
|
|
|
|
else if (pArguments->Name.equals(::rtl::OUString::createFromAscii("ColumnPosition")))
|
|
|
|
{
|
|
|
|
sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const sal_Int16*)0));
|
2001-03-23 06:33:59 -06:00
|
|
|
OSL_ENSURE(bCorrectType, "invalid type for argument \"ColumnPosition\" !");
|
2000-10-26 08:46:14 -05:00
|
|
|
if (bCorrectType)
|
|
|
|
nControlPos = ::comphelper::getINT16(pArguments->Value);
|
|
|
|
}
|
|
|
|
else if (pArguments->Name.equals(::rtl::OUString::createFromAscii("ColumnProperties")))
|
|
|
|
{
|
|
|
|
sal_Bool bCorrectType = pArguments->Value.getValueType().equals(::getCppuType((const Sequence< ::com::sun::star::beans::PropertyValue>*)0));
|
2001-03-23 06:33:59 -06:00
|
|
|
OSL_ENSURE(bCorrectType, "invalid type for argument \"ColumnProperties\" !");
|
2000-10-26 08:46:14 -05:00
|
|
|
if (bCorrectType)
|
|
|
|
aControlProps = *(Sequence< ::com::sun::star::beans::PropertyValue>*)pArguments->Value.getValue();
|
|
|
|
}
|
|
|
|
else
|
2001-04-03 08:16:03 -05:00
|
|
|
OSL_ENSURE(sal_False, ((ByteString("SbaExternalSourceBrowser::dispatch(AddGridColumn) : unknown argument (") += ByteString((const sal_Unicode*)pArguments->Name, gsl_getSystemTextEncoding()).GetBuffer()) += ") !").GetBuffer());
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
if (!sControlType.getLength())
|
|
|
|
{
|
2001-04-03 08:16:03 -05:00
|
|
|
OSL_ENSURE(sal_False, "SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnType) !");
|
2000-10-26 08:46:14 -05:00
|
|
|
sControlType = ::rtl::OUString::createFromAscii("TextField");
|
|
|
|
}
|
2001-03-23 06:33:59 -06:00
|
|
|
OSL_ENSURE(aControlProps.getLength(), "SbaExternalSourceBrowser::dispatch(AddGridColumn) : missing argument (ColumnProperties) !");
|
2000-10-26 08:46:14 -05:00
|
|
|
|
|
|
|
// create the col
|
|
|
|
Reference< ::com::sun::star::form::XGridColumnFactory > xColFactory(getControlModel(), UNO_QUERY);
|
|
|
|
Reference< ::com::sun::star::beans::XPropertySet > xNewCol = xColFactory->createColumn(sControlType);
|
2001-05-11 10:14:23 -05:00
|
|
|
Reference< XPropertySetInfo > xNewColProperties;
|
|
|
|
if (xNewCol.is())
|
|
|
|
xNewColProperties = xNewCol->getPropertySetInfo();
|
2000-10-26 08:46:14 -05:00
|
|
|
// set it's properties
|
2001-05-11 10:14:23 -05:00
|
|
|
if (xNewColProperties.is())
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
2001-05-11 10:14:23 -05:00
|
|
|
const ::com::sun::star::beans::PropertyValue* pControlProps = aControlProps.getConstArray();
|
|
|
|
for (i=0; i<aControlProps.getLength(); ++i, ++pControlProps)
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
2001-05-11 10:14:23 -05:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if (xNewColProperties->hasPropertyByName(pControlProps->Name))
|
|
|
|
xNewCol->setPropertyValue(pControlProps->Name, pControlProps->Value);
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
|
|
|
{
|
|
|
|
OSL_ENSURE(sal_False,
|
|
|
|
( ByteString("SbaExternalSourceBrowser::dispatch : could not set a column property (")
|
2001-07-17 07:07:48 -05:00
|
|
|
+= ByteString(pControlProps->Name.getStr(), (sal_uInt16)pControlProps->Name.getLength(), RTL_TEXTENCODING_ASCII_US)
|
2001-05-11 10:14:23 -05:00
|
|
|
+= ByteString(")!")).GetBuffer());
|
|
|
|
}
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// correct the position
|
|
|
|
Reference< ::com::sun::star::container::XIndexContainer > xColContainer(getControlModel(), UNO_QUERY);
|
|
|
|
|
|
|
|
if (nControlPos > xColContainer->getCount())
|
|
|
|
nControlPos = xColContainer->getCount();
|
|
|
|
if (nControlPos < 0)
|
|
|
|
nControlPos = 0;
|
|
|
|
|
|
|
|
// append the column
|
|
|
|
xColContainer->insertByIndex(nControlPos, makeAny(xNewCol));
|
|
|
|
}
|
|
|
|
else if (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/ClearView")))
|
|
|
|
{
|
|
|
|
ClearView();
|
|
|
|
}
|
|
|
|
else if (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AttachToForm")))
|
|
|
|
{
|
|
|
|
if (!m_pDataSourceImpl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Reference< XRowSet > xMasterForm;
|
|
|
|
// search the arguments for he master form
|
|
|
|
for (sal_uInt16 i=0; i<aArgs.getLength(); ++i, ++pArguments)
|
|
|
|
{
|
|
|
|
if ((pArguments->Name.equals(::rtl::OUString::createFromAscii("MasterForm"))) && (pArguments->Value.getValueTypeClass() == TypeClass_INTERFACE))
|
|
|
|
{
|
|
|
|
xMasterForm = Reference< XRowSet > (*(Reference< XInterface > *)pArguments->Value.getValue(), UNO_QUERY);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!xMasterForm.is())
|
|
|
|
{
|
2001-04-03 08:16:03 -05:00
|
|
|
OSL_ENSURE(sal_False, "SbaExternalSourceBrowser::dispatch(FormSlots/AttachToForm) : please specify a form to attach to as argument !");
|
2000-10-26 08:46:14 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Attach(xMasterForm);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SbaXDataBrowserController::dispatch(aURL, aArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
Reference< ::com::sun::star::frame::XDispatch > SAL_CALL SbaExternalSourceBrowser::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::frame::XDispatch > xReturn;
|
|
|
|
if (m_bInQueryDispatch)
|
|
|
|
return xReturn;
|
|
|
|
|
|
|
|
m_bInQueryDispatch = sal_True;
|
|
|
|
|
|
|
|
if ( (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AttachToForm")))
|
|
|
|
// attach a new external form
|
|
|
|
|| (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/AddGridColumn")))
|
|
|
|
// add a column to the grid
|
|
|
|
|| (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/ClearView")))
|
|
|
|
// clear the grid
|
|
|
|
)
|
|
|
|
xReturn = (::com::sun::star::frame::XDispatch*)this;
|
|
|
|
|
|
|
|
if ( !xReturn.is()
|
|
|
|
&& ( (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToFirst")))
|
|
|
|
|| (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToPrev")))
|
|
|
|
|| (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToNext")))
|
|
|
|
|| (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToLast")))
|
|
|
|
|| (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/moveToNew")))
|
|
|
|
|| (aURL.Complete.equals(::rtl::OUString::createFromAscii(".uno:FormSlots/undoRecord")))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
2001-05-16 06:29:39 -05:00
|
|
|
OSL_ENSURE(aURL.Mark.getLength() == 0, "SbaExternalSourceBrowser::queryDispatch : the ::com::sun::star::util::URL shouldn't have a mark !");
|
2000-10-26 08:46:14 -05:00
|
|
|
::com::sun::star::util::URL aNewUrl = aURL;
|
|
|
|
|
|
|
|
// split the ::com::sun::star::util::URL
|
2002-01-24 10:43:35 -06:00
|
|
|
OSL_ENSURE( m_xUrlTransformer.is(), "SbaExternalSourceBrowser::queryDispatch : could not create an URLTransformer !" );
|
|
|
|
if ( m_xUrlTransformer.is() )
|
|
|
|
m_xUrlTransformer->parseStrict( aNewUrl );
|
2000-10-26 08:46:14 -05:00
|
|
|
|
|
|
|
// set a new mark
|
|
|
|
aNewUrl.Mark = ::rtl::OUString::createFromAscii("DB/FormGridView");
|
|
|
|
// this controller is instantiated when somebody dispatches the ".component:DB/FormGridView" in any
|
|
|
|
// frame, so we use "FormGridView" as mark that a dispatch request came from this view
|
|
|
|
|
2002-01-24 10:43:35 -06:00
|
|
|
if (m_xUrlTransformer.is())
|
|
|
|
m_xUrlTransformer->assemble(aNewUrl);
|
2000-10-26 08:46:14 -05:00
|
|
|
|
|
|
|
Reference< ::com::sun::star::frame::XDispatchProvider > xFrameDispatcher(m_xCurrentFrame, UNO_QUERY);
|
|
|
|
if (xFrameDispatcher.is())
|
2001-10-16 08:43:19 -05:00
|
|
|
xReturn = xFrameDispatcher->queryDispatch(aNewUrl, aTargetFrameName, FrameSearchFlag::PARENT);
|
2000-10-26 08:46:14 -05:00
|
|
|
|
|
|
|
#if SUPD<=548 && !PRIV_DEBUG
|
|
|
|
xReturn = NULL;
|
|
|
|
// in version 548 the dispatch interception and the task-local beamer will work ... me hopes
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!xReturn.is())
|
|
|
|
xReturn = SbaXDataBrowserController::queryDispatch(aURL, aTargetFrameName, nSearchFlags);
|
|
|
|
|
|
|
|
m_bInQueryDispatch = sal_False;
|
|
|
|
return xReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2001-03-01 08:17:55 -06:00
|
|
|
void SAL_CALL SbaExternalSourceBrowser::disposing()
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
|
|
|
// say our modify listeners goodbye
|
|
|
|
::com::sun::star::lang::EventObject aEvt;
|
|
|
|
aEvt.Source = (XWeak*) this;
|
|
|
|
m_aModifyListeners.disposeAndClear(aEvt);
|
|
|
|
|
|
|
|
stopListening();
|
|
|
|
|
2001-03-01 08:17:55 -06:00
|
|
|
SbaXDataBrowserController::disposing();
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaExternalSourceBrowser::addModifyListener(const Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
m_aModifyListeners.addInterface(aListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaExternalSourceBrowser::removeModifyListener(const Reference< ::com::sun::star::util::XModifyListener > & aListener) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
m_aModifyListeners.removeInterface(aListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaExternalSourceBrowser::unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
if (m_pDataSourceImpl && (m_pDataSourceImpl->getAttachedForm() == aEvent.Source))
|
|
|
|
{
|
|
|
|
ClearView();
|
|
|
|
}
|
|
|
|
|
|
|
|
SbaXDataBrowserController::unloading(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SbaExternalSourceBrowser::Attach(const Reference< XRowSet > & xMaster)
|
|
|
|
{
|
|
|
|
Any aOldPos;
|
2001-08-21 08:18:51 -05:00
|
|
|
sal_Bool bWasInsertRow = sal_False;
|
2001-03-01 04:06:16 -06:00
|
|
|
sal_Bool bBeforeFirst = sal_True;
|
|
|
|
sal_Bool bAfterLast = sal_True;
|
2001-08-21 08:18:51 -05:00
|
|
|
Reference< XResultSet > xResultSet(xMaster, UNO_QUERY);
|
|
|
|
Reference< XRowLocate > xCursor(xMaster, UNO_QUERY);
|
|
|
|
Reference< XPropertySet > xMasterProps(xMaster, UNO_QUERY);
|
2002-01-29 05:24:44 -06:00
|
|
|
|
|
|
|
setLoadingStarted();
|
|
|
|
|
2001-08-21 08:18:51 -05:00
|
|
|
try
|
2001-03-01 04:06:16 -06:00
|
|
|
{
|
2001-08-21 08:18:51 -05:00
|
|
|
// switch the control to design mode
|
|
|
|
if (getBrowserView() && getBrowserView()->getGridControl().is())
|
|
|
|
getBrowserView()->getGridControl()->setDesignMode(sal_True);
|
2001-03-01 04:06:16 -06:00
|
|
|
|
2001-08-21 08:18:51 -05:00
|
|
|
// the grid will move the form's cursor to the first record, but we want the form to remain unchanged
|
|
|
|
// restore the old position
|
|
|
|
if (xCursor.is() && xResultSet.is())
|
|
|
|
{
|
|
|
|
bBeforeFirst = xResultSet->isBeforeFirst();
|
|
|
|
bAfterLast = xResultSet->isAfterLast();
|
|
|
|
if(!bBeforeFirst && !bAfterLast)
|
|
|
|
aOldPos = xCursor->getBookmark();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xMasterProps.is())
|
|
|
|
xMasterProps->getPropertyValue(PROPERTY_ISNEW) >>= bWasInsertRow;
|
|
|
|
}
|
|
|
|
catch(Exception&)
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
2001-08-21 08:18:51 -05:00
|
|
|
OSL_ENSURE(sal_False, "SbaExternalSourceBrowser::Attach: caught an exception in part 1 (analyzing)!");
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
stopListening();
|
|
|
|
m_pDataSourceImpl->AttachForm(xMaster);
|
|
|
|
startListening();
|
|
|
|
|
|
|
|
if (xMaster.is())
|
|
|
|
{
|
2000-11-03 07:44:21 -06:00
|
|
|
// at this point we have to reset the formatter for the new form
|
|
|
|
initFormatter();
|
2001-08-16 04:39:55 -05:00
|
|
|
// assume that the master form is already loaded
|
2003-04-15 10:03:08 -05:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2001-08-16 04:39:55 -05:00
|
|
|
{
|
|
|
|
Reference< XLoadable > xLoadable( xMaster, UNO_QUERY );
|
|
|
|
OSL_ENSURE( xLoadable.is() && xLoadable->isLoaded(), "SbaExternalSourceBrowser::Attach: master is not loaded!" );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-07-17 07:07:48 -05:00
|
|
|
LoadFinished(sal_True);
|
2000-10-26 08:46:14 -05:00
|
|
|
|
|
|
|
Reference< XResultSetUpdate > xUpdate(xMaster, UNO_QUERY);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (bWasInsertRow && xUpdate.is())
|
|
|
|
xUpdate->moveToInsertRow();
|
|
|
|
else if (xCursor.is() && aOldPos.hasValue())
|
|
|
|
xCursor->moveToBookmark(aOldPos);
|
2001-03-01 04:06:16 -06:00
|
|
|
else if(bBeforeFirst && xResultSet.is())
|
|
|
|
xResultSet->beforeFirst();
|
|
|
|
else if(bAfterLast && xResultSet.is())
|
|
|
|
xResultSet->afterLast();
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
2001-03-01 04:06:16 -06:00
|
|
|
catch(Exception&)
|
2000-10-26 08:46:14 -05:00
|
|
|
{
|
2001-04-03 08:16:03 -05:00
|
|
|
OSL_ENSURE(sal_False, "SbaExternalSourceBrowser::Attach : couldn't restore the cursor position !");
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SbaExternalSourceBrowser::ClearView()
|
|
|
|
{
|
|
|
|
// set a new (empty) datasource
|
|
|
|
Attach(Reference< XRowSet > ());
|
|
|
|
|
|
|
|
|
|
|
|
// clear all cols in the grid
|
|
|
|
Reference< ::com::sun::star::container::XIndexContainer > xColContainer(getControlModel(), UNO_QUERY);
|
|
|
|
while (xColContainer->getCount() > 0)
|
|
|
|
xColContainer->removeByIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SAL_CALL SbaExternalSourceBrowser::disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
if (m_pDataSourceImpl && (m_pDataSourceImpl->getAttachedForm() == Source.Source))
|
|
|
|
{
|
|
|
|
ClearView();
|
|
|
|
}
|
|
|
|
|
2001-01-09 08:52:33 -06:00
|
|
|
SbaXDataBrowserController::disposing(Source);
|
2000-10-26 08:46:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SbaExternalSourceBrowser::startListening()
|
|
|
|
{
|
|
|
|
if (m_pDataSourceImpl && m_pDataSourceImpl->getAttachedForm().is())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::form::XLoadable > xLoadable(m_pDataSourceImpl->getAttachedForm(), UNO_QUERY);
|
|
|
|
xLoadable->addLoadListener((::com::sun::star::form::XLoadListener*)this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void SbaExternalSourceBrowser::stopListening()
|
|
|
|
{
|
|
|
|
if (m_pDataSourceImpl && m_pDataSourceImpl->getAttachedForm().is())
|
|
|
|
{
|
|
|
|
Reference< ::com::sun::star::form::XLoadable > xLoadable(m_pDataSourceImpl->getAttachedForm(), UNO_QUERY);
|
|
|
|
xLoadable->removeLoadListener((::com::sun::star::form::XLoadListener*)this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2002-01-24 10:43:35 -06:00
|
|
|
//sal_uInt16 SbaExternalSourceBrowser::SaveData(sal_Bool bUI, sal_Bool bForBrowsing)
|
|
|
|
//{
|
|
|
|
// if (m_bSuspending)
|
|
|
|
// // don't ask the user if we're beeing suspended currently
|
|
|
|
// // this is the responsibility of our owner, as we are only an external view to an existing form
|
|
|
|
// // 73384 - 22.02.00 - FS
|
|
|
|
// return (sal_uInt16)sal_True;
|
|
|
|
//
|
|
|
|
// return SbaXDataBrowserController::SaveData(bUI, bForBrowsing);
|
|
|
|
//}
|
2000-10-26 08:46:14 -05:00
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
//==================================================================
|