2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* $RCSfile: fmtools.cxx,v $
|
|
|
|
* $Revision: 1.40 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-11 00:13:38 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 04:10:48 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svx.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#include <com/sun/star/io/XPersistObject.hpp>
|
2001-07-25 12:57:12 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
|
|
|
|
#include <com/sun/star/sdb/XCompletedConnection.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/Privilege.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/lang/Locale.hpp>
|
|
|
|
#include "fmtools.hxx"
|
2009-09-08 04:57:32 +00:00
|
|
|
#include "svx/dbtoolsclient.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "fmservs.hxx"
|
2007-06-27 17:16:03 +00:00
|
|
|
#include <svx/fmglob.hxx>
|
2001-07-25 12:57:12 +00:00
|
|
|
#include <vcl/stdtext.hxx>
|
|
|
|
#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
|
|
|
|
#include <toolkit/unohlp.hxx>
|
|
|
|
#endif
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
#include <com/sun/star/uno/XNamingService.hpp>
|
|
|
|
#include <com/sun/star/sdbc/XDataSource.hpp>
|
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdb/SQLContext.hpp>
|
|
|
|
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
|
|
|
|
#include <com/sun/star/sdb/XResultSetAccess.hpp>
|
2007-11-21 14:24:05 +00:00
|
|
|
#include <com/sun/star/sdb/ErrorCondition.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
|
|
|
#include <com/sun/star/util/NumberFormat.hpp>
|
|
|
|
#include <com/sun/star/io/XActiveDataSink.hpp>
|
|
|
|
#include <com/sun/star/io/XActiveDataSource.hpp>
|
|
|
|
#include <com/sun/star/script/XEventAttacherManager.hpp>
|
|
|
|
#include <com/sun/star/form/XForm.hpp>
|
|
|
|
#include <com/sun/star/form/XFormComponent.hpp>
|
|
|
|
#include <com/sun/star/util/XNumberFormatter.hpp>
|
|
|
|
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
|
|
|
|
#include <com/sun/star/util/Language.hpp>
|
|
|
|
#include <com/sun/star/util/XNumberFormats.hpp>
|
|
|
|
#include <com/sun/star/util/XNumberFormatTypes.hpp>
|
|
|
|
#include <com/sun/star/util/XCloneable.hpp>
|
|
|
|
#include <com/sun/star/io/XObjectInputStream.hpp>
|
|
|
|
#include <com/sun/star/io/XObjectOutputStream.hpp>
|
|
|
|
#include <com/sun/star/reflection/XIdlClass.hpp>
|
|
|
|
#include <com/sun/star/reflection/XIdlMethod.hpp>
|
|
|
|
#include <com/sun/star/beans/XIntrospection.hpp>
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
|
|
|
#include <com/sun/star/container/XChild.hpp>
|
2001-07-25 12:57:12 +00:00
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
2004-05-10 12:14:34 +00:00
|
|
|
#include <com/sun/star/awt/LineEndFormat.hpp>
|
|
|
|
#include <com/sun/star/form/XGridColumnFactory.hpp>
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <tools/string.hxx>
|
2005-04-13 07:29:42 +00:00
|
|
|
#include <basic/sbxvar.hxx>
|
2003-03-27 14:06:05 +00:00
|
|
|
#include <rtl/math.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
|
|
|
#ifndef _SVX_FMPROP_HRC
|
|
|
|
#include "fmprop.hrc"
|
|
|
|
#endif
|
|
|
|
#include <sfx2/bindings.hxx>
|
|
|
|
#include <svtools/eitem.hxx>
|
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#include <cppuhelper/servicefactory.hxx>
|
2000-10-20 13:18:57 +00:00
|
|
|
#include <comphelper/types.hxx>
|
|
|
|
#include <comphelper/property.hxx>
|
|
|
|
#include <comphelper/container.hxx>
|
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <comphelper/sequence.hxx>
|
2001-03-15 08:02:28 +00:00
|
|
|
#include <comphelper/extract.hxx>
|
2000-10-20 13:18:57 +00:00
|
|
|
#include <comphelper/uno3.hxx>
|
|
|
|
#include <connectivity/dbexception.hxx>
|
2001-03-15 08:02:28 +00:00
|
|
|
#include <comphelper/extract.hxx>
|
2004-04-13 09:59:42 +00:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
2003-03-27 14:06:05 +00:00
|
|
|
#include <algorithm>
|
2009-04-23 10:42:05 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-10-31 10:59:33 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
2000-11-09 09:07:35 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::frame;
|
2001-07-25 12:57:12 +00:00
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::task;
|
2004-05-10 12:14:34 +00:00
|
|
|
using namespace ::com::sun::star::form;
|
2000-12-18 07:22:38 +00:00
|
|
|
using namespace ::svxform;
|
2001-07-25 12:57:12 +00:00
|
|
|
using namespace ::connectivity::simple;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-11-21 14:24:05 +00:00
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
static bool lcl_shouldDisplayError( const Any& _rError )
|
|
|
|
{
|
|
|
|
SQLException aError;
|
|
|
|
if ( !( _rError >>= aError ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ( aError.Message.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "[OOoBase]" ) ) != 0 )
|
|
|
|
// it is an exception *not* thrown by an OOo Base core component
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// the only exception we do not display ATM is a RowSetVetoException, which
|
|
|
|
// has been raised because an XRowSetApprovalListener vetoed a change
|
|
|
|
if ( aError.ErrorCode + ErrorCondition::ROW_SET_OPERATION_VETOED == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// everything else is to be displayed
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-25 12:57:12 +00:00
|
|
|
// ------------------------------------------------------------------------------
|
2006-12-01 16:26:35 +00:00
|
|
|
void displayException(const Any& _rExcept, Window* _pParent)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::displayException" );
|
2007-11-21 14:24:05 +00:00
|
|
|
// check whether we need to display it
|
|
|
|
if ( !lcl_shouldDisplayError( _rExcept ) )
|
|
|
|
return;
|
|
|
|
|
2001-07-25 12:57:12 +00:00
|
|
|
try
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-07-25 12:57:12 +00:00
|
|
|
// the parent window
|
|
|
|
Window* pParentWindow = _pParent ? _pParent : GetpApp()->GetDefDialogParent();
|
|
|
|
Reference< XWindow > xParentWindow = VCLUnoHelper::GetInterface(pParentWindow);
|
|
|
|
|
|
|
|
Sequence< Any > aArgs(2);
|
2006-12-01 16:26:35 +00:00
|
|
|
aArgs[0] <<= PropertyValue(::rtl::OUString::createFromAscii("SQLException"), 0, _rExcept, PropertyState_DIRECT_VALUE);
|
2001-07-25 12:57:12 +00:00
|
|
|
aArgs[1] <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE);
|
|
|
|
|
|
|
|
static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog");
|
|
|
|
Reference< XExecutableDialog > xErrorDialog(
|
|
|
|
::comphelper::getProcessServiceFactory()->createInstanceWithArguments(s_sDialogServiceName, aArgs), UNO_QUERY);
|
|
|
|
if (xErrorDialog.is())
|
|
|
|
xErrorDialog->execute();
|
|
|
|
else
|
|
|
|
ShowServiceNotAvailableError(pParentWindow, s_sDialogServiceName, sal_True);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-07-25 12:57:12 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-07-25 12:57:12 +00:00
|
|
|
OSL_ENSURE(sal_False, "displayException: could not display the error message!");
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
2001-07-25 12:57:12 +00:00
|
|
|
void displayException(const ::com::sun::star::sdbc::SQLException& _rExcept, Window* _pParent)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-07-25 12:57:12 +00:00
|
|
|
displayException(makeAny(_rExcept), _pParent);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
2001-07-25 12:57:12 +00:00
|
|
|
void displayException(const ::com::sun::star::sdbc::SQLWarning& _rExcept, Window* _pParent)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-07-25 12:57:12 +00:00
|
|
|
displayException(makeAny(_rExcept), _pParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
void displayException(const ::com::sun::star::sdb::SQLContext& _rExcept, Window* _pParent)
|
|
|
|
{
|
|
|
|
displayException(makeAny(_rExcept), _pParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------
|
|
|
|
void displayException(const ::com::sun::star::sdb::SQLErrorEvent& _rEvent, Window* _pParent)
|
|
|
|
{
|
|
|
|
displayException(_rEvent.Reason, _pParent);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< XInterface > cloneUsingProperties(const Reference< ::com::sun::star::io::XPersistObject>& _xObj)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::cloneUsingProperties" );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!_xObj.is())
|
2003-03-27 14:06:05 +00:00
|
|
|
return Reference< XInterface >();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// create a new object
|
|
|
|
::rtl::OUString aObjectService = _xObj->getServiceName();
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::beans::XPropertySet> xDestSet(::comphelper::getProcessServiceFactory()->createInstance(aObjectService), UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!xDestSet.is())
|
|
|
|
{
|
|
|
|
DBG_ERROR("cloneUsingProperties : could not instantiate an object of the given type !");
|
2003-03-27 14:06:05 +00:00
|
|
|
return Reference< XInterface >();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
// transfer properties
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< XPropertySet > xSourceSet(_xObj, UNO_QUERY);
|
|
|
|
Reference< XPropertySetInfo > xSourceInfo( xSourceSet->getPropertySetInfo());
|
|
|
|
Sequence< Property> aSourceProperties = xSourceInfo->getProperties();
|
|
|
|
Reference< XPropertySetInfo > xDestInfo( xDestSet->getPropertySetInfo());
|
|
|
|
Sequence< Property> aDestProperties = xDestInfo->getProperties();
|
2000-09-18 16:07:07 +00:00
|
|
|
int nDestLen = aDestProperties.getLength();
|
|
|
|
|
2003-03-27 14:06:05 +00:00
|
|
|
Property* pSourceProps = aSourceProperties.getArray();
|
|
|
|
Property* pSourceEnd = pSourceProps + aSourceProperties.getLength();
|
|
|
|
Property* pDestProps = aDestProperties.getArray();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-03-27 14:06:05 +00:00
|
|
|
for (; pSourceProps != pSourceEnd; ++pSourceProps)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-03-27 14:06:05 +00:00
|
|
|
::com::sun::star::beans::Property* pResult = ::std::lower_bound(
|
|
|
|
pDestProps,
|
|
|
|
pDestProps + nDestLen,
|
|
|
|
pSourceProps->Name,
|
|
|
|
::comphelper::PropertyStringLessFunctor()
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( ( pResult != pDestProps + nDestLen )
|
|
|
|
&& ( pResult->Name == pSourceProps->Name )
|
|
|
|
&& ( pResult->Attributes == pSourceProps->Attributes )
|
|
|
|
&& ( (pResult->Attributes & PropertyAttribute::READONLY ) == 0 )
|
|
|
|
&& ( pResult->Type.equals( pSourceProps->Type ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
)
|
|
|
|
{ // Attribute/type are the same and the prop isn't readonly
|
|
|
|
try
|
|
|
|
{
|
|
|
|
xDestSet->setPropertyValue(pResult->Name, xSourceSet->getPropertyValue(pResult->Name));
|
|
|
|
}
|
2003-03-27 14:06:05 +00:00
|
|
|
catch(IllegalArgumentException e)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2006-06-19 14:58:52 +00:00
|
|
|
(void)e;
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
::rtl::OString sMessage("cloneUsingProperties : could not transfer the value for property \"");
|
2001-07-25 12:57:12 +00:00
|
|
|
sMessage = sMessage + ::rtl::OString(pResult->Name.getStr(), pResult->Name.getLength(), RTL_TEXTENCODING_ASCII_US);
|
2000-09-18 16:07:07 +00:00
|
|
|
sMessage = sMessage + '\"';
|
|
|
|
DBG_ERROR(sMessage);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-11 11:19:21 +00:00
|
|
|
return xDestSet.get();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
sal_Bool searchElement(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::searchElement" );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!xCont.is() || !xElement.is())
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
sal_Int32 nCount = xCont->getCount();
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< XInterface > xComp;
|
2000-09-18 16:07:07 +00:00
|
|
|
for (sal_Int32 i = 0; i < nCount; i++)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2000-11-07 12:16:50 +00:00
|
|
|
xCont->getByIndex(i) >>= xComp;
|
|
|
|
if (xComp.is())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
if ( xElement == xComp )
|
2000-09-18 16:07:07 +00:00
|
|
|
return sal_True;
|
|
|
|
else
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::container::XIndexAccess> xCont2(xComp, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xCont2.is() && searchElement(xCont2, xElement))
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-10-31 10:59:33 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getElementPos" );
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_Int32 nIndex = -1;
|
|
|
|
if (!xCont.is())
|
|
|
|
return nIndex;
|
|
|
|
|
|
|
|
|
2002-09-25 11:43:34 +00:00
|
|
|
Reference< XInterface > xNormalized( xElement, UNO_QUERY );
|
|
|
|
DBG_ASSERT( xNormalized.is(), "getElementPos: invalid element!" );
|
|
|
|
if ( xNormalized.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// Feststellen an welcher Position sich das Kind befindet
|
|
|
|
nIndex = xCont->getCount();
|
|
|
|
while (nIndex--)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
Reference< XInterface > xCurrent(xCont->getByIndex( nIndex ),UNO_QUERY);
|
2002-09-25 11:43:34 +00:00
|
|
|
DBG_ASSERT( xCurrent.get() == Reference< XInterface >( xCurrent, UNO_QUERY ).get(),
|
|
|
|
"getElementPos: container element not normalized!" );
|
|
|
|
if ( xNormalized.get() == xCurrent.get() )
|
2000-09-18 16:07:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-10-31 10:59:33 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-09-25 11:43:34 +00:00
|
|
|
DBG_ERROR( "getElementPos: caught an exception!" );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
String getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getFormComponentAccessPath" );
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY);
|
|
|
|
Reference< ::com::sun::star::container::XIndexAccess> xParent;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xChild.is())
|
2000-11-06 06:19:53 +00:00
|
|
|
xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// while the current content is a form
|
|
|
|
String sReturn;
|
|
|
|
String sCurrentIndex;
|
|
|
|
while (xChild.is())
|
|
|
|
{
|
|
|
|
// get the content's relative pos within it's parent container
|
|
|
|
sal_Int32 nPos = getElementPos(xParent, xChild);
|
|
|
|
|
|
|
|
// prepend this current relaive pos
|
|
|
|
sCurrentIndex = String::CreateFromInt32(nPos);
|
|
|
|
if (sReturn.Len() != 0)
|
|
|
|
{
|
|
|
|
sCurrentIndex += '\\';
|
|
|
|
sCurrentIndex += sReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
sReturn = sCurrentIndex;
|
|
|
|
|
|
|
|
// travel up
|
2000-11-06 06:19:53 +00:00
|
|
|
if (::comphelper::query_interface((Reference< XInterface >)xParent,xChild))
|
|
|
|
xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_rTopLevelElement = xParent;
|
|
|
|
return sReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
String getFormComponentAccessPath(const Reference< XInterface >& _xElement)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< XInterface > xDummy;
|
2000-09-18 16:07:07 +00:00
|
|
|
return getFormComponentAccessPath(_xElement, xDummy);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< XInterface > getElementFromAccessPath(const Reference< ::com::sun::star::container::XIndexAccess>& _xParent, const String& _rRelativePath)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getElementFromAccessPath" );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!_xParent.is())
|
2003-03-27 14:06:05 +00:00
|
|
|
return Reference< XInterface >();
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::container::XIndexAccess> xContainer(_xParent);
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< XInterface > xElement( _xParent);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
String sPath(_rRelativePath);
|
|
|
|
while (sPath.Len() && xContainer.is())
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
xub_StrLen nSepPos = sPath.Search((sal_Unicode)'\\');
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-06 06:19:53 +00:00
|
|
|
String sIndex(sPath.Copy(0, (nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos));
|
2000-09-18 16:07:07 +00:00
|
|
|
// DBG_ASSERT(sIndex.IsNumeric(), "getElementFromAccessPath : invalid path !");
|
|
|
|
|
2000-11-06 06:19:53 +00:00
|
|
|
sPath = sPath.Copy((nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos+1);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
::cppu::extractInterface(xElement, xContainer->getByIndex(sIndex.ToInt32()));
|
2000-11-06 06:19:53 +00:00
|
|
|
xContainer = Reference< ::com::sun::star::container::XIndexAccess>::query(xElement);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sPath.Len() != 0)
|
|
|
|
// the loop terminated because an element wasn't a container, but we stil have a path -> the path is invalid
|
|
|
|
xElement = NULL;
|
|
|
|
|
|
|
|
return xElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
// Vergleichen von PropertyInfo
|
|
|
|
extern "C" int
|
|
|
|
#if defined( WNT )
|
|
|
|
__cdecl
|
|
|
|
#endif
|
|
|
|
#if defined( ICC ) && defined( OS2 )
|
|
|
|
_Optlink
|
|
|
|
#endif
|
|
|
|
NameCompare(const void* pFirst, const void* pSecond)
|
|
|
|
{
|
|
|
|
return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
sal_Int32 findPos(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::findPos" );
|
2000-09-18 16:07:07 +00:00
|
|
|
const ::rtl::OUString* pStrList = rList.getConstArray();
|
|
|
|
::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString),
|
|
|
|
&NameCompare);
|
|
|
|
|
|
|
|
if (pResult)
|
|
|
|
return (pResult - pStrList);
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< ::com::sun::star::frame::XModel> getXModel(const Reference< XInterface >& xIface)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getXModel" );
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::frame::XModel> xModel(xIface, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xModel.is())
|
|
|
|
return xModel;
|
|
|
|
else
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::container::XChild> xChild(xIface, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xChild.is())
|
|
|
|
{
|
2003-03-27 14:06:05 +00:00
|
|
|
Reference< XInterface > xParent( xChild->getParent());
|
2000-09-18 16:07:07 +00:00
|
|
|
return getXModel(xParent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
::rtl::OUString getLabelName(const Reference< ::com::sun::star::beans::XPropertySet>& xControlModel)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getLabelName" );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!xControlModel.is())
|
|
|
|
return ::rtl::OUString();
|
|
|
|
|
2000-10-20 13:18:57 +00:00
|
|
|
if (::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xControlModel))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-07 12:16:50 +00:00
|
|
|
Reference< ::com::sun::star::beans::XPropertySet> xLabelSet;
|
|
|
|
xControlModel->getPropertyValue(FM_PROP_CONTROLLABEL) >>= xLabelSet;
|
|
|
|
if (xLabelSet.is() && ::comphelper::hasProperty(FM_PROP_LABEL, xLabelSet))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-07 12:16:50 +00:00
|
|
|
Any aLabel( xLabelSet->getPropertyValue(FM_PROP_LABEL) );
|
|
|
|
if ((aLabel.getValueTypeClass() == TypeClass_STRING) && ::comphelper::getString(aLabel).getLength())
|
|
|
|
return ::comphelper::getString(aLabel);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-20 13:18:57 +00:00
|
|
|
return ::comphelper::getString(xControlModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// = CursorWrapper
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor, sal_Bool bUseCloned)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
ImplConstruct(Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY), bUseCloned);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplConstruct(_rxCursor, bUseCloned);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
void CursorWrapper::ImplConstruct(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (bUseCloned)
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::sdb::XResultSetAccess> xAccess(_rxCursor, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
try
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
m_xMoveOperations = xAccess.is() ? xAccess->createResultSet() : Reference< ::com::sun::star::sdbc::XResultSet>();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-10-31 10:59:33 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_xMoveOperations = _rxCursor;
|
|
|
|
|
2002-07-31 07:47:53 +00:00
|
|
|
m_xBookmarkOperations = m_xBookmarkOperations.query( m_xMoveOperations );
|
|
|
|
m_xColumnsSupplier = m_xColumnsSupplier.query( m_xMoveOperations );
|
|
|
|
m_xPropertyAccess = m_xPropertyAccess.query( m_xMoveOperations );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-07-31 07:47:53 +00:00
|
|
|
if ( !m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is() || !m_xPropertyAccess.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{ // all or nothing !!
|
|
|
|
m_xMoveOperations = NULL;
|
|
|
|
m_xBookmarkOperations = NULL;
|
|
|
|
m_xColumnsSupplier = NULL;
|
|
|
|
}
|
2000-10-31 10:59:33 +00:00
|
|
|
else
|
|
|
|
m_xGeneric = m_xMoveOperations.get();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
const CursorWrapper& CursorWrapper::operator=(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
m_xMoveOperations = Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY);
|
|
|
|
m_xBookmarkOperations = Reference< ::com::sun::star::sdbcx::XRowLocate>(_rxCursor, UNO_QUERY);
|
|
|
|
m_xColumnsSupplier = Reference< ::com::sun::star::sdbcx::XColumnsSupplier>(_rxCursor, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is())
|
|
|
|
{ // all or nothing !!
|
|
|
|
m_xMoveOperations = NULL;
|
|
|
|
m_xBookmarkOperations = NULL;
|
|
|
|
m_xColumnsSupplier = NULL;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
FmXDisposeListener::~FmXDisposeListener()
|
|
|
|
{
|
|
|
|
setAdapter(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void FmXDisposeListener::setAdapter(FmXDisposeMultiplexer* pAdapter)
|
|
|
|
{
|
|
|
|
if (m_pAdapter)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(m_rMutex);
|
|
|
|
m_pAdapter->release();
|
|
|
|
m_pAdapter = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pAdapter)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard(m_rMutex);
|
|
|
|
m_pAdapter = pAdapter;
|
|
|
|
m_pAdapter->acquire();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
DBG_NAME(FmXDisposeMultiplexer);
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
FmXDisposeMultiplexer::FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const Reference< ::com::sun::star::lang::XComponent>& _rxObject, sal_Int16 _nId)
|
2006-06-19 14:58:52 +00:00
|
|
|
:m_xObject(_rxObject)
|
|
|
|
,m_pListener(_pListener)
|
2000-09-18 16:07:07 +00:00
|
|
|
,m_nId(_nId)
|
|
|
|
{
|
|
|
|
DBG_CTOR(FmXDisposeMultiplexer, NULL);
|
|
|
|
m_pListener->setAdapter(this);
|
|
|
|
|
|
|
|
if (m_xObject.is())
|
|
|
|
m_xObject->addEventListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
FmXDisposeMultiplexer::~FmXDisposeMultiplexer()
|
|
|
|
{
|
|
|
|
DBG_DTOR(FmXDisposeMultiplexer, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ::com::sun::star::lang::XEventListener
|
|
|
|
//------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
void FmXDisposeMultiplexer::disposing(const ::com::sun::star::lang::EventObject& _Source) throw( RuntimeException )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (m_pListener)
|
|
|
|
{
|
|
|
|
m_pListener->disposing(_Source, m_nId);
|
|
|
|
m_pListener->setAdapter(NULL);
|
|
|
|
m_pListener = NULL;
|
|
|
|
}
|
|
|
|
m_xObject = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void FmXDisposeMultiplexer::dispose()
|
|
|
|
{
|
|
|
|
if (m_xObject.is())
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
m_xObject->removeEventListener(this);
|
|
|
|
m_xObject = NULL;
|
|
|
|
|
|
|
|
m_pListener->setAdapter(NULL);
|
|
|
|
m_pListener = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
sal_Int16 getControlTypeByObject(const Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getControlTypeByObject" );
|
2000-09-18 16:07:07 +00:00
|
|
|
// ask for the persistent service name
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::io::XPersistObject> xPersistence(_rxObject, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
DBG_ASSERT(xPersistence.is(), "::getControlTypeByObject : argument shold be an ::com::sun::star::io::XPersistObject !");
|
|
|
|
if (!xPersistence.is())
|
|
|
|
return OBJ_FM_CONTROL;
|
|
|
|
|
|
|
|
::rtl::OUString sPersistentServiceName = xPersistence->getServiceName();
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_EDIT)) // 5.0-Name
|
|
|
|
{
|
|
|
|
// may be a simple edit field or a formatted field, dependent of the supported services
|
|
|
|
if (_rxObject->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD))
|
|
|
|
return OBJ_FM_FORMATTEDFIELD;
|
|
|
|
return OBJ_FM_EDIT;
|
|
|
|
}
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_TEXTFIELD))
|
|
|
|
return OBJ_FM_EDIT;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_COMMANDBUTTON))
|
|
|
|
return OBJ_FM_BUTTON;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_FIXEDTEXT))
|
|
|
|
return OBJ_FM_FIXEDTEXT;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_LISTBOX))
|
|
|
|
return OBJ_FM_LISTBOX;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_CHECKBOX))
|
|
|
|
return OBJ_FM_CHECKBOX;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_RADIOBUTTON))
|
|
|
|
return OBJ_FM_RADIOBUTTON;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_GROUPBOX))
|
|
|
|
return OBJ_FM_GROUPBOX;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_COMBOBOX))
|
|
|
|
return OBJ_FM_COMBOBOX;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_GRID)) // 5.0-Name
|
|
|
|
return OBJ_FM_GRID;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_GRIDCONTROL))
|
|
|
|
return OBJ_FM_GRID;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_IMAGEBUTTON))
|
|
|
|
return OBJ_FM_IMAGEBUTTON;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_FILECONTROL))
|
|
|
|
return OBJ_FM_FILECONTROL;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_DATEFIELD))
|
|
|
|
return OBJ_FM_DATEFIELD;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_TIMEFIELD))
|
|
|
|
return OBJ_FM_TIMEFIELD;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_NUMERICFIELD))
|
|
|
|
return OBJ_FM_NUMERICFIELD;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_CURRENCYFIELD))
|
|
|
|
return OBJ_FM_CURRENCYFIELD;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_PATTERNFIELD))
|
|
|
|
return OBJ_FM_PATTERNFIELD;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_HIDDEN)) // 5.0-Name
|
|
|
|
return OBJ_FM_HIDDEN;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_HIDDENCONTROL))
|
|
|
|
return OBJ_FM_HIDDEN;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_IMAGECONTROL))
|
|
|
|
return OBJ_FM_IMAGECONTROL;
|
|
|
|
if (sPersistentServiceName.equals(FM_COMPONENT_FORMATTEDFIELD))
|
|
|
|
{
|
|
|
|
DBG_ERROR("::getControlTypeByObject : suspicious persistent service name (formatted field) !");
|
|
|
|
// objects with that service name should exist as they aren't compatible with older versions
|
|
|
|
return OBJ_FM_FORMATTEDFIELD;
|
|
|
|
}
|
2003-12-11 11:19:21 +00:00
|
|
|
if ( sPersistentServiceName.equals( FM_SUN_COMPONENT_SCROLLBAR ) )
|
|
|
|
return OBJ_FM_SCROLLBAR;
|
|
|
|
if ( sPersistentServiceName.equals( FM_SUN_COMPONENT_SPINBUTTON) )
|
|
|
|
return OBJ_FM_SPINBUTTON;
|
2004-04-13 09:59:42 +00:00
|
|
|
if (sPersistentServiceName.equals(FM_SUN_COMPONENT_NAVIGATIONBAR))
|
|
|
|
return OBJ_FM_NAVIGATIONBAR;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
DBG_ERROR("::getControlTypeByObject : unknown object type !");
|
|
|
|
return OBJ_FM_CONTROL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString getServiceNameByControlType(sal_Int16 nType)
|
|
|
|
{
|
|
|
|
switch (nType)
|
|
|
|
{
|
|
|
|
case OBJ_FM_EDIT : return FM_COMPONENT_TEXTFIELD;
|
|
|
|
case OBJ_FM_BUTTON : return FM_COMPONENT_COMMANDBUTTON;
|
|
|
|
case OBJ_FM_FIXEDTEXT : return FM_COMPONENT_FIXEDTEXT;
|
|
|
|
case OBJ_FM_LISTBOX : return FM_COMPONENT_LISTBOX;
|
|
|
|
case OBJ_FM_CHECKBOX : return FM_COMPONENT_CHECKBOX;
|
|
|
|
case OBJ_FM_RADIOBUTTON : return FM_COMPONENT_RADIOBUTTON;
|
|
|
|
case OBJ_FM_GROUPBOX : return FM_COMPONENT_GROUPBOX;
|
|
|
|
case OBJ_FM_COMBOBOX : return FM_COMPONENT_COMBOBOX;
|
|
|
|
case OBJ_FM_GRID : return FM_COMPONENT_GRIDCONTROL;
|
|
|
|
case OBJ_FM_IMAGEBUTTON : return FM_COMPONENT_IMAGEBUTTON;
|
|
|
|
case OBJ_FM_FILECONTROL : return FM_COMPONENT_FILECONTROL;
|
|
|
|
case OBJ_FM_DATEFIELD : return FM_COMPONENT_DATEFIELD;
|
|
|
|
case OBJ_FM_TIMEFIELD : return FM_COMPONENT_TIMEFIELD;
|
|
|
|
case OBJ_FM_NUMERICFIELD : return FM_COMPONENT_NUMERICFIELD;
|
|
|
|
case OBJ_FM_CURRENCYFIELD : return FM_COMPONENT_CURRENCYFIELD;
|
|
|
|
case OBJ_FM_PATTERNFIELD : return FM_COMPONENT_PATTERNFIELD;
|
|
|
|
case OBJ_FM_HIDDEN : return FM_COMPONENT_HIDDENCONTROL;
|
|
|
|
case OBJ_FM_IMAGECONTROL : return FM_COMPONENT_IMAGECONTROL;
|
|
|
|
case OBJ_FM_FORMATTEDFIELD : return FM_COMPONENT_FORMATTEDFIELD;
|
2003-12-11 11:19:21 +00:00
|
|
|
case OBJ_FM_SCROLLBAR : return FM_SUN_COMPONENT_SCROLLBAR;
|
|
|
|
case OBJ_FM_SPINBUTTON : return FM_SUN_COMPONENT_SPINBUTTON;
|
2004-04-13 09:59:42 +00:00
|
|
|
case OBJ_FM_NAVIGATIONBAR : return FM_SUN_COMPONENT_NAVIGATIONBAR;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return ::rtl::OUString();
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
Sequence< ::rtl::OUString> getEventMethods(const Type& type)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getEventMethods" );
|
2000-09-18 16:07:07 +00:00
|
|
|
typelib_InterfaceTypeDescription *pType=0;
|
|
|
|
type.getDescription( (typelib_TypeDescription**)&pType);
|
|
|
|
|
|
|
|
if(!pType)
|
2000-11-06 06:19:53 +00:00
|
|
|
return Sequence< ::rtl::OUString>();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-06 06:19:53 +00:00
|
|
|
Sequence< ::rtl::OUString> aNames(pType->nMembers);
|
2000-09-18 16:07:07 +00:00
|
|
|
::rtl::OUString* pNames = aNames.getArray();
|
|
|
|
for(sal_Int32 i=0;i<pType->nMembers;i++,++pNames)
|
|
|
|
{
|
2000-11-24 13:38:27 +00:00
|
|
|
// the decription reference
|
|
|
|
typelib_TypeDescriptionReference* pMemberDescriptionReference = pType->ppMembers[i];
|
|
|
|
// the description for the reference
|
|
|
|
typelib_TypeDescription* pMemberDescription = NULL;
|
|
|
|
typelib_typedescriptionreference_getDescription(&pMemberDescription, pMemberDescriptionReference);
|
|
|
|
if (pMemberDescription)
|
|
|
|
{
|
|
|
|
typelib_InterfaceMemberTypeDescription* pRealMemberDescription =
|
|
|
|
reinterpret_cast<typelib_InterfaceMemberTypeDescription*>(pMemberDescription);
|
|
|
|
*pNames = pRealMemberDescription->pMemberName;
|
|
|
|
}
|
2001-05-11 15:07:05 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
typelib_typedescription_release( (typelib_TypeDescription *)pType );
|
|
|
|
return aNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
void TransferEventScripts(const Reference< ::com::sun::star::awt::XControlModel>& xModel, const Reference< ::com::sun::star::awt::XControl>& xControl,
|
|
|
|
const Sequence< ::com::sun::star::script::ScriptEventDescriptor>& rTransferIfAvailable)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::TransferEventScripts" );
|
2000-09-18 16:07:07 +00:00
|
|
|
// first check if we have a XEventAttacherManager for the model
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::container::XChild> xModelChild(xModel, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!xModelChild.is())
|
|
|
|
return; // nothing to do
|
|
|
|
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::script::XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!xEventManager.is())
|
|
|
|
return; // nothing to do
|
|
|
|
|
|
|
|
if (!rTransferIfAvailable.getLength())
|
|
|
|
return; // nothing to do
|
|
|
|
|
|
|
|
// check for the index of the model within it's parent
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::container::XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!xParentIndex.is())
|
|
|
|
return; // nothing to do
|
|
|
|
sal_Int32 nIndex = getElementPos(xParentIndex, xModel);
|
|
|
|
if (nIndex<0 || nIndex>=xParentIndex->getCount())
|
|
|
|
return; // nothing to do
|
|
|
|
|
|
|
|
// then we need informations about the listeners supported by the control and the model
|
2000-11-06 06:19:53 +00:00
|
|
|
Sequence< Type> aModelListeners;
|
|
|
|
Sequence< Type> aControlListeners;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::beans::XIntrospection> xModelIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY);
|
|
|
|
Reference< ::com::sun::star::beans::XIntrospection> xControlIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (xModelIntrospection.is() && xModel.is())
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Any aModel(makeAny(xModel));
|
2000-09-18 16:07:07 +00:00
|
|
|
aModelListeners = xModelIntrospection->inspect(aModel)->getSupportedListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xControlIntrospection.is() && xControl.is())
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Any aControl(makeAny(xControl));
|
2000-09-18 16:07:07 +00:00
|
|
|
aControlListeners = xControlIntrospection->inspect(aControl)->getSupportedListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength();
|
|
|
|
if (!nMaxNewLen)
|
|
|
|
return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos)
|
|
|
|
|
2000-11-06 06:19:53 +00:00
|
|
|
Sequence< ::com::sun::star::script::ScriptEventDescriptor> aTransferable(nMaxNewLen);
|
2000-09-18 16:07:07 +00:00
|
|
|
::com::sun::star::script::ScriptEventDescriptor* pTransferable = aTransferable.getArray();
|
|
|
|
|
|
|
|
const ::com::sun::star::script::ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray();
|
|
|
|
sal_Int32 i,j,k;
|
|
|
|
for (i=0; i<rTransferIfAvailable.getLength(); ++i, ++pCurrent)
|
|
|
|
{
|
|
|
|
// search the model/control idl classes for the event described by pCurrent
|
2000-11-06 06:19:53 +00:00
|
|
|
for ( Sequence< Type>* pCurrentArray = &aModelListeners;
|
2000-09-18 16:07:07 +00:00
|
|
|
pCurrentArray;
|
|
|
|
pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL
|
|
|
|
)
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
const Type* pCurrentListeners = pCurrentArray->getConstArray();
|
2000-09-18 16:07:07 +00:00
|
|
|
for (j=0; j<pCurrentArray->getLength(); ++j, ++pCurrentListeners)
|
|
|
|
{
|
|
|
|
UniString aListener = (*pCurrentListeners).getTypeName();
|
2006-10-12 11:46:59 +00:00
|
|
|
xub_StrLen nTokens = aListener.GetTokenCount('.');
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nTokens)
|
|
|
|
aListener = aListener.GetToken(nTokens - 1, '.');
|
|
|
|
|
|
|
|
if (aListener == pCurrent->ListenerType.getStr())
|
|
|
|
// the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners class
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// now check the methods
|
2000-11-06 06:19:53 +00:00
|
|
|
Sequence< ::rtl::OUString> aMethodsNames = getEventMethods(*pCurrentListeners);
|
2000-09-18 16:07:07 +00:00
|
|
|
const ::rtl::OUString* pMethodsNames = aMethodsNames.getConstArray();
|
|
|
|
for (k=0; k<aMethodsNames.getLength(); ++k, ++pMethodsNames)
|
|
|
|
{
|
|
|
|
if ((*pMethodsNames).compareTo(pCurrent->EventMethod) != COMPARE_EQUAL)
|
|
|
|
// the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners current method
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// we can transfer the script event : the model (control) supports it
|
|
|
|
*pTransferable = *pCurrent;
|
|
|
|
++pTransferable;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (k<aMethodsNames.getLength())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray();
|
|
|
|
aTransferable.realloc(nRealNewLen);
|
|
|
|
|
|
|
|
xEventManager->registerScriptEvents(nIndex, aTransferable);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
sal_Int16 GridView2ModelPos(const Reference< ::com::sun::star::container::XIndexAccess>& rColumns, sal_Int16 nViewPos)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::GridView2ModelPos" );
|
2000-11-07 12:16:50 +00:00
|
|
|
try
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-07 12:16:50 +00:00
|
|
|
if (rColumns.is())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-07 12:16:50 +00:00
|
|
|
// loop through all columns
|
|
|
|
sal_Int16 i;
|
|
|
|
Reference< ::com::sun::star::beans::XPropertySet> xCur;
|
|
|
|
for (i=0; i<rColumns->getCount(); ++i)
|
|
|
|
{
|
|
|
|
rColumns->getByIndex(i) >>= xCur;
|
|
|
|
if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN)))
|
2009-03-05 07:09:20 +00:00
|
|
|
{
|
2000-11-07 12:16:50 +00:00
|
|
|
// for every visible col : if nViewPos is greater zero, decrement it, else we
|
|
|
|
// have found the model position
|
|
|
|
if (!nViewPos)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
--nViewPos;
|
2009-03-05 07:09:20 +00:00
|
|
|
}
|
2000-11-07 12:16:50 +00:00
|
|
|
}
|
|
|
|
if (i<rColumns->getCount())
|
|
|
|
return i;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-11-07 12:16:50 +00:00
|
|
|
}
|
2001-07-25 12:57:12 +00:00
|
|
|
catch(const Exception&)
|
2000-11-07 12:16:50 +00:00
|
|
|
{
|
|
|
|
DBG_ERROR("GridView2ModelPos Exception occured!");
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return (sal_Int16)-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2005-01-05 11:21:33 +00:00
|
|
|
sal_Bool isLoadable( const Reference< XInterface >& _rxLoadable )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::isLoadable" );
|
2000-09-18 16:07:07 +00:00
|
|
|
// determines whether a form should be loaded or not
|
|
|
|
// if there is no datasource or connection there is no reason to load a form
|
2005-01-05 11:21:33 +00:00
|
|
|
Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY );
|
|
|
|
if ( xSet.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2005-01-05 11:21:33 +00:00
|
|
|
Reference< XConnection > xConn;
|
|
|
|
if ( OStaticDataAccessTools().isEmbeddedInDatabase( _rxLoadable.get(), xConn ) )
|
|
|
|
return sal_True;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// is there already a active connection
|
2000-11-07 12:16:50 +00:00
|
|
|
xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn;
|
2005-01-05 11:21:33 +00:00
|
|
|
if ( xConn.is() )
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
::rtl::OUString sPropertyValue;
|
|
|
|
OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue );
|
|
|
|
if ( sPropertyValue.getLength() )
|
|
|
|
return sal_True;
|
|
|
|
|
|
|
|
OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue );
|
|
|
|
if ( sPropertyValue.getLength() )
|
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2000-10-31 10:59:33 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-01-05 11:21:33 +00:00
|
|
|
DBG_ERROR( "isLoadable: caught an exception!" );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-06 06:19:53 +00:00
|
|
|
void setConnection(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, const Reference< ::com::sun::star::sdbc::XConnection>& _rxConn)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::setConnection" );
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::beans::XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xRowSetProps.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2000-11-06 06:19:53 +00:00
|
|
|
Any aConn(makeAny(_rxConn));
|
2000-09-18 16:07:07 +00:00
|
|
|
xRowSetProps->setPropertyValue(FM_PROP_ACTIVE_CONNECTION, aConn);
|
|
|
|
}
|
2000-10-31 10:59:33 +00:00
|
|
|
catch(Exception&)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
DBG_ERROR("::setConnection : could not set the connection !");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2003-03-27 14:06:05 +00:00
|
|
|
sal_Bool isRowSetAlive(const Reference< XInterface >& _rxRowSet)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-04-23 10:42:05 +00:00
|
|
|
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::isRowSetAlive" );
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_Bool bIsAlive = sal_False;
|
2000-11-06 06:19:53 +00:00
|
|
|
Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSupplyCols(_rxRowSet, UNO_QUERY);
|
|
|
|
Reference< ::com::sun::star::container::XIndexAccess> xCols;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xSupplyCols.is())
|
2000-11-06 06:19:53 +00:00
|
|
|
xCols = Reference< ::com::sun::star::container::XIndexAccess>(xSupplyCols->getColumns(), UNO_QUERY);
|
2000-09-18 16:07:07 +00:00
|
|
|
if (xCols.is() && (xCols->getCount() > 0))
|
|
|
|
bIsAlive = sal_True;
|
|
|
|
|
|
|
|
return bIsAlive;
|
|
|
|
}
|
|
|
|
|