2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
#include "Pattern.hxx"
|
2013-06-03 08:34:09 +02:00
|
|
|
#include "comphelper/processfactory.hxx"
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
//.........................................................................
|
|
|
|
namespace frm
|
|
|
|
{
|
|
|
|
//.........................................................................
|
2007-11-01 13:55:41 +00:00
|
|
|
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::lang::XMultiServiceFactory;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
using ::com::sun::star::uno::Type;
|
2013-06-03 08:34:09 +02:00
|
|
|
using ::com::sun::star::uno::XComponentContext;
|
2007-11-01 13:55:41 +00:00
|
|
|
using ::com::sun::star::beans::Property;
|
|
|
|
using ::com::sun::star::uno::Exception;
|
|
|
|
using ::com::sun::star::uno::XInterface;
|
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
using ::com::sun::star::uno::makeAny;
|
|
|
|
using ::com::sun::star::sdbc::XRowSet;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY;
|
2013-04-01 18:45:57 +02:00
|
|
|
|
2007-11-01 13:55:41 +00:00
|
|
|
namespace FormComponentType = ::com::sun::star::form::FormComponentType;
|
2000-09-18 15:33:13 +00:00
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
// OPatternControl
|
|
|
|
//==================================================================
|
|
|
|
//------------------------------------------------------------------
|
2013-06-03 08:34:09 +02:00
|
|
|
OPatternControl::OPatternControl(const Reference<XComponentContext>& _rxFactory)
|
2000-09-18 15:33:13 +00:00
|
|
|
:OBoundControl(_rxFactory, VCL_CONTROL_PATTERNFIELD)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------
|
2000-11-23 07:48:15 +00:00
|
|
|
InterfaceRef SAL_CALL OPatternControl_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2013-06-03 08:34:09 +02:00
|
|
|
return *(new OPatternControl( comphelper::getComponentContext(_rxFactory) ));
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 07:48:15 +00:00
|
|
|
Sequence<Type> OPatternControl::_getTypes()
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
|
|
|
return OBoundControl::_getTypes();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
StringSequence OPatternControl::getSupportedServiceNames() throw()
|
|
|
|
{
|
|
|
|
StringSequence aSupported = OBoundControl::getSupportedServiceNames();
|
|
|
|
aSupported.realloc(aSupported.getLength() + 1);
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString*pArray = aSupported.getArray();
|
2000-09-18 15:33:13 +00:00
|
|
|
pArray[aSupported.getLength()-1] = FRM_SUN_CONTROL_PATTERNFIELD;
|
|
|
|
return aSupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
// OPatternModel
|
|
|
|
//==================================================================
|
|
|
|
//------------------------------------------------------------------
|
2000-11-23 07:48:15 +00:00
|
|
|
InterfaceRef SAL_CALL OPatternModel_CreateInstance(const Reference<XMultiServiceFactory>& _rxFactory)
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2013-06-03 08:34:09 +02:00
|
|
|
return *(new OPatternModel( comphelper::getComponentContext(_rxFactory) ));
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2000-11-23 07:48:15 +00:00
|
|
|
Sequence<Type> OPatternModel::_getTypes()
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
|
|
|
return OEditBaseModel::_getTypes();
|
|
|
|
}
|
|
|
|
|
2002-12-02 08:56:36 +00:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
DBG_NAME( OPatternModel )
|
2000-09-18 15:33:13 +00:00
|
|
|
//------------------------------------------------------------------
|
2013-06-03 08:34:09 +02:00
|
|
|
OPatternModel::OPatternModel(const Reference<XComponentContext>& _rxFactory)
|
2004-05-10 11:46:56 +00:00
|
|
|
:OEditBaseModel( _rxFactory, VCL_CONTROLMODEL_PATTERNFIELD, FRM_SUN_CONTROL_PATTERNFIELD, sal_False, sal_False )
|
2000-09-18 15:33:13 +00:00
|
|
|
// use the old control name for compytibility reasons
|
|
|
|
{
|
2002-12-02 08:56:36 +00:00
|
|
|
DBG_CTOR( OPatternModel, NULL );
|
|
|
|
|
2000-11-23 07:48:15 +00:00
|
|
|
m_nClassId = FormComponentType::PATTERNFIELD;
|
2003-10-21 07:59:46 +00:00
|
|
|
initValueProperty( PROPERTY_TEXT, PROPERTY_ID_TEXT );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
2002-12-02 08:56:36 +00:00
|
|
|
//------------------------------------------------------------------
|
2013-06-03 08:34:09 +02:00
|
|
|
OPatternModel::OPatternModel( const OPatternModel* _pOriginal, const Reference<XComponentContext>& _rxFactory )
|
2002-12-02 08:56:36 +00:00
|
|
|
:OEditBaseModel( _pOriginal, _rxFactory )
|
|
|
|
{
|
|
|
|
DBG_CTOR( OPatternModel, NULL );
|
|
|
|
}
|
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
//------------------------------------------------------------------
|
|
|
|
OPatternModel::~OPatternModel()
|
|
|
|
{
|
2002-12-02 08:56:36 +00:00
|
|
|
DBG_DTOR( OPatternModel, NULL );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
2002-12-02 08:56:36 +00:00
|
|
|
// XCloneable
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_DEFAULT_CLONING( OPatternModel )
|
|
|
|
|
2000-11-23 07:48:15 +00:00
|
|
|
// XServiceInfo
|
2000-09-18 15:33:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
StringSequence SAL_CALL OPatternModel::getSupportedServiceNames() throw()
|
|
|
|
{
|
|
|
|
StringSequence aSupported = OBoundControlModel::getSupportedServiceNames();
|
|
|
|
aSupported.realloc(aSupported.getLength() + 2);
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString*pArray = aSupported.getArray();
|
2002-03-04 13:49:12 +00:00
|
|
|
pArray[aSupported.getLength()-2] = FRM_SUN_COMPONENT_DATABASE_PATTERNFIELD;
|
2000-09-18 15:33:13 +00:00
|
|
|
pArray[aSupported.getLength()-1] = FRM_SUN_COMPONENT_PATTERNFIELD;
|
|
|
|
return aSupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-03-09 12:30:52 +00:00
|
|
|
void OPatternModel::describeFixedProperties( Sequence< Property >& _rProps ) const
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2004-04-02 09:55:08 +00:00
|
|
|
BEGIN_DESCRIBE_PROPERTIES( 4, OEditBaseModel )
|
2013-04-07 12:06:47 +02:00
|
|
|
DECL_PROP2(DEFAULT_TEXT, OUString, BOUND, MAYBEDEFAULT);
|
2000-09-18 15:33:13 +00:00
|
|
|
DECL_BOOL_PROP1(EMPTY_IS_NULL, BOUND);
|
|
|
|
DECL_PROP1(TABINDEX, sal_Int16, BOUND);
|
|
|
|
DECL_PROP2(FILTERPROPOSAL, sal_Bool, BOUND, MAYBEDEFAULT);
|
2004-04-02 09:55:08 +00:00
|
|
|
END_DESCRIBE_PROPERTIES();
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString SAL_CALL OPatternModel::getServiceName() throw ( ::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2013-04-23 11:48:24 +02:00
|
|
|
return OUString(FRM_COMPONENT_PATTERNFIELD); // old (non-sun) name for compatibility !
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2006-06-19 11:52:48 +00:00
|
|
|
sal_Bool OPatternModel::commitControlValueToDbColumn( bool /*_bPostReset*/ )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2008-12-01 12:31:27 +00:00
|
|
|
Any aNewValue( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) );
|
2003-10-21 07:59:46 +00:00
|
|
|
|
2008-12-01 12:31:27 +00:00
|
|
|
if ( aNewValue != m_aLastKnownValue )
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sNewValue;
|
2008-12-01 12:31:27 +00:00
|
|
|
aNewValue >>= sNewValue;
|
|
|
|
|
|
|
|
if ( !aNewValue.hasValue()
|
2011-12-26 15:08:46 -02:00
|
|
|
|| ( sNewValue.isEmpty() // an empty string
|
2008-12-01 12:31:27 +00:00
|
|
|
&& m_bEmptyIsNull // which should be interpreted as NULL
|
|
|
|
)
|
|
|
|
)
|
|
|
|
{
|
2000-09-18 15:33:13 +00:00
|
|
|
m_xColumnUpdate->updateNull();
|
2008-12-01 12:31:27 +00:00
|
|
|
}
|
2000-09-18 15:33:13 +00:00
|
|
|
else
|
|
|
|
{
|
2007-11-01 13:55:41 +00:00
|
|
|
OSL_ENSURE( m_pFormattedValue.get(), "OPatternModel::commitControlValueToDbColumn: no value helper!" );
|
|
|
|
if ( !m_pFormattedValue.get() )
|
|
|
|
return sal_False;
|
|
|
|
|
|
|
|
if ( !m_pFormattedValue->setFormattedValue( sNewValue ) )
|
2000-09-18 15:33:13 +00:00
|
|
|
return sal_False;
|
|
|
|
}
|
2008-12-01 12:31:27 +00:00
|
|
|
|
|
|
|
m_aLastKnownValue = aNewValue;
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
2008-12-01 12:31:27 +00:00
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2007-11-01 13:55:41 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OPatternModel::onConnectedDbColumn( const Reference< XInterface >& _rxForm )
|
|
|
|
{
|
|
|
|
OEditBaseModel::onConnectedDbColumn( _rxForm );
|
|
|
|
|
|
|
|
Reference< XPropertySet > xField( getField() );
|
|
|
|
if ( !xField.is() )
|
|
|
|
return;
|
|
|
|
|
2013-06-03 08:34:09 +02:00
|
|
|
m_pFormattedValue.reset( new ::dbtools::FormattedColumnValue( getContext(), Reference< XRowSet >( _rxForm, UNO_QUERY ), xField ) );
|
2007-11-01 13:55:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OPatternModel::onDisconnectedDbColumn()
|
|
|
|
{
|
|
|
|
OEditBaseModel::onDisconnectedDbColumn();
|
|
|
|
m_pFormattedValue.reset();
|
|
|
|
}
|
|
|
|
|
2000-11-23 07:48:15 +00:00
|
|
|
// XPropertyChangeListener
|
2000-09-18 15:33:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2003-10-21 07:59:46 +00:00
|
|
|
Any OPatternModel::translateDbColumnToControlValue()
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2007-11-01 13:55:41 +00:00
|
|
|
OSL_PRECOND( m_pFormattedValue.get(), "OPatternModel::translateDbColumnToControlValue: no value helper!" );
|
2008-12-01 12:31:27 +00:00
|
|
|
|
2007-11-01 13:55:41 +00:00
|
|
|
if ( m_pFormattedValue.get() )
|
2008-12-01 12:31:27 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString sValue( m_pFormattedValue->getFormattedValue() );
|
2011-12-26 15:08:46 -02:00
|
|
|
if ( sValue.isEmpty()
|
2008-12-01 12:31:27 +00:00
|
|
|
&& m_pFormattedValue->getColumn().is()
|
|
|
|
&& m_pFormattedValue->getColumn()->wasNull()
|
|
|
|
)
|
|
|
|
{
|
|
|
|
m_aLastKnownValue.clear();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_aLastKnownValue <<= sValue;
|
|
|
|
}
|
|
|
|
}
|
2007-11-01 13:55:41 +00:00
|
|
|
else
|
2008-12-01 12:31:27 +00:00
|
|
|
m_aLastKnownValue.clear();
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
return m_aLastKnownValue.hasValue() ? m_aLastKnownValue : makeAny( OUString() );
|
2008-12-01 12:31:27 +00:00
|
|
|
// (m_aLastKnownValue is alllowed to be VOID, the control value isn't)
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
2000-11-23 07:48:15 +00:00
|
|
|
// XReset
|
2000-09-18 15:33:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2003-10-21 07:59:46 +00:00
|
|
|
Any OPatternModel::getDefaultForReset() const
|
2000-09-18 15:33:13 +00:00
|
|
|
{
|
2003-10-21 07:59:46 +00:00
|
|
|
return makeAny( m_aDefaultText );
|
2000-09-18 15:33:13 +00:00
|
|
|
}
|
|
|
|
|
CWS-TOOLING: integrate CWS dba32j
2009-11-26 09:30:10 +0100 msc r277648 : #100000 fix urgent testscript error
2009-11-25 10:27:56 +0100 msc r277625 : #i100000 fix urgent testscript error
2009-11-17 22:16:46 +0100 fs r277544 : CWS-TOOLING: rebase CWS dba32j to branches/OOO320@277531 (milestone: OOO320:m5)
2009-11-17 14:26:47 +0100 fs r277535 : ooops, didn't mean to commit this uncommented line
2009-11-14 20:50:29 +0100 fs r277505 : add a --disable-pango switch to SM's configure options, and add a patch which makes certain code respect it (well, respect it better than currently, by not using some pango_x_* functions, which are not always available, even when pango itself is present)
2009-11-14 20:47:41 +0100 fs r277504 : spelling
2009-11-13 14:04:00 +0100 fs r277502 : #i100764# (commit approved by ab@openoffice.org): getModelFromBasic: do not start with the parent's parent when looking for ThisComponent, but walk up the anchestor chain, starting with the immediate parent
2009-11-13 11:04:15 +0100 fs r277496 : #i100764# better heuristics for determining whether or not to participate in the ThisComponent game
2009-11-13 11:02:30 +0100 fs r277495 : #i100764# set the WB_EXT_DOCUMENT style at the backing component's container window, when creating it without the TaskCreator (which would normally do this)
2009-11-11 13:49:11 +0100 fs r277452 : #i106816#
2009-11-11 13:48:53 +0100 fs r277451 : fix the CREATETARBAL target, which is expected to create the zips used as prebuilts. The *inc.zip missed the NSS files in case NSS was built externally
2009-11-11 12:15:34 +0100 fs r277449 : update ignore list
2009-11-11 12:09:23 +0100 fs r277448 : add a link to the Mozilla build tools download location
2009-11-11 12:07:16 +0100 fs r277447 : add a link to the Mozilla build tools download location
2009-11-06 16:23:12 +0100 fs r277393 : #i106643#
2009-11-03 23:20:29 +0100 fs r277328 : #i106574#
reverted the recent fix for issue #i105235#, and implemented a better one.
2009-11-02 12:59:48 +0100 fs r277294 : #i106550# errorOccured: also display the error when we're not in a nested form action - form actions are allowed to be triggered by other instances as well
2009-12-01 09:53:35 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OPatternModel::resetNoBroadcast()
|
|
|
|
{
|
|
|
|
OEditBaseModel::resetNoBroadcast();
|
|
|
|
m_aLastKnownValue.clear();
|
|
|
|
}
|
|
|
|
|
2000-09-18 15:33:13 +00:00
|
|
|
//.........................................................................
|
|
|
|
} // namespace frm
|
|
|
|
//.........................................................................
|
|
|
|
|
2010-10-12 15:57:08 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|